Parcourir la source

融资申请优化

liuj il y a 6 mois
Parent
commit
ce76193dcb

+ 29 - 16
src/main/java/com/sunxung/factoring/service/financing/apply/impl/FinancingApplyServiceImpl.java

@@ -10,7 +10,6 @@ import com.sunxung.factoring.component.exception.BusinessException;
 import com.sunxung.factoring.component.exception.ValidatorException;
 import com.sunxung.factoring.component.util.*;
 import com.sunxung.factoring.dict.impl.FileModuleDict;
-import com.sunxung.factoring.entity.ResponseJson;
 import com.sunxung.factoring.entity.creditresolution.CreditResolution;
 import com.sunxung.factoring.entity.entprise.Enterprise;
 import com.sunxung.factoring.entity.financing.apply.*;
@@ -648,6 +647,8 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
                 if (reviewQuotaDisburse.getPlanIrr() != null) {
                     reviewQuotaDisburse.setPlanIrrStr(PercentageUtil.convertPercentage(reviewQuotaDisburse.getPlanIrr().doubleValue()));
                 }
+                //填充业务综合授信余额和供应商授信余额
+                autoBalance(financingBasicInfo, reviewQuotaDisburse);
                 //填充主合同信息
                 autoMasterContractInfo(reviewQuotaDisburse);
                 //填充融资信息
@@ -671,23 +672,9 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
     private void initQuotaDisburse(CFinancingBasicInfo financingBasicInfo, BigDecimal
             netAccountsReceivableAmountTotal, ReviewQuotaDisburse reviewQuotaDisburse) {
         reviewQuotaDisburse.setFinancingBasicInfoId(financingBasicInfo.getId());
-        //计算业务占用的授信金额
-        BigDecimal businessOccupyAmount = getBusinessOccupyAmount(financingBasicInfo);
-        //计算供应商占用的授信金额
-        BigDecimal supplierOccupyAmount = getSupplierOccupyAmount(financingBasicInfo);
-        //计算业务综合授信余额和供应商授信余额
-        ProjectInformation projectInformation = projectInformationService.getOne(new QueryWrapper<ProjectInformation>()
-                .eq("business_number", financingBasicInfo.getBusinessNumber()));
-        if (projectInformation == null) {
-            throw new BusinessException(CodeUtil.FAIL, "根据业务编号获取不到对应项目信息");
-        }
+        autoBalance(financingBasicInfo, reviewQuotaDisburse);
 
-        CreditResolution creditResolution = creditResolutionService.getByProjectInformationId(projectInformation.getId());
         reviewQuotaDisburse.setBusinessNumber(financingBasicInfo.getBusinessNumber());
-        reviewQuotaDisburse.setBusinessCreditBalance(creditResolution.getProposedCreditLine().subtract(businessOccupyAmount));
-
-        SupplierInfo supplierInfo = supplierInfoService.get(projectInformation.getcSupplierInfoId());
-        reviewQuotaDisburse.setSupplierCreditBalance(supplierInfo.getCreditLimit().multiply(new BigDecimal("10000")).subtract(supplierOccupyAmount));
         reviewQuotaDisburse.setAccountsReceivableNetAmountTotal(netAccountsReceivableAmountTotal);
 
         //融资信息
@@ -771,6 +758,32 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
         reviewQuotaDisburse.setReviewBasicContractList(Arrays.asList(reviewBasicContract));
     }
 
+    /**
+     * 填充业务综合授信余额和供应商综合授信余额
+     *
+     * @param financingBasicInfo
+     * @param reviewQuotaDisburse
+     */
+    private void autoBalance(CFinancingBasicInfo financingBasicInfo, ReviewQuotaDisburse reviewQuotaDisburse) {
+        //计算业务占用的授信金额
+        BigDecimal businessOccupyAmount = getBusinessOccupyAmount(financingBasicInfo);
+        //计算供应商占用的授信金额
+        BigDecimal supplierOccupyAmount = getSupplierOccupyAmount(financingBasicInfo);
+        //计算业务综合授信余额和供应商授信余额
+        ProjectInformation projectInformation = projectInformationService.getOne(new QueryWrapper<ProjectInformation>()
+                .eq("business_number", financingBasicInfo.getBusinessNumber()));
+        if (projectInformation == null) {
+            throw new BusinessException(CodeUtil.FAIL, "根据业务编号获取不到对应项目信息");
+        }
+
+        CreditResolution creditResolution = creditResolutionService.getByProjectInformationId(projectInformation.getId());
+
+        reviewQuotaDisburse.setBusinessCreditBalance(creditResolution.getProposedCreditLine().subtract(businessOccupyAmount));
+
+        SupplierInfo supplierInfo = supplierInfoService.get(projectInformation.getcSupplierInfoId());
+        reviewQuotaDisburse.setSupplierCreditBalance(supplierInfo.getCreditLimit().multiply(new BigDecimal("10000")).subtract(supplierOccupyAmount));
+    }
+
     /**
      * 填充主合同信息
      *