shenziyin-gh 1 年之前
父節點
當前提交
2b19b7412c

+ 7 - 0
src/main/java/com/cool/bang/api/DataMatch.java

@@ -180,4 +180,11 @@ public class DataMatch {
     @GetMapping("bankAccountChecing")
     public void bankAccountChecing(){mySQLSecondService.bankAccountChecing();}
 
+
+    /**
+     * 托管合同交存跟交易对账
+     */
+    @GetMapping("contractFundCheckTrade")
+    public void contractFundCheckTrade(){mySQLSecondService.contractFundCheckTrade();}
+
 }

+ 18 - 7
src/main/java/com/cool/bang/modules/mysql/domain/FcTrade.java

@@ -3,6 +3,7 @@ package com.cool.bang.modules.mysql.domain;
 import com.cool.bang.common.util.DateUtil;
 
 import java.math.BigDecimal;
+import java.util.List;
 
 public class FcTrade {
 
@@ -117,28 +118,38 @@ public class FcTrade {
         this.flushSerialNumber = item.getFlushSerialNumber();
         this.businessNumber = item.getBusinessNumber();
         this.channelType = item.getChannelType();
-        if(null != account){
+        if (null != account) {
             this.channelCode = account.getBankCode();
             this.accountType = account.getType();
             this.account = account.getAccount();
             this.accountId = account.getId();
         }
-        if(null != projectAccount){
+        if (null != projectAccount) {
             this.projectAccountId = projectAccount.getId();
         }
-        if(null != buildingAccount){
+        if (null != buildingAccount) {
             this.buildingAccountId = buildingAccount.getId();
         }
         this.amount = item.getAmount();
-        if(null != item.getCode()){
+        if (null != item.getCode()) {
             String code = String.valueOf(item.getCode());
-            if(code.startsWith("1")){
+            if (code.startsWith("1")) {
                 this.type = 1;
-            }else if(code.startsWith("2")){
+            } else if (code.startsWith("2")) {
                 this.type = 2;
             }
         }
-        this.transactionMode = 1;
+
+        if (item.getPayType().equals("06")) {
+            this.transactionMode = 3;
+        } else if (item.getPayType().equals("05")) {
+            this.transactionMode = 2;
+        } else if (item.getPayType().equals("09")) {
+            this.transactionMode = 1;
+        } else {
+            this.transactionMode = 1;
+        }
+
         this.transactionTime = null != item.getTransactionTime() ? DateUtil.dateToStr(item.getTransactionTime(), "yyyy-MM-dd") : null;
         this.checkStatus = 1;
         this.delFlag = 1;

+ 5 - 2
src/main/java/com/cool/bang/modules/mysql/domain/Fund.java

@@ -185,8 +185,11 @@ public class Fund {
         if (this.paidAmount.compareTo(this.payableAmount) == 1) {
             this.paidAmount = this.payableAmount;
         }
-        //应交  = 已交
-        if (this.payableAmount.compareTo(this.paidAmount) == 0) {
+        //如果通知书金额为0
+        if(BigDecimal.ZERO.compareTo(this.payableAmount) == 0){
+            this.paymentStatus = 0;//待交存
+            //应交  = 已交
+        } else if (this.payableAmount.compareTo(this.paidAmount) == 0) {
             this.paymentStatus = 2;//已交存
         } else if (this.payableAmount.compareTo(this.unpaidAmount) == 0) {
             this.paymentStatus = 0;//待交存

+ 120 - 0
src/main/java/com/cool/bang/modules/mysql/domain/FundInfo.java

@@ -0,0 +1,120 @@
+package com.cool.bang.modules.mysql.domain;
+
+import java.math.BigDecimal;
+
+public class FundInfo {
+
+    /**
+     * 通知书编号
+     */
+    private String businessNumber;
+    /**
+     * 合同主键
+     */
+    private Long contractId;
+
+    /**
+     * 合同编号
+     */
+    private String contractNumber;
+    /**
+     * 交存款项 1首期款(含一次性付款)2分期后期款 3商业贷款 4公积金贷款
+     */
+    private Integer paymentType;
+
+    /**
+     * 应交存金额
+     */
+    private BigDecimal payableAmount;
+
+    /**
+     * 已交存金额
+     */
+    private BigDecimal paidAmount;
+
+    /**
+     * 待交存金额
+     */
+    private BigDecimal unpaidAmount;
+    /**
+     * 账户类型 1托管账户 2监管账户
+     */
+    private Integer accountType;
+    /**
+     * 交存状态 0未交存 1未足额 2已交存
+     */
+    private Integer paymentStatus;
+
+
+    public String getBusinessNumber() {
+        return businessNumber;
+    }
+
+    public void setBusinessNumber(String businessNumber) {
+        this.businessNumber = businessNumber;
+    }
+
+    public Long getContractId() {
+        return contractId;
+    }
+
+    public void setContractId(Long contractId) {
+        this.contractId = contractId;
+    }
+
+    public String getContractNumber() {
+        return contractNumber;
+    }
+
+    public void setContractNumber(String contractNumber) {
+        this.contractNumber = contractNumber;
+    }
+
+    public Integer getPaymentType() {
+        return paymentType;
+    }
+
+    public void setPaymentType(Integer paymentType) {
+        this.paymentType = paymentType;
+    }
+
+    public BigDecimal getPayableAmount() {
+        return payableAmount;
+    }
+
+    public void setPayableAmount(BigDecimal payableAmount) {
+        this.payableAmount = payableAmount;
+    }
+
+    public BigDecimal getPaidAmount() {
+        return paidAmount;
+    }
+
+    public void setPaidAmount(BigDecimal paidAmount) {
+        this.paidAmount = paidAmount;
+    }
+
+    public BigDecimal getUnpaidAmount() {
+        return unpaidAmount;
+    }
+
+    public void setUnpaidAmount(BigDecimal unpaidAmount) {
+        this.unpaidAmount = unpaidAmount;
+    }
+
+    public Integer getAccountType() {
+        return accountType;
+    }
+
+    public void setAccountType(Integer accountType) {
+        this.accountType = accountType;
+    }
+
+    public Integer getPaymentStatus() {
+        return paymentStatus;
+    }
+
+    public void setPaymentStatus(Integer paymentStatus) {
+        this.paymentStatus = paymentStatus;
+    }
+}

+ 10 - 0
src/main/java/com/cool/bang/modules/mysql/domain/TradeInfo.java

@@ -31,6 +31,8 @@ public class TradeInfo {
 
     private String lzbh;
 
+    private String payType;
+
 
     public Long getId() {
         return id;
@@ -135,4 +137,12 @@ public class TradeInfo {
     public void setLzbh(String lzbh) {
         this.lzbh = lzbh;
     }
+
+    public String getPayType() {
+        return payType;
+    }
+
+    public void setPayType(String payType) {
+        this.payType = payType;
+    }
 }

+ 20 - 0
src/main/java/com/cool/bang/modules/mysql/mapper/MySqlMapper.java

@@ -90,4 +90,24 @@ public interface MySqlMapper {
      * @return
      */
     List<Account> selectTgAccountInfo();
+
+    /**
+     * 银行流水编号
+     * @param serialNumbers
+     * @return
+     */
+    List<Account> selectTsDzByserial(@Param("serialNumbers") List<String> serialNumbers);
+
+    /**
+     * 获取托管账户的交存
+     * @return
+     */
+    List<FundInfo> getTgFund();
+
+    /**
+     * 根据业务编号查询 交易 金额
+     * @param businessNumber
+     * @return
+     */
+    BigDecimal getAmountByBusinessNumber(@Param("businessNumber") String businessNumber);
 }

+ 46 - 12
src/main/java/com/cool/bang/modules/mysql/service/MySQLSecondService.java

@@ -45,22 +45,12 @@ public class MySQLSecondService {
 
 
     /**
-     * 定金导入
+     * 退款
      */
     @Transactional
     public void refundTo() {
         System.out.println("===============fc_refund 导入数据开始=================");
-        //List<TkInfo> djTkList = oracleMapper.selectDjTk();
         List<TkInfo> htTkList = oracleMapper.selectHtTk();
-        /*List<Integer> otherHtIds = new ArrayList<>();
-        otherHtIds.add(40051);
-        otherHtIds.add(3958);
-        otherHtIds.add(13496);
-        otherHtIds.add(19046);*/
-
-        //List<TkInfo> otherChange = oracleMapper.selectOtherHtTk(otherHtIds);
-        //List<TkInfo> tkInfoList = Stream.concat(djTkList.stream(), htTkList.stream()).collect(Collectors.toList());
-        //tkInfoList = Stream.concat(tkInfoList.stream(), otherChange.stream()).collect(Collectors.toList());
         List<Refund> refunds = new ArrayList<>();
         for (TkInfo item : htTkList) {
             Integer qybh = StringUtils.isEmpty(item.getQybh()) ? null : Integer.valueOf(item.getQybh());
@@ -134,6 +124,7 @@ public class MySQLSecondService {
     public void tradeTgTo() {
         System.out.println("===============fc_trade 导入数据开始=================");
         List<TradeInfo> tradeInfoList = oracleMapper.selectTG();
+
         List<FcTrade> fcTrades = new ArrayList<>();
 
         for (TradeInfo item : tradeInfoList) {
@@ -219,7 +210,18 @@ public class MySQLSecondService {
         List<Account> wdzJc = oracleMapper.getWdzJc();
         List<Account> wdzBf = oracleMapper.getWdzBf();
         List<String> strs = new ArrayList<>();
+        //处理特殊的对账
+        //1、寿光农商银行  缺失的 定金626475.6 (银行流水号 = 041002202216625184199811) 手续费0.44(银行流水号= 041002202216655621675571) (总的楼栋户的合计 比 账户余额少 这两笔 需要加上这两笔 )
+        //2、中国建设银行股份有限公司寿光支行 bankCode:02   手续费 -200(银行流水号= 021002202216625378315471) (总的楼栋户的合计 比对完账的账户余额 多200 总的楼栋户合计需要加上这个-200)
+        //3、中国邮政储蓄银行股份有限公司寿光市支行 利息186893.99 (银行流水号=161002202316730870521161) (总的楼栋户的合计 比账户余额少这一笔  总的楼栋户合计需要加上这个 186893.99)
+        List<String> serialNumbers = new ArrayList<>();
+        serialNumbers.add("041002202216625184199811");
+        serialNumbers.add("041002202216655621675571");
+        serialNumbers.add("021002202216625378315471");
+        serialNumbers.add("161002202316730870521161");
+        List<Account> tsList = mySqlMapper.selectTsDzByserial(serialNumbers);
         for (Account account : list) {
+
             //未对账的交存
             BigDecimal jc = BigDecimal.ZERO;
             if (wdzJc != null && !wdzJc.isEmpty()) {
@@ -232,14 +234,23 @@ public class MySQLSecondService {
                 Account bfAccount = wdzBf.stream().filter(t -> !StringUtils.isEmpty(t.getBankCode()) && t.getBankCode().equals(account.getBankCode())).findFirst().orElse(null);
                 bf = null != bfAccount ? bfAccount.getBalance() : BigDecimal.ZERO;
             }
+            //当前托管户 的其他类型的 对账金额
+            BigDecimal otherTypeAmount = BigDecimal.ZERO;
+            Account otherTypeAccount = tsList.stream().filter(t -> !StringUtils.isEmpty(t.getBankCode()) && t.getBankCode().equals(account.getBankCode())).findFirst().orElse(null);
+            if (otherTypeAccount != null) {
+                otherTypeAmount = otherTypeAccount.getBalance();
+                otherTypeAmount = null != otherTypeAmount ? otherTypeAccount.getBalance() : BigDecimal.ZERO;
+            }
+
             StringBuilder str = new StringBuilder();
             str.append(account.getBankName())
                     .append(";" + account.getBankCode())
                     .append(";" + jc)
                     .append(";" + bf)
+                    .append(";" + otherTypeAmount)
                     .append(";" + account.getBalance())
                     .append(";" + account.getAccountBalance())
-                    .append(";" + ((account.getBalance().subtract(jc)).add(bf)).subtract(account.getAccountBalance()));
+                    .append(";" + ((account.getBalance().subtract(jc)).add(bf).add(otherTypeAmount)).subtract(account.getAccountBalance()));
             strs.add(str.toString());
         }
 
@@ -247,4 +258,27 @@ public class MySQLSecondService {
             System.out.println(str);
         }
     }
+
+    public void contractFundCheckTrade() {
+        List<FundInfo> tgFund = mySqlMapper.getTgFund();
+        List<String> strs = new ArrayList<>();
+        for (FundInfo item : tgFund) {
+            //查询 交易
+            BigDecimal amount = mySqlMapper.getAmountByBusinessNumber(item.getBusinessNumber());
+            StringBuilder str = new StringBuilder();
+            str.append(item.getContractNumber() + ";")
+                    .append(item.getContractId() + ";")
+                    .append(item.getBusinessNumber() + ";")
+                    .append(1 == item.getPaymentStatus() ? "未足额" : (2 == item.getPaymentStatus() ? "已交存" : (0 == item.getPaymentStatus() ? "未交存" : "")))
+                    .append(";" + item.getPayableAmount() + ";")
+                    .append(amount + ";")
+                    .append(item.getPayableAmount().compareTo(amount) == 0 ? "是" : "否");
+            strs.add(str.toString());
+        }
+        System.out.flush();
+        for (String str : strs) {
+            System.out.println(str);
+        }
+    }
+
 }

+ 7 - 0
src/main/java/com/cool/bang/modules/oracle/mapper/OracleMapper.java

@@ -89,4 +89,11 @@ public interface OracleMapper {
      * @return
      */
     List<Account> getWdzBf();
+
+    /**
+     * 查询托管的账户的交易  跟楼栋户合计 对账缺失的 几条交易
+     * @param ids
+     * @return
+     */
+    List<TradeInfo> selectTGTsDz(@Param("ids") List<Integer> ids);
 }

+ 25 - 0
src/main/resources/mapper/mysql/MySQLMapper.xml

@@ -388,4 +388,29 @@
         WHERE
             t.type = 1
     </select>
+
+    <select id="selectTsDzByserial" resultType="com.cool.bang.modules.mysql.domain.Account">
+        select a.bank_code AS bankCode,sum(t.amount) AS balance
+        from fc_trade t
+        left join fc_account a on a.id = t.account_id
+        where
+        serial_number IN
+        <foreach item="item" index="index" collection="serialNumbers"
+                 open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+        group by bankCode
+    </select>
+
+    <select id="getTgFund" resultType="com.cool.bang.modules.mysql.domain.FundInfo">
+        SELECT business_number AS businessNumber,payment_status AS paymentStatus,account_type AS accountType,
+               id,contract_id AS contractId,contract_number AS contractNumber,payable_amount AS payableAmount,
+               paid_amount AS paidAmount,unpaid_amount AS unpaidAmount,payment_type AS paymentType
+        FROM fc_fund
+        WHERE payment_status != 0 AND account_type = 1
+    </select>
+
+    <select id="getAmountByBusinessNumber" resultType="decimal">
+        select IFNULL(SUM(amount),0) from  fc_trade where business_number = #{businessNumber}
+    </select>
 </mapper>

+ 19 - 4
src/main/resources/mapper/oracle/OracleMapper.xml

@@ -76,7 +76,7 @@
         FROM BHTPAY hp
                  LEFT JOIN ACCOUNT a ON hp.ACCOUNTID = a.ACCOUNTID
                  LEFT JOIN BHT h ON hp.HTID = h.HTID
-        WHERE hp.STATE =1
+        WHERE hp.STATE = 1
     </select>
 
     <select id="getBhtPayTradeByBHTID" resultType="com.cool.bang.modules.oracle.domain.po.BhtTrade">
@@ -103,7 +103,7 @@
         FROM BDJ dj
             LEFT JOIN TRADE tra ON dj.DJBH = tra.DJNUM AND tra.PAYTYPE = 9 AND tra.TRADESTATE = 1
             LEFT JOIN BHTPAY hp ON tra.TRADENUM = hp.JKBH AND hp.STATE = 1
-            LEFT JOIN ACCOUNT a ON hp.ACCOUNTID = a.ACCOUNTID
+            LEFT JOIN ACCOUNT a ON dj.ACCOUNTID = a.ACCOUNTID
             LEFT JOIN BHT ht ON ht.HTID = hp.HTID AND ht.STATE = 1
         WHERE dj.STATE = 1 AND (dj.TRADESTATE = 0 OR dj.TRADESTATE = 1 OR dj.TRADESTATE = 2)
     </select>
@@ -129,7 +129,7 @@
     <select id="selectDDZ" resultType="com.cool.bang.modules.mysql.domain.TradeInfo">
         SELECT
             ID AS id,ACCOUNTNO AS accountNo,BANKSER AS serialNumber,OLDBANKSER AS flushSerialNumber,
-            TRADENUM AS businessNumber,BANKFLAG AS channelType,TRADEAMOUNT AS amount,TRADECODE  AS code,
+            TRADENUM AS businessNumber,BANKFLAG AS channelType,TRADEAMOUNT AS amount,TRADECODE  AS code,PAYTYPE AS payType,
             CHECKFLAG AS checkStatus,CHECKDATE AS checkDate, 1 AS transactionMode,TRADEDATE AS  transactionTime,LZBH AS lzbh
         from TRADE
         WHERE CHECKFLAG =1
@@ -138,7 +138,7 @@
     <select id="selectTG" resultType="com.cool.bang.modules.mysql.domain.TradeInfo">
         SELECT
             ID AS id,ACCOUNTNO AS accountNo,BANKSER AS serialNumber,OLDBANKSER AS flushSerialNumber,
-            TRADENUM AS businessNumber,BANKFLAG AS channelType,TRADEAMOUNT AS amount,TRADECODE  AS code,
+            TRADENUM AS businessNumber,BANKFLAG AS channelType,TRADEAMOUNT AS amount,TRADECODE  AS code, PAYTYPE AS payType,
             CHECKFLAG AS checkStatus,CHECKDATE AS checkDate, 1 AS transactionMode,TRADEDATE AS  transactionTime,LZBH AS lzbh
         FROM
             trade
@@ -146,6 +146,21 @@
             accountno IN ( SELECT accountno FROM account  WHERE accountid &lt;= 8 ) AND CHECKFLAG = 2 AND TRADESTATE =1
     </select>
 
+    <select id="selectTGTsDz" resultType="com.cool.bang.modules.mysql.domain.TradeInfo">
+        SELECT
+            ID AS id,ACCOUNTNO AS accountNo,BANKSER AS serialNumber,OLDBANKSER AS flushSerialNumber,
+            TRADENUM AS businessNumber,BANKFLAG AS channelType,TRADEAMOUNT AS amount,TRADECODE  AS code, PAYTYPE AS payType,
+            CHECKFLAG AS checkStatus,CHECKDATE AS checkDate, 1 AS transactionMode,TRADEDATE AS  transactionTime,LZBH AS lzbh
+        FROM
+            trade
+        WHERE
+            ID IN
+        <foreach item="item" index="index" collection="ids"
+                 open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+    </select>
+
 
     <select id="sumByZgToTg" resultType="decimal">
         SELECT NVL(SUM(t3.money),0)