liuj пре 6 месеци
родитељ
комит
f8a87125df

+ 1 - 1
src/main/java/com/inkasso/factoring/acceptanceManagement/service/impl/CAcceptanceBasicInfoServiceImpl.java

@@ -1102,7 +1102,7 @@ public class CAcceptanceBasicInfoServiceImpl extends ServiceImpl<CAcceptanceBasi
         return acceptanceBasicInfo;
     }
 
-
+    @Override
     public List<CAcceptanceBasicInfo> findByCondition(CAcceptanceBasicInfo basicInfo, Boolean financing) {
         return baseMapper.findByCondition(basicInfo, financing);
     }

+ 102 - 4
src/main/java/com/inkasso/factoring/financingmanagement/service/impl/FinancingApplyServiceImpl.java

@@ -1,6 +1,7 @@
 package com.inkasso.factoring.financingmanagement.service.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -20,6 +21,7 @@ import com.inkasso.factoring.creditmanagement.entity.Enterprise;
 import com.inkasso.factoring.creditmanagement.entity.ProjectInformation;
 import com.inkasso.factoring.creditmanagement.service.IEnterpriseService;
 import com.inkasso.factoring.creditmanagement.service.IProjectInformationService;
+import com.inkasso.factoring.dict.entity.Dictionary;
 import com.inkasso.factoring.dict.service.DictionaryService;
 import com.inkasso.factoring.file.entity.FileStorageDO;
 import com.inkasso.factoring.file.enums.FileTypeEnum;
@@ -57,6 +59,7 @@ import org.springframework.web.client.RestTemplate;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -108,6 +111,10 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
     private String financingApplyUrl;
     @Value("${sop.viewLatestPlanUrl}")
     private String viewLatestPlanUrl;
+    @Value("${sop.judgeCustomerGradeUrl}")
+    private String judgeCustomerGradeUrl;
+    @Value("${sop.judgeCustomerExemptionMattersUrl}")
+    private String judgeCustomerExemptionMattersUrl;
     @Autowired
     private FinancingApplyMapper financingApplyMapper;
     @Autowired
@@ -335,10 +342,16 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
 
         List<CFinancingGoodsInfo> financingGoodsInfoList = financingApplyVo.getFinancingGoodsInfoList();
         if (visible) {
-            //验验收单货物是否已经融资
+            //验验收单货物是否已经融资
             checkAcceptanceGoods(financingGoodsInfoList);
-            //校验项目授信决议是否通过
-            //123
+            //校验供应商五级分类是否正常用户
+            checkEnterpriseGrade(financingBasicInfo.getMainEnterpriseId());
+            //校验供应商名下是否存在豁免事项跟进未完成的数据
+            checkEnterpriseExemptionMatters(financingBasicInfo.getMainEnterpriseId());
+            //校验是否存在超过预计结算日期且未结算的验收单
+            checkAcceptance(financingBasicInfo.getBusinessNumber());
+            //校验是否存在已逾期的融资申请
+            checkOverdue(financingBasicInfo.getBusinessNumber());
             //状态为处理中
             financingBasicInfo.setFinancingStatus(ProjectInitiationStatusEnum.PROCESSING.getCode());
             //当前阶段为额度支用
@@ -407,7 +420,6 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
                 financingBasicInfo.setRiskManagerId(userDO.getRiskManager());
             }
             financingBasicInfo.setFinancingHisInfoId(financingHisInfo.getId());
-            //todo 添加应收账款净额
             ResponseEntity<String> responseEntity = restTemplate.postForEntity(financingApplyUrl, financingBasicInfo, String.class);
             ResponseJson responseJson = JSONUtil.toBean(responseEntity.getBody(), ResponseJson.class);
             if (responseEntity.getStatusCode().value() != HttpStatus.OK.value() || !responseJson.isSuccess()) {
@@ -416,6 +428,92 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
         }
     }
 
