8 Commits 07b28f83e5 ... 3287bada2b

Autor SHA1 Mensaje Fecha
  DESKTOP-2HCHTFV\Xu 3287bada2b Revert "审核小改+押品完成" hace 5 meses
  DESKTOP-2HCHTFV\Xu 045acbbdec Merge remote-tracking branch 'origin/master' hace 5 meses
  DESKTOP-2HCHTFV\Xu a3df1d0290 审核小改+押品完成 hace 5 meses
  DESKTOP-2HCHTFV\Xu c9fb23856f 审核完成 hace 5 meses
  DESKTOP-2HCHTFV\Xu e8bc236386 审核完成 hace 5 meses
  DESKTOP-2HCHTFV\Xu 6dcc951108 审核完成 hace 5 meses
  DESKTOP-2HCHTFV\Xu 6d8b8555f2 Merge remote-tracking branch 'origin/master' hace 5 meses
  DESKTOP-2HCHTFV\Xu 8e0375b693 审核完成 hace 5 meses
Se han modificado 39 ficheros con 1049 adiciones y 411 borrados
  1. 28 0
      pom.xml
  2. 1 0
      src/main/java/com/loan/system/constant/JwtClaimsConstant.java
  3. 83 115
      src/main/java/com/loan/system/controller/wechat/ApprovalController.java
  4. 247 0
      src/main/java/com/loan/system/controller/wechat/CollateralController.java
  5. 138 138
      src/main/java/com/loan/system/controller/wechat/UserController.java
  6. 14 0
      src/main/java/com/loan/system/domain/WXAuth.java
  7. 25 0
      src/main/java/com/loan/system/domain/dto/CollateralPlanApprovalDTO.java
  8. 20 0
      src/main/java/com/loan/system/domain/dto/CollateralPlanDTO.java
  9. 16 0
      src/main/java/com/loan/system/domain/dto/CustomerLoginDTO.java
  10. 1 1
      src/main/java/com/loan/system/domain/entity/ApprovalRecord.java
  11. 54 0
      src/main/java/com/loan/system/domain/entity/CollateralPlan.java
  12. 39 0
      src/main/java/com/loan/system/domain/entity/CollateralRecord.java
  13. 3 0
      src/main/java/com/loan/system/domain/entity/LoanCase.java
  14. 16 0
      src/main/java/com/loan/system/domain/entity/TemplateMessage.java
  15. 7 1
      src/main/java/com/loan/system/domain/enums/DecisionEnum.java
  16. 8 0
      src/main/java/com/loan/system/domain/enums/ExceptionEnum.java
  17. 29 0
      src/main/java/com/loan/system/domain/vo/CollateralPlanVO.java
  18. 22 0
      src/main/java/com/loan/system/repository/ApprovalRepository.java
  19. 46 0
      src/main/java/com/loan/system/repository/CollateralPlanRepository.java
  20. 14 0
      src/main/java/com/loan/system/repository/CollateralRepository.java
  21. 24 0
      src/main/java/com/loan/system/repository/LoanCaseRepository.java
  22. 4 3
      src/main/java/com/loan/system/repository/LoanRepository.java
  23. 2 2
      src/main/java/com/loan/system/repository/StepRepository.java
  24. 7 1
      src/main/java/com/loan/system/repository/UserRepository.java
  25. 17 0
      src/main/java/com/loan/system/service/CollateralPlanService.java
  26. 8 0
      src/main/java/com/loan/system/service/CollateralService.java
  27. 65 0
      src/main/java/com/loan/system/service/Impl/CollateralPlanServiceImpl.java
  28. 14 0
      src/main/java/com/loan/system/service/Impl/CollateralServiceImpl.java
  29. 30 0
      src/main/java/com/loan/system/service/Impl/LoanCaseServiceImpl.java
  30. 2 2
      src/main/java/com/loan/system/service/Impl/LoanServiceImpl.java
  31. 7 1
      src/main/java/com/loan/system/service/Impl/StepServiceImpl.java
  32. 5 0
      src/main/java/com/loan/system/service/Impl/UserServiceImpl.java
  33. 11 0
      src/main/java/com/loan/system/service/LoanCaseService.java
  34. 1 1
      src/main/java/com/loan/system/service/LoanService.java
  35. 1 0
      src/main/java/com/loan/system/service/UserService.java
  36. 4 1
      src/main/java/com/loan/system/utils/JwtTokenUtil.java
  37. 0 122
      src/main/java/com/loan/system/utils/WeChatUtil.java
  38. 12 16
      src/main/resources/application-dev.yaml
  39. 24 7
      src/main/resources/application.yaml

+ 28 - 0
pom.xml

@@ -22,6 +22,32 @@
     </properties>
 
     <dependencies>
+        <dependency>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+            <version>20231013</version> <!-- 使用最新版本 -->
+        </dependency>
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.8.11</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.13</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.83</version>
+        </dependency>
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp</artifactId>
+            <version>4.10.0</version>
+        </dependency>
+
         <dependency>
             <groupId>javax.annotation</groupId>
             <artifactId>jsr250-api</artifactId>
@@ -307,6 +333,8 @@
                             <version>${org.lombok.version}</version>
                         </path>
                     </annotationProcessorPaths>
+                    <source>8</source>
+                    <target>8</target>
                 </configuration>
             </plugin>
         </plugins>

+ 1 - 0
src/main/java/com/loan/system/constant/JwtClaimsConstant.java

@@ -4,6 +4,7 @@ public class JwtClaimsConstant {
 
     public static final String EMP_ID = "empId";
     public static final String USER_ID = "userId";
+    public static final String CUSTOMER_ID = "customerId";
     public static final String PHONE = "phone";
     public static final String USERNAME = "username";
     public static final String NAME = "name";

+ 83 - 115
src/main/java/com/loan/system/controller/wechat/ApprovalController.java

@@ -1,7 +1,5 @@
 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.PreApprovalDTO;
 import com.loan.system.domain.entity.*;
@@ -20,17 +18,14 @@ import io.swagger.annotations.ApiOperation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
 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.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
+import java.util.Objects;
 
 import static com.loan.system.domain.enums.ExceptionEnum.*;
 
@@ -53,47 +48,56 @@ public class ApprovalController {
     private StepService stepService;
     @Autowired
     private JwtProperties jwtProperties;
-    @Autowired
-    private MessageService messageService;
 //    @Autowired
 //    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')")
     @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);
         User user = userService.findByIdAndIsDelete(userId);
         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());
         }
         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);
