ソースを参照

分账逻辑优化

liuj 6 ヶ月 前
コミット
cb5c3e96f7
共有1 個のファイルを変更した10 個の追加8 個の削除を含む
  1. 10 8
      src/main/java/com/sunxung/factoring/service/ledger/impl/LedgerManagementServiceImpl.java

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

@@ -1170,7 +1170,7 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
 
                             Boolean assignOverdueInterest = hasAssignOverdueInterest(allPlanFactoringList, goodsAssignVo.getHasAssignOverdueInterest());
                             //5.获取截至到分账日期的新的本金计划
-                            List<PaymentCollectionPlanFactoring> newPrincipalFactoringList = new ArrayList<>();
+                            List<PaymentCollectionPlanFactoring> newPrincipalFactoringList;
                             if (assignOverdueInterest) {
                                 //判断是否存在逾期利息不豁免且需要分逾期利息的场景,如果存在分账日期取系统当前日期
                                 newPrincipalFactoringList = getPrincipalFactoringByLedgerDate(principalFactoringList, new Date(), returnedAmount);
@@ -1179,10 +1179,10 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
                             }
                             //6.计算截至到分账日期计划应收管理费总和
                             BigDecimal planManagementTotal = getAllocatedAmountByPlanFactoring(newPrincipalFactoringList, managementFeeDict,
-                                    goodsAssignVo, paymentCalculateVo);
+                                    goodsAssignVo, paymentCalculateVo, ledgerDate);
                             //7.计算截至到分账日期计划应收利息总和
                             BigDecimal planInterestTotal = getAllocatedAmountByPlanFactoring(newPrincipalFactoringList, interestDict,
-                                    goodsAssignVo, paymentCalculateVo);
+                                    goodsAssignVo, paymentCalculateVo, ledgerDate);
                             //剩余未分配管理费
                             BigDecimal unAssignManagement = BigDecimal.ZERO;
                             //剩余未分配利息
@@ -2301,7 +2301,7 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
      * @return
      */
     private BigDecimal getAllocatedAmountByPlanFactoring(List<PaymentCollectionPlanFactoring> principalList, Dictionary dict,
-                                                         LedgerFundGoodsAssign goodsAssign, PrePaymentCalculateVo paymentCalculateVo) {
+                                                         LedgerFundGoodsAssign goodsAssign, PrePaymentCalculateVo paymentCalculateVo, Date ledgerDate) {
         //计算需要分配掉的利息或管理费
         if (principalList == null || principalList.isEmpty()) {
             return BigDecimal.ZERO;
@@ -2323,10 +2323,12 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
                     newPrincipalList.add(factoring);
                 });
             } else {
-                PaymentCollectionPlanFactoring factoring = new PaymentCollectionPlanFactoring();
-                factoring.setPlanDate(p.getPlanDate());
-                factoring.setAmount(p.getAmount());
-                newPrincipalList.add(factoring);
+                if (p.getPlanDate().compareTo(ledgerDate) == 0) {
+                    PaymentCollectionPlanFactoring factoring = new PaymentCollectionPlanFactoring();
+                    factoring.setPlanDate(p.getPlanDate());
+                    factoring.setAmount(p.getAmount());
+                    newPrincipalList.add(factoring);
+                }
             }
         });