|
@@ -5,12 +5,11 @@ import cn.hutool.json.JSONUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.sunxung.factoring.component.enums.FileTypeEnum;
|
|
import com.sunxung.factoring.component.enums.FileTypeEnum;
|
|
import com.sunxung.factoring.component.enums.FinancingCurrentStageEnum;
|
|
import com.sunxung.factoring.component.enums.FinancingCurrentStageEnum;
|
|
-import com.sunxung.factoring.component.enums.FinancingStatusEnum;
|
|
|
|
import com.sunxung.factoring.component.exception.BusinessException;
|
|
import com.sunxung.factoring.component.exception.BusinessException;
|
|
import com.sunxung.factoring.component.exception.ValidatorException;
|
|
import com.sunxung.factoring.component.exception.ValidatorException;
|
|
import com.sunxung.factoring.component.util.*;
|
|
import com.sunxung.factoring.component.util.*;
|
|
import com.sunxung.factoring.dict.impl.FileModuleDict;
|
|
import com.sunxung.factoring.dict.impl.FileModuleDict;
|
|
-import com.sunxung.factoring.entity.ResponseJson;
|
|
|
|
|
|
+import com.sunxung.factoring.dict.impl.ProjectInitiationStatusDict;
|
|
import com.sunxung.factoring.entity.creditresolution.CreditResolution;
|
|
import com.sunxung.factoring.entity.creditresolution.CreditResolution;
|
|
import com.sunxung.factoring.entity.entprise.Enterprise;
|
|
import com.sunxung.factoring.entity.entprise.Enterprise;
|
|
import com.sunxung.factoring.entity.financing.apply.*;
|
|
import com.sunxung.factoring.entity.financing.apply.*;
|
|
@@ -648,6 +647,8 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
|
|
if (reviewQuotaDisburse.getPlanIrr() != null) {
|
|
if (reviewQuotaDisburse.getPlanIrr() != null) {
|
|
reviewQuotaDisburse.setPlanIrrStr(PercentageUtil.convertPercentage(reviewQuotaDisburse.getPlanIrr().doubleValue()));
|
|
reviewQuotaDisburse.setPlanIrrStr(PercentageUtil.convertPercentage(reviewQuotaDisburse.getPlanIrr().doubleValue()));
|
|
}
|
|
}
|
|
|
|
+ //填充业务综合授信余额和供应商授信余额
|
|
|
|
+ autoBalance(financingBasicInfo, reviewQuotaDisburse);
|
|
//填充主合同信息
|
|
//填充主合同信息
|
|
autoMasterContractInfo(reviewQuotaDisburse);
|
|
autoMasterContractInfo(reviewQuotaDisburse);
|
|
//填充融资信息
|
|
//填充融资信息
|
|
@@ -671,23 +672,9 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
|
|
private void initQuotaDisburse(CFinancingBasicInfo financingBasicInfo, BigDecimal
|
|
private void initQuotaDisburse(CFinancingBasicInfo financingBasicInfo, BigDecimal
|
|
netAccountsReceivableAmountTotal, ReviewQuotaDisburse reviewQuotaDisburse) {
|
|
netAccountsReceivableAmountTotal, ReviewQuotaDisburse reviewQuotaDisburse) {
|
|
reviewQuotaDisburse.setFinancingBasicInfoId(financingBasicInfo.getId());
|
|
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.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);
|
|
reviewQuotaDisburse.setAccountsReceivableNetAmountTotal(netAccountsReceivableAmountTotal);
|
|
|
|
|
|
//融资信息
|
|
//融资信息
|
|
@@ -771,6 +758,32 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
|
|
reviewQuotaDisburse.setReviewBasicContractList(Arrays.asList(reviewBasicContract));
|
|
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));
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 填充主合同信息
|
|
* 填充主合同信息
|
|
*
|
|
*
|
|
@@ -820,22 +833,15 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
|
|
throw new BusinessException(CodeUtil.FAIL, "查询sop对应的业务编号失败:" + jsonObject.getStr("msg"));
|
|
throw new BusinessException(CodeUtil.FAIL, "查询sop对应的业务编号失败:" + jsonObject.getStr("msg"));
|
|
}
|
|
}
|
|
BigDecimal returnedPrincipal = jsonObject.getBigDecimal("data");
|
|
BigDecimal returnedPrincipal = jsonObject.getBigDecimal("data");
|
|
|
|
+
|
|
List<CFinancingBasicInfo> list1 = financingBasicInfoService.list(new QueryWrapper<CFinancingBasicInfo>()
|
|
List<CFinancingBasicInfo> list1 = financingBasicInfoService.list(new QueryWrapper<CFinancingBasicInfo>()
|
|
.eq("supplier_id", financingBasicInfo.getMainEnterpriseId())
|
|
.eq("supplier_id", financingBasicInfo.getMainEnterpriseId())
|
|
- .ne("current_stage", FinancingCurrentStageEnum.REVIEW_QUOTA_DISBURSE.getCode())
|
|
|
|
- .ne("financing_status", FinancingStatusEnum.FINANCING_PROCESSING.getCode()));
|
|
|
|
|
|
+ .ne("id", financingBasicInfo.getId())
|
|
|
|
+ .ne("current_stage", FinancingCurrentStageEnum.REVIEW_QUOTA_DISBURSE.getCode()));
|
|
if (CollectionUtil.isNotEmpty(list1)) {
|
|
if (CollectionUtil.isNotEmpty(list1)) {
|
|
- BigDecimal occupyAmount = list1.stream().filter(basicInfo -> basicInfo.getFinancingAmount() != null).map(CFinancingBasicInfo::getFinancingAmount)
|
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
- supplierOccupyAmount = supplierOccupyAmount.add(occupyAmount).subtract(returnedPrincipal);
|
|
|
|
- }
|
|
|
|
- List<CFinancingBasicInfo> list2 = financingBasicInfoService.list(new QueryWrapper<CFinancingBasicInfo>()
|
|
|
|
- .eq("supplier_id", financingBasicInfo.getMainEnterpriseId())
|
|
|
|
- .ne("current_stage", "")
|
|
|
|
- .ne("financing_status", FinancingStatusEnum.FINANCING_TERMINATED.getCode()));
|
|
|
|
- if (CollectionUtil.isNotEmpty(list2)) {
|
|
|
|
- BigDecimal occupyAmount = list2.stream().filter(basicInfo -> basicInfo.getFinancingAmount() != null).map(CFinancingBasicInfo::getFinancingAmount)
|
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
+ BigDecimal occupyAmount = list1.stream().filter(basicInfo -> basicInfo.getFinancingAmount() != null
|
|
|
|
+ && !ProjectInitiationStatusDict.ChildEnum.TERMINATED.getCode().equals(basicInfo.getFinancingStatus()))
|
|
|
|
+ .map(CFinancingBasicInfo::getFinancingAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
supplierOccupyAmount = supplierOccupyAmount.add(occupyAmount).subtract(returnedPrincipal);
|
|
supplierOccupyAmount = supplierOccupyAmount.add(occupyAmount).subtract(returnedPrincipal);
|
|
}
|
|
}
|
|
return supplierOccupyAmount;
|
|
return supplierOccupyAmount;
|
|
@@ -858,20 +864,12 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
|
|
BigDecimal returnedPrincipal = jsonObject.getBigDecimal("data");
|
|
BigDecimal returnedPrincipal = jsonObject.getBigDecimal("data");
|
|
List<CFinancingBasicInfo> list1 = financingBasicInfoService.list(new QueryWrapper<CFinancingBasicInfo>()
|
|
List<CFinancingBasicInfo> list1 = financingBasicInfoService.list(new QueryWrapper<CFinancingBasicInfo>()
|
|
.eq("business_number", financingBasicInfo.getBusinessNumber())
|
|
.eq("business_number", financingBasicInfo.getBusinessNumber())
|
|
- .ne("current_stage", FinancingCurrentStageEnum.REVIEW_QUOTA_DISBURSE.getCode())
|
|
|
|
- .ne("financing_status", FinancingStatusEnum.FINANCING_PROCESSING.getCode()));
|
|
|
|
|
|
+ .ne("id", financingBasicInfo.getId())
|
|
|
|
+ .ne("current_stage", FinancingCurrentStageEnum.REVIEW_QUOTA_DISBURSE.getCode()));
|
|
if (CollectionUtil.isNotEmpty(list1)) {
|
|
if (CollectionUtil.isNotEmpty(list1)) {
|
|
- BigDecimal occupyAmount = list1.stream().filter(basicInfo -> basicInfo.getFinancingAmount() != null).map(CFinancingBasicInfo::getFinancingAmount)
|
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
- businessOccupyAmount = businessOccupyAmount.add(occupyAmount).subtract(returnedPrincipal);
|
|
|
|
- }
|
|
|
|
- List<CFinancingBasicInfo> list2 = financingBasicInfoService.list(new QueryWrapper<CFinancingBasicInfo>()
|
|
|
|
- .eq("business_number", financingBasicInfo.getBusinessNumber())
|
|
|
|
- .ne("current_stage", "")
|
|
|
|
- .ne("financing_status", FinancingStatusEnum.FINANCING_TERMINATED.getCode()));
|
|
|
|
- if (CollectionUtil.isNotEmpty(list2)) {
|
|
|
|
- BigDecimal occupyAmount = list2.stream().filter(basicInfo -> basicInfo.getFinancingAmount() != null).map(CFinancingBasicInfo::getFinancingAmount)
|
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
+ BigDecimal occupyAmount = list1.stream().filter(basicInfo -> basicInfo.getFinancingAmount() != null
|
|
|
|
+ && !ProjectInitiationStatusDict.ChildEnum.TERMINATED.getCode().equals(basicInfo.getFinancingStatus()))
|
|
|
|
+ .map(CFinancingBasicInfo::getFinancingAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
businessOccupyAmount = businessOccupyAmount.add(occupyAmount).subtract(returnedPrincipal);
|
|
businessOccupyAmount = businessOccupyAmount.add(occupyAmount).subtract(returnedPrincipal);
|
|
}
|
|
}
|
|
return businessOccupyAmount;
|
|
return businessOccupyAmount;
|