@@ -122,17 +126,7 @@ public class ApprovalController {
         stepService.updateStatusByCaseId(StepEnum.PROCESS.getMsg(), StepPropertyEnum.APPROVAL.getLabel(), preApprovalDTO.getCaseId());
         loanCaseService.updateUpdatetimeByIdAndIsDeleted(preApprovalDTO.getCaseId(),false);
         //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());
-
         return ResultUtil.success("success","预审通过");
     }
 
@@ -178,26 +172,30 @@ public class ApprovalController {
 //        return ResultUtil.success("success","审批通过");
 //    }
 
-    @PostMapping("/preapproval-records/reject")
+    @PostMapping("/preapproval-records/{caseId}/rejection")
     @PreAuthorize("@pms.hasAnyRoles('LEAD_SALES','ASSIST_SALES')")
     @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);
         User user = userService.findByIdAndIsDelete(userId);
         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());
         //判断过去处理人与目前处理人是否一致
         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("没找到对应以前审批记录");
@@ -218,71 +216,39 @@ public class ApprovalController {
             approvalService.updateDecisionByCaseIdAndStepNameAndIsDelete(DecisionEnum.REJECT.getMsg(),preApprovalDTO.getCaseId(),StepPropertyEnum.PRE_TRIAL.getLabel(),preApprovalDTO.getComments(),userId);
         }
         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);
         //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());
-
         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')")
     @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);
         //审批业务逻辑
-        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());
         //判断过去处理人与目前处理人是否一致
-        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("没找到对应以前审批记录");
@@ -304,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());
@@ -325,15 +291,16 @@ public class ApprovalController {
 
     }
 
-    @PostMapping("/approval/reject")
+    @PostMapping("/approval/{caseId}/rejection")
     @PreAuthorize("@pms.hasRole('APPROVER')")
     @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);
         //审批业务逻辑
-        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());
         }
         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()){
             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(), "环节已完成,无法重复审批");
         }
         //审批记录处理
@@ -366,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());
         }
         //更新环节状态
@@ -380,23 +347,24 @@ public class ApprovalController {
 
         return ResultUtil.success("success","审批驳回");
     }
-    @PostMapping("/approval/terminate")
+    @PostMapping("/approval/{caseId}/termination")
     @PreAuthorize("@pms.hasRole('APPROVER')")
     @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);
         //审批业务逻辑
-        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());
         }
         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(), "环节已完成,无法重复审批");
         }
         //审批记录处理
@@ -421,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());
         }
         //更新项目和环节状态 作逻辑删除
@@ -432,7 +400,7 @@ public class ApprovalController {
         }
         //TODO微信推送审批驳回消息和通知重新受理(到业务受理)
 
-        return ResultUtil.success("success","审批驳回");
+        return ResultUtil.success("success","业务终结");
     }
 }
 

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

