├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── sjes │ │ └── dzfp │ │ ├── InvoiceApplication.java │ │ ├── ResponseBody │ │ └── ResponseMessage.java │ │ ├── controller │ │ └── InvoiceController.java │ │ ├── domain │ │ ├── mongo │ │ │ ├── InvocieOpenInfo.java │ │ │ └── InvoiceErroInfo.java │ │ └── tt.java │ │ ├── model │ │ ├── invoice │ │ │ ├── BodyModel.java │ │ │ ├── ContentData.java │ │ │ ├── GlobalInfo.java │ │ │ ├── InvoiceUtils.java │ │ │ ├── invoiceFlushRed │ │ │ │ ├── InvoiceFlushRedReq.java │ │ │ │ └── InvoiceFlushRedRes.java │ │ │ ├── invoiceMail │ │ │ │ ├── InvoiceMailReq.java │ │ │ │ └── InvoiceMailRes.java │ │ │ ├── invoiceOpen │ │ │ │ ├── InvoiceOpenReq.java │ │ │ │ └── InvoiceOpenRes.java │ │ │ ├── invoiceSearch │ │ │ │ ├── InvoiceSearchReq.java │ │ │ │ ├── InvoiceSearchRes.java │ │ │ │ ├── OUTSTR.java │ │ │ │ └── OUTSTRS.java │ │ │ ├── orderInvoiceSearch │ │ │ │ └── OrderInvoiceSearchRes.java │ │ │ └── orderSerach │ │ │ │ ├── FPKJXX_FPTXX.java │ │ │ │ ├── FPKJXX_XMXX.java │ │ │ │ ├── FPKJXX_XMXXS.java │ │ │ │ ├── OrderSearchRes.java │ │ │ │ └── REQUEST_FPKJXX.java │ │ └── tt.java │ │ ├── repository │ │ ├── mongo │ │ │ ├── InvocieOpenInfoRepository.java │ │ │ └── InvoiceErroInfoRepository.java │ │ └── tt.java │ │ ├── service │ │ ├── invoice │ │ │ ├── InvoiceService.java │ │ │ └── impl │ │ │ │ └── InvoiceServiceImpl.java │ │ └── tt.java │ │ └── utils │ │ ├── Base64Utils.java │ │ └── XmlUtils.java └── resources │ ├── application-dev.yml │ ├── application-production.yml │ ├── application.yml │ └── logback-spring.xml └── test └── java └── sjes └── dzfp └── InvoiceApplicationTests.java /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wujianlonglong/dzfp/9cbabaaea8538caa03aa1091e2a78d6495a147c2/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip 2 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Migwn, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 204 | echo $MAVEN_PROJECTBASEDIR 205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 206 | 207 | # For Cygwin, switch paths to Windows format before running java 208 | if $cygwin; then 209 | [ -n "$M2_HOME" ] && 210 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 211 | [ -n "$JAVA_HOME" ] && 212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 213 | [ -n "$CLASSPATH" ] && 214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 215 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 217 | fi 218 | 219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 220 | 221 | exec "$JAVACMD" \ 222 | $MAVEN_OPTS \ 223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 226 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 84 | @REM Fallback to current working directory if not found. 85 | 86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 88 | 89 | set EXEC_DIR=%CD% 90 | set WDIR=%EXEC_DIR% 91 | :findBaseDir 92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 93 | cd .. 94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 95 | set WDIR=%CD% 96 | goto findBaseDir 97 | 98 | :baseDirFound 99 | set MAVEN_PROJECTBASEDIR=%WDIR% 100 | cd "%EXEC_DIR%" 101 | goto endDetectBaseDir 102 | 103 | :baseDirNotFound 104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 105 | cd "%EXEC_DIR%" 106 | 107 | :endDetectBaseDir 108 | 109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 110 | 111 | @setlocal EnableExtensions EnableDelayedExpansion 112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 114 | 115 | :endReadAdditionalConfig 116 | 117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 118 | 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 123 | if ERRORLEVEL 1 goto error 124 | goto end 125 | 126 | :error 127 | set ERROR_CODE=1 128 | 129 | :end 130 | @endlocal & set ERROR_CODE=%ERROR_CODE% 131 | 132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 136 | :skipRcPost 137 | 138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 140 | 141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 142 | 143 | exit /B %ERROR_CODE% 144 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.sanjiang 7 | invoice 8 | 1.0.0-SNAPSHOT 9 | jar 10 | 11 | invoice 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.5.10.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | Edgware.SR2 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-data-mongodb 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-web 36 | 37 | 38 | org.springframework.cloud 39 | spring-cloud-starter-eureka 40 | 41 | 42 | 43 | org.projectlombok 44 | lombok 45 | true 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-test 50 | test 51 | 52 | 53 | org.apache.cxf 54 | cxf-rt-frontend-jaxws 55 | 3.1.6 56 | 57 | 58 | org.apache.cxf 59 | cxf-rt-transports-http 60 | 3.1.6 61 | 62 | 63 | net.logstash.logback 64 | logstash-logback-encoder 65 | 4.11 66 | 67 | 68 | net.sourceforge.nekohtml 69 | nekohtml 70 | 1.9.22 71 | 72 | 73 | 74 | 75 | 76 | 77 | org.springframework.cloud 78 | spring-cloud-dependencies 79 | ${spring-cloud.version} 80 | pom 81 | import 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | org.springframework.boot 90 | spring-boot-maven-plugin 91 | 92 | true 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/InvoiceApplication.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.scheduling.annotation.EnableAsync; 7 | 8 | @SpringBootApplication 9 | @EnableDiscoveryClient 10 | @EnableAsync 11 | public class InvoiceApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(InvoiceApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/ResponseBody/ResponseMessage.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.ResponseBody; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.io.Serializable; 9 | 10 | @Component 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class ResponseMessage implements Serializable { 15 | 16 | private int code = 0; 17 | 18 | private String message; 19 | 20 | private T data; 21 | 22 | public static ResponseMessage defaultSuccess(T data) { 23 | return new ResponseMessage(1, "", data); 24 | } 25 | 26 | public static ResponseMessage success(int code, T data) { 27 | return new ResponseMessage(code, "", data); 28 | } 29 | 30 | public void setSuccess(int code, T data) { 31 | this.code = code; 32 | this.data = data; 33 | } 34 | 35 | public void setFailure(int code, String message, T data) { 36 | this.code = code; 37 | this.message = message; 38 | this.data = data; 39 | } 40 | 41 | 42 | public static ResponseMessage success(int code, String message) { 43 | return new ResponseMessage(code, message, null); 44 | } 45 | 46 | public static ResponseMessage defaultFailure(String message, T data) { 47 | return new ResponseMessage(0, message, data); 48 | } 49 | 50 | public static ResponseMessage defaultFailure(T data) { 51 | return new ResponseMessage(0, "", data); 52 | } 53 | 54 | public static ResponseMessage failure(int code, String message, T data) { 55 | return new ResponseMessage(code, message, data); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/controller/InvoiceController.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.controller; 2 | 3 | import sjes.dzfp.ResponseBody.ResponseMessage; 4 | import sjes.dzfp.model.invoice.orderInvoiceSearch.OrderInvoiceSearchRes; 5 | import sjes.dzfp.service.invoice.InvoiceService; 6 | import org.apache.commons.lang.StringUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.*; 9 | import sun.misc.BASE64Decoder; 10 | 11 | import javax.servlet.ServletOutputStream; 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | import java.io.IOException; 15 | import java.io.OutputStream; 16 | 17 | @RestController 18 | @RequestMapping("/invoice") 19 | @CrossOrigin("*") 20 | public class InvoiceController { 21 | 22 | @Autowired 23 | private InvoiceService invoiceService; 24 | 25 | /** 26 | * 开票 27 | * 28 | * @param searchNo 查询序列号 29 | * @param invoiceHead 发票抬头 30 | */ 31 | 32 | /** 33 | * 开票 34 | * 35 | * @param searchNo 查询序列号 36 | * @param invoiceType 1单位 2个人 37 | * @param invoiceHead 发票抬头 38 | * @param nsrNo 税号 39 | * @param address 地址 40 | * @param mobile 手机 41 | * @param bankNo 银行卡号 42 | * @return 43 | */ 44 | @RequestMapping(value = "/invoiceOpen") 45 | public ResponseMessage invoiceOpen(@RequestParam(name = "searchNo", required = false) String searchNo, 46 | @RequestParam(name = "invoiceType", required = false) Integer invoiceType, 47 | @RequestParam(name = "invoiceHead", required = false) String invoiceHead, 48 | @RequestParam(name = "nsrNo", required = false) String nsrNo, 49 | @RequestParam(name = "address", required = false) String address, 50 | @RequestParam(name = "mobile", required = false) String mobile, 51 | @RequestParam(name = "bankNo", required = false) String bankNo) { 52 | return invoiceService.invoiceOpen(searchNo, invoiceType, invoiceHead, nsrNo, address, mobile, bankNo); 53 | } 54 | 55 | 56 | /** 57 | * 发票查询 58 | * 59 | * @param invoiceStream 60 | * @param invoiceCode 61 | * @param invoiceNo 62 | */ 63 | @RequestMapping(value = "/invoiceSearch", method = RequestMethod.GET) 64 | public ResponseMessage invoiceSearch(@RequestParam(name = "invoiceStream", required = false) String invoiceStream, @RequestParam(name = "invoiceCode", required = false) String invoiceCode, @RequestParam(name = "invoiceNo", required = false) String invoiceNo) { 65 | return invoiceService.invoiceSearch(invoiceStream, invoiceCode, invoiceNo); 66 | } 67 | 68 | 69 | /** 70 | * 发票冲红 71 | * 72 | * @param invoiceStream 发票流水号 73 | * @param taxpayerCode 纳税人编号 74 | * @param orderStream 订单流水号 75 | */ 76 | @RequestMapping(value = "/invoiceFlushRed") 77 | public ResponseMessage invoiceFlushRed(@RequestParam(name = "invoiceStream", required = false) String invoiceStream, @RequestParam(name = "taxpayerCode", required = false) String taxpayerCode, @RequestParam(name = "orderStream", required = false) String orderStream) { 78 | return invoiceService.invoiceFlushRed(invoiceStream, taxpayerCode, orderStream); 79 | } 80 | 81 | 82 | /** 83 | * 订单查询 84 | * 85 | * @param searchNo 查询序列号 86 | * @return 87 | */ 88 | @RequestMapping(value = "/orderSerach") 89 | public ResponseMessage orderSerach(@RequestParam(name = "searchNo", required = false) String searchNo) { 90 | if (StringUtils.isEmpty(searchNo)) { 91 | return ResponseMessage.failure(-1, "订单查询失败:查询号码不能为空", null); 92 | } 93 | return invoiceService.orderSerach(searchNo); 94 | } 95 | 96 | /** 97 | * 订单和发票查询 98 | * 99 | * @param searchNo 查询序列号 100 | * @return 101 | */ 102 | @RequestMapping(value = "/orderAndInvoiceSearch") 103 | public ResponseMessage orderAndInvoiceSearch(@RequestParam(name = "searchNo", required = false) String searchNo) { 104 | if (StringUtils.isEmpty(searchNo)) { 105 | return ResponseMessage.failure(-1, "订单查询失败:查询号码不能为空", null); 106 | } 107 | return invoiceService.orderAndInvoiceSearch(searchNo); 108 | } 109 | 110 | 111 | /** 112 | * 发送发票邮箱 113 | * 114 | * @param mail 邮箱地址 115 | * @param searchNo 查询序列号 116 | * @return 117 | */ 118 | @RequestMapping(value = "/mailSend") 119 | public ResponseMessage mailSend(@RequestParam(name = "mail", required = false) String mail, @RequestParam(name = "searchNo", required = false) String searchNo) { 120 | return invoiceService.mailSend(mail, searchNo); 121 | } 122 | 123 | 124 | /** 125 | * 查询发票图片 126 | * 127 | * @param searchNo 查询序列号 128 | * @param request 129 | * @param response 130 | * @return 131 | */ 132 | @RequestMapping(value = "/pic") 133 | public String viewSignatureImage(@RequestParam(name = "searchNo", required = false) String searchNo, HttpServletRequest request, HttpServletResponse response) throws IOException { 134 | ResponseMessage res = invoiceService.orderAndInvoiceSearch(searchNo); 135 | OrderInvoiceSearchRes invoiceSearchRes = (OrderInvoiceSearchRes) res.getData(); 136 | String jpg = ""; 137 | if (invoiceSearchRes == null || invoiceSearchRes.getOUTSTR() == null) 138 | jpg = ""; 139 | else jpg = invoiceSearchRes.getOUTSTR().getJPG_FILE(); 140 | BASE64Decoder decoder = new BASE64Decoder(); 141 | byte[] decoderBytes = decoder.decodeBuffer(jpg); 142 | response.addHeader("Access-Control-Expose-Headers","exist"); 143 | if (StringUtils.isEmpty(jpg)) 144 | response.addHeader("exist", "0"); 145 | else 146 | response.addHeader("exist", "1"); 147 | ServletOutputStream out = null; 148 | try { 149 | response.setContentType("image/jpg"); 150 | // response.addHeader("Content-Disposition", "attachment;filename=test.jpg"); 151 | out = response.getOutputStream(); 152 | out.write(decoderBytes); 153 | out.flush(); 154 | } catch (Exception e) { 155 | e.printStackTrace(); 156 | } finally { 157 | if (out != null) { 158 | try { 159 | out.close(); 160 | } catch (Exception e) { 161 | e.printStackTrace(); 162 | } 163 | } 164 | } 165 | return null; 166 | } 167 | 168 | 169 | /** 170 | * 下载发票pdf 171 | * 172 | * @param searchNo 173 | * @param request 174 | * @param response 175 | * @return 176 | * @throws IOException 177 | */ 178 | @RequestMapping(value = "/downloadPdf") 179 | public String downloadPdf(@RequestParam(name = "searchNo", required = false) String searchNo, HttpServletRequest request, HttpServletResponse response) throws IOException { 180 | ResponseMessage res = invoiceService.orderAndInvoiceSearch(searchNo); 181 | OrderInvoiceSearchRes invoiceSearchRes = (OrderInvoiceSearchRes) res.getData(); 182 | String pdf = ""; 183 | if (invoiceSearchRes == null || invoiceSearchRes.getOUTSTR() == null) 184 | pdf = ""; 185 | else pdf = invoiceSearchRes.getOUTSTR().getPDF_FILE(); 186 | BASE64Decoder base64Decoder = new BASE64Decoder(); 187 | byte[] decoderBytes = base64Decoder.decodeBuffer(pdf); 188 | OutputStream out = response.getOutputStream(); 189 | try { 190 | response.setContentType("application/pdf"); 191 | response.setHeader("Content-Disposition", "attachment;filename=" + searchNo + ".pdf"); 192 | out.write(decoderBytes); 193 | out.flush(); 194 | } catch (Exception e) { 195 | e.printStackTrace(); 196 | } finally { 197 | if (out != null) { 198 | try { 199 | out.close(); 200 | } catch (Exception e) { 201 | e.printStackTrace(); 202 | } 203 | } 204 | } 205 | 206 | return null; 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/domain/mongo/InvocieOpenInfo.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.domain.mongo; 2 | 3 | import lombok.Data; 4 | import org.springframework.data.annotation.Id; 5 | import org.springframework.data.mongodb.core.mapping.Document; 6 | 7 | @Document(collection = "InvocieOpenInfo") 8 | @Data 9 | public class InvocieOpenInfo { 10 | @Id 11 | private String id; 12 | private String searchNo; 13 | private Integer invoiceType; 14 | private String invoiceHead; 15 | private String nsrNo; 16 | private String address; 17 | private String mobile; 18 | private String bankNo; 19 | private String kpDate; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/domain/mongo/InvoiceErroInfo.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.domain.mongo; 2 | 3 | import lombok.Data; 4 | import org.springframework.data.annotation.Id; 5 | import org.springframework.data.mongodb.core.mapping.Document; 6 | 7 | @Data 8 | @Document(collection = "invoiceErroInfo") 9 | public class InvoiceErroInfo { 10 | @Id 11 | private String id; 12 | private String searchNo; 13 | private String xpls; 14 | private String type; 15 | private String erroMessage; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/domain/tt.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.domain; 2 | 3 | public class tt { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/BodyModel.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice; 2 | 3 | import javax.xml.bind.annotation.XmlElement; 4 | import javax.xml.bind.annotation.XmlRootElement; 5 | 6 | 7 | @XmlRootElement(name="interface") 8 | public class BodyModel { 9 | 10 | private GlobalInfo globalInfo; 11 | 12 | private ContentData Data; 13 | 14 | public ContentData getData(){ 15 | return Data; 16 | } 17 | @XmlElement(name="Data") 18 | public void setData(ContentData contentData){ 19 | this.Data=contentData; 20 | } 21 | 22 | public GlobalInfo getGlobalInfo(){ 23 | return globalInfo; 24 | } 25 | @XmlElement(name="globalInfo") 26 | public void setGlobalInfo(GlobalInfo globalInfo){ 27 | this.globalInfo=globalInfo; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/ContentData.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice; 2 | 3 | import lombok.Data; 4 | 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | 7 | @Data 8 | @XmlRootElement(name="Data") 9 | public class ContentData { 10 | private String content; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/GlobalInfo.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice; 2 | 3 | import lombok.Data; 4 | 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | 7 | @Data 8 | @XmlRootElement(name="globalInfo") 9 | public class GlobalInfo { 10 | private String version; 11 | 12 | private String interfaceCode; 13 | 14 | public GlobalInfo(String version, String interfaceCode) { 15 | this.version = version; 16 | this.interfaceCode = interfaceCode; 17 | } 18 | 19 | public GlobalInfo(){} 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/InvoiceUtils.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice; 2 | 3 | import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; 4 | import org.springframework.http.HttpEntity; 5 | import org.springframework.http.HttpHeaders; 6 | import org.springframework.http.MediaType; 7 | import org.springframework.web.client.RestTemplate; 8 | import sjes.dzfp.model.invoice.invoiceFlushRed.InvoiceFlushRedReq; 9 | import sjes.dzfp.model.invoice.invoiceFlushRed.InvoiceFlushRedRes; 10 | import sjes.dzfp.model.invoice.invoiceMail.InvoiceMailReq; 11 | import sjes.dzfp.model.invoice.invoiceMail.InvoiceMailRes; 12 | import sjes.dzfp.model.invoice.invoiceOpen.InvoiceOpenRes; 13 | import sjes.dzfp.model.invoice.invoiceSearch.InvoiceSearchReq; 14 | import sjes.dzfp.model.invoice.invoiceSearch.InvoiceSearchRes; 15 | import sjes.dzfp.model.invoice.orderSerach.OrderSearchRes; 16 | import sjes.dzfp.model.invoice.orderSerach.REQUEST_FPKJXX; 17 | import sjes.dzfp.utils.Base64Utils; 18 | import sjes.dzfp.utils.XmlUtils; 19 | 20 | import javax.xml.bind.JAXBException; 21 | import java.io.IOException; 22 | 23 | public class InvoiceUtils { 24 | 25 | private final static String url = "http://193.0.10.230:8121/DZFP"; 26 | 27 | private final static String orderSearchUrl = "http://193.0.10.228:8088/webservice/dzfp?wsdl"; 28 | // private final static String orderSearchUrl = "http://weixin-dev.sanjiang.com/webservice/dzfp?wsdl"; 29 | 30 | private static String version = "1.0"; 31 | 32 | private static String jskp = "DZFPKHDSC"; 33 | 34 | private static String fpcx = "DZFPCX"; 35 | 36 | private static String fpch = "DZFPCH"; 37 | 38 | private static String dzyx = "DZFPEMAIL"; 39 | 40 | /** 41 | * 发票查询 42 | * 43 | * @param invoiceSearch 44 | * @return 45 | * @throws JAXBException 46 | */ 47 | public static InvoiceSearchRes invoiceSerach(InvoiceSearchReq invoiceSearch) throws JAXBException, IOException { 48 | BodyModel body = new BodyModel(); 49 | GlobalInfo globalInfo = new GlobalInfo(version, fpcx); 50 | body.setGlobalInfo(globalInfo); 51 | ContentData data = new ContentData(); 52 | String requetBodyXml = XmlUtils.objectToXml(invoiceSearch, InvoiceSearchReq.class); 53 | requetBodyXml = Base64Utils.getBase64(requetBodyXml); 54 | data.setContent(requetBodyXml); 55 | body.setData(data); 56 | 57 | String requetAllBodyXml = XmlUtils.objectToXml(body, BodyModel.class); 58 | HttpHeaders headers = new HttpHeaders(); 59 | headers.setContentType(MediaType.APPLICATION_XML); 60 | HttpEntity entity = new HttpEntity(requetAllBodyXml, headers); 61 | RestTemplate restTemplate = new RestTemplate(); 62 | InvoiceSearchRes responseBody = restTemplate.postForObject(url, entity, InvoiceSearchRes.class); 63 | // if (responseBody.getOUTSTRS() != null && responseBody.getOUTSTRS().getOUTSTR() != null) { 64 | // String pic = responseBody.getOUTSTRS().getOUTSTR().getJPG_FILE(); 65 | // String pdf = responseBody.getOUTSTRS().getOUTSTR().getPDF_FILE(); 66 | // if (StringUtils.isNotEmpty(pic)) 67 | // Base64Utils.DecodeToFile(pic); 68 | // } 69 | 70 | return responseBody; 71 | } 72 | 73 | 74 | /** 75 | * 发票冲红 76 | * 77 | * @param invoiceFlushRedReq 78 | * @return 79 | * @throws JAXBException 80 | */ 81 | public static InvoiceFlushRedRes invoiceFlushRed(InvoiceFlushRedReq invoiceFlushRedReq) throws JAXBException { 82 | BodyModel body = new BodyModel(); 83 | GlobalInfo globalInfo = new GlobalInfo(version, fpch); 84 | body.setGlobalInfo(globalInfo); 85 | ContentData data = new ContentData(); 86 | String requetBodyXml = XmlUtils.objectToXml(invoiceFlushRedReq, InvoiceFlushRedReq.class); 87 | requetBodyXml = Base64Utils.getBase64(requetBodyXml); 88 | data.setContent(requetBodyXml); 89 | body.setData(data); 90 | 91 | String requetAllBodyXml = XmlUtils.objectToXml(body, BodyModel.class); 92 | HttpHeaders headers = new HttpHeaders(); 93 | headers.setContentType(MediaType.APPLICATION_XML); 94 | HttpEntity entity = new HttpEntity(requetAllBodyXml, headers); 95 | RestTemplate restTemplate = new RestTemplate(); 96 | InvoiceFlushRedRes responseBody = restTemplate.postForObject(url, entity, InvoiceFlushRedRes.class); 97 | return responseBody; 98 | } 99 | 100 | 101 | public static OrderSearchRes txdOrderSerachDetail(String orderNo, String orderDate) throws Exception { 102 | JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); 103 | org.apache.cxf.endpoint.Client client = dcf.createClient(orderSearchUrl); 104 | Object[] objects = client.invoke("getSaleInfo", new Object[]{"2", "", "", orderNo, orderDate}); 105 | String data = objects[0].toString(); 106 | BodyModel body = (BodyModel) XmlUtils.xmlToObject(data, BodyModel.class); 107 | String content = (String) body.getData().getContent(); 108 | String deContent = Base64Utils.getFromBase64(content); 109 | OrderSearchRes res = (OrderSearchRes) XmlUtils.xmlToObject(deContent, OrderSearchRes.class); 110 | return res; 111 | } 112 | 113 | public static OrderSearchRes otherOrderSerachDetail(String shopNo, String posNo, String streamNo, String orderDate) throws Exception { 114 | JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); 115 | org.apache.cxf.endpoint.Client client = dcf.createClient(orderSearchUrl); 116 | Object[] objects = client.invoke("getSaleInfo", new Object[]{"1", shopNo, posNo, streamNo, orderDate}); 117 | String data = objects[0].toString(); 118 | BodyModel body = (BodyModel) XmlUtils.xmlToObject(data, BodyModel.class); 119 | String content = (String) body.getData().getContent(); 120 | String deContent = Base64Utils.getFromBase64(content); 121 | OrderSearchRes res = (OrderSearchRes) XmlUtils.xmlToObject(deContent, OrderSearchRes.class); 122 | return res; 123 | } 124 | 125 | public static InvoiceOpenRes invoiceOpen(REQUEST_FPKJXX REQUEST_FPKJXX) throws JAXBException { 126 | BodyModel body = new BodyModel(); 127 | GlobalInfo globalInfo = new GlobalInfo(version, jskp); 128 | body.setGlobalInfo(globalInfo); 129 | ContentData data = new ContentData(); 130 | String requetBodyXml = XmlUtils.objectToXml(REQUEST_FPKJXX, REQUEST_FPKJXX.class); 131 | requetBodyXml = Base64Utils.getBase64(requetBodyXml); 132 | data.setContent(requetBodyXml); 133 | body.setData(data); 134 | 135 | String requetAllBodyXml = XmlUtils.objectToXml(body, BodyModel.class); 136 | HttpHeaders headers = new HttpHeaders(); 137 | headers.setContentType(MediaType.APPLICATION_XML); 138 | HttpEntity entity = new HttpEntity(requetAllBodyXml, headers); 139 | RestTemplate restTemplate = new RestTemplate(); 140 | InvoiceOpenRes responseBody = restTemplate.postForObject(url, entity, InvoiceOpenRes.class); 141 | return responseBody; 142 | } 143 | 144 | 145 | public static InvoiceMailRes mailSend(InvoiceMailReq invoiceMailReq) throws JAXBException { 146 | BodyModel body = new BodyModel(); 147 | GlobalInfo globalInfo = new GlobalInfo(version, dzyx); 148 | body.setGlobalInfo(globalInfo); 149 | ContentData data = new ContentData(); 150 | String requetBodyXml = XmlUtils.objectToXml(invoiceMailReq, InvoiceMailReq.class); 151 | requetBodyXml = Base64Utils.getBase64(requetBodyXml); 152 | data.setContent(requetBodyXml); 153 | body.setData(data); 154 | 155 | String requetAllBodyXml = XmlUtils.objectToXml(body, BodyModel.class); 156 | HttpHeaders headers = new HttpHeaders(); 157 | headers.setContentType(MediaType.APPLICATION_XML); 158 | HttpEntity entity = new HttpEntity(requetAllBodyXml, headers); 159 | RestTemplate restTemplate = new RestTemplate(); 160 | InvoiceMailRes responseBody = restTemplate.postForObject(url, entity, InvoiceMailRes.class); 161 | return responseBody; 162 | } 163 | 164 | } 165 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/invoiceFlushRed/InvoiceFlushRedReq.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice.invoiceFlushRed; 2 | 3 | import lombok.Data; 4 | 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | 7 | @Data 8 | @XmlRootElement(name="DATA") 9 | public class InvoiceFlushRedReq { 10 | private String XPLSH; 11 | 12 | private String NSRSBH; 13 | 14 | private String DDLSH; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/invoiceFlushRed/InvoiceFlushRedRes.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice.invoiceFlushRed; 2 | 3 | import lombok.Data; 4 | 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | 7 | @Data 8 | @XmlRootElement(name = "ROOT") 9 | public class InvoiceFlushRedRes { 10 | private String CODE; 11 | 12 | private String MESSAGE; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/invoiceMail/InvoiceMailReq.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice.invoiceMail; 2 | 3 | import lombok.Data; 4 | 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | 7 | @Data 8 | @XmlRootElement(name="DATA") 9 | public class InvoiceMailReq { 10 | private String EMAIL; 11 | private String FPDM; 12 | private String FPHM; 13 | private String DDLSH; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/invoiceMail/InvoiceMailRes.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice.invoiceMail; 2 | 3 | import lombok.Data; 4 | 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | 7 | @Data 8 | @XmlRootElement(name = "ROOT") 9 | public class InvoiceMailRes { 10 | private String CODE; 11 | private String MESSAGE; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/invoiceOpen/InvoiceOpenReq.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice.invoiceOpen; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class InvoiceOpenReq { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/invoiceOpen/InvoiceOpenRes.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice.invoiceOpen; 2 | 3 | import lombok.Data; 4 | 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | 7 | @Data 8 | @XmlRootElement(name = "ROOT") 9 | public class InvoiceOpenRes { 10 | private String CODE; 11 | private String MESSAGE; 12 | private String DDLSH; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/invoiceSearch/InvoiceSearchReq.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice.invoiceSearch; 2 | 3 | 4 | import lombok.Data; 5 | 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | @Data 9 | @XmlRootElement(name = "ROOT") 10 | public class InvoiceSearchReq { 11 | private String XPLSH; 12 | private String FPDM = ""; 13 | private String FPHM = ""; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/invoiceSearch/InvoiceSearchRes.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice.invoiceSearch; 2 | 3 | import lombok.Data; 4 | 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | 7 | @Data 8 | @XmlRootElement(name="ROOT") 9 | public class InvoiceSearchRes { 10 | private OUTSTRS OUTSTRS; 11 | private String CODE; 12 | private String MESSAGE; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/invoiceSearch/OUTSTR.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice.invoiceSearch; 2 | 3 | import lombok.Data; 4 | 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | 7 | @Data 8 | @XmlRootElement(name="OUTSTR") 9 | public class OUTSTR { 10 | private String FP_CODE; 11 | private String FP_MESSAGE; 12 | private String DDLSH; 13 | private String XPLSH; 14 | private String JYM; 15 | private String EWM; 16 | private String FP_DM; 17 | private String FP_HM; 18 | private String KPRQ; 19 | private String KPLX; 20 | private String KPHJJE; 21 | private String GHFMC; 22 | private String PDF_FILE=""; 23 | private String NSRSBH; 24 | private String JPG_FILE=""; 25 | private Boolean KPBZ; 26 | private String GSMC="三江购物俱乐部股份有限公司"; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/invoiceSearch/OUTSTRS.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice.invoiceSearch; 2 | 3 | import lombok.Data; 4 | 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | 7 | @Data 8 | @XmlRootElement(name = "OUTSTR") 9 | public class OUTSTRS { 10 | private OUTSTR OUTSTR; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/orderInvoiceSearch/OrderInvoiceSearchRes.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice.orderInvoiceSearch; 2 | 3 | import lombok.Data; 4 | import sjes.dzfp.model.invoice.invoiceSearch.OUTSTR; 5 | import sjes.dzfp.model.invoice.orderSerach.FPKJXX_FPTXX; 6 | import sjes.dzfp.model.invoice.orderSerach.FPKJXX_XMXXS; 7 | 8 | @Data 9 | public class OrderInvoiceSearchRes { 10 | private FPKJXX_FPTXX FPKJXX_FPTXX; 11 | private FPKJXX_XMXXS FPKJXX_XMXXS; 12 | private OUTSTR OUTSTR; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/orderSerach/FPKJXX_FPTXX.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice.orderSerach; 2 | 3 | import lombok.Data; 4 | 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | 7 | @Data 8 | @XmlRootElement(name = "FPKJXX_FPTXX") 9 | public class FPKJXX_FPTXX { 10 | private String XPLSH; 11 | private String XPLSH2; 12 | private String NSRSBH; 13 | private String MDBM; 14 | private String XSDATE; 15 | private String HYKH; 16 | private String HYSJ; 17 | private String THBS; 18 | private String YXPLSH; 19 | private String FPLY; 20 | private String SHRMC; 21 | private String SKY; 22 | private String KPHJJE; 23 | private String YFKZFBS; 24 | private String YFKJE; 25 | private String HJBHSJE; 26 | private String HJSE; 27 | private String BZ; 28 | private String GHF_MC; 29 | private String GHF_NSRSBH; 30 | private String GHF_DZ; 31 | private String GHF_GDDH; 32 | private String GHF_YHZH; 33 | private String GHF_SJ; 34 | private String GHF_EMAIL; 35 | private String KPY; 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/orderSerach/FPKJXX_XMXX.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice.orderSerach; 2 | 3 | import lombok.Data; 4 | 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | 7 | @Data 8 | @XmlRootElement(name="FPKJXX_XMXX") 9 | public class FPKJXX_XMXX { 10 | private String SPMC; 11 | private String SPDW; 12 | private String GGXH; 13 | private String SPSL; 14 | private String SPDJ; 15 | private String FPHXZ; 16 | private String SPBM; 17 | private String ZXBM; 18 | private String YHZCBS; 19 | private String ZZSTSGL; 20 | private String SPJE; 21 | private String SL; 22 | private String SE; 23 | private String SLANDDW; 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/orderSerach/FPKJXX_XMXXS.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice.orderSerach; 2 | 3 | import lombok.Data; 4 | 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | import java.util.List; 7 | 8 | @Data 9 | @XmlRootElement(name = "FPKJXX_XMXXS") 10 | public class FPKJXX_XMXXS { 11 | private List FPKJXX_XMXX; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/orderSerach/OrderSearchRes.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice.orderSerach; 2 | 3 | import lombok.Data; 4 | 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | import java.util.List; 7 | 8 | @Data 9 | @XmlRootElement(name="REQUEST_FPKJXXS") 10 | public class OrderSearchRes { 11 | private REQUEST_FPKJXX REQUEST_FPKJXX; 12 | private List REQUEST_THXX; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/invoice/orderSerach/REQUEST_FPKJXX.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model.invoice.orderSerach; 2 | 3 | import lombok.Data; 4 | 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | 7 | @Data 8 | @XmlRootElement(name = "REQUEST_FPKJXX") 9 | public class REQUEST_FPKJXX { 10 | private FPKJXX_FPTXX FPKJXX_FPTXX; 11 | private FPKJXX_XMXXS FPKJXX_XMXXS; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/model/tt.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.model; 2 | 3 | public class tt { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/repository/mongo/InvocieOpenInfoRepository.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.repository.mongo; 2 | 3 | 4 | import sjes.dzfp.domain.mongo.InvocieOpenInfo; 5 | import org.springframework.data.mongodb.repository.MongoRepository; 6 | 7 | public interface InvocieOpenInfoRepository extends MongoRepository { 8 | 9 | InvocieOpenInfo findBySearchNo(String searchNo); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/repository/mongo/InvoiceErroInfoRepository.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.repository.mongo; 2 | 3 | 4 | import sjes.dzfp.domain.mongo.InvoiceErroInfo; 5 | import org.springframework.data.mongodb.repository.MongoRepository; 6 | 7 | public interface InvoiceErroInfoRepository extends MongoRepository { 8 | InvoiceErroInfo findBySearchNoAndType(String serachNo, String type); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/repository/tt.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.repository; 2 | 3 | public class tt { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/service/invoice/InvoiceService.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.service.invoice; 2 | 3 | 4 | import sjes.dzfp.ResponseBody.ResponseMessage; 5 | 6 | public interface InvoiceService { 7 | 8 | /** 9 | * 开票 10 | * @param searchNo 查询序列号 11 | * @param invoiceType 1单位 2个人 12 | * @param invoiceHead 发票抬头 13 | * @param nsrNo 税号 14 | * @param address 地址 15 | * @param mobile 手机 16 | * @param bankNo 银行卡号 17 | * @return 18 | */ 19 | ResponseMessage invoiceOpen(String searchNo, Integer invoiceType, String invoiceHead, String nsrNo, String address, String mobile, String bankNo); 20 | 21 | /** 22 | * 发票查询 23 | * 24 | * @param invoiceStream 发票流水号 25 | * @param invoiceCode 发票代码 26 | * @param invoiceNo 怕票号码 27 | */ 28 | ResponseMessage invoiceSearch(String invoiceStream, String invoiceCode, String invoiceNo); 29 | 30 | 31 | /** 32 | * 发票冲红 33 | * 34 | * @param invoiceStream 发票流水号 35 | * @param taxpayerCode 纳税人编号 36 | * @param orderStream 订单流水号 37 | */ 38 | ResponseMessage invoiceFlushRed(String invoiceStream, String taxpayerCode, String orderStream); 39 | 40 | 41 | /** 42 | * 订单查询 43 | * 44 | * @param searchNo 查询序列号 45 | * @return 46 | */ 47 | ResponseMessage orderSerach(String searchNo); 48 | 49 | 50 | /** 51 | * 订单和发票查询 52 | * 53 | * @param searchNo 查询序列号 54 | * @return 55 | */ 56 | ResponseMessage orderAndInvoiceSearch(String searchNo); 57 | 58 | 59 | /** 60 | * 发送发票邮箱 61 | * 62 | * @param mail 邮箱地址 63 | * @param searchNo 查询序列号 64 | * @return 65 | */ 66 | ResponseMessage mailSend(String mail, String searchNo); 67 | 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/service/invoice/impl/InvoiceServiceImpl.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.service.invoice.impl; 2 | 3 | 4 | import sjes.dzfp.ResponseBody.ResponseMessage; 5 | import org.apache.commons.lang.StringUtils; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.scheduling.annotation.Async; 10 | import org.springframework.stereotype.Service; 11 | import sjes.dzfp.domain.mongo.InvocieOpenInfo; 12 | import sjes.dzfp.domain.mongo.InvoiceErroInfo; 13 | import sjes.dzfp.model.invoice.InvoiceUtils; 14 | import sjes.dzfp.model.invoice.invoiceFlushRed.InvoiceFlushRedReq; 15 | import sjes.dzfp.model.invoice.invoiceFlushRed.InvoiceFlushRedRes; 16 | import sjes.dzfp.model.invoice.invoiceMail.InvoiceMailReq; 17 | import sjes.dzfp.model.invoice.invoiceMail.InvoiceMailRes; 18 | import sjes.dzfp.model.invoice.invoiceOpen.InvoiceOpenRes; 19 | import sjes.dzfp.model.invoice.invoiceSearch.InvoiceSearchReq; 20 | import sjes.dzfp.model.invoice.invoiceSearch.InvoiceSearchRes; 21 | import sjes.dzfp.model.invoice.invoiceSearch.OUTSTR; 22 | import sjes.dzfp.model.invoice.orderInvoiceSearch.OrderInvoiceSearchRes; 23 | import sjes.dzfp.model.invoice.orderSerach.FPKJXX_XMXX; 24 | import sjes.dzfp.model.invoice.orderSerach.OrderSearchRes; 25 | import sjes.dzfp.model.invoice.orderSerach.REQUEST_FPKJXX; 26 | import sjes.dzfp.repository.mongo.InvocieOpenInfoRepository; 27 | import sjes.dzfp.repository.mongo.InvoiceErroInfoRepository; 28 | import sjes.dzfp.service.invoice.InvoiceService; 29 | 30 | import java.time.LocalDateTime; 31 | import java.util.regex.Matcher; 32 | import java.util.regex.Pattern; 33 | 34 | @Service("InvoiceService") 35 | public class InvoiceServiceImpl implements InvoiceService { 36 | 37 | Logger log = LoggerFactory.getLogger(InvoiceServiceImpl.class); 38 | 39 | @Autowired 40 | InvocieOpenInfoRepository invocieOpenInfoRepository; 41 | 42 | @Autowired 43 | InvoiceErroInfoRepository invoiceErroInfoRepository; 44 | 45 | /** 46 | * 开票 47 | * 48 | * @param searchNo 查询序列号 49 | * @param invoiceType 1单位 2个人 50 | * @param invoiceHead 发票抬头 51 | * @param nsrNo 税号 52 | * @param address 地址 53 | * @param mobile 手机 54 | * @param bankNo 银行卡号 55 | * @return 56 | */ 57 | @Override 58 | public ResponseMessage invoiceOpen(String searchNo, Integer invoiceType, String invoiceHead, String nsrNo, String address, String mobile, String bankNo) { 59 | ResponseMessage responseMessage = new ResponseMessage(); 60 | try { 61 | if (StringUtils.isEmpty(invoiceHead)) { 62 | responseMessage.setFailure(-1, "发票抬头不能为空", null); 63 | return responseMessage; 64 | } 65 | ResponseMessage orderAndInvoiceRes = orderAndInvoiceSearch(searchNo); 66 | if (orderAndInvoiceRes.getCode() == -1) { 67 | return orderAndInvoiceRes; 68 | } 69 | OrderInvoiceSearchRes orderInvoiceSearchRes = (OrderInvoiceSearchRes) orderAndInvoiceRes.getData(); 70 | //判断是否为全部预付卡支付 71 | if (orderInvoiceSearchRes.getFPKJXX_FPTXX().getYFKZFBS().equals("1")) { 72 | responseMessage.setFailure(-1, "全部储值卡支付,不能开票", null); 73 | return responseMessage; 74 | } 75 | //之前开过票的先冲红再开票 76 | if (orderInvoiceSearchRes.getOUTSTR().getKPBZ() == true) { 77 | ResponseMessage flushRes = this.invoiceFlushRed(orderInvoiceSearchRes.getFPKJXX_FPTXX().getXPLSH(), orderInvoiceSearchRes.getFPKJXX_FPTXX().getNSRSBH(), null); 78 | if (flushRes.getCode() == -1) { 79 | String errorMessage = "发票冲红失败,不能开票--订单号:" + orderInvoiceSearchRes.getFPKJXX_FPTXX().getXPLSH(); 80 | if (StringUtils.isNotBlank(orderInvoiceSearchRes.getFPKJXX_FPTXX().getXPLSH2())) { 81 | errorMessage = "发票冲红失败,不能开票--订单号:" + orderInvoiceSearchRes.getFPKJXX_FPTXX().getXPLSH() 82 | + ",发票号:" + orderInvoiceSearchRes.getFPKJXX_FPTXX().getXPLSH2(); 83 | } 84 | responseMessage.setFailure(-1, errorMessage, null); 85 | saveInvoiceErroMessage(searchNo, orderInvoiceSearchRes.getFPKJXX_FPTXX().getXPLSH(), "fpch", errorMessage); 86 | return responseMessage; 87 | } 88 | } 89 | 90 | REQUEST_FPKJXX REQUEST_FPKJXX = new REQUEST_FPKJXX(); 91 | REQUEST_FPKJXX.setFPKJXX_FPTXX(orderInvoiceSearchRes.getFPKJXX_FPTXX()); 92 | REQUEST_FPKJXX.setFPKJXX_XMXXS(orderInvoiceSearchRes.getFPKJXX_XMXXS()); 93 | REQUEST_FPKJXX.getFPKJXX_FPTXX().setGHF_MC(invoiceHead); 94 | REQUEST_FPKJXX.getFPKJXX_FPTXX().setGHF_NSRSBH(nsrNo); 95 | REQUEST_FPKJXX.getFPKJXX_FPTXX().setGHF_DZ(address); 96 | REQUEST_FPKJXX.getFPKJXX_FPTXX().setGHF_GDDH(mobile); 97 | REQUEST_FPKJXX.getFPKJXX_FPTXX().setGHF_YHZH(bankNo); 98 | REQUEST_FPKJXX.getFPKJXX_FPTXX().setKPY("自助开票"); 99 | // InvoiceOpenRes res = null; 100 | InvoiceOpenRes res = InvoiceUtils.invoiceOpen(REQUEST_FPKJXX); 101 | if (res.getCODE().equals("9999")) { 102 | String errorMessage = res.getMESSAGE(); 103 | if (StringUtils.isNotBlank(REQUEST_FPKJXX.getFPKJXX_FPTXX().getXPLSH2())) { 104 | String[] split = res.getMESSAGE().split("--"); 105 | errorMessage = split[0] + "--订单号:" + REQUEST_FPKJXX.getFPKJXX_FPTXX().getXPLSH2() + res.getMESSAGE().substring(split[0].length()); 106 | } 107 | responseMessage.setFailure(-1, errorMessage, null); 108 | saveInvoiceErroMessage(searchNo, orderInvoiceSearchRes.getFPKJXX_FPTXX().getXPLSH(), "fpkp", errorMessage); 109 | return responseMessage; 110 | } 111 | responseMessage.setData(res); 112 | saveInvoiceOpen(searchNo, invoiceType, invoiceHead, nsrNo, address, mobile, bankNo); 113 | } catch (Exception ex) { 114 | String errorMessage = "开票(查询序列号:" + searchNo + ")失败:" + ex.toString(); 115 | log.error(errorMessage); 116 | responseMessage.setFailure(-1, "开票(查询序列号:" + searchNo + ")失败", null); 117 | saveInvoiceErroMessage(searchNo, "", "fpkp", errorMessage); 118 | 119 | } 120 | return responseMessage; 121 | } 122 | 123 | 124 | /** 125 | * 发票查询 126 | * 127 | * @param invoiceStream 发票流水号 128 | * @param invoiceCode 发票代码 129 | * @param invoiceNo 怕票号码 130 | */ 131 | @Override 132 | public ResponseMessage invoiceSearch(String invoiceStream, String invoiceCode, String invoiceNo) { 133 | ResponseMessage responseMessage = new ResponseMessage(); 134 | try { 135 | InvoiceSearchReq invoiceSearch = new InvoiceSearchReq(); 136 | invoiceSearch.setXPLSH(invoiceStream); 137 | invoiceSearch.setFPDM(invoiceCode); 138 | invoiceSearch.setFPHM(invoiceNo); 139 | InvoiceSearchRes res = InvoiceUtils.invoiceSerach(invoiceSearch); 140 | responseMessage.setData(res); 141 | } catch (Exception ex) { 142 | log.error("发票查询(流水:" + invoiceStream + ",代码:" + invoiceCode + ",号码:" + invoiceNo + ")失败:" + ex.toString()); 143 | responseMessage.setFailure(-1, "发票查询异常", null); 144 | } 145 | return responseMessage; 146 | } 147 | 148 | 149 | /** 150 | * 发票冲红 151 | * 152 | * @param invoiceStream 发票流水号 153 | * @param taxpayerCode 纳税人编号 154 | * @param orderStream 订单流水号 155 | */ 156 | @Override 157 | public ResponseMessage invoiceFlushRed(String invoiceStream, String taxpayerCode, String orderStream) { 158 | ResponseMessage responseMessage = new ResponseMessage(); 159 | try { 160 | InvoiceFlushRedReq invoiceFlushRedReq = new InvoiceFlushRedReq(); 161 | invoiceFlushRedReq.setXPLSH(invoiceStream); 162 | invoiceFlushRedReq.setNSRSBH(taxpayerCode); 163 | invoiceFlushRedReq.setDDLSH(orderStream); 164 | InvoiceFlushRedRes res = InvoiceUtils.invoiceFlushRed(invoiceFlushRedReq); 165 | responseMessage.setData(res); 166 | return responseMessage; 167 | } catch (Exception ex) { 168 | String erroMessage = "发票冲红(发票流水号:" + invoiceStream + ",纳税人编号:" + taxpayerCode + ",订单流水号:" + orderStream + ")失败:" + ex.toString(); 169 | log.error(erroMessage); 170 | responseMessage.setFailure(-1, "发票冲红异常", null); 171 | } 172 | return responseMessage; 173 | } 174 | 175 | 176 | /** 177 | * 订单查询 178 | * 179 | * @param searchNo 查询序列号 180 | * @return 181 | */ 182 | @Override 183 | public ResponseMessage orderSerach(String searchNo) { 184 | ResponseMessage responseMessage = new ResponseMessage(); 185 | try { 186 | if (StringUtils.isEmpty(searchNo)) { 187 | responseMessage.setFailure(-1, "订单查询失败:查询号不能为空", null); 188 | return responseMessage; 189 | } 190 | OrderSearchRes res = new OrderSearchRes(); 191 | if (searchNo.startsWith("1")) { 192 | if (searchNo.length() != 22) { 193 | responseMessage.setFailure(-1, "订单查询失败:查询号以1开头的长度必须为22位", null); 194 | return responseMessage; 195 | } 196 | String shopNo = searchNo.substring(1, 4); 197 | String orderDate = searchNo.substring(4, 10); 198 | orderDate = "20" + orderDate.substring(0, 2) + "-" + orderDate.substring(2, 4) + "-" + orderDate.substring(4, 6); 199 | String posNo = searchNo.substring(10, 14); 200 | String streamNo = searchNo.substring(14, 20); 201 | res = InvoiceUtils.otherOrderSerachDetail(shopNo, posNo, streamNo, orderDate); 202 | } else if (searchNo.startsWith("2")) { 203 | // if (searchNo.length() != 27) { 204 | // responseMessage.setFailure(-1, "订单查询失败:查询号以2开头的长度必须为27位", null); 205 | // return responseMessage; 206 | // } 207 | String orderNo = searchNo.substring(7, searchNo.length() - 2); 208 | String orderDate = searchNo.substring(1, 7); 209 | orderDate = "20" + orderDate.substring(0, 2) + "-" + orderDate.substring(2, 4) + "-" + orderDate.substring(4, 6); 210 | res = InvoiceUtils.txdOrderSerachDetail(orderNo, orderDate); 211 | } else { 212 | responseMessage.setFailure(-1, "订单查询失败:查询号必须以1或2开头", null); 213 | } 214 | 215 | if (res.getREQUEST_FPKJXX() == null) { 216 | String erroMessage = "订单查询失败:未查询到发票信息"; 217 | responseMessage.setFailure(-1, erroMessage, null); 218 | saveInvoiceErroMessage(searchNo, "", "ddcx", erroMessage); 219 | } else { 220 | responseMessage.setData(res); 221 | } 222 | 223 | } catch (Exception ex) { 224 | String erroMessage = "订单查询(查询序列号:" + searchNo + ")失败:" + ex.toString(); 225 | log.error(erroMessage); 226 | responseMessage.setFailure(-1, "订单查询异常", null); 227 | saveInvoiceErroMessage(searchNo, "", "ddcx", erroMessage); 228 | } 229 | 230 | return responseMessage; 231 | } 232 | 233 | 234 | /** 235 | * 订单和发票查询 236 | * 237 | * @param searchNo 查询序列号 238 | * @return 239 | */ 240 | public ResponseMessage orderAndInvoiceSearch(String searchNo) { 241 | ResponseMessage responseMessage = new ResponseMessage(); 242 | try { 243 | OrderInvoiceSearchRes orderInvoiceSearchRes = new OrderInvoiceSearchRes(); 244 | ResponseMessage orderDetailRes = this.orderSerach(searchNo); 245 | if (orderDetailRes.getCode() == -1) { 246 | return orderDetailRes; 247 | } 248 | orderInvoiceSearchRes.setFPKJXX_FPTXX(orderDetailRes.getData().getREQUEST_FPKJXX().getFPKJXX_FPTXX()); 249 | orderInvoiceSearchRes.setFPKJXX_XMXXS(orderDetailRes.getData().getREQUEST_FPKJXX().getFPKJXX_XMXXS()); 250 | if (orderInvoiceSearchRes.getFPKJXX_XMXXS() != null && orderInvoiceSearchRes.getFPKJXX_XMXXS().getFPKJXX_XMXX() != null) { 251 | for (FPKJXX_XMXX fpkjxx_xmxx : orderInvoiceSearchRes.getFPKJXX_XMXXS().getFPKJXX_XMXX()) { 252 | fpkjxx_xmxx.setSLANDDW(subZeroAndDot(fpkjxx_xmxx.getSPSL()) + "/" + fpkjxx_xmxx.getSPDW()); 253 | } 254 | } 255 | 256 | REQUEST_FPKJXX orderDetail = orderDetailRes.getData().getREQUEST_FPKJXX(); 257 | String xplsh = orderDetail.getFPKJXX_FPTXX().getXPLSH(); 258 | ResponseMessage invoiceDetailRes = this.invoiceSearch(xplsh, "", ""); 259 | if (invoiceDetailRes.getCode() == -1 || invoiceDetailRes.getData().getCODE().equals("9999")||invoiceDetailRes.getData().getOUTSTRS().getOUTSTR().getFP_CODE().equals("9999")) { 260 | //设置开票标志为未开票 261 | OUTSTR outstr = new OUTSTR(); 262 | outstr.setKPBZ(false); 263 | orderInvoiceSearchRes.setOUTSTR(outstr); 264 | } else { 265 | //设置开票标志为已开票 266 | OUTSTR outstr = invoiceDetailRes.getData().getOUTSTRS().getOUTSTR(); 267 | outstr.setKPBZ(true); 268 | orderInvoiceSearchRes.setOUTSTR(outstr); 269 | } 270 | responseMessage.setData(orderInvoiceSearchRes); 271 | 272 | } catch (Exception ex) { 273 | log.error("订单和发票查询(查询序列号:" + searchNo + ")失败:" + ex.toString()); 274 | responseMessage.setFailure(-1, "订单和发票查询异常", null); 275 | } 276 | return responseMessage; 277 | 278 | } 279 | 280 | 281 | /** 282 | * 发送发票邮箱 283 | * 284 | * @param mail 邮箱地址 285 | * @param searchNo 查询序列号 286 | * @return 287 | */ 288 | @Override 289 | public ResponseMessage mailSend(String mail, String searchNo) { 290 | ResponseMessage responseMessage = new ResponseMessage(); 291 | try { 292 | if (StringUtils.isEmpty(mail) || !this.checkEmaile(mail)) { 293 | responseMessage.setFailure(-1, "邮箱不能为空或格式不对", null); 294 | return responseMessage; 295 | } 296 | ResponseMessage orderAndInvoiceSearchRes = this.orderAndInvoiceSearch(searchNo); 297 | if (orderAndInvoiceSearchRes.getCode() == -1) { 298 | return orderAndInvoiceSearchRes; 299 | } 300 | OrderInvoiceSearchRes orderInvoiceSearchRes = (OrderInvoiceSearchRes) orderAndInvoiceSearchRes.getData(); 301 | if (orderInvoiceSearchRes.getOUTSTR() == null || orderInvoiceSearchRes.getOUTSTR().getKPBZ() == false) { 302 | responseMessage.setFailure(-1, "未开票", null); 303 | return responseMessage; 304 | } 305 | InvoiceMailReq invoiceMailReq = new InvoiceMailReq(); 306 | invoiceMailReq.setEMAIL(mail); 307 | invoiceMailReq.setFPDM(orderInvoiceSearchRes.getOUTSTR().getFP_DM()); 308 | invoiceMailReq.setFPHM(orderInvoiceSearchRes.getOUTSTR().getFP_HM()); 309 | invoiceMailReq.setDDLSH(orderInvoiceSearchRes.getOUTSTR().getDDLSH()); 310 | InvoiceMailRes res = InvoiceUtils.mailSend(invoiceMailReq); 311 | } catch (Exception ex) { 312 | log.error("发送发票邮箱(邮箱地址:" + mail + ",查询号:" + searchNo + ")失败:" + ex.toString()); 313 | responseMessage.setFailure(-1, "发送发票邮箱失败", null); 314 | } 315 | return responseMessage; 316 | } 317 | 318 | 319 | /** 320 | * 保存开票信息 321 | * 322 | * @param searchNo 查询序列号 323 | * @param invoiceType 1单位 2个人 324 | * @param invoiceHead 发票抬头 325 | * @param nsrNo 税号 326 | * @param address 地址 327 | * @param mobile 手机 328 | * @param bankNo 银行卡号 329 | */ 330 | @Async 331 | public void saveInvoiceOpen(String searchNo, Integer invoiceType, String invoiceHead, String nsrNo, String address, String mobile, String bankNo) { 332 | try { 333 | InvocieOpenInfo invocieOpenInfo = invocieOpenInfoRepository.findBySearchNo(searchNo); 334 | if (invocieOpenInfo == null) { 335 | invocieOpenInfo = new InvocieOpenInfo(); 336 | } 337 | String now = LocalDateTime.now().toString(); 338 | invocieOpenInfo.setSearchNo(searchNo); 339 | invocieOpenInfo.setInvoiceType(invoiceType); 340 | invocieOpenInfo.setInvoiceHead(invoiceHead); 341 | invocieOpenInfo.setNsrNo(nsrNo); 342 | invocieOpenInfo.setAddress(address); 343 | invocieOpenInfo.setMobile(mobile); 344 | invocieOpenInfo.setBankNo(bankNo); 345 | invocieOpenInfo.setKpDate(now); 346 | invocieOpenInfoRepository.save(invocieOpenInfo); 347 | } catch (Exception ex) { 348 | log.error("开票(查询号:" + searchNo + ",类型:" + invoiceType + ",抬头:" + invoiceHead + ")保存至mongo失败:" + ex.toString()); 349 | } 350 | } 351 | 352 | /** 353 | * 正则表达式校验邮箱 354 | * 355 | * @param emaile 待匹配的邮箱 356 | * @return 匹配成功返回true 否则返回false; 357 | */ 358 | private static boolean checkEmaile(String emaile) { 359 | String RULE_EMAIL = "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$"; 360 | //正则表达式的模式 361 | Pattern p = Pattern.compile(RULE_EMAIL); 362 | //正则表达式的匹配器 363 | Matcher m = p.matcher(emaile); 364 | //进行正则匹配 365 | return m.matches(); 366 | } 367 | 368 | 369 | /** 370 | * 使用java正则表达式去掉多余的.与0 371 | * 372 | * @param s 373 | * @return 374 | */ 375 | public static String subZeroAndDot(String s) { 376 | if (s.indexOf(".") > 0) { 377 | s = s.replaceAll("0+?$", "");//去掉多余的0 378 | s = s.replaceAll("[.]$", "");//如最后一位是.则去掉 379 | } 380 | return s; 381 | } 382 | 383 | 384 | /** 385 | * 保存错误信息 386 | * 387 | * @param searchNo 388 | * @param xpls 389 | * @param type 390 | * @param erroMessage 391 | */ 392 | @Async 393 | public void saveInvoiceErroMessage(String searchNo, String xpls, String type, String erroMessage) { 394 | InvoiceErroInfo invoiceErroInfo = invoiceErroInfoRepository.findBySearchNoAndType(searchNo, type); 395 | if (invoiceErroInfo == null) 396 | invoiceErroInfo = new InvoiceErroInfo(); 397 | invoiceErroInfo.setSearchNo(searchNo); 398 | invoiceErroInfo.setXpls(xpls); 399 | invoiceErroInfo.setType(type); 400 | invoiceErroInfo.setErroMessage(erroMessage); 401 | invoiceErroInfoRepository.save(invoiceErroInfo); 402 | } 403 | 404 | 405 | } 406 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/service/tt.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.service; 2 | 3 | public class tt { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/utils/Base64Utils.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.utils; 2 | 3 | import org.apache.commons.codec.binary.Base64; 4 | import sun.misc.BASE64Decoder; 5 | import sun.misc.BASE64Encoder; 6 | 7 | import java.io.File; 8 | import java.io.FileOutputStream; 9 | import java.io.IOException; 10 | import java.io.UnsupportedEncodingException; 11 | 12 | public class Base64Utils { 13 | 14 | /** 15 | * 使用jdk的base64 加密字符串 16 | */ 17 | public static String jdkBase64Encoder(String str) { 18 | BASE64Encoder encoder = new BASE64Encoder(); 19 | String encode = encoder.encode(str.getBytes()); 20 | return encode; 21 | } 22 | 23 | //加密 24 | public static String getBase64(String str) { 25 | byte[] b = null; 26 | String s = null; 27 | try { 28 | b = str.getBytes("utf-8"); 29 | } catch (UnsupportedEncodingException e) { 30 | e.printStackTrace(); 31 | } 32 | if (b != null) { 33 | s = new BASE64Encoder().encode(b); 34 | } 35 | return s; 36 | } 37 | 38 | 39 | // 解密 40 | public static String getFromBase64(String s) { 41 | byte[] b = null; 42 | String result = null; 43 | if (s != null) { 44 | BASE64Decoder decoder = new BASE64Decoder(); 45 | try { 46 | b = decoder.decodeBuffer(s); 47 | result = new String(b, "utf-8"); 48 | } catch (Exception e) { 49 | e.printStackTrace(); 50 | } 51 | } 52 | return result; 53 | } 54 | 55 | 56 | /** 57 | * 使用commons-codec的base64 加密字符串 58 | */ 59 | public static String CCBase64Encoder(String str) { 60 | 61 | return new String(Base64.encodeBase64(str.getBytes())); 62 | } 63 | 64 | 65 | /** 66 | * 解码base64图片 67 | * 68 | * @param str 69 | * @throws IOException 70 | */ 71 | public static void DecodeToFile(String str) throws IOException { 72 | BASE64Decoder decoder = new BASE64Decoder(); 73 | FileOutputStream write = new FileOutputStream(new File("C:/Users/wujianlong/Desktop/ttt.jpg")); 74 | byte[] decoderBytes = decoder.decodeBuffer(str); 75 | write.write(decoderBytes); 76 | write.close(); 77 | } 78 | 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/sjes/dzfp/utils/XmlUtils.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp.utils; 2 | 3 | import javax.xml.bind.JAXBContext; 4 | import javax.xml.bind.JAXBException; 5 | import javax.xml.bind.Marshaller; 6 | import javax.xml.bind.Unmarshaller; 7 | import java.io.ByteArrayInputStream; 8 | import java.io.ByteArrayOutputStream; 9 | import java.io.InputStream; 10 | 11 | public class XmlUtils { 12 | 13 | public static String objectToXml(Object object, Class... clazz) throws JAXBException { 14 | JAXBContext context = JAXBContext.newInstance(clazz); // 获取上下文对象 15 | Marshaller marshaller = context.createMarshaller(); // 根据上下文获取marshaller对象 16 | marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); // 设置编码字符集 17 | marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); // 格式化XML输出,有分行和缩进 18 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 19 | marshaller.marshal(object, baos); 20 | String xmlObj = new String(baos.toByteArray()); // 生成XML字符串 21 | return xmlObj; 22 | } 23 | 24 | public static Object xmlToObject(String xml, Class... clazz) throws JAXBException { 25 | JAXBContext context = JAXBContext.newInstance(clazz); 26 | Unmarshaller unmarshaller = context.createUnmarshaller(); 27 | InputStream is = new ByteArrayInputStream(xml.getBytes()); 28 | Object object = unmarshaller.unmarshal(is); 29 | return object; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | data: 3 | mongodb: 4 | host: srv3.sanjiang.info 5 | port: 27017 6 | database: sjes-hub-api 7 | 8 | 9 | 10 | log4j: 11 | logger: 12 | org: 13 | hibernate: 14 | SQL: trace 15 | type: trace 16 | logging: 17 | level: 18 | org.springframework.security: debug 19 | org.mongodb.driver.protocol: debug 20 | org.mongeez: debug 21 | 22 | eureka: 23 | # instance: 24 | # hostname: 193.0.1.122 25 | instance: 26 | hostname: srv0.sanjiang.info 27 | client: 28 | serviceUrl: 29 | defaultZone: http://srv3.sanjiang.info:8761/eureka/ 30 | -------------------------------------------------------------------------------- /src/main/resources/application-production.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | data: 3 | mongodb: 4 | host: prod3.sjes.sanjiang.info 5 | port: 27017 6 | database: sjes-hub-api 7 | 8 | 9 | 10 | eureka: 11 | instance: 12 | prefer-ip-address: true 13 | client: 14 | serviceUrl: 15 | defaultZone: http://prod1.sjes.sanjiang.info:8761/eureka/ -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 20009 3 | spring: 4 | profiles: 5 | active: dev 6 | application: 7 | name: sjes-dzfp-api 8 | 9 | 10 | hystrix: 11 | command: 12 | default: 13 | execution: 14 | isolation: 15 | thread: 16 | timeoutInMilliseconds: 10000 17 | -------------------------------------------------------------------------------- /src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | com-sanjiang-invoice 5 | 6 | 7 | 8 | 9 | 10 | 11 | info 12 | 13 | 14 | %d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n 15 | 16 | 17 | 18 | 19 | ${logging.path} 20 | 21 | ${logging.path}.%d{yyyy-MM-dd}.zip 22 | 23 | 24 | 25 | %date %level [%thread] %logger{36} [%file : %line] %msg%n 26 | 27 | 28 | 29 | 30 | 31 | prod9.sjes.sanjiang.info:4560 32 | 33 | 34 | 35 | 36 | 5 minutes 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/test/java/sjes/dzfp/InvoiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package sjes.dzfp; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class InvoiceApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | --------------------------------------------------------------------------------