Bladeren bron

审核完成

DESKTOP-2HCHTFV\Xu 5 maanden geleden
bovenliggende
commit
6dcc951108

+ 2 - 0
src/main/java/com/loan/system/config/WebMvcConfiguration.java

@@ -102,6 +102,8 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport {
         log.info("设置静态资源映射");
         registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/");
         registry.addResourceHandler("/files/**").addResourceLocations("classpath:/META-INF/resources/file_store/");
+        registry.addResourceHandler("/webjars/**")
+                .addResourceLocations("classpath:/META-INF/resources/webjars/");
     }
 
     /*

+ 379 - 379
src/main/java/com/loan/system/controller/ApprovalController.java

@@ -1,134 +1,176 @@
-package com.loan.system.controller;
-
-import com.loan.system.domain.dto.ApprovalDTO;
-import com.loan.system.domain.dto.PreApprovalDTO;
-import com.loan.system.domain.entity.*;
-import com.loan.system.domain.enums.DecisionEnum;
-import com.loan.system.domain.enums.StepEnum;
-import com.loan.system.domain.enums.StepPropertyEnum;
-import com.loan.system.domain.pojo.Result;
-import com.loan.system.domain.vo.LoanCasePreApprovalVo;
-import com.loan.system.properties.JwtProperties;
-import com.loan.system.service.*;
-import com.loan.system.service.Impl.UserServiceImpl;
-import com.loan.system.utils.JwtUtil;
-import com.loan.system.utils.ResultUtil;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletRequest;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.List;
-
-import static com.loan.system.domain.enums.ExceptionEnum.*;
-
-@RestController
-@RequestMapping("/User")
-@Api(tags = "业务审核接口")
-public class ApprovalController {
-    private static final Logger log = LoggerFactory.getLogger(UserServiceImpl.class);
-    @Autowired
-    private UserService userService;
-    @Autowired
-    private CustomerService customerService;
-    @Autowired
-    private LoanCaseService  loanCaseService;
-    @Autowired
-    private ApprovalService approvalService;
-    @Autowired
-    private DocumentService documentService;
-    @Autowired
-    private StepService stepService;
-    @Autowired
-    private JwtProperties jwtProperties;
-    @Autowired
-    private WxService wxService;
-
-    @GetMapping("/loan_case/{id}")
-    @ApiOperation("获取业务客户信息")
-    //TODO:给前端展示的VO补充完整
-    public Result info(@PathVariable Long id) {
-        log.info("获取业务客户信息: {}", id);
-        LoanCase loanCase = loanCaseService.findByIdAndIsDelete(id);
-        Customer customer = customerService.findByIdAndIsDelete(loanCase.getCustomerId());
-        Step 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",loanCasePreApprovalVo);
-    }
-    @PostMapping("/preapproval-assist/{caseId}/pass")
-    @PreAuthorize("@pms.hasRole('ASSIST_SALES')")
-    @ApiOperation("副业务员审核")
-    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);
-        User user = userService.findByIdAndIsDelete(userId);
-        log.info("用户: {}", user.getMobile());
-        LoanCase loanCase = loanCaseService.findByIdAndIsDelete(preApprovalDTO.getCaseId());
-        if(loanCase == null||loanCase.getIsDelete()){
-            return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
-        }
-        Step step = stepService.findByStepNameAndCaseId(StepPropertyEnum.PRE_TRIAL.getLabel(), preApprovalDTO.getCaseId());
-        if(step.getUserId2()!=null&&userId!=step.getUserId2()){
-            return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
-        }
-        if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
-            return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
-        }
-        ApprovalRecord approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(preApprovalDTO.getCaseId(),StepPropertyEnum.PRE_TRIAL.getLabel(),userId);
-        if (approvalRecord_origin == null) {
-            // 创建审批记录
-            ApprovalRecord approvalRecord = new ApprovalRecord();
-            approvalRecord.setCaseId(preApprovalDTO.getCaseId());
-            approvalRecord.setStepName(StepPropertyEnum.PRE_TRIAL.getLabel());
-            approvalRecord.setApproverId(user.getId());
-            approvalRecord.setDecision(DecisionEnum.PASS.getMsg());
-            approvalRecord.setComments(preApprovalDTO.getComments());
-            approvalRecord.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-            approvalRecord.setUpdateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-            approvalRecord.setIsDelete(false);
-            // 保存到数据库
-            approvalService.save(approvalRecord);
-            stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.PRE_TRIAL.getLabel(), user.getId(), preApprovalDTO.getCaseId());
-        }else {
-            approvalService.updateDecisionByCaseIdAndStepNameAndIsDelete(DecisionEnum.PASS.getMsg(), preApprovalDTO.getCaseId(), StepPropertyEnum.PRE_TRIAL.getLabel(), preApprovalDTO.getComments(), userId);
-        }
-        stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.PRE_TRIAL.getLabel(),userId,preApprovalDTO.getCaseId());
-        //更新步骤状态
-        stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.PRE_TRIAL_PARENT.getLabel(), preApprovalDTO.getCaseId());
-        stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.PRE_TRIAL.getLabel(), preApprovalDTO.getCaseId());
-        stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.APPROVAL_PARENT.getLabel(), preApprovalDTO.getCaseId());
-        stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.APPROVAL.getLabel(), preApprovalDTO.getCaseId());
-        loanCaseService.updateUpdatetimeByIdAndIsDeleted(preApprovalDTO.getCaseId(),false);
-        //TODO:微信推送预审通过消息和通知下一环节
-//        wxService.sendTemplateMessage(loanCase.getCustomer().getMobile(),new TemplateMessage());
-        return ResultUtil.success("success","预审通过");
-    }
-
-//    @PostMapping("/approval-lead/{caseId}/pass")
-//    @PreAuthorize("@pms.hasRole('LEAD_SALES')")
-//    @ApiOperation("主业务员审核")
-//    public Result pre_approval_save_assist(PreApprovalDTO preApprovalDTO, HttpServletRequest request) {
+//package com.loan.system.controller;
+//
+//import com.loan.system.domain.dto.ApprovalDTO;
+//import com.loan.system.domain.dto.PreApprovalDTO;
+//import com.loan.system.domain.entity.*;
+//import com.loan.system.domain.enums.DecisionEnum;
+//import com.loan.system.domain.enums.StepEnum;
+//import com.loan.system.domain.enums.StepPropertyEnum;
+//import com.loan.system.domain.pojo.Result;
+//import com.loan.system.domain.vo.LoanCasePreApprovalVo;
+//import com.loan.system.properties.JwtProperties;
+//import com.loan.system.service.*;
+//import com.loan.system.service.Impl.UserServiceImpl;
+//import com.loan.system.utils.JwtUtil;
+//import com.loan.system.utils.ResultUtil;
+//import io.swagger.annotations.Api;
+//import io.swagger.annotations.ApiOperation;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.security.access.prepost.PreAuthorize;
+//import org.springframework.web.bind.annotation.*;
+//
+//import javax.servlet.http.HttpServletRequest;
+//import java.time.LocalDateTime;
+//import java.time.format.DateTimeFormatter;
+//import java.util.List;
+//
+//import static com.loan.system.domain.enums.ExceptionEnum.*;
+//
+//@RestController
+//@RequestMapping("/User")
+//@Api(tags = "业务审核接口")
+//public class ApprovalController {
+//    private static final Logger log = LoggerFactory.getLogger(UserServiceImpl.class);
+//    @Autowired
+//    private UserService userService;
+//    @Autowired
+//    private CustomerService customerService;
+//    @Autowired
+//    private LoanCaseService  loanCaseService;
+//    @Autowired
+//    private ApprovalService approvalService;
+//    @Autowired
+//    private DocumentService documentService;
+//    @Autowired
+//    private StepService stepService;
+//    @Autowired
+//    private JwtProperties jwtProperties;
+//    @Autowired
+//    private WxService wxService;
+//
+//    @GetMapping("/loan_case/{id}")
+//    @ApiOperation("获取业务客户信息")
+//    //TODO:给前端展示的VO补充完整
+//    public Result info(@PathVariable Long id) {
+//        log.info("获取业务客户信息: {}", id);
+//        LoanCase loanCase = loanCaseService.findByIdAndIsDelete(id);
+//        Customer customer = customerService.findByIdAndIsDelete(loanCase.getCustomerId());
+//        Step 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",loanCasePreApprovalVo);
+//    }
+//    @PostMapping("/preapproval-assist/{caseId}/pass")
+//    @PreAuthorize("@pms.hasRole('ASSIST_SALES')")
+//    @ApiOperation("副业务员审核")
+//    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);
+//        User user = userService.findByIdAndIsDelete(userId);
+//        log.info("用户: {}", user.getMobile());
+//        LoanCase loanCase = loanCaseService.findByIdAndIsDelete(preApprovalDTO.getCaseId());
+//        if(loanCase == null||loanCase.getIsDelete()){
+//            return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
+//        }
+//        Step step = stepService.findByStepNameAndCaseId(StepPropertyEnum.PRE_TRIAL.getLabel(), preApprovalDTO.getCaseId());
+//        if(step.getUserId2()!=null&&userId!=step.getUserId2()){
+//            return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
+//        }
+//        if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
+//            return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
+//        }
+//        ApprovalRecord approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(preApprovalDTO.getCaseId(),StepPropertyEnum.PRE_TRIAL.getLabel(),userId);
+//        if (approvalRecord_origin == null) {
+//            // 创建审批记录
+//            ApprovalRecord approvalRecord = new ApprovalRecord();
+//            approvalRecord.setCaseId(preApprovalDTO.getCaseId());
+//            approvalRecord.setStepName(StepPropertyEnum.PRE_TRIAL.getLabel());
+//            approvalRecord.setApproverId(user.getId());
+//            approvalRecord.setDecision(DecisionEnum.PASS.getMsg());
+//            approvalRecord.setComments(preApprovalDTO.getComments());
+//            approvalRecord.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+//            approvalRecord.setUpdateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+//            approvalRecord.setIsDelete(false);
+//            // 保存到数据库
+//            approvalService.save(approvalRecord);
+//            stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.PRE_TRIAL.getLabel(), user.getId(), preApprovalDTO.getCaseId());
+//        }else {
+//            approvalService.updateDecisionByCaseIdAndStepNameAndIsDelete(DecisionEnum.PASS.getMsg(), preApprovalDTO.getCaseId(), StepPropertyEnum.PRE_TRIAL.getLabel(), preApprovalDTO.getComments(), userId);
+//        }
+//        stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.PRE_TRIAL.getLabel(),userId,preApprovalDTO.getCaseId());
+//        //更新步骤状态
+//        stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.PRE_TRIAL_PARENT.getLabel(), preApprovalDTO.getCaseId());
+//        stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.PRE_TRIAL.getLabel(), preApprovalDTO.getCaseId());
+//        stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.APPROVAL_PARENT.getLabel(), preApprovalDTO.getCaseId());
+//        stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.APPROVAL.getLabel(), preApprovalDTO.getCaseId());
+//        loanCaseService.updateUpdatetimeByIdAndIsDeleted(preApprovalDTO.getCaseId(),false);
+//        //TODO:微信推送预审通过消息和通知下一环节
+////        wxService.sendTemplateMessage(loanCase.getCustomer().getMobile(),new TemplateMessage());
+//        return ResultUtil.success("success","预审通过");
+//    }
+//
+////    @PostMapping("/approval-lead/{caseId}/pass")
+////    @PreAuthorize("@pms.hasRole('LEAD_SALES')")
+////    @ApiOperation("主业务员审核")
+////    public Result pre_approval_save_assist(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);
+////        User user = userService.findByIdAndIsDelete(userId);
+////        log.info("用户: {}", user.getMobile());
+////        LoanCase loanCase = loanCaseService.findByIdAndIsDelete(preApprovalDTO.getCaseId());
+////        if(loanCase == null){
+////            return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
+////        }
+////        // TODO: 使用userId进行后续操作
+////        // 创建新的审批记录
+////        ApprovalRecord approvalRecord = new ApprovalRecord();
+////        approvalRecord.setCaseId(preApprovalDTO.getCaseId());
+////        approvalRecord.setStepName(StepPropertyEnum.PRE_TRIAL.getLabel());
+////        approvalRecord.setApproverId(userId);
+////        approvalRecord.setDecision(DecisionEnum.PASS.getMsg());
+////        approvalRecord.setComments(preApprovalDTO.getComments());
+////        approvalRecord.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+////        approvalRecord.setUpdateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+////        approvalRecord.setIsDelete(false);
+////        // 保存到数据库
+////        approvalService.save(approvalRecord);
+////        stepService.updateUserId1ByCaseIdAndStepName(StepPropertyEnum.PRE_TRIAL.getLabel(),userId,preApprovalDTO.getCaseId());
+////        Step step = stepService.findByStepNameAndCaseId(StepPropertyEnum.PRE_TRIAL.getLabel(),preApprovalDTO.getCaseId());
+////        if(step.getUserId1()!=null && step.getUserId2()!=null){
+////            stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.PRE_TRIAL_PARENT.getLabel(),preApprovalDTO.getCaseId());
+////            stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.PRE_TRIAL.getLabel(),preApprovalDTO.getCaseId());
+////            stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.APPROVAL_PARENT.getLabel(),preApprovalDTO.getCaseId());
+////            stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.APPROVAL.getLabel(),preApprovalDTO.getCaseId());
+////            //TODO: 添加业务逻辑 ,通知下一个环节审批人
+////        }
+////        log.info("业务id: {}", preApprovalDTO.getCaseId());
+////        loanCaseService.updateUpdatetimeByIdAndIsDeleted(preApprovalDTO.getCaseId(),false);
+////        return ResultUtil.success("success","审批通过");
+////    }
+//
+//    @PostMapping("/preapproval-records/{caseId}/reject")
+//    @PreAuthorize("@pms.hasAnyRoles('LEAD_SALES','ASSIST_SALES')")
+//    @ApiOperation("业务预审拒绝")
+//    public Result pre_approval_reject(PreApprovalDTO preApprovalDTO, HttpServletRequest request) {
 //        //请求头根据token获取用户信息
 //        //String token = request.getHeader("Authorization").substring(7); // 去掉"Bearer "前缀
 //        String token = request.getHeader("Authorization");
@@ -137,257 +179,215 @@ public class ApprovalController {
 //        User user = userService.findByIdAndIsDelete(userId);
 //        log.info("用户: {}", user.getMobile());
 //        LoanCase loanCase = loanCaseService.findByIdAndIsDelete(preApprovalDTO.getCaseId());
-//        if(loanCase == null){
+//        Step step = stepService.findByStepNameAndCaseId(StepPropertyEnum.PRE_TRIAL.getLabel(), preApprovalDTO.getCaseId());
+//        //判断过去处理人与目前处理人是否一致
+//        if(step.getUserId2()!=null&&userId!=step.getUserId2()){
+//            return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
+//        }
+//        if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
+//            return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
+//        }
+//        if(loanCase == null||loanCase.getIsDelete()){
 //            return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
 //        }
-//        // TODO: 使用userId进行后续操作
-//        // 创建新的审批记录
-//        ApprovalRecord approvalRecord = new ApprovalRecord();
-//        approvalRecord.setCaseId(preApprovalDTO.getCaseId());
-//        approvalRecord.setStepName(StepPropertyEnum.PRE_TRIAL.getLabel());
-//        approvalRecord.setApproverId(userId);
-//        approvalRecord.setDecision(DecisionEnum.PASS.getMsg());
-//        approvalRecord.setComments(preApprovalDTO.getComments());
-//        approvalRecord.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-//        approvalRecord.setUpdateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-//        approvalRecord.setIsDelete(false);
-//        // 保存到数据库
-//        approvalService.save(approvalRecord);
-//        stepService.updateUserId1ByCaseIdAndStepName(StepPropertyEnum.PRE_TRIAL.getLabel(),userId,preApprovalDTO.getCaseId());
-//        Step step = stepService.findByStepNameAndCaseId(StepPropertyEnum.PRE_TRIAL.getLabel(),preApprovalDTO.getCaseId());
-//        if(step.getUserId1()!=null && step.getUserId2()!=null){
-//            stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.PRE_TRIAL_PARENT.getLabel(),preApprovalDTO.getCaseId());
-//            stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.PRE_TRIAL.getLabel(),preApprovalDTO.getCaseId());
-//            stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.APPROVAL_PARENT.getLabel(),preApprovalDTO.getCaseId());
-//            stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.APPROVAL.getLabel(),preApprovalDTO.getCaseId());
-//            //TODO: 添加业务逻辑 ,通知下一个环节审批人
+//        ApprovalRecord approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(preApprovalDTO.getCaseId(),StepPropertyEnum.PRE_TRIAL.getLabel(),userId);
+//        if(approvalRecord_origin == null) {
+//            log.info("没找到对应以前审批记录");
+//            // 创建审批记录
+//            ApprovalRecord approvalRecord = new ApprovalRecord();
+//            approvalRecord.setCaseId(preApprovalDTO.getCaseId());
+//            approvalRecord.setStepName(StepPropertyEnum.PRE_TRIAL.getLabel());
+//            approvalRecord.setApproverId(userId);
+//            approvalRecord.setDecision(DecisionEnum.REJECT.getMsg());
+//            approvalRecord.setComments(preApprovalDTO.getComments());
+//            approvalRecord.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+//            approvalRecord.setUpdateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+//            approvalRecord.setIsDelete(false);
+//            // 保存到数据库
+//            approvalService.save(approvalRecord);
+//        }else{
+//            log.info("找到对应以前审批记录");
+//            approvalService.updateDecisionByCaseIdAndStepNameAndIsDelete(DecisionEnum.REJECT.getMsg(),preApprovalDTO.getCaseId(),StepPropertyEnum.PRE_TRIAL.getLabel(),preApprovalDTO.getComments(),userId);
 //        }
-//        log.info("业务id: {}", preApprovalDTO.getCaseId());
+//        stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.PRE_TRIAL.getLabel(),userId,preApprovalDTO.getCaseId());
 //        loanCaseService.updateUpdatetimeByIdAndIsDeleted(preApprovalDTO.getCaseId(),false);
+//        //TODO:微信推送预审拒绝消息和通知下一环节
+////        wxService.sendTemplateMessage(loanCase.getCustomer().getMobile(),new TemplateMessage());
+//        return ResultUtil.success("success","预审拒绝");
+//    }
+//
+//    @PostMapping("/approval/{caseId}/pass")
+//    @PreAuthorize("@pms.hasRole('APPROVER')")
+//    @ApiOperation("业务审批通过")
+//    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);
+//        //审批业务逻辑
+//        LoanCase loanCase = loanCaseService.findByIdAndIsDelete(approvalDTO.getCaseId());
+//        Step step = stepService.findByStepNameAndCaseId(StepPropertyEnum.APPROVAL.getLabel(), approvalDTO.getCaseId());
+//        //判断过去处理人与目前处理人是否一致
+//        if(step.getUserId1()!=null&&step.getUserId2()!=null&&userId!=step.getUserId2()&&userId!=step.getUserId1()){
+//            return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
+//        }
+//        if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
+//            return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
+//        }
+//        if(loanCase == null||loanCase.getIsDelete()){
+//            return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
+//        }
+//        ApprovalRecord approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),userId);
+//        if(approvalRecord_origin == null) {
+//            log.info("没找到对应以前审批记录");
+//            // 创建审批记录
+//            ApprovalRecord approvalRecord = new ApprovalRecord();
+//            approvalRecord.setCaseId(approvalDTO.getCaseId());
+//            approvalRecord.setStepName(StepPropertyEnum.APPROVAL.getLabel());
+//            approvalRecord.setApproverId(userId);
+//            approvalRecord.setDecision(DecisionEnum.PASS.getMsg());
+//            approvalRecord.setComments(approvalDTO.getComments());
+//            approvalRecord.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+//            approvalRecord.setUpdateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+//            approvalRecord.setIsDelete(false);
+//            // 保存到数据库
+//            approvalService.save(approvalRecord);
+//        }else{
+//            log.info("找到对应以前审批记录");
+//            approvalService.updateDecisionByCaseIdAndStepNameAndIsDelete(DecisionEnum.PASS.getMsg(),approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),approvalDTO.getComments(),userId);
+//        }
+//        if(step.getUserId1()== null){
+//            stepService.updateUserId1ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
+//        }else if(step.getUserId2()== null){
+//            stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
+//        }
+//        if(step.getUserId1()!=null&&step.getUserId2()!=null){
+//            ApprovalRecord approvalRecord_user1 = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),step.getUserId1());
+//            ApprovalRecord approvalRecord_user2 = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),step.getUserId2());
+//            if(approvalRecord_user1.getDecision() == DecisionEnum.PASS.getMsg()&&approvalRecord_user2.getDecision() == DecisionEnum.PASS.getMsg()){
+//                stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(),StepPropertyEnum.APPROVAL_PARENT.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.getLabel(),approvalDTO.getCaseId());
+//                //TODO微信推送审批通过消息和通知下一环节
+//            }
+//        }else{
+//            //TODO微信推送另一个审批人审批
+//        }
+//
 //        return ResultUtil.success("success","审批通过");
+//
+//    }
+//
+//    @PostMapping("/approval/{caseId}/reject")
+//    @PreAuthorize("@pms.hasRole('APPROVER')")
+//    @ApiOperation("业务审批拒绝")
+//    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);
+//        //审批业务逻辑
+//        LoanCase loanCase = loanCaseService.findByIdAndIsDelete(approvalDTO.getCaseId());
+//        if(loanCase == null||loanCase.getIsDelete()){
+//            return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
+//        }
+//        Step step = stepService.findByStepNameAndCaseId(StepPropertyEnum.APPROVAL.getLabel(), approvalDTO.getCaseId());
+//        //判断过去处理人与目前处理人是否一致
+//        if(step.getUserId1()!=null&&step.getUserId2()!=null&&userId!=step.getUserId2()&&userId!=step.getUserId1()){
+//            return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
+//        }
+//        if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
+//            return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
+//        }
+//        //审批记录处理
+//        ApprovalRecord approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),userId);
+//        if(approvalRecord_origin == null) {
+//            log.info("没找到对应以前审批记录");
+//            // 创建审批记录
+//            ApprovalRecord approvalRecord = new ApprovalRecord();
+//            approvalRecord.setCaseId(approvalDTO.getCaseId());
+//            approvalRecord.setStepName(StepPropertyEnum.APPROVAL.getLabel());
+//            approvalRecord.setApproverId(userId);
+//            approvalRecord.setDecision(DecisionEnum.REJECT.getMsg());
+//            approvalRecord.setComments(approvalDTO.getComments());
+//            approvalRecord.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+//            approvalRecord.setUpdateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+//            approvalRecord.setIsDelete(false);
+//            // 保存到数据库
+//            approvalService.save(approvalRecord);
+//        }else{
+//            log.info("找到对应以前审批记录");
+//            approvalService.updateDecisionByCaseIdAndStepNameAndIsDelete(DecisionEnum.REJECT.getMsg(),approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),approvalDTO.getComments(),userId);
+//        }
+//        if(step.getUserId1()== null){
+//            stepService.updateUserId1ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
+//        }else if(step.getUserId2()== null){
+//            stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
+//        }
+//        //更新环节状态
+//        stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(),StepPropertyEnum.BUSINESS_ACCEPT_PARENT.getLabel(),approvalDTO.getCaseId());
+//        stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(),StepPropertyEnum.BUSINESS_ACCEPT.getLabel(),approvalDTO.getCaseId());
+//        stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(),StepPropertyEnum.PRE_TRIAL_PARENT.getLabel(),approvalDTO.getCaseId());
+//        stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(),StepPropertyEnum.PRE_TRIAL.getLabel(),approvalDTO.getCaseId());
+//        stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(),StepPropertyEnum.APPROVAL_PARENT.getLabel(),approvalDTO.getCaseId());
+//        stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(),StepPropertyEnum.APPROVAL.getLabel(),approvalDTO.getCaseId());
+//        //TODO微信推送审批驳回消息和通知重新受理(到业务受理)
+//
+//        return ResultUtil.success("success","审批驳回");
+//    }
+//    @PostMapping("/approval/{caseId}/terminate")
+//    @PreAuthorize("@pms.hasRole('APPROVER')")
+//    @ApiOperation("业务审批终结")
+//    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);
+//        //审批业务逻辑
+//        LoanCase loanCase = loanCaseService.findByIdAndIsDelete(approvalDTO.getCaseId());
+//        if(loanCase == null||loanCase.getIsDelete()){
+//            return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
+//        }
+//        Step step = stepService.findByStepNameAndCaseId(StepPropertyEnum.APPROVAL.getLabel(), approvalDTO.getCaseId());
+//        //判断过去处理人与目前处理人是否一致
+//        if(step.getUserId1()!=null&&step.getUserId2()!=null&&userId!=step.getUserId2()&&userId!=step.getUserId1()){
+//            return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
+//        }
+//        if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
+//            return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
+//        }
+//        //审批记录处理
+//        ApprovalRecord approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),userId);
+//        if(approvalRecord_origin == null) {
+//            log.info("没找到对应以前审批记录");
+//            // 创建审批记录
+//            ApprovalRecord approvalRecord = new ApprovalRecord();
+//            approvalRecord.setCaseId(approvalDTO.getCaseId());
+//            approvalRecord.setStepName(StepPropertyEnum.APPROVAL.getLabel());
+//            approvalRecord.setApproverId(userId);
+//            approvalRecord.setDecision(DecisionEnum.TERMINATE.getMsg());
+//            approvalRecord.setComments(approvalDTO.getComments());
+//            approvalRecord.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+//            approvalRecord.setUpdateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+//            approvalRecord.setIsDelete(false);
+//            // 保存到数据库
+//            approvalService.save(approvalRecord);
+//        }else{
+//            log.info("找到对应以前审批记录");
+//            approvalService.updateDecisionByCaseIdAndStepNameAndIsDelete(DecisionEnum.TERMINATE.getMsg(),approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),approvalDTO.getComments(),userId);
+//        }
+//        if(step.getUserId1()== null){
+//            stepService.updateUserId1ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
+//        }else if(step.getUserId2()== null){
+//            stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
+//        }
+//        //更新项目和环节状态 作逻辑删除
+//        loanCaseService.logic_delete(approvalDTO.getCaseId());
+//        List<Step> steps = stepService.getAllStepByCaseId(approvalDTO.getCaseId());
+//        for (Step step_each : steps){
+//            stepService.logic_delete(step_each.getId());
+//        }
+//        //TODO微信推送审批驳回消息和通知重新受理(到业务受理)
+//
+//        return ResultUtil.success("success","审批驳回");
 //    }
-
-    @PostMapping("/preapproval-records/{caseId}/reject")
-    @PreAuthorize("@pms.hasAnyRoles('LEAD_SALES','ASSIST_SALES')")
-    @ApiOperation("业务预审拒绝")
-    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);
-        User user = userService.findByIdAndIsDelete(userId);
-        log.info("用户: {}", user.getMobile());
-        LoanCase loanCase = loanCaseService.findByIdAndIsDelete(preApprovalDTO.getCaseId());
-        Step step = stepService.findByStepNameAndCaseId(StepPropertyEnum.PRE_TRIAL.getLabel(), preApprovalDTO.getCaseId());
-        //判断过去处理人与目前处理人是否一致
-        if(step.getUserId2()!=null&&userId!=step.getUserId2()){
-            return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
-        }
-        if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
-            return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
-        }
-        if(loanCase == null||loanCase.getIsDelete()){
-            return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
-        }
-        ApprovalRecord approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(preApprovalDTO.getCaseId(),StepPropertyEnum.PRE_TRIAL.getLabel(),userId);
-        if(approvalRecord_origin == null) {
-            log.info("没找到对应以前审批记录");
-            // 创建审批记录
-            ApprovalRecord approvalRecord = new ApprovalRecord();
-            approvalRecord.setCaseId(preApprovalDTO.getCaseId());
-            approvalRecord.setStepName(StepPropertyEnum.PRE_TRIAL.getLabel());
-            approvalRecord.setApproverId(userId);
-            approvalRecord.setDecision(DecisionEnum.REJECT.getMsg());
-            approvalRecord.setComments(preApprovalDTO.getComments());
-            approvalRecord.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-            approvalRecord.setUpdateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-            approvalRecord.setIsDelete(false);
-            // 保存到数据库
-            approvalService.save(approvalRecord);
-        }else{
-            log.info("找到对应以前审批记录");
-            approvalService.updateDecisionByCaseIdAndStepNameAndIsDelete(DecisionEnum.REJECT.getMsg(),preApprovalDTO.getCaseId(),StepPropertyEnum.PRE_TRIAL.getLabel(),preApprovalDTO.getComments(),userId);
-        }
-        stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.PRE_TRIAL.getLabel(),userId,preApprovalDTO.getCaseId());
-        loanCaseService.updateUpdatetimeByIdAndIsDeleted(preApprovalDTO.getCaseId(),false);
-        //TODO:微信推送预审拒绝消息和通知下一环节
-//        wxService.sendTemplateMessage(loanCase.getCustomer().getMobile(),new TemplateMessage());
-        return ResultUtil.success("success","预审拒绝");
-    }
-
-    @PostMapping("/approval/{caseId}/pass")
-    @PreAuthorize("@pms.hasRole('APPROVER')")
-    @ApiOperation("业务审批通过")
-    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);
-        //审批业务逻辑
-        LoanCase loanCase = loanCaseService.findByIdAndIsDelete(approvalDTO.getCaseId());
-        Step step = stepService.findByStepNameAndCaseId(StepPropertyEnum.APPROVAL.getLabel(), approvalDTO.getCaseId());
-        //判断过去处理人与目前处理人是否一致
-        if(step.getUserId1()!=null&&step.getUserId2()!=null&&userId!=step.getUserId2()&&userId!=step.getUserId1()){
-            return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
-        }
-        if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
-            return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
-        }
-        if(loanCase == null||loanCase.getIsDelete()){
-            return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
-        }
-        ApprovalRecord approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),userId);
-        if(approvalRecord_origin == null) {
-            log.info("没找到对应以前审批记录");
-            // 创建审批记录
-            ApprovalRecord approvalRecord = new ApprovalRecord();
-            approvalRecord.setCaseId(approvalDTO.getCaseId());
-            approvalRecord.setStepName(StepPropertyEnum.APPROVAL.getLabel());
-            approvalRecord.setApproverId(userId);
-            approvalRecord.setDecision(DecisionEnum.PASS.getMsg());
-            approvalRecord.setComments(approvalDTO.getComments());
-            approvalRecord.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-            approvalRecord.setUpdateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-            approvalRecord.setIsDelete(false);
-            // 保存到数据库
-            approvalService.save(approvalRecord);
-        }else{
-            log.info("找到对应以前审批记录");
-            approvalService.updateDecisionByCaseIdAndStepNameAndIsDelete(DecisionEnum.PASS.getMsg(),approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),approvalDTO.getComments(),userId);
-        }
-        if(step.getUserId1()== null){
-            stepService.updateUserId1ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
-        }else if(step.getUserId2()== null){
-            stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
-        }
-        if(step.getUserId1()!=null&&step.getUserId2()!=null){
-            ApprovalRecord approvalRecord_user1 = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),step.getUserId1());
-            ApprovalRecord approvalRecord_user2 = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),step.getUserId2());
-            if(approvalRecord_user1.getDecision() == DecisionEnum.PASS.getMsg()&&approvalRecord_user2.getDecision() == DecisionEnum.PASS.getMsg()){
-                stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(),StepPropertyEnum.APPROVAL_PARENT.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.getLabel(),approvalDTO.getCaseId());
-                //TODO微信推送审批通过消息和通知下一环节
-            }
-        }else{
-            //TODO微信推送另一个审批人审批
-        }
-
-        return ResultUtil.success("success","审批通过");
-
-    }
-
-    @PostMapping("/approval/{caseId}/reject")
-    @PreAuthorize("@pms.hasRole('APPROVER')")
-    @ApiOperation("业务审批拒绝")
-    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);
-        //审批业务逻辑
-        LoanCase loanCase = loanCaseService.findByIdAndIsDelete(approvalDTO.getCaseId());
-        if(loanCase == null||loanCase.getIsDelete()){
-            return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
-        }
-        Step step = stepService.findByStepNameAndCaseId(StepPropertyEnum.APPROVAL.getLabel(), approvalDTO.getCaseId());
-        //判断过去处理人与目前处理人是否一致
-        if(step.getUserId1()!=null&&step.getUserId2()!=null&&userId!=step.getUserId2()&&userId!=step.getUserId1()){
-            return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
-        }
-        if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
-            return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
-        }
-        //审批记录处理
-        ApprovalRecord approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),userId);
-        if(approvalRecord_origin == null) {
-            log.info("没找到对应以前审批记录");
-            // 创建审批记录
-            ApprovalRecord approvalRecord = new ApprovalRecord();
-            approvalRecord.setCaseId(approvalDTO.getCaseId());
-            approvalRecord.setStepName(StepPropertyEnum.APPROVAL.getLabel());
-            approvalRecord.setApproverId(userId);
-            approvalRecord.setDecision(DecisionEnum.REJECT.getMsg());
-            approvalRecord.setComments(approvalDTO.getComments());
-            approvalRecord.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-            approvalRecord.setUpdateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-            approvalRecord.setIsDelete(false);
-            // 保存到数据库
-            approvalService.save(approvalRecord);
-        }else{
-            log.info("找到对应以前审批记录");
-            approvalService.updateDecisionByCaseIdAndStepNameAndIsDelete(DecisionEnum.REJECT.getMsg(),approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),approvalDTO.getComments(),userId);
-        }
-        if(step.getUserId1()== null){
-            stepService.updateUserId1ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
-        }else if(step.getUserId2()== null){
-            stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
-        }
-        //更新环节状态
-        stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(),StepPropertyEnum.BUSINESS_ACCEPT_PARENT.getLabel(),approvalDTO.getCaseId());
-        stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(),StepPropertyEnum.BUSINESS_ACCEPT.getLabel(),approvalDTO.getCaseId());
-        stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(),StepPropertyEnum.PRE_TRIAL_PARENT.getLabel(),approvalDTO.getCaseId());
-        stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(),StepPropertyEnum.PRE_TRIAL.getLabel(),approvalDTO.getCaseId());
-        stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(),StepPropertyEnum.APPROVAL_PARENT.getLabel(),approvalDTO.getCaseId());
-        stepService.updateStatusByCaseId(StepEnum.UNSTART.getMsg(),StepPropertyEnum.APPROVAL.getLabel(),approvalDTO.getCaseId());
-        //TODO微信推送审批驳回消息和通知重新受理(到业务受理)
-
-        return ResultUtil.success("success","审批驳回");
-    }
-    @PostMapping("/approval/{caseId}/terminate")
-    @PreAuthorize("@pms.hasRole('APPROVER')")
-    @ApiOperation("业务审批终结")
-    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);
-        //审批业务逻辑
-        LoanCase loanCase = loanCaseService.findByIdAndIsDelete(approvalDTO.getCaseId());
-        if(loanCase == null||loanCase.getIsDelete()){
-            return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
-        }
-        Step step = stepService.findByStepNameAndCaseId(StepPropertyEnum.APPROVAL.getLabel(), approvalDTO.getCaseId());
-        //判断过去处理人与目前处理人是否一致
-        if(step.getUserId1()!=null&&step.getUserId2()!=null&&userId!=step.getUserId2()&&userId!=step.getUserId1()){
-            return ResultUtil.error(STEP_USER_NOT_EXPECTED.getCode(), "环节处理人不是预期用户");
-        }
-        if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
-            return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
-        }
-        //审批记录处理
-        ApprovalRecord approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),userId);
-        if(approvalRecord_origin == null) {
-            log.info("没找到对应以前审批记录");
-            // 创建审批记录
-            ApprovalRecord approvalRecord = new ApprovalRecord();
-            approvalRecord.setCaseId(approvalDTO.getCaseId());
-            approvalRecord.setStepName(StepPropertyEnum.APPROVAL.getLabel());
-            approvalRecord.setApproverId(userId);
-            approvalRecord.setDecision(DecisionEnum.TERMINATE.getMsg());
-            approvalRecord.setComments(approvalDTO.getComments());
-            approvalRecord.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-            approvalRecord.setUpdateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-            approvalRecord.setIsDelete(false);
-            // 保存到数据库
-            approvalService.save(approvalRecord);
-        }else{
-            log.info("找到对应以前审批记录");
-            approvalService.updateDecisionByCaseIdAndStepNameAndIsDelete(DecisionEnum.TERMINATE.getMsg(),approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),approvalDTO.getComments(),userId);
-        }
-        if(step.getUserId1()== null){
-            stepService.updateUserId1ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
-        }else if(step.getUserId2()== null){
-            stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.APPROVAL.getLabel(),userId,approvalDTO.getCaseId());
-        }
-        //更新项目和环节状态 作逻辑删除
-        loanCaseService.logic_delete(approvalDTO.getCaseId());
-        List<Step> steps = stepService.getAllStepByCaseId(approvalDTO.getCaseId());
-        for (Step step_each : steps){
-            stepService.logic_delete(step_each.getId());
-        }
-        //TODO微信推送审批驳回消息和通知重新受理(到业务受理)
-
-        return ResultUtil.success("success","审批驳回");
-    }
-}
-
+//}
+//

+ 34 - 21
src/main/java/com/loan/system/controller/wechat/ApprovalController.java

@@ -25,6 +25,7 @@ import javax.servlet.http.HttpServletRequest;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.List;
+import java.util.Objects;
 
 import static com.loan.system.domain.enums.ExceptionEnum.*;
 
@@ -56,6 +57,10 @@ public class ApprovalController {
     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());
@@ -85,14 +90,14 @@ public class ApprovalController {
         User user = userService.findByIdAndIsDelete(userId);
         log.info("用户: {}", user.getMobile());
         LoanCaseVO loanCase = loanCaseService.findLoanCaseByIdAndIsDelete(preApprovalDTO.getCaseId(),false);
-        if(loanCase == null||loanCase.getIsDelete()){
+        if(loanCase == null){
             return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
         }
         StepVO step = stepService.findByStepNameAndCaseId(StepPropertyEnum.PRE_TRIAL.getLabel(), preApprovalDTO.getCaseId());
         if(step.getUserId2()!=null&&userId!=step.getUserId2()){
             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(), "环节已完成,无法重复审批");
         }
         ApprovalRecordVO approvalRecord_origin = approvalService.findByCaseIdAndIsDeleteAndStepName(preApprovalDTO.getCaseId(),StepPropertyEnum.PRE_TRIAL.getLabel(),userId);
@@ -179,17 +184,18 @@ public class ApprovalController {
         User user = userService.findByIdAndIsDelete(userId);
         log.info("用户: {}", user.getMobile());
         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());
         //判断过去处理人与目前处理人是否一致
         if(step.getUserId2()!=null&&userId!=step.getUserId2()){
             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(), "环节已完成,无法重复审批");
         }
-        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);
         if(approvalRecord_origin == null) {
             log.info("没找到对应以前审批记录");
@@ -211,6 +217,12 @@ public class ApprovalController {
         }
         stepService.updateUserId2ByCaseIdAndStepName(StepPropertyEnum.PRE_TRIAL.getLabel(),userId,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);
         //TODO:微信推送预审拒绝消息和通知下一环节
 //        wxService.sendTemplateMessage(loanCase.getCustomer().getMobile(),new TemplateMessage());
         return ResultUtil.success("success","预审拒绝");
@@ -225,17 +237,18 @@ public class ApprovalController {
         log.info("用户id: {}", userId);
         //审批业务逻辑
         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());
         //判断过去处理人与目前处理人是否一致
-        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(), "环节处理人不是预期用户");
         }
-        if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
+        if(Objects.equals(step.getStatus(), StepEnum.COMPLETED.getMsg())){
             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);
         if(approvalRecord_origin == null) {
             log.info("没找到对应以前审批记录");
@@ -257,13 +270,13 @@ public class ApprovalController {
         }
         if(step.getUserId1()== null){
             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());
         }
         if(step.getUserId1()!=null&&step.getUserId2()!=null){
             ApprovalRecordVO approvalRecord_user1 = approvalService.findByCaseIdAndIsDeleteAndStepName(approvalDTO.getCaseId(),StepPropertyEnum.APPROVAL.getLabel(),step.getUserId1());
             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.getLabel(),approvalDTO.getCaseId());
                 stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(),StepPropertyEnum.CONTRACT_SIGN_PARENT.getLabel(),approvalDTO.getCaseId());
@@ -287,7 +300,7 @@ public class ApprovalController {
         log.info("用户id: {}", userId);
         //审批业务逻辑
         LoanCaseVO loanCase = loanCaseService.findLoanCaseByIdAndIsDelete(approvalDTO.getCaseId(),false);
-        if(loanCase == null||loanCase.getIsDelete()){
+        if(loanCase == null){
             return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
         }
         StepVO step = stepService.findByStepNameAndCaseId(StepPropertyEnum.APPROVAL.getLabel(), approvalDTO.getCaseId());
@@ -295,7 +308,7 @@ public class ApprovalController {
         if(step.getUserId1()!=null&&step.getUserId2()!=null&&userId!=step.getUserId2()&&userId!=step.getUserId1()){
             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(), "环节已完成,无法重复审批");
         }
         //审批记录处理
@@ -320,7 +333,7 @@ public class ApprovalController {
         }
         if(step.getUserId1()== null){
             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());
         }
         //更新环节状态
@@ -343,15 +356,15 @@ public class ApprovalController {
         log.info("用户id: {}", userId);
         //审批业务逻辑
         LoanCaseVO loanCase = loanCaseService.findLoanCaseByIdAndIsDelete(approvalDTO.getCaseId(),false);
-        if(loanCase == null||loanCase.getIsDelete()){
+        if(loanCase == null){
             return ResultUtil.error(PROJECT_NOT_EXIST.getCode(), PROJECT_NOT_EXIST.getMsg());
         }
         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(), "环节处理人不是预期用户");
         }
-        if(step.getStatus()==StepEnum.COMPLETED.getMsg()){
+        if(Objects.equals(step.getStatus(), StepEnum.COMPLETED.getMsg())){
             return ResultUtil.error(STEP_HAS_COMPLETEED.getCode(), "环节已完成,无法重复审批");
         }
         //审批记录处理
@@ -376,7 +389,7 @@ public class ApprovalController {
         }
         if(step.getUserId1()== null){
             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());
         }
         //更新项目和环节状态 作逻辑删除
@@ -387,7 +400,7 @@ public class ApprovalController {
         }
         //TODO微信推送审批驳回消息和通知重新受理(到业务受理)
 
-        return ResultUtil.success("success","审批驳回");
+        return ResultUtil.success("success","业务终结");
     }
 }
 

+ 61 - 0
src/main/java/com/loan/system/controller/wechat/CollateralController.java

@@ -0,0 +1,61 @@
+package com.loan.system.controller.wechat;
+
+import com.loan.system.domain.dto.CollateralDTO;
+import com.loan.system.domain.pojo.Result;
+import com.loan.system.domain.vo.CollateralVO;
+import com.loan.system.service.CollateralService;
+import com.loan.system.utils.ResultUtil;
+import io.swagger.annotations.Api;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/wechat/collateral")
+@Api(tags = "抵押物接口")
+public class CollateralController {
+
+    @Autowired
+    private CollateralService collateralService;
+    //显示业务相关抵押物状态
+    @RequestMapping("/{id}")
+    public Result findCollateral(@PathVariable("id") Long id){
+        List<CollateralVO> collaterals = collateralService.findByCaseId(id);
+        return ResultUtil.success("success",collaterals);
+    }
+    /**确认抵押物入库
+     *
+     */
+    @RequestMapping("/warehouse/{id}")
+    public Result warehouseCollateral(@PathVariable("id") Long id){
+
+
+        return null;
+    }
+    /**确认抵押物出库
+     *
+     */
+    @RequestMapping("/outbound/{id}")
+    public Result outboundCollateral(@PathVariable("id") Long id){
+
+
+        return null;
+    }
+    /**删除抵押物
+     *
+     */
+    @RequestMapping("/delete/{id}")
+    public Result deleteCollateral(@PathVariable("id") Long id){
+        collateralService.logic_delete(id);
+        return ResultUtil.success("success","抵押物删除成功");
+    }
+//    @RequestMapping("/add")
+//    public Result addCollateral(CollateralDTO collateralDTO){
+//
+//        return null;
+//    }
+
+}

