Browse Source

电子发票打印代码

609324174@qq.com 4 years ago
parent
commit
a490730722
21 changed files with 719 additions and 66 deletions
  1. 1 0
      smart-city-platform/src/main/java/com/bz/smart_city/commom/security/WebSecurityConfig.java
  2. 18 5
      smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayPrintInvoiceController.java
  3. 28 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayInvoicePrintMapper.java
  4. 27 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/InvoicePrintInfoResult.java
  5. 18 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayEleInvoiceRequestDto.java
  6. 19 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayInvoiceResultDto.java
  7. 16 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/ReturnPrintResultDto.java
  8. 88 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayInvoiceprinted.java
  9. 42 0
      smart-city-platform/src/main/java/com/bz/smart_city/quartz/job/InvoicePrintResultJob.java
  10. 132 48
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/IssueElectronicInvoiceServiceImpl.java
  11. 5 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayBaseConfigServiceImpl.java
  12. 15 8
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayInvoiceParamServiceImpl.java
  13. 48 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayInvoicePrintServiceImpl.java
  14. 101 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PrintInvoiceQueryResultServiceImpl.java
  15. 3 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/IssueElectronicInvoiceService.java
  16. 3 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayBaseConfigService.java
  17. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayInvoiceParamService.java
  18. 28 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PrintInvoicePrintService.java
  19. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/archives/PayBaseCustomerandmeterrelaService.java
  20. 2 3
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/archives/impl/PayBaseCustomerandmeterrelaServiceImpl.java
  21. 122 0
      smart-city-platform/src/main/resources/mapper/pay/PayInvoicePrintMapper.xml

+ 1 - 0
smart-city-platform/src/main/java/com/bz/smart_city/commom/security/WebSecurityConfig.java

@@ -99,6 +99,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/watermeter/getMeterReadData","/watermeter/getDeviceCustomerInfo","/watermeter/getPeriodMeterReadData","/data/clearingData","/data/meterReadData")
                 .antMatchers("/apply/register","/apply/detail","/apply/approve")
                 .antMatchers("/payFee/payFee")
+                .antMatchers("/printinvoice/InvoicePrintRequest")
                 .antMatchers("/waterMeter/getMeterByDeviceNo")
                 .antMatchers("/device/synArchies")
                 .antMatchers("/druid/**");

+ 18 - 5
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayPrintInvoiceController.java

@@ -1,11 +1,16 @@
 package com.bz.smart_city.controller.pay;
 
+import com.bz.smart_city.commom.model.AjaxMessage;
+import com.bz.smart_city.commom.model.ResultStatus;
+import com.bz.smart_city.dto.pay.ReturnPrintResultDto;
 import com.bz.smart_city.service.pay.IssueElectronicInvoiceService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