@@ -0,0 +1,247 @@
+package com.loan.system.controller.wechat;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.loan.system.context.BaseContext;
+import com.loan.system.domain.dto.CollateralPlanApprovalDTO;
+import com.loan.system.domain.dto.CollateralPlanDTO;
+import com.loan.system.domain.entity.ApprovalRecord;
+import com.loan.system.domain.entity.Collateral;
+import com.loan.system.domain.entity.CollateralPlan;
+import com.loan.system.domain.entity.User;
+import com.loan.system.domain.enums.ExceptionEnum;
+import com.loan.system.domain.enums.RoleEnum;
+import com.loan.system.domain.pojo.Result;
+import com.loan.system.domain.vo.CollateralPlanVO;
+import com.loan.system.domain.vo.CollateralVO;
+import com.loan.system.service.ApprovalService;
+import com.loan.system.service.CollateralPlanService;
+import com.loan.system.service.CollateralService;
+import com.loan.system.service.Impl.UserServiceImpl;
+import com.loan.system.service.UserService;
+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 java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.loan.system.domain.enums.DecisionEnum.*;
+import static com.loan.system.domain.enums.ExceptionEnum.*;
+
+@RestController
+@RequestMapping("/wechat/collateral")
+@Api(tags = "抵押物接口")
+public class CollateralController {
+
+    @Autowired
+    private CollateralService collateralService;
+    @Autowired
+    private CollateralPlanService collateralPlanService;
+    @Autowired
+    private ApprovalService approvalService;
+    @Autowired
+    private UserService userService;
+    private static final Logger log = LoggerFactory.getLogger(UserServiceImpl.class);
+
+    //显示业务相关抵押物状态
+    @GetMapping("/{id}")
+    @ApiOperation("查看业务相关抵押物状态")
+    public Result findCollateral(@PathVariable("id") Long id){
+        List<CollateralVO> collaterals = collateralService.findByCaseId(id);
+        return ResultUtil.success("success",collaterals);
+    }
+    /**
+     * 查看项目抵押物计划
+     * @param id
+     * @return 响应
+    */
+    @GetMapping("/plan/{id}")
+    @ApiOperation("查看项目抵押物计划")
+    public Result findCollateralPlan(@PathVariable("id") Long id){
+        List<CollateralPlan> collateralPlans = collateralPlanService.findByCaseIdAndIsDelete(id,false);
+        if(collateralPlans == null || collateralPlans.isEmpty()){
+            return ResultUtil.error(COLLATERAL_PLAN_NOT_EXIST.getCode(),"计划不存在");
+        }
+
+        List<String> Roles=new ArrayList<>();
+        Roles.add(RoleEnum.LEAD_SALES.getMsg());
+        Roles.add(RoleEnum.ASSIST_SALES.getMsg());
+
+        // 创建VO列表
+        List<CollateralPlanVO> collateralPlanVOs = new ArrayList<>();
+        for(CollateralPlan plan : collateralPlans){
+            CollateralPlanVO vo = new CollateralPlanVO();
+            BeanUtil.copyProperties(plan, vo);
+            vo.setOperatorId(plan.getOperatorId());
+            vo.setOperatorName(plan.getOperatorName());
+            collateralPlanVOs.add(vo);
+        }
+
+        return ResultUtil.success("success",collateralPlanVOs);
+    }
+
+    /**
+     * 上报计划
+     * @return 响应
+    */
+    @PostMapping("/plan")
+    @PreAuthorize("@pms.hasAnyRoles('LEAD_SALES','ASSIST_SALES')")
+    @ApiOperation("上报计划")
+    public Result createCollateralPlan(@RequestBody CollateralPlanDTO collateralPlanDTO){
+        Collateral collaterals = collateralService.findCollateralById(collateralPlanDTO.getCollateralId());
+        if (collaterals == null){
+            return ResultUtil.error(COLLATERAL_NOT_EXIST.getCode(), "抵押物不存在");
+        }
+        List<CollateralPlan> collateralPlans=collateralPlanService.findByCollateralIdAndIsDelete(collateralPlanDTO.getCollateralId());
+        // 修改后的代码
+        for(CollateralPlan plan : collateralPlans){
+            // 如果状态既不是拒绝也不是执行完成,则返回错误
+            if(!plan.getStatus().equals(REJECTION.getMsg()) && !plan.getStatus().equals(EXECUTION_COMPLETE.getMsg())){
+                return ResultUtil.error(COLLATERAL_PLAN_ALREADY_EXIST.getCode(), COLLATERAL_PLAN_ALREADY_EXIST.getMsg());
+            }
+        }
+
+        Long userid = BaseContext.getCurrentId();
+        CollateralPlan collateralPlan = CollateralPlan.builder()
+                .collateralId(collateralPlanDTO.getCollateralId())
+                .caseId(collateralPlanDTO.getCaseId())
+                .time(collateralPlanDTO.getCollateralTime())
+                .place(collateralPlanDTO.getCollateralPlace())
+                .flag(collateralPlanDTO.getFlag())
+                .userId(userid)
+                .comments(collateralPlanDTO.getComments())
+                .createTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))
+                .updateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))
+                .status(WAITING_APPROVAL.getMsg())
+                .isDelete(false)
+                .build();
+        collateralPlanService.save(collateralPlan);
+        return ResultUtil.success("success", "计划上报成功");
+    }
+
+    /**
+     * 审批计划
+     * @param collateralPlanApprovalDTO
+     * @return 响应
+    */
+    @PostMapping("/plan/approval")
+    @PreAuthorize("@pms.hasRole('APPROVER')")
+    @ApiOperation("审批计划")
+    public Result refuseCollateralPlan(@RequestBody CollateralPlanApprovalDTO collateralPlanApprovalDTO){
+        CollateralPlan collateralPlan = collateralPlanService.findById(collateralPlanApprovalDTO.getId());
+        if(collateralPlan == null){
+            return ResultUtil.error(COLLATERAL_PLAN_NOT_EXIST.getCode(),"计划不存在");
+        }
+        log.info("collaterralplanid: " + collateralPlan.getId());
+        if(!collateralPlan.getStatus().equals(WAITING_APPROVAL.getMsg())){
+            return ResultUtil.error(COLLATERAL_PLAN_NOT_ALREADY_APPROVED.getCode(),COLLATERAL_PLAN_NOT_ALREADY_APPROVED.getMsg());
+        }
+        ApprovalRecord approvalRecord = ApprovalRecord.builder()
+                .caseId(collateralPlanApprovalDTO.getCaseId())
+                .stepName("押品管控环节")
+                .approverId(BaseContext.getCurrentId())
+                .decision(collateralPlanApprovalDTO.getDecision())
+                .comments(collateralPlanApprovalDTO.getComments())
+                .createTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))
+                .updateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))
+                .isDelete( false)
+                .build();
+        approvalService.save(approvalRecord);
+        log.info(collateralPlanApprovalDTO.getDecision());
+        log.info("操作者id"+collateralPlanApprovalDTO.getOperator().getId());
+        if("拒绝".equals(collateralPlanApprovalDTO.getDecision())){
+            collateralPlanService.updateCollateralStatusByid(collateralPlan.getId(), REJECTION.getMsg());
+            //collateralPlanService.logic_delete(collateralPlanApprovalDTO.getId());
+            return ResultUtil.success("success","计划已拒绝");
+        }else if("通过".equals(collateralPlanApprovalDTO.getDecision())){
+//            collateralPlanService.updateCollateraluserIdByid(collateralPlanApprovalDTO.getId(),collateralPlanApprovalDTO.getUserId());
+            collateralPlanService.updateCollateralStatusByid(collateralPlanApprovalDTO.getId(),WAITING_EXECUTION.getMsg());
+            // 修改 Controller 中的调用
+            collateralPlanService.updateCollateraloperatorIdByid(
+                    collateralPlan.getId(),
+                    collateralPlanApprovalDTO.getOperator().getId(),
+                    collateralPlanApprovalDTO.getOperator().getRealName()
+            );
+//TODO 改状态+微信推送下一个节点业务员
+            return ResultUtil.success("success","计划已通过");
+        }else{
+            return ResultUtil.error(ExceptionEnum.UNKNOWN_ERROR,"请选择通过或者拒绝");
+        }
+    }
+
+
+
+    /**确认抵押物入库,完成任务
+     *ID:计划id
+     */
+    @PostMapping("/warehouse/{id}")
+    @PreAuthorize("@pms.hasAnyRoles('LEAD_SALES','ASSIST_SALES')")
+    @ApiOperation("确认抵押物入库")
+    public Result warehouseCollateral(@PathVariable("id") Long id){
+        CollateralPlan collateralPlan = collateralPlanService.findByCollateralPlanId(id);
+        if(collateralPlan == null){
+            return ResultUtil.error(COLLATERAL_PLAN_NOT_EXIST.getCode(),"计划不存在");
+        }
+        if(!collateralPlan.getStatus().equals(WAITING_EXECUTION.getMsg())){
+            return ResultUtil.error(COLLATERAL_PLAN_NOT_ALREADY_EXECUTION.getCode(),COLLATERAL_PLAN_NOT_ALREADY_EXECUTION.getMsg());
+        }
+        if(!collateralPlan.getFlag().equals("入库")){
+            return ResultUtil.error(COLLATERAL_PLAN_NOT_EQUAL_WAREHOUSE.getCode(),COLLATERAL_PLAN_NOT_EQUAL_WAREHOUSE.getMsg());
+        }
+        Collateral collateral = collateralService.findCollateralById(collateralPlan.getCollateralId());
+        if(collateral == null){
+            return ResultUtil.error(COLLATERAL_NOT_EXIST.getCode(),"抵押物不存在");
+        }
+
+        collateralService.updateCollateralStatusByid(collateral.getId(),"入库");
+        collateralPlanService.updateCollateralStatusByid(id,EXECUTION_COMPLETE.getMsg());
+        return ResultUtil.success("success","抵押物入库成功");
+    }
+    /**确认抵押物出库,完成任务
+     *ID:计划id
+     */
+    @PostMapping("/outbound/{id}")
+    @PreAuthorize("@pms.hasAnyRoles('LEAD_SALES','ASSIST_SALES')")
+    @ApiOperation("确认抵押物出库")
+    public Result outboundCollateral(@PathVariable("id") Long id){
+        CollateralPlan collateralPlan = collateralPlanService.findByCollateralPlanId(id);
+        if(collateralPlan == null){
+            return ResultUtil.error(COLLATERAL_PLAN_NOT_EXIST.getCode(),"计划不存在");
+        }
+        if(!collateralPlan.getStatus().equals(WAITING_EXECUTION.getMsg())){
+            return ResultUtil.error(COLLATERAL_PLAN_NOT_ALREADY_EXECUTION.getCode(),COLLATERAL_PLAN_NOT_ALREADY_EXECUTION.getMsg());
+        }
+        if(!collateralPlan.getFlag().equals("出库")){
+            return ResultUtil.error(COLLATERAL_PLAN_NOT_EQUAL_OUTBOUND.getCode(),COLLATERAL_PLAN_NOT_EQUAL_OUTBOUND.getMsg());
+        }
+        Collateral collateral = collateralService.findCollateralById(collateralPlan.getCollateralId());
+        if(collateral == null){
+            return ResultUtil.error(COLLATERAL_NOT_EXIST.getCode(),"抵押物不存在");
+        }
+        collateralService.updateCollateralStatusByid(collateral.getId(),"出库");
+        collateralPlanService.updateCollateralStatusByid(id,EXECUTION_COMPLETE.getMsg());
+        return ResultUtil.success("success","抵押物出库成功");
+    }
+    /**删除抵押物
+     *
+     */
+    @PostMapping("/delete/{id}")
+    @PreAuthorize("@pms.hasAnyRoles('LEAD_SALES','ASSIST_SALES')")
+    @ApiOperation("删除抵押物")
+    public Result deleteCollateral(@PathVariable("id") Long id){
+        Collateral collateral = collateralService.findCollateralById(id);
+        if(collateral == null){
+            return ResultUtil.error(COLLATERAL_NOT_EXIST.getCode(),"抵押物不存在");
+        }
+        collateralService.logic_delete(id);
+        return ResultUtil.success("success","抵押物删除成功");
+    }
+
+}

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

