Jelajahi Sumber

银行代收:查询、缴费、对账接口

wangli 4 tahun lalu
induk
melakukan
5512b22c52
23 mengubah file dengan 921 tambahan dan 16 penghapusan
  1. 1 0
      smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayChargeSurveyController.java
  2. 83 0
      smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayFeeController.java
  3. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayAgenttransactionMapper.java
  4. 8 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayCheckbalanceMapper.java
  5. 10 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayFeeMapper.java
  6. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayTransactiondetailsMapper.java
  7. 48 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/BankCheckBill.java
  8. 65 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/BankCheckBillParm.java
  9. 32 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/BankCheckBillsMsg.java
  10. 56 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/BankPayFeeParm.java
  11. 29 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/BankPayResult.java
  12. 33 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/BankPayfeeAccountInfo.java
  13. 36 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/BankPayfeeMsg.java
  14. 47 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/BankQueryParm.java
  15. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayPayAgentbranch.java
  16. 355 12
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayFeeServiceImp.java
  17. 6 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayFeeService.java
  18. 2 0
      smart-city-platform/src/main/resources/application-dev.properties
  19. 4 1
      smart-city-platform/src/main/resources/application-prd.properties
  20. 4 1
      smart-city-platform/src/main/resources/application-sit.properties
  21. 6 0
      smart-city-platform/src/main/resources/mapper/pay/PayAgenttransactionMapper.xml
  22. 15 0
      smart-city-platform/src/main/resources/mapper/pay/PayCheckbalanceMapper.xml
  23. 75 0
      smart-city-platform/src/main/resources/mapper/pay/payFeeMapper.xml

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

@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
 
 import java.math.BigInteger;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.List;
 

+ 83 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayFeeController.java

@@ -7,6 +7,7 @@ import com.bz.smart_city.dto.pay.BaseWaterPropertyFormDto;
 import com.bz.smart_city.dto.pay.PayInvoiceDto;
 import com.bz.smart_city.dto.pay.PayTransactiondetailsDto;
 import com.bz.smart_city.dto.pay.payfee.*;
+import com.bz.smart_city.entity.pay.PayPayAgentbranch;
 import com.bz.smart_city.service.pay.BaseWaterPropertyService;
 import com.bz.smart_city.service.pay.PayFeeService;
 import com.bz.smart_city.service.pay.PayPayReceivedService;
@@ -17,6 +18,7 @@ import io.swagger.annotations.ApiParam;
 import org.apache.commons.lang3.StringUtils;
 import org.aspectj.weaver.loadtime.Aj;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -47,6 +49,9 @@ public class PayFeeController {
     @Autowired
     private BaseWaterPropertyService baseWaterPropertyService;
 
+    @Value("${payfee.bank.customerId}")
+    private Integer customerId;
+
 
     @PostMapping("/payFee")
     @ApiOperation(value = "冲账接口,客户名称、客户编码、应收id不能同时为空")
@@ -211,6 +216,84 @@ public class PayFeeController {
     ) {
         return new AjaxMessage<>(ResultStatus.OK, payFeeService.getPayinvoiceInfo(id, year));
     }
+
+    @PostMapping("/queryUserInfo")
+    @ApiOperation(value = "银行缴费接口——客户信息查询")
+    public BankPayfeeMsg queryUserInfo(@RequestBody BankQueryParm bankQueryParm){
+        try{
+            //空值
+            String parmCheck = bankQueryParm.checkParmIsNull();
+            if(StringUtils.isNotBlank(parmCheck)){
+                return new BankPayfeeMsg("0002",parmCheck,null);
+            }
+            PayPayAgentbranch payPayAgentbranch =  payFeeService.selectPayAgentbranchInfo(bankQueryParm.getAgentCode(), customerId);
+            if(null == payPayAgentbranch || null == payPayAgentbranch.getId()){
+                return new BankPayfeeMsg("0003","代收单位不存在",null);
+            }
+            if(null == payPayAgentbranch.getPaykey() ||!bankQueryParm.getAgentPwd().equals(payPayAgentbranch.getPaykey())){
+                return new BankPayfeeMsg("0004","代收单位密钥错误",null);
+            }
+
+            List<BankPayfeeAccountInfo> list = payFeeService.selectBankPayfeeAccountInfo(bankQueryParm.getQueryType(),bankQueryParm.getQueryValue());
+            if(list.size() == 0){
+                return new BankPayfeeMsg("1001","查询的号码不存在",list);
+            }
+            return new BankPayfeeMsg("9999","查询成功",list);
+        }catch (Exception e){
+            e.printStackTrace();
+            return new BankPayfeeMsg("0005","系统异常");
+        }
+    }
+
+    @PostMapping("/payFeeAmount")
+    @ApiOperation(value = "银行缴费接口——缴费欠费")
+    public BankPayfeeMsg payFeeAmount(@RequestBody BankPayFeeParm bankPayFeeParm){
+        try{
+            String parmCheck = bankPayFeeParm.checkParmIsNull();
+            if(StringUtils.isNotBlank(parmCheck)){
+                return new BankPayfeeMsg("0002",parmCheck);
+            }
+            PayPayAgentbranch payPayAgentbranch =  payFeeService.selectPayAgentbranchInfo(bankPayFeeParm.getAgentCode(), customerId);
+            if(null == payPayAgentbranch || null == payPayAgentbranch.getId()){
+                return new BankPayfeeMsg("0003","代收单位不存在");
+            }
+            if(null == payPayAgentbranch.getPaykey() ||!bankPayFeeParm.getAgentPwd().equals(payPayAgentbranch.getPaykey())){
+                return new BankPayfeeMsg("0004","代收单位密钥错误");
+            }
+
+            return payFeeService.payfeeByBank(payPayAgentbranch,bankPayFeeParm.getOrderCode(),bankPayFeeParm.getAccountNumber(),bankPayFeeParm.getMoney(),bankPayFeeParm.getPayTime());
+        }catch (Exception e){
+            e.printStackTrace();
+            return new BankPayfeeMsg("0005","系统异常");
+        }
+    }
+
+    @PostMapping("/checkBill")
+    @ApiOperation(value = "银行缴费接口——对账")
+    public BankCheckBillsMsg checkBill(@RequestBody BankCheckBillParm bankCheckBillParm){
+        try{
+
+
+        String parmCheck = bankCheckBillParm.checkParmIsNull();
+        if(StringUtils.isNotBlank(parmCheck)){
+            return new BankCheckBillsMsg("0002",parmCheck,null);
+        }
+        PayPayAgentbranch payPayAgentbranch =  payFeeService.selectPayAgentbranchInfo(bankCheckBillParm.getAgentCode(), customerId);
+        if(null == payPayAgentbranch || null == payPayAgentbranch.getId()){
+            return new BankCheckBillsMsg("0003","代收单位不存在",null);
+        }
+        if(null == payPayAgentbranch.getPaykey() ||!bankCheckBillParm.getAgentPwd().equals(payPayAgentbranch.getPaykey())){
+            return new BankCheckBillsMsg("0004","代收单位密钥错误",null);
+        }
+
+        return payFeeService.checkBill(payPayAgentbranch,bankCheckBillParm);
+        }catch (Exception e){
+            e.printStackTrace();
+            return new BankCheckBillsMsg("0005","系统异常");
+        }
+    }
+
+
 }
 
 

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

