Преглед на файлове

Merge remote-tracking branch 'origin/smb' into smb

liutao преди 1 месец
родител
ревизия
77beb068fb

+ 59 - 57
src/main/java/com/sunxung/factoring/entity/ledger/LedgerFundGoodsAssignHis.java

@@ -121,7 +121,7 @@ public class LedgerFundGoodsAssignHis extends BaseEntity {
      * 是否计提 0:否,1:是
      */
     @TableField("is_accrual")
-    private Boolean isAccrual;
+    private Boolean accrual;
 
     /**
      * 计提金额
@@ -241,7 +241,25 @@ public class LedgerFundGoodsAssignHis extends BaseEntity {
      * 是否提交
      */
     @TableField("is_submit")
-    private Boolean isSubmit;
+    private Boolean submit;
+
+    /**
+     * 是否分配资方融资利息/管理费/本金
+     */
+    @TableField("has_assign_management")
+    private Boolean hasAssignManagement;
+
+    /**
+     * 资方融资利息
+     */
+    @TableField("management_interest")
+    private BigDecimal managementInterest;
+
+    /**
+     * 资方融资本金
+     */
+    @TableField("management_principal")
+    private BigDecimal managementPrincipal;
 
     public Long getLedgerAccountHisInfoId() {
         return ledgerAccountHisInfoId;
@@ -355,13 +373,7 @@ public class LedgerFundGoodsAssignHis extends BaseEntity {
     public void setCurrentAssignAmount(BigDecimal currentAssignAmount) {
         this.currentAssignAmount = currentAssignAmount;
     }
-    public Boolean getIsAccrual() {
-        return isAccrual;
-    }
 
-    public void setIsAccrual(Boolean isAccrual) {
-        this.isAccrual = isAccrual;
-    }
     public BigDecimal getAccrualAmount() {
         return accrualAmount;
     }
@@ -495,54 +507,44 @@ public class LedgerFundGoodsAssignHis extends BaseEntity {
     public void setReturnedAmount(BigDecimal returnedAmount) {
         this.returnedAmount = returnedAmount;
     }
-    public Boolean getIsSubmit() {
-        return isSubmit;
-    }
-
-    public void setIsSubmit(Boolean isSubmit) {
-        this.isSubmit = isSubmit;
-    }
-
-    @Override
-    public String toString() {
-        return "LedgerFundGoodsAssignHis{" +
-            "ledgerAccountHisInfoId=" + ledgerAccountHisInfoId +
-            ", businessNumber=" + businessNumber +
-            ", underlyingAssetsNo=" + underlyingAssetsNo +
-            ", acceptanceGoodsNumber=" + acceptanceGoodsNumber +
-            ", settlementNumber=" + settlementNumber +
-            ", billingFactoringBusinessLoanRecordId=" + billingFactoringBusinessLoanRecordId +
-            ", sopAccountsReceivableId=" + sopAccountsReceivableId +
-            ", supplierId=" + supplierId +
-            ", supplierName=" + supplierName +
-            ", contractNo=" + contractNo +
-            ", quotaDisburseBatch=" + quotaDisburseBatch +
-            ", salesTotalPrice=" + salesTotalPrice +
-            ", purchaseTotalPrice=" + purchaseTotalPrice +
-            ", loanDate=" + loanDate +
-            ", loanAmount=" + loanAmount +
-            ", currentAssignAmount=" + currentAssignAmount +
-            ", isAccrual=" + isAccrual +
-            ", accrualAmount=" + accrualAmount +
-            ", financingOverdueInterest=" + financingOverdueInterest +
-            ", financingInterest=" + financingInterest +
-            ", financingManagementFee=" + financingManagementFee +
-            ", hasAssignInterest=" + hasAssignInterest +
-            ", hasAssignManagementFee=" + hasAssignManagementFee +
-            ", hasAssignOverdueInterest=" + hasAssignOverdueInterest +
-            ", financingPrincipal=" + financingPrincipal +
-            ", platformProfit=" + platformProfit +
-            ", guarantee=" + guarantee +
-            ", discountAmount=" + discountAmount +
-            ", refundInterest=" + refundInterest +
-            ", refundManagementFee=" + refundManagementFee +
-            ", toAssignedAmount=" + toAssignedAmount +
-            ", goodsAssignId=" + goodsAssignId +
-            ", latestCollDate=" + latestCollDate +
-            ", lastPlanDate=" + lastPlanDate +
-            ", payCollBasicId=" + payCollBasicId +
-            ", returnedAmount=" + returnedAmount +
-            ", isSubmit=" + isSubmit +
-        "}";
+
+    public Boolean getAccrual() {
+        return accrual;
+    }
+
+    public void setAccrual(Boolean accrual) {
+        this.accrual = accrual;
+    }
+
+    public Boolean getSubmit() {
+        return submit;
+    }
+
+    public void setSubmit(Boolean submit) {
+        this.submit = submit;
+    }
+
+    public Boolean getHasAssignManagement() {
+        return hasAssignManagement;
+    }
+
+    public void setHasAssignManagement(Boolean hasAssignManagement) {
+        this.hasAssignManagement = hasAssignManagement;
+    }
+
+    public BigDecimal getManagementInterest() {
+        return managementInterest;
+    }
+
+    public void setManagementInterest(BigDecimal managementInterest) {
+        this.managementInterest = managementInterest;
+    }
+
+    public BigDecimal getManagementPrincipal() {
+        return managementPrincipal;
+    }
+
+    public void setManagementPrincipal(BigDecimal managementPrincipal) {
+        this.managementPrincipal = managementPrincipal;
     }
 }

+ 15 - 10
src/main/java/com/sunxung/factoring/service/ledger/impl/LedgerManagementServiceImpl.java

@@ -845,7 +845,7 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
             if (financingLoanInfo != null) {
                 oaOtherPaymentTradeVo.setCollectionAccountName(financingLoanInfo.getRepayAcctName());
                 oaOtherPaymentTradeVo.setCollectionAccount(financingLoanInfo.getRepayAcctNo());
-                oaOtherPaymentTradeVo.setCollectionBankName("");
+                oaOtherPaymentTradeVo.setCollectionBankName("苏商银行");
             }
         }
         HttpHeaders headers = new HttpHeaders();
@@ -1703,7 +1703,7 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
                 actualDate = ledgerDate;
             }
             //1.查看计划是否有逾期利息未分完的,存在先分逾期利息
-            if (goodsAssignVo.getHasAssignOverdueInterest()) {
+            if (goodsAssignVo.getHasAssignOverdueInterest() && assignAmount.compareTo(BigDecimal.ZERO) > 0) {
                 List<PaymentCollectionPlanFactoring> overdueInterestList = planFactoringList.stream()
                         .filter(f -> f.getAmountType().getCode().equals("overdue_interest"))
                         .sorted(Comparator.comparing(PaymentCollectionPlanFactoring::getPlanDate)).collect(Collectors.toList());
@@ -1721,7 +1721,7 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
                 }
             }
             //2.判断是否分配长银融资利息、管理费和本金
-            if (goodsAssignVo.getHasAssignInterest()) {
+            if (goodsAssignVo.getHasAssignInterest() && assignAmount.compareTo(BigDecimal.ZERO) > 0) {
                 //利息分配 取所有垫付标识的
                 if (goodsAssignVo.getHasAssignOverdueInterest()) {
                     List<PaymentCollectionPlanFactoring> interestList = planFactoringList.stream()
@@ -1803,12 +1803,16 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
                 }
 
                 if (assignAmount.compareTo(BigDecimal.ZERO) > 0) {
+                    //取所有有垫付标识的本金
+
+                    List<PaymentCollectionPlanFactoring> filterPrincipalFactoringList = principalFactoringList.stream().filter(p -> p.getAdvanceFlag().equals(1))
+                            .collect(Collectors.toList());
                     //分配完还有钱去分配本金
-                    if (CollectionUtil.isNotEmpty(principalFactoringList)) {
+                    if (CollectionUtil.isNotEmpty(filterPrincipalFactoringList)) {
                         //按计划日期升序排列
-                        Collections.sort(principalFactoringList, Comparator.comparing(PaymentCollectionPlanFactoring::getPlanDate));
+                        Collections.sort(filterPrincipalFactoringList, Comparator.comparing(PaymentCollectionPlanFactoring::getPlanDate));
                         Boolean flag = false;
-                        for (PaymentCollectionPlanFactoring planFactoring : principalFactoringList) {
+                        for (PaymentCollectionPlanFactoring planFactoring : filterPrincipalFactoringList) {
                             if (!PaymentCollectionPlanStatusDict.ChildEnum.COMPLETED.getCode().equals(planFactoring.getStatus().getCode()) &&
                                     !PaymentCollectionPlanStatusDict.ChildEnum.OVERDUE_COMPLETED.getCode().equals(planFactoring.getStatus().getCode())) {
                                 if (flag) {
@@ -1918,7 +1922,7 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
                 }
             }
             //3.判断是否分配资方本金和利息
-            if (goodsAssignVo.getHasAssignManagement()) {
+            if (goodsAssignVo.getHasAssignManagement() && assignAmount.compareTo(BigDecimal.ZERO) > 0) {
                 FinancingLoanInfo financingLoanInfo = getFinancingLoanInfoByAccountsReceivableId(goodsAssignVo.getSopAccountsReceivableId());
 
                 //调用苏商还款试算接口、查询资方剩余的本金和利息
@@ -1932,8 +1936,9 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
                         managementInterest = new BigDecimal(repayTrialResp.getRemandInt());
                         assignAmount = assignAmount.subtract(remandTotAmt);
                     } else if (assignAmount.compareTo(remandTotAmt) == -1) {
-                        //分配金额小于归还总额、重新调用还款试算接口
-                        repayTrialResp = repayTrialBySMB(financingLoanInfo, "3", assignAmount);
+                        //分配金额小于归还总额、重新调用还款试算接口 todo
+                        repayTrialResp = repayTrialBySMB(financingLoanInfo, "2", assignAmount);
+                        // repayTrialResp = repayTrialBySMB(financingLoanInfo, "3", assignAmount);
                         managementPrincipal = new BigDecimal(repayTrialResp.getRemandPrincipal());
                         managementInterest = new BigDecimal(repayTrialResp.getRemandInt());
                         assignAmount = assignAmount.subtract(remandTotAmt);
@@ -1988,7 +1993,7 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
         RepayTrial repayTrial = new RepayTrial();
         repayTrial.setDuebillNo(financingLoanInfo.getDueBillNo());
         repayTrial.setRepayKind(repayKind);
-        if ("3".equals(repayKind)) {
+        if ("3".equals(repayKind) || "2".equals(repayKind)) {
             repayTrial.setRepayAmt(assignAmount.toString());
             repayTrial.setPrePmtTp("2");
         }

+ 16 - 5
src/main/java/com/sunxung/factoring/web/smb/SmbApiController.java

@@ -7,11 +7,10 @@ import com.sunxung.factoring.entity.smb.SmbIndustry;
 import com.sunxung.factoring.entity.smb.SmbRefinancingInfo;
 import com.sunxung.factoring.entity.smb.vo.FinancingAdvancePaymentVo;
 import com.sunxung.factoring.service.smb.IFinancingAdvancePaymentInfoService;
+import com.sunxung.factoring.service.smbApi.api.SMBApiService;
+import com.sunxung.factoring.service.smbApi.resp.RepayPlanResp;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -26,6 +25,9 @@ public class SmbApiController {
     @Autowired
     private IFinancingAdvancePaymentInfoService financingAdvancePaymentInfoService;
 
+    @Autowired
+    private SMBApiService smbApiService;
+
     /**
      * 还款计划查询
      *
@@ -57,6 +59,15 @@ public class SmbApiController {
         return new ResponseJson(financingAdvancePaymentInfoService.repayPlanQuery(advancePaymentInfo));
     }
 
-
+    /**
+     * 还款计划查询
+     *
+     * @return
+     */
+    @GetMapping("/repayPlanQuery")
+    public ResponseJson repayPlanQuery(String openId, String duebillNo) {
+        RepayPlanResp repayPlanResp = smbApiService.repayPlanQuery(openId, duebillNo);
+        return new ResponseJson(repayPlanResp);
+    }
 
 }

+ 16 - 6
src/main/resources/data/update/smb0826.sql

@@ -22,15 +22,14 @@ ALTER TABLE `ledger_account_basic_info` ADD COLUMN `is_smb_financing` tinyint(1)
 ALTER TABLE `ledger_account_his_info` ADD COLUMN `is_smb_financing` tinyint(1) DEFAULT '0' COMMENT '是否苏商资方 1-是 0-否';
 
 
-ALTER TABLE `ledger_fund_goods_assign` ADD `has_assign_inkasso` tinyint(1) DEFAULT NULL COMMENT '是否分配长银融资利息/管理费/本金 1-是 0-否';
-ALTER TABLE `ledger_fund_goods_assign` ADD `inkasso_interest` decimal(17,2) DEFAULT '0.00' COMMENT '长银融资利息';
-ALTER TABLE `ledger_fund_goods_assign` ADD `inkasso_management_fee` decimal(17,2) DEFAULT '0.00' COMMENT '长银融资管理费';
-ALTER TABLE `ledger_fund_goods_assign` ADD `inkasso_principal` decimal(17,2) DEFAULT '0.00' COMMENT '长银融资本金';
+# ALTER TABLE `ledger_fund_goods_assign` ADD `has_assign_inkasso` tinyint(1) DEFAULT NULL COMMENT '是否分配长银融资利息/管理费/本金 1-是 0-否';
+# ALTER TABLE `ledger_fund_goods_assign` ADD `inkasso_interest` decimal(17,2) DEFAULT '0.00' COMMENT '长银融资利息';
+# ALTER TABLE `ledger_fund_goods_assign` ADD `inkasso_management_fee` decimal(17,2) DEFAULT '0.00' COMMENT '长银融资管理费';
+# ALTER TABLE `ledger_fund_goods_assign` ADD `inkasso_principal` decimal(17,2) DEFAULT '0.00' COMMENT '长银融资本金';
 ALTER TABLE `ledger_fund_goods_assign` ADD `has_assign_management` tinyint(1) DEFAULT NULL COMMENT '是否分配资方融资利息/本金 1-是 0-否';
 ALTER TABLE `ledger_fund_goods_assign` ADD `management_interest` decimal(17,2) DEFAULT '0.00' COMMENT '资方融资利息';
 ALTER TABLE `ledger_fund_goods_assign` ADD `management_principal` decimal(17,2) DEFAULT '0.00' COMMENT '资方融资本金';
 
-
 -- 资方放款信息
 DROP TABLE IF EXISTS `financing_loan_info`;
 CREATE TABLE `financing_loan_info` (
@@ -87,4 +86,15 @@ INSERT INTO `t_dictionary` ( `name`, `parentId`, `code`, `value`, `gradation`, `
 VALUES ('苏商银行主合同文件', 1349, 'sushangFirstContrat', NULL, 3, '2024-02-07 14:54:49', '2024-02-07 14:54:49');
 
 INSERT INTO `t_dictionary` ( `name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
-VALUES ('苏商银行担保合同文件', 1349, 'sushangGuaranteeContrat', NULL, 3, '2024-02-07 14:54:49', '2024-02-07 14:54:49');
+VALUES ('苏商银行担保合同文件', 1349, 'sushangGuaranteeContrat', NULL, 3, '2024-02-07 14:54:49', '2024-02-07 14:54:49');
+
+ALTER TABLE `ledger_fund_goods_assign_his` ADD `has_assign_management` tinyint(1) DEFAULT NULL COMMENT '是否分配资方融资利息/本金 1-是 0-否';
+ALTER TABLE `ledger_fund_goods_assign_his` ADD `management_interest` decimal(17,2) DEFAULT '0.00' COMMENT '资方融资利息';
+ALTER TABLE `ledger_fund_goods_assign_his` ADD `management_principal` decimal(17,2) DEFAULT '0.00' COMMENT '资方融资本金';
+
+INSERT INTO `t_dictionary`(`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
+VALUES ('应退利息',(select id from t_dictionary p where p.code = 'cashFlowOutType'), 'refundInterest', NULL, 11, NULL, NULL);
+INSERT INTO `t_dictionary`(`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
+VALUES ('应退管理费',(select id from t_dictionary p where p.code = 'cashFlowOutType'), 'refundManagementFee', NULL, 12, NULL, NULL);
+INSERT INTO `t_dictionary`(`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
+VALUES ('资方融资款项',(select id from t_dictionary p where p.code = 'cashFlowOutType'), 'outType_management_amount', NULL, 13, NULL, NULL);