@@ -71,152 +71,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")

+ 14 - 0
src/main/java/com/loan/system/domain/WXAuth.java

@@ -0,0 +1,14 @@
+package com.loan.system.domain;
+
+import lombok.Data;
+
+@Data
+public class WXAuth {
+    private String encryptedData;
+    private String iv;
+    private String sessionKey;
+    private String signature;
+    private String rawData;
+
+
+}

+ 25 - 0
src/main/java/com/loan/system/domain/dto/CollateralPlanApprovalDTO.java

@@ -0,0 +1,25 @@
+package com.loan.system.domain.dto;
+
+import com.loan.system.domain.entity.User;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.web.bind.annotation.PathVariable;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class CollateralPlanApprovalDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
+    private Long caseId;
+    private String comments;
+    private String decision;
+    private Long userId;
+    private User operator;
+}

+ 20 - 0
src/main/java/com/loan/system/domain/dto/CollateralPlanDTO.java

@@ -0,0 +1,20 @@
+package com.loan.system.domain.dto;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class CollateralPlanDTO extends CollateralDTO{
+    private static final long serialVersionUID = 1L;
+    private Long collateralId;
+    private Long caseId;
+    private String collateralName;
+    private String collateralTime;
+    private String collateralPlace;
+    private String comments;
+    private String flag;
+}

+ 16 - 0
src/main/java/com/loan/system/domain/dto/CustomerLoginDTO.java

@@ -0,0 +1,16 @@
+package com.loan.system.domain.dto;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class CustomerLoginDTO implements Serializable {
+    private String mobile;
+    private String openid;
+}

+ 1 - 1
src/main/java/com/loan/system/domain/entity/ApprovalRecord.java

@@ -5,7 +5,7 @@ import lombok.*;
 import javax.persistence.*;
 import java.time.Instant;
 
-
+@Builder
 @Entity
 @Table(name = "approval_record", indexes = {
         @Index(name = "idx_case_id", columnList = "case_id")

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

@@ -0,0 +1,54 @@
+package com.loan.system.domain.entity;
+
+import lombok.*;
+
+import javax.persistence.*;
+import java.time.Instant;
+@Builder
+@Entity
+@Table(name = "collateral_plan")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class CollateralPlan extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    @Column(name = "case_id")
+    private Long caseId;
+
+    @Column(name = "collateral_id")
+    private Long collateralId;
+
+    @Column(name = "user_id")
+    private Long userId;
+
+    @Column(name = "time")
+    private String time;
+
+    @Column(name = "place", length = 255)
+    private String place;
+
+    @Column(name = "flag", length = 10)
+    private String flag;
+
+    @Column(name = "comments")
+    private String comments;
+
+    @Column(name = "create_time")
+    private String  createTime;
+
+    @Column(name = "update_time")
+    private String  updateTime;
+
+    @Column(name = "is_delete")
+    private Boolean isDelete;
+
+    @Column(name = "status", length = 10)
+    private String status;
+
+    @Column(name="operator_id")
+    private Long operatorId;
+
+    @Column(name="operator_name")
+    private String operatorName;
+}

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

@@ -0,0 +1,39 @@
+package com.loan.system.domain.entity;
+
+import lombok.*;
+
+import javax.persistence.*;
+import java.time.Instant;
+
+@Entity
+@Table(name = "collateral_record")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class CollateralRecord extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    @Column(name = "case_id")
+    private Long caseId;
+
+    @Column(name = "collateral_id")
+    private Long collateralId;
+
+    @Column(name = "operation", length = 50)
+    private String operation;
+
+    @Column(name = "user_id")
+    private Long userId;
+
+    @Column(name = "comments")
+    private String comments;
+
+    @Column(name = "create_time")
+    private Instant createTime;
+
+    @Column(name = "update_time")
+    private Instant updateTime;
+
+    @Column(name = "is_delete")
+    private Boolean isDelete;
+}

