609324174@qq.com 4 rokov pred
rodič
commit
94a5527a5a

+ 1 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/InvoicePrintInfoResult.java

@@ -24,4 +24,5 @@ public class InvoicePrintInfoResult {
 	private String c_taxnum;
 	private String c_jym;
 	private String c_invoice_line;
+	private String qrCode;
 }

+ 3 - 1
smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayInvoiceprinted.java

@@ -51,7 +51,7 @@ public class PayInvoiceprinted extends PayBaseInfo {
 	private String checkCode;
 	@ApiModelProperty(value = "开票日期")
 	private Date printDate;
-	@ApiModelProperty(value = "发票状态 0:待生成 1:正常 2: 开票中 3:已冲红 4:开票失败  5:已作废")
+	@ApiModelProperty(value = "发票状态 0:待生成 1:正常 2: 开票中(待生成) 3:已冲红 4:开票失败  5:已作废")
 	private Integer state;
 	@ApiModelProperty(value = "发票类型 1:蓝票 2:红票")
 	private Integer invoiceType;
@@ -83,6 +83,8 @@ public class PayInvoiceprinted extends PayBaseInfo {
 	private BigInteger cancelInvoiceId;
 	@ApiModelProperty(value = "身份认证号")
 	private String saleIdentity;
+	@ApiModelProperty(value = "二维码")
+	private  String qrCode;
 }
 
 

+ 16 - 3
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/IssueElectronicInvoiceServiceImpl.java

@@ -12,6 +12,7 @@ import com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela;
 import com.bz.smart_city.service.pay.*;
 import com.bz.smart_city.service.pay.archives.PayBaseCustomerandmeterrelaService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
@@ -44,6 +45,8 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
     PrintInvoiceQueryResultServiceImpl printInvoiceQueryResultService;
     @Autowired
     private SnowflakeIdWorker idWorker;
+    @Value("${invoice.print.url}")
+    private  String printUrl;
 
     private Map<String, String> getPrintParam(Integer siteId, Integer customerId) {
         Map<String, String> map = new HashMap<>();
@@ -100,7 +103,7 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
      * @Author:
      * @Date: 2020/7/28
      */
-    public ReturnPrintResultDto requestPrint(String kpType, String userCode, String payseriesno, String invoicePrintId){
+    public ReturnPrintResultDto requestPrint(String kpType, String userCode, String payseriesno, String invoicePrintId) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         String name = loginUser.getName();//操作员姓名
 
@@ -112,6 +115,12 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
         Map<String, String> invoiceParam = getPrintParam(loginUser.getSiteId(), loginUser.getCustomerId());//销方开票信息
         Map<Integer, PayInvoiceParam> invoiceMap = getInvoiceParam(loginUser.getSiteId(), loginUser.getCustomerId());//税率相关参数
         payEleInvoiceDto.setIdentity(invoiceParam.get("saleIdentity"));//认证信息
+        if(invoiceParam.get("saleIdentity")==null)
+        {
+            returnPrintResultDto.setResult("1");//开票失败
+            returnPrintResultDto.setMsg("开票失败,失败原因:认证信息缺失");
+            return returnPrintResultDto;
+        }
 
         payInvoiceOrderDto.setSaleaccount(invoiceParam.get("saleAccount"));//销方银行账号
         payInvoiceOrderDto.setSalephone(invoiceParam.get("salePhone"));//销方电话
@@ -229,7 +238,7 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
         Map<String, String> map = new HashMap<String, String>();
         map.put("order", jsonsString);
         try {
-            String returnString = HttpClientUtils.doPost("http://nnfpbox.nuonuocs.cn/shop/buyer/allow/cxfKp/cxfServerKpOrderSync.action", map);
+            String returnString = HttpClientUtils.doPost(printUrl, map);
             JSONObject jsonObject = (JSONObject) JSON.parse(returnString);
             PayInvoiceprinted payInvoiceprinted = new PayInvoiceprinted();//发票信息
             payInvoiceprinted.setTaxnum(payInvoiceOrderDto.getTaxnum());
@@ -264,10 +273,14 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
                 payInvoiceprinted.setId(BigInteger.valueOf(idWorker.nextId()));
                 payInvoiceprinted.setState(0);//待生成
                 payInvoiceprinted.setFpqqlsh(jsonObject.getString("fpqqlsh"));
-                returnPrintResultDto.setResult("0");//开票失败
+                returnPrintResultDto.setResult("0");//开票成功
                 returnPrintResultDto.setMsg("开票成功,请等待系统票据查询结果");
                 //开票成功的情况,新保存开票的相关信息,查询时再进行更新
                 int num = printInvoicePrintService.insert(payInvoiceprinted);
+                //请求成功时就把实收或者蓝票则需根据开票查询结果进行标记
+                if (payInvoiceprinted.getInvoiceType() == 1) {//开具蓝票
+                    printInvoicePrintService.updateReceivedIsPrint(true, payInvoiceprinted.getPayseriesno(), payInvoiceprinted.getCustomerId());
+                }
                 //异步查询结果,根据查询结果进行更新票据相关信息
                 printInvoiceQueryResultService.queryPrintInvoiceInfo(payInvoiceprinted);
             } else {//开票失败

+ 37 - 35
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PrintInvoiceQueryResultServiceImpl.java

@@ -10,6 +10,7 @@ import com.bz.smart_city.entity.pay.PayInvoiceprinted;
 import com.bz.smart_city.service.pay.PrintInvoicePrintService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
@@ -29,6 +30,8 @@ import java.util.Map;
 public class PrintInvoiceQueryResultServiceImpl {
     @Autowired
     PrintInvoicePrintService printInvoicePrintService;
+    @Value("${invoice.query.url}")
+    private  String queryUrl;
 
     @Async
     public void queryPrintInvoiceInfo(PayInvoiceprinted payInvoiceprinted) throws Exception {
@@ -41,61 +44,60 @@ public class PrintInvoiceQueryResultServiceImpl {
             String resultString = DESDZFP.encrypt(JSON.toJSONString(payEleInvoiceRequestDto));
             Map<String, String> invoiceResult = new HashMap<String, String>();
             invoiceResult.put("order", resultString);
-            String invoiceInfo = HttpClientUtils.doPost("http://nnfpbox.nuonuocs.cn/shop/buyer/allow/ecOd/queryElectricKp.action", invoiceResult);
+            String invoiceInfo = HttpClientUtils.doPost(queryUrl, invoiceResult);
             PayInvoiceResultDto payInvoiceResultDto = JSON.parseObject(invoiceInfo, PayInvoiceResultDto.class);
             if (payInvoiceResultDto != null && payInvoiceResultDto.getList().size() > 0) {
-                for (InvoicePrintInfoResult item : payInvoiceResultDto.getList()) {
+                InvoicePrintInfoResult item = payInvoiceResultDto.getList().get(0);
+                {
                     if (item.getC_status().equals("2")) {
                         payInvoiceprinted.setState(1);//已生成
+                        payInvoiceprinted.setOrderNo(item.getC_orderno());
+                        if (StringUtils.isNotBlank(item.getC_kprq()))
+                            payInvoiceprinted.setPrintDate(new Date(new Long(item.getC_kprq())));
+                        payInvoiceprinted.setInvoiceCode(item.getC_fpdm());
+                        payInvoiceprinted.setInvoiceNo(item.getC_fphm());
+                        payInvoiceprinted.setMessage(item.getC_msg());
+                        payInvoiceprinted.setTotalAmount(Double.valueOf(item.getC_bhsje()));
+                        payInvoiceprinted.setInvoiceAmount(Double.valueOf(item.getC_hjse()));
+                        if (StringUtils.isNotBlank(item.getC_bhsje()) && StringUtils.isNotBlank(item.getC_hjse())) {
+                            Double totalPrintAmount = Double.valueOf(item.getC_bhsje()) + Double.valueOf(item.getC_hjse());
+                            payInvoiceprinted.setTotalPrintAmount(totalPrintAmount);
+                        }
+                        payInvoiceprinted.setCheckCode(item.getC_jym());
+                        payInvoiceprinted.setPdfUrl(item.getC_url());
+                        payInvoiceprinted.setJpgUrl(item.getC_jpg_url());
+                        payInvoiceprinted.setRemarks(item.getC_resultmsg());
+                        payInvoiceprinted.setBuyername(item.getC_buyername());
+                        payInvoiceprinted.setTaxnum(item.getC_taxnum());
+                        payInvoiceprinted.setQrCode(item.getQrCode());
                     }
                     if (item.getC_status().equals("20") || item.getC_status().equals("21")) {
-                        payInvoiceprinted.setState(2);//开票中
-                        break;
+                        payInvoiceprinted.setState(0);//开票中 也标注为待生成
                     }
                     if (item.getC_status().equals("22") || item.getC_status().equals("24")) {
                         payInvoiceprinted.setState(4);//开票失败
-                        break;
                     }
                     if (item.getC_status().equals("3") || item.getC_status().equals("31")) {
                         payInvoiceprinted.setState(5);//已作废
-                        break;
                     }
-                    payInvoiceprinted.setOrderNo(item.getC_orderno());
-
-                    if (StringUtils.isNotBlank(item.getC_kprq()))
-                        payInvoiceprinted.setPrintDate(new Date(new Long(item.getC_kprq())));
-                    payInvoiceprinted.setInvoiceCode(item.getC_fpdm());
-                    payInvoiceprinted.setInvoiceNo(item.getC_fphm());
-                    payInvoiceprinted.setMessage(item.getC_msg());
-                    payInvoiceprinted.setTotalAmount(Double.valueOf(item.getC_bhsje()));
-                    payInvoiceprinted.setInvoiceAmount(Double.valueOf(item.getC_hjse()));
-                    if (StringUtils.isNotBlank(item.getC_bhsje()) && StringUtils.isNotBlank(item.getC_hjse())) {
-                        Double totalPrintAmount = Double.valueOf(item.getC_bhsje()) + Double.valueOf(item.getC_hjse());
-                        payInvoiceprinted.setTotalPrintAmount(totalPrintAmount);
-                    }
-                    payInvoiceprinted.setCheckCode(item.getC_jym());
-                    payInvoiceprinted.setPdfUrl(item.getC_url());
-                    payInvoiceprinted.setJpgUrl(item.getC_jpg_url());
-                    payInvoiceprinted.setRemarks(item.getC_resultmsg());
-                    payInvoiceprinted.setBuyername(item.getC_buyername());
-                    payInvoiceprinted.setTaxnum(item.getC_taxnum());
-                    printInvoicePrintService.update(payInvoiceprinted);
                 }
+                printInvoicePrintService.update(payInvoiceprinted);
             }
         }
+        //开票失败则恢复实收及蓝票的状态
         if (payInvoiceprinted.getInvoiceType() == 1) {//开具蓝票
-            if (payInvoiceprinted.getState() == 1 || payInvoiceprinted.getState() == 2) {
-                printInvoicePrintService.updateReceivedIsPrint(true, payInvoiceprinted.getPayseriesno(), payInvoiceprinted.getCustomerId());
+            if (payInvoiceprinted.getState() == 4 || payInvoiceprinted.getState() == 5) {
+                printInvoicePrintService.updateReceivedIsPrint(false, payInvoiceprinted.getPayseriesno(), payInvoiceprinted.getCustomerId());
             }
-        } else {//蓝票冲红
-            if (payInvoiceprinted.getState() == 1 || payInvoiceprinted.getState() == 2) {
+        } else {//蓝票冲红  需明确状态后才更新
+            if (payInvoiceprinted.getState() == 1) {
                 printInvoicePrintService.updateReceivedIsPrint(false, payInvoiceprinted.getPayseriesno(), payInvoiceprinted.getCustomerId());
+                //标记原始蓝票为已冲红 状态3
+                PayInvoiceprinted oldPayInvoiceprinted = new PayInvoiceprinted();
+                oldPayInvoiceprinted.setId(payInvoiceprinted.getCancelInvoiceId());
+                oldPayInvoiceprinted.setState(3);//正常
+                printInvoicePrintService.update(oldPayInvoiceprinted);
             }
-            //标记原始蓝票为已冲红 状态3
-            PayInvoiceprinted oldPayInvoiceprinted = new PayInvoiceprinted();
-            oldPayInvoiceprinted.setId(payInvoiceprinted.getCancelInvoiceId());
-            oldPayInvoiceprinted.setState(3);//已冲红
-            printInvoicePrintService.update(oldPayInvoiceprinted);
         }
     }
 }

+ 4 - 1
smart-city-platform/src/main/resources/application-188sit.properties

@@ -128,4 +128,7 @@ spring.kafka.consumer.enable-auto-commit=true
 #kafka\u751F\u4EA7\u8005\u914D\u7F6E
 spring.kafka.producer.retries=0
 spring.kafka.producer.batch-size=4096
-spring.kafka.producer.buffer-memory=40960
+spring.kafka.producer.buffer-memory=40960
+#发票请求打印接口
+invoice.print.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/cxfKp/cxfServerKpOrderSync.action
+invoice.query.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/ecOd/queryElectricKp.action

+ 3 - 0
smart-city-platform/src/main/resources/application-dev.properties

@@ -160,4 +160,7 @@ spring.rabbitmq.zy.topic=test
 
 #UDIP平台集成元管理url
 udip.unit.url=http://114.135.61.188:48322
+#发票请求打印接口
+invoice.print.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/cxfKp/cxfServerKpOrderSync.action
+invoice.query.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/ecOd/queryElectricKp.action
 

+ 4 - 1
smart-city-platform/src/main/resources/application-prd.properties

@@ -163,4 +163,7 @@ spring.rabbitmq.virtual-host=/
 spring.rabbitmq.zy.topic=zyqueue
 
 #UDIP平台集成元管理url
-udip.unit.url=http://47.112.15.78:8322
+udip.unit.url=http://47.112.15.78:8322
+#发票请求打印接口
+invoice.print.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/cxfKp/cxfServerKpOrderSync.action
+invoice.query.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/ecOd/queryElectricKp.action

+ 4 - 1
smart-city-platform/src/main/resources/application-sit.properties

@@ -162,4 +162,7 @@ spring.rabbitmq.virtual-host=/
 spring.rabbitmq.zy.topic=hello
 
 #UDIP平台集成元管理url
-udip.unit.url=http://114.135.61.188:48322
+udip.unit.url=http://114.135.61.188:48322
+#发票请求打印接口
+invoice.print.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/cxfKp/cxfServerKpOrderSync.action
+invoice.query.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/ecOd/queryElectricKp.action

+ 4 - 1
smart-city-platform/src/main/resources/application-uat.properties

@@ -137,4 +137,7 @@ easylinkin.api.url.gateway.ap=http://api.easylinkin.com/api/v1/application/ap
 service.domain=http://www.zoniot.com
 
 #UDIP平台集成元管理url
-udip.unit.url=http://114.135.61.188:48322
+udip.unit.url=http://114.135.61.188:48322
+#发票请求打印接口
+invoice.print.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/cxfKp/cxfServerKpOrderSync.action
+invoice.query.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/ecOd/queryElectricKp.action

+ 1 - 0
smart-city-platform/src/main/resources/mapper/pay/PayInvoicePrintMapper.xml

@@ -104,6 +104,7 @@
 			<if test="payInvoiceprinted.remarks != null">remarks=#{payInvoiceprinted.remarks},</if>
 			<if test="payInvoiceprinted.buyername != null">buyername=#{payInvoiceprinted.buyername},</if>
 			<if test="payInvoiceprinted.taxnum != null">taxnum=#{payInvoiceprinted.taxnum},</if>
+			<if test="payInvoiceprinted.qrCode != null">qrcode=#{payInvoiceprinted.qrCode},</if>
 		</set>
 		where id=#{payInvoiceprinted.id,jdbcType=BIGINT}
 	</update>