Browse Source

移交业务 增加 融资申请 和 退款

zhangc 7 months ago
parent
commit
77e2e245e8

+ 176 - 1
src/main/java/com/sunxung/factoring/service/sys/impl/ClientUserServiceImpl.java

@@ -15,12 +15,14 @@ import com.sunxung.factoring.entity.biddingManagement.CBiddingBasicInfo;
 import com.sunxung.factoring.entity.businessmanagement.BusinessBasicInfo;
 import com.sunxung.factoring.entity.businessmanagement.BusinessBasicInfoHistory;
 import com.sunxung.factoring.entity.creditresolution.CreditResolution;
+import com.sunxung.factoring.entity.financing.apply.CFinancingBasicInfo;
 import com.sunxung.factoring.entity.invoicemanage.InvoiceBasicInfo;
 import com.sunxung.factoring.entity.project.BusinessAssignee;
 import com.sunxung.factoring.entity.project.BusinessProcessingLog;
 import com.sunxung.factoring.entity.project.ProjectCoreEnterprise;
 import com.sunxung.factoring.entity.project.ProjectInformation;
 import com.sunxung.factoring.entity.purchcontractmanagement.PurchContractManagement;
+import com.sunxung.factoring.entity.refundsManagement.RefundManagement;
 import com.sunxung.factoring.entity.salescontractmanagement.CSalesContract;
 import com.sunxung.factoring.entity.settlement.SettlementBasicInfo;
 import com.sunxung.factoring.entity.supplier.SupplierInfo;
@@ -35,6 +37,7 @@ import com.sunxung.factoring.mapper.sys.ClientUserMapper;
 import com.sunxung.factoring.service.acceptancesheet.AcceptanceBasicInfoService;
 import com.sunxung.factoring.service.biddingManagement.ICBiddingBasicInfoService;
 import com.sunxung.factoring.service.creditresolution.ICreditResolutionService;
+import com.sunxung.factoring.service.financing.apply.ICFinancingBasicInfoService;
 import com.sunxung.factoring.service.invoicemanage.InvoiceBasicInfoService;
 import com.sunxung.factoring.service.project.BusinessAssigneeService;
 import com.sunxung.factoring.service.project.BusinessProcessingLogService;
@@ -42,6 +45,7 @@ import com.sunxung.factoring.service.project.IProjectCoreEnterpriseService;
 import com.sunxung.factoring.service.project.IProjectInformationService;
 import com.sunxung.factoring.service.project.impl.ProjectInformationServiceImpl;
 import com.sunxung.factoring.service.purchcontractmanagement.PurchContractService;
+import com.sunxung.factoring.service.refundsManagement.IRefundManagementService;
 import com.sunxung.factoring.service.salescontractmanagement.SalesContractService;
 import com.sunxung.factoring.service.settlement.SettlementBasicInfoService;
 import com.sunxung.factoring.service.supplier.ICreditInvestigationInfoService;
@@ -106,6 +110,10 @@ public class ClientUserServiceImpl extends ServiceImpl<ClientUserMapper, ClientU
   private ICreditResolutionService creditResolutionService;
   @Autowired
   private ICBiddingBasicInfoService biddingBasicInfoService;
+  @Autowired
+  private ICFinancingBasicInfoService cfinancingBasicInfoService;
+  @Autowired
+  private IRefundManagementService refundManagementService;
 
 
   @Override
@@ -234,6 +242,10 @@ public class ClientUserServiceImpl extends ServiceImpl<ClientUserMapper, ClientU
               biddingBasicInfoTransfer(p.getBusinessNumber(),projectManagerId);
               //移交发票
               invoiceTransfer(p.getBusinessNumber(), projectManagerId);
+              //移交额度只用
+              financingApplyProjectTransfer(p.getBusinessNumber(),projectManagerId);
+              //退款 移交 业务经理
+              refundManagerTransfer(p.getBusinessNumber(),projectManagerId);
             }
           }
         }
@@ -265,7 +277,9 @@ public class ClientUserServiceImpl extends ServiceImpl<ClientUserMapper, ClientU
                 shouxinTransferRisk(creditResolution.getId(), riskManagerId);
                }
 //              //移交发票
-//              invoiceTransfer(p.getBusinessNumber(), projectManagerId);
+              //invoiceTransfer(p.getBusinessNumber(), projectManagerId);
+              //移交融资申请
+              financingApplyRiskTransfer(p.getBusinessNumber(),riskManagerId);
             }
           }
         }
@@ -432,6 +446,165 @@ public class ClientUserServiceImpl extends ServiceImpl<ClientUserMapper, ClientU
     }
   }
 
