Browse Source

Merge branch 'master' into dev1.0

liutao 6 months ago
parent
commit
f785538dc1

+ 7 - 0
src/main/java/com/sunxung/factoring/service/creditresolution/ICreditResolutionService.java

@@ -23,6 +23,13 @@ public interface ICreditResolutionService extends IService<CreditResolution> {
      */
     void startProcess(Long cProjectInformationId);
 
+    /**
+     * 开启老授信的授信决议流程
+     * @param cProjectInformationId
+     * @param oldCoreEnterpriseId
+     */
+    void startProcessOld(Long cProjectInformationId, Long oldCoreEnterpriseId);
+
     /**
      * 根据id查询
      *

+ 77 - 6
src/main/java/com/sunxung/factoring/service/creditresolution/impl/CreditResolutionServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
 import com.sunxung.factoring.component.exception.BusinessException;
+import com.sunxung.factoring.component.exception.ServiceException;
 import com.sunxung.factoring.component.exception.ValidatorException;
 import com.sunxung.factoring.component.util.*;
 import com.sunxung.factoring.dict.impl.ProjectInitiationStatusDict;
@@ -134,14 +135,84 @@ public class CreditResolutionServiceImpl extends ServiceImpl<CreditResolutionMap
             BigDecimal projectCreditLimit ;
             ProjectCoreEnterpriseAudit projectCoreEnterpriseAudit;
             ProjectCoreEnterpriseComprehensiveEvaluation projectCoreEnterpriseComprehensiveEvaluation;
-            //如果用的之前授信的结果就要从之前的数据里取金额
-            if(projectCoreEnterprise.getProcess() == 0){
-                projectCoreEnterpriseAudit = projectCoreEnterpriseAuditService.lambdaQuery().eq(ProjectCoreEnterpriseAudit::getcProjectCoreEnterpriseId, projectCoreEnterprise.getOldCoreEnterpriseId()).one();
-                projectCoreEnterpriseComprehensiveEvaluation = projectCoreEnterpriseComprehensiveEvaluationService.lambdaQuery().eq(ProjectCoreEnterpriseComprehensiveEvaluation::getProjectCoreEnterpriseAuditId, projectCoreEnterpriseAudit.getId()).one();
+
+            projectCoreEnterpriseAudit = projectCoreEnterpriseAuditService.lambdaQuery().eq(ProjectCoreEnterpriseAudit::getcProjectCoreEnterpriseId, projectCoreEnterprise.getId()).one();
+            projectCoreEnterpriseComprehensiveEvaluation = projectCoreEnterpriseComprehensiveEvaluationService.lambdaQuery().eq(ProjectCoreEnterpriseComprehensiveEvaluation::getProjectCoreEnterpriseAuditId, projectCoreEnterpriseAudit.getId()).one();
+
+            Enterprise coreEnterprise = enterpriseService.getById(projectCoreEnterprise.getcEnterpriseId());
+            Enterprise enterprise = enterpriseService.getById(projectInformation.getcEnterpriseId());
+            BigDecimal supplierCreditLimit = supplierInfo.getCreditLimit();
+            BigDecimal projectCoreEnterpriseCreditLimit = projectCoreEnterpriseComprehensiveEvaluation.getCreditLimit();
+            BigDecimal result ;
+            if(projectAudit != null){
+                ProjectOwnerComprehensiveEvaluation projectOwnerComprehensiveEvaluation = projectOwnerComprehensiveEvaluationService.lambdaQuery().eq(ProjectOwnerComprehensiveEvaluation::getProjectAuditId, projectAudit.getId()).one();
+                projectCreditLimit = projectOwnerComprehensiveEvaluation.getCreditLimit();
+                result = supplierCreditLimit.compareTo(projectCreditLimit) > -1 ? projectCreditLimit : supplierCreditLimit;
             }else {
-                projectCoreEnterpriseAudit = projectCoreEnterpriseAuditService.lambdaQuery().eq(ProjectCoreEnterpriseAudit::getcProjectCoreEnterpriseId, projectCoreEnterprise.getId()).one();
-                projectCoreEnterpriseComprehensiveEvaluation = projectCoreEnterpriseComprehensiveEvaluationService.lambdaQuery().eq(ProjectCoreEnterpriseComprehensiveEvaluation::getProjectCoreEnterpriseAuditId, projectCoreEnterpriseAudit.getId()).one();
+                result = supplierCreditLimit;
+            }
+            result = result.compareTo(projectCoreEnterpriseCreditLimit) > -1 ? projectCoreEnterpriseCreditLimit : result;
+            creditResolution.setProposedCreditLine(result.multiply(new BigDecimal("10000")));
+            creditResolution.setCurrency("CNY");
+            creditResolution.setProposedCreditTerm(360);
+            creditResolution.setStatusStr(ProjectInitiationStatusDict.ChildEnum.PROCESSING.getCode());
+            creditResolution.setUpstreamAccountingPeriod(projectInformation.getEstimatedAccountingPeriod() * 30 + 60);
+            creditResolution.setFactoringFinancingPeriod(projectInformation.getEstimatedAccountingPeriod() * 30 + 60);
+            creditResolution.setCreditReport(1);
+            baseMapper.add(creditResolution);
+            //开启流程
+            Map<String, Object> procVariables = new HashMap<>();
+            UserDO userDO = cUserService.getById(supplierInfo.getSysUserId());
+            if (userDO.getRiskManager() == null) {
+                throw new BusinessException(CodeUtil.FAIL, "请联系客服分配风控经理");
+            }
+            if (userDO.getProjectManager() == null) {
+                throw new BusinessException(CodeUtil.FAIL, "请联系客服分配业务经理");
+            }
+            procVariables.put(ConstantUtil.CREDIT_RESOLUTION_ADD_ASSIGNEE, userDO.getProjectManager());
+            procVariables.put(ConstantUtil.CREDIT_RESOLUTION_APPROVAL_ASSIGNEE, userDO.getRiskManager());
+            procVariables.put(ConstantUtil.RECONSIDER_ADJUST_ADD_ASSIGNEE, userDO.getProjectManager());
+            procVariables.put(ConstantUtil.RECONSIDER_ADJUST_APPROVAL_ASSIGNEE, userDO.getRiskManager());
+            //查询条件:业务编号 项目名称 主企业名称 核心企业名称
+            String queryBusiness = projectInformation.getBusinessNumber() + FlowableUtil.splitChar + projectInformation.getProjectName();
+            if(enterprise != null){
+                queryBusiness = queryBusiness + FlowableUtil.splitChar + enterprise.getCorporateName();
+            }
+            if(coreEnterprise != null){
+                queryBusiness = queryBusiness + FlowableUtil.splitChar + coreEnterprise.getCorporateName();
+            }
+            ProcessInstance processInst = flowableService.startProcessInstance(creditResolution, procVariables,
+                    FlowableUtil.generateBusinessKey(creditResolution, ConstantUtil.CREDIT_RESOLUTION, queryBusiness), null, ConstantUtil.CREDIT_RESOLUTION);
+            if (processInst == null) {
+                throw new BusinessException(CodeUtil.FAIL, "流程启动失败");
             }
+        }
+    }
+
+    @Override
+    public void startProcessOld(Long cProjectInformationId, Long oldCoreEnterpriseId) {
+        if(oldCoreEnterpriseId == null){
+            throw new ServiceException(CodeUtil.FAIL,"项目核心企业id为空,无法开启授信决议流程!");
+        }
+        CreditResolution existCredit = baseMapper.getByProjectInfoId(cProjectInformationId);
+        if (existCredit == null) {
+            //保存基础信息
+            ProjectInformation projectInformation = projectInformationService.get(cProjectInformationId);
+            ProjectCoreEnterprise projectCoreEnterprise = projectCoreEnterpriseService.getByProjectInfoId(cProjectInformationId);
+            SupplierInfo supplierInfo = supplierInfoService.get(projectInformation.getcSupplierInfoId());
+            CreditResolution creditResolution = new CreditResolution();
+            creditResolution.setcProjectInformationId(cProjectInformationId);
+            creditResolution.setCreditType("综合授信");
+            creditResolution.setDomesticFactoring("国内保理");
+            creditResolution.setImplementingFactoringProducts("贸理通");
+            creditResolution.setImplementingFactoringType("池保理 有追索权 明保理 正向保理");
+            ProjectAudit projectAudit = projectAuditService.lambdaQuery().eq(ProjectAudit::getcProjectInformationId, projectInformation.getId()).one();
+            BigDecimal projectCreditLimit ;
+            ProjectCoreEnterpriseAudit projectCoreEnterpriseAudit;
+            ProjectCoreEnterpriseComprehensiveEvaluation projectCoreEnterpriseComprehensiveEvaluation;
+            //如果用的之前授信的结果就要从之前的数据里取金额
+            projectCoreEnterpriseAudit = projectCoreEnterpriseAuditService.lambdaQuery().eq(ProjectCoreEnterpriseAudit::getcProjectCoreEnterpriseId, oldCoreEnterpriseId).one();
+            projectCoreEnterpriseComprehensiveEvaluation = projectCoreEnterpriseComprehensiveEvaluationService.lambdaQuery().eq(ProjectCoreEnterpriseComprehensiveEvaluation::getProjectCoreEnterpriseAuditId, projectCoreEnterpriseAudit.getId()).one();
             Enterprise coreEnterprise = enterpriseService.getById(projectCoreEnterprise.getcEnterpriseId());
             Enterprise enterprise = enterpriseService.getById(projectInformation.getcEnterpriseId());
             BigDecimal supplierCreditLimit = supplierInfo.getCreditLimit();

+ 5 - 5
src/main/java/com/sunxung/factoring/web/creditresolution/CreditResolutionController.java

@@ -54,13 +54,13 @@ public class CreditResolutionController {
     }
 
     /**
-     * 手动开启流程
+     * 手动开启流程项目3个月内授信过
      * @param id
      */
-    @RequestMapping("startProcess")
-    @OperationLog(operationModule = "授信决议",operationType = OperationTypeEnum.INSERT,description = "手动开启流程")
-    public void startProcess(@RequestParam Long id){
-        creditResolutionService.startProcess(id);
+    @RequestMapping("startProcessOld")
+    @OperationLog(operationModule = "授信决议",operationType = OperationTypeEnum.INSERT,description = "手动开启流程项目3个月内授信过")
+    public void startProcess(@RequestParam Long id,@RequestParam Long oldCoreEnterpriseId){
+        creditResolutionService.startProcessOld(id,oldCoreEnterpriseId);
     }
 
     /**