Forráskód Böngészése

融资管理-授信余额计算逻辑修改

liuj 6 hónapja%!(EXTRA string=óta)
szülő
commit
090904aac7

+ 12 - 27
src/main/java/com/sunxung/factoring/service/financing/apply/impl/FinancingApplyServiceImpl.java

@@ -5,11 +5,11 @@ import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.sunxung.factoring.component.enums.FileTypeEnum;
 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.ValidatorException;
 import com.sunxung.factoring.component.util.*;
 import com.sunxung.factoring.dict.impl.FileModuleDict;
+import com.sunxung.factoring.dict.impl.ProjectInitiationStatusDict;
 import com.sunxung.factoring.entity.creditresolution.CreditResolution;
 import com.sunxung.factoring.entity.entprise.Enterprise;
 import com.sunxung.factoring.entity.financing.apply.*;
@@ -833,22 +833,15 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
             throw new BusinessException(CodeUtil.FAIL, "查询sop对应的业务编号失败:" + jsonObject.getStr("msg"));
         }
         BigDecimal returnedPrincipal = jsonObject.getBigDecimal("data");
+
         List<CFinancingBasicInfo> list1 = financingBasicInfoService.list(new QueryWrapper<CFinancingBasicInfo>()
                 .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)) {
-            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);
         }
         return supplierOccupyAmount;
@@ -871,20 +864,12 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
         BigDecimal returnedPrincipal = jsonObject.getBigDecimal("data");
         List<CFinancingBasicInfo> list1 = financingBasicInfoService.list(new QueryWrapper<CFinancingBasicInfo>()
                 .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)) {
-            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);
         }
         return businessOccupyAmount;