Browse Source

feat(合同制作):金额保留两位小数

Wangyafan 5 months ago
parent
commit
7cfec18d74

+ 35 - 35
src/main/java/com/sunxung/factoring/service/financing/contract/impl/NewContractMakingServiceImpl.java

@@ -221,7 +221,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
             // 融资金额
             BigDecimal financingAmount = new BigDecimal(0.00);
             if (null != contractFinancingInfo && null != contractFinancingInfo.getFinancingAmount()) {
-                financingAmount = contractFinancingInfo.getFinancingAmount().setScale(2,RoundingMode.HALF_UP);
+                financingAmount = contractFinancingInfo.getFinancingAmount().setScale(2,BigDecimal.ROUND_HALF_UP);
             }
             // 币种中文名称
             String currency_cn = "人民币";
@@ -285,7 +285,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     // 授信金额
                     BigDecimal creditLine = new BigDecimal(0.00);
                     if (null != creditResolution && null != creditResolution.getProposedCreditLine()) {
-                        creditLine = creditResolution.getProposedCreditLine().setScale(2,RoundingMode.HALF_UP);
+                        creditLine = creditResolution.getProposedCreditLine().setScale(2,BigDecimal.ROUND_HALF_UP);
                     }
                     if (creditLine != null) {
                         amountCname = MoneyToCNFormatUtil
@@ -403,7 +403,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                 String loanBalanceStr = "";
                                 BigDecimal loanBalance = estate.getLoanBalance();
                                 if (null != loanBalance) {
-                                    loanBalance = loanBalance.setScale(2,RoundingMode.HALF_UP);
+                                    loanBalance = loanBalance.setScale(2,BigDecimal.ROUND_HALF_UP);
                                     loanBalanceStr = NumberFormatUtil.convertDecimal(loanBalance,
                                             NumberFormatUtil.THOUSAND_SEPARATOR_TWO_DECIMAL) + "元";
                                 }
@@ -444,7 +444,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                 String loanBalanceStr = "";
                                 BigDecimal loanBalance = vehicle.getLoanBalance();
                                 if (null != loanBalance) {
-                                    loanBalance = loanBalance.setScale(2,RoundingMode.HALF_UP);
+                                    loanBalance = loanBalance.setScale(2,BigDecimal.ROUND_HALF_UP);
                                     loanBalanceStr = NumberFormatUtil.convertDecimal(loanBalance,
                                             NumberFormatUtil.THOUSAND_SEPARATOR_TWO_DECIMAL) + "元";
                                 }
@@ -466,7 +466,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                 String registeredCapitalStr = "";
                                 BigDecimal registeredCapital = equityAssets.getRegisteredCapital();
                                 if (null != registeredCapital) {
-                                    registeredCapital = registeredCapital.setScale(2,RoundingMode.HALF_UP);
+                                    registeredCapital = registeredCapital.setScale(2,BigDecimal.ROUND_HALF_UP);
                                     registeredCapitalStr = NumberFormatUtil.convertDecimal(registeredCapital,
                                             NumberFormatUtil.THOUSAND_SEPARATOR_TWO_DECIMAL) + "元";
                                 }
@@ -483,7 +483,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                 String investmentAmountStr = "";
                                 BigDecimal investmentAmount = equityAssets.getInvestmentAmount();
                                 if (null != investmentAmount) {
-                                    investmentAmount = investmentAmount.setScale(2,RoundingMode.HALF_UP);
+                                    investmentAmount = investmentAmount.setScale(2,BigDecimal.ROUND_HALF_UP);
                                     investmentAmountStr = NumberFormatUtil.convertDecimal(investmentAmount,
                                             NumberFormatUtil.THOUSAND_SEPARATOR_TWO_DECIMAL) + "元";
                                 }
@@ -627,7 +627,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                 String loanBalanceStr = "";
                                 BigDecimal loanBalance = vehicle.getLoanBalance();
                                 if (null != loanBalance) {
-                                    loanBalance = loanBalance.setScale(2,RoundingMode.HALF_UP);
+                                    loanBalance = loanBalance.setScale(2,BigDecimal.ROUND_HALF_UP);
                                     loanBalanceStr = NumberFormatUtil.convertDecimal(loanBalance,
                                             NumberFormatUtil.THOUSAND_SEPARATOR_TWO_DECIMAL) + "元";
                                 }
@@ -649,7 +649,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                 String registeredCapitalStr = "";
                                 BigDecimal registeredCapital = equityAssets.getRegisteredCapital();
                                 if (null != registeredCapital) {
-                                    registeredCapital = registeredCapital.setScale(2,RoundingMode.HALF_UP);
+                                    registeredCapital = registeredCapital.setScale(2,BigDecimal.ROUND_HALF_UP);
                                     registeredCapitalStr = NumberFormatUtil.convertDecimal(registeredCapital,
                                             NumberFormatUtil.THOUSAND_SEPARATOR_TWO_DECIMAL) + "元";
                                 }
@@ -667,7 +667,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                 String investmentAmountStr = "";
                                 BigDecimal investmentAmount = equityAssets.getInvestmentAmount();
                                 if (null != investmentAmount) {
-                                    investmentAmount = investmentAmount.setScale(2,RoundingMode.HALF_UP);
+                                    investmentAmount = investmentAmount.setScale(2,BigDecimal.ROUND_HALF_UP);
                                     investmentAmountStr = NumberFormatUtil.convertDecimal(investmentAmount,
                                             NumberFormatUtil.THOUSAND_SEPARATOR_TWO_DECIMAL) + "元";
                                 }
@@ -871,7 +871,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     // 融资金额中文
                     String financingAmount_cn = "";
                     if (null != financingAmount && StringUtil.isNotEmpty(currency_cn)) {
-                        financingAmount = financingAmount.setScale(2,RoundingMode.HALF_UP);
+                        financingAmount = financingAmount.setScale(2,BigDecimal.ROUND_HALF_UP);
                         financingAmount_cn = MoneyToCNFormatUtil.formatToCN(financingAmount.doubleValue());
                     }
                     // 融资金额英文
@@ -996,7 +996,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     map.put("day", DateUtil.getDay(date));
                     String financingAmountCname = "";
                     if (null != financingInfo.getFinancingAmount()) {
-                        financingAmount = financingInfo.getFinancingAmount().setScale(2,RoundingMode.HALF_UP);
+                        financingAmount = financingInfo.getFinancingAmount().setScale(2,BigDecimal.ROUND_HALF_UP);
                         financingAmountCname = MoneyToCNFormatUtil
                                 .formatToCN(financingInfo.getFinancingAmount().doubleValue());
                     }
@@ -1045,9 +1045,9 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
             String creditLineCname = "";
             String creditLine = "";
             if (null != creditResolution.getProposedCreditLine()) {
-                creditLine = creditResolution.getProposedCreditLine().setScale(2,RoundingMode.HALF_UP).toString();
+                creditLine = creditResolution.getProposedCreditLine().setScale(2,BigDecimal.ROUND_HALF_UP).toString();
                 creditLineCname = MoneyToCNFormatUtil
-                        .formatToCN(creditResolution.getProposedCreditLine().setScale(2,RoundingMode.HALF_UP).doubleValue());
+                        .formatToCN(creditResolution.getProposedCreditLine().setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
             }
             // 合同名称
             String contractName = masterContract.getContractName();
@@ -1139,7 +1139,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     String amountEname = "";
                     String amountCname = "";
                     if (financingAmount != null) {
-                        financingAmount = financingAmount.setScale(2,RoundingMode.HALF_UP);
+                        financingAmount = financingAmount.setScale(2,BigDecimal.ROUND_HALF_UP);
                         amountCname = MoneyToCNFormatUtil.formatToCN(financingAmount.doubleValue());
                         amountEname = financingAmount + "元";
                     }
@@ -1234,7 +1234,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
             // 融资金额
             BigDecimal financingAmount = null;
             if (null != contractFinancingInfo && null != contractFinancingInfo.getFinancingAmount()) {
-                financingAmount = contractFinancingInfo.getFinancingAmount().setScale(2,RoundingMode.HALF_UP);
+                financingAmount = contractFinancingInfo.getFinancingAmount().setScale(2,BigDecimal.ROUND_HALF_UP);
             }
             ReviewRltRepay rltRepay = reviewRltRepayService.getById(reviewRltRepayId);
             //社会统一信用代码/身份证号码
@@ -1351,16 +1351,16 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     .eq("review_quota_disburse_id", contractInfo.getReviewQuotaDisburseId()));
             if (null != financingInfo) {
                 //融资利息
-                BigDecimal financingInterest = financingInfo.getFinancingInterest().setScale(2,RoundingMode.HALF_UP);
+                BigDecimal financingInterest = financingInfo.getFinancingInterest().setScale(2,BigDecimal.ROUND_HALF_UP);
                 //融资金额
-                BigDecimal financingAmount = financingInfo.getFinancingAmount().setScale(2,RoundingMode.HALF_UP);
+                BigDecimal financingAmount = financingInfo.getFinancingAmount().setScale(2,BigDecimal.ROUND_HALF_UP);
                 BigDecimal financingTotal = new BigDecimal(0.00);
                 financingTotal = financingTotal
-                        .add(null == financingAmount ? new BigDecimal(0.00) : financingAmount.setScale(2,RoundingMode.HALF_UP))
-                        .add(null == financingInterest ? new BigDecimal(0.00) : financingInterest.setScale(2,RoundingMode.HALF_UP));
+                        .add(null == financingAmount ? new BigDecimal(0.00) : financingAmount.setScale(2,BigDecimal.ROUND_HALF_UP))
+                        .add(null == financingInterest ? new BigDecimal(0.00) : financingInterest.setScale(2,BigDecimal.ROUND_HALF_UP));
                 map.put("financingTotal", financingTotal);
                 BigDecimal managementFeeAmount = financingInfo.getManagementFeeAmount();
-                map.put("managementFeeAmount", managementFeeAmount == null ? new BigDecimal(0.00) : managementFeeAmount.setScale(2,RoundingMode.HALF_UP));
+                map.put("managementFeeAmount", managementFeeAmount == null ? new BigDecimal(0.00) : managementFeeAmount.setScale(2,BigDecimal.ROUND_HALF_UP));
             }
             // 保理合同编号
             String factoringContractNo = masterContract.getContractNo();
@@ -1949,7 +1949,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     // 融资利息
                     financingInterest = financingInfo.getFinancingInterest();
                     if (null != financingInterest) {
-                        financingInterest = financingInterest.setScale(2,RoundingMode.HALF_UP);
+                        financingInterest = financingInterest.setScale(2,BigDecimal.ROUND_HALF_UP);
                         financingInterestName = MoneyToCNFormatUtil.formatToCN(financingInterest.doubleValue());
                     }
                     // 支付方式
@@ -1971,7 +1971,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     manageFeeRate = StringUtil.subZeroAndDot(PercentageUtil.convertPercentage(financingInfo.getManagementFeeRatio().doubleValue()).split("%")[0] + "%");
                     // 管理费金额大写
                     if (null != manageFeeAmount) {
-                        manageFeeAmount = manageFeeAmount.setScale(2,RoundingMode.HALF_UP);
+                        manageFeeAmount = manageFeeAmount.setScale(2,BigDecimal.ROUND_HALF_UP);
                         manageFeeAmountName = MoneyToCNFormatUtil.formatToCN(manageFeeAmount.doubleValue());
                     }
                     //管理费支付方式
@@ -1982,7 +1982,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     otherFeeCollectionMethod = contractFinancingInfo.getOtherFeeCollectionMethod();
                     // 其他费用金额大写
                     if (null != otherFee) {
-                        otherFee = otherFee.setScale(2,RoundingMode.HALF_UP);
+                        otherFee = otherFee.setScale(2,BigDecimal.ROUND_HALF_UP);
                         otherFeeName = MoneyToCNFormatUtil.formatToCN(otherFee.doubleValue());
                     }
                     // 信用风险担保金额
@@ -2006,7 +2006,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     transferNoticeMethodId = transferNoticeMethodId.trim();
                 }
                 if (null != financingAmmount) {
-                    financingAmmount = financingAmmount.setScale(2,RoundingMode.HALF_UP);
+                    financingAmmount = financingAmmount.setScale(2,BigDecimal.ROUND_HALF_UP);
                     financingAmmountCname = MoneyToCNFormatUtil.formatToCN(financingAmmount.doubleValue());
                 }
                 // 提款条件