+ 138 - 138
src/main/java/com/loan/system/controller/wechat/UserController.java

@@ -65,152 +65,152 @@ public class UserController {//包含内部人员、外部人员
     2.若不是内部人员,查询外部人员
     3.外部人员也不存在,进行注册(因为小程序端直接获取手机号,任何用户都可以登录)
      */
-    @PostMapping("/login")
-    @ApiOperation("微信登陆")
-    public Result login(@RequestBody UserLoginDTO userLoginDTO){
-
-        User user = userService.getUserByMobile(userLoginDTO.getTel());
-        UserLoginVO userLoginVO = new UserLoginVO();
-
-        //为微信用户生成jwt令牌
-        Map<String ,Object> claims=new HashMap<>();
-        Long userId = null;
-
-        if (!ObjectUtils.isEmpty(user)){
-            userLoginVO.setId(user.getId());
-            userLoginVO.setRole(user.getRole());
-            userLoginVO.setOpenid(user.getOpenid());
-        }else{
-            CustomerVO customer = customerService.getCustomerByMobile(userLoginDTO.getTel());
-            if(ObjectUtils.isEmpty(customer)) {
-                Customer customer1 = new Customer();
-                customer1.setMobile(userLoginDTO.getTel());
-                //补充
-                customerService.addCustomer(customer1);
-
-                customer = customerService.getCustomerByMobile(userLoginDTO.getTel());
-            }
-            userLoginVO.setId(customer.getId());
-            userLoginVO.setRole(RoleEnum.EXTERNAL.getMsg());
-            userLoginVO.setOpenid(customer.getOpenid());
-        }
-
-        claims.put(JwtClaimsConstant.USER_ID,userLoginVO.getId());
-        String token = JwtUtil.createJWT(jwtProperties.getUserSecretKey(), jwtProperties.getUserTtl(), claims);
-        userLoginVO.setToken(token);
-
-        return ResultUtil.success("success", userLoginVO);
-    }
-//    @GetMapping("/get_sessionId")
-//    @ApiOperation("获取微信openid")
-//    public Result get_sessionId(String code){
-//        return userService.get_sessionId(code);
-//    }
-//    public Result customer_login(Customer customer){
-//        customer=customerService.findBymobileAndIsDelete(customer.getMobile());
-//        if (ObjectUtils.isEmpty(customer))
-//            throw new IllegalArgumentException("Customer object is null");
-//        //为微信用户生成jwt令牌
-//        Map<String ,Object> claims=new HashMap<>();
-//        //用openid还是id?
-//        //claims.put(JwtClaimsConstant.CUSTOMER_ID,customer.getOpenid());
-//        claims.put(JwtClaimsConstant.USER_ID,customer.getId());
-//        String token = JwtUtil.createJWT(jwtProperties.getUserSecretKey(), jwtProperties.getUserTtl(), claims);
-//        log.info("手机号码:{}",customer.getMobile());
-//        CustomerLoginVO customerLoginVO = CustomerLoginVO.builder()
-//                .id(customer.getId())
-//                .openid(customer.getOpenid())
-//                .token(token)
-//                .name(customer.getName())
-//                .is_customer(1)
-//                .build();
+//    @PostMapping("/login")
+//    @ApiOperation("微信登陆")
+//    public Result login(@RequestBody UserLoginDTO userLoginDTO){
 //
-//        return ResultUtil.success("success", customerLoginVO);
-//    }
+//        User user = userService.getUserByMobile(userLoginDTO.getTel());
+//        UserLoginVO userLoginVO = new UserLoginVO();
 //
-//    /**
-//     * 用户登陆
-//     * @param userLoginDTO
-//     * @return
-//     */
-//    public Result user_login(UserLoginDTO userLoginDTO){
-//        User user= userService.findByPhoneNumberAndIsDelete(userLoginDTO.getTel());
-//        if (ObjectUtils.isEmpty(user))
-//            throw new IllegalArgumentException("User object is null");
 //        //为微信用户生成jwt令牌
 //        Map<String ,Object> claims=new HashMap<>();
-//        claims.put(JwtClaimsConstant.USER_ID,user.getId());
-//        String token = JwtUtil.createJWT(jwtProperties.getUserSecretKey(), jwtProperties.getUserTtl(), claims);
-//        log.info("手机号码:{}",userLoginDTO.getTel());
-//        log.info("用户ID:{}",user.getId());
-//        UserLoginVO userLoginVO = UserLoginVO.builder()
-//                .id(user.getId())
-//                .openid(user.getOpenid())
-//                .token(token)
-//                .role(user.getRole())
-//                .is_customer(0)
-//                .userName(user.getUsername())
-//                .build();
+//        Long userId = null;
 //
-//        return ResultUtil.success("success", userLoginVO);
-//    }
-//
-//    /**
-//     * 注册客户
-//     * @param customer
-//     * @return
-//     */
-//    public Result register(Customer customer){
-//        customer.setCreateTime(LocalDateTime.now()
-//                .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-//        customer.setUpdateTime(LocalDateTime.now()
-//                .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-//        customer.setIsDelete(false);
-//        customerService.addCustomer(customer);
-//        return this.customer_login(customer);
-//    }
-//
-//    @PostMapping("/login_wechat")
-//    @ApiOperation("微信手机号登陆")
-//    public Result login(@RequestBody WeChatLoginDTO weChatLoginDTO){
-//        String access_token=wxService.getAccessToken();
-//        String phoneNumber=wxService.getUserPhoneNumber(access_token,weChatLoginDTO.getCode());
-//        boolean user_is_exist = userService.existsByMobileAndIsDelete(phoneNumber);
-//        boolean customer_is_exist=customerService.existsBymobileAndIsDelete(phoneNumber);
-//        log.info("code:{}",phoneNumber);
-//        log.info("用户是否存在:{}",user_is_exist);
-//        if(!customer_is_exist&&!user_is_exist){
-//            Customer customer = new Customer();
-//            customer.setMobile(phoneNumber);
-//            customer.setOpenid(weChatLoginDTO.getOpenid());
-//            return this.register(customer);
-//        }else if(customer_is_exist){   //存在客户
-//            Customer customer=customerService.findBymobileAndIsDelete(phoneNumber);
-//            return this.customer_login(customer);
-//        }else { //存在用户
-//            UserLoginDTO userLoginDTO = new UserLoginDTO();
-//            userLoginDTO.setTel(phoneNumber);
-//            return this.user_login(userLoginDTO);
-//        }
-//    }
-//    @PostMapping("/login")
-//    @ApiOperation("账号登陆")
-//    public Result login(@RequestBody UserLoginDTO userLoginDTO){
-//        String phoneNumber=userLoginDTO.getTel();
-//        boolean user_is_exist = userService.existsByMobileAndIsDelete(phoneNumber);
-//        boolean customer_is_exist=customerService.existsBymobileAndIsDelete(phoneNumber);
-//        if(!customer_is_exist&&!user_is_exist){
-//            Customer customer = new Customer();
-//            customer.setMobile(phoneNumber);
-//            customer.setOpenid(userLoginDTO.getOpenid());
-//            return this.register(customer);
-//        }else if(customer_is_exist){
-//            Customer customer=customerService.findBymobileAndIsDelete(phoneNumber);
-//            return this.customer_login(customer);
+//        if (!ObjectUtils.isEmpty(user)){
+//            userLoginVO.setId(user.getId());
+//            userLoginVO.setRole(user.getRole());
+//            userLoginVO.setOpenid(user.getOpenid());
 //        }else{
-//            return this.user_login(userLoginDTO);
+//            CustomerVO customer = customerService.getCustomerByMobile(userLoginDTO.getTel());
+//            if(ObjectUtils.isEmpty(customer)) {
+//                Customer customer1 = new Customer();
+//                customer1.setMobile(userLoginDTO.getTel());
+//                //补充
+//                customerService.addCustomer(customer1);
+//
+//                customer = customerService.getCustomerByMobile(userLoginDTO.getTel());
+//            }
+//            userLoginVO.setId(customer.getId());
+//            userLoginVO.setRole(RoleEnum.EXTERNAL.getMsg());
+//            userLoginVO.setOpenid(customer.getOpenid());
 //        }
+//
+//        claims.put(JwtClaimsConstant.USER_ID,userLoginVO.getId());
+//        String token = JwtUtil.createJWT(jwtProperties.getUserSecretKey(), jwtProperties.getUserTtl(), claims);
+//        userLoginVO.setToken(token);
+//
+//        return ResultUtil.success("success", userLoginVO);
 //    }
+    @GetMapping("/get_sessionId")
+    @ApiOperation("获取微信openid")
+    public Result get_sessionId(String code){
+        return userService.get_sessionId(code);
+    }
+    public Result customer_login(Customer customer){
+        customer=customerService.findBymobileAndIsDelete(customer.getMobile());
+        if (ObjectUtils.isEmpty(customer))
+            throw new IllegalArgumentException("Customer object is null");
+        //为微信用户生成jwt令牌
+        Map<String ,Object> claims=new HashMap<>();
+        //用openid还是id?
+        //claims.put(JwtClaimsConstant.CUSTOMER_ID,customer.getOpenid());
+        claims.put(JwtClaimsConstant.USER_ID,customer.getId());
+        String token = JwtUtil.createJWT(jwtProperties.getUserSecretKey(), jwtProperties.getUserTtl(), claims);
+        log.info("手机号码:{}",customer.getMobile());
+        CustomerLoginVO customerLoginVO = CustomerLoginVO.builder()
+                .id(customer.getId())
+                .openid(customer.getOpenid())
+                .token(token)
+                .name(customer.getName())
+                .is_customer(1)
+                .build();
+
+        return ResultUtil.success("success", customerLoginVO);
+    }
+
+    /**
+     * 用户登陆
+     * @param userLoginDTO
+     * @return
+     */
+    public Result user_login(UserLoginDTO userLoginDTO){
+        User user= userService.findByPhoneNumberAndIsDelete(userLoginDTO.getTel());
+        if (ObjectUtils.isEmpty(user))
+            throw new IllegalArgumentException("User object is null");
+        //为微信用户生成jwt令牌
+        Map<String ,Object> claims=new HashMap<>();
+        claims.put(JwtClaimsConstant.USER_ID,user.getId());
+        String token = JwtUtil.createJWT(jwtProperties.getUserSecretKey(), jwtProperties.getUserTtl(), claims);
+        log.info("手机号码:{}",userLoginDTO.getTel());
+        log.info("用户ID:{}",user.getId());
+        UserLoginVO userLoginVO = UserLoginVO.builder()
+                .id(user.getId())
+                .openid(user.getOpenid())
+                .token(token)
+                .role(user.getRole())
+                .is_customer(0)
+                .userName(user.getUsername())
+                .build();
+
+        return ResultUtil.success("success", userLoginVO);
+    }
+
+    /**
+     * 注册客户
+     * @param customer
+     * @return
+     */
+    public Result register(Customer customer){
+        customer.setCreateTime(LocalDateTime.now()
+                .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+        customer.setUpdateTime(LocalDateTime.now()
+                .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+        customer.setIsDelete(false);
+        customerService.addCustomer(customer);
+        return this.customer_login(customer);
+    }
+
+    @PostMapping("/login_wechat")
+    @ApiOperation("微信手机号登陆")
+    public Result login(@RequestBody WeChatLoginDTO weChatLoginDTO){
+        String access_token=wxService.getAccessToken();
+        String phoneNumber=wxService.getUserPhoneNumber(access_token,weChatLoginDTO.getCode());
+        boolean user_is_exist = userService.existsByMobileAndIsDelete(phoneNumber);
+        boolean customer_is_exist=customerService.existsBymobileAndIsDelete(phoneNumber);
+        log.info("code:{}",phoneNumber);
+        log.info("用户是否存在:{}",user_is_exist);
+        if(!customer_is_exist&&!user_is_exist){
+            Customer customer = new Customer();
+            customer.setMobile(phoneNumber);
+            customer.setOpenid(weChatLoginDTO.getOpenid());
+            return this.register(customer);
+        }else if(customer_is_exist){   //存在客户
+            Customer customer=customerService.findBymobileAndIsDelete(phoneNumber);
+            return this.customer_login(customer);
+        }else { //存在用户
+            UserLoginDTO userLoginDTO = new UserLoginDTO();
+            userLoginDTO.setTel(phoneNumber);
+            return this.user_login(userLoginDTO);
+        }
+    }
+    @PostMapping("/login")
+    @ApiOperation("账号登陆")
+    public Result login(@RequestBody UserLoginDTO userLoginDTO){
+        String phoneNumber=userLoginDTO.getTel();
+        boolean user_is_exist = userService.existsByMobileAndIsDelete(phoneNumber);
+        boolean customer_is_exist=customerService.existsBymobileAndIsDelete(phoneNumber);
+        if(!customer_is_exist&&!user_is_exist){
+            Customer customer = new Customer();
+            customer.setMobile(phoneNumber);
+            customer.setOpenid(userLoginDTO.getOpenid());
+            return this.register(customer);
+        }else if(customer_is_exist){
+            Customer customer=customerService.findBymobileAndIsDelete(phoneNumber);
+            return this.customer_login(customer);
+        }else{
+            return this.user_login(userLoginDTO);
+        }
+    }
 
 
     @PostMapping("/role")

+ 27 - 0
src/main/java/com/loan/system/domain/entity/CollateralPlan.java

@@ -0,0 +1,27 @@
+package com.loan.system.domain.entity;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "collateral_plan")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class CollateralPlan extends BaseEntity{
+    private Long id;
+    private Long case_id;
+    private Long collateral_id;
+    private Long user_id;
+    private String time;
+    private String place;
+    private String flag;
+    private String comments;
+    private String create_time;
+    private String update_time;
+}

+ 24 - 0
src/main/java/com/loan/system/domain/entity/CollateralRecord.java

@@ -0,0 +1,24 @@
+package com.loan.system.domain.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "collateral_record")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class CollateralRecord extends BaseEntity{
+    private Long id;
+    private Long case_id;
+    private Long collateral_id;
+    private String operation;
+    private Long user_id;
+    private String comments;
+    private String create_time;
+    private String update_time;
+}

+ 3 - 0
src/main/java/com/loan/system/domain/entity/LoanCase.java

@@ -51,5 +51,8 @@ public class LoanCase extends BaseEntity{
 
     @Column(name = "is_delete")
     private Boolean isDelete;
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "customer_id", insertable = false, updatable = false, referencedColumnName = "id")
+    private Customer customer;
 
 }