@@ -1,6 +1,7 @@
 package com.bz.smart_city.dao.pay;
 
 import com.bz.smart_city.dto.pay.PayAgenttransactionDto;
+import com.bz.smart_city.entity.pay.PayAgenttransaction;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -17,4 +18,5 @@ public interface PayAgenttransactionMapper {
     List<PayAgenttransactionDto> findList(PayAgenttransactionDto payAgenttransactionDto);
     void cancelByPayseriesno(@Param("payseriesno") String payseriesno, @Param("siteId")Integer siteId, @Param("customerId")Integer customerId);
     void cancelCheckAgentPayseriesno(@Param("payseriesno") String payseriesno, @Param("siteId")Integer siteId, @Param("customerId")Integer customerId);
+    Integer insertAgenttransaction(PayAgenttransaction payAgenttransaction);
 }

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

@@ -1,8 +1,13 @@
 package com.bz.smart_city.dao.pay;
 
+import com.bz.smart_city.dto.pay.PayAgenttransactionDto;
 import com.bz.smart_city.dto.pay.PayCheckbalanceDto;
+import com.bz.smart_city.dto.pay.payfee.BankCheckBillParm;
+import com.bz.smart_city.entity.pay.PayCheckbalance;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
+import java.math.BigInteger;
 import java.util.List;
 
 /**
@@ -14,4 +19,7 @@ import java.util.List;
 @Mapper
 public interface PayCheckbalanceMapper {
     List<PayCheckbalanceDto> findList(PayCheckbalanceDto payCheckbalanceDto);
+    Integer batchInsert(@Param("payCheckbalances") List<PayCheckbalance> payCheckbalances);
+    Integer insertCheckBalanceLog(BankCheckBillParm bankCheckBillParm);
+    Integer updateAgenttransactionState(BigInteger id);
 }

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

@@ -1,10 +1,13 @@
 package com.bz.smart_city.dao.pay;
 
+import com.bz.smart_city.dto.pay.PayAgenttransactionDto;
 import com.bz.smart_city.dto.pay.PayCustomRechargeDto;
 import com.bz.smart_city.dto.pay.PayInvoiceDto;
 import com.bz.smart_city.dto.pay.payfee.*;
 import com.bz.smart_city.entity.ProgramItem;
 import com.bz.smart_city.entity.pay.BaseClosingAccountInfo;
+import com.bz.smart_city.entity.pay.PayAgenttransaction;
+import com.bz.smart_city.entity.pay.PayPayAgentbranch;
 import com.bz.smart_city.entity.pay.PayReceivable;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -53,4 +56,11 @@ public interface PayFeeMapper {
     List<PayInvoiceDto> getPayinvoiceInfo(@Param("accountId")BigInteger accountId , @Param("year")Integer year, @Param("siteId") Integer siteId, @Param("customerId") Integer customerId);
 
     BigInteger getWaterPropertyId(@Param("id")BigInteger id);
+
+    List<BankPayfeeAccountInfo> selectBankPayfeeAccountInfo(@Param("queryType")String queryType,@Param("queryValue")String queryValue);
+
+    PayPayAgentbranch selectPayAgentbranchInfo(@Param("code")String code, @Param("customerId")Integer customerId);
+
+
+    PayAgenttransactionDto selectAgenttransaction(@Param("orderNo")String orderNo);
 }

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

@@ -3,6 +3,7 @@ package com.bz.smart_city.dao.pay;
 import com.bz.smart_city.dto.pay.PayTransactiondetails;
 import com.bz.smart_city.dto.pay.PayTransactiondetailsDto;
 import com.bz.smart_city.entity.ProgramItem;
+import com.bz.smart_city.entity.pay.PayAgenttransaction;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -36,4 +37,5 @@ public interface PayTransactiondetailsMapper {
 
     void updateLastRecreamaing(@Param("lastrecreamaing") BigDecimal lastrecreamaing,@Param("payseriesno")String payseriesno);
 
+
 }

+ 48 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/BankCheckBill.java

@@ -0,0 +1,48 @@
+package com.bz.smart_city.dto.pay.payfee;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Serializable;
+
+/**
+ * @description 银行代收对账信息
+ * @auto wangli
+ * @data 2020/12/17 10:41
+ */
+@ApiModel("银行代收对账信息")
+@Data
+public class BankCheckBill implements Serializable {
+
+    private static final long serialVersionUID = 3021705021063077295L;
+
+    @ApiModelProperty("交易流水号,银行生成流水号")
+    private String orderCode;
+    @ApiModelProperty("用户编号")
+    private String accountNumber;
+    @ApiModelProperty("缴费金额")
+    private Float money;
+    @ApiModelProperty("缴费时间,格式为yyyyMMddhhmmss")
+    private String payTime;
+
+    @ApiModelProperty(value = "缴费/对账信息",hidden = true)
+    private String message;
+
+    public String checkParmIsNull(){
+        if(StringUtils.isBlank(this.orderCode)){
+            return "交易流水号为空";
+        }
+        if(StringUtils.isBlank(this.accountNumber)){
+            return "用户编号为空";
+        }
+        if(null  == this.money){
+            return "缴费金额为空";
+        }
+        if(StringUtils.isBlank(this.payTime)){
+            return "缴费时间为空";
+        }
+        return null;
+    }
+}

+ 65 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/BankCheckBillParm.java

