Преглед изворни кода

Merge remote-tracking branch 'origin/dev1.0' into dev1.0

wangyf пре 6 дана
родитељ
комит
2a73af36e2

+ 39 - 6
src/main/java/com/sunxung/factoring/service/financing/contract/impl/ContractMakingServiceImpl.java

@@ -14,6 +14,7 @@ import com.sunxung.factoring.entity.entprise.Enterprise;
 import com.sunxung.factoring.entity.financing.apply.CFinancingBasicInfo;
 import com.sunxung.factoring.entity.financing.contract.*;
 import com.sunxung.factoring.entity.financing.contractTemplate.ContractTemplate;
+import com.sunxung.factoring.entity.financing.payment.PaymentInfo;
 import com.sunxung.factoring.entity.financing.review.*;
 import com.sunxung.factoring.entity.project.ProjectInformation;
 import com.sunxung.factoring.entity.smb.FinancingFromInvestorsHistory;
@@ -30,6 +31,7 @@ import com.sunxung.factoring.service.entprise.IEnterpriseService;
 import com.sunxung.factoring.service.financing.apply.ICFinancingBasicInfoService;
 import com.sunxung.factoring.service.financing.contract.*;
 import com.sunxung.factoring.service.financing.contractTemplate.IContractTemplateService;
+import com.sunxung.factoring.service.financing.payment.IPaymentInfoService;
 import com.sunxung.factoring.service.financing.review.*;
 import com.sunxung.factoring.service.project.BusinessAssigneeService;
 import com.sunxung.factoring.service.project.IProjectInformationService;
@@ -174,6 +176,8 @@ public class ContractMakingServiceImpl implements ContractMakingService {
     private ISysAttachmentRefService sysAttachmentRefService;
     @Autowired
     private ICreditInvestigationInfoService creditInvestigationInfoService;
+    @Autowired
+    private IPaymentInfoService paymentInfoService;
 
     @Override
     public ContractInfo edit(Long id) {
@@ -804,14 +808,24 @@ public class ContractMakingServiceImpl implements ContractMakingService {
             Map<String, Object> procVariables = new HashMap<>();
             String key = ConstantUtil.FINANCING_APPLY;
             CFinancingBasicInfo financingBasicInfo = financingBasicInfoService.getById(quotaDisburse.getFinancingBasicInfoId());
-            Long assigneeId = assigneeService.getIdByBusiness(financingBasicInfo.getId(), key, ConstantUtil.ASSIGNEE_C_SUPPLIER);
+
             if (contractInfo.getConclusion().equals(ConstantConversionUtil.APPROVAL_RESULT_PASS)) {
-                //修改融资申请当前阶段
-                financingBasicInfo.setCurrentStage(FinancingCurrentStageEnum.CONTRACT_SIGNING.getCode());
-                financingBasicInfoService.updateById(financingBasicInfo);
+                if (contractInfo.getContractSignMethod() != null && contractInfo.getContractSignMethod().equals(0)) {
+                    //如果是线下签
+                    //修改融资申请当前阶段为融资申请
+                    financingBasicInfo.setCurrentStage(FinancingCurrentStageEnum.PAYMENT_APPLY.getCode());
+                    financingBasicInfoService.updateById(financingBasicInfo);
+                    procVariables.put(ConstantUtil.PAYMENT_APPLY_ASSIGNEE, assigneeService.getIdByBusiness(financingBasicInfo.getId(), key, ConstantUtil.ASSIGNEE_PROJECT_MANAGER));
+
+                    //新增付款信息
+                    addPaymentInfo(financingBasicInfo, contractInfo, quotaDisburse);
+                } else if (contractInfo.getContractSignMethod().equals(1)) {
+                    //如果是电子签
+                    //修改融资申请当前阶段为付款申请
+                    financingBasicInfo.setCurrentStage(FinancingCurrentStageEnum.CONTRACT_SIGNING.getCode());
+                    financingBasicInfoService.updateById(financingBasicInfo);
+                    procVariables.put(ConstantUtil.CONTRACT_SIGNING_ASSIGNEE, assigneeService.getIdByBusiness(financingBasicInfo.getId(), key, ConstantUtil.ASSIGNEE_C_SUPPLIER));
 
-                procVariables.put(ConstantUtil.CONTRACT_SIGNING_ASSIGNEE, assigneeId);
-                if (contractInfo.getContractSignMethod().equals(1)) {
                     List<String> electronicSigns = contractInfo.getElectronicSign();
                     if (electronicSigns != null && !electronicSigns.isEmpty()) {
                         //制作电子签合同
@@ -853,6 +867,25 @@ public class ContractMakingServiceImpl implements ContractMakingService {
         return contractInfo;
     }
 
+    private void addPaymentInfo(CFinancingBasicInfo financingBasicInfo, ContractInfo contractInfo, ReviewQuotaDisburse quotaDisburse) {
+        PaymentInfo paymentInfo = new PaymentInfo();
+        paymentInfo.setBusinessNo(contractInfo.getBusinessNo());
+        paymentInfo.setFinancingBasicInfoId(financingBasicInfo.getId());
+        paymentInfo.setContractInfoId(contractInfo.getId());
+        paymentInfo.setQuotaDisburseId(quotaDisburse.getId());
+        paymentInfo.setQuotaDisburseBatch(quotaDisburse.getQuotaDisburseBatch());
+        paymentInfo.setContractNo(contractInfo.getContractNo());
+
+        ReviewFinancingInfo reviewFinancingInfo = reviewFinancingInfoService.getOne(new QueryWrapper<ReviewFinancingInfo>()
+                .eq("review_quota_disburse_id", quotaDisburse.getId()));
+        if (reviewFinancingInfo == null) {
+            throw new ValidatorException(CodeUtil.FAIL, "获取不到对应融资信息!");
+        }
+        paymentInfo.setTotalLoanAmount(reviewFinancingInfo.getFinancingAmount());
+
+        paymentInfoService.save(paymentInfo);
+    }
+
     /**
      * 保存合同历史信息
      *