@@ -2084,14 +2084,14 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                         // 金额合计
                         amountTotal = loanConditionList.stream().filter(e -> {
                                     if (null != e.getAmount()) {
-                                        e.setAmount(e.getAmount().setScale(2,RoundingMode.HALF_UP));
+                                        e.setAmount(e.getAmount().setScale(2,BigDecimal.ROUND_HALF_UP));
                                     }
                                     return null != e.getAmount();
                                 })
                                 .map(ReviewLoanCondition::getAmount)
                                 .reduce(new BigDecimal(0.00), BigDecimal::add);
                         if (null != amountTotal) {
-                            amountTotal = amountTotal.setScale(2,RoundingMode.HALF_UP);
+                            amountTotal = amountTotal.setScale(2,BigDecimal.ROUND_HALF_UP);
                             amountTotalName = MoneyToCNFormatUtil.formatToCN(amountTotal.doubleValue());
                         }
                         map.put("fixedConditionNo", fixedConditionNo);
@@ -2145,10 +2145,10 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                 map3.put("receivableType", "货款");
                 //计算应收账款金融
                 BigDecimal accountsReceivableAmount = calculateAccountsReceivableAmount(reviewQuotaDisburse.getFinancingBasicInfoId());
-                map3.put("receivableAmount", null == accountsReceivableAmount ? new BigDecimal(0.00) : accountsReceivableAmount.setScale(2,RoundingMode.HALF_UP));
+                map3.put("receivableAmount", null == accountsReceivableAmount ? new BigDecimal(0.00) : accountsReceivableAmount.setScale(2,BigDecimal.ROUND_HALF_UP));
                 BigDecimal accountsReceivableNetAmountTotal = reviewQuotaDisburse.getAccountsReceivableNetAmountTotal();
                 map3.put("receivableNetAmount",
-                        accountsReceivableNetAmountTotal == null ? new BigDecimal(0.00) : accountsReceivableNetAmountTotal.setScale(2,RoundingMode.HALF_UP));
+                        accountsReceivableNetAmountTotal == null ? new BigDecimal(0.00) : accountsReceivableNetAmountTotal.setScale(2,BigDecimal.ROUND_HALF_UP));
                 if (null != reviewQuotaDisburse.getTerm()) {
                     map3.put("term", reviewQuotaDisburse.getTerm());
                 }