+ 1 - 1
src/main/java/com/loan/system/domain/vo/LoanCaseVO.java

@@ -37,5 +37,5 @@ public class LoanCaseVO implements Serializable {
     private List<DocumentVO> documents;// 文件
     private String currentAddress;// 房产产证地址
     private Boolean isInvolvedInLitigation;//是否涉及诉讼
-    private Boolean IsDelete;
+    private Boolean isDelete;
 }

+ 1 - 0
src/main/java/com/loan/system/interceptor/JwtTokenUserInterceptor.java

@@ -54,6 +54,7 @@ public class JwtTokenUserInterceptor implements HandlerInterceptor {
             Claims claims = JwtUtil.parseJWT(jwtProperties.getUserSecretKey(), token);
             Long userId = Long.valueOf(claims.get(JwtClaimsConstant.USER_ID).toString());
             BaseContext.setCurrentId(userId);
+            setSpringSecurityAuthentication(userId);
             //3、通过,放行
             return true;
         } catch (Exception ex) {

+ 11 - 0
src/main/java/com/loan/system/repository/CollateralRepository.java

@@ -43,4 +43,15 @@ public interface CollateralRepository extends JpaRepository<Collateral,Long> {
     @Modifying
     @Query("delete FROM Collateral c WHERE c.caseId = ?1")
     void deleteAllByCaseId(Long caseId);
+
+    //逻辑删除
+    @Modifying
+    @Transactional
+    @Query("UPDATE Collateral c SET c.isDelete = true , c.updateTime = CURRENT_TIMESTAMP WHERE c.id = ?1")
+    void deleteById(Long id);
+
+    @Modifying
+    @Transactional
+    @Query("UPDATE Collateral c SET c.staus = ?2 ,c.updateTime = CURRENT_TIMESTAMP  WHERE c.id = ?1 And c.isDelete= false ")
+    void updateCollateralStatusByid(Long id, String status);
 }

+ 4 - 3
src/main/java/com/loan/system/repository/LoanRepository.java

@@ -33,8 +33,9 @@ public interface LoanRepository extends JpaRepository<LoanCase,Long> {
            "WHERE l.id = :caseId")
     void updateLoanCaseById(@Param("loanCase") LoanCase loanCase, @Param("caseId") Long caseId);
 
-    @Query("SELECT l FROM LoanCase l WHERE l.id = :caseId and l.isDelete = :isDelete")
-    LoanCase findLoanCaseById(Long caseId, boolean isDelete);
+    @Query("SELECT lc FROM LoanCase lc LEFT JOIN FETCH lc.customer WHERE lc.id = :caseId AND lc.isDelete = :isDelete")
+    LoanCase findLoanCaseById(@Param("caseId") Long caseId, @Param("isDelete") boolean isDelete);
+
 
     @Modifying
     @Transactional
@@ -43,6 +44,6 @@ public interface LoanRepository extends JpaRepository<LoanCase,Long> {
 
     @Modifying
     @Transactional
-    @Query("UPDATE LoanCase SET updateTime = ?3, isDelete = ?2 WHERE id = ?1 AND isDelete = ?2")
+    @Query("UPDATE LoanCase SET updateTime = ?3, isDelete = ?2 WHERE id = ?1 AND isDelete = false")
     void logic_delete(Long id, boolean isDelete, String updateTime);
 }

+ 2 - 2
src/main/java/com/loan/system/repository/StepRepository.java

@@ -37,7 +37,7 @@ public interface StepRepository extends JpaRepository<Step,Long> {
     @Query("update Step set userId2 = ?2 where caseId = ?3 and  stepName = ?1")
     void updateUser2ByCaseIdAndStepName(String stepName, Long approverId, Long caseId);
 
-    List<StepVO> findByCaseId(Long caseId);
+    List<Step> findByCaseId(Long caseId);
 
     @Modifying
     @Transactional
@@ -51,6 +51,6 @@ public interface StepRepository extends JpaRepository<Step,Long> {
 
     @Modifying
     @Transactional
-    @Query("UPDATE Step SET updateTime = ?3, isDelete = ?2 WHERE id = ?1 AND isDelete = ?2")
+    @Query("UPDATE Step SET updateTime = ?3, isDelete = ?2 WHERE id = ?1 AND isDelete = false")
     void logic_delete(Long id, boolean isDelete, String updateTime);
 }

+ 4 - 0
src/main/java/com/loan/system/service/CollateralService.java

@@ -16,4 +16,8 @@ public interface CollateralService {
     void updateCollateralById(Long id, CollateralDTO collateralDTO, boolean isDelete);
 
     void deleteAllByCaseId(Long caseId);
+
+    void logic_delete(Long id);
+
+    void updateCollateralStatusByid(Long id,String  status);
 }

+ 9 - 0
src/main/java/com/loan/system/service/Impl/CollateralServiceImpl.java

@@ -52,4 +52,13 @@ public class CollateralServiceImpl implements CollateralService {
     public void deleteAllByCaseId(Long caseId) {
         collateralRepository.deleteAllByCaseId(caseId);
     }
+    @Override
+    public void logic_delete(Long id) {
+        collateralRepository.deleteById(id);
+    }
+
+    @Override
+    public void updateCollateralStatusByid(Long id,String  status){
+        collateralRepository.updateCollateralStatusByid(id,status);
+    }
 }

+ 7 - 1
src/main/java/com/loan/system/service/Impl/StepServiceImpl.java

@@ -109,7 +109,13 @@ public class StepServiceImpl implements StepService {
 
     @Override
     public List<StepVO> getStepByCaseId(Long caseId) {
-        return stepRepository.findByCaseId(caseId);
+        List<Step> steps = stepRepository.findByCaseId(caseId);
+        List<StepVO> stepVOS = new ArrayList<>();
+        for (Step step : steps) {
+            StepVO stepVO = BeanUtil.copyProperties(step, StepVO.class);
+            stepVOS.add(stepVO);
+        }
+        return stepVOS;
     }
 
     @Override

+ 2 - 1
src/main/resources/application.yaml

@@ -32,7 +32,8 @@ logging:
   level:
     root:
       info
-
+upload:
+  templatePath: C:\\Users\\Xu\\Documents\\loan_project
 system:
   jwt:
     user-secret-key: "HDU-JUAasSDSAds*87ASud/A?D(G+KbPeShVmYq3s6v9y$B&E)H@McQfTjWnZr4u7w"