+    /**
+     * 校验是否存在已逾期的融资申请
+     *
+     * @param businessNumber
+     */
+    private void checkOverdue(String businessNumber) {
+        List<CFinancingBasicInfo> financingBasicInfoList = financingBasicInfoService.list(new QueryWrapper<CFinancingBasicInfo>().eq("business_number", businessNumber));
+        if (CollectionUtil.isNotEmpty(financingBasicInfoList)) {
+            for (CFinancingBasicInfo financingBasicInfo : financingBasicInfoList) {
+                PaymentCollectionBasic basic = getViewLatestPlan(financingBasicInfo.getId());
+                if (basic != null && CollectionUtil.isNotEmpty(basic.getPlanFactoringList())) {
+                    for (PaymentCollectionPlanFactoring planFactoring : basic.getPlanFactoringList()) {
+                        if ("pay_coll_collection".equals(planFactoring.getPaymentCollectionType()) && planFactoring.getAmount().compareTo(BigDecimal.ZERO) > 0) {
+                            Dictionary statusDict = planFactoring.getStatus();
+                            if (statusDict != null && "pay_coll_plan_overdue".equals(statusDict.getCode())) {
+                                throw new BusinessException(CodeUtil.FAIL, "存在已逾期的融资申请,请结清后操作");
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 校验是否存在超过预计结算日期且未结算的验收单
+     *
+     * @param businessNumber
+     */
+    private void checkAcceptance(String businessNumber) {
+        List<CAcceptanceBasicInfo> acceptanceBasicInfoList = acceptanceBasicInfoService.list(new QueryWrapper<CAcceptanceBasicInfo>().eq("business_number", businessNumber));
+        if (CollectionUtil.isNotEmpty(acceptanceBasicInfoList)) {
+            for (CAcceptanceBasicInfo acceptanceBasicInfo : acceptanceBasicInfoList) {
+                if (acceptanceBasicInfo.getSettlement() != null && !acceptanceBasicInfo.getSettlement()) {
+                    //未结算
+                    if (acceptanceBasicInfo.getExpectedSettlementDate() != null
+                            && DateUtil.beginOfDay(new Date()).compareTo(acceptanceBasicInfo.getExpectedSettlementDate()) > 0) {
+                        throw new BusinessException(CodeUtil.FAIL, "存在到期未结算的验收单,请联系业务经理");
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 校验供应商五级分类是否正常
+     *
+     * @param mainEnterpriseId
+     */
+    private void checkEnterpriseGrade(Long mainEnterpriseId) {
+        Enterprise enterprise = enterpriseService.getById(mainEnterpriseId);
+        if (enterprise != null && enterprise.getSocialCreditCode() != null) {
+            JSONObject jsonObject = restTemplate.getForObject(judgeCustomerGradeUrl + "?socialCreditCode=" + enterprise.getSocialCreditCode(), JSONObject.class);
+            Integer code = jsonObject.getInt("code");
+            Boolean success = jsonObject.getBool("success");
+            if (code != HttpStatus.OK.value() || !success) {
+                throw new BusinessException(CodeUtil.FAIL, "获取客户五级分类失败:" + jsonObject.getStr("msg"));
+            }
+            Boolean bool = jsonObject.getBool("data");
+            if (!bool) {
+                throw new BusinessException(CodeUtil.FAIL, "五级分类异常,请联系业务经理");
+            }
+        }
+    }
+
+    /**
+     * 校验供应商下是否存在豁免事项跟进未完成的数据
+     *
+     * @param mainEnterpriseId
+     */
+    private void checkEnterpriseExemptionMatters(Long mainEnterpriseId) {
+        Enterprise enterprise = enterpriseService.getById(mainEnterpriseId);
+        if (enterprise != null && enterprise.getSocialCreditCode() != null) {
+            JSONObject jsonObject = restTemplate.getForObject(judgeCustomerExemptionMattersUrl + "?socialCreditCode=" + enterprise.getSocialCreditCode(), JSONObject.class);
+            Integer code = jsonObject.getInt("code");
+            Boolean success = jsonObject.getBool("success");
+            if (code != HttpStatus.OK.value() || !success) {
+                throw new BusinessException(CodeUtil.FAIL, "获取客户豁免事项待办失败:" + jsonObject.getStr("msg"));
+            }
+            Boolean bool = jsonObject.getBool("data");
+            if (!bool) {
+                throw new BusinessException(CodeUtil.FAIL, "存在豁免事项待办,请联系业务经理");
+            }
+        }
+    }
+
     /**
      * 校验验收单货物是否已融资
      *

+ 2 - 0
src/main/resources/application-dev.yml

@@ -146,6 +146,8 @@ sop:
   synchronizeInformation: http://192.168.3.6:8868/sys/customer/synchronize/information
   getEnterpriseAreaUrl: http://192.168.3.6:8868/api/trade/getEnterpriseArea
   viewLatestPlanUrl: http://192.168.3.6:8868/api/payColl/viewLatestPlan
+  judgeCustomerGradeUrl: http://192.168.3.6:8868/api/judgeCustomerGrade
+  judgeCustomerExemptionMattersUrl: http://192.168.3.6:8868/api/judgeCustomerExemptionMatters
 
 trade:
   biddingManagementStartProcessUrl: http://localhost:8888/api/biddingManagement/startProcess

+ 3 - 0
src/main/resources/application-prod.yml

@@ -150,6 +150,9 @@ sop:
   synchronizeInformation: http://222.90.211.174:10526/sys/customer/synchronize/information
   getEnterpriseAreaUrl: http://222.90.211.174:10526/api/trade/getEnterpriseArea
   viewLatestPlanUrl: http://222.90.211.174:10526/api/payColl/viewLatestPlan
+  judgeCustomerGradeUrl: http://222.90.211.174:10526/api/judgeCustomerGrade
+  judgeCustomerExemptionMattersUrl: http://222.90.211.174:10526/api/judgeCustomerExemptionMatters
+
 
 trade:
   biddingManagementStartProcessUrl: http://139.224.194.150:8868/tradeV4-backend/api/biddingManagement/startProcess