Browse Source

分账优化

liuj 6 months ago
parent
commit
92338cc2d2

+ 12 - 6
src/main/java/com/sunxung/factoring/service/ledger/impl/LedgerManagementServiceImpl.java

@@ -1368,7 +1368,13 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
                                 }
                                 }
                                 //增加一笔剩余利息计划
                                 //增加一笔剩余利息计划
                                 //计算剩余应收利息
                                 //计算剩余应收利息
-                                BigDecimal calculateInterest = calculateAssignInterest(returnedAmount, ledgerDate, lastPlanDate,
+                                Date actualDate;
+                                if (assignOverdueInterest) {
+                                    actualDate = new Date();
+                                }else {
+                                    actualDate = ledgerDate;
+                                }
+                                BigDecimal calculateInterest = calculateAssignInterest(returnedAmount, actualDate, lastPlanDate,
                                         !hasPrincipalAssign, paymentCalculateVo, IncomeExpenditureTypeDict.ChildEnum.INTEREST.getCode());
                                         !hasPrincipalAssign, paymentCalculateVo, IncomeExpenditureTypeDict.ChildEnum.INTEREST.getCode());
                                 BigDecimal surplusInterest = calculateInterest.add(unAssignInterest);
                                 BigDecimal surplusInterest = calculateInterest.add(unAssignInterest);
                                 if (surplusInterest.compareTo(new BigDecimal("0.5")) <= 0 && surplusInterest.compareTo(new BigDecimal("-0.5")) >= 0) {
                                 if (surplusInterest.compareTo(new BigDecimal("0.5")) <= 0 && surplusInterest.compareTo(new BigDecimal("-0.5")) >= 0) {
@@ -1379,13 +1385,13 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
                                 if (surplusInterest.compareTo(BigDecimal.ZERO) < 0) {
                                 if (surplusInterest.compareTo(BigDecimal.ZERO) < 0) {
                                     refundInterest = surplusInterest.negate();
                                     refundInterest = surplusInterest.negate();
 
 
-                                    ledgerPlanFactoringAssignList.add(addPlanFactoringInsertAssign(ledgerDate, surplusInterest, BigDecimal.ZERO,
+                                    ledgerPlanFactoringAssignList.add(addPlanFactoringInsertAssign(actualDate, surplusInterest, BigDecimal.ZERO,
                                             IncomeExpenditureTypeDict.ChildEnum.INTEREST.getCode(), goodsAssignVo, 0));
                                             IncomeExpenditureTypeDict.ChildEnum.INTEREST.getCode(), goodsAssignVo, 0));
                                 }
                                 }
                                 if (surplusInterest.compareTo(BigDecimal.ZERO) > 0) {
                                 if (surplusInterest.compareTo(BigDecimal.ZERO) > 0) {
                                     PaymentCollectionPlanFactoring lastInterestFactoring = getLastPrincipalFactoring(allPlanFactoringList, interestDict, lastPlanDate);
                                     PaymentCollectionPlanFactoring lastInterestFactoring = getLastPrincipalFactoring(allPlanFactoringList, interestDict, lastPlanDate);
                                     if (lastInterestFactoring == null) {
                                     if (lastInterestFactoring == null) {
-                                        ledgerPlanFactoringAssignList.add(addPlanFactoringInsertAssign(ledgerDate, surplusInterest, BigDecimal.ZERO,
+                                        ledgerPlanFactoringAssignList.add(addPlanFactoringInsertAssign(actualDate, surplusInterest, BigDecimal.ZERO,
                                                 IncomeExpenditureTypeDict.ChildEnum.INTEREST.getCode(), goodsAssignVo, 0));
                                                 IncomeExpenditureTypeDict.ChildEnum.INTEREST.getCode(), goodsAssignVo, 0));
                                     } else {
                                     } else {
                                         //可能存在计划已经在之前的判断中被删除的情况,所以需要再判断一次
                                         //可能存在计划已经在之前的判断中被删除的情况,所以需要再判断一次
@@ -1406,7 +1412,7 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
                                 }
                                 }
                                 //增加一笔剩余管理费计划
                                 //增加一笔剩余管理费计划
                                 //计算剩余应收管理费
                                 //计算剩余应收管理费
-                                BigDecimal calculateManagementFee = calculateAssignInterest(returnedAmount, ledgerDate, lastPlanDate,
+                                BigDecimal calculateManagementFee = calculateAssignInterest(returnedAmount, actualDate, lastPlanDate,
                                         !hasPrincipalAssign, paymentCalculateVo, IncomeExpenditureTypeDict.ChildEnum.MANAGEMENT_FEE.getCode());
                                         !hasPrincipalAssign, paymentCalculateVo, IncomeExpenditureTypeDict.ChildEnum.MANAGEMENT_FEE.getCode());
                                 BigDecimal surplusManagement = calculateManagementFee.add(unAssignManagement);
                                 BigDecimal surplusManagement = calculateManagementFee.add(unAssignManagement);
                                 if (surplusManagement.compareTo(new BigDecimal("0.5")) <= 0 && surplusManagement.compareTo(new BigDecimal("-0.5")) >= 0) {
                                 if (surplusManagement.compareTo(new BigDecimal("0.5")) <= 0 && surplusManagement.compareTo(new BigDecimal("-0.5")) >= 0) {
@@ -1417,14 +1423,14 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
                                 if (surplusManagement.compareTo(BigDecimal.ZERO) < 0) {
                                 if (surplusManagement.compareTo(BigDecimal.ZERO) < 0) {
                                     refundManagement = surplusManagement.negate();
                                     refundManagement = surplusManagement.negate();
 
 
-                                    ledgerPlanFactoringAssignList.add(addPlanFactoringInsertAssign(ledgerDate, surplusManagement, BigDecimal.ZERO,
+                                    ledgerPlanFactoringAssignList.add(addPlanFactoringInsertAssign(actualDate, surplusManagement, BigDecimal.ZERO,
                                             IncomeExpenditureTypeDict.ChildEnum.MANAGEMENT_FEE.getCode(), goodsAssignVo, 0));
                                             IncomeExpenditureTypeDict.ChildEnum.MANAGEMENT_FEE.getCode(), goodsAssignVo, 0));
                                 }
                                 }
                                 if (surplusManagement.compareTo(BigDecimal.ZERO) > 0) {
                                 if (surplusManagement.compareTo(BigDecimal.ZERO) > 0) {
                                     PaymentCollectionPlanFactoring lastManagementFactoring = getLastPrincipalFactoring(allPlanFactoringList, managementFeeDict, lastPlanDate);
                                     PaymentCollectionPlanFactoring lastManagementFactoring = getLastPrincipalFactoring(allPlanFactoringList, managementFeeDict, lastPlanDate);
                                     //可能存在计划已经在之前的判断中被删除的情况,所以需要再判断一次
                                     //可能存在计划已经在之前的判断中被删除的情况,所以需要再判断一次
                                     if (lastManagementFactoring == null) {
                                     if (lastManagementFactoring == null) {
-                                        ledgerPlanFactoringAssignList.add(addPlanFactoringInsertAssign(ledgerDate, surplusManagement, BigDecimal.ZERO,
+                                        ledgerPlanFactoringAssignList.add(addPlanFactoringInsertAssign(actualDate, surplusManagement, BigDecimal.ZERO,
                                                 IncomeExpenditureTypeDict.ChildEnum.MANAGEMENT_FEE.getCode(), goodsAssignVo, 0));
                                                 IncomeExpenditureTypeDict.ChildEnum.MANAGEMENT_FEE.getCode(), goodsAssignVo, 0));
                                     } else {
                                     } else {
                                         //可能存在计划已经在之前的判断中被删除的情况,所以需要再判断一次
                                         //可能存在计划已经在之前的判断中被删除的情况,所以需要再判断一次

+ 1 - 1
src/test/java/com/sunxung/factoring/generator/MpCodeGenerator.java

@@ -31,7 +31,7 @@ public class MpCodeGenerator {
     //author
     //author
     public static final String author = "liutao";
     public static final String author = "liutao";
     //database
     //database
-    public static final String databaseUrl = "jdbc:mysql://192.168.3.6:3106/factoring_trade_v4?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true";
+    public static final String databaseUrl = "jdbc:mysql://192.168.3.5:3306/factoring_trade_v4?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true";
     public static final String driverName = "com.mysql.jdbc.Driver";
     public static final String driverName = "com.mysql.jdbc.Driver";
     public static final String userName = "root";
     public static final String userName = "root";
     public static final String password = "root";
     public static final String password = "root";