@@ -0,0 +1,65 @@
+package com.bz.smart_city.dto.pay.payfee;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.formula.functions.T;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * @description 银行代收对账接口参数
+ * @auto wangli
+ * @data 2020/12/17 10:28
+ */
+@ApiModel("银行代收对账接口参数")
+@Data
+public class BankCheckBillParm implements Serializable {
+
+    private static final long serialVersionUID = -4503048754607488363L;
+
+    @ApiModelProperty("代收单位编号,与营业系统代收单位对应(营收系统分配)")
+    private String agentCode;
+    @ApiModelProperty("代收单位验证密钥,与营业系统代收单位对应(营收系统分配)")
+    private String agentPwd;
+    @ApiModelProperty("收费日期(yyyyMMdd)")
+    private String chargeDate;
+    @ApiModelProperty("缴费总金额")
+    private String totalMoney;
+    @ApiModelProperty("缴费总笔数")
+    private String totalCount;
+    @ApiModelProperty("明细清单多条")
+    private List<BankCheckBill> transDetails;
+
+    @ApiModelProperty(value = "对账成功笔数",hidden = true)
+    private Integer successCount;
+
+    @ApiModelProperty(value = "创建时间" ,hidden = true)
+    private LocalDateTime createDate;
+
+    public String checkParmIsNull(){
+        if(StringUtils.isBlank(this.agentCode)){
+            return "代收单位编号为空";
+        }
+        if(StringUtils.isBlank(this.agentPwd)){
+            return "代收单位验证密钥为空";
+        }
+        if(StringUtils.isBlank(this.chargeDate)){
+            return "收费日期为空";
+        }
+        if(StringUtils.isBlank(this.totalMoney)){
+            return "缴费总金额为空";
+        }
+        if(StringUtils.isBlank(this.totalCount)){
+            return "缴费总笔数为空";
+        }
+        if( null == this.transDetails){
+            return "明细清单为空";
+        }
+        return null;
+    }
+}

+ 32 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/BankCheckBillsMsg.java

@@ -0,0 +1,32 @@
+package com.bz.smart_city.dto.pay.payfee;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @description 银行对账返回信息
+ * @auto wangli
+ * @data 2020/12/21 18:43
+ */
+@ApiModel("银行对账返回信息")
+@Data
+public class BankCheckBillsMsg extends BankPayResult implements Serializable {
+
+    private static final long serialVersionUID = 3184254852168735345L;
+
+    @ApiModelProperty("对账失败信息")
+    private List<BankCheckBill> bankCheckBills;
+
+    public BankCheckBillsMsg(String rtnCode,String rtnMsg){
+        super(rtnCode,rtnMsg);
+    }
+
+    public BankCheckBillsMsg(String rtnCode,String rtnMsg,List<BankCheckBill> bankCheckBills){
+        super(rtnCode,rtnMsg);
+        this.bankCheckBills=bankCheckBills;
+    }
+}

+ 56 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/BankPayFeeParm.java

@@ -0,0 +1,56 @@
+package com.bz.smart_city.dto.pay.payfee;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Serializable;
+
+/**
+ * @description 银行代收支付接口参数
+ * @auto wangli
+ * @data 2020/12/17 10:27
+ */
+@ApiModel("银行代收支付接口参数")
+@Data
+public class BankPayFeeParm implements Serializable {
+
+    private static final long serialVersionUID = 7248914556094192650L;
+
+    @ApiModelProperty("交易流水号,银行生成流水号,后续用于对账")
+    private String orderCode;
+    @ApiModelProperty("用户编号")
+    private String accountNumber;
+    @ApiModelProperty("代收单位编号,与营业系统代收单位对应(营收系统分配)")
+    private String agentCode;
+    @ApiModelProperty("代收单位验证密钥,与营业系统代收单位对应(营收系统分配)")
+    private String agentPwd;
+    @ApiModelProperty("缴费总金额(包含预存),缴费金额需大于等于欠费金额")
+    private Float money;
+    @ApiModelProperty("缴费时间,格式为yyyyMMddhhmmss")
+    private String payTime;
+
+    public String checkParmIsNull(){
+        if(StringUtils.isBlank(this.agentCode)){
+            return "代收单位编号为空";
+        }
+        if(StringUtils.isBlank(this.agentPwd)){
+            return "代收单位验证密钥为空";
+        }
+        if(StringUtils.isBlank(this.accountNumber)){
+            return "用户编号为空";
+        }
+        if(StringUtils.isBlank(this.orderCode)){
+            return "交易流水号为空";
+        }
+        if( null == this.money){
+            return "缴费总金额为空";
+        }
+        if(StringUtils.isBlank(this.payTime)){
+            return "缴费时间为空";
+        }
+        return null;
+    }
+
+}

+ 29 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/BankPayResult.java

@@ -0,0 +1,29 @@
+package com.bz.smart_city.dto.pay.payfee;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @description
+ * @auto wangli
+ * @data 2020/12/21 18:38
+ */
+@Data
+public class BankPayResult implements Serializable {
+
+    private static final long serialVersionUID = 3420525882070393627L;
+    @ApiModelProperty("结果代码")
+    private String rtnCode;
+    @ApiModelProperty("结果代码")
+    private String rtnMsg;
+
+
+    public BankPayResult(){}
+
+    public BankPayResult(String rtnCode,String rtnMsg){
+        this.rtnCode=rtnCode;
+        this.rtnMsg=rtnMsg;
+    }
+}

+ 33 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/BankPayfeeAccountInfo.java

@@ -0,0 +1,33 @@
+package com.bz.smart_city.dto.pay.payfee;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @description银行代收查询客户信息结果
+ * @auto wangli
+ * @data 2020/12/17 9:56
+ */
+@Data
+@ApiModel("银行代收查询客户信息结果")
+public class BankPayfeeAccountInfo implements Serializable {
+    private static final long serialVersionUID = -6918627344254052536L;
+
+    @ApiModelProperty("用户名称")
+    private String accountName;
+    @ApiModelProperty("用户编码")
+    private String accountCode;
+    @ApiModelProperty("地址")
+    private String address;
+    @ApiModelProperty("联系电话")
+    private String phone;
+    @ApiModelProperty("身份证号")
+    private String idCardNo;
+    @ApiModelProperty("欠费金额")
+    private Float debt;
+    @ApiModelProperty("账户余额")
+    private Float prepayAmount;
+}

+ 36 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/BankPayfeeMsg.java

@@ -0,0 +1,36 @@
+package com.bz.smart_city.dto.pay.payfee;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.apache.poi.ss.formula.functions.T;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @description 银行代收返回信息
+ * @auto wangli
+ * @data 2020/12/17 9:56
+ */
+@Data
+@ApiModel("银行代收查询返回信息")
+public class BankPayfeeMsg extends BankPayResult implements Serializable {
+
+    private static final long serialVersionUID = 7242185507405923654L;
+
+
+    @ApiModelProperty("明细信息")
+    private List<BankPayfeeAccountInfo> accountInfo;
+
+    public BankPayfeeMsg(){ }
+
+    public BankPayfeeMsg(String rtnCode,String rtnMsg){
+        super(rtnCode,rtnMsg);
+    }
+
+    public BankPayfeeMsg(String rtnCode,String rtnMsg,List<BankPayfeeAccountInfo> accountInfo){
+        super(rtnCode,rtnMsg);
+        this.accountInfo=accountInfo;
+    }
+}

+ 47 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/BankQueryParm.java