+  /**
+   * 额度支用--风险移交 调用
+   * @param businessNumber
+   * @param userId
+   */
+  private void financingApplyRiskTransfer(String businessNumber,Long userId){
+    List<CFinancingBasicInfo> list  = cfinancingBasicInfoService.lambdaQuery()
+        .eq(CFinancingBasicInfo::getBusinessNumber, businessNumber).list();
+    for(CFinancingBasicInfo one:list) {
+      List<BusinessProcessingLog> businessProcessingLogs = businessProcessingLogService.listForNullValueOfEndTime(
+          one.getId(), ConstantUtil.FINANCING_APPLY);
+      if (CollectionUtil.isNotEmpty(businessProcessingLogs)) {
+        for (BusinessProcessingLog businessProcessingLog : businessProcessingLogs) {
+          Task task = taskService.createTaskQuery()
+              .taskId(businessProcessingLog.getHistoricTaskId())
+              .singleResult();
+          if (task == null) {
+            log.error("--------------移交出现任务id查看不到确切任务,跳过循环执行下一次循环------------taskId="
+                + businessProcessingLog.getHistoricTaskId());
+            continue;
+          }
+          taskService.setVariable(businessProcessingLog.getHistoricTaskId(),
+              ConstantUtil.REVIEW_QUOTA_DISBURSE_APPROVAL_ASSIGNEE, String.valueOf(userId));
+
+          //修改business_assignee
+          // BusinessAssignee businessAssignee = assigneeService.getByBusiness(projectId, ConstantUtil.BUSINESS_MANAGEMENT, ConstantUtil.ASSIGNEE_PROJECT_MANAGER);
+          // businessAssignee.setAssigneeId(userId);
+          //assigneeService.update(businessAssignee);
+          if (businessProcessingLog.getTaskDefKey().equals("review_quota_disburse_approval")) {
+            taskService.setAssignee(businessProcessingLog.getHistoricTaskId(),
+                String.valueOf(userId));
+            taskService.setOwner(businessProcessingLog.getHistoricTaskId(), String.valueOf(userId));
+            businessProcessingLog.setAssignee(userService.get(userId));
+            processingLogMapper.updateAssigneeId(businessProcessingLog);
+          }
+        }
+      }
+    }
+  }
+
+  /**
+   * 额度支用-- 项目经理 移交调用
+   * @param businessNumber
+   * @param userId
+   */
+  private void financingApplyProjectTransfer(String businessNumber,Long userId){
+    List<CFinancingBasicInfo> list  = cfinancingBasicInfoService.lambdaQuery()
+        .eq(CFinancingBasicInfo::getBusinessNumber, businessNumber).list();
+    for(CFinancingBasicInfo one:list) {
+      List<BusinessProcessingLog> businessProcessingLogs = businessProcessingLogService.listForNullValueOfEndTime(
+          one.getId(), ConstantUtil.FINANCING_APPLY);
+      if (CollectionUtil.isNotEmpty(businessProcessingLogs)) {
+        for (BusinessProcessingLog businessProcessingLog : businessProcessingLogs) {
+          Task task = taskService.createTaskQuery()
+              .taskId(businessProcessingLog.getHistoricTaskId())
+              .singleResult();
+          if (task == null) {
+            log.error("--------------移交出现任务id查看不到确切任务,跳过循环执行下一次循环------------taskId="
+                + businessProcessingLog.getHistoricTaskId());
+            continue;
+          }
+          taskService.setVariable(businessProcessingLog.getHistoricTaskId(),
+              ConstantUtil.REVIEW_QUOTA_DISBURSE_ASSIGNEE, String.valueOf(userId));
+
+          //修改business_assignee
+          // BusinessAssignee businessAssignee = assigneeService.getByBusiness(projectId, ConstantUtil.BUSINESS_MANAGEMENT, ConstantUtil.ASSIGNEE_PROJECT_MANAGER);
+          // businessAssignee.setAssigneeId(userId);
+          //assigneeService.update(businessAssignee);
+          if (businessProcessingLog.getTaskDefKey().equals("review_quota_disburse")) {
+            taskService.setAssignee(businessProcessingLog.getHistoricTaskId(),
+                String.valueOf(userId));
+            taskService.setOwner(businessProcessingLog.getHistoricTaskId(), String.valueOf(userId));
+            businessProcessingLog.setAssignee(userService.get(userId));
+            processingLogMapper.updateAssigneeId(businessProcessingLog);
+          }
+        }
+      }
+    }
+  }
+
+
+
+//   风控经理是个 组任务  不需要移交
+//  private void  refundRiskTransfer(String businessNumber,Long userId){
+//    List<RefundManagement> list  = refundManagementService.lambdaQuery()
+//        .eq(RefundManagement::getBusinessNumber, businessNumber).list();
+//    for(RefundManagement one:list) {
+//      List<BusinessProcessingLog> businessProcessingLogs = businessProcessingLogService.listForNullValueOfEndTime(
+//          one.getId(), ConstantUtil.REFUND_MANAGEMENT);
+//      if (CollectionUtil.isNotEmpty(businessProcessingLogs)) {
+//        for (BusinessProcessingLog businessProcessingLog : businessProcessingLogs) {
+//          Task task = taskService.createTaskQuery()
+//              .taskId(businessProcessingLog.getHistoricTaskId())
+//              .singleResult();
+//          if (task == null) {
+//            log.error("--------------移交出现任务id查看不到确切任务,跳过循环执行下一次循环------------taskId="
+//                + businessProcessingLog.getHistoricTaskId());
+//            continue;
+//          }
+//          taskService.setVariable(businessProcessingLog.getHistoricTaskId(),
+//              ConstantUtil.REFUND_APPROVAL + ConstantUtil._CANDIDATE, String.valueOf(userId));
+//
+//          //修改business_assignee
+//          // BusinessAssignee businessAssignee = assigneeService.getByBusiness(projectId, ConstantUtil.BUSINESS_MANAGEMENT, ConstantUtil.ASSIGNEE_PROJECT_MANAGER);
+//          // businessAssignee.setAssigneeId(userId);
+//          //assigneeService.update(businessAssignee);
+//          if (businessProcessingLog.getTaskDefKey().equals(ConstantUtil.REFUND_APPROVAL)) {
+//            taskService.setAssignee(businessProcessingLog.getHistoricTaskId(),
+//                String.valueOf(userId));
+//            taskService.setOwner(businessProcessingLog.getHistoricTaskId(), String.valueOf(userId));
+//            businessProcessingLog.setAssignee(userService.get(userId));
+//            processingLogMapper.updateAssigneeId(businessProcessingLog);
+//          }
+//        }
+//      }
+//    }
+//  }
+
+  /**
+   *  退款 ----------- 移交 业务经理
+   * @param businessNumber
+   * @param userId
+   */
+  private void  refundManagerTransfer(String businessNumber,Long userId){
+    List<RefundManagement> list  = refundManagementService.lambdaQuery()
+        .eq(RefundManagement::getBusinessNumber, businessNumber).list();
+    for(RefundManagement one:list) {
+      List<BusinessProcessingLog> businessProcessingLogs = businessProcessingLogService.listForNullValueOfEndTime(
+          one.getId(), ConstantUtil.REFUND_MANAGEMENT);
+      if (CollectionUtil.isNotEmpty(businessProcessingLogs)) {
+        for (BusinessProcessingLog businessProcessingLog : businessProcessingLogs) {
+          Task task = taskService.createTaskQuery()
+              .taskId(businessProcessingLog.getHistoricTaskId())
+              .singleResult();
+          if (task == null) {
+            log.error("--------------移交出现任务id查看不到确切任务,跳过循环执行下一次循环------------taskId="
+                + businessProcessingLog.getHistoricTaskId());
+            continue;
+          }
+          taskService.setVariable(businessProcessingLog.getHistoricTaskId(),
+              ConstantUtil.REFUND_APPLY + ConstantUtil.ASSIGNEE, String.valueOf(userId));
+
+          //修改business_assignee
+          // BusinessAssignee businessAssignee = assigneeService.getByBusiness(projectId, ConstantUtil.BUSINESS_MANAGEMENT, ConstantUtil.ASSIGNEE_PROJECT_MANAGER);
+          // businessAssignee.setAssigneeId(userId);
+          //assigneeService.update(businessAssignee);
+          if (businessProcessingLog.getTaskDefKey().equals(ConstantUtil.REFUND_APPLY)) {
+            taskService.setAssignee(businessProcessingLog.getHistoricTaskId(),
+                String.valueOf(userId));
+            taskService.setOwner(businessProcessingLog.getHistoricTaskId(), String.valueOf(userId));
+            businessProcessingLog.setAssignee(userService.get(userId));
+            processingLogMapper.updateAssigneeId(businessProcessingLog);
+          }
+        }
+      }
+    }
+  }
+
+
   /**
    * 授信-------移交项目经理
    *
@@ -516,6 +689,8 @@ public class ClientUserServiceImpl extends ServiceImpl<ClientUserMapper, ClientU
   }
 
 
+
+
   /**
    * 法务审核 --  这个应该不需要移交
    *