+ 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;
 
 }

+ 16 - 0
src/main/java/com/loan/system/domain/entity/TemplateMessage.java

@@ -0,0 +1,16 @@
+package com.loan.system.domain.entity;
+
+import lombok.Data;
+
+import java.util.Map;
+
+@Data
+public class TemplateMessage {
+    private String touser;              // 接收者 openid
+    private String template_id;         // 模板 ID
+    private String page;                // 小程序内部页面路径(如 pages/review/detail?id=1)
+    private String url;                 // 可选,H5 外部链接
+    private Map<String, Object> miniprogram; // 可选,跳转其他小程序
+    private Map<String, Map<String, String>> data; // 模板数据
+    private String client_msg_id;
+}

+ 7 - 1
src/main/java/com/loan/system/domain/enums/DecisionEnum.java

@@ -6,7 +6,13 @@ package com.loan.system.domain.enums;
 public enum DecisionEnum {
     PASS("PASS", "通过"),
     REJECT("REJECT", "驳回"),
-    TERMINATE("TERMINATE", "终结");
+    TERMINATE("TERMINATE", "终结"),
+    WAITING_APPROVAL("WAIT_APPROVAL", "待审批"),
+    REJECTION("REJECTION", "拒绝"),
+    WAITING_EXECUTION("WAIT_EXECUTION", "待执行"),
+    EXECUTION_COMPLETE("EXECUTION_COMPLETE", "执行完成");
+
+
 
     private final String status;
     private final String msg;

+ 8 - 0
src/main/java/com/loan/system/domain/enums/ExceptionEnum.java

@@ -98,6 +98,14 @@ public enum ExceptionEnum {
     DISBURSEMENT_HAS_NOT_COMPLETED(-301, "出款未完成,无法新增"),
     DISBURSEMENT_HAS_COMPLETED(-302, "出款已完成,无法修改"),
 
+    COLLATERAL_NOT_EXIST(-310, "抵押物不存在"),
+    COLLATERAL_PLAN_NOT_EXIST(-311,"计划不存在"),
+    COLLATERAL_PLAN_NOT_ALREADY_APPROVED(-312,"计划未处于待审批状态"),
+    COLLATERAL_PLAN_NOT_ALREADY_EXECUTION(-313,"计划未处于待执行状态"),
+    COLLATERAL_PLAN_NOT_EQUAL_WAREHOUSE(-314,"计划与入库操作不符"),
+    COLLATERAL_PLAN_NOT_EQUAL_OUTBOUND(-315,"计划与出库操作不符"),
+    COLLATERAL_PLAN_ALREADY_EXIST(-316,"该押品已有计划未执行完成,不能重复添加"),
+
 
     STEP_EXIST(-350, "项目环节已存在"),
     STEP_NOT_EXIST(-351, "项目环节不存在"),

+ 29 - 0
src/main/java/com/loan/system/domain/vo/CollateralPlanVO.java

@@ -0,0 +1,29 @@
+package com.loan.system.domain.vo;
+
+import com.loan.system.domain.entity.User;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class CollateralPlanVO implements Serializable {
+    private Long id;
+    private Long caseId;
+    private Long collateralId;
+    private Long userId;
+    private String time;
+    private String place;
+    private String flag;
+    private String comments;
+    private String createTime;
+    private String updateTime;
+    private String status;
+    private Long operatorId;
+    private String operatorName;
+    private Boolean isDelete;
+}

+ 22 - 0
src/main/java/com/loan/system/repository/ApprovalRepository.java

@@ -0,0 +1,22 @@
+package com.loan.system.repository;
+
+import com.loan.system.domain.entity.ApprovalRecord;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+public interface ApprovalRepository extends JpaRepository<ApprovalRecord,Long> {
+    List<ApprovalRecord> findByCaseIdAndIsDelete(Long id, Boolean isDelete);
+
+    ApprovalRecord findByCaseIdAndIsDeleteAndStepNameAndApproverId(Long caseId, Boolean isDelete, String stepName,Long approverId);
+
+    @Modifying
+    @Transactional
+    @Query(value = "UPDATE approval_record SET decision = ?1, update_time = ?5, comments = ?6 WHERE case_id = ?2 AND step_name = ?3 AND is_delete = ?4 AND approver_id = ?7", nativeQuery = true)
+    void updateDecisionByCaseIdAndStepNameAndIsDeleteAndApproverId(String decision, Long caseId, String stepName, Boolean isDelete,String updateTime,String  comments, Long approverId);
+
+}

+ 46 - 0
src/main/java/com/loan/system/repository/CollateralPlanRepository.java

@@ -0,0 +1,46 @@
+package com.loan.system.repository;
+
+
+import com.loan.system.domain.entity.CollateralPlan;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+public interface CollateralPlanRepository extends JpaRepository<CollateralPlan,Long> {
+
+    @Query("select c from CollateralPlan c where c.collateralId = ?1 and c.isDelete = ?2 and c.status='待审批'")
+    CollateralPlan findByCollateralIdAndIsDelete(Long collateralId, boolean isDelete);
+
+    @Query("select c from CollateralPlan c where c.id = ?1 and c.isDelete = ?2")
+    CollateralPlan findByIdAndIsDelete(Long id, Boolean isDelete);
+
+    @Query("select c from CollateralPlan c where c.collateralId = ?1 and c.isDelete = ?2")
+    List<CollateralPlan> findsByCollateralIdAndIsDelete(Long collateralId, boolean isDelete);
+
+    @Query("select c from CollateralPlan c where c.caseId = ?1 and c.isDelete = ?2")
+    List<CollateralPlan> findByCaseIdAndIsDelete(Long caseId, boolean isDelete);
+
+    @Modifying
+    @Transactional
+    @Query("update CollateralPlan c set c.isDelete = true where c.id = ?1")
+    void logic_delete(Long id);
+
+    @Modifying
+    @Transactional
+    @Query("update CollateralPlan c set c.userId = ?2 , c.updateTime=CURRENT_TIMESTAMP where c.collateralId = ?1")
+    void updateCollateralUserIdeByid(Long collateralId, Long userId);
+
+    @Modifying
+    @Transactional
+    @Query("update CollateralPlan c set c.status = ?2 , c.updateTime=CURRENT_TIMESTAMP where c.id = ?1")
+    void updateCollateralStatusByid(Long collateralId, String status);
+
+    @Modifying
+    @Transactional
+    @Query("update CollateralPlan c set c.operatorId = ?2 , c.operatorName = ?3 , c.updateTime=CURRENT_TIMESTAMP where c.id = ?1")
+    void updateCollateraloperatorIdByid(Long collateralId, Long operatorId,String operatorName);
+
+}

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

@@ -43,4 +43,18 @@ 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);
+
+    @Query("SELECT c FROM Collateral c WHERE c.id = ?1 And c.isDelete = false")
+    Collateral findCollateralById(Long id);
 }