@@ -22,10 +27,18 @@ public class PayPrintInvoiceController {
     @Autowired
     private IssueElectronicInvoiceService issueElectronicInvoiceService;
 
-    @ApiOperation(value = "请求打印")
-    @GetMapping(value = "/printRequest")
-    public void printInoice()
-    {
-        issueElectronicInvoiceService.requestPrint("1","0460000003","C046000000301200522155950402");
+    @ApiOperation(value = "发票打印")
+    @GetMapping(value = "/InvoicePrintRequest")
+    public AjaxMessage<ReturnPrintResultDto> InvoicePrintRequest(@ApiParam(value = "用户编号", required = true) @RequestParam(required = true) String userCode, @ApiParam(value = "缴费流水号", required = true) @RequestParam(required = true) String payseriesno) {
+        ReturnPrintResultDto returnPrintResultDto = issueElectronicInvoiceService.requestPrint("1", userCode, payseriesno, null);
+        return new AjaxMessage<>(ResultStatus.OK, returnPrintResultDto);
     }
+
+    @ApiOperation(value = "发票冲红")
+    @GetMapping(value = "/cancelInvoicePrint")
+    public AjaxMessage<ReturnPrintResultDto> cancelInvoicePrint(@ApiParam(value = "用户编号", required = true) @RequestParam(required = true) String userCode, @ApiParam(value = "票据ID", required = true) @RequestParam(required = true) String invoicePrintId) {
+        ReturnPrintResultDto returnPrintResultDto = issueElectronicInvoiceService.requestPrint("2", null, null, invoicePrintId);
+        return new AjaxMessage<>(ResultStatus.OK, returnPrintResultDto);
+    }
+
 }

+ 28 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayInvoicePrintMapper.java

@@ -0,0 +1,28 @@
+package com.bz.smart_city.dao.pay;
+
+import com.bz.smart_city.entity.pay.PayInvoiceprinted;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigInteger;
+import java.util.List;
+
+/**
+ * @ClassName PayInvoicePrintMapper
+ * @Description: 发票信息
+ * @Author :WYY
+ * @Date 2020/8/10
+ * @Version V1.0
+ **/
+@Mapper
+public interface PayInvoicePrintMapper {
+    Integer insert(PayInvoiceprinted payInvoiceprinted);
+
+    Integer update(@Param("payInvoiceprinted") PayInvoiceprinted payInvoiceprinted);
+
+    PayInvoiceprinted findInvoiceByPayseriesno(@Param("invoicePrintId") String invoicePrintId, @Param("siteId") BigInteger siteId, @Param("customerId") BigInteger customerId);
+
+    List<PayInvoiceprinted> findListByState();
+
+    Integer updateReceivedIsPrint(@Param("isPrint") Boolean isPrint, @Param("payseriesno") String payseriesno, @Param("customerId") BigInteger customerId);
+}

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

@@ -0,0 +1,27 @@
+package com.bz.smart_city.dto.pay;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import lombok.Data;
+
+@JsonInclude(value=Include.NON_NULL)
+@Data
+public class InvoicePrintInfoResult {
+	private String c_orderno;
+	private String c_fpqqlsh;
+	private String c_status;
+	private String  c_msg;
+	private String c_url;
+	private String c_jpg_url;
+	private String c_kprq;
+	private String c_fpdm;
+	private String c_fphm;
+	private String c_bhsje;
+	private String c_hjse;
+	private String c_resultmsg;
+	private String c_invoiceid;
+	private String c_buyername;
+	private String c_taxnum;
+	private String c_jym;
+	private String c_invoice_line;
+}

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

@@ -0,0 +1,18 @@
+package com.bz.smart_city.dto.pay;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+/**
+ * @ClassName PayEleInvoiceDto
+ * @Description: 电子发票信息
+ * @Author :WYY
+ * @Date 2020/7/28
+ * @Version V1.0
+ **/
+@Data
+@ApiModel(value = "电子发票查询主体信息")
+public class PayEleInvoiceRequestDto {
+    private String identity;
+    private String[] fpqqlsh;
+}

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

@@ -0,0 +1,19 @@
+package com.bz.smart_city.dto.pay;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @ClassName PayInvoiceResultDto
+ * @Description: TODO
+ * @Author :WYY
+ * @Date 2020/8/10
+ * @Version V1.0
+ **/
+@Data
+public class PayInvoiceResultDto {
+    private String result;
+    private String errorMsg;
+    private List<InvoicePrintInfoResult> list;
+}

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

@@ -0,0 +1,16 @@
+package com.bz.smart_city.dto.pay;
+
+import lombok.Data;
+
+/**
+ * @ClassName ReturnPrintResultDto
+ * @Description: 票据打印返回结果
+ * @Author :WYY
+ * @Date 2020/8/11
+ * @Version V1.0
+ **/
+@Data
+public class ReturnPrintResultDto {
+    private String result;
+    private String msg;
+}

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

@@ -0,0 +1,88 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package com.bz.smart_city.entity.pay;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+
+import java.math.BigInteger;
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * 发票信息Entity
+ * @author lzd
+ * @version 2018-11-29
+ */
+@Data
+@ApiModel(value = "发票信息")
+public class PayInvoiceprinted extends PayBaseInfo {
+	@ApiModelProperty(value = "发票流水号")
+	private String printNo;
+	@ApiModelProperty(value = "发票请求流水号")
+	private String fpqqlsh;
+	@ApiModelProperty(value = "原发票代码")
+	private String oldInvoiceCode;
+	@ApiModelProperty(value = "原发票号码")
+	private String oldInvoiceNo;
+	@ApiModelProperty(value = "实收批次号")
+	private String payseriesno;
+	@ApiModelProperty(value = "客户ID")
+	private BigInteger accountId;
+	@ApiModelProperty(value = "阶税合计")
+	private Double totalPrintAmount;
+	@ApiModelProperty(value = "合计金额")
+	private Double totalAmount;
+	@ApiModelProperty(value = "合计税额")
+	private Double invoiceAmount;
+	@ApiModelProperty(value = "发票代码")
+	private String invoiceCode;
+	@ApiModelProperty(value = "发票号码")
+	private String invoiceNo;
+	@ApiModelProperty(value = "发票密文")
+	private String ciphertext;
+	@ApiModelProperty(value = "发票校验码")
+	private String checkCode;
+	@ApiModelProperty(value = "开票日期")
+	private Date printDate;
+	@ApiModelProperty(value = "发票状态 0:待生成 1:正常 2: 开票中 3:已冲红 4:开票失败  5:已作废")
+	private Integer state;
+	@ApiModelProperty(value = "发票类型 1:蓝票 2:红票")
+	private Integer invoiceType;
+	@ApiModelProperty(value = "票据类型 1:收据 2:发票")
+	private Integer type;
+	@ApiModelProperty(value = "发票种类")
+	private String invoiceLine;
+	@ApiModelProperty(value = "推送状态  1 已推送, 0未推送")
+	private Integer sendtype;
+	@ApiModelProperty(value = "作废时间")
+	private Date canceltime;
+	@ApiModelProperty(value = "消息")
+	private String message;
+	@ApiModelProperty(value = "订单号")
+	private String orderNo;
+	@ApiModelProperty(value = "发票PDF路径")
+	private String pdfUrl;
+	@ApiModelProperty(value = "发票JPG路径")
+	private String jpgUrl;
+	@ApiModelProperty(value = "购方名称")
+	private String buyername;
+	@ApiModelProperty(value = "购方税号")
+	private String taxnum;
+	@ApiModelProperty(value = "主键")
+	private BigInteger id;
+	@ApiModelProperty(value = "客户编号")
+	private String userCode;
+	@ApiModelProperty(value = "被冲红记录ID")
+	private BigInteger cancelInvoiceId;
+	@ApiModelProperty(value = "身份认证号")
+	private String saleIdentity;
+}
+
+

+ 42 - 0
smart-city-platform/src/main/java/com/bz/smart_city/quartz/job/InvoicePrintResultJob.java

@@ -0,0 +1,42 @@
+package com.bz.smart_city.quartz.job;
+
+import com.bz.smart_city.entity.pay.PayInvoiceprinted;
+import com.bz.smart_city.service.impl.pay.PrintInvoiceQueryResultServiceImpl;
+import com.bz.smart_city.service.pay.PayInvoiceParamService;
+import com.bz.smart_city.service.pay.PrintInvoicePrintService;
+import org.apache.juli.logging.Log;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Configurable;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @ClassName InvoicePrintResultJob
+ * @Description: 发票结果查询
+ * @Author :WYY
+ * @Date 2020/8/11
+ * @Version V1.0
+ **/
+@Component
+public class InvoicePrintResultJob {
+    @Autowired
+    private PrintInvoicePrintService printInvoicePrintService;
+    @Autowired
+    private PrintInvoiceQueryResultServiceImpl printInvoiceQueryResultService;
+
+    @Scheduled(cron = "0 0 0/1 * * ?")
+    private void queryResult() {
+        List<PayInvoiceprinted> payInvoiceprinteds = printInvoicePrintService.findListByState();
+        for (PayInvoiceprinted item : payInvoiceprinteds) {
+            try {
+                printInvoiceQueryResultService.queryPrintInvoiceInfo(item);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+    }
+}

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

@@ -1,21 +1,17 @@
 package com.bz.smart_city.service.impl.pay;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.bz.smart_city.commom.model.Pagination;
-import com.bz.smart_city.commom.util.DESDZFP;
-import com.bz.smart_city.commom.util.HttpClientUtils;
-import com.bz.smart_city.commom.util.RandomUtil;
-import com.bz.smart_city.commom.util.UserUtil;
+import com.bz.smart_city.commom.util.*;
 import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.pay.*;
-import com.bz.smart_city.entity.pay.PayBaseAccount;
 import com.bz.smart_city.entity.pay.PayInvoiceParam;
+import com.bz.smart_city.entity.pay.PayInvoiceprinted;
 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 com.google.gson.JsonObject;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
@@ -42,12 +38,17 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
     PayPayReceivedService payPayReceivedService;
     @Autowired
     PayBaseCustomerandmeterrelaService payBaseCustomerandmeterrelaService;
+    @Autowired
+    PrintInvoicePrintService printInvoicePrintService;
+    @Autowired
+    PrintInvoiceQueryResultServiceImpl printInvoiceQueryResultService;
+    @Autowired
+    private SnowflakeIdWorker idWorker;
 
-    private Map<String, String> getPrintParam() {
+    private Map<String, String> getPrintParam(Integer siteId, Integer customerId) {
         Map<String, String> map = new HashMap<>();
         //查询销方参数
-        Pagination<PayBaseConfigDto> payBaseConfigDtoPagination = payBaseConfigService.getAll("PRINT_", 1, 15);
-        List<PayBaseConfigDto> payBaseConfigDtos = payBaseConfigDtoPagination.getList();
+        List<PayBaseConfigDto> payBaseConfigDtos = payBaseConfigService.getPrintInfo("PRINT_", siteId, customerId);
         for (PayBaseConfigDto item : payBaseConfigDtos) {
             switch (item.getName().trim()) {
                 case "PRINT_INVOICE_ADDRESS":
@@ -76,9 +77,9 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
         return map;
     }
 
-    private Map<Integer, PayInvoiceParam> getInvoiceParam() {
+    private Map<Integer, PayInvoiceParam> getInvoiceParam(Integer siteId, Integer customerId) {
         Map<Integer, PayInvoiceParam> map = new HashMap<>();
-        List<PayInvoiceParam> payInvoiceParams = payInvoiceParamService.findList(null);
+        List<PayInvoiceParam> payInvoiceParams = payInvoiceParamService.findList(null, siteId, customerId);
         for (PayInvoiceParam item : payInvoiceParams) {
             map.put(item.getFeetype(), item);
         }
@@ -90,82 +91,114 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
         return a;
     }
 
-    public BigDecimal saveEightDecimal(BigDecimal d) {
-        BigDecimal a = d.setScale(8, BigDecimal.ROUND_HALF_UP);
-        return a;
-    }
-
     /**
-     * @MethodName:
-     * @Description: TODO
+     * @return
+     * @MethodName:请求开票
+     * @Description: 请求开票
      * @Param: kpType 开票类型  1 正票 2 红票  userCode 用户号 payseriesno 缴费流水号
      * @Return:
      * @Author:
      * @Date: 2020/7/28
-     **/
-    public void requestPrint(String kpType, String userCode, String payseriesno) {
+     */
+    public ReturnPrintResultDto requestPrint(String kpType, String userCode, String payseriesno, String invoicePrintId){
         LoginUser loginUser = UserUtil.getCurrentUser();
         String name = loginUser.getName();//操作员姓名
-        BigInteger siteId = BigInteger.valueOf(loginUser.getSiteId());
-        BigInteger customerId = BigInteger.valueOf(loginUser.getCustomerId());
-
-        Map<String, String> invoiceParam = getPrintParam();//发票参数
-        PayEleInvoiceDto payEleInvoiceDto = new PayEleInvoiceDto();
-        payEleInvoiceDto.setIdentity(invoiceParam.get("saleIdentity"));
-
-        Map<Integer, PayInvoiceParam> invoiceMap = getInvoiceParam();//税率相关参数
 
+        ReturnPrintResultDto returnPrintResultDto = new ReturnPrintResultDto();//开票返回结果信息
         PayInvoiceOrderDto payInvoiceOrderDto = new PayInvoiceOrderDto();//开票订单信息
+        PayEleInvoiceDto payEleInvoiceDto = new PayEleInvoiceDto();//电子发票请求主体信息
+        PayInvoiceprinted oldInvoiceprinted = new PayInvoiceprinted();//原始蓝票信息(红票时处理)
+        List<PayInvoiceOrderDetailDto> orderDetailDtos = new ArrayList<>();//蓝票详细信息
+        Map<String, String> invoiceParam = getPrintParam(loginUser.getSiteId(), loginUser.getCustomerId());//销方开票信息
+        Map<Integer, PayInvoiceParam> invoiceMap = getInvoiceParam(loginUser.getSiteId(), loginUser.getCustomerId());//税率相关参数
+        payEleInvoiceDto.setIdentity(invoiceParam.get("saleIdentity"));//认证信息
+
         payInvoiceOrderDto.setSaleaccount(invoiceParam.get("saleAccount"));//销方银行账号
         payInvoiceOrderDto.setSalephone(invoiceParam.get("salePhone"));//销方电话
         payInvoiceOrderDto.setSaleaddress(invoiceParam.get("saleAddress"));//销方地址
         payInvoiceOrderDto.setSaletaxnum(invoiceParam.get("saleCode"));//销方税号
         payInvoiceOrderDto.setChecker(invoiceParam.get("saleChecker"));//复核人
-        if(name.length()>4) {
+        payInvoiceOrderDto.setKptype(kpType);//开票类型
+        payInvoiceOrderDto.setTsfs("2");//推送方式
+        payInvoiceOrderDto.setInvoicedate(LocalDateTime.now());//开票时间
+        payInvoiceOrderDto.setOrderno(RandomUtil.getRandomString());//订单号
+
+        if (name.length() > 4) {
             name = "*" + name.substring(name.length() - 3, name.length());
             payInvoiceOrderDto.setClerk(name);//开票人
             payInvoiceOrderDto.setPayee(name);//收款人
         }
 
-        payInvoiceOrderDto.setKptype(kpType);//开票类型
-        payInvoiceOrderDto.setTsfs("2");//推送方式
-        payInvoiceOrderDto.setInvoicedate(LocalDateTime.now());
-        payInvoiceOrderDto.setOrderno(RandomUtil.getRandomString());
+        if (kpType.equals("2")) {//红票按蓝票票ID查询
+            oldInvoiceprinted = printInvoicePrintService.findInvoiceByPayseriesno(invoicePrintId, BigInteger.valueOf(loginUser.getSiteId()), BigInteger.valueOf(loginUser.getCustomerId()));
+            if (oldInvoiceprinted != null && oldInvoiceprinted.getInvoiceCode() != null) {
+                payInvoiceOrderDto.setFpdm(oldInvoiceprinted.getInvoiceCode());
+                payInvoiceOrderDto.setFphm(oldInvoiceprinted.getInvoiceNo());
+                payInvoiceOrderDto.setMessage("对应正数发票代码:" + oldInvoiceprinted.getInvoiceCode() + "号码:" + oldInvoiceprinted.getInvoiceNo());
+                payseriesno = oldInvoiceprinted.getPayseriesno();
+            } else {
+                returnPrintResultDto.setResult("1");//开票失败
+                returnPrintResultDto.setMsg("开票失败,失败原因:冲红蓝票信息缺失");
+                return returnPrintResultDto;
+            }
+        }
+
         //查询购方相关信息
-        PayBaseCustomerandmeterrela payBaseAccount = payBaseCustomerandmeterrelaService.findAccountByAccountNumber(userCode);
+        PayBaseCustomerandmeterrela payBaseAccount = payBaseCustomerandmeterrelaService.findAccountByAccountNumber(userCode, loginUser.getSiteId(), loginUser.getCustomerId());
+        if (payBaseAccount == null) {
+            returnPrintResultDto.setResult("1");//开票失败
+            returnPrintResultDto.setMsg("开票失败,失败原因:购方信息缺失");
+            return returnPrintResultDto;
+        }
         payInvoiceOrderDto.setBuyername(payBaseAccount.getAccountname());//购方名称
         payInvoiceOrderDto.setPhone(payBaseAccount.getTelephone());//电话
         payInvoiceOrderDto.setAddress(payBaseAccount.getAddress());//地址
         payInvoiceOrderDto.setAccount(payBaseAccount.getBankaccount());//银行账号
         payInvoiceOrderDto.setTelephone(payBaseAccount.getTelephone());//电话
+        payInvoiceOrderDto.setTaxnum(payBaseAccount.getVatno());//购方税号
 
-        List<PayInvoiceOrderDetailDto> orderDetailDtos = new ArrayList<>();
         //循环加入明细
         List<PayReceivedInvoiceDto> payReceivedInvoiceDtos = payPayReceivedService.findInvoiceReceivedByPayseriesno(payseriesno, loginUser.getSiteId(), loginUser.getCustomerId());
-        //将水费分开,其他类型水费合并todo
         for (PayReceivedInvoiceDto item : payReceivedInvoiceDtos) {
             PayInvoiceOrderDetailDto orderDetailDto = new PayInvoiceOrderDetailDto();
             PayInvoiceParam payInvoiceParam = invoiceMap.get(item.getFeetype());
             orderDetailDto.setGoodsname(item.getFeetypename());
-            orderDetailDto.setTaxamt(String.valueOf(saveTwoDecimal(item.getReceivedamount())));//含税金额
+            if (kpType.equals("1")) {//蓝票
+                orderDetailDto.setTaxamt(String.valueOf(saveTwoDecimal(item.getReceivedamount())));//含税金额
+            } else {
+                orderDetailDto.setTaxamt(String.valueOf(saveTwoDecimal(item.getReceivedamount().multiply(BigDecimal.valueOf(-1)))));//含税金额
+            }
             //含税标志为1 含税,税额=round((数量*含税单价)*税率/(1+税率)),2),不含税金额=含税金额-税额
             //含税标志为0 不含税,税额=round((数量*不含税单价)*税率),2),含税金额=不含税金额+税额
             BigDecimal taxAmount = new BigDecimal(0);//税额
             BigDecimal receAmount = item.getReceivedamount();//实收金额
             BigDecimal rate = new BigDecimal(payInvoiceParam.getTaxrate());//税率
             if (payInvoiceParam.getPricetax().equals("1")) {
-                taxAmount = saveTwoDecimal(receAmount.multiply(rate).divide(rate.add(BigDecimal.valueOf(1)),2, BigDecimal.ROUND_HALF_UP));
-                orderDetailDto.setTax(String.valueOf(saveTwoDecimal(taxAmount)));//税额
-                orderDetailDto.setTaxfreeamt(String.valueOf(saveTwoDecimal(receAmount.subtract(taxAmount))));//不含税金额
+                taxAmount = saveTwoDecimal(receAmount.multiply(rate).divide(rate.add(BigDecimal.valueOf(1)), 2, BigDecimal.ROUND_HALF_UP));
+                if (kpType.equals("2")) {
+                    orderDetailDto.setTax(String.valueOf(saveTwoDecimal(taxAmount.multiply(BigDecimal.valueOf(-1)))));//税额
+                    orderDetailDto.setTaxfreeamt(String.valueOf(saveTwoDecimal(receAmount.subtract(taxAmount).multiply(BigDecimal.valueOf(-1)))));//不含税金额
+                } else {
+                    orderDetailDto.setTax(String.valueOf(saveTwoDecimal(taxAmount)));//税额
+                    orderDetailDto.setTaxfreeamt(String.valueOf(saveTwoDecimal(receAmount.subtract(taxAmount))));//不含税金额
+                }
             } else {
                 taxAmount = saveTwoDecimal(receAmount.multiply(rate));
-                orderDetailDto.setTax(String.valueOf(saveTwoDecimal(taxAmount)));//税额
-                orderDetailDto.setTaxfreeamt(String.valueOf(saveTwoDecimal(receAmount.add(taxAmount))));//不含税金额
+                if (kpType.equals("2")) {
+                    orderDetailDto.setTax(String.valueOf(saveTwoDecimal(taxAmount)));//税额
+                    orderDetailDto.setTaxfreeamt(String.valueOf(saveTwoDecimal(receAmount.add(taxAmount).multiply(BigDecimal.valueOf(-1)))));//不含税金额
+                } else {
+                    orderDetailDto.setTax(String.valueOf(saveTwoDecimal(taxAmount)));//税额
+                    orderDetailDto.setTaxfreeamt(String.valueOf(saveTwoDecimal(receAmount.add(taxAmount).multiply(BigDecimal.valueOf(-1)))));//不含税金额
+                }
             }
-
             if (item.getPrice() != null) {
                 orderDetailDto.setPrice(String.valueOf(saveTwoDecimal(item.getPrice())));
-                orderDetailDto.setNum(String.valueOf(receAmount.divide(saveTwoDecimal(item.getPrice()), 8, BigDecimal.ROUND_HALF_UP)));
+                if (kpType.equals("1")) {
+                    orderDetailDto.setNum(String.valueOf(receAmount.divide(saveTwoDecimal(item.getPrice()), 8, BigDecimal.ROUND_HALF_UP)));
+                } else {
+                    orderDetailDto.setNum(String.valueOf(receAmount.divide(saveTwoDecimal(item.getPrice()), 8, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(-1))));
+                }
             }
             if (!payInvoiceParam.getZerotax().equals("0")) {
                 orderDetailDto.setLslbs(payInvoiceParam.getZerotax());//零税率标志
@@ -183,8 +216,13 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
 
             orderDetailDtos.add(orderDetailDto);
         }
+        if (orderDetailDtos.size() == 0) {
+            returnPrintResultDto.setResult("1");//开票失败
+            returnPrintResultDto.setMsg("开票失败,失败原因:发票详细信息缺失");
+            return returnPrintResultDto;
+        }
         payInvoiceOrderDto.setDetail(orderDetailDtos);
-        payInvoiceOrderDto.setEmail("wangyangyang@hxiswater.com");
+        payInvoiceOrderDto.setEmail(invoiceParam.get("saleEmail"));
         payEleInvoiceDto.setOrder(payInvoiceOrderDto);
         //发送开票请求
         String jsonsString = DESDZFP.encrypt(JSON.toJSONString(payEleInvoiceDto));
@@ -192,9 +230,55 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
         map.put("order", jsonsString);
         try {
             String returnString = HttpClientUtils.doPost("http://nnfpbox.nuonuocs.cn/shop/buyer/allow/cxfKp/cxfServerKpOrderSync.action", map);
-            System.out.println("returnString:" + returnString);
+            JSONObject jsonObject = (JSONObject) JSON.parse(returnString);
+            PayInvoiceprinted payInvoiceprinted = new PayInvoiceprinted();//发票信息
+            payInvoiceprinted.setTaxnum(payInvoiceOrderDto.getTaxnum());
+            payInvoiceprinted.setSendtype(2);
+            payInvoiceprinted.setInvoiceType(1);
+            payInvoiceprinted.setPrintNo(payInvoiceOrderDto.getOrderno());
+            payInvoiceprinted.setOrderNo(payInvoiceOrderDto.getOrderno());
+            payInvoiceprinted.setPayseriesno(payseriesno);
+            payInvoiceprinted.setAccountId(payBaseAccount.getAccountId());
+            payInvoiceprinted.setCreateBy(BigInteger.valueOf(loginUser.getId()));
+            payInvoiceprinted.setCreateDate(LocalDateTime.now());
+            payInvoiceprinted.setUpdateBy(BigInteger.valueOf(loginUser.getId()));
+            payInvoiceprinted.setUpdateDate(LocalDateTime.now());
+            payInvoiceprinted.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
+            payInvoiceprinted.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
+            payInvoiceprinted.setDelFlag("0");
+            payInvoiceprinted.setRemarks(jsonObject.getString("message"));
+            payInvoiceprinted.setType(1); //发票
+            payInvoiceprinted.setInvoiceType(1); //蓝票
+            payInvoiceprinted.setInvoiceLine("p");
+            payInvoiceprinted.setUserCode(userCode);
+            payInvoiceprinted.setSaleIdentity(invoiceParam.get("saleIdentity"));
+            if (kpType.equals("2")) {
+                payInvoiceprinted.setInvoiceType(2);//红票
+                payInvoiceprinted.setCancelInvoiceId(BigInteger.valueOf(Long.parseLong(invoicePrintId)));
+                payInvoiceprinted.setOldInvoiceCode(oldInvoiceprinted.getInvoiceCode());
+                payInvoiceprinted.setOldInvoiceNo(oldInvoiceprinted.getInvoiceNo());
+            }
+
+            if (jsonObject.getString("status").equals("0000"))//开票成功
+            {
+                payInvoiceprinted.setId(BigInteger.valueOf(idWorker.nextId()));
+                payInvoiceprinted.setState(0);//待生成
+                payInvoiceprinted.setFpqqlsh(jsonObject.getString("fpqqlsh"));
+                returnPrintResultDto.setResult("0");//开票失败
+                returnPrintResultDto.setMsg("开票成功,请等待系统票据查询结果");
+                //开票成功的情况,新保存开票的相关信息,查询时再进行更新
+                int num = printInvoicePrintService.insert(payInvoiceprinted);
+                //异步查询结果,根据查询结果进行更新票据相关信息
+                printInvoiceQueryResultService.queryPrintInvoiceInfo(payInvoiceprinted);
+            } else {//开票失败
+                payInvoiceprinted.setState(4);//开票失败
+                returnPrintResultDto.setResult("1");//开票失败
+                returnPrintResultDto.setMsg("开票失败,失败原因:" + jsonObject.getString("message"));
+            }
         } catch (Exception e) {
-            e.printStackTrace();
+            returnPrintResultDto.setResult("1");//开票失败
+            returnPrintResultDto.setMsg("开票失败,失败原因:" + e.getMessage());
         }
+        return returnPrintResultDto;
     }
 }

+ 5 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayBaseConfigServiceImpl.java

@@ -67,6 +67,11 @@ public class PayBaseConfigServiceImpl implements PayBaseConfigService {
         List<PayBaseConfigDto> payBaseConfigList = payBaseConfigMapper.getNameCnname(queryInfo,loginUser.getSiteId(),loginUser.getCustomerId());
         return new Pagination<>(payBaseConfigList);
     }
+    @Override
+    public List<PayBaseConfigDto> getPrintInfo(String queryInfo, Integer siteId, Integer customerId) {
+        List<PayBaseConfigDto> payBaseConfigList = payBaseConfigMapper.getNameCnname(queryInfo, siteId, customerId);
+        return payBaseConfigList;
+    }
 
     @Override
     public int delete(BigInteger id) {

+ 15 - 8
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayInvoiceParamServiceImpl.java

@@ -39,6 +39,7 @@ public class PayInvoiceParamServiceImpl implements PayInvoiceParamService {
     PaySysDictMapper paySysDictMapper;
     @Autowired
     PayBaseConfigService payBaseConfigService;
+
     @Override
     public int batchInsert() {
         //1、从登陆信息中获取站点Id 水司ID
@@ -47,7 +48,7 @@ public class PayInvoiceParamServiceImpl implements PayInvoiceParamService {
         BigInteger customerId = BigInteger.valueOf(loginUser.getCustomerId());
         List<PaySysDictSelectDto> paySysDictSelectDtos = paySysDictMapper.getDicts("收费类型", siteId, customerId);
         List<PayInvoiceParam> list = new ArrayList<PayInvoiceParam>();
-        for (PaySysDictSelectDto item: paySysDictSelectDtos) {
+        for (PaySysDictSelectDto item : paySysDictSelectDtos) {
             PayInvoiceParam payInvoiceParam = new PayInvoiceParam();
             payInvoiceParam.setFeetype(Integer.valueOf(item.getValue()));
             payInvoiceParam.setDelFlag("0");
@@ -66,6 +67,7 @@ public class PayInvoiceParamServiceImpl implements PayInvoiceParamService {
     public int update(PayInvoiceParam payInvoiceParam) {
         return payInvoiceParamMapper.update(payInvoiceParam);
     }
+
     @Override
     public List<PayInvoiceParam> findList(String queryparam) {
         LoginUser loginUser = UserUtil.getCurrentUser();
@@ -113,18 +115,23 @@ public class PayInvoiceParamServiceImpl implements PayInvoiceParamService {
             payBaseConfig.setName("PRINT_EMAIL");
             payBaseConfig.setType("0");
             payBaseConfigService.add(payBaseConfig);
-        }catch (Exception ex)
-        {
+        } catch (Exception ex) {
             //异常不处理,可手动添加
         }
 
         //发票参数
-        List<PayInvoiceParam> payInvoiceParams = payInvoiceParamMapper.findList(queryparam,siteId,customerId);
-        if(payInvoiceParams.size()==0)
-        {
+        List<PayInvoiceParam> payInvoiceParams = payInvoiceParamMapper.findList(queryparam, siteId, customerId);
+        if (payInvoiceParams.size() == 0) {
             batchInsert();
-            payInvoiceParams = payInvoiceParamMapper.findList(queryparam,siteId,customerId);
+            payInvoiceParams = payInvoiceParamMapper.findList(queryparam, siteId, customerId);
         }
-        return  payInvoiceParams;
+        return payInvoiceParams;
+    }
+
+    @Override
+    public List<PayInvoiceParam> findList(String queryparam, Integer siteId, Integer customerId) {
+        //发票参数
+        List<PayInvoiceParam> payInvoiceParams = payInvoiceParamMapper.findList(queryparam, BigInteger.valueOf(siteId), BigInteger.valueOf(customerId));
+        return payInvoiceParams;
     }
 }

+ 48 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayInvoicePrintServiceImpl.java

@@ -0,0 +1,48 @@
+package com.bz.smart_city.service.impl.pay;
+
+import com.bz.smart_city.dao.pay.PayInvoicePrintMapper;
+import com.bz.smart_city.entity.pay.PayInvoiceprinted;
+import com.bz.smart_city.service.pay.PrintInvoicePrintService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigInteger;
+import java.util.List;
+
+/**
+ * @ClassName PayInvoicePrintServiceImpl
+ * @Description: TODO
+ * @Author :WYY
+ * @Date 2020/8/10
+ * @Version V1.0
+ **/
+@Service
+public class PayInvoicePrintServiceImpl implements PrintInvoicePrintService {
+    @Resource
+    private PayInvoicePrintMapper payInvoicePrintMapper;
+
+    @Override
+    public Integer insert(PayInvoiceprinted payInvoiceprinted) {
+        return payInvoicePrintMapper.insert(payInvoiceprinted);
+    }
+
+    @Override
+    public Integer update(PayInvoiceprinted payInvoiceprinted) {
+        return payInvoicePrintMapper.update(payInvoiceprinted);
+    }
+
+    @Override
+    public PayInvoiceprinted findInvoiceByPayseriesno(String invoicePrintId, BigInteger siteId, BigInteger customerId) {
+        return payInvoicePrintMapper.findInvoiceByPayseriesno(invoicePrintId, siteId, customerId);
+    }
+
+    @Override
+    public List<PayInvoiceprinted> findListByState() {
+        return payInvoicePrintMapper.findListByState();
+    }
+
+    @Override
+    public Integer updateReceivedIsPrint(Boolean isPrint, String payseriesno, BigInteger customerId) {
+        return payInvoicePrintMapper.updateReceivedIsPrint(isPrint,payseriesno,customerId);
+    }
+}

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

@@ -0,0 +1,101 @@
+package com.bz.smart_city.service.impl.pay;
+
+import com.alibaba.fastjson.JSON;
+import com.bz.smart_city.commom.util.DESDZFP;
+import com.bz.smart_city.commom.util.HttpClientUtils;
+import com.bz.smart_city.dto.pay.InvoicePrintInfoResult;
+import com.bz.smart_city.dto.pay.PayEleInvoiceRequestDto;
+import com.bz.smart_city.dto.pay.PayInvoiceResultDto;
+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.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import java.math.BigInteger;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @ClassName PrintInvoiceQueryResultServiceImpl
+ * @Description: 票据查询异步方法
+ * @Author :WYY
+ * @Date 2020/8/11
+ * @Version V1.0
+ **/
+@Service
+public class PrintInvoiceQueryResultServiceImpl {
+    @Autowired
+    PrintInvoicePrintService printInvoicePrintService;
+
+    @Async
+    public void queryPrintInvoiceInfo(PayInvoiceprinted payInvoiceprinted) throws Exception {
+        //创建票据打印记录信息
+        if (payInvoiceprinted.getFpqqlsh() != null && payInvoiceprinted.getFpqqlsh().length() > 0) {
+            Thread.sleep(30 * 1000);
+            PayEleInvoiceRequestDto payEleInvoiceRequestDto = new PayEleInvoiceRequestDto();
+            payEleInvoiceRequestDto.setIdentity(payInvoiceprinted.getSaleIdentity());
+            payEleInvoiceRequestDto.setFpqqlsh(new String[]{payInvoiceprinted.getFpqqlsh()});
+            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);
+            PayInvoiceResultDto payInvoiceResultDto = JSON.parseObject(invoiceInfo, PayInvoiceResultDto.class);
+            if (payInvoiceResultDto != null && payInvoiceResultDto.getList().size() > 0) {
+                for (InvoicePrintInfoResult item : payInvoiceResultDto.getList()) {
+                    if (item.getC_status().equals("2")) {
+                        payInvoiceprinted.setState(1);//已生成
+                    }
+                    if (item.getC_status().equals("20") || item.getC_status().equals("21")) {
+                        payInvoiceprinted.setState(2);//开票中
+                        break;
+                    }
+                    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);
+                }
+            }
+        }
+        if (payInvoiceprinted.getInvoiceType() == 1) {//开具蓝票
+            if (payInvoiceprinted.getState() == 1 || payInvoiceprinted.getState() == 2) {
+                printInvoicePrintService.updateReceivedIsPrint(true, payInvoiceprinted.getPayseriesno(), payInvoiceprinted.getCustomerId());
+            }
+        } else {//蓝票冲红
+            if (payInvoiceprinted.getState() == 1 || payInvoiceprinted.getState() == 2) {
+                printInvoicePrintService.updateReceivedIsPrint(false, payInvoiceprinted.getPayseriesno(), payInvoiceprinted.getCustomerId());
+            }
+            //标记原始蓝票为已冲红 状态3
+            PayInvoiceprinted oldPayInvoiceprinted = new PayInvoiceprinted();
+            oldPayInvoiceprinted.setId(payInvoiceprinted.getCancelInvoiceId());
+            oldPayInvoiceprinted.setState(3);//已冲红
+            printInvoicePrintService.update(oldPayInvoiceprinted);
+        }
+    }
+}

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

@@ -1,5 +1,7 @@
 package com.bz.smart_city.service.pay;
 
+import com.bz.smart_city.dto.pay.ReturnPrintResultDto;
+
 /**
  * @ClassName IssueElectronicInvoiceService
  * @Description: TODO
@@ -8,5 +10,5 @@ package com.bz.smart_city.service.pay;
  * @Version V1.0
  **/
 public interface IssueElectronicInvoiceService {
-    void requestPrint(String kpType, String userCode, String payseriesno);
+    ReturnPrintResultDto requestPrint(String kpType, String userCode, String payseriesno, String invoicePrintId);
 }

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayBaseConfigService.java

@@ -3,6 +3,7 @@ package com.bz.smart_city.service.pay;
 import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.dto.pay.PayBaseConfigDto;
 import java.math.BigInteger;
+import java.util.List;
 
 public interface PayBaseConfigService {
 
@@ -30,4 +31,6 @@ public interface PayBaseConfigService {
      * @return
      */
     int edit(PayBaseConfigDto payBaseConfigDto);
+
+    List<PayBaseConfigDto> getPrintInfo(String queryInfo,Integer siteId,Integer customerId);
 }

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayInvoiceParamService.java

@@ -19,4 +19,6 @@ public interface PayInvoiceParamService {
     int update(PayInvoiceParam payInvoiceParam);
 
     List<PayInvoiceParam> findList(String queryparam);
+
+    List<PayInvoiceParam> findList(String queryparam, Integer siteId, Integer customerId);
 }

+ 28 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PrintInvoicePrintService.java

@@ -0,0 +1,28 @@
+package com.bz.smart_city.service.pay;
+
+import com.bz.smart_city.entity.pay.PayInvoice;
+import com.bz.smart_city.entity.pay.PayInvoiceprinted;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigInteger;
+import java.util.List;
+
+/**
+ * @ClassName PrintInvoicePrintService
+ * @Description: 发票信息
+ * @Author :WYY
+ * @Date 2020/8/10
+ * @Version V1.0
+ **/
+public interface PrintInvoicePrintService {
+
+    Integer insert(PayInvoiceprinted payInvoiceprinted);
+
+    Integer update(PayInvoiceprinted payInvoiceprinted);
+
+    PayInvoiceprinted findInvoiceByPayseriesno(String invoicePrintId, BigInteger siteId, BigInteger customerId);
+
+    List<PayInvoiceprinted> findListByState();
+
+    Integer updateReceivedIsPrint(Boolean isPrint, String payseriesno, BigInteger customerId);
+}

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/archives/PayBaseCustomerandmeterrelaService.java

@@ -54,5 +54,5 @@ public interface PayBaseCustomerandmeterrelaService {
     public Pagination<CustomerListInfo> selectAccountnumberList(String accountnumber,int pageNum, int pageSize);
 
     public List<PayBaseCustomerandmeterrelaDto> getResetLadderList(Integer siteId,Integer customerId);
-    public PayBaseCustomerandmeterrela findAccountByAccountNumber(String accountnumber);
+    public PayBaseCustomerandmeterrela findAccountByAccountNumber(String accountnumber,Integer siteId,Integer customerId);
 }

+ 2 - 3
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/archives/impl/PayBaseCustomerandmeterrelaServiceImpl.java

@@ -161,9 +161,8 @@ public class PayBaseCustomerandmeterrelaServiceImpl implements PayBaseCustomeran
     }
 
     @Override
-    public PayBaseCustomerandmeterrela findAccountByAccountNumber(String accountnumber) {
-        LoginUser loginUser = UserUtil.getCurrentUser();
-        return payBaseCustomerandmeterrelaMapper.findAccountByAccountNumber(loginUser.getSiteId(),loginUser.getCustomerId(),accountnumber);
+    public PayBaseCustomerandmeterrela findAccountByAccountNumber(String accountnumber,Integer siteId,Integer customerId) {
+        return payBaseCustomerandmeterrelaMapper.findAccountByAccountNumber(siteId, customerId, accountnumber);
     }
 
     /**

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

@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.bz.smart_city.dao.pay.PayInvoicePrintMapper">
+    <insert id="insert" parameterType="com.bz.smart_city.entity.pay.PayInvoiceprinted" useGeneratedKeys="true" keyProperty="id">
+        INSERT INTO pay_invoice_printed(
+			print_no,
+			old_invoice_code,
+			old_invoice_no,
+			payseriesno,
+			account_id,
+			total_print_amount,
+			total_amount,
+			invoice_amount,
+			invoice_code,
+			invoice_no,
+			ciphertext,
+			check_code,
+			print_date,
+			state,
+			invoice_type,
+			type,
+			create_by,
+			create_date,
+			update_by,
+			update_date,
+			remarks,
+			del_flag,
+			message,
+			order_no,
+			pdf_url,
+			jpg_url,
+			buyername,
+			taxnum,
+			canceltime,
+			invoice_line,
+			fpqqlsh,
+			sendtype,
+			site_id,
+            customer_id,
+            usercode,
+            cancelinvoice_id,
+            saleidentity
+		) VALUES (
+			#{printNo},
+			#{oldInvoiceCode},
+			#{oldInvoiceNo},
+			#{payseriesno},
+			#{accountId},
+			#{totalPrintAmount},
+			#{totalAmount},
+			#{invoiceAmount},
+			#{invoiceCode},
+			#{invoiceNo},
+			#{ciphertext},
+			#{checkCode},
+			#{printDate},
+			#{state},
+			#{invoiceType},
+			#{type},
+			#{createBy},
+			#{createDate},
+			#{updateBy},
+			#{updateDate},
+			#{remarks},
+			#{delFlag},
+			#{message},
+			#{orderNo},
+			#{pdfUrl},
+			#{jpgUrl},
+			#{buyername},
+			#{taxnum},
+			#{canceltime},
+			#{invoiceLine},
+			#{fpqqlsh},
+			#{sendtype},
+			#{siteId},
+            #{customerId},
+            #{userCode},
+            #{cancelInvoiceId},
+            #{saleIdentity}
+		)
+    </insert>
+    <select id="findInvoiceByPayseriesno" resultType="com.bz.smart_city.entity.pay.PayInvoiceprinted">
+		select a.id, a.invoice_code as invoiceCode,a.invoice_no as invoiceNo,a.payseriesno
+        from pay_invoice_printed a
+		where  a.id=#{invoicePrintId} and a.state=1 and a.site_id=#{siteId} and a.customer_id=#{customerId}
+		limit 1
+	</select>
+	<update id="update">
+		update pay_invoice_printed
+		<set>
+			<if test="payInvoiceprinted.state != null"> state=#{payInvoiceprinted.state},</if>
+			<if test="payInvoiceprinted.orderNo != null">order_no=#{payInvoiceprinted.orderNo},</if>
+			<if test="payInvoiceprinted.invoiceCode != null">invoice_code=#{payInvoiceprinted.invoiceCode},</if>
+			<if test="payInvoiceprinted.printDate != null">print_date=#{payInvoiceprinted.printDate},</if>
+			<if test="payInvoiceprinted.invoiceNo != null">invoice_no=#{payInvoiceprinted.invoiceNo},</if>
+			<if test="payInvoiceprinted.message != null">message=#{payInvoiceprinted.message},</if>
+			<if test="payInvoiceprinted.totalAmount != null">total_amount=#{payInvoiceprinted.totalAmount},</if>
+			<if test="payInvoiceprinted.invoiceAmount != null">invoice_amount=#{payInvoiceprinted.invoiceAmount},</if>
+			<if test="payInvoiceprinted.totalPrintAmount != null">total_print_amount=#{payInvoiceprinted.totalPrintAmount},</if>
+			<if test="payInvoiceprinted.checkCode != null">check_code=#{payInvoiceprinted.checkCode},</if>
+			<if test="payInvoiceprinted.pdfUrl != null">pdf_url=#{payInvoiceprinted.pdfUrl},</if>
+			<if test="payInvoiceprinted.jpgUrl != null">jpg_url=#{payInvoiceprinted.jpgUrl},</if>
+			<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>
+		</set>
+		where id=#{payInvoiceprinted.id,jdbcType=BIGINT}
+	</update>
+	<select id="findListByState" resultType="com.bz.smart_city.entity.pay.PayInvoiceprinted">
+	SELECT a.invoice_code as invoiceCode,a.invoice_no as invoiceNo,a.id as id,a.usercode as userCode,
+		   a.cancelinvoice_id as cancelInvoiceId,a.fpqqlsh as fpqqlsh,a.saleidentity as saleIdentity,
+		   a.invoice_type as invoiceType,customer_id as customerId
+	from pay_invoice_printed a
+	where a.state=0 or a.state=2
+	</select>
+	<update id="updateReceivedIsPrint">
+		update  pay_pay_received  set isprint=#{isPrint}
+		where payseriesno=#{payseriesno} and customer_id=#{customerId}
+	</update>
+
+</mapper>