|
@@ -9,6 +9,7 @@ import com.loan.system.domain.dto.DisbursementStartDTO;
|
|
|
import com.loan.system.domain.entity.*;
|
|
import com.loan.system.domain.entity.*;
|
|
|
import com.loan.system.domain.enums.*;
|
|
import com.loan.system.domain.enums.*;
|
|
|
import com.loan.system.domain.pojo.DateAndAmountPOJO;
|
|
import com.loan.system.domain.pojo.DateAndAmountPOJO;
|
|
|
|
|
+import com.loan.system.domain.pojo.TemplateMessage;
|
|
|
import com.loan.system.domain.vo.*;
|
|
import com.loan.system.domain.vo.*;
|
|
|
import com.loan.system.exception.DescribeException;
|
|
import com.loan.system.exception.DescribeException;
|
|
|
import com.loan.system.repository.DisbursementRepository;
|
|
import com.loan.system.repository.DisbursementRepository;
|
|
@@ -22,10 +23,7 @@ import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import static com.loan.system.domain.enums.DecisionEnum.PASS;
|
|
import static com.loan.system.domain.enums.DecisionEnum.PASS;
|
|
@@ -49,6 +47,7 @@ public class DisbursementServiceImpl implements DisbursementService {
|
|
|
private final LocationDatumService locationDatumService;
|
|
private final LocationDatumService locationDatumService;
|
|
|
private final ContractService contractService;
|
|
private final ContractService contractService;
|
|
|
private final ContractBankInfoService contractBankInfoService;
|
|
private final ContractBankInfoService contractBankInfoService;
|
|
|
|
|
+ private final WxService wxService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public DisbursementVO addDisbursement(DisbursementDTO disbursementDTO) {
|
|
public DisbursementVO addDisbursement(DisbursementDTO disbursementDTO) {
|
|
@@ -134,7 +133,7 @@ public class DisbursementServiceImpl implements DisbursementService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void addDisbursementPlan(DisbursementDTO disbursementDTO) {
|
|
|
|
|
|
|
+ public void addDisbursementPlan(LoanCaseSimpleVO loanCaseSimpleVO, DisbursementDTO disbursementDTO) {
|
|
|
Long id = disbursementDTO.getId();
|
|
Long id = disbursementDTO.getId();
|
|
|
if (id > 0) {
|
|
if (id > 0) {
|
|
|
Disbursement disbursement = disbursementRepository.findByIdAndIsDelete(id, false);
|
|
Disbursement disbursement = disbursementRepository.findByIdAndIsDelete(id, false);
|
|
@@ -165,21 +164,39 @@ public class DisbursementServiceImpl implements DisbursementService {
|
|
|
//修改状态
|
|
//修改状态
|
|
|
stepService.updateUserId1ByCaseIdAndStepCode(StepPropertyEnum.PLAN_REPORT.getCode(), BaseContext.getCurrentId(), disbursementDTO.getCaseId());
|
|
stepService.updateUserId1ByCaseIdAndStepCode(StepPropertyEnum.PLAN_REPORT.getCode(), BaseContext.getCurrentId(), disbursementDTO.getCaseId());
|
|
|
if (PlanIsCleared(disbursementDTO.getCaseId())) {
|
|
if (PlanIsCleared(disbursementDTO.getCaseId())) {
|
|
|
- //TODO:存在问题
|
|
|
|
|
stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.PLAN_REPORT.getCode(), disbursementDTO.getCaseId());
|
|
stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.PLAN_REPORT.getCode(), disbursementDTO.getCaseId());
|
|
|
}
|
|
}
|
|
|
//删除驳回记录
|
|
//删除驳回记录
|
|
|
new RedisData(redisTemplate).deleteApprovalByKey(disbursementDTO.getCaseId(), StepPropertyEnum.PLAN_REPORT.getLabel(), StepPropertyEnum.PLAN_REPORT.getCode());
|
|
new RedisData(redisTemplate).deleteApprovalByKey(disbursementDTO.getCaseId(), StepPropertyEnum.PLAN_REPORT.getLabel(), StepPropertyEnum.PLAN_REPORT.getCode());
|
|
|
stepService.tryStartStep(StepPropertyEnum.PLAN_REPORT.getCode(), disbursementDTO.getCaseId());
|
|
stepService.tryStartStep(StepPropertyEnum.PLAN_REPORT.getCode(), disbursementDTO.getCaseId());
|
|
|
|
|
|
|
|
|
|
+ //TODO:微信推送预审拒绝消息和通知下一环节:审批员
|
|
|
|
|
+ com.loan.system.domain.pojo.TemplateMessage message = new TemplateMessage();
|
|
|
|
|
+ Map<String, Map<String, String>> data = new HashMap<>();
|
|
|
|
|
+ data.put("character_string6", Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getId())));//caseId
|
|
|
|
|
+ data.put("phrase7", Collections.singletonMap("value",StepPropertyEnum.PLAN_AUDIT.getLabel()));//当前环节
|
|
|
|
|
+ data.put("thing1", Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getBusinessType())));//业务类型
|
|
|
|
|
+ Customer customer = customerService.findByIdAndIsDelete(loanCaseSimpleVO.getCustomerId());
|
|
|
|
|
+ data.put("thing3", Collections.singletonMap("value", customer!=null ? customer.getName() : ""));//客户名称
|
|
|
|
|
+ data.put("amount4",Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getTotalLoanAmount())));//典当金额
|
|
|
|
|
+ message.setData(data);
|
|
|
|
|
+ List<User> users = userService.findByRoleAndIsDelete(Arrays.asList(RoleEnum.APPROVER.getMsg()), false);
|
|
|
|
|
+ for (User user : users) {
|
|
|
|
|
+ if (user.getOpenid() != null)
|
|
|
|
|
+ wxService.sendTemplateMessage(user.getOpenid(), message);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void disbursementPlanApproval(ApprovalRecordDTO approvalRecordDTO, Long chargeId, Long assistantId) {
|
|
|
|
|
|
|
+ public void disbursementPlanApproval(LoanCaseSimpleVO loanCaseSimpleVO, ApprovalRecordDTO approvalRecordDTO, Long chargeId, Long assistantId) {
|
|
|
Long caseId = approvalRecordDTO.getCaseId();
|
|
Long caseId = approvalRecordDTO.getCaseId();
|
|
|
//指派下一环节负责人
|
|
//指派下一环节负责人
|
|
|
- if (assistantId != null)
|
|
|
|
|
|
|
+ User user = null;
|
|
|
|
|
+ if (assistantId != null){
|
|
|
stepService.updateUserId1ByCaseIdAndStepCode(StepPropertyEnum.DISBURSE_START.getCode(), assistantId, caseId);
|
|
stepService.updateUserId1ByCaseIdAndStepCode(StepPropertyEnum.DISBURSE_START.getCode(), assistantId, caseId);
|
|
|
|
|
+ user = userService.findByIdAndIsDelete(assistantId);
|
|
|
|
|
+ }
|
|
|
stepService.updateUserId1ByCaseIdAndStepCode(StepPropertyEnum.DISBURSE_START.getCode(), chargeId, caseId);
|
|
stepService.updateUserId1ByCaseIdAndStepCode(StepPropertyEnum.DISBURSE_START.getCode(), chargeId, caseId);
|
|
|
disbursementRepository.updateUserById(chargeId, assistantId, approvalRecordDTO.getRecordId());
|
|
disbursementRepository.updateUserById(chargeId, assistantId, approvalRecordDTO.getRecordId());
|
|
|
|
|
|
|
@@ -194,21 +211,25 @@ public class DisbursementServiceImpl implements DisbursementService {
|
|
|
stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.PLAN_AUDIT.getCode(), caseId);
|
|
stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.PLAN_AUDIT.getCode(), caseId);
|
|
|
stepService.tryStartStep(StepPropertyEnum.PLAN_AUDIT.getCode(), caseId);
|
|
stepService.tryStartStep(StepPropertyEnum.PLAN_AUDIT.getCode(), caseId);
|
|
|
|
|
|
|
|
- //TODO:微信推送预审通过消息和通知下一环节
|
|
|
|
|
-// SysMessage message = new SysMessage();
|
|
|
|
|
-// message.setMobile(null);
|
|
|
|
|
-// message.setUserRole("");
|
|
|
|
|
-// message.setMessageTitle("");
|
|
|
|
|
-// message.setMessageContent("");
|
|
|
|
|
-// message.setStepName("");
|
|
|
|
|
-// message.setRelatedId(loanCase.getId());
|
|
|
|
|
-// message.setRelatedType("");
|
|
|
|
|
-// messageService.addMessage(message);
|
|
|
|
|
-// wxService.sendTemplateMessage(loanCase.getCustomer().getMobile(),new TemplateMessage());
|
|
|
|
|
|
|
+ //TODO:微信推送下环节负责人
|
|
|
|
|
+ TemplateMessage message = new TemplateMessage();
|
|
|
|
|
+ Map<String, Map<String, String>> data = new HashMap<>();
|
|
|
|
|
+ data.put("character_string6", Collections.singletonMap("value", String.valueOf(caseId)));//caseId
|
|
|
|
|
+ data.put("phrase7", Collections.singletonMap("value", StepPropertyEnum.DISBURSE_START.getLabel()));//当前环节
|
|
|
|
|
+ data.put("thing1", Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getBusinessType())));//业务类型
|
|
|
|
|
+ Customer customer = customerService.findByIdAndIsDelete(loanCaseSimpleVO.getCustomerId());
|
|
|
|
|
+ data.put("thing3", Collections.singletonMap("value", customer!=null ? customer.getName() : ""));//客户名称
|
|
|
|
|
+ data.put("amount4",Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getTotalLoanAmount())));//典当金额
|
|
|
|
|
+ message.setData(data);
|
|
|
|
|
+ User user1 = userService.findByIdAndIsDelete(chargeId);
|
|
|
|
|
+ if (user1 != null && user1.getOpenid() != null)
|
|
|
|
|
+ wxService.sendTemplateMessage(user1.getOpenid(), message);
|
|
|
|
|
+ if (user != null && user.getOpenid() != null)
|
|
|
|
|
+ wxService.sendTemplateMessage(user.getOpenid(), message);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void disbursementPlanApprovalReject(ApprovalRecordDTO approvalRecordDTO) {
|
|
|
|
|
|
|
+ public void disbursementPlanApprovalReject(LoanCaseSimpleVO loanCaseSimpleVO, ApprovalRecordDTO approvalRecordDTO) {
|
|
|
Long caseId = approvalRecordDTO.getCaseId();
|
|
Long caseId = approvalRecordDTO.getCaseId();
|
|
|
//填写驳回
|
|
//填写驳回
|
|
|
ApprovalRecord approvalRecord = approvalService.addApprovalRecord(caseId, StepPropertyEnum.PLAN_AUDIT.getCode(), DecisionEnum.REJECT.getMsg(), approvalRecordDTO.getComments());
|
|
ApprovalRecord approvalRecord = approvalService.addApprovalRecord(caseId, StepPropertyEnum.PLAN_AUDIT.getCode(), DecisionEnum.REJECT.getMsg(), approvalRecordDTO.getComments());
|
|
@@ -220,22 +241,30 @@ public class DisbursementServiceImpl implements DisbursementService {
|
|
|
stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(), StepPropertyEnum.PLAN_AUDIT.getCode(), caseId);
|
|
stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(), StepPropertyEnum.PLAN_AUDIT.getCode(), caseId);
|
|
|
//new RedisData(redisTemplate).setRejectApprovalRecord(caseId,StepPropertyEnum.PLAN_REPORT.getLabel(),StepPropertyEnum.PLAN_REPORT.getCode(),approvalRecordDTO.getComments());
|
|
//new RedisData(redisTemplate).setRejectApprovalRecord(caseId,StepPropertyEnum.PLAN_REPORT.getLabel(),StepPropertyEnum.PLAN_REPORT.getCode(),approvalRecordDTO.getComments());
|
|
|
|
|
|
|
|
- //TODO:微信推送预审通过消息和通知下一环节
|
|
|
|
|
-// SysMessage message = new SysMessage();
|
|
|
|
|
-// StepVO stepVO1 = stepService.findBystepCodeAndCaseId(StepPropertyEnum.PLAN_REPORT.getCode(), caseId);
|
|
|
|
|
-// message.setMobile(userService.findByIdAndIsDelete(stepVO1.getUserId1()).getMobile());
|
|
|
|
|
-// message.setUserRole(null);
|
|
|
|
|
-// message.setMessageTitle("");
|
|
|
|
|
-// message.setMessageContent("");
|
|
|
|
|
-// message.setstepCode(StepPropertyEnum.PLAN_AUDIT.getCode());
|
|
|
|
|
-// message.setRelatedId(caseId);
|
|
|
|
|
-// message.setRelatedType("");
|
|
|
|
|
- // messageService.addMessage(message);
|
|
|
|
|
-// wxService.sendTemplateMessage(loanCase.getCustomer().getMobile(),new TemplateMessage());
|
|
|
|
|
|
|
+ //TODO:微信通知上环节负责人
|
|
|
|
|
+ TemplateMessage message = new TemplateMessage();
|
|
|
|
|
+ Map<String, Map<String, String>> data = new HashMap<>();
|
|
|
|
|
+ data.put("character_string6", Collections.singletonMap("value", String.valueOf(caseId)));//caseId
|
|
|
|
|
+ data.put("phrase7", Collections.singletonMap("value",StepPropertyEnum.PLAN_REPORT.getLabel()));//当前环节
|
|
|
|
|
+ data.put("thing1", Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getBusinessType())));//业务类型
|
|
|
|
|
+ Customer customer = customerService.findByIdAndIsDelete(loanCaseSimpleVO.getCustomerId());
|
|
|
|
|
+ data.put("thing3", Collections.singletonMap("value", customer!=null ? customer.getName() : ""));//客户名称
|
|
|
|
|
+ data.put("amount4",Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getTotalLoanAmount())));//典当金额
|
|
|
|
|
+ message.setData(data);
|
|
|
|
|
+ Disbursement disbursement = disbursementRepository.findByIdAndIsDelete(approvalRecordDTO.getRecordId(), false);
|
|
|
|
|
+ User user = userService.findByIdAndIsDelete(disbursement.getOperatorUserId());
|
|
|
|
|
+ if (user != null && user.getOpenid() != null)
|
|
|
|
|
+ wxService.sendTemplateMessage(user.getOpenid(), message);
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void commitDisbursement(DisbursementStartDTO disbursementStartDTO, Boolean isComplete) {
|
|
|
|
|
|
|
+ public void commitDisbursement(LoanCaseSimpleVO loanCaseSimpleVO, DisbursementStartDTO disbursementStartDTO, Boolean isComplete) {
|
|
|
|
|
+ Disbursement disbursement = disbursementRepository.findByIdAndIsDelete(disbursementStartDTO.getDisbursementRecordDTO().getDisbursementId(),false);
|
|
|
|
|
+ if (disbursement.getMainUserId()!=null && !disbursement.getMainUserId().equals(BaseContext.getCurrentId())
|
|
|
|
|
+ || (disbursement.getAssistUserId() != null && !disbursement.getAssistUserId().equals(BaseContext.getCurrentId())))
|
|
|
|
|
+ throw new DescribeException(STEP_USER_NOT_EXPECTED);
|
|
|
|
|
+
|
|
|
DisbursementRecordDTO disbursementRecordDTO = disbursementStartDTO.getDisbursementRecordDTO();
|
|
DisbursementRecordDTO disbursementRecordDTO = disbursementStartDTO.getDisbursementRecordDTO();
|
|
|
Long caseId = disbursementRecordDTO.getCaseId();
|
|
Long caseId = disbursementRecordDTO.getCaseId();
|
|
|
Long recordId = disbursementRecordDTO.getId();
|
|
Long recordId = disbursementRecordDTO.getId();
|
|
@@ -325,37 +354,46 @@ public class DisbursementServiceImpl implements DisbursementService {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (flag || disburseIsComplete(caseId))
|
|
|
|
|
- stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.DISBURSE_START.getCode(), caseId);
|
|
|
|
|
|
|
+ if (flag || disburseIsComplete(caseId)){
|
|
|
|
|
+ updateStatusOnDisbursement(caseId);
|
|
|
|
|
+ }
|
|
|
stepService.tryStartStep(StepPropertyEnum.DISBURSE_START.getCode(), caseId);
|
|
stepService.tryStartStep(StepPropertyEnum.DISBURSE_START.getCode(), caseId);
|
|
|
|
|
|
|
|
- //TODO:微信推送预审通过消息和通知下一环节
|
|
|
|
|
-// SysMessage message = new SysMessage();
|
|
|
|
|
-// message.setMobile(null);
|
|
|
|
|
-// message.setUserRole("");
|
|
|
|
|
-// message.setMessageTitle("");
|
|
|
|
|
-// message.setMessageContent("");
|
|
|
|
|
-// message.setStepName("");
|
|
|
|
|
-// message.setRelatedId(loanCase.getId());
|
|
|
|
|
-// message.setRelatedType("");
|
|
|
|
|
-// messageService.addMessage(message);
|
|
|
|
|
-// wxService.sendTemplateMessage(loanCase.getCustomer().getMobile(),new TemplateMessage());
|
|
|
|
|
|
|
+ //TODO:微信通知下一环节:审批员
|
|
|
|
|
+ TemplateMessage message = new TemplateMessage();
|
|
|
|
|
+ Map<String, Map<String, String>> data = new HashMap<>();
|
|
|
|
|
+ data.put("character_string6", Collections.singletonMap("value", String.valueOf(caseId)));//caseId
|
|
|
|
|
+ data.put("phrase7", Collections.singletonMap("value", StepPropertyEnum.DISBURSE_AUDIT.getLabel()));//当前环节
|
|
|
|
|
+ data.put("thing1", Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getBusinessType())));//业务类型
|
|
|
|
|
+ Customer customer = customerService.findByIdAndIsDelete(loanCaseSimpleVO.getCustomerId());
|
|
|
|
|
+ data.put("thing3", Collections.singletonMap("value", customer!=null ? customer.getName() : ""));//客户名称
|
|
|
|
|
+ data.put("amount4",Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getTotalLoanAmount())));//典当金额
|
|
|
|
|
+ message.setData(data);
|
|
|
|
|
+ List<User> users = userService.findByRoleAndIsDelete(Arrays.asList(RoleEnum.APPROVER.getMsg()), false);
|
|
|
|
|
+ for (User user : users) {
|
|
|
|
|
+ if (user.getOpenid() != null)
|
|
|
|
|
+ wxService.sendTemplateMessage(user.getOpenid(), message);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private boolean disburseIsComplete(Long caseId) {
|
|
|
|
|
|
|
+ private boolean disburseIsComplete(Long caseId) {//如果刚好金额都匹配上,则表示出款完成
|
|
|
List<DisbursementRecord> records = disbursementRecordService.findRecordByCaseId(caseId);
|
|
List<DisbursementRecord> records = disbursementRecordService.findRecordByCaseId(caseId);
|
|
|
Double totalAmount = 0.0;
|
|
Double totalAmount = 0.0;
|
|
|
for (DisbursementRecord record : records)
|
|
for (DisbursementRecord record : records)
|
|
|
totalAmount += record.getAmount();
|
|
totalAmount += record.getAmount();
|
|
|
LoanCaseSimpleVO l = loanService.findLoanCaseSimpleByIdAndIsDelete(caseId, false);
|
|
LoanCaseSimpleVO l = loanService.findLoanCaseSimpleByIdAndIsDelete(caseId, false);
|
|
|
|
|
|
|
|
- return Math.abs(totalAmount - l.getTotalLoanAmount())<Double.MIN_VALUE;
|
|
|
|
|
|
|
+ if(Math.abs(totalAmount - l.getTotalLoanAmount())<Double.MIN_VALUE){
|
|
|
|
|
+ contractService.updateIsDisbursementByCaseId(caseId);//将全部设置为已更新
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void disbursementApproval(ApprovalRecordDTO approvalRecordDTO, String decision) {
|
|
|
|
|
|
|
+ public void disbursementApproval(LoanCaseSimpleVO loanCaseSimpleVO, ApprovalRecordDTO approvalRecordDTO, String decision) {
|
|
|
Long caseId = approvalRecordDTO.getCaseId();
|
|
Long caseId = approvalRecordDTO.getCaseId();
|
|
|
//填写审批意见
|
|
//填写审批意见
|
|
|
ApprovalRecord approvalRecord = approvalService.addApprovalRecord(caseId, StepPropertyEnum.DISBURSE_AUDIT.getCode(), decision, approvalRecordDTO.getComments());
|
|
ApprovalRecord approvalRecord = approvalService.addApprovalRecord(caseId, StepPropertyEnum.DISBURSE_AUDIT.getCode(), decision, approvalRecordDTO.getComments());
|
|
@@ -376,12 +414,46 @@ public class DisbursementServiceImpl implements DisbursementService {
|
|
|
if (ApprovalIsCompleted(caseId, StepPropertyEnum.DISBURSE_AUDIT.getCode()) && step.getStatus().equals(StepEnum.COMPLETED.getMsg()))
|
|
if (ApprovalIsCompleted(caseId, StepPropertyEnum.DISBURSE_AUDIT.getCode()) && step.getStatus().equals(StepEnum.COMPLETED.getMsg()))
|
|
|
stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.DISBURSE_AUDIT.getCode(), caseId);
|
|
stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.DISBURSE_AUDIT.getCode(), caseId);
|
|
|
stepService.tryStartStep(StepPropertyEnum.DISBURSE_AUDIT.getCode(), caseId);
|
|
stepService.tryStartStep(StepPropertyEnum.DISBURSE_AUDIT.getCode(), caseId);
|
|
|
|
|
+
|
|
|
|
|
+ //TODO:微信通知下一环节:出款确认
|
|
|
|
|
+ TemplateMessage message = new TemplateMessage();
|
|
|
|
|
+ Map<String, Map<String, String>> data = new HashMap<>();
|
|
|
|
|
+ data.put("character_string6", Collections.singletonMap("value", String.valueOf(caseId)));//caseId
|
|
|
|
|
+ data.put("phrase7", Collections.singletonMap("value", StepPropertyEnum.FINANCE_DISBURSE.getLabel()));//当前环节
|
|
|
|
|
+ data.put("thing1", Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getBusinessType())));//业务类型
|
|
|
|
|
+ Customer customer = customerService.findByIdAndIsDelete(loanCaseSimpleVO.getCustomerId());
|
|
|
|
|
+ data.put("thing3", Collections.singletonMap("value", customer!=null ? customer.getName() : ""));//客户名称
|
|
|
|
|
+ data.put("amount4",Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getTotalLoanAmount())));//典当金额
|
|
|
|
|
+ message.setData(data);
|
|
|
|
|
+ List<User> users = userService.findByRoleAndIsDelete(Arrays.asList( RoleEnum.FINANCE.getMsg()), false);
|
|
|
|
|
+ for (User user : users) {
|
|
|
|
|
+ if (user.getOpenid() != null)
|
|
|
|
|
+ wxService.sendTemplateMessage(user.getOpenid(), message);
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
new RedisData(redisTemplate).setRejectApprovalRecord(caseId, StepPropertyEnum.DISBURSE_START.getLabel(), StepPropertyEnum.DISBURSE_START.getCode(), approvalRecordDTO.getComments());
|
|
new RedisData(redisTemplate).setRejectApprovalRecord(caseId, StepPropertyEnum.DISBURSE_START.getLabel(), StepPropertyEnum.DISBURSE_START.getCode(), approvalRecordDTO.getComments());
|
|
|
|
|
|
|
|
//修改状态
|
|
//修改状态
|
|
|
stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.DISBURSE_START.getCode(), caseId);//重新出款
|
|
stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.DISBURSE_START.getCode(), caseId);//重新出款
|
|
|
stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(), StepPropertyEnum.DISBURSE_AUDIT.getCode(), caseId);
|
|
stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(), StepPropertyEnum.DISBURSE_AUDIT.getCode(), caseId);
|
|
|
|
|
+
|
|
|
|
|
+ //TODO:微信推送预审拒绝消息和通知上环节负责人
|
|
|
|
|
+ TemplateMessage message = new TemplateMessage();
|
|
|
|
|
+ Map<String, Map<String, String>> data = new HashMap<>();
|
|
|
|
|
+ data.put("character_string6", Collections.singletonMap("value", String.valueOf(caseId)));//caseId
|
|
|
|
|
+ data.put("phrase7", Collections.singletonMap("value", StepPropertyEnum.DISBURSE_START.getLabel()));//当前环节
|
|
|
|
|
+ data.put("thing1", Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getBusinessType())));//业务类型
|
|
|
|
|
+ Customer customer = customerService.findByIdAndIsDelete(loanCaseSimpleVO.getCustomerId());
|
|
|
|
|
+ data.put("thing3", Collections.singletonMap("value", customer!=null ? customer.getName() : ""));//客户名称
|
|
|
|
|
+ data.put("amount4",Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getTotalLoanAmount())));//典当金额
|
|
|
|
|
+ message.setData(data);
|
|
|
|
|
+ Disbursement disbursement = disbursementRepository.findByIdAndIsDelete(record.getDisbursementId(), false);
|
|
|
|
|
+ User user1 = userService.findByIdAndIsDelete(disbursement.getMainUserId());
|
|
|
|
|
+ User user2 = userService.findByIdAndIsDelete(disbursement.getAssistUserId());
|
|
|
|
|
+ if (user1 != null && user1.getOpenid() != null)
|
|
|
|
|
+ wxService.sendTemplateMessage(user1.getOpenid(), message);
|
|
|
|
|
+ if (user2 != null && user2.getOpenid() != null)
|
|
|
|
|
+ wxService.sendTemplateMessage(user2.getOpenid(), message);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -490,14 +562,21 @@ public class DisbursementServiceImpl implements DisbursementService {
|
|
|
userVOMap2.put(plan.getId(), u);
|
|
userVOMap2.put(plan.getId(), u);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- List<ContractDisbursement> contractDisbursements = contractDisbursementService.findByRecordIdAndIsPlan(plan.getId(), true);
|
|
|
|
|
|
|
+ planVOs.add(disbursementVO);
|
|
|
|
|
+ }
|
|
|
|
|
+ for (DisbursementVO planVO : planVOs){//重新再计算每个计划的金额(即使又进行了循环,但速度也比访问数据库快)
|
|
|
|
|
+ List<ContractDisbursement> contractDisbursements = contractDisbursementService.findByRecordIdAndIsPlan(planVO.getId(), true);
|
|
|
Map<Long, Double> contractAndAmount = new HashMap<>();
|
|
Map<Long, Double> contractAndAmount = new HashMap<>();
|
|
|
|
|
+ Map<Long, Double> contractAndAmount1 = new HashMap<>();
|
|
|
for (ContractDisbursement contractDisbursement : contractDisbursements) {
|
|
for (ContractDisbursement contractDisbursement : contractDisbursements) {
|
|
|
contractAndAmount.merge(contractDisbursement.getContractId(), contractDisbursement.getAmount(), Double::sum);
|
|
contractAndAmount.merge(contractDisbursement.getContractId(), contractDisbursement.getAmount(), Double::sum);
|
|
|
- }
|
|
|
|
|
- disbursementVO.setContractAndPlanAmount(contractAndAmount);
|
|
|
|
|
|
|
|
|
|
- planVOs.add(disbursementVO);
|
|
|
|
|
|
|
+ ApprovalRecordVO approvalRecordVO = planVO.getApprovalRecordVO();
|
|
|
|
|
+ if(approvalRecordVO!=null && approvalRecordVO.getDecision().equals(PASS.getMsg()))
|
|
|
|
|
+ contractAndAmount1.merge(contractDisbursement.getContractId(), contractDisbursement.getAmount(), Double::sum);
|
|
|
|
|
+ }
|
|
|
|
|
+ planVO.setContractAndPlanAmount(contractAndAmount);
|
|
|
|
|
+ planVO.setContractAndPlanAmount1(contractAndAmount1);
|
|
|
}
|
|
}
|
|
|
disbursementDetailVO.setDisbursementPlans(planVOs);
|
|
disbursementDetailVO.setDisbursementPlans(planVOs);
|
|
|
disbursementDetailVO.setCurrentPlanAmount(currentPlanAmount);
|
|
disbursementDetailVO.setCurrentPlanAmount(currentPlanAmount);
|
|
@@ -508,6 +587,7 @@ public class DisbursementServiceImpl implements DisbursementService {
|
|
|
double currentAmount = 0.0;
|
|
double currentAmount = 0.0;
|
|
|
double currentAmount1 = 0.0;
|
|
double currentAmount1 = 0.0;
|
|
|
Map<Long, Double> contractAndCurrentAmount = new HashMap<>();//合同的目前总金额
|
|
Map<Long, Double> contractAndCurrentAmount = new HashMap<>();//合同的目前总金额
|
|
|
|
|
+ Map<Long, Double> contractAndCurrentAmount1 = new HashMap<>();//合同的目前总金额
|
|
|
for (int i = 0; i < records.size(); i++) {
|
|
for (int i = 0; i < records.size(); i++) {
|
|
|
DisbursementRecordVO record = records.get(i);
|
|
DisbursementRecordVO record = records.get(i);
|
|
|
List<ApprovalRecordVO> financeApprovalRecordVOs = record.getFinanceApprovalRecordVOs();
|
|
List<ApprovalRecordVO> financeApprovalRecordVOs = record.getFinanceApprovalRecordVOs();
|
|
@@ -518,7 +598,7 @@ public class DisbursementServiceImpl implements DisbursementService {
|
|
|
Long recordId = record.getId();
|
|
Long recordId = record.getId();
|
|
|
List<ContractDisbursement> contractDisbursements = contractDisbursementService.findByRecordIdAndIsPlan(recordId, false);
|
|
List<ContractDisbursement> contractDisbursements = contractDisbursementService.findByRecordIdAndIsPlan(recordId, false);
|
|
|
|
|
|
|
|
- Map<Long, Double> contractAndAmount = new HashMap<>();
|
|
|
|
|
|
|
+ Map<Long, Double> contractAndAmount = new HashMap<>();//单个计划
|
|
|
for (ContractDisbursement contractDisbursement : contractDisbursements) {
|
|
for (ContractDisbursement contractDisbursement : contractDisbursements) {
|
|
|
//对合同的金额做累加
|
|
//对合同的金额做累加
|
|
|
contractAndCurrentAmount.merge(contractDisbursement.getContractId(), contractDisbursement.getAmount(), Double::sum);
|
|
contractAndCurrentAmount.merge(contractDisbursement.getContractId(), contractDisbursement.getAmount(), Double::sum);
|
|
@@ -542,6 +622,16 @@ public class DisbursementServiceImpl implements DisbursementService {
|
|
|
disbursementDetailVO.setDisbursementRecords(records);
|
|
disbursementDetailVO.setDisbursementRecords(records);
|
|
|
// 4.private Map<Long,Double> contractAndCurrentAmount;//目前合同对应的出款金额
|
|
// 4.private Map<Long,Double> contractAndCurrentAmount;//目前合同对应的出款金额
|
|
|
disbursementDetailVO.setContractAndCurrentAmount(contractAndCurrentAmount);
|
|
disbursementDetailVO.setContractAndCurrentAmount(contractAndCurrentAmount);
|
|
|
|
|
+ for (DisbursementRecordVO record1 : records){
|
|
|
|
|
+ List<ApprovalRecordVO> financeApprovalRecordVOs = record1.getFinanceApprovalRecordVOs();
|
|
|
|
|
+ if(financeApprovalRecordVOs!=null && financeApprovalRecordVOs.get(financeApprovalRecordVOs.size()-1).getDecision().equals(PASS.getMsg())){
|
|
|
|
|
+ Map<Long, Double> contractIdAndAmount = record1.getContractIdAndAmount();
|
|
|
|
|
+ contractIdAndAmount.forEach((contractId, amount) -> {
|
|
|
|
|
+ contractAndCurrentAmount1.merge(contractId, amount, Double::sum);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ disbursementDetailVO.setContractAndCurrentAmount1(contractAndCurrentAmount1);
|
|
|
// 6.private Double currentAmount;//目前金额
|
|
// 6.private Double currentAmount;//目前金额
|
|
|
disbursementDetailVO.setCurrentAmount(currentAmount);
|
|
disbursementDetailVO.setCurrentAmount(currentAmount);
|
|
|
disbursementDetailVO.setCurrentAmount1(currentAmount1);
|
|
disbursementDetailVO.setCurrentAmount1(currentAmount1);
|
|
@@ -646,7 +736,7 @@ public class DisbursementServiceImpl implements DisbursementService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void financeApproval(ApprovalRecordDTO approvalRecordDTO, String decision) {
|
|
|
|
|
|
|
+ public void financeApproval(LoanCaseSimpleVO loanCaseSimpleVO,ApprovalRecordDTO approvalRecordDTO, String decision) {
|
|
|
Long caseId = approvalRecordDTO.getCaseId();
|
|
Long caseId = approvalRecordDTO.getCaseId();
|
|
|
//填写审批意见
|
|
//填写审批意见
|
|
|
ApprovalRecord approvalRecord = approvalService.addApprovalRecord(caseId, StepPropertyEnum.FINANCE_DISBURSE.getCode(), decision, approvalRecordDTO.getComments());
|
|
ApprovalRecord approvalRecord = approvalService.addApprovalRecord(caseId, StepPropertyEnum.FINANCE_DISBURSE.getCode(), decision, approvalRecordDTO.getComments());
|
|
@@ -657,6 +747,7 @@ public class DisbursementServiceImpl implements DisbursementService {
|
|
|
disbursementRecordDTO.setId(record.getId());
|
|
disbursementRecordDTO.setId(record.getId());
|
|
|
String approvalIds = record.getFinanceApprovalIds() == null ? approvalRecord.getId().toString() : record.getFinanceApprovalIds() + "," + approvalRecord.getId();
|
|
String approvalIds = record.getFinanceApprovalIds() == null ? approvalRecord.getId().toString() : record.getFinanceApprovalIds() + "," + approvalRecord.getId();
|
|
|
disbursementRecordDTO.setFinanceApprovalIds(approvalIds);
|
|
disbursementRecordDTO.setFinanceApprovalIds(approvalIds);
|
|
|
|
|
+ disbursementRecordDTO.setCreateTime(approvalRecordDTO.getDisbursementTime());
|
|
|
disbursementRecordService.updateRecordById(disbursementRecordDTO);
|
|
disbursementRecordService.updateRecordById(disbursementRecordDTO);
|
|
|
|
|
|
|
|
//修改状态
|
|
//修改状态
|
|
@@ -680,13 +771,88 @@ public class DisbursementServiceImpl implements DisbursementService {
|
|
|
if (ApprovalIsCompleted(caseId, StepPropertyEnum.FINANCE_DISBURSE.getCode()) && step.getStatus().equals(StepEnum.COMPLETED.getMsg()))
|
|
if (ApprovalIsCompleted(caseId, StepPropertyEnum.FINANCE_DISBURSE.getCode()) && step.getStatus().equals(StepEnum.COMPLETED.getMsg()))
|
|
|
stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.FINANCE_DISBURSE.getCode(), caseId);
|
|
stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.FINANCE_DISBURSE.getCode(), caseId);
|
|
|
stepService.tryStartStep(StepPropertyEnum.FINANCE_DISBURSE.getCode(), caseId);
|
|
stepService.tryStartStep(StepPropertyEnum.FINANCE_DISBURSE.getCode(), caseId);
|
|
|
|
|
+
|
|
|
|
|
+ TemplateMessage message = new TemplateMessage();
|
|
|
|
|
+ Map<String, Map<String, String>> data = new HashMap<>();
|
|
|
|
|
+ data.put("character_string6", Collections.singletonMap("value", String.valueOf(caseId)));//caseId
|
|
|
|
|
+ data.put("phrase7", Collections.singletonMap("value", StepPropertyEnum.DISBURSE_CONFIRM.getLabel()));//当前环节
|
|
|
|
|
+ data.put("thing1", Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getBusinessType())));//业务类型
|
|
|
|
|
+ Customer customer = customerService.findByIdAndIsDelete(loanCaseSimpleVO.getCustomerId());
|
|
|
|
|
+ data.put("thing3", Collections.singletonMap("value", customer!=null ? customer.getName() : ""));//客户名称
|
|
|
|
|
+ data.put("amount4",Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getTotalLoanAmount())));//典当金额
|
|
|
|
|
+ message.setData(data);
|
|
|
|
|
+ List<User> users = userService.findByRoleAndIsDelete(Arrays.asList(RoleEnum.ASSIST_SALES.getMsg(), RoleEnum.LEAD_SALES.getMsg()), false);
|
|
|
|
|
+ for (User user : users)
|
|
|
|
|
+ if (user.getOpenid() != null)
|
|
|
|
|
+ wxService.sendTemplateMessage(user.getOpenid(), message);
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
new RedisData(redisTemplate).setRejectApprovalRecord(caseId, StepPropertyEnum.DISBURSE_START.getLabel(), StepPropertyEnum.DISBURSE_START.getCode(), approvalRecordDTO.getComments());
|
|
new RedisData(redisTemplate).setRejectApprovalRecord(caseId, StepPropertyEnum.DISBURSE_START.getLabel(), StepPropertyEnum.DISBURSE_START.getCode(), approvalRecordDTO.getComments());
|
|
|
|
|
|
|
|
//修改状态
|
|
//修改状态
|
|
|
stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.DISBURSE_START.getCode(), caseId);//重新出款
|
|
stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.DISBURSE_START.getCode(), caseId);//重新出款
|
|
|
stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(), StepPropertyEnum.FINANCE_DISBURSE.getCode(), caseId);
|
|
stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(), StepPropertyEnum.FINANCE_DISBURSE.getCode(), caseId);
|
|
|
|
|
+
|
|
|
|
|
+ //TODO:微信推送预审拒绝消息和通知上环节负责人
|
|
|
|
|
+ TemplateMessage message = new TemplateMessage();
|
|
|
|
|
+ Map<String, Map<String, String>> data = new HashMap<>();
|
|
|
|
|
+ data.put("character_string6", Collections.singletonMap("value", String.valueOf(caseId)));//caseId
|
|
|
|
|
+ data.put("phrase7", Collections.singletonMap("value", StepPropertyEnum.DISBURSE_START.getLabel()));//当前环节
|
|
|
|
|
+ data.put("thing1", Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getBusinessType())));//业务类型
|
|
|
|
|
+ Customer customer = customerService.findByIdAndIsDelete(loanCaseSimpleVO.getCustomerId());
|
|
|
|
|
+ data.put("thing3", Collections.singletonMap("value", customer!=null ? customer.getName() : ""));//客户名称
|
|
|
|
|
+ data.put("amount4",Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getTotalLoanAmount())));//典当金额
|
|
|
|
|
+ message.setData(data);
|
|
|
|
|
+ Disbursement disbursement = disbursementRepository.findByIdAndIsDelete(record.getDisbursementId(), false);
|
|
|
|
|
+ User user1 = userService.findByIdAndIsDelete(disbursement.getMainUserId());
|
|
|
|
|
+ User user2 = userService.findByIdAndIsDelete(disbursement.getAssistUserId());
|
|
|
|
|
+ if (user1 != null && user1.getOpenid() != null)
|
|
|
|
|
+ wxService.sendTemplateMessage(user1.getOpenid(), message);
|
|
|
|
|
+ if (user2 != null && user2.getOpenid() != null)
|
|
|
|
|
+ wxService.sendTemplateMessage(user2.getOpenid(), message);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void completeDisburse(Long caseId) {
|
|
|
|
|
+ //1.检查各环节是否有正在进行的事务
|
|
|
|
|
+ List<Disbursement> disbursements = disbursementRepository.findDisbursementsByCaseId(caseId,false);
|
|
|
|
|
+ if (disbursements==null)//无出款计划,报错
|
|
|
|
|
+ throw new DescribeException(ILLEGAL_OPERATION);
|
|
|
|
|
+ for (Disbursement disbursement : disbursements){
|
|
|
|
|
+ ApprovalRecord approvalRecord = approvalService.findByIdAndIsDelete(disbursement.getApprovalId());
|
|
|
|
|
+ if (approvalRecord==null || approvalRecord.getDecision().equals(DecisionEnum.REJECT.getMsg()))//有计划但无审批或驳回,报错
|
|
|
|
|
+ throw new DescribeException(ILLEGAL_OPERATION_1);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<DisbursementRecordVO> records = disbursementRecordService.findRecordVOByCaseId(caseId);
|
|
|
|
|
+ if (records==null || records.size()!=disbursements.size())
|
|
|
|
|
+ throw new DescribeException(ILLEGAL_OPERATION_2);//有计划但还未出款,报错
|
|
|
|
|
+ for (DisbursementRecordVO disbursementRecordVO: records){
|
|
|
|
|
+ if (disbursementRecordVO.getApprovalRecordVOs()==null || disbursementRecordVO.getApprovalRecordVOs().get(disbursementRecordVO.getApprovalRecordVOs().size()-1).getDecision().
|
|
|
|
|
+ equals(DecisionEnum.REJECT.getMsg()))
|
|
|
|
|
+ throw new DescribeException(ILLEGAL_OPERATION_3);//有审批
|
|
|
|
|
+ if (disbursementRecordVO.getFinanceApprovalRecordVOs()==null || disbursementRecordVO.getFinanceApprovalRecordVOs().get(disbursementRecordVO.getFinanceApprovalRecordVOs().size()-1).getDecision().
|
|
|
|
|
+ equals(DecisionEnum.REJECT.getMsg()))
|
|
|
|
|
+ throw new DescribeException(ILLEGAL_OPERATION_4);//有财务审批
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //2.更新合同信息
|
|
|
|
|
+ contractService.updateIsDisbursementByCaseId(caseId);
|
|
|
|
|
+
|
|
|
|
|
+ //3.更新各环节
|
|
|
|
|
+ stepService.updateStatusByCaseIdAndParentCode(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.DISBURSE_PARENT.getCode(),caseId);
|
|
|
|
|
+
|
|
|
|
|
+ //4.开启回款
|
|
|
|
|
+ stepService.tryStartStep(StepPropertyEnum.DISBURSE_CONFIRM.getCode(), caseId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void updateStatusOnDisbursement(Long caseId){
|
|
|
|
|
+ List<StepVO> stepVOs = stepService.findByStepCodesAndCaseId(Arrays.asList(StepPropertyEnum.PLAN_REPORT.getCode(), StepPropertyEnum.PLAN_AUDIT.getCode()), caseId);
|
|
|
|
|
+ for (StepVO stepVO : stepVOs){
|
|
|
|
|
+ if (stepVO.getStatus().equals(StepEnum.PROCESS.getMsg()))
|
|
|
|
|
+ stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), stepVO.getCode(), caseId);
|
|
|
}
|
|
}
|
|
|
|
|
+ stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.DISBURSE_START.getCode(), caseId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private Boolean PlanIsCleared(Long caseId) {
|
|
private Boolean PlanIsCleared(Long caseId) {
|