@@ -0,0 +1,47 @@
+package com.bz.smart_city.dto.pay.payfee;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Serializable;
+
+/**
+ * @description 银行代收查询接口参数
+ * @auto wangli
+ * @data 2020/12/17 10:27
+ */
+@Data
+@ApiModel("银行代收查询接口参数")
+public class BankQueryParm implements Serializable {
+
+    private static final long serialVersionUID = -4685922371311183570L;
+
+    @ApiModelProperty("查询条件的类别:01:用户编号; 02:手机号码;03:身份证")
+    private String queryType;   //查询条件的类别(必填):01:用户编号; 02:手机号码;03:身份证。
+    @ApiModelProperty("查询条件参数")
+    private String queryValue;  //对应查询类别的查询条件。
+    @ApiModelProperty("代收单位编号")
+    private String agentCode;   //代收单位编号(必填),与营业系统代收单位对应(营收系统分配)
+    @ApiModelProperty("代收单位验证密钥")
+    private String agentPwd;    //代收单位验证密钥,与营业系统代收单位对应(营收系统分配)(必填)
+
+    public String checkParmIsNull(){
+        if(StringUtils.isBlank(this.agentCode)){
+            return "代收单位编号为空";
+        }
+        if(StringUtils.isBlank(this.agentPwd)){
+            return "代收单位验证密钥为空";
+        }
+        if(StringUtils.isBlank(this.queryType)){
+            return "查询条件的类别为空";
+        }
+        if(StringUtils.isBlank(this.queryValue)){
+            return "代收单位编号为空";
+        }
+        return null;
+    }
+
+}

+ 2 - 2
smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayPayAgentbranch.java

@@ -48,7 +48,7 @@ public class PayPayAgentbranch {
     @ApiModelProperty(example = "1",notes = "删除标记",hidden = true)
     private String delFlag;
     @ApiModelProperty(example = "1",notes = "站点ID",hidden = true)
-    private long siteId;
+    private Integer siteId;
     @ApiModelProperty(example = "1",notes = "水司ID",hidden = true)
-    private long customerId;
+    private Integer customerId;
 }

+ 355 - 12
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayFeeServiceImp.java

@@ -9,10 +9,9 @@ import com.bz.smart_city.dao.pay.*;
 import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.pay.*;
 import com.bz.smart_city.dto.pay.payfee.*;
-import com.bz.smart_city.entity.pay.BaseClosingAccountInfo;
-import com.bz.smart_city.entity.pay.PayPayReceived;
-import com.bz.smart_city.entity.pay.PayReceivable;
+import com.bz.smart_city.entity.pay.*;
 import com.bz.smart_city.service.pay.PayFeeService;