@@ -2184,7 +2184,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     creditLine = creditResolution.getProposedCreditLine();
                     creditBalance = reviewQuotaDisburse.getBusinessCreditBalance();
                     if (null != creditBalance) {
-                        creditBalance = creditBalance.setScale(2,RoundingMode.HALF_UP);
+                        creditBalance = creditBalance.setScale(2,BigDecimal.ROUND_HALF_UP);
                         if (creditBalance.compareTo(BigDecimal.ZERO) == -1) {
                             creditBalanceName = MoneyToCNFormatUtil.formatToCN(creditBalance.abs().doubleValue());
                             creditBalanceName = "负" + creditBalanceName;
@@ -2194,7 +2194,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     }
                     // 授信金额中文
                     if (null != creditLine) {
-                        creditLine = creditLine.setScale(2,RoundingMode.HALF_UP);
+                        creditLine = creditLine.setScale(2,BigDecimal.ROUND_HALF_UP);
                         creditLineName = MoneyToCNFormatUtil.formatToCN(creditLine.doubleValue());
                     }
                     // 授信期限
@@ -2389,7 +2389,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
             accountsReceivableAmount = informationList.stream()
                     .filter(accountsReceivable -> {
                         if (null != accountsReceivable.getAccountsReceivableAmount()) {
-                            accountsReceivable.setAccountsReceivableAmount(accountsReceivable.getAccountsReceivableAmount().setScale(2, RoundingMode.HALF_UP));
+                            accountsReceivable.setAccountsReceivableAmount(accountsReceivable.getAccountsReceivableAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
                         }
                         return null != accountsReceivable.getAccountsReceivableAmount();
                     })
@@ -2555,9 +2555,9 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                 }
                 noticeMap.put("financingRateStr", financingRateStr);
                 BigDecimal financingAmmount = financingInfo.getFinancingAmount() == null ?
-                        new BigDecimal(0.00) : financingInfo.getFinancingAmount().setScale(2,RoundingMode.HALF_UP);
+                        new BigDecimal(0.00) : financingInfo.getFinancingAmount().setScale(2,BigDecimal.ROUND_HALF_UP);
                 financingAmountInterest = financingAmmount
-                        .add(financingInfo.getFinancingInterest() == null ? new BigDecimal(0.00) : financingInfo.getFinancingInterest().setScale(2,RoundingMode.HALF_UP));
+                        .add(financingInfo.getFinancingInterest() == null ? new BigDecimal(0.00) : financingInfo.getFinancingInterest().setScale(2,BigDecimal.ROUND_HALF_UP));
                 noticeMap.put("financingAmountInterest", financingAmountInterest);
                 Map<Long, List<Map<String, Object>>> groupingByMap = new HashMap<>();
 
@@ -2604,7 +2604,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                 noticeMap.put("changeList", changeList);
                 noticeMap.put("receivableAmountAll", accountsReceivableAmount);
                 if (null != invoiceAmmountAll) {
-                    noticeMap.put("invoiceAmmountAll", invoiceAmmountAll.setScale(2,RoundingMode.HALF_UP));
+                    noticeMap.put("invoiceAmmountAll", invoiceAmmountAll.setScale(2,BigDecimal.ROUND_HALF_UP));
                 } else {
                     noticeMap.put("invoiceAmmountAll", "");
                 }
@@ -2730,7 +2730,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                             .add(financingAmmount
                                     .multiply(new BigDecimal("0.12").subtract(financingInfo.getManagementFeeRatio()))
                                     .divide(new BigDecimal("360"), 8, BigDecimal.ROUND_HALF_UP).multiply(financingDays));
-                    BigDecimal balance = balanceLong.setScale(2,RoundingMode.HALF_UP);
+                    BigDecimal balance = balanceLong.setScale(2,BigDecimal.ROUND_HALF_UP);
                     confirmMap.put("balance", balance);
                 } else {
                     confirmMap.put("balance", BigDecimal.ZERO);