Просмотр исходного кода

贸理通推送sop逻辑优化

liuj 1 месяц назад
Родитель
Сommit
75e3009f36

+ 28 - 0
src/main/java/com/sunxung/factoring/entity/smb/SmbRefinancingInfo.java

@@ -2,6 +2,8 @@ package com.sunxung.factoring.entity.smb;
 
 import com.sunxung.factoring.service.smbApi.resp.RepayPlanResp;
 
+import java.math.BigDecimal;
+
 /**
  * 苏商再融资还款信息
  */
@@ -22,6 +24,16 @@ public class SmbRefinancingInfo {
      */
     private String repaymentMethod;
 
+    /**
+     * 归还本金
+     */
+    private BigDecimal repayPrincipal;
+
+    /**
+     * 归还利息
+     */
+    private BigDecimal repayInterest;
+
     /**
      * 苏商还款计划
      */
@@ -58,4 +70,20 @@ public class SmbRefinancingInfo {
     public void setRepaymentMethod(String repaymentMethod) {
         this.repaymentMethod = repaymentMethod;
     }
+
+    public BigDecimal getRepayPrincipal() {
+        return repayPrincipal;
+    }
+
+    public void setRepayPrincipal(BigDecimal repayPrincipal) {
+        this.repayPrincipal = repayPrincipal;
+    }
+
+    public BigDecimal getRepayInterest() {
+        return repayInterest;
+    }
+
+    public void setRepayInterest(BigDecimal repayInterest) {
+        this.repayInterest = repayInterest;
+    }
 }

+ 26 - 3
src/main/java/com/sunxung/factoring/service/ledger/impl/LedgerManagementServiceImpl.java

@@ -270,6 +270,9 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
     @Value("${config.smbRefinancingPlanUpdate.url}")
     private String smbRefinancingPlanUpdateUrl;
 
+    @Value("${config.smbBeforeRepayPlanUpdate.url}")
+    private String smbBeforeRepayPlanUpdateUrl;
+
     @Override
     public LedgerAccountBasicInfo get(Long id) {
         return ledgerAccountBasicInfoMapper.getListInfo(id);
@@ -525,7 +528,24 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void repayApplyBySMB(LedgerFundGoodsAssign ledgerFundGoodsAssign) {
+
         FinancingLoanInfo financingLoanInfo = getFinancingLoanInfoByAccountsReceivableId(ledgerFundGoodsAssign.getSopAccountsReceivableId());
+
+        //还款前计划查询和更新、防止因自动批扣导致计划发生过变更
+        RepayPlanResp repayPlanResp = smbApiService.repayPlanQuery(financingLoanInfo.getOpenId(), financingLoanInfo.getDueBillNo());
+        if (repayPlanResp != null) {
+            SmbRefinancingInfo smbRefinancingInfo = new SmbRefinancingInfo();
+            smbRefinancingInfo.setContractNo(financingLoanInfo.getContractNo());
+            smbRefinancingInfo.setQuotaDisburseBatch(financingLoanInfo.getQuotaDisburseBatch());
+            smbRefinancingInfo.setRepayPlanResp(repayPlanResp);
+
+            ResponseEntity<String> responseEntity = restTemplate.postForEntity(smbBeforeRepayPlanUpdateUrl, smbRefinancingInfo, String.class);
+            ResponseJson responseJson = JSONUtil.toBean(responseEntity.getBody(), ResponseJson.class);
+            if (responseEntity.getStatusCode().value() != HttpStatus.OK.value() || !responseJson.isSuccess()) {
+                throw new BusinessException(CodeUtil.FAIL, "苏商还款计划更新推送sop失败:" + responseJson.getMsg().toString());
+            }
+        }
+
         RepayApply repayApply = new RepayApply();
         if (financingLoanInfo != null) {
             repayApply.setDuebillNo(financingLoanInfo.getDueBillNo());
@@ -545,20 +565,23 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
             bizNo = bizNo.substring(0, 32);
         }
         repayApply.setBizNo(bizNo);
+        //提交还款申请
         RepayStatusResp repayStatusResp = smbApiService.repayApply(repayApply, financingLoanInfo.getOpenId());
         if (repayStatusResp != null) {
             //保存资方还款信息
-            saveFinancingLoanInfo(financingLoanInfo, repayStatusResp, bizNo);
+            saveFinancingPaymentInfo(financingLoanInfo, repayStatusResp, bizNo);
             if ("01".equals(repayStatusResp.getRepayStatus())) {
                 //如果状态为还款成功
                 //如果还款状态由还款中->还款成功 查询最新的还款计划,同步更新到sop中
-                RepayPlanResp repayPlanResp = smbApiService.repayPlanQuery(financingLoanInfo.getOpenId(), financingLoanInfo.getDueBillNo());
+                repayPlanResp = smbApiService.repayPlanQuery(financingLoanInfo.getOpenId(), financingLoanInfo.getDueBillNo());
                 if (repayPlanResp != null) {
                     SmbRefinancingInfo smbRefinancingInfo = new SmbRefinancingInfo();
                     smbRefinancingInfo.setContractNo(financingLoanInfo.getContractNo());
                     smbRefinancingInfo.setQuotaDisburseBatch(financingLoanInfo.getQuotaDisburseBatch());
                     smbRefinancingInfo.setRepayPlanResp(repayPlanResp);
                     smbRefinancingInfo.setRepaymentMethod(SmbRepaymentMethodEnum.PROACTIVE_REPAYMENT.getCode());
+                    smbRefinancingInfo.setRepayPrincipal(new BigDecimal(repayStatusResp.getHxCapi()));
+                    smbRefinancingInfo.setRepayInterest(new BigDecimal(repayStatusResp.getHxInte()));
 
                     ResponseEntity<String> responseEntity = restTemplate.postForEntity(smbRefinancingPlanUpdateUrl, smbRefinancingInfo, String.class);
                     ResponseJson responseJson = JSONUtil.toBean(responseEntity.getBody(), ResponseJson.class);
@@ -576,7 +599,7 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
      * @param financingLoanInfo
      * @param repayStatusResp
      */
-    private void saveFinancingLoanInfo(FinancingLoanInfo financingLoanInfo, RepayStatusResp repayStatusResp, String bizNo) {
+    private void saveFinancingPaymentInfo(FinancingLoanInfo financingLoanInfo, RepayStatusResp repayStatusResp, String bizNo) {
         FinancingPaymentInfo financingPaymentInfo = new FinancingPaymentInfo(financingLoanInfo);
         //bizNo
         financingPaymentInfo.setBizNo(bizNo);

+ 0 - 5
src/main/java/com/sunxung/factoring/service/smb/impl/FinancingPaymentInfoServiceImpl.java

@@ -154,11 +154,6 @@ public class FinancingPaymentInfoServiceImpl extends ServiceImpl<FinancingPaymen
             for (FinancingPaymentInfo financingPaymentInfo : list) {
                 String beforeRepayStatus = financingPaymentInfo.getRepayStatus();
 
-                //查询最新还款状态
-//                String bizNo = UUID.randomUUID().toString().replace("-", "");
-//                if (bizNo.length() > 32) {
-//                    bizNo = bizNo.substring(0, 32);
-//                }
                 RepayStatusResp repayStatusResp = smbApiService.repayStatusQuery(financingPaymentInfo.getOpenId(), financingPaymentInfo.getBizNo(), financingPaymentInfo.getDueBillNo());
                 if (repayStatusResp != null) {
                     //更新资方还款信息

+ 2 - 0
src/main/resources/config.properties

@@ -52,3 +52,5 @@ config.contract.getContractFile.url=${sop.url}/api/getContractFile
 config.startOaPaymentProcessUrl.url=${sop.url}/api/startOaOtherPaymentProcess
 ## \u82CF\u5546\u8FD8\u6B3E\u8BA1\u5212\u66F4\u65B0
 config.smbRefinancingPlanUpdate.url=${sop.url}/api/smb/refinancingPlanUpdate
+## \u82CF\u5546\u4E3B\u52A8\u8FD8\u6B3E\u3001\u57AB\u4ED8\u524D\u8BA1\u5212\u66F4\u65B0
+config.smbBeforeRepayPlanUpdate.url=${sop.url}/api/smb/smbBeforeRepayPlanUpdate