+import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -21,6 +20,7 @@ import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -38,19 +38,23 @@ public class PayFeeServiceImp implements PayFeeService {
 
 
     @Resource
-    PayFeeMapper payFeeMapper;
+    private PayFeeMapper payFeeMapper;
 
     @Resource
-    PayPayReceivedMapper payPayReceivedMapper;
+    private PayPayReceivedMapper payPayReceivedMapper;
 
     @Resource
-    PayTransactiondetailsMapper payTransactiondetailsMapper;
+    private PayTransactiondetailsMapper payTransactiondetailsMapper;
 
     @Resource
-    PaySysDictMapper sysDictMapper;
+    private PaySysDictMapper sysDictMapper;
 
     @Resource
-    BaseClosingAccountInfoMapper baseClosingAccountInfoMapper;
+    private BaseClosingAccountInfoMapper baseClosingAccountInfoMapper;
+    @Resource
+    private PayAgenttransactionMapper payAgenttransactionMapper;
+    @Resource
+    private PayCheckbalanceMapper payCheckbalanceMapper;
 
     /**
      *  柜台缴费
@@ -66,7 +70,7 @@ public class PayFeeServiceImp implements PayFeeService {
     public PayfeeResult payFeeCounter( String id,Integer payway,BigDecimal transAmount, Integer balancetype,BigDecimal debt,
                                        BigDecimal ycremaining,Integer amount,BigDecimal price){
         //实收金额不可为负数
-        if(transAmount.compareTo(BigDecimal.ZERO)!=1){
+        if(transAmount.compareTo(BigDecimal.ZERO) == -1){
             throw new ServiceException(ResultStatus.PAYFEE_TRANSAMOUNT_BELOW_ZERO);
         }
         //欠费金额不能为负数
@@ -322,7 +326,7 @@ public class PayFeeServiceImp implements PayFeeService {
    @Transactional(rollbackFor = Exception.class)
     public String payFee(String accountnumber, String metercode, BigDecimal transAmount, Integer payway , LocalDateTime transTime, List<BigInteger> receivableIds,Integer siteId,Integer customerId,Integer userId) {
        //交易金额不可为负数
-       if(transAmount.compareTo(BigDecimal.ZERO)!=1){
+       if(transAmount.compareTo(BigDecimal.ZERO) == -1){
            throw new ServiceException(ResultStatus.PAYFEE_TRANSAMOUNT_BELOW_ZERO);
        }
         LoginUser loginUser = UserUtil.getCurrentUser();
@@ -565,7 +569,7 @@ public class PayFeeServiceImp implements PayFeeService {
     public PayfeeResult rechargefeeCounter(String  accountId , BigDecimal transAmount, Integer payway ,Integer balancetype,BigDecimal waterAmount){
 
         //交易金额不可为负数
-        if(transAmount.compareTo(BigDecimal.ZERO)!=1){
+        if(transAmount.compareTo(BigDecimal.ZERO) == -1){
             throw new ServiceException(ResultStatus.PAYFEE_TRANSAMOUNT_BELOW_ZERO);
         }
         LoginUser loginUser = UserUtil.getCurrentUser();
@@ -647,7 +651,7 @@ public class PayFeeServiceImp implements PayFeeService {
     @Transactional(rollbackFor = Exception.class)
     public String rechargefee(String accountnumber, String metercode, BigDecimal transAmount, Integer payway , LocalDateTime transTime,Integer siteId,Integer customerId,Integer userId){
         //交易金额不可为负数
-        if(transAmount.compareTo(BigDecimal.ZERO)!=1){
+        if(transAmount.compareTo(BigDecimal.ZERO) == -1){
             throw new ServiceException(ResultStatus.PAYFEE_TRANSAMOUNT_BELOW_ZERO);
         }
         LoginUser loginUser = UserUtil.getCurrentUser();
@@ -947,5 +951,344 @@ public class PayFeeServiceImp implements PayFeeService {
     public BigInteger getWaterPropertyId(BigInteger id){
         return payFeeMapper.getWaterPropertyId(id);
     }
+    public List<BankPayfeeAccountInfo> selectBankPayfeeAccountInfo(String queryType,String queryValue){
+        return payFeeMapper.selectBankPayfeeAccountInfo(queryType,queryValue);
+    }
+
+    public PayPayAgentbranch selectPayAgentbranchInfo(String code, Integer customerId){
+        return payFeeMapper.selectPayAgentbranchInfo(code,customerId);
+    }
+
+    /**
+     * 银行代缴充值
+     * @param payPayAgentbranch
+     * @param orderCode
+     * @param accountNumber
+     * @param money
+     * @param payTime
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public BankPayfeeMsg payfeeByBank( PayPayAgentbranch payPayAgentbranch ,String orderCode,String accountNumber,Float money, String payTime ){
+        //如果传入时间则用传入的时间做交易时间
+        LocalDateTime localDateTime;
+        try{
+            DateTimeFormatter dateTimeFormatter =   DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+            localDateTime= LocalDateTime.parse(payTime, dateTimeFormatter);
+        }catch (Exception e){
+
+            return new BankPayfeeMsg("0001","时间格式异常");
+        }
+
+        Integer customerId=payPayAgentbranch.getCustomerId();
+        Integer siteId=payPayAgentbranch.getSiteId();
+        //计费系统需要有客户站点信息
+        if(siteId ==null || customerId == null ){
+           return new BankPayfeeMsg("0005","系统信息配置异常");
+        }
+
+        BigDecimal payfee = new BigDecimal(money);
+        //实收金额不可为负数
+        if(payfee.compareTo(BigDecimal.ZERO) == -1){
+            return new BankPayfeeMsg("2002","小于最小缴费金额");
+        }
+
+
+
+        //根据客编获取客户信息
+        PayCustomRechargeDto payCustomRechargeDto = payFeeMapper.getCustomInfoByMeterOrAccount(null,accountNumber,null,BigInteger.valueOf(siteId),BigInteger.valueOf(customerId));
+        if(payCustomRechargeDto == null ){
+            //获取客户信息失败
+            return new BankPayfeeMsg("1001","查询的号码不合法或不存在");
+        }
+        //查询欠费信息
+        List<PayReceivable> payReceivableList =payFeeMapper.getReceivable(siteId,customerId,payCustomRechargeDto.getAccountId(),null);
+
+        //支付方式
+        List<PaySysDictSelectDto> payways = sysDictMapper.getDicts("支付方式",BigInteger.valueOf(siteId),BigInteger.valueOf(customerId));
+        if(payways.size() == 0){
+            return new BankPayfeeMsg("0005","系统信息配置异常");
+        }
+        String paywayName = payways.stream().filter(item -> item.getValue().equals("3")).findFirst().get().getLabel();
+
+//         Map<String,PaySysDictSelectDto> paywayMap = payways.stream().collect(Collectors.toMap(PaySysDictSelectDto::getValue, PaySysDictSelectDto->PaySysDictSelectDto));
+        //收费类型
+        List<PaySysDictSelectDto> feetypes = sysDictMapper.getDicts("收费类型",BigInteger.valueOf(siteId),BigInteger.valueOf(customerId));
+        if(payways.size() == 0) {
+            return new BankPayfeeMsg("0005","系统信息配置异常");
+        }
+        Map<String, PaySysDictSelectDto> feetypeMap = feetypes.stream().collect(Collectors.toMap(PaySysDictSelectDto::getValue, PaySysDictSelectDto -> PaySysDictSelectDto));
 
+        //生成批次号
+        // 微信:W  现金、预存账户:C 银行:B 支付宝:A
+        String payseriesno= Util.getBatchNo("B",payCustomRechargeDto.getAccountnumber());
+        //获取账期
+        BaseClosingAccountInfo baseClosingAccountInfo=payFeeMapper.getLastClosingAccount(siteId,customerId);
+        if(baseClosingAccountInfo == null){
+            //获取账期信息失败、
+            return new BankPayfeeMsg("0005","系统信息配置异常");
+        }
+        int month =baseClosingAccountInfo.getMonth();
+        int year =baseClosingAccountInfo.getYear();
+
+        if(payReceivableList.size() == 0 ){ //没有应收信息走仅充值
+            //余额
+            BigDecimal remaining = payCustomRechargeDto.getRemaining();
+            //生成交易明细
+            PayTransactiondetails payTransactiondetails = getPayTransactiondetails(3, paywayName, localDateTime, payCustomRechargeDto, payseriesno, month, year, payfee, siteId, customerId, 1);
+            payTransactiondetails.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "充值");
+            payTransactiondetails.setTranstype(1);
+            payTransactiondetails.setTranstypeLabel("充值");
+            payTransactiondetails.setRemaining(remaining);//交易前账户余额
+            remaining = remaining.add(payfee);
+            payTransactiondetails.setLastrecreamaing(remaining);//交易后账户余额
+            payTransactiondetailsMapper.insert(payTransactiondetails);
+            //修改预存账户
+            payFeeMapper.updateRechargeaccount(remaining, BigInteger.valueOf(1), localDateTime, payCustomRechargeDto.getRechargeId());
+            //更新客户状态
+            payFeeMapper.updateAccountState(payCustomRechargeDto.getAccountId());
+
+        }else{
+            BigDecimal debts=BigDecimal.ZERO;
+            for(PayReceivable payReceivable: payReceivableList){
+                debts=debts.add(payReceivable.getDebt());
+            }
+            //预存+实收<欠费 金额不足
+            if(payCustomRechargeDto.getRemaining().add(payfee).compareTo(debts) == -1){
+                return new BankPayfeeMsg("2002","小于最小缴费金额");
+            }
+
+
+            //余额
+            BigDecimal remaining = payCustomRechargeDto.getRemaining();
+            //用作明细记录交易前余额
+            BigDecimal oldRemaining = payCustomRechargeDto.getRemaining();
+            //交易明细最后统一赋值交易前后余额,批量保存
+            List<PayTransactiondetails> transactiondetailsDtoList = new ArrayList();
+            //预存抵扣
+            Iterator<PayReceivable> iterator = payReceivableList.iterator();
+            while(iterator.hasNext()) {
+                //抵扣的应收
+                PayReceivable payReceivable=iterator.next();
+                //账户余额先抵扣
+                if (remaining.compareTo(BigDecimal.ZERO) == 1) {
+                    if(payReceivable.getDebt().compareTo(BigDecimal.ZERO) != 1){
+                        //欠费不大于零直接移除
+                        iterator.remove();
+                    }else if(remaining.compareTo(payReceivable.getDebt()) != -1){
+                        //预存余额不小于欠费(完全抵扣)
+                        iterator.remove();
+                        remaining = remaining.subtract(payReceivable.getDebt());//修改余额
+                        //生成并保存实收
+                        PayPayReceived payPayReceived = getReceived(payReceivable, year, month, localDateTime,5,payseriesno,payReceivable.getDebt(),feetypeMap, siteId, customerId, 1 );
+                        //生成交易明细
+                        PayTransactiondetails payTransactiondetails = getPayTransactiondetails(5,"预存账户", localDateTime, payCustomRechargeDto, payseriesno, month, year, payReceivable.getDebt().negate(), siteId, customerId, 1 );
+                        payTransactiondetails.setReceivedId(payPayReceived.getId());
+                        payTransactiondetails.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "扣费");
+                        payTransactiondetails.setTranstype(2);
+                        payTransactiondetails.setTranstypeLabel("扣费");
+                        transactiondetailsDtoList.add(payTransactiondetails);
+                        //修改应收
+                        payReceivable.setDebt(BigDecimal.ZERO);
+                        payReceivable.setUpdateDate(localDateTime);
+                        payReceivable.setUpdateBy(BigInteger.valueOf(1));
+                        payFeeMapper.updatePayReceivable(payReceivable);
+                    }else{
+                        //预存余额小于于欠费(部分抵扣)
+                        //生成并保存实收
+
+                        PayPayReceived payPayReceived = getReceived(payReceivable, year, month, localDateTime,5,payseriesno,remaining,feetypeMap, siteId, customerId, 1 );
+
+                        PayTransactiondetails payTransactiondetails = getPayTransactiondetails(5, "预存账户",localDateTime, payCustomRechargeDto, payseriesno, month, year, remaining.negate() , siteId, customerId, 1 );
+                        payTransactiondetails.setReceivedId(payPayReceived.getId());
+                        payTransactiondetails.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "扣费");
+                        payTransactiondetails.setTranstype(2);
+                        payTransactiondetails.setTranstypeLabel("扣费");
+                        transactiondetailsDtoList.add(payTransactiondetails);
+                        //修改应收
+                        payReceivable.setDebt(payReceivable.getDebt().subtract(remaining));
+                        payReceivable.setUpdateDate(localDateTime);
+                        payReceivable.setUpdateBy(BigInteger.valueOf(1));
+                        payFeeMapper.updatePayReceivable(payReceivable);
+
+                        remaining = BigDecimal.ZERO;//修改余额
+                        break;
+                    }
+                }
+            }
+
+
+            //缴费抵扣
+            Iterator<PayReceivable> iteratorTransAmount = payReceivableList.iterator();
+            while(iteratorTransAmount.hasNext()) {
+                //抵扣的应收
+                PayReceivable payReceivable=iteratorTransAmount.next();
+                //交易金额抵扣
+                if (payfee.compareTo(BigDecimal.ZERO) == 1) {
+                    if(payReceivable.getDebt().compareTo(BigDecimal.ZERO) != 1){
+                        //欠费不大于零直接移除
+                        iteratorTransAmount.remove();
+                    }else if(payfee.compareTo(payReceivable.getDebt()) != -1){
+                        //交易金额不小于欠费(完全抵扣)
+                        iteratorTransAmount.remove();
+                        payfee = payfee.subtract(payReceivable.getDebt());//修改剩余交易金额
+
+                        //生成并保存实收
+                        getReceived(payReceivable, year, month, localDateTime,3,payseriesno,payReceivable.getDebt(),feetypeMap, siteId, customerId, 1 );
+                        //修改应收
+                        payReceivable.setDebt(BigDecimal.ZERO);
+                        payReceivable.setUpdateDate(localDateTime);
+                        payReceivable.setUpdateBy(BigInteger.valueOf(1));
+                        payFeeMapper.updatePayReceivable(payReceivable);
+
+                    }else{
+                        //交易金额小于于欠费(部分抵扣)
+                        //生成并保存实收
+
+                        getReceived(payReceivable, year, month, localDateTime,3,payseriesno,payfee,feetypeMap, siteId, customerId, 1 );
+                        //修改应收
+                        payReceivable.setDebt(payReceivable.getDebt().subtract(payfee));
+                        payReceivable.setUpdateDate(localDateTime);
+                        payReceivable.setUpdateBy(BigInteger.valueOf(1));
+                        payFeeMapper.updatePayReceivable(payReceivable);
+                        payfee = BigDecimal.ZERO;//修改余额
+                        break;
+                    }
+                }
+            }
+            //余额充值或划扣有余额
+            if( payfee.compareTo(BigDecimal.ZERO) == 1){
+                //修改余额
+                remaining=remaining.add(payfee);
+                //生成交易明细
+                PayTransactiondetails payTransactiondetails = getPayTransactiondetails(3, paywayName,localDateTime, payCustomRechargeDto, payseriesno, month, year, payfee, siteId, customerId, 1  );
+                payTransactiondetails.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "缴费");
+                payTransactiondetails.setTranstype(4);
+                payTransactiondetails.setTranstypeLabel("账户转预存");
+                transactiondetailsDtoList.add(payTransactiondetails);
+            }
+
+            //修改预存账户
+            payFeeMapper.updateRechargeaccount(remaining,BigInteger.valueOf(1),localDateTime,payCustomRechargeDto.getRechargeId());
+            //更新客户状态
+            payFeeMapper.updateAccountState(payCustomRechargeDto.getAccountId());
+            //赋值交易明细交易前后余额并保存
+            for(PayTransactiondetails payTransactiondetails : transactiondetailsDtoList){
+                payTransactiondetails.setRemaining(oldRemaining);//交易前账户余额
+                payTransactiondetails.setLastrecreamaing(remaining);//交易后账户余额
+            }
+            //批量保存交易明细
+            if(transactiondetailsDtoList.size()>0){
+                payTransactiondetailsMapper.batchInsert(transactiondetailsDtoList);
+            }
+        }
+        //第三方交易明细
+        PayAgenttransaction payAgenttransaction = new PayAgenttransaction();
+        payAgenttransaction.setAccountname(payCustomRechargeDto.getAccountname());
+        payAgenttransaction.setAccountnumber(payCustomRechargeDto.getAccountnumber());
+        payAgenttransaction.setAgentbranchId(payPayAgentbranch.getId());
+        payAgenttransaction.setAgentName(payPayAgentbranch.getName());
+        payAgenttransaction.setAgentCode(payPayAgentbranch.getCode());
+        payAgenttransaction.setAmount(new BigDecimal(money));
+        payAgenttransaction.setState(0);
+        payAgenttransaction.setTranstime(localDateTime);
+        payAgenttransaction.setPayseriesno(payseriesno);
+        payAgenttransaction.setOrderNo(orderCode);
+        payAgenttransaction.setSiteId(BigInteger.valueOf(siteId));
+        payAgenttransaction.setCustomerId(BigInteger.valueOf(customerId));
+        payAgenttransaction.setCreateBy(BigInteger.valueOf(1));
+        payAgenttransaction.setCreateDate(LocalDateTime.now());
+        payAgenttransaction.setUpdateBy(BigInteger.valueOf(1));
+        payAgenttransaction.setUpdateDate(LocalDateTime.now());
+        payAgenttransaction.setRemarks("银行代缴充值");
+        payAgenttransaction.setDelFlag("0");
+        payAgenttransactionMapper.insertAgenttransaction(payAgenttransaction);
+        return new BankPayfeeMsg("9999","交易成功");
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public BankCheckBillsMsg checkBill( PayPayAgentbranch payPayAgentbranch, BankCheckBillParm bankCheckBillParm ){
+
+        //对账成功的对账信息
+        List<PayCheckbalance> payCheckbalances = new ArrayList();
+        //对账失败的
+        List<BankCheckBill> bankCheckBillList = new ArrayList();
+        for(BankCheckBill bankCheckBill:bankCheckBillParm.getTransDetails()){
+                if(null != bankCheckBill.checkParmIsNull()){
+                    bankCheckBill.setMessage(bankCheckBill.checkParmIsNull());
+                    bankCheckBillList.add(bankCheckBill);
+                    continue;
+                }
+                //订单号查询第三方交易记录
+                PayAgenttransactionDto payAgenttransactionDto = payFeeMapper.selectAgenttransaction(bankCheckBill.getOrderCode());
+                //缺失记录的补记录(缴费)
+                if(payAgenttransactionDto == null || payAgenttransactionDto.getId() == null){
+                    BankPayfeeMsg bankPayfeeMsg = payfeeByBank(payPayAgentbranch,bankCheckBill.getOrderCode(),bankCheckBill.getAccountNumber(),bankCheckBill.getMoney(),bankCheckBill.getPayTime());
+                    if(!bankPayfeeMsg.getRtnCode().equals("9999")){
+                        bankCheckBill.setMessage("补缴失败:"+bankPayfeeMsg.getRtnMsg());
+                        bankCheckBillList.add(bankCheckBill);
+                        continue;
+                    }
+                }else if(payAgenttransactionDto.getState().equals(3)){
+                    bankCheckBill.setMessage("已对账");
+                    bankCheckBillList.add(bankCheckBill);
+                    continue;
+                }else if(payAgenttransactionDto .getAmount() == null || payAgenttransactionDto .getAmount().compareTo(new BigDecimal(bankCheckBill.getMoney())) != 0){
+                    bankCheckBill.setMessage("对账金额有误");
+                    bankCheckBillList.add(bankCheckBill);
+                    continue;
+                }else if(payAgenttransactionDto .getAccountnumber() == null || !payAgenttransactionDto .getAccountnumber().equals(bankCheckBill.getAccountNumber())){
+                    bankCheckBill.setMessage("对账用户编码有误");
+                    bankCheckBillList.add(bankCheckBill);
+                    continue;
+                }
+
+                //对账信息无误,修改第三方交易明细状态3
+                payCheckbalanceMapper.updateAgenttransactionState(payAgenttransactionDto.getId());
+                //如果传入时间则用传入的时间做交易时间
+                DateTimeFormatter dateTimeFormatter =   DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+                LocalDateTime localDateTime= LocalDateTime.parse(bankCheckBill.getPayTime(), dateTimeFormatter);
+                //记录对账信息
+                PayCheckbalance payCheckbalance = new PayCheckbalance();
+                payCheckbalance.setTranstime(localDateTime);
+                payCheckbalance.setWebchatid("");
+                payCheckbalance.setMachid(payPayAgentbranch.getMchid());
+                payCheckbalance.setNmachid("");
+                payCheckbalance.setDeviceid("");
+                payCheckbalance.setOrderNo(bankCheckBill.getOrderCode());
+                payCheckbalance.setOutTradeNo(bankCheckBill.getOrderCode());
+                payCheckbalance.setUserId("");
+                payCheckbalance.setTranstype("");
+                payCheckbalance.setTransstate("SUCCESS");
+                payCheckbalance.setPayBank("BANK");
+                payCheckbalance.setMoneyType("BANK");
+                payCheckbalance.setOrderFee(BigDecimal.ZERO);
+                payCheckbalance.setCashFee(BigDecimal.ZERO);
+                payCheckbalance.setGoodsName("HXRemotePay");
+                payCheckbalance.setUserData("");
+                payCheckbalance.setServiceCharge(BigDecimal.ZERO);
+                payCheckbalance.setRate("");
+                payCheckbalance.setTransFee(new BigDecimal(bankCheckBill.getMoney()));
+                payCheckbalance.setRateRemark("");
+                payCheckbalance.setCreateBy(BigInteger.valueOf(1));
+                payCheckbalance.setCreateDate(localDateTime.now());
+                payCheckbalance.setUpdateBy(BigInteger.valueOf(1));
+                payCheckbalance.setUpdateDate(localDateTime.now());
+                payCheckbalance.setRemarks("代收对账");
+                payCheckbalance.setDelFlag("0");
+                payCheckbalance.setState(3);
+                payCheckbalance.setSiteId( BigInteger.valueOf(payPayAgentbranch.getSiteId()));
+                payCheckbalance.setCustomerId(BigInteger.valueOf(payPayAgentbranch.getCustomerId()));
+                payCheckbalances.add(payCheckbalance);
+        }
+
+        if(payCheckbalances.size()>0){
+            payCheckbalanceMapper.batchInsert(payCheckbalances);
+        }
+        bankCheckBillParm.setSuccessCount(payCheckbalances.size());
+        bankCheckBillParm.setCreateDate(LocalDateTime.now());
+        payCheckbalanceMapper.insertCheckBalanceLog(bankCheckBillParm);
+
+        return new BankCheckBillsMsg("9999",
+                "对账完成,对账总数:"+bankCheckBillParm.getTotalCount()+",对账成功数:"+payCheckbalances.size(),bankCheckBillList);
+    }
 }

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

@@ -2,6 +2,7 @@ package com.bz.smart_city.service.pay;
 
 import com.bz.smart_city.dto.pay.PayInvoiceDto;
 import com.bz.smart_city.dto.pay.payfee.*;
+import com.bz.smart_city.entity.pay.PayPayAgentbranch;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
@@ -118,6 +119,11 @@ public interface PayFeeService {
 
     BigInteger getWaterPropertyId(BigInteger id);
 
+    PayPayAgentbranch selectPayAgentbranchInfo(String code,Integer customerId);
 
+    List<BankPayfeeAccountInfo> selectBankPayfeeAccountInfo(String queryType,String queryValue);
 
+    BankPayfeeMsg payfeeByBank( PayPayAgentbranch payPayAgentbranch ,String orderCode,String accountNumber,Float money, String payTime );
+
+    BankCheckBillsMsg checkBill(PayPayAgentbranch payPayAgentbranch, BankCheckBillParm bankCheckBillParm );
 }

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

@@ -170,3 +170,5 @@ gd.agent.url=http://10.0.0.160:6377/api
 sync.customer.linhe.id=126
 sync.data.limit=50
 
+#银行代收客户id
+payfee.bank.customerId=47

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

@@ -172,4 +172,7 @@ invoice.query.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/ecOd/queryElectric
 gd.agent.url=http://47.112.16.203:9001
 #临河客户
 sync.customer.linhe.id=68
-sync.data.limit=100
+sync.data.limit=100
+
+#银行代收客户id
+payfee.bank.customerId=47

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

@@ -171,4 +171,7 @@ invoice.query.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/ecOd/queryElectric
 gd.agent.url=http://10.0.0.160:6377/api
 #临河客户
 sync.customer.linhe.id=126
-sync.data.limit=100
+sync.data.limit=100
+
+#银行代收客户id
+payfee.bank.customerId=47

+ 6 - 0
smart-city-platform/src/main/resources/mapper/pay/PayAgenttransactionMapper.xml

@@ -40,4 +40,10 @@
          where out_trade_no =(select order_no from pay_pay_agenttransaction where payseriesno=#{payseriesno} and site_id= #{siteId} and customer_id= #{customerId})
     </update>
 
+    <insert id="insertAgenttransaction">
+        INSERT INTO pay_pay_agenttransaction(
+            accountnumber, accountname, agentbranch_id, agent_name, agent_code, amount, state, transtime, payseriesno, order_no, create_by, create_date, update_by, update_date, remarks, del_flag, site_id, customer_id)
+        VALUES(#{accountnumber},#{accountname},#{agentbranchId},#{agentName},#{agentCode},#{amount},#{state},#{transtime},#{payseriesno},#{orderNo},#{createBy},#{createDate},#{updateBy},#{updateDate},#{remarks},#{delFlag},#{siteId},#{customerId})
+    </insert>
+
 </mapper>

+ 15 - 0
smart-city-platform/src/main/resources/mapper/pay/PayCheckbalanceMapper.xml

@@ -39,6 +39,21 @@
 
     </select>
 
+    <insert id="batchInsert">
 
+    INSERT INTO pay_pay_checkbalance( transtime, webchatid, machid, nmachid, deviceid, order_no, out_trade_no, user_id, transtype, transstate, pay_bank, money_type, order_fee, cash_fee, goods_name, user_data, service_charge, rate, trans_fee, rate_remark, create_by, create_date, update_by, update_date, remarks, del_flag, state, site_id, customer_id)
+    VALUES
+        <foreach collection="payCheckbalances" item="item" separator=",">
+    (#{item.transtime},#{item.webchatid},#{item.machid},#{item.nmachid},#{item.deviceid},#{item.orderNo},#{item.outTradeNo},#{item.userId},#{item.transtype},#{item.transstate},#{item.payBank},#{item.moneyType},#{item.orderFee},#{item.cashFee},#{item.goodsName},#{item.userData},#{item.serviceCharge},#{item.rate},#{item.transFee},#{item.rateRemark},#{item.createBy},#{item.createDate},#{item.updateBy},#{item.updateDate},#{item.remarks},#{item.delFlag},#{item.state},#{item.siteId},#{item.customerId})
+        </foreach>
+    </insert>
 
+    <insert id="insertCheckBalanceLog">
+    INSERT INTO pay_pay_checkbalance_log( agentCode, agentPwd, chargeDate, totalMoney, totalCount, successCount, createDate)
+    VALUES(#{agentCode},#{agentPwd},#{chargeDate},#{totalMoney},#{totalCount},#{successCount},#{createDate})
+    </insert>
+
+     <update id="updateAgenttransactionState">
+        update pay_pay_agenttransaction set state=3 where id = #{id}
+    </update>
 </mapper>

+ 75 - 0
smart-city-platform/src/main/resources/mapper/pay/payFeeMapper.xml

@@ -321,4 +321,79 @@
         from pay_base_customerandmeterrela
         where account_id =#{id}
     </select>
+
+
+    <select id="selectBankPayfeeAccountInfo" resultType="com.bz.smart_city.dto.pay.payfee.BankPayfeeAccountInfo">
+        select
+            a.name as "accountName"
+            ,a.accountnumber as "accountCode"
+            ,a.address as "address"
+            ,a.mobilephone as "phone"
+            ,a.idcardno as "idCardNo"
+            ,IFNULL(r.debt,0) as "debt"
+            ,IFNULL(h.remaining,0) as  "prepayAmount"
+        from pay_base_account a
+        left join pay_pay_rechargeaccount h on a.id=h.account_id
+        left join (
+                select
+                    account_id
+                    ,sum(debt) debt
+                from pay_pay_receivable
+                group by account_id
+        ) r on r.account_id =a.id
+        where
+         <if test="queryType != null and queryType == '01'">
+            a.accountnumber = #{queryValue}
+         </if>
+         <if test="queryType != null and queryType == '02'">
+             a.mobilephone= #{queryValue}
+         </if>
+         <if test="queryType != null and queryType == '03'">
+             a.idcardno= #{queryValue}
+         </if>
+    </select>
+    
+    <select id="selectPayAgentbranchInfo" resultType="com.bz.smart_city.entity.pay.PayPayAgentbranch">
+            select
+                id
+                ,paykey
+                ,code
+                ,name
+                ,type
+                ,appid
+                ,appsecret
+                ,mchid
+                ,site_id as "siteId"
+                ,customer_id as "customerId"
+            from pay_pay_agentbranch
+            where del_flag = 0  and `code`=#{code} and customer_id =#{customerId}
+    </select>
+
+    <select id="selectAgenttransaction"  resultType="com.bz.smart_city.dto.pay.PayAgenttransactionDto">
+
+        select
+            a.accountnumber as "accountnumber",
+            a.accountname as "accountname",
+            a.agentbranch_id as "agentbranchId",
+            a.agent_name as "agentName",
+            a.agent_code as "agentCode",
+            a.amount as "amount",
+            a.state as "state",
+            a.transtime as "transtime",
+            a.payseriesno as "payseriesno",
+            a.order_no as "orderNo",
+
+            a.id as "id",
+            a.site_id as "siteId",
+            a.customer_id as "customerId",
+            a.create_date as "createDate",
+            a.create_by as "createBy",
+            a.update_date as "updateDate",
+            a.update_by as "updateBy",
+            a.remarks as "remarks",
+            a.del_flag as "delFlag"
+        from pay_pay_agenttransaction a
+        where  a.order_no = #{orderNo}
+
+    </select>
 </mapper>