|
@@ -1,7 +1,5 @@
|
|
|
package com.loan.system.controller.wechat;
|
|
package com.loan.system.controller.wechat;
|
|
|
|
|
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
-import com.loan.system.context.BaseContext;
|
|
|
|
|
import com.loan.system.domain.dto.ApprovalDTO;
|
|
import com.loan.system.domain.dto.ApprovalDTO;
|
|
|
import com.loan.system.domain.dto.PreApprovalDTO;
|
|
import com.loan.system.domain.dto.PreApprovalDTO;
|
|
|
import com.loan.system.domain.entity.*;
|
|
import com.loan.system.domain.entity.*;
|
|
@@ -20,17 +18,14 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
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.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
|
|
import static com.loan.system.domain.enums.ExceptionEnum.*;
|
|
import static com.loan.system.domain.enums.ExceptionEnum.*;
|
|
|
|
|
|
|
@@ -53,47 +48,56 @@ public class ApprovalController {
|
|
|
private StepService stepService;
|
|
private StepService stepService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private JwtProperties jwtProperties;
|
|
private JwtProperties jwtProperties;
|
|
|
- @Autowired
|
|
|
|
|
- private MessageService messageService;
|
|
|
|
|
// @Autowired
|
|
// @Autowired
|
|
|
// private WxService wxService;
|
|
// private WxService wxService;
|
|
|
|
|
|
|
|
- @GetMapping("preApproval/detail")
|
|
|
|
|
- @ApiOperation("获取预审审详情")
|
|
|
|
|
- @PreAuthorize("@pms.hasAnyRoles('SYSTEM_ADMIN','APPROVER','LEAD_SALES', 'ASSIST_SALES', 'FINANCE', 'BACK_OFFICE')")
|
|
|
|
|
- public Result getPreApprovalDetail(@RequestParam Long caseId) {
|
|
|
|
|
- ApprovalVO approvalVO = new ApprovalVO();
|
|
|
|
|
- StepVO stepVO = stepService.findByStepNameAndCaseId(StepPropertyEnum.PRE_TRIAL.getLabel(), caseId);
|
|
|
|
|
- Map<UserVO,String> decision=new HashMap<>();
|
|
|
|
|
- Map<UserVO,String> comment=new HashMap<>();
|
|
|
|
|
-
|
|
|
|
|
- if (stepVO.getUserId2()!=null){
|
|
|
|
|
- User user=userService.findByIdAndIsDelete(stepVO.getUserId2());
|
|
|
|
|
- ApprovalRecordVO approvalRecordVO = approvalService.findByCaseIdAndIsDeleteAndStepName(caseId, StepPropertyEnum.APPROVAL.getLabel(), user.getId());
|
|
|
|
|
- decision.put(BeanUtil.copyProperties(user,UserVO.class),approvalRecordVO.getDecision());
|
|
|
|
|
- comment.put(BeanUtil.copyProperties(user,UserVO.class),approvalRecordVO.getComments());
|
|
|
|
|
|
|
+ @GetMapping("/loan_case/{id}")
|
|
|
|
|
+ @ApiOperation("获取业务客户信息")
|
|
|
|
|
+ //TODO:给前端展示的VO补充完整
|
|
|
|
|
+ public Result info(@PathVariable Long id) {
|
|
|
|
|
+ log.info("获取业务客户信息: {}", id);
|
|
|
|
|
+ LoanCaseVO loanCase = loanCaseService.findLoanCaseByIdAndIsDelete(id,false);
|
|
|
|
|
+ if(loanCase == null){
|
|
|
|
|
+ log.info("业务客户信息: 空");
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("业务客户信息: {}", loanCase.getCustomer().getId());
|
|
|
|
|
+ CustomerVO customer = customerService.findByCustomerIdAndIsDelete(loanCase.getCustomer().getId(), false);
|
|
|
|
|
+ StepVO step = stepService.findByStepNameAndCaseId(StepPropertyEnum.PRE_TRIAL.getLabel(),id);
|
|
|
|
|
+ //List<Document> documentList = documentService.findDocumentByCaseIdAndIsDelete(customer.getId());
|
|
|
|
|
+ User user1= userService.findByIdAndIsDelete(step.getUserId1());
|
|
|
|
|
+ User user2= userService.findByIdAndIsDelete(step.getUserId2());
|
|
|
|
|
+ LoanCasePreApprovalVo loanCasePreApprovalVo = new LoanCasePreApprovalVo();
|
|
|
|
|
+ if(user1!=null){
|
|
|
|
|
+ loanCasePreApprovalVo.setLead_Sales(user1.getRealName());
|
|
|
|
|
+ }
|
|
|
|
|
+ if(user2!=null){
|
|
|
|
|
+ loanCasePreApprovalVo.setAssist_Sales(user2.getRealName());
|
|
|
}
|
|
}
|
|
|
|
|
+ //TODO 补充业务信息、客户信息
|
|
|
|
|
|
|
|
- return ResultUtil.success("success",approvalVO);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- @PostMapping("/preapproval-assist/pass")
|
|
|
|
|
|
|
+ return ResultUtil.success("success",loanCasePreApprovalVo);
|
|
|
|
|
+ }
|
|
|
|
|
+ @PostMapping("/preapproval-assist/{caseId}/pass")
|
|
|
@PreAuthorize("@pms.hasRole('ASSIST_SALES')")
|
|
@PreAuthorize("@pms.hasRole('ASSIST_SALES')")
|
|
|
@ApiOperation("副业务员审核")
|
|
@ApiOperation("副业务员审核")
|
|
|
- public Result pre_approval_save_primary(@RequestBody PreApprovalDTO preApprovalDTO) {
|
|
|
|
|
- Long userId= BaseContext.getCurrentId();
|
|
|
|
|
|
|
+ public Result pre_approval_save_primary(PreApprovalDTO preApprovalDTO, HttpServletRequest request) {
|
|
|
|
|
+ //请求头根据token获取用户信息
|
|
|
|
|
+ //String token = request.getHeader("Authorization").substring(7); // 去掉"Bearer "前缀
|
|
|
|
|
+ String token = request.getHeader("Authorization");
|
|
|
|
|
+ Long userId=Long.parseLong(JwtUtil.parseJWT(jwtProperties.getUserSecretKey(),token).get("userId").toString());
|
|
|
log.info("用户id: {}", userId);
|
|
log.info("用户id: {}", userId);
|
|
|
User user = userService.findByIdAndIsDelete(userId);
|
|
User user = userService.findByIdAndIsDelete(userId);
|
|
|
log.info("用户: {}", user.getMobile());
|
|
log.info("用户: {}", user.getMobile());
|
|
|
- LoanCase loanCase = loanCaseService.findLoanCaseByIdAndIsDelete(preApprovalDTO.getCaseId(),false);
|
|
|
|
|
- if(loanCase == null||loanCase.getIsDelete()){
|
|
|
|
|
|
|
+ LoanCaseVO loanCase = loanCaseService.findLoanCaseByIdAndIsDelete(preApprovalDTO.getCaseId(),false);
|
|
|
|
|
+ if(loanCase == null){
|
|
|
return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
|
|
return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
|
|
|
}
|
|
}
|
|
|
StepVO step = stepService.findByStepNameAndCaseId(StepPropertyEnum.PRE_TRIAL.getLabel(), preApprovalDTO.getCaseId());
|
|
StepVO step = stepService.findByStepNameAndCaseId(StepPropertyEnum.PRE_TRIAL.getLabel(), preApprovalDTO.getCaseId());
|
|
|
if(step.getUserId2()!=null&&userId!=step.getUserId2()){
|
|
if(step.getUserId2()!=null&&userId!=step.getUserId2()){
|
|
|
return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
|
|
return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
|
|
|
}
|
|
}
|
|
|
- if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
|
|
|
|
|
|
|
+ if(Objects.equals(step.getStatus(), StepEnum.COMPLETED.getMsg())){
|
|
|
return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
|
|
return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
|
|
|
}
|
|
}
|
|
|
ApprovalRecordVO approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(preApprovalDTO.getCaseId(),StepPropertyEnum.PRE_TRIAL.getLabel(),userId);
|
|
ApprovalRecordVO approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(preApprovalDTO.getCaseId(),StepPropertyEnum.PRE_TRIAL.getLabel(),userId);
|
|
@@ -122,17 +126,7 @@ public class ApprovalController {
|
|
|
stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.APPROVAL.getLabel(), preApprovalDTO.getCaseId());
|
|
stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.APPROVAL.getLabel(), preApprovalDTO.getCaseId());
|
|
|
loanCaseService.updateUpdatetimeByIdAndIsDeleted(preApprovalDTO.getCaseId(),false);
|
|
loanCaseService.updateUpdatetimeByIdAndIsDeleted(preApprovalDTO.getCaseId(),false);
|
|
|
//TODO:微信推送预审通过消息和通知下一环节
|
|
//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());
|
|
// wxService.sendTemplateMessage(loanCase.getCustomer().getMobile(),new TemplateMessage());
|
|
|
-
|
|
|
|
|
return ResultUtil.success("success","预审通过");
|
|
return ResultUtil.success("success","预审通过");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -178,26 +172,30 @@ public class ApprovalController {
|
|
|
// return ResultUtil.success("success","审批通过");
|
|
// return ResultUtil.success("success","审批通过");
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
- @PostMapping("/preapproval-records/reject")
|
|
|
|
|
|
|
+ @PostMapping("/preapproval-records/{caseId}/rejection")
|
|
|
@PreAuthorize("@pms.hasAnyRoles('LEAD_SALES','ASSIST_SALES')")
|
|
@PreAuthorize("@pms.hasAnyRoles('LEAD_SALES','ASSIST_SALES')")
|
|
|
@ApiOperation("业务预审拒绝")
|
|
@ApiOperation("业务预审拒绝")
|
|
|
- public Result pre_approval_reject(@RequestBody PreApprovalDTO preApprovalDTO) {
|
|
|
|
|
- Long userId= BaseContext.getCurrentId();
|
|
|
|
|
|
|
+ public Result pre_approval_reject(PreApprovalDTO preApprovalDTO, HttpServletRequest request) {
|
|
|
|
|
+ //请求头根据token获取用户信息
|
|
|
|
|
+ //String token = request.getHeader("Authorization").substring(7); // 去掉"Bearer "前缀
|
|
|
|
|
+ String token = request.getHeader("Authorization");
|
|
|
|
|
+ Long userId=Long.parseLong(JwtUtil.parseJWT(jwtProperties.getUserSecretKey(),token).get("userId").toString());
|
|
|
log.info("用户id: {}", userId);
|
|
log.info("用户id: {}", userId);
|
|
|
User user = userService.findByIdAndIsDelete(userId);
|
|
User user = userService.findByIdAndIsDelete(userId);
|
|
|
log.info("用户: {}", user.getMobile());
|
|
log.info("用户: {}", user.getMobile());
|
|
|
- LoanCase loanCase = loanCaseService.findLoanCaseByIdAndIsDelete(preApprovalDTO.getCaseId(),false);
|
|
|
|
|
|
|
+ LoanCaseVO loanCase = loanCaseService.findLoanCaseByIdAndIsDelete(preApprovalDTO.getCaseId(),false);
|
|
|
|
|
+ if(loanCase == null){
|
|
|
|
|
+ return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
|
|
|
|
|
+ }
|
|
|
StepVO step = stepService.findByStepNameAndCaseId(StepPropertyEnum.PRE_TRIAL.getLabel(), preApprovalDTO.getCaseId());
|
|
StepVO step = stepService.findByStepNameAndCaseId(StepPropertyEnum.PRE_TRIAL.getLabel(), preApprovalDTO.getCaseId());
|
|
|
//判断过去处理人与目前处理人是否一致
|
|
//判断过去处理人与目前处理人是否一致
|
|
|
if(step.getUserId2()!=null&&userId!=step.getUserId2()){
|
|
if(step.getUserId2()!=null&&userId!=step.getUserId2()){
|
|
|
return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
|
|
return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
|
|
|
}
|
|
}
|
|
|
- if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
|
|
|
|
|
|
|
+ if(Objects.equals(step.getStatus(), StepEnum.COMPLETED.getMsg())){
|
|
|
return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
|
|
return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
|
|
|
}
|
|
}
|
|
|
- if(loanCase == null||loanCase.getIsDelete()){
|
|
|
|
|
- return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
ApprovalRecordVO approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(preApprovalDTO.getCaseId(),StepPropertyEnum.PRE_TRIAL.getLabel(),userId);
|
|
ApprovalRecordVO approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(preApprovalDTO.getCaseId(),StepPropertyEnum.PRE_TRIAL.getLabel(),userId);
|
|
|
if(approvalRecord_origin == null) {
|
|
if(approvalRecord_origin == null) {
|
|
|
log.info("没找到对应以前审批记录");
|
|
log.info("没找到对应以前审批记录");
|
|
@@ -218,71 +216,39 @@ public class ApprovalController {
|
|
|
approvalService.updateDecisionByCaseIdAndStepNameAndIsDelete(DecisionEnum.REJECT.getMsg(),preApprovalDTO.getCaseId(),StepPropertyEnum.PRE_TRIAL.getLabel(),preApprovalDTO.getComments(),userId);
|
|
approvalService.updateDecisionByCaseIdAndStepNameAndIsDelete(DecisionEnum.REJECT.getMsg(),preApprovalDTO.getCaseId(),StepPropertyEnum.PRE_TRIAL.getLabel(),preApprovalDTO.getComments(),userId);
|
|
|
}
|
|
}
|
|
|
stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.PRE_TRIAL.getLabel(),userId,preApprovalDTO.getCaseId());
|
|
stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.PRE_TRIAL.getLabel(),userId,preApprovalDTO.getCaseId());
|
|
|
- stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(),StepPropertyEnum.BUSINESS_ACCEPT.getLabel(),preApprovalDTO.getCaseId());
|
|
|
|
|
- stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(),StepPropertyEnum.BUSINESS_ACCEPT_PARENT.getLabel(),preApprovalDTO.getCaseId());
|
|
|
|
|
- stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(),StepPropertyEnum.PRE_TRIAL_PARENT.getLabel(),preApprovalDTO.getCaseId());
|
|
|
|
|
- stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(),StepPropertyEnum.PRE_TRIAL.getLabel(),preApprovalDTO.getCaseId());
|
|
|
|
|
|
|
+ loanCaseService.updateUpdatetimeByIdAndIsDeleted(preApprovalDTO.getCaseId(),false);
|
|
|
|
|
+
|
|
|
|
|
+ stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.BUSINESS_ACCEPT_PARENT.getLabel(), preApprovalDTO.getCaseId());
|
|
|
|
|
+ stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.BUSINESS_ACCEPT.getLabel(), preApprovalDTO.getCaseId());
|
|
|
|
|
+ stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(), StepPropertyEnum.PRE_TRIAL_PARENT.getLabel(), preApprovalDTO.getCaseId());
|
|
|
|
|
+ stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(), StepPropertyEnum.PRE_TRIAL.getLabel(), preApprovalDTO.getCaseId());
|
|
|
loanCaseService.updateUpdatetimeByIdAndIsDeleted(preApprovalDTO.getCaseId(),false);
|
|
loanCaseService.updateUpdatetimeByIdAndIsDeleted(preApprovalDTO.getCaseId(),false);
|
|
|
//TODO:微信推送预审拒绝消息和通知下一环节
|
|
//TODO:微信推送预审拒绝消息和通知下一环节
|
|
|
-// SysMessage message = new SysMessage();
|
|
|
|
|
-// message.setMobile(null);
|
|
|
|
|
-// message.setUserRole("");
|
|
|
|
|
-// message.setMessageTitle("");
|
|
|
|
|
-// message.setMessageContent("");
|
|
|
|
|
-// message.setStepName("");
|
|
|
|
|
-// message.setRelatedId(caseId);
|
|
|
|
|
-// message.setRelatedType("");
|
|
|
|
|
-// messageService.addMessage(message);
|
|
|
|
|
// wxService.sendTemplateMessage(loanCase.getCustomer().getMobile(),new TemplateMessage());
|
|
// wxService.sendTemplateMessage(loanCase.getCustomer().getMobile(),new TemplateMessage());
|
|
|
-
|
|
|
|
|
return ResultUtil.success("success","预审拒绝");
|
|
return ResultUtil.success("success","预审拒绝");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @GetMapping("approval/detail")
|
|
|
|
|
- @ApiOperation("获取审批详情")
|
|
|
|
|
- @PreAuthorize("@pms.hasAnyRoles('SYSTEM_ADMIN','APPROVER','LEAD_SALES', 'ASSIST_SALES', 'FINANCE', 'BACK_OFFICE')")
|
|
|
|
|
- public Result getApprovalDetail(@RequestParam Long caseId) {
|
|
|
|
|
- ApprovalVO approvalVO = new ApprovalVO();
|
|
|
|
|
- StepVO stepVO = stepService.findByStepNameAndCaseId(StepPropertyEnum.APPROVAL.getLabel(), caseId);
|
|
|
|
|
- Map<UserVO,String> decision=new HashMap<>();
|
|
|
|
|
- Map<UserVO,String> comment=new HashMap<>();
|
|
|
|
|
-
|
|
|
|
|
- if (stepVO.getUserId1()!=null){
|
|
|
|
|
- User user=userService.findByIdAndIsDelete(stepVO.getUserId1());
|
|
|
|
|
- ApprovalRecordVO approvalRecordVO = approvalService.findByCaseIdAndIsDeleteAndStepName(caseId, StepPropertyEnum.APPROVAL.getLabel(), user.getId());
|
|
|
|
|
- decision.put(BeanUtil.copyProperties(user,UserVO.class),approvalRecordVO.getDecision());
|
|
|
|
|
- comment.put(BeanUtil.copyProperties(user,UserVO.class),approvalRecordVO.getComments());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (stepVO.getUserId2()!=null){
|
|
|
|
|
- User user=userService.findByIdAndIsDelete(stepVO.getUserId2());
|
|
|
|
|
- ApprovalRecordVO approvalRecordVO = approvalService.findByCaseIdAndIsDeleteAndStepName(caseId, StepPropertyEnum.APPROVAL.getLabel(), user.getId());
|
|
|
|
|
- decision.put(BeanUtil.copyProperties(user,UserVO.class),approvalRecordVO.getDecision());
|
|
|
|
|
- comment.put(BeanUtil.copyProperties(user,UserVO.class),approvalRecordVO.getComments());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return ResultUtil.success("success",approvalVO);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @PostMapping("/approval/pass")
|
|
|
|
|
|
|
+ @PostMapping("/approval/{caseId}/pass")
|
|
|
@PreAuthorize("@pms.hasRole('APPROVER')")
|
|
@PreAuthorize("@pms.hasRole('APPROVER')")
|
|
|
@ApiOperation("业务审批通过")
|
|
@ApiOperation("业务审批通过")
|
|
|
- public Result approval_pass(@RequestBody ApprovalDTO approvalDTO) {
|
|
|
|
|
- Long userId= BaseContext.getCurrentId();
|
|
|
|
|
|
|
+ public Result approval_pass(ApprovalDTO approvalDTO, HttpServletRequest request) {
|
|
|
|
|
+ String token = request.getHeader("Authorization");
|
|
|
|
|
+ Long userId=Long.parseLong(JwtUtil.parseJWT(jwtProperties.getUserSecretKey(),token).get("userId").toString());
|
|
|
log.info("用户id: {}", userId);
|
|
log.info("用户id: {}", userId);
|
|
|
//审批业务逻辑
|
|
//审批业务逻辑
|
|
|
- LoanCase loanCase = loanCaseService.findLoanCaseByIdAndIsDelete(approvalDTO.getCaseId(), false);
|
|
|
|
|
|
|
+ LoanCaseVO loanCase = loanCaseService.findLoanCaseByIdAndIsDelete(approvalDTO.getCaseId(), false);
|
|
|
|
|
+ if(loanCase == null){
|
|
|
|
|
+ return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
|
|
|
|
|
+ }
|
|
|
StepVO step = stepService.findByStepNameAndCaseId(StepPropertyEnum.APPROVAL.getLabel(), approvalDTO.getCaseId());
|
|
StepVO step = stepService.findByStepNameAndCaseId(StepPropertyEnum.APPROVAL.getLabel(), approvalDTO.getCaseId());
|
|
|
//判断过去处理人与目前处理人是否一致
|
|
//判断过去处理人与目前处理人是否一致
|
|
|
- if(step.getUserId1()!=null&&step.getUserId2()!=null&&userId != step.getUserId2()&&userId!=step.getUserId1()){
|
|
|
|
|
|
|
+ if(step.getUserId1()!=null&&step.getUserId2()!=null&& !userId.equals(step.getUserId2()) && !userId.equals(step.getUserId1())){
|
|
|
return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
|
|
return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
|
|
|
}
|
|
}
|
|
|
- if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
|
|
|
|
|
|
|
+ if(Objects.equals(step.getStatus(), StepEnum.COMPLETED.getMsg())){
|
|
|
return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
|
|
return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
|
|
|
}
|
|
}
|
|
|
- if(loanCase == null || loanCase.getIsDelete()){
|
|
|
|
|
- return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
ApprovalRecordVO approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),userId);
|
|
ApprovalRecordVO approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),userId);
|
|
|
if(approvalRecord_origin == null) {
|
|
if(approvalRecord_origin == null) {
|
|
|
log.info("没找到对应以前审批记录");
|
|
log.info("没找到对应以前审批记录");
|
|
@@ -304,13 +270,13 @@ public class ApprovalController {
|
|
|
}
|
|
}
|
|
|
if(step.getUserId1()== null){
|
|
if(step.getUserId1()== null){
|
|
|
stepService.updateUserId1ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
|
|
stepService.updateUserId1ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
|
|
|
- }else if(step.getUserId2()== null){
|
|
|
|
|
|
|
+ }else if(step.getUserId2()== null&&!userId.equals(step.getUserId1())){
|
|
|
stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
|
|
stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
|
|
|
}
|
|
}
|
|
|
if(step.getUserId1()!=null&&step.getUserId2()!=null){
|
|
if(step.getUserId1()!=null&&step.getUserId2()!=null){
|
|
|
ApprovalRecordVO approvalRecord_user1 = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),step.getUserId1());
|
|
ApprovalRecordVO approvalRecord_user1 = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),step.getUserId1());
|
|
|
ApprovalRecordVO approvalRecord_user2 = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),step.getUserId2());
|
|
ApprovalRecordVO approvalRecord_user2 = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),step.getUserId2());
|
|
|
- if(approvalRecord_user1.getDecision() == DecisionEnum.PASS.getMsg()&&approvalRecord_user2.getDecision() == DecisionEnum.PASS.getMsg()){
|
|
|
|
|
|
|
+ if(Objects.equals(approvalRecord_user1.getDecision(), DecisionEnum.PASS.getMsg()) && Objects.equals(approvalRecord_user2.getDecision(), DecisionEnum.PASS.getMsg())){
|
|
|
stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(),StepPropertyEnum.APPROVAL_PARENT.getLabel(),approvalDTO.getCaseId());
|
|
stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(),StepPropertyEnum.APPROVAL_PARENT.getLabel(),approvalDTO.getCaseId());
|
|
|
stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(),StepPropertyEnum.APPROVAL.getLabel(),approvalDTO.getCaseId());
|
|
stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(),StepPropertyEnum.APPROVAL.getLabel(),approvalDTO.getCaseId());
|
|
|
stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(),StepPropertyEnum.CONTRACT_SIGN_PARENT.getLabel(),approvalDTO.getCaseId());
|
|
stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(),StepPropertyEnum.CONTRACT_SIGN_PARENT.getLabel(),approvalDTO.getCaseId());
|
|
@@ -325,15 +291,16 @@ public class ApprovalController {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @PostMapping("/approval/reject")
|
|
|
|
|
|
|
+ @PostMapping("/approval/{caseId}/rejection")
|
|
|
@PreAuthorize("@pms.hasRole('APPROVER')")
|
|
@PreAuthorize("@pms.hasRole('APPROVER')")
|
|
|
@ApiOperation("业务审批拒绝")
|
|
@ApiOperation("业务审批拒绝")
|
|
|
- public Result approval_reject(@RequestBody ApprovalDTO approvalDTO) {
|
|
|
|
|
- Long userId= BaseContext.getCurrentId();
|
|
|
|
|
|
|
+ public Result approval_reject(ApprovalDTO approvalDTO, HttpServletRequest request) {
|
|
|
|
|
+ String token = request.getHeader("Authorization");
|
|
|
|
|
+ Long userId=Long.parseLong(JwtUtil.parseJWT(jwtProperties.getUserSecretKey(),token).get("userId").toString());
|
|
|
log.info("用户id: {}", userId);
|
|
log.info("用户id: {}", userId);
|
|
|
//审批业务逻辑
|
|
//审批业务逻辑
|
|
|
- LoanCase loanCase = loanCaseService.findLoanCaseByIdAndIsDelete(approvalDTO.getCaseId(),false);
|
|
|
|
|
- if(loanCase == null||loanCase.getIsDelete()){
|
|
|
|
|
|
|
+ LoanCaseVO loanCase = loanCaseService.findLoanCaseByIdAndIsDelete(approvalDTO.getCaseId(),false);
|
|
|
|
|
+ if(loanCase == null){
|
|
|
return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
|
|
return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
|
|
|
}
|
|
}
|
|
|
StepVO step = stepService.findByStepNameAndCaseId(StepPropertyEnum.APPROVAL.getLabel(), approvalDTO.getCaseId());
|
|
StepVO step = stepService.findByStepNameAndCaseId(StepPropertyEnum.APPROVAL.getLabel(), approvalDTO.getCaseId());
|
|
@@ -341,7 +308,7 @@ public class ApprovalController {
|
|
|
if(step.getUserId1()!=null&&step.getUserId2()!=null&&userId!=step.getUserId2()&&userId!=step.getUserId1()){
|
|
if(step.getUserId1()!=null&&step.getUserId2()!=null&&userId!=step.getUserId2()&&userId!=step.getUserId1()){
|
|
|
return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
|
|
return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
|
|
|
}
|
|
}
|
|
|
- if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
|
|
|
|
|
|
|
+ if(Objects.equals(step.getStatus(), StepEnum.COMPLETED.getMsg())){
|
|
|
return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
|
|
return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
|
|
|
}
|
|
}
|
|
|
//审批记录处理
|
|
//审批记录处理
|
|
@@ -366,7 +333,7 @@ public class ApprovalController {
|
|
|
}
|
|
}
|
|
|
if(step.getUserId1()== null){
|
|
if(step.getUserId1()== null){
|
|
|
stepService.updateUserId1ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
|
|
stepService.updateUserId1ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
|
|
|
- }else if(step.getUserId2()== null){
|
|
|
|
|
|
|
+ }else if(step.getUserId2()== null&&!userId.equals(step.getUserId1())){
|
|
|
stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
|
|
stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
|
|
|
}
|
|
}
|
|
|
//更新环节状态
|
|
//更新环节状态
|
|
@@ -380,23 +347,24 @@ public class ApprovalController {
|
|
|
|
|
|
|
|
return ResultUtil.success("success","审批驳回");
|
|
return ResultUtil.success("success","审批驳回");
|
|
|
}
|
|
}
|
|
|
- @PostMapping("/approval/terminate")
|
|
|
|
|
|
|
+ @PostMapping("/approval/{caseId}/termination")
|
|
|
@PreAuthorize("@pms.hasRole('APPROVER')")
|
|
@PreAuthorize("@pms.hasRole('APPROVER')")
|
|
|
@ApiOperation("业务审批终结")
|
|
@ApiOperation("业务审批终结")
|
|
|
- public Result approval_end(@RequestBody ApprovalDTO approvalDTO) {
|
|
|
|
|
- Long userId= BaseContext.getCurrentId();
|
|
|
|
|
|
|
+ public Result approval_end(ApprovalDTO approvalDTO, HttpServletRequest request) {
|
|
|
|
|
+ String token = request.getHeader("Authorization");
|
|
|
|
|
+ Long userId=Long.parseLong(JwtUtil.parseJWT(jwtProperties.getUserSecretKey(),token).get("userId").toString());
|
|
|
log.info("用户id: {}", userId);
|
|
log.info("用户id: {}", userId);
|
|
|
//审批业务逻辑
|
|
//审批业务逻辑
|
|
|
- LoanCase loanCase = loanCaseService.findLoanCaseByIdAndIsDelete(approvalDTO.getCaseId(),false);
|
|
|
|
|
- if(loanCase == null||loanCase.getIsDelete()){
|
|
|
|
|
|
|
+ LoanCaseVO loanCase = loanCaseService.findLoanCaseByIdAndIsDelete(approvalDTO.getCaseId(),false);
|
|
|
|
|
+ if(loanCase == null){
|
|
|
return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
|
|
return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
|
|
|
}
|
|
}
|
|
|
StepVO step = stepService.findByStepNameAndCaseId(StepPropertyEnum.APPROVAL.getLabel(), approvalDTO.getCaseId());
|
|
StepVO step = stepService.findByStepNameAndCaseId(StepPropertyEnum.APPROVAL.getLabel(), approvalDTO.getCaseId());
|
|
|
//判断过去处理人与目前处理人是否一致
|
|
//判断过去处理人与目前处理人是否一致
|
|
|
- if(step.getUserId1()!=null&&step.getUserId2()!=null&&userId!=step.getUserId2()&&userId!=step.getUserId1()){
|
|
|
|
|
|
|
+ if(step.getUserId1()!=null&&step.getUserId2()!=null&& !userId.equals(step.getUserId2()) && !userId.equals(step.getUserId1())){
|
|
|
return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
|
|
return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
|
|
|
}
|
|
}
|
|
|
- if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
|
|
|
|
|
|
|
+ if(Objects.equals(step.getStatus(), StepEnum.COMPLETED.getMsg())){
|
|
|
return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
|
|
return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
|
|
|
}
|
|
}
|
|
|
//审批记录处理
|
|
//审批记录处理
|
|
@@ -421,7 +389,7 @@ public class ApprovalController {
|
|
|
}
|
|
}
|
|
|
if(step.getUserId1()== null){
|
|
if(step.getUserId1()== null){
|
|
|
stepService.updateUserId1ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
|
|
stepService.updateUserId1ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
|
|
|
- }else if(step.getUserId2()== null){
|
|
|
|
|
|
|
+ }else if(step.getUserId2()== null&&!userId.equals(step.getUserId1())){
|
|
|
stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
|
|
stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
|
|
|
}
|
|
}
|
|
|
//更新项目和环节状态 作逻辑删除
|
|
//更新项目和环节状态 作逻辑删除
|
|
@@ -432,7 +400,7 @@ public class ApprovalController {
|
|
|
}
|
|
}
|
|
|
//TODO微信推送审批驳回消息和通知重新受理(到业务受理)
|
|
//TODO微信推送审批驳回消息和通知重新受理(到业务受理)
|
|
|
|
|
|
|
|
- return ResultUtil.success("success","审批驳回");
|
|
|
|
|
|
|
+ return ResultUtil.success("success","业务终结");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|