+ 24 - 0
src/main/java/com/loan/system/repository/LoanCaseRepository.java

@@ -0,0 +1,24 @@
+package com.loan.system.repository;
+
+
+import com.loan.system.domain.entity.LoanCase;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.transaction.annotation.Transactional;
+
+public interface LoanCaseRepository extends JpaRepository<LoanCase,Long> {
+    LoanCase findByIdAndIsDelete(Long customerId,boolean isDelete);
+
+    @Modifying
+    @Transactional
+    @Query("update LoanCase set updateTime = ?3 where id = ?1 and isDelete = ?2")
+    void updateUpdatetimeByIdAndIsDeleted(Long id,boolean isDelete,String updateTime);
+
+    @Modifying
+    @Transactional
+    @Query("UPDATE LoanCase SET updateTime = ?3, isDelete = ?2 WHERE id = ?1 AND isDelete = ?2")
+    void logic_delete(Long id, boolean isDelete, String updateTime);
+
+
+}

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

@@ -35,8 +35,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
@@ -45,7 +46,7 @@ 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);
 
     Boolean existsByIdAndIsDelete(Long caseId, boolean isDelete);

+ 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);
 }

+ 7 - 1
src/main/java/com/loan/system/repository/UserRepository.java

@@ -1,7 +1,6 @@
 package com.loan.system.repository;
 
 import com.loan.system.domain.entity.User;
-import com.loan.system.domain.vo.UserVO;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
@@ -46,4 +45,11 @@ public interface UserRepository extends JpaRepository<User,Long> {
     @Modifying
     @Query("update User u set u.role = ?1 where u.id = ?2")
     void updateRoleById(String role,Long id);
+
+    @Query("select u from User u where (u.role like %?1% or u.role = ?1) and u.isDelete = ?2")
+    List<User> findByRoleLikeAndIsDelete(String role, Boolean isDelete);
+
+    @Query("select u from User u where u.role in ?1 and u.isDelete = ?2")
+    List<User> findByRoleInAndIsDelete(List<String> roles, Boolean isDelete);
+
 }

+ 17 - 0
src/main/java/com/loan/system/service/CollateralPlanService.java

@@ -0,0 +1,17 @@
+package com.loan.system.service;
+
+import com.loan.system.domain.entity.CollateralPlan;
+
+import java.util.List;
+
+public interface CollateralPlanService {
+    void save(CollateralPlan collateralPlan);
+    CollateralPlan findByCollateralPlanId(Long id);
+    void logic_delete(Long id);
+    void updateCollateraluserIdByid(Long collateralId, Long userId);
+    List<CollateralPlan> findByCaseIdAndIsDelete(Long caseId, boolean isDelete);
+    void updateCollateralStatusByid(Long collateralId, String status);
+    void updateCollateraloperatorIdByid(Long planId, Long operatorId, String operatorName);
+    List<CollateralPlan> findByCollateralIdAndIsDelete(Long collateralId);
+    CollateralPlan findById(Long id);
+}

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

@@ -13,7 +13,15 @@ public interface CollateralService {
 
     Collateral saveCollateral(CollateralDTO collateralDTO);
 
+    Collateral findCollateralById(Long id);
+
     void updateCollateralById(Long id, CollateralDTO collateralDTO, boolean isDelete);
 
     void deleteAllByCaseId(Long caseId);
+
+    void logic_delete(Long id);
+
+    void updateCollateralStatusByid(Long id,String  status);
+
+
 }

+ 65 - 0
src/main/java/com/loan/system/service/Impl/CollateralPlanServiceImpl.java

@@ -0,0 +1,65 @@
+package com.loan.system.service.Impl;
+
+import com.loan.system.domain.entity.CollateralPlan;
+import com.loan.system.repository.CollateralPlanRepository;
+import com.loan.system.repository.CollateralRepository;
+import com.loan.system.service.CollateralPlanService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class CollateralPlanServiceImpl implements CollateralPlanService {
+
+    private final CollateralPlanRepository collateralPlanRepository;
+
+    public CollateralPlanServiceImpl(CollateralPlanRepository collateralPlanRepository) {
+        this.collateralPlanRepository = collateralPlanRepository;
+    }
+
+
+    @Override
+    public void save(CollateralPlan collateralPlan) {
+        collateralPlanRepository.save(collateralPlan);
+    }
+
+    @Override
+    public CollateralPlan findByCollateralPlanId(Long id){
+        return collateralPlanRepository.findByIdAndIsDelete(id,false);
+    }
+
+    @Override
+    public void logic_delete(Long id){
+        collateralPlanRepository.logic_delete(id);
+    }
+
+    @Override
+    public void updateCollateraluserIdByid(Long id,Long userId){
+        collateralPlanRepository.updateCollateralUserIdeByid(id,userId);
+    }
+
+    @Override
+    public List<CollateralPlan> findByCaseIdAndIsDelete(Long caseId, boolean isDelete){
+        return collateralPlanRepository.findByCaseIdAndIsDelete(caseId,isDelete);
+    };
+
+    @Override
+    public  void updateCollateralStatusByid(Long collateralId, String status){
+        collateralPlanRepository.updateCollateralStatusByid(collateralId,status);
+    }
+
+    @Override
+    public void updateCollateraloperatorIdByid(Long planId, Long operatorId, String operatorName){
+        collateralPlanRepository.updateCollateraloperatorIdByid(planId,operatorId,operatorName);
+    };
+
+    @Override
+    public List<CollateralPlan> findByCollateralIdAndIsDelete(Long collateralId){
+        return collateralPlanRepository.findsByCollateralIdAndIsDelete(collateralId,false);
+    }
+
+    @Override
+    public CollateralPlan findById(Long id){
+        return collateralPlanRepository.findByIdAndIsDelete(id,false);
+    }
+}

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

@@ -52,4 +52,18 @@ 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);
+    }
+    @Override
+    public Collateral findCollateralById(Long id){
+        return collateralRepository.findCollateralById(id);
+    }
 }
+

+ 30 - 0
src/main/java/com/loan/system/service/Impl/LoanCaseServiceImpl.java

@@ -0,0 +1,30 @@
+package com.loan.system.service.Impl;
+
+import com.loan.system.domain.entity.LoanCase;
+import com.loan.system.repository.LoanCaseRepository;
+import com.loan.system.service.LoanCaseService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+@Service
+public class LoanCaseServiceImpl implements LoanCaseService {
+    @Autowired
+    private LoanCaseRepository LoanCaseRepository;
+
+    @Override
+
+    public LoanCase findByIdAndIsDelete(Long id){
+        return LoanCaseRepository.findByIdAndIsDelete(id,false);
+    };
+    @Override
+    public void updateUpdatetimeByIdAndIsDeleted(Long id,boolean isDelete){
+        LoanCaseRepository.updateUpdatetimeByIdAndIsDeleted(id,false, LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+    }
+    @Override
+    public void logic_delete(Long id){
+           LoanCaseRepository.logic_delete(id, true, LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+    }
+}

+ 2 - 2
src/main/java/com/loan/system/service/Impl/LoanServiceImpl.java

@@ -150,8 +150,8 @@ public class LoanServiceImpl implements LoanService {
     }
 
     @Override
-    public LoanCase findLoanCaseByIdAndIsDelete(Long caseId, boolean isDelete) {
-        return loanRepository.findLoanCaseById(caseId, isDelete);
+    public LoanCaseVO findLoanCaseByIdAndIsDelete(Long caseId, boolean isDelete) {
+        return BeanUtil.copyProperties(loanRepository.findLoanCaseById(caseId, isDelete), LoanCaseVO.class);
     }
 
     @Override

+ 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

+ 5 - 0
src/main/java/com/loan/system/service/Impl/UserServiceImpl.java

@@ -228,4 +228,9 @@ public class UserServiceImpl implements UserService {
         return userRepository.findByIdAndIsDelete(id,false);
     }
 
+    @Override
+    public List<User> findByRoleAndIsDelete(List<String> role, boolean isDelete){
+        return userRepository.findByRoleInAndIsDelete(role,isDelete);
+    };
+
 }

+ 11 - 0
src/main/java/com/loan/system/service/LoanCaseService.java

@@ -0,0 +1,11 @@
+package com.loan.system.service;
+
+import com.loan.system.domain.entity.LoanCase;
+
+public interface LoanCaseService {
+    LoanCase findByIdAndIsDelete(Long id);
+
+    void updateUpdatetimeByIdAndIsDeleted(Long id,boolean isDelete);
+
+    void logic_delete(Long id);
+}

+ 1 - 1
src/main/java/com/loan/system/service/LoanService.java

@@ -16,7 +16,7 @@ public interface LoanService {
 
     LoanCaseVO findLoanCaseDetailsById(Long caseId);
 
-    LoanCase findLoanCaseByIdAndIsDelete(Long caseId, boolean isDelete);
+    LoanCaseVO findLoanCaseByIdAndIsDelete(Long caseId, boolean isDelete);
 
     void updateUpdatetimeByIdAndIsDeleted(Long id,boolean isDelete);
 

+ 1 - 0
src/main/java/com/loan/system/service/UserService.java

@@ -38,4 +38,5 @@ public interface UserService {
     void deleteUserByLogic(Long id);
 
     void updateUserRole(String role,Long id);
+    List<User> findByRoleAndIsDelete(List<String> role, boolean isDelete);
 }

+ 4 - 1
src/main/java/com/loan/system/utils/JwtTokenUtil.java

@@ -1,5 +1,6 @@
 package com.loan.system.utils;
 
+import com.loan.system.constant.JwtClaimsConstant;
 import io.jsonwebtoken.Claims;
 import io.jsonwebtoken.ExpiredJwtException;
 import io.jsonwebtoken.Jwts;
@@ -86,7 +87,9 @@ public class JwtTokenUtil implements Serializable {
     public static String getUsernameFromToken(String token) {
         return getClaimsFromToken(token).getSubject();
     }
-
+    public static Long getUserIdFromToken(String token){
+        return (Long) getClaimsFromToken(token).get(JwtClaimsConstant.USER_ID);
+    }
     public static String getNumberFromToken(String token){
         return (String) getClaimsFromToken(token).get("number");
     }

+ 0 - 122
src/main/java/com/loan/system/utils/WeChatUtil.java

@@ -1,122 +0,0 @@
-package com.loan.system.utils;
-
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.commons.codec.binary.Base64;
-import org.codehaus.xfire.client.Client;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author raptor
- * @description WeChatUtil
- * @date 2021/4/1 13:21
- */
-public class WeChatUtil {
-    private static ObjectMapper mapper = new ObjectMapper();
-    private static ApplicationContext appContext;
-
-    /**
-     *
-     * @param person_info
-     * 接收人信息,每个人员信息格式为:名字|学工号|部门ID|部门名称|对应微信账号,
-     * 人与人之间用“^@^”隔开(如果数据无法提供,可以写空,但是“|”不可省略),必须
-     *                      "raptor|202050235|11644008804352|杭州电子科技大学|18758159060"
-     * @param priority  发送优先级(1:紧急通知;2:验证码;3:立即发送;4:发送),必须
-     * @param wechat_info   内容,必须
-     * @return  {"result":true,"msg_id":"22961055561793536","msg":"发布成功"}
-     */
-    public static Object sendWeChatMessage(String person_info, String priority, String wechat_info){
-        Map<String, Object> map = new HashMap<String, Object>(16);
-        try {
-            appContext = new ClassPathXmlApplicationContext(new String[] {});
-            // webservice 地址由生产环境决定
-            org.springframework.core.io.Resource resource = appContext
-                    .getResource("http://i.hdu.edu.cn/tp_mp/service/WechatService?wsdl");
-
-            /** start 协议参数 start **/
-            // 调用接口的第三方系统协议名称。由双方协议确定。(*必填项)
-            map.put("tp_name", "Document");
-            // 提供接口服务的系统名称(sys/up/mp…)。由统一门户系统提供。(*必填项)
-            map.put("sys_id", "mp");
-            // 接口方法所属模块。由统一门户系统提供。(*必填项)
-            map.put("module_id", "wechat");
-            // SHA 加密后第三方系统的权限密钥值。权限密钥由统一门户系统提供。(*必填项)
-            map.put("secret_key", getSHA("xWpDa+fGlqkXGUZLNjawGT+9MHw="));
-            // 对应的接口方法名称,由统一门户系统提供。(*必填项)
-            map.put("interface_method", "saveWechatInfo");
-            /** end 协议参数 end **/
-
-            map.put("person_info", person_info);
-
-            map.put("send_priority", priority);
-
-            /** start 业务参数 start **/
-            //发送微信发布类型(text:⽂本;news:图⽂;image:图⽚;file:⽂件;video:视频;voice:⾳频),不可为空,参数不可省略
-            map.put("wechat_type", "text");
-            //内容,必须
-            map.put("wechat_info", wechat_info);
-            //发送⼈ID_NUMBER,需要发送回执的时候不可为空,参数不可省略
-            map.put("operator_id_number", "09901");
-            //发送微信附件(包括图⽚,⽂件,视频和⾳频的附件路径),为空,参数不可	省略
-            map.put("wechat_attachment", "");
-            //发送附件名称,为空,参数不可省略
-            map.put("attachment_name", "");
-            //发送附件标题,为空,参数不可省略
-            map.put("attachment_title", "");
-            //发送附件描述,为空,参数不可省略
-            map.put("attachment_des", "");
-            //发送附件时⻓(视频和⾳频),为空,参数不可省略
-            map.put("attachment_time", "");
-            //发送模板选择,不发送模板值为”0”,参数不可省略
-            map.put("templet_id", "0");
-            //发送回执选择,不发送回执值为”0”,参数不可省略
-            map.put("receipt_id", "0");
-            //发送⼈签名,根据模板⽽定,选择的模板有“发送⼈签名”标签的需要写值,其他为空,参数不可省略
-            map.put("person_send", "公管处");
-            /** end 业务参数 end **/
-
-
-
-            String json = mapper.writeValueAsString(map);
-            // 请求参数
-            System.out.println("json:" + json);
-
-            Client client = new Client(resource.getInputStream(), null);
-            Object[] result = client.invoke("saveWechatInfo", new Object[] { json });
-
-            // 返回结果
-            System.out.println(result[0]);
-
-            client.close();
-            return result[0];
-        } catch (Exception e) {
-            e.printStackTrace();
-            return null;
-        }
-    }
-    /**
-     * 获取 SHA 值  
-     *
-     * @author neusoft
-     * @since V7.0
-     * @param password
-     * @return SHA(password)
-     */
-    private static String getSHA(String password) {
-        try {
-            MessageDigest sha = MessageDigest.getInstance("SHA");
-            sha.update(password.getBytes());
-            byte[] hash = sha.digest();
-            return new String(Base64.encodeBase64(hash));
-        } catch (NoSuchAlgorithmException e1) {
-            e1.printStackTrace();
-        }
-        return "";
-    }
-}

+ 12 - 16
src/main/resources/application-dev.yaml

@@ -1,15 +1,12 @@
 server:
   port: 8080
-  servlet:
-    context-path: /api
 
 spring:
-  servlet:
-    multipart:
-      enabled: true
-      max-file-size: 20MB     # 单个文件最大 20MB
-      max-request-size: 100MB # 总请求大小限制
-
+#  servlet:
+#    multipart:
+#      enabled: true
+#      max-file-size: 10MB
+#      max-request-size: 30MB
   aop:
     proxy-target-class: true
     auto: true
@@ -61,18 +58,17 @@ spring:
     driver-class-name: com.mysql.cj.jdbc.Driver
     url: jdbc:mysql://localhost:3306/loan_system?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai #改
     username: root
-    password: wgw20030620 #改
+    password: xjj010430 #改
 mybatis:
   mapper-locations: classpath*:/mapping/*Mapper.xml
  # type-aliases-package: com.he.common.entity.domain
 
 upload:
   host: "http://tczbus.natappfree.cc/uploads"
-  location: "classpath:file_store" #改
-  extensions: "pdf,doc,docx,xls,xlsx,JPG,jpg,bmp,BMP,gif,GIF,BMP,png,PNG,bmp,jpeg,JPEG,svg,txt"
-  templatePath: "classpath:file_store\\template\\template1.docx" #改
+  location: "C:\\Users\\Xu\\Documents\\loan_project" #改
+  extensions: "pdf,doc,docx,xlsx,JPG,jpg,bmp,BMP,gif,GIF,BMP,png,PNG,bmp,jpeg,JPEG,svg,txt"
+  #改
 
-system:
-  wechat:
-    appid: wx9c0acf979455549f
-    secret: 37452088548ea9cc6e244dc7817d938d
+wechat:
+  appid: wx9c0acf979455549f
+  secret: 37452088548ea9cc6e244dc7817d938d

+ 24 - 7
src/main/resources/application.yaml

@@ -6,6 +6,19 @@ spring:
       enabled: true
       max-file-size: 50MB
       max-request-size: 50MB
+#  mail:
+#    host: mail2010.hollysys.net
+#    username: fczf@hollysys.net
+#    password: Hls123456
+#    port: 443
+#    default-encoding: utf-8
+#    properties:
+#      mail:
+#        debug: true
+##        smtp:
+##          socketFactory:
+##            class: javax.net.ssl.SSLSocketFactory
+#    protocol: smtp
 
 JWT:
   LOGIN_URL: "/login"
@@ -19,12 +32,16 @@ logging:
   level:
     root:
       info
-
+upload:
+  templatePath: C:\\Users\\Xu\\Documents\\loan_project
 system:
   jwt:
-    user-secret-key: loanSystemTest
-    user-ttl: 604800000
-    user-token-name: Authorization
-    admin-secret-key: loanSystemTest
-    admin-ttl: 604800000
-    admin-token-name: Authorization
+    user-secret-key: "HDU-JUAasSDSAds*87ASud/A?D(G+KbPeShVmYq3s6v9y$B&E)H@McQfTjWnZr4u7w"
+    user-ttl: 60480000
+    userTokenName: Authorization
+    admin-secret-key: "HDU-JUAasSDSAds*87ASud/A?D(G+KbPeShVmYq3s6v9y$B&E)H@McQfTjWnZr4u7w"
+    admin-ttl: 60480000
+    adminTokenName: Authorization
+wechat:
+  appid: wx9c0acf979455549f
+  secret: 37452088548ea9cc6e244dc7817d938d