Przeglądaj źródła

Merge remote-tracking branch 'origin/test' into test-dismantle

785834757 2 lat temu
rodzic
commit
fe717c425a
100 zmienionych plików z 3451 dodań i 354 usunięć
  1. 1 1
      src/main/java/com/ydtech/SpringInsApplication.java
  2. 1 2
      src/main/java/com/ydtech/config/properties/BohaiApiConfigurationProperties.java
  3. 32 0
      src/main/java/com/ydtech/modules/admin/controller/SysAmountAuditingController.java
  4. 63 0
      src/main/java/com/ydtech/modules/admin/controller/SysDeptAccountController.java
  5. 4 1
      src/main/java/com/ydtech/modules/admin/controller/SysLoginController.java
  6. 48 0
      src/main/java/com/ydtech/modules/admin/controller/SysUserAccountController.java
  7. 59 0
      src/main/java/com/ydtech/modules/admin/controller/SysUserAccountHistoryController.java
  8. 70 0
      src/main/java/com/ydtech/modules/admin/controller/SysUserBankController.java
  9. 11 0
      src/main/java/com/ydtech/modules/admin/dao/SysAmountAuditingMapper.java
  10. 10 0
      src/main/java/com/ydtech/modules/admin/dao/SysDeptAccountDao.java
  11. 6 0
      src/main/java/com/ydtech/modules/admin/dao/SysUserAccountMapper.java
  12. 4 0
      src/main/java/com/ydtech/modules/admin/dao/SysUserBankCardMapper.java
  13. 42 0
      src/main/java/com/ydtech/modules/admin/model/SysDeptAccountEntity.java
  14. 55 0
      src/main/java/com/ydtech/modules/admin/model/po/SysAmountAuditingEntity.java
  15. 67 0
      src/main/java/com/ydtech/modules/admin/model/po/SysUserAccount.java
  16. 3 0
      src/main/java/com/ydtech/modules/admin/model/po/SysUserAccountHistory.java
  17. 6 1
      src/main/java/com/ydtech/modules/admin/model/po/SysUserBankCard.java
  18. 52 0
      src/main/java/com/ydtech/modules/admin/model/vo/SysAmountAuditingVo.java
  19. 45 0
      src/main/java/com/ydtech/modules/admin/model/vo/SysDeptAccountVO.java
  20. 64 0
      src/main/java/com/ydtech/modules/admin/model/vo/SysUserAccountHistoryVo.java
  21. 99 0
      src/main/java/com/ydtech/modules/admin/model/vo/SysUserAccountVo.java
  22. 51 0
      src/main/java/com/ydtech/modules/admin/model/vo/SysUserBankCardVO.java
  23. 11 0
      src/main/java/com/ydtech/modules/admin/service/SysAmountAuditingService.java
  24. 21 0
      src/main/java/com/ydtech/modules/admin/service/SysDeptAccountService.java
  25. 11 0
      src/main/java/com/ydtech/modules/admin/service/SysUserAccountHistoryService.java
  26. 10 0
      src/main/java/com/ydtech/modules/admin/service/SysUserAccountService.java
  27. 15 0
      src/main/java/com/ydtech/modules/admin/service/SysUserBankCardService.java
  28. 68 0
      src/main/java/com/ydtech/modules/admin/service/impl/SysAmountAuditingServiceImpl.java
  29. 91 0
      src/main/java/com/ydtech/modules/admin/service/impl/SysDeptAccountServiceImpl.java
  30. 62 0
      src/main/java/com/ydtech/modules/admin/service/impl/SysUserAccountHistoryServiceImpl.java
  31. 246 7
      src/main/java/com/ydtech/modules/admin/service/impl/SysUserAccountServiceImpl.java
  32. 63 5
      src/main/java/com/ydtech/modules/admin/service/impl/SysUserBankCardServiceImpl.java
  33. 57 42
      src/main/java/com/ydtech/modules/fee/dto/vo/RuleAttrMappingVo.java
  34. 60 2
      src/main/java/com/ydtech/modules/fee/service/impl/FeeRuleSchemeServiceNewImpl.java
  35. 1 0
      src/main/java/com/ydtech/modules/fnc/controller/CarSettleController.java
  36. 138 69
      src/main/java/com/ydtech/modules/fnc/service/impl/InsFeeAuditServiceImpl.java
  37. 4 5
      src/main/java/com/ydtech/modules/ins/model/yc/YcBuildData.java
  38. 31 1
      src/main/java/com/ydtech/modules/inv/controller/InvReceivableController.java
  39. 48 0
      src/main/java/com/ydtech/modules/inv/model/po/InvSettlementSource.java
  40. 11 2
      src/main/java/com/ydtech/modules/inv/model/po/InvSource.java
  41. 23 0
      src/main/java/com/ydtech/modules/inv/model/vo/InvSettlementSourceQueryVo.java
  42. 3 3
      src/main/java/com/ydtech/modules/inv/model/vo/InvSourceQueryVo.java
  43. 2 0
      src/main/java/com/ydtech/modules/inv/service/InvReceivableService.java
  44. 76 25
      src/main/java/com/ydtech/modules/inv/service/impl/InvReceivableServiceImpl.java
  45. 8 0
      src/main/java/com/ydtech/modules/inv/service/impl/InvSettlementSourceServiceImpl.java
  46. 2 1
      src/main/java/com/ydtech/modules/inv/service/impl/InvSourceServiceImpl.java
  47. 1 0
      src/main/java/com/ydtech/modules/order/components/ConfigureParametersComponents.java
  48. 81 3
      src/main/java/com/ydtech/modules/order/components/FileComponents.java
  49. 45 32
      src/main/java/com/ydtech/modules/order/components/bohai/BoHaiRequestApiComponent.java
  50. 6 0
      src/main/java/com/ydtech/modules/order/constants/OrderCacheConstant.java
  51. 8 0
      src/main/java/com/ydtech/modules/order/controller/BoHaiOrderApiController.java
  52. 3 2
      src/main/java/com/ydtech/modules/order/controller/IdentifyController.java
  53. 3 0
      src/main/java/com/ydtech/modules/order/dao/InsAreaCompanyMapper.java
  54. 0 3
      src/main/java/com/ydtech/modules/order/entity/InsAreaCompany.java
  55. 2 2
      src/main/java/com/ydtech/modules/order/entity/api/bohai/BoHaiEncrypted.java
  56. 18 0
      src/main/java/com/ydtech/modules/order/entity/api/bohai/constants/InsuranceType.java
  57. 0 4
      src/main/java/com/ydtech/modules/order/entity/api/bohai/constants/RequestType.java
  58. 14 5
      src/main/java/com/ydtech/modules/order/entity/api/bohai/request/BoHaiBaseRequest.java
  59. 1 1
      src/main/java/com/ydtech/modules/order/entity/api/bohai/request/ElectronicPolicyRequest.java
  60. 1 1
      src/main/java/com/ydtech/modules/order/entity/api/bohai/request/GenerateOrderNoRequest.java
  61. 1 1
      src/main/java/com/ydtech/modules/order/entity/api/bohai/request/ImageUploadRequest.java
  62. 6 1
      src/main/java/com/ydtech/modules/order/entity/api/bohai/request/PaymentRequest.java
  63. 36 0
      src/main/java/com/ydtech/modules/order/entity/api/bohai/request/PolicyResultCallbackRequest.java
  64. 1 1
      src/main/java/com/ydtech/modules/order/entity/api/bohai/request/QuotationRequest.java
  65. 1 1
      src/main/java/com/ydtech/modules/order/entity/api/bohai/request/StatusDocumentsRequest.java
  66. 1 1
      src/main/java/com/ydtech/modules/order/entity/api/bohai/request/UnderwritingRequest.java
  67. 1 1
      src/main/java/com/ydtech/modules/order/entity/api/bohai/request/VehicleConfirmationReqeust.java
  68. 1 1
      src/main/java/com/ydtech/modules/order/entity/api/bohai/request/VehicleTypeQueryRequest.java
  69. 3 0
      src/main/java/com/ydtech/modules/order/entity/api/bohai/response/ElectronicPolicyResponse.java
  70. 12 10
      src/main/java/com/ydtech/modules/order/entity/api/bohai/response/PaymentResponse.java
  71. 2 2
      src/main/java/com/ydtech/modules/order/entity/crawler/vo/CrawlerPolicyPrintVo.java
  72. 13 2
      src/main/java/com/ydtech/modules/order/service/BoHaiOrderApiService.java
  73. 3 2
      src/main/java/com/ydtech/modules/order/service/IdentifyService.java
  74. 4 0
      src/main/java/com/ydtech/modules/order/service/InsAreaCompanyService.java
  75. 72 34
      src/main/java/com/ydtech/modules/order/service/impl/BoHaiOrderApiServiceImpl.java
  76. 79 14
      src/main/java/com/ydtech/modules/order/service/impl/IdentifyServiceImpl.java
  77. 5 0
      src/main/java/com/ydtech/modules/order/service/impl/InsAreaCompanyServiceImpl.java
  78. 12 1
      src/main/java/com/ydtech/modules/order/service/impl/InsOrdersServiceImpl.java
  79. 3 0
      src/main/java/com/ydtech/modules/protocol/service/impl/PtlAgreementServiceImpl.java
  80. 81 0
      src/main/java/com/ydtech/modules/protocols/controller/PtlNewAgreementHistoryController.java
  81. 19 0
      src/main/java/com/ydtech/modules/protocols/dao/PtlAgreementProductCostsAttrLinkHistoryMapper.java
  82. 23 0
      src/main/java/com/ydtech/modules/protocols/dao/PtlAgreementProductCostsNewHistoryMapper.java
  83. 19 0
      src/main/java/com/ydtech/modules/protocols/dao/PtlAgreementUndwrtRulesAttrLinkHistoryMapper.java
  84. 24 0
      src/main/java/com/ydtech/modules/protocols/dao/PtlAgreementUndwrtRulesNewHistoryMapper.java
  85. 77 0
      src/main/java/com/ydtech/modules/protocols/entity/po/PtlAgreementProductCostsAttrLinkHistory.java
  86. 203 0
      src/main/java/com/ydtech/modules/protocols/entity/po/PtlAgreementProductCostsNewHistory.java
  87. 76 0
      src/main/java/com/ydtech/modules/protocols/entity/po/PtlAgreementUndwrtRulesAttrLinkHistory.java
  88. 4 0
      src/main/java/com/ydtech/modules/protocols/entity/po/PtlAgreementUndwrtRulesNew.java
  89. 72 0
      src/main/java/com/ydtech/modules/protocols/entity/po/PtlAgreementUndwrtRulesNewHistory.java
  90. 19 18
      src/main/java/com/ydtech/modules/protocols/entity/vo/AgreementProductCosts.java
  91. 1 1
      src/main/java/com/ydtech/modules/protocols/entity/vo/AgreementProductCostsSave.java
  92. 14 0
      src/main/java/com/ydtech/modules/protocols/service/PtlAgreementProductCostsAttrLinkHistoryService.java
  93. 24 0
      src/main/java/com/ydtech/modules/protocols/service/PtlAgreementProductCostsNewHistoryService.java
  94. 14 0
      src/main/java/com/ydtech/modules/protocols/service/PtlAgreementUndwrtRulesAttrLinkHistoryService.java
  95. 24 0
      src/main/java/com/ydtech/modules/protocols/service/PtlAgreementUndwrtRulesNewHistoryService.java
  96. 21 0
      src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementProductCostsAttrLinkHistoryServiceImpl.java
  97. 119 0
      src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementProductCostsNewHistoryServiceImpl.java
  98. 171 43
      src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementProductCostsNewServiceImpl.java
  99. 21 0
      src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementUndwrtRulesAttrLinkHistoryServiceImpl.java
  100. 131 0
      src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementUndwrtRulesNewHistoryServiceImpl.java

+ 1 - 1
src/main/java/com/ydtech/SpringInsApplication.java

@@ -38,4 +38,4 @@ public class SpringInsApplication {
         SpringApplication.run(SpringInsApplication.class, args);
     }
 
-}
+}

+ 1 - 2
src/main/java/com/ydtech/config/properties/BohaiApiConfigurationProperties.java

@@ -25,7 +25,6 @@ public class BohaiApiConfigurationProperties {
     // 合作方代码,由渤海分配
     private String insurerCode;
 
-    // 配置code
-    private String sysSourceCode;
+
 
 }

+ 32 - 0
src/main/java/com/ydtech/modules/admin/controller/SysAmountAuditingController.java

@@ -0,0 +1,32 @@
+package com.ydtech.modules.admin.controller;
+
+
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.admin.model.vo.SysAmountAuditingVo;
+import com.ydtech.modules.admin.model.vo.SysUserAccountVo;
+import com.ydtech.modules.admin.service.SysAmountAuditingService;
+import com.ydtech.modules.base.controller.BaseController;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Api(tags = "账户余额")
+@RequestMapping("/sysAmountAuditing")
+@RestController
+public class SysAmountAuditingController extends BaseController {
+    @Autowired
+    private SysAmountAuditingService sysAmountAuditingService;
+
+
+
+    @PutMapping("AmountReview")
+    @ApiOperation("审核提现")
+    public HttpResult<Object> AmountReview(@RequestBody SysAmountAuditingVo sysUserAccountVo) {
+        sysAmountAuditingService.AmountReview(sysUserAccountVo);
+        return HttpResult.ok("审核成功");
+    }
+}

+ 63 - 0
src/main/java/com/ydtech/modules/admin/controller/SysDeptAccountController.java

@@ -0,0 +1,63 @@
+package com.ydtech.modules.admin.controller;
+
+
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.admin.model.SysDeptAccountEntity;
+import com.ydtech.modules.admin.model.po.SysUserBankCard;
+import com.ydtech.modules.admin.model.vo.SysDeptAccountVO;
+import com.ydtech.modules.admin.model.vo.SysUserBankCardVO;
+import com.ydtech.modules.admin.service.SysDeptAccountService;
+import com.ydtech.modules.base.controller.BaseController;
+import com.ydtech.modules.order.entity.BasePageResult;
+import com.ydtech.modules.protocol.utils.AssertionUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+@Api(tags = "机构账户表")
+@RequestMapping("/sysDeptAccount")
+@RestController
+public class SysDeptAccountController extends BaseController {
+
+    @Autowired
+    private SysDeptAccountService sysDeptAccountService;
+
+    @PostMapping("/queryPage")
+    @ApiOperation(value = "机构账户表")
+    public HttpResult<BasePageResult<SysDeptAccountEntity>> queryPageOrder(@RequestBody @Valid SysDeptAccountVO sysDeptAccountVO ) {
+        BasePageResult<SysDeptAccountEntity> result = sysDeptAccountService.queryByVo(sysDeptAccountVO);
+        return HttpResult.ok("success", result);
+    }
+
+
+    @PostMapping("/insert")
+    @ApiOperation("提交")
+    public HttpResult<Object> submit(@RequestBody SysDeptAccountVO sysDeptAccountVO) {
+        boolean b = sysDeptAccountService.inert(sysDeptAccountVO);
+        AssertionUtils.isSucceed(b, "新增失败");
+        return HttpResult.ok("新增成功");
+    }
+
+
+    @DeleteMapping(value = "/{id}")
+    @ApiOperation("删除")
+    public HttpResult<Object> deleteDept(@PathVariable Long id) {
+        sysDeptAccountService.deleteSysUserBank(id);
+        return HttpResult.ok("删除成功");
+    }
+    @PutMapping("update")
+    @ApiOperation("修改")
+    public HttpResult<Object> modification(@RequestBody SysDeptAccountVO sysDeptAccountVO) {
+        sysDeptAccountService.uodate(sysDeptAccountVO);
+        return HttpResult.ok("修改成功");
+    }
+
+
+
+
+
+
+}

+ 4 - 1
src/main/java/com/ydtech/modules/admin/controller/SysLoginController.java

@@ -372,6 +372,7 @@ public class SysLoginController {
      * 获取二维码生成的uuid
      */
     @GetMapping("/getQrCode")
+    @ApiOperation(value = "获取登录二维码")
     public HttpResult getQrCode(@RequestParam String uuid) throws JsonProcessingException {
 //        String uuid = UUID.randomUUID().toString();
         int statusCode = QrCodeStatusEnum.WAITING.getStatusCode();
@@ -395,6 +396,7 @@ public class SysLoginController {
      * 扫描二维码 改变redis中相关uuid状态并于对应用户关联
      */
     @GetMapping("/scanQrCode")
+    @ApiOperation(value = "扫描登录二维码")
     public HttpResult scanQrCode(@RequestParam String uuid) {
         Map<String, Object> data = new HashMap<>();
         try {
@@ -423,7 +425,7 @@ public class SysLoginController {
                 return HttpResult.ok(data);
             } else {
                 data.put("statusCode", QrCodeStatusEnum.INVALID);
-                return HttpResult.error("二维码已过期");
+                return HttpResult.error("二维码已过期或已被他人使用,请刷新二维码");
             }
         } catch (RuntimeException | JsonProcessingException e) {
             throw new RuntimeException(e);
@@ -434,6 +436,7 @@ public class SysLoginController {
      *  轮询接口 获取二维码状态
      */
     @GetMapping("/getQrCodeStatus")
+    @ApiOperation(value = "获取登录二维码状态")
     public HttpResult getQrCodeStatus(HttpServletRequest request, HttpServletResponse response,
         @RequestParam String uuid) throws JsonProcessingException {
 

+ 48 - 0
src/main/java/com/ydtech/modules/admin/controller/SysUserAccountController.java

@@ -0,0 +1,48 @@
+package com.ydtech.modules.admin.controller;
+
+
+import com.ydtech.aop.request.RequestSingleParam;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.admin.model.po.SysUserAccount;
+import com.ydtech.modules.admin.model.vo.SysUserAccountHistoryVo;
+import com.ydtech.modules.admin.model.vo.SysUserAccountVo;
+import com.ydtech.modules.admin.service.SysUserAccountService;
+import com.ydtech.modules.base.controller.BaseController;
+import com.ydtech.modules.esm.model.vo.EsmInsAttributionTemplateSaveVo;
+import com.ydtech.modules.order.entity.BasePageResult;
+import com.ydtech.modules.protocol.utils.AssertionUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+@Api(tags = "账户余额")
+@RequestMapping("/sysUserAccount")
+@RestController
+public class SysUserAccountController extends BaseController {
+    @Autowired
+    private SysUserAccountService sysUserAccountService;
+
+
+
+    @PostMapping("/queryPage")
+    @ApiOperation(value = "用户账户表分页")
+    public HttpResult<BasePageResult<SysUserAccount>> queryPageOrder(@RequestBody @Valid SysUserAccountVo sysUserAccountVo ) {
+        BasePageResult<SysUserAccount> result = sysUserAccountService.queryByVo(sysUserAccountVo);
+        return HttpResult.ok("success", result);
+    }
+
+    @PostMapping("/insert")
+    @ApiOperation("提交")
+    public HttpResult<Object> submit(@RequestBody SysUserAccountVo sysUserAccountVo) {
+        return sysUserAccountService.inert(sysUserAccountVo);
+    }
+
+
+
+
+
+
+}

+ 59 - 0
src/main/java/com/ydtech/modules/admin/controller/SysUserAccountHistoryController.java

@@ -0,0 +1,59 @@
+package com.ydtech.modules.admin.controller;
+
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.admin.model.po.SysUserAccountHistory;
+import com.ydtech.modules.admin.model.po.SysUserBankCard;
+import com.ydtech.modules.admin.model.vo.SysUserAccountHistoryVo;
+import com.ydtech.modules.admin.model.vo.SysUserBankCardVO;
+import com.ydtech.modules.admin.service.SysUserAccountHistoryService;
+import com.ydtech.modules.base.controller.BaseController;
+import com.ydtech.modules.order.entity.BasePageResult;
+import com.ydtech.modules.protocol.utils.AssertionUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+@Api(tags = "用户账户表日志记录")
+@RequestMapping("/sysUserAccountHistory")
+@RestController
+public class SysUserAccountHistoryController extends BaseController {
+
+    @Autowired
+    private SysUserAccountHistoryService  sysUserAccountHistoryService;
+
+    @PostMapping("/queryPage")
+    @ApiOperation(value = "用户账户表日志记录分页")
+    public HttpResult<BasePageResult<SysUserAccountHistory>> queryPageOrder(@RequestBody @Valid SysUserAccountHistoryVo sysUserAccountHistoryVo ) {
+        BasePageResult<SysUserAccountHistory> result = sysUserAccountHistoryService.queryByVo(sysUserAccountHistoryVo);
+        return HttpResult.ok("success", result);
+    }
+
+
+
+    @PostMapping("/insert")
+    @ApiOperation("提交")
+    public HttpResult<Object> submit(@RequestBody SysUserAccountHistoryVo sysUserAccountHistoryVo) {
+        boolean b = sysUserAccountHistoryService.inert(sysUserAccountHistoryVo);
+        AssertionUtils.isSucceed(b, "新增失败");
+        return HttpResult.ok("新增成功");
+    }
+
+
+    @DeleteMapping(value = "/{id}")
+    @ApiOperation("删除")
+    public HttpResult<Object> deleteDept(@PathVariable Long id) {
+        sysUserAccountHistoryService.deleteSysUserHistory(id);
+        return HttpResult.ok("删除成功");
+    }
+    @PutMapping("update")
+    @ApiOperation("修改")
+    public HttpResult<Object> modification(@RequestBody SysUserAccountHistoryVo sysUserAccountHistoryVo) {
+        sysUserAccountHistoryService.uodate(sysUserAccountHistoryVo);
+        return HttpResult.ok("修改成功");
+    }
+}
+
+

+ 70 - 0
src/main/java/com/ydtech/modules/admin/controller/SysUserBankController.java

@@ -0,0 +1,70 @@
+package com.ydtech.modules.admin.controller;
+
+
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.admin.model.po.SysUserBankCard;
+import com.ydtech.modules.admin.model.vo.SysPositionVo;
+import com.ydtech.modules.admin.model.vo.SysUserBankCardVO;
+import com.ydtech.modules.admin.model.vo.SysUserBaseVO;
+import com.ydtech.modules.admin.model.vo.SysUserVO;
+import com.ydtech.modules.admin.service.SysUserBankCardService;
+import com.ydtech.modules.base.controller.BaseController;
+import com.ydtech.modules.esm.model.vo.EsmInsVehicleInspectionCodeVo;
+import com.ydtech.modules.fnc.model.FncSubject;
+import com.ydtech.modules.order.entity.BasePageResult;
+import com.ydtech.modules.order.entity.InsOrders;
+import com.ydtech.modules.order.entity.vo.OrderQueryVo;
+import com.ydtech.modules.protocol.utils.AssertionUtils;
+import io.swagger.annotations.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.validation.Valid;
+import java.util.HashMap;
+
+@Api(tags = "银行卡号")
+@RequestMapping("/userBank")
+@RestController
+public class SysUserBankController extends BaseController {
+
+    @Autowired
+    private SysUserBankCardService bankCardService;
+
+
+
+
+    @PostMapping("/queryPage")
+    @ApiOperation(value = "银行卡号分页")
+    public HttpResult<BasePageResult<SysUserBankCard>> queryPageOrder(@RequestBody @Valid SysUserBankCardVO sysUserBankCardVO ) {
+            BasePageResult<SysUserBankCard> result = bankCardService.queryByVo(sysUserBankCardVO);
+        return HttpResult.ok("success", result);
+    }
+
+    @PostMapping("/insert")
+    @ApiOperation("提交")
+    public HttpResult<Object> submit(@RequestBody SysUserBankCardVO sysUserBankCardVO) {
+        boolean b = bankCardService.inert(sysUserBankCardVO);
+        AssertionUtils.isSucceed(b, "新增失败");
+        return HttpResult.ok("新增成功");
+    }
+
+
+    @DeleteMapping(value = "/{id}")
+    @ApiOperation("删除")
+    public HttpResult<Object> deleteDept(@PathVariable Long id) {
+        bankCardService.deleteSysUserBank(id);
+        return HttpResult.ok("删除成功");
+    }
+    @PutMapping("update")
+    @ApiOperation("修改")
+    public HttpResult<Object> modification(@RequestBody SysUserBankCardVO sysUserBankCardVO) {
+        bankCardService.uodate(sysUserBankCardVO);
+        return HttpResult.ok("修改成功");
+    }
+    @GetMapping HttpResult<SysUserBankCardVO> getById (String  userId){
+        return  bankCardService.getByUserId(userId);
+    }
+
+
+}

+ 11 - 0
src/main/java/com/ydtech/modules/admin/dao/SysAmountAuditingMapper.java

@@ -0,0 +1,11 @@
+package com.ydtech.modules.admin.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ydtech.modules.admin.model.po.SysAmountAuditingEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface SysAmountAuditingMapper  extends BaseMapper<SysAmountAuditingEntity> {
+    SysAmountAuditingEntity getByUserId(String userId);
+
+}

+ 10 - 0
src/main/java/com/ydtech/modules/admin/dao/SysDeptAccountDao.java

@@ -0,0 +1,10 @@
+package com.ydtech.modules.admin.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ydtech.modules.admin.model.SysDept;
+import com.ydtech.modules.admin.model.SysDeptAccountEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface SysDeptAccountDao extends BaseMapper<SysDeptAccountEntity> {
+}

+ 6 - 0
src/main/java/com/ydtech/modules/admin/dao/SysUserAccountMapper.java

@@ -1,7 +1,10 @@
 package com.ydtech.modules.admin.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ydtech.modules.admin.model.po.SysUserAccount;
+import com.ydtech.modules.admin.model.vo.SysUserAccountVo;
+import org.apache.ibatis.annotations.Param;
 
 /**
 * @author Administrator
@@ -11,6 +14,9 @@ import com.ydtech.modules.admin.model.po.SysUserAccount;
 */
 public interface SysUserAccountMapper extends BaseMapper<SysUserAccount> {
 
+    Page<SysUserAccount> queryPageOrder(SysUserAccountVo sysUserAccountVo,@Param("page") Page page);
+
+    SysUserAccount getById(String userId);
 }
 
 

+ 4 - 0
src/main/java/com/ydtech/modules/admin/dao/SysUserBankCardMapper.java

@@ -1,7 +1,9 @@
 package com.ydtech.modules.admin.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.admin.model.po.SysUserBankCard;
+import com.ydtech.modules.admin.model.vo.SysUserBankCardVO;
 
 /**
 * @author Administrator
@@ -11,6 +13,8 @@ import com.ydtech.modules.admin.model.po.SysUserBankCard;
 */
 public interface SysUserBankCardMapper extends BaseMapper<SysUserBankCard> {
 
+
+    HttpResult<SysUserBankCardVO> getByUserId(String userId);
 }
 
 

+ 42 - 0
src/main/java/com/ydtech/modules/admin/model/SysDeptAccountEntity.java

@@ -0,0 +1,42 @@
+package com.ydtech.modules.admin.model;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@TableName(value = "sys_dept_account")
+@Data
+@ApiModel(value = "机构管理")
+public class SysDeptAccountEntity implements Serializable {
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "dept_id")
+    private String deptId;
+
+    @TableField(value = "handling_fee")
+    private BigDecimal handlingFee;
+
+    @TableField(value = "documentary")
+    private BigDecimal documentary;
+
+    @TableField(value = "promotion")
+    private BigDecimal promotion;
+
+
+    @TableField(value = "create_time")
+    private Date createTime;
+
+
+
+
+}

+ 55 - 0
src/main/java/com/ydtech/modules/admin/model/po/SysAmountAuditingEntity.java

@@ -0,0 +1,55 @@
+package com.ydtech.modules.admin.model.po;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@TableName(value ="sys_amount_auditing")
+@Data
+public class SysAmountAuditingEntity implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * id
+     */
+    @TableId(value = "id")
+    private Integer id;
+    /**
+     * 用户id
+     */
+    @TableField(value = "user_id")
+    private String userId;
+    /**
+     * 银行卡号
+     */
+    @TableField(value = "bank_number")
+    private String bankNumber;
+
+    /**
+     * 提现金额
+     */
+    @TableField(value = "amount")
+    private BigDecimal amount;
+
+    /**
+     * 创建时间
+     */
+    @TableField(value = "create_time")
+    private Date createTime;
+
+    /**
+     * 审核状态
+     */
+    @TableField(value = "auditing_status")
+    private String auditingStatus;
+    /**
+     * 金额类型
+     */
+    @TableField(value = "amount_status")
+    private String amountStatus;
+}

+ 67 - 0
src/main/java/com/ydtech/modules/admin/model/po/SysUserAccount.java

@@ -46,6 +46,73 @@ public class SysUserAccount implements Serializable {
     @TableField(value = "create_time")
     private Date createTime;
 
+    /**
+     * 手续费提现总金额
+     */
+    @TableField(value = "handling_amount_withdrawal")
+    private BigDecimal handlingAmountWithdrawal;
+
+    /**
+     * 手续费已到账金额
+     */
+    @TableField(value = "handling_amount_account")
+    private BigDecimal handlingAmountAccount;
+
+    /**
+     * 手续费支付中金额
+     */
+    @TableField(value = "handling_amount_payment")
+    private BigDecimal handlingAmountPayment;
+
+    /**
+     * 非跟单费提现总金额
+     */
+    @TableField(value = "documentary_amount_withdrawal")
+    private BigDecimal documentaryAmountWithdrawal;
+
+    /**
+     * 非跟单费已到账金额
+     */
+    @TableField(value = "documentary_amount_account")
+    private BigDecimal documentaryAmountAccount;
+
+    /**
+     * 非跟单费支付中金额
+     */
+    @TableField(value = "documentary_amount_payment")
+    private BigDecimal documentaryAmountpayment;
+
+    /**
+     * 分销费提现总金额
+     */
+    @TableField(value = "promotion_amount_withdrawal")
+    private BigDecimal promotionAmountWithdrawal;
+
+    /**
+     * 分销费已到账金额
+     */
+    @TableField(value = "promotion_amount_account")
+    private BigDecimal promotionAmountAccount;
+
+    /**
+     * 分销费支付中金额
+     */
+    @TableField(value = "promotion_amount_payment")
+    private BigDecimal promotionAmountPayment;
+
+
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
+    @TableField(exist = false)
+    private  String  documentaryStatus;
+    @TableField(exist = false)
+    private String  suborderId;
+
+    @TableField(exist = false)
+    private  String  deptName;
+    @TableField(exist = false)
+    private  String  name;
+
+    @TableField(exist = false)
+    private  String  deptId;
 }

+ 3 - 0
src/main/java/com/ydtech/modules/admin/model/po/SysUserAccountHistory.java

@@ -78,4 +78,7 @@ public class SysUserAccountHistory implements Serializable {
 
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
+
+    @TableField(exist = false)
+    private BigDecimal   remainingAmount;
 }

+ 6 - 1
src/main/java/com/ydtech/modules/admin/model/po/SysUserBankCard.java

@@ -1,9 +1,13 @@
 package com.ydtech.modules.admin.model.po;
 
+import com.baomidou.mybatisplus.annotation.FieldFill;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
+import org.apache.ibatis.annotations.Insert;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -42,7 +46,8 @@ public class SysUserBankCard implements Serializable {
     /**
      * 创建时间
      */
-    @TableField(value = "create_time")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @TableField(value = "create_time",fill = FieldFill.INSERT_UPDATE)
     private Date createTime;
 
     @TableField(exist = false)

+ 52 - 0
src/main/java/com/ydtech/modules/admin/model/vo/SysAmountAuditingVo.java

@@ -0,0 +1,52 @@
+package com.ydtech.modules.admin.model.vo;
+
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@ApiModel("查询Vo")
+public class SysAmountAuditingVo {
+
+    @ApiModelProperty(value = "id")
+    private Integer id;
+
+    @ApiModelProperty(value = "用户id")
+    private String userId;
+
+    @ApiModelProperty(value = "银行卡号")
+    private String bankNumber;
+
+
+    @ApiModelProperty(value = "提现金额")
+    private BigDecimal amount;
+
+
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+
+
+    @ApiModelProperty(value = "审核状态")
+    private String auditingStatus;
+
+    @ApiModelProperty(value = "金额类型")
+    private String amountStatus;
+
+    @ApiModelProperty(value = "每页页数")
+    @Min(value = 20, message = "页数最小为20")
+    @Max(value = 100, message = "页数最大为100")
+    private int pageSize;
+
+    @ApiModelProperty(value = "页数")
+    @Min(value = 1, message = "页数最小为1")
+    private int pageNum;
+
+}

+ 45 - 0
src/main/java/com/ydtech/modules/admin/model/vo/SysDeptAccountVO.java

@@ -0,0 +1,45 @@
+package com.ydtech.modules.admin.model.vo;
+
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@ApiModel("查询Vo")
+public class SysDeptAccountVO {
+
+
+    @ApiModelProperty(value = "deptId")
+    private String deptId;
+
+    @ApiModelProperty(value = "手续费佣金")
+    private BigDecimal handlingFee;
+
+    @ApiModelProperty(value = "非跟单佣金")
+    private BigDecimal documentary;
+
+    @ApiModelProperty(value = "推广佣金")
+    private BigDecimal promotion;
+
+
+    @ApiModelProperty(value = "推广佣金")
+    @JsonFormat( pattern = "yyyy-MM-dd")
+    private Date createTime;
+
+    @ApiModelProperty(value = "每页页数")
+    @Min(value = 20, message = "页数最小为20")
+    @Max(value = 100, message = "页数最大为100")
+    private int pageSize;
+
+    @ApiModelProperty(value = "页数")
+    @Min(value = 1, message = "页数最小为1")
+    private int pageNum;
+}

+ 64 - 0
src/main/java/com/ydtech/modules/admin/model/vo/SysUserAccountHistoryVo.java

@@ -0,0 +1,64 @@
+package com.ydtech.modules.admin.model.vo;
+
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.apache.poi.hpsf.Decimal;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@ApiModel("查询Vo")
+public class SysUserAccountHistoryVo {
+
+    @ApiModelProperty("id")
+    private Long id;
+
+    @ApiModelProperty("金额")
+    private BigDecimal amount;
+
+    @ApiModelProperty("剩余金额")
+    private BigDecimal surplusAmount;
+
+    @ApiModelProperty("提现 / 收入 1 提现 2 收入")
+    private Integer  documentary;
+
+
+    @ApiModelProperty("金钱属性 1 手续费 2 非跟单 3 推广")
+    private Integer  property;
+
+
+    @ApiModelProperty("来源订单")
+    private String  suborder;
+
+    @ApiModelProperty("转出银行卡")
+    private String  fromBankCard;
+
+    @ApiModelProperty("转入银行卡")
+    private String  toBankCard;
+
+    @ApiModelProperty("提交人")
+    private String   userId;
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @TableField(value = "create_time",fill = FieldFill.INSERT_UPDATE)
+    @ApiModelProperty("提交时间")
+    private Date createTime;
+
+
+    @ApiModelProperty(value = "每页页数")
+    @Min(value = 20, message = "页数最小为20")
+    @Max(value = 100, message = "页数最大为100")
+    private int pageSize;
+
+    @ApiModelProperty(value = "页数")
+    @Min(value = 1, message = "页数最小为1")
+    private int pageNum;
+}

+ 99 - 0
src/main/java/com/ydtech/modules/admin/model/vo/SysUserAccountVo.java

@@ -0,0 +1,99 @@
+package com.ydtech.modules.admin.model.vo;
+
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@ApiModel("查询Vo")
+public class SysUserAccountVo {
+
+    @ApiModelProperty(value = "用户id")
+    private String userId;
+
+
+    @ApiModelProperty(value = "手续费佣金")
+    private BigDecimal handlingFee;
+
+    @ApiModelProperty(value = "非跟单佣金")
+    private BigDecimal documentary;
+
+
+    @ApiModelProperty(value = "推广佣金")
+    private BigDecimal promotion;
+
+
+
+    @ApiModelProperty(value = "创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @TableField(value = "create_time",fill = FieldFill.INSERT_UPDATE)
+    private Date createTime;
+
+    @ApiModelProperty(value = "手续费提现总金额")
+    private BigDecimal handlingAmountWithdrawal;
+
+    @ApiModelProperty(value = "手续费已到账金额")
+    private BigDecimal handlingAmountAccount;
+
+    @ApiModelProperty(value = "手续费支付中金额")
+    private BigDecimal handlingAmountPayment;
+
+    @ApiModelProperty(value = "非跟单费提现总金额")
+    private BigDecimal documentaryAmountWithdrawal;
+
+    @ApiModelProperty(value = "非跟单费已到账金额")
+    private BigDecimal documentaryAmountAccount;
+
+    @ApiModelProperty(value = "非跟单费支付中金额")
+    private BigDecimal documentaryAmountPayment;
+
+    @ApiModelProperty(value = "分销费提现总金额")
+    private BigDecimal promotionAmountWithdrawal;
+
+    @ApiModelProperty(value = "分销费已到账金额")
+    private BigDecimal promotionAmountAccount;
+
+    @ApiModelProperty(value = "分销费支付中金额")
+    private BigDecimal promotionAmountPayment;
+
+
+    @ApiModelProperty(value = "部门id")
+    private String  deptId;
+
+    @ApiModelProperty(value = "部门id")
+    private String  deptName;
+
+
+
+
+
+    @ApiModelProperty(value = "每页页数")
+    @Min(value = 20, message = "页数最小为20")
+    @Max(value = 100, message = "页数最大为100")
+    private int pageSize;
+
+    @ApiModelProperty(value = "页数")
+    @Min(value = 1, message = "页数最小为1")
+    private int pageNum;
+
+
+
+    @ApiModelProperty(value = "提现金额")
+    private BigDecimal amount;
+
+    @ApiModelProperty(value = "体现类型  1.手续费佣金 2.非跟单佣金 3.推广佣金")
+    private String amountStatus;
+
+    @ApiModelProperty(value = "银行卡")
+    private String fromBankCard;
+}

+ 51 - 0
src/main/java/com/ydtech/modules/admin/model/vo/SysUserBankCardVO.java

@@ -0,0 +1,51 @@
+package com.ydtech.modules.admin.model.vo;
+
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.util.ObjectUtils;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotEmpty;
+import java.time.LocalDate;
+import java.util.Date;
+
+@Data
+@ApiModel("查询Vo")
+public class SysUserBankCardVO {
+
+    @ApiModelProperty("id")
+    private Long id;
+
+    @ApiModelProperty(value = "银行卡号")
+    private String bankNumber;
+
+    @ApiModelProperty(value = "开户行")
+    private String bankAccount;
+
+    @ApiModelProperty(value = "userId")
+    private String userId;
+
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @TableField(value = "create_time",fill = FieldFill.INSERT_UPDATE)
+    private Date createTime;
+
+
+    @ApiModelProperty(value = "每页页数")
+    @Min(value = 20, message = "页数最小为20")
+    @Max(value = 100, message = "页数最大为100")
+    private int pageSize;
+
+    @ApiModelProperty(value = "页数")
+    @Min(value = 1, message = "页数最小为1")
+    private int pageNum;
+
+
+
+}

+ 11 - 0
src/main/java/com/ydtech/modules/admin/service/SysAmountAuditingService.java

@@ -0,0 +1,11 @@
+package com.ydtech.modules.admin.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.modules.admin.model.po.SysAmountAuditingEntity;
+import com.ydtech.modules.admin.model.vo.SysAmountAuditingVo;
+
+public interface SysAmountAuditingService extends IService<SysAmountAuditingEntity> {
+    void AmountReview(SysAmountAuditingVo sysUserAccountVo);
+
+    SysAmountAuditingEntity getByUserId(String userId);
+}

+ 21 - 0
src/main/java/com/ydtech/modules/admin/service/SysDeptAccountService.java

@@ -0,0 +1,21 @@
+package com.ydtech.modules.admin.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.modules.admin.model.SysDept;
+import com.ydtech.modules.admin.model.SysDeptAccountEntity;
+import com.ydtech.modules.admin.model.vo.SysDeptAccountVO;
+import com.ydtech.modules.order.entity.BasePageResult;
+
+public interface SysDeptAccountService extends IService<SysDeptAccountEntity> {
+    BasePageResult<SysDeptAccountEntity> queryByVo(SysDeptAccountVO sysDeptAccountVO);
+
+    boolean inert(SysDeptAccountVO sysDeptAccountVO);
+
+    void deleteSysUserBank(Long id);
+
+    void uodate(SysDeptAccountVO sysDeptAccountVO);
+
+    void addOrUpdate(SysDeptAccountEntity sysDeptAccountEntity);
+
+
+}

+ 11 - 0
src/main/java/com/ydtech/modules/admin/service/SysUserAccountHistoryService.java

@@ -2,6 +2,8 @@ package com.ydtech.modules.admin.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ydtech.modules.admin.model.po.SysUserAccountHistory;
+import com.ydtech.modules.admin.model.vo.SysUserAccountHistoryVo;
+import com.ydtech.modules.order.entity.BasePageResult;
 
 /**
 * @author Administrator
@@ -10,4 +12,13 @@ import com.ydtech.modules.admin.model.po.SysUserAccountHistory;
 */
 public interface SysUserAccountHistoryService extends IService<SysUserAccountHistory> {
 
+    BasePageResult<SysUserAccountHistory> queryByVo(SysUserAccountHistoryVo sysUserAccountHistoryVo);
+
+    boolean inert(SysUserAccountHistoryVo sysUserAccountHistoryVo);
+
+    void deleteSysUserHistory(Long id);
+
+    void uodate(SysUserAccountHistoryVo sysUserAccountHistoryVo);
+
+    void updayteByUserAccount(SysUserAccountHistory sysUserAccountHistory);
 }

+ 10 - 0
src/main/java/com/ydtech/modules/admin/service/SysUserAccountService.java

@@ -1,7 +1,10 @@
 package com.ydtech.modules.admin.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.admin.model.po.SysUserAccount;
+import com.ydtech.modules.admin.model.vo.SysUserAccountVo;
+import com.ydtech.modules.order.entity.BasePageResult;
 
 /**
 * @author Administrator
@@ -10,4 +13,11 @@ import com.ydtech.modules.admin.model.po.SysUserAccount;
 */
 public interface SysUserAccountService extends IService<SysUserAccount> {
 
+    void addOrUpdate(SysUserAccount sysUserAccount);
+
+    BasePageResult<SysUserAccount> queryByVo(SysUserAccountVo sysUserAccountVo);
+
+
+    HttpResult<Object> inert(SysUserAccountVo sysUserAccountVo);
+
 }

+ 15 - 0
src/main/java/com/ydtech/modules/admin/service/SysUserBankCardService.java

@@ -1,7 +1,12 @@
 package com.ydtech.modules.admin.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.admin.model.po.SysUserBankCard;
+import com.ydtech.modules.admin.model.vo.SysUserBankCardVO;
+import com.ydtech.modules.order.entity.BasePageResult;
+
+import java.util.HashMap;
 
 /**
 * @author Administrator
@@ -10,4 +15,14 @@ import com.ydtech.modules.admin.model.po.SysUserBankCard;
 */
 public interface SysUserBankCardService extends IService<SysUserBankCard> {
 
+
+    BasePageResult<SysUserBankCard> queryByVo(SysUserBankCardVO sysUserBankCardVO);
+
+    boolean inert(SysUserBankCardVO sysUserBankCardVO);
+
+    void deleteSysUserBank(Long id);
+
+    void uodate(SysUserBankCardVO sysUserBankCardVO);
+
+    HttpResult<SysUserBankCardVO> getByUserId(String userId);
 }

+ 68 - 0
src/main/java/com/ydtech/modules/admin/service/impl/SysAmountAuditingServiceImpl.java

@@ -0,0 +1,68 @@
+package com.ydtech.modules.admin.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.modules.admin.dao.SysAmountAuditingMapper;
+import com.ydtech.modules.admin.model.po.SysAmountAuditingEntity;
+import com.ydtech.modules.admin.model.po.SysUserAccount;
+import com.ydtech.modules.admin.model.vo.SysAmountAuditingVo;
+import com.ydtech.modules.admin.service.SysAmountAuditingService;
+import com.ydtech.modules.admin.service.SysUserAccountService;
+import com.ydtech.utils.StringUtils;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+
+@Service
+public class SysAmountAuditingServiceImpl extends ServiceImpl<SysAmountAuditingMapper, SysAmountAuditingEntity> implements SysAmountAuditingService {
+    @Autowired
+    private SysUserAccountService sysUserAccountService;
+
+    @Override
+    @Transactional
+    public void AmountReview(SysAmountAuditingVo sysAmountAuditingVo) {
+
+        SysAmountAuditingEntity sysAmountAuditingEntity = new SysAmountAuditingEntity();
+
+        BigDecimal amount = sysAmountAuditingVo.getAmount();
+        String userId = sysAmountAuditingVo.getUserId();
+        SysUserAccount sysUserAccountEntity = new SysUserAccount();
+//      用户扣减金额
+        if (StringUtils.isNotEmpty(userId)) {
+            sysUserAccountEntity.setUserId(userId);
+            SysUserAccount sysUserAccount = sysUserAccountService.getById(userId);
+            if (ObjectUtils.isNotEmpty(sysUserAccount)) {
+                String amountStatus = sysAmountAuditingVo.getAmountStatus();
+                if (StringUtils.isNotEmpty(amountStatus)) {
+                    if ("1".equals(amountStatus)) {
+                        BigDecimal handlingFee = sysUserAccount.getHandlingFee();
+                        BigDecimal afterAmount = handlingFee.subtract(amount);
+                        sysUserAccountEntity.setHandlingFee(afterAmount);
+                    } else if ("2".equals(amountStatus)) {
+                        BigDecimal documentary = sysUserAccount.getDocumentary();
+                        BigDecimal afterAmount = documentary.subtract(amount);
+                        sysUserAccountEntity.setHandlingFee(afterAmount);
+                    } else {
+                        BigDecimal promotion = sysUserAccount.getPromotion();
+                        BigDecimal afterAmount = promotion.subtract(amount);
+                        sysUserAccountEntity.setHandlingFee(afterAmount);
+                    }
+                }
+                sysUserAccountService.updateById(sysUserAccountEntity);
+            }
+            sysAmountAuditingVo.setAuditingStatus("3");
+            BeanUtils.copyProperties(sysAmountAuditingVo, sysAmountAuditingEntity);
+            baseMapper.updateById(sysAmountAuditingEntity);
+        }
+
+
+    }
+
+    @Override
+    public SysAmountAuditingEntity getByUserId(String userId) {
+        return  baseMapper.getByUserId(userId);
+    }
+}

+ 91 - 0
src/main/java/com/ydtech/modules/admin/service/impl/SysDeptAccountServiceImpl.java

@@ -0,0 +1,91 @@
+package com.ydtech.modules.admin.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.modules.admin.dao.SysDeptAccountDao;
+import com.ydtech.modules.admin.model.SysDeptAccountEntity;
+import com.ydtech.modules.admin.model.vo.SysDeptAccountVO;
+import com.ydtech.modules.admin.service.SysDeptAccountService;
+import com.ydtech.modules.order.entity.BasePageResult;
+import com.ydtech.modules.protocol.utils.AssertionUtils;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+
+@Service
+public class SysDeptAccountServiceImpl extends ServiceImpl<SysDeptAccountDao, SysDeptAccountEntity>  implements SysDeptAccountService {
+
+
+    @Override
+    public BasePageResult<SysDeptAccountEntity> queryByVo(SysDeptAccountVO sysDeptAccountVO) {
+
+        Page<SysDeptAccountEntity> page = new Page<>(sysDeptAccountVO.getPageNum(), sysDeptAccountVO.getPageSize());
+        QueryWrapper<SysDeptAccountEntity> wrapper = new QueryWrapper<>();
+
+        Page<SysDeptAccountEntity> sysUserAccountHistoryPage  = page(page, wrapper);
+        return new BasePageResult<>(sysDeptAccountVO.getPageNum(), page.getSize(), sysUserAccountHistoryPage.getTotal(), page.getPages(),
+                sysUserAccountHistoryPage.getRecords());
+    }
+
+    @Override
+    @Transactional
+    public boolean inert(SysDeptAccountVO sysDeptAccountVO) {
+        SysDeptAccountEntity sysDeptAccountEntity = new SysDeptAccountEntity();
+        BeanUtils.copyProperties(sysDeptAccountVO, sysDeptAccountEntity);
+        return super.save(sysDeptAccountEntity);
+
+    }
+
+    @Override
+    public void deleteSysUserBank(Long id) {
+        boolean b = removeById(id);
+        AssertionUtils.isSucceed(b, "删除失败");
+    }
+
+    @Override
+    @Transactional
+    public void uodate(SysDeptAccountVO sysDeptAccountVO) {
+        SysDeptAccountEntity sysDeptAccountEntity = new SysDeptAccountEntity();
+        BeanUtils.copyProperties(sysDeptAccountVO, sysDeptAccountEntity);
+        super.updateById(sysDeptAccountEntity);
+    }
+
+    @Override
+    public void addOrUpdate(SysDeptAccountEntity sysDeptAccountEntity) {
+        //          如果用户id有值则累加   没有则 新增
+        BigDecimal handlingFee =BigDecimal.ZERO;
+        BigDecimal documentary = BigDecimal.ZERO;
+        BigDecimal promotion = BigDecimal.ZERO;
+
+        String deptId = sysDeptAccountEntity.getDeptId();
+        SysDeptAccountEntity sysUserAccountEntityById = super.getById(deptId);
+        if(ObjectUtils.isNotEmpty(sysUserAccountEntityById)){
+            if(sysUserAccountEntityById.getHandlingFee()==null){
+                sysUserAccountEntityById.setHandlingFee(handlingFee);
+            }
+            if (sysUserAccountEntityById.getDocumentary()==null){
+                sysUserAccountEntityById.setDocumentary(documentary);
+            }
+            if(sysUserAccountEntityById.getPromotion()==null){
+                sysUserAccountEntityById.setPromotion(promotion);
+            }
+            sysUserAccountEntityById.setHandlingFee(sysDeptAccountEntity.getHandlingFee().add(sysUserAccountEntityById.getHandlingFee()));
+            sysUserAccountEntityById.setDocumentary(sysDeptAccountEntity.getDocumentary().add(sysUserAccountEntityById.getDocumentary()));
+            sysUserAccountEntityById.setPromotion(sysDeptAccountEntity.getPromotion().add(sysUserAccountEntityById.getPromotion()));
+
+            baseMapper.updateById(sysUserAccountEntityById);
+        }else {
+            SysDeptAccountEntity newAccount = new SysDeptAccountEntity();
+            newAccount.setDeptId(deptId);
+            newAccount.setDocumentary(sysDeptAccountEntity.getDocumentary());
+            newAccount.setPromotion(sysDeptAccountEntity.getPromotion());
+            newAccount.setHandlingFee(sysDeptAccountEntity.getHandlingFee());
+            baseMapper.insert(newAccount);
+        }
+
+    }
+}

+ 62 - 0
src/main/java/com/ydtech/modules/admin/service/impl/SysUserAccountHistoryServiceImpl.java

@@ -1,10 +1,24 @@
 package com.ydtech.modules.admin.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ydtech.modules.admin.dao.SysUserAccountHistoryMapper;
 import com.ydtech.modules.admin.model.po.SysUserAccountHistory;
+import com.ydtech.modules.admin.model.po.SysUserBankCard;
+import com.ydtech.modules.admin.model.vo.SysUserAccountHistoryVo;
+import com.ydtech.modules.admin.model.vo.SysUserBankCardVO;
 import com.ydtech.modules.admin.service.SysUserAccountHistoryService;
+import com.ydtech.modules.admin.service.SysUserBankCardService;
+import com.ydtech.modules.order.entity.BasePageResult;
+import com.ydtech.modules.protocol.utils.AssertionUtils;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * @author Administrator
@@ -13,6 +27,54 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class SysUserAccountHistoryServiceImpl extends ServiceImpl<SysUserAccountHistoryMapper, SysUserAccountHistory> implements SysUserAccountHistoryService {
+    @Autowired
+    private SysUserBankCardService  sysUserBankCardService;
+
+    @Override
+    public BasePageResult<SysUserAccountHistory> queryByVo(SysUserAccountHistoryVo sysUserAccountHistoryVo) {
+
+        Page<SysUserAccountHistory> page = new Page<>(sysUserAccountHistoryVo.getPageNum(), sysUserAccountHistoryVo.getPageSize());
+        QueryWrapper<SysUserAccountHistory> wrapper = new QueryWrapper<>();
+
+        Page<SysUserAccountHistory> sysUserAccountHistoryPage  = page(page, wrapper);
+        return new BasePageResult<>(sysUserAccountHistoryVo.getPageNum(), page.getSize(), sysUserAccountHistoryPage.getTotal(), page.getPages(),
+                sysUserAccountHistoryPage.getRecords());
+    }
+
+    @Override
+    @Transactional
+    public boolean inert(SysUserAccountHistoryVo sysUserAccountHistoryVo) {
+
+        SysUserAccountHistory sysUserAccountHistory = new SysUserAccountHistory();
+        BeanUtils.copyProperties(sysUserAccountHistoryVo, sysUserAccountHistory);
+        return super.save(sysUserAccountHistory);
+
+    }
+
+    @Override
+    @Transactional
+    public void deleteSysUserHistory(Long id) {
+        boolean b = removeById(id);
+        AssertionUtils.isSucceed(b, "删除失败");
+    }
+
+    @Override
+    @Transactional
+    public void uodate(SysUserAccountHistoryVo sysUserAccountHistoryVo) {
+        SysUserAccountHistory sysUserAccountHistory = new SysUserAccountHistory();
+        BeanUtils.copyProperties(sysUserAccountHistoryVo, sysUserAccountHistory);
+        super.updateById(sysUserAccountHistory);
+    }
+
+    @Override
+    public void updayteByUserAccount(SysUserAccountHistory sysUserAccountHistory) {
+//        sysUserAccountHistory.setSurplusAmount( sysUserAccountHistory.getAmount().add(sysUserAccountHistory.getRemainingAmount()));
+
+
+        super.save(sysUserAccountHistory);
+
+    }
+
 
 }
 

+ 246 - 7
src/main/java/com/ydtech/modules/admin/service/impl/SysUserAccountServiceImpl.java

@@ -1,20 +1,259 @@
 package com.ydtech.modules.admin.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.admin.dao.SysUserAccountMapper;
+import com.ydtech.modules.admin.model.po.SysAmountAuditingEntity;
 import com.ydtech.modules.admin.model.po.SysUserAccount;
-import com.ydtech.modules.admin.service.SysUserAccountService;
+import com.ydtech.modules.admin.model.po.SysUserAccountHistory;
+import com.ydtech.modules.admin.model.po.SysUserBankCard;
+import com.ydtech.modules.admin.model.vo.SysUserAccountVo;
+import com.ydtech.modules.admin.model.vo.SysUserBankCardVO;
+import com.ydtech.modules.admin.service.*;
+import com.ydtech.modules.esm.model.EsmUserReferrer;
+import com.ydtech.modules.esm.service.EsmUserReferrerService;
+import com.ydtech.modules.order.entity.BasePageResult;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.Date;
 
 /**
-* @author Administrator
-* @description 针对表【sys_user_account(用户账户表)】的数据库操作Service实现
-* @createDate 2024-03-05 11:52:30
-*/
+ * @author Administrator
+ * @description 针对表【sys_user_account(用户账户表)】的数据库操作Service实现
+ * @createDate 2024-03-05 11:52:30
+ */
 @Service
-public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper, SysUserAccount>
-    implements SysUserAccountService {
+public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper, SysUserAccount> implements SysUserAccountService {
+
+    @Autowired
+    private SysUserAccountHistoryService sysUserAccountHistoryService;
+    @Autowired
+    private EsmUserReferrerService esmUserReferrerService;
+    @Autowired
+    private SysAmountAuditingService sysAmountAuditingService;
+
+    @Autowired
+    private SysUserBankCardService sysUserBankCardService;
+
+    @Override
+    @Transactional
+    public void addOrUpdate(SysUserAccount sysUserAccount) {
+
+//      如果用户id有值则累加   没有则 新增
+        BigDecimal handlingFee = BigDecimal.ZERO;
+//      用户历史记录表金额
+        BigDecimal total = BigDecimal.ZERO;
+        BigDecimal remainingAmount = BigDecimal.ZERO;
+
+
+        String userId = sysUserAccount.getUserId();
+        SysUserAccount sysUserAccountEntity = super.getById(userId);
+        SysUserAccount newAccount = new SysUserAccount();
+        if (sysUserAccount.getHandlingFee() == null) {
+            sysUserAccount.setHandlingFee(handlingFee);
+        } else {
+            total = total.add(sysUserAccount.getHandlingFee());
+
+        }
+        if (sysUserAccount.getDocumentary() == null) {
+            sysUserAccount.setDocumentary(handlingFee);
+        } else {
+            total = total.add(sysUserAccount.getDocumentary());
+
+        }
+        if (sysUserAccount.getPromotion() == null) {
+            sysUserAccount.setPromotion(handlingFee);
+        } else {
+            total = total.add(sysUserAccount.getPromotion());
+
+        }
+
+
+        if (ObjectUtils.isNotEmpty(sysUserAccountEntity)) {
+            if (sysUserAccountEntity.getHandlingFee() == null) {
+                sysUserAccountEntity.setHandlingFee(handlingFee);
+            } else {
+                remainingAmount = remainingAmount.add(sysUserAccountEntity.getHandlingFee());
+            }
+            if (sysUserAccountEntity.getDocumentary() == null) {
+                sysUserAccountEntity.setDocumentary(handlingFee);
+            } else {
+                remainingAmount = remainingAmount.add(sysUserAccountEntity.getDocumentary());
+
+            }
+            if (sysUserAccountEntity.getPromotion() == null) {
+                sysUserAccountEntity.setPromotion(handlingFee);
+            } else {
+                remainingAmount = remainingAmount.add(sysUserAccountEntity.getPromotion());
+
+            }
+            sysUserAccountEntity.setHandlingFee(sysUserAccount.getHandlingFee().add(sysUserAccountEntity.getHandlingFee()));
+            sysUserAccountEntity.setDocumentary(sysUserAccount.getDocumentary().add(sysUserAccountEntity.getDocumentary()));
+            sysUserAccountEntity.setPromotion(sysUserAccount.getPromotion().add(sysUserAccountEntity.getPromotion()));
+            if (StringUtils.isNotEmpty(sysUserAccount.getDocumentaryStatus())) {
+                sysUserAccountEntity.setDocumentaryStatus(sysUserAccount.getDocumentaryStatus());
+            }
+            baseMapper.updateById(sysUserAccountEntity);
+        } else {
+            newAccount.setUserId(userId);
+            newAccount.setDocumentary(sysUserAccount.getDocumentary());
+            newAccount.setPromotion(sysUserAccount.getPromotion());
+            newAccount.setHandlingFee(sysUserAccount.getHandlingFee());
+            if (StringUtils.isNotEmpty(sysUserAccount.getDocumentaryStatus())) {
+                newAccount.setDocumentaryStatus(sysUserAccount.getDocumentaryStatus());
+            }
+            baseMapper.insert(newAccount);
+        }
+
+        if (StringUtils.isNotEmpty(sysUserAccount.getDocumentaryStatus())) {
+//          判断是否是一级二级三级
+            this.judgeLevel(userId, sysUserAccountEntity, newAccount);
+        }
+
+
+    }
+
+    @Override
+    public BasePageResult<SysUserAccount> queryByVo(SysUserAccountVo sysUserAccountVo) {
+        Page<SysUserAccount> page = new Page<>(sysUserAccountVo.getPageNum(), sysUserAccountVo.getPageSize());
+        QueryWrapper<SysUserAccount> wrapper = new QueryWrapper<>();
+
+        Page<SysUserAccount> sysUserAccountHistoryPage = baseMapper.queryPageOrder(sysUserAccountVo, page);
+        return new BasePageResult<>(sysUserAccountVo.getPageNum(), page.getSize(), sysUserAccountHistoryPage.getTotal(), page.getPages(),
+                sysUserAccountHistoryPage.getRecords());
+    }
+
+    @Override
+    @Transactional
+    public HttpResult<Object> inert(SysUserAccountVo sysUserAccountVo) {
+        String userId = sysUserAccountVo.getUserId();
+        BigDecimal zero = BigDecimal.ZERO;
+        BigDecimal beforeAmount;
+        BigDecimal afterAmount;
+//       用户当前金额
+        BigDecimal amount = sysUserAccountVo.getAmount();
+//       扣减后金额更改
+        SysUserAccountHistory sysUserAccountHistory = new SysUserAccountHistory();  // 记录
+        sysUserAccountHistory.setDocumentary(1);  // 1提现
+        sysUserAccountHistory.setUserId(sysUserAccountVo.getUserId());
+        SysAmountAuditingEntity sysAmountAuditingEntity = new SysAmountAuditingEntity();//审核记录表
+        sysAmountAuditingEntity.setUserId(sysUserAccountVo.getUserId());
+        sysAmountAuditingEntity.setAmount(sysUserAccountVo.getAmount());
+        SysAmountAuditingEntity   judge =    sysAmountAuditingService.getByUserId(userId);
+        if(ObjectUtils.isNotEmpty(judge)){
+            return HttpResult.ok("有未提现审核单据, 请审核完成之后再提现");
+        }
+//      获取银行卡
+        HttpResult<SysUserBankCardVO> byUserId = sysUserBankCardService.getByUserId(userId);
+        if(byUserId!=null  && byUserId.getData()!=null  ){
+            SysUserBankCardVO data = byUserId.getData();
+            if(ObjectUtils.isNotEmpty(data)){
+                sysAmountAuditingEntity.setBankNumber( data.getBankNumber());
+                sysUserAccountHistory.setFromBankCard( data.getBankNumber());
+            }
+        }
+
+
+        if (StringUtils.isNotEmpty(userId)) {
+            SysUserAccount sysUserAccount = baseMapper.getById(userId);
+
+            if (StringUtils.isNotEmpty(sysUserAccountVo.getAmountStatus())) {
+                sysUserAccountHistory.setProperty(Integer.valueOf(sysUserAccountVo.getAmountStatus()));   //金额类型
+
+                if ("1".equals(sysUserAccountVo.getAmountStatus())) {
+//                  用户当前费用金
+                    beforeAmount = sysUserAccount.getHandlingFee();
+                    afterAmount = beforeAmount.subtract(amount);
+                } else if ("2".equals(sysUserAccountVo.getAmountStatus())) {
+//                    用户当前 非跟单佣金
+                    beforeAmount = sysUserAccount.getDocumentary();
+                    afterAmount = beforeAmount.subtract(amount);
+                } else {
+                    beforeAmount = sysUserAccount.getPromotion();
+                    afterAmount = beforeAmount.subtract(amount);
+                }
+//              用户相差
+                if (beforeAmount.compareTo(zero) == 0 || afterAmount.compareTo(zero) < 0) {
+                    return HttpResult.ok("余额不足");
+                }
+                sysUserAccountHistory.setAmount(amount);  // 金额
+                sysUserAccountHistory.setSurplusAmount(afterAmount); // 剩余金额
+                sysAmountAuditingEntity.setCreateTime(new Date());
+                sysAmountAuditingEntity.setAuditingStatus("2");   // 2  为待审核  3  审核通过
+                sysAmountAuditingEntity.setAmountStatus(sysUserAccountVo.getAmountStatus());
+//              新增金额记录
+                sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
+                sysAmountAuditingService.save(sysAmountAuditingEntity);
+            }
+
+        }
+        return HttpResult.ok("提现成功,等待审核");
+    }
+
+
+
+    private void judgeLevel(String userId, SysUserAccount sysUserAccountEntity, SysUserAccount newAccount) {
+        if (!ObjectUtils.isNotEmpty(sysUserAccountEntity)) {
+            sysUserAccountEntity = newAccount;
+        }
+        EsmUserReferrer esmUserReferrerServiceById = esmUserReferrerService.getById(userId);
+        if (ObjectUtils.isNotEmpty(esmUserReferrerServiceById)) {
+            String referrerId = esmUserReferrerServiceById.getReferrerId();
+//              如果相等则为一级
+            if (StringUtils.isNotEmpty(referrerId) && referrerId.equals(userId)) {
+                if (ObjectUtils.isNotEmpty(sysUserAccountEntity)) {
+                    for (int i = 1; i <= 3; i++) {
+                        SysUserAccountHistory sysUserAccountHistory = new SysUserAccountHistory();
+                        sysUserAccountHistory.setUserId(userId);
+                        sysUserAccountHistory.setDocumentary(Integer.valueOf(sysUserAccountEntity.getDocumentaryStatus()));
+                        sysUserAccountHistory.setProperty(i);
+                        sysUserAccountHistory.setSuborder(sysUserAccountEntity.getSuborderId());
+                        SysUserAccount byId = super.getById(userId);
+                        if (i == 1) {
+                            sysUserAccountHistory.setAmount(sysUserAccountEntity.getHandlingFee());
+//                            查询当前用户金额
+                            if (ObjectUtils.isNotEmpty(byId)) {
+                                sysUserAccountHistory.setSurplusAmount(byId.getHandlingFee() == null ? BigDecimal.ZERO.add(sysUserAccountEntity.getHandlingFee()) : byId.getHandlingFee().add(sysUserAccountEntity.getHandlingFee()));
+                            }
+                        } else if (i == 2) {
+                            sysUserAccountHistory.setAmount(sysUserAccountEntity.getDocumentary());   //非跟单佣金
+                            if (ObjectUtils.isNotEmpty(byId)) {
+                                sysUserAccountHistory.setSurplusAmount(byId.getDocumentary() == null ? BigDecimal.ZERO.add(sysUserAccountEntity.getDocumentary()) : byId.getDocumentary().add(sysUserAccountEntity.getDocumentary()));
+                            }
 
+                        } else {
+                            sysUserAccountHistory.setAmount(sysUserAccountEntity.getPromotion());  // 佣金
+                            if (ObjectUtils.isNotEmpty(byId)) {
+                                sysUserAccountHistory.setSurplusAmount(byId.getPromotion() == null ? BigDecimal.ZERO.add(sysUserAccountEntity.getPromotion()) : byId.getPromotion().add(sysUserAccountEntity.getPromotion()));
+                            }
+                        }
+                        if (sysUserAccountHistory.getAmount().compareTo(BigDecimal.ZERO) == 1) {
+                            sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
+                        }
+                    }
+                }
+            } else {
+//                其余都是推广金
+                SysUserAccountHistory sysUserAccountHistory = new SysUserAccountHistory();
+                sysUserAccountHistory.setAmount(sysUserAccountEntity.getPromotion());
+                sysUserAccountHistory.setProperty(3);
+                sysUserAccountHistory.setSuborder(sysUserAccountEntity.getSuborderId());
+                sysUserAccountHistory.setUserId(userId);
+                sysUserAccountHistory.setDocumentary(Integer.valueOf(sysUserAccountEntity.getDocumentaryStatus()));
+                SysUserAccount byId = super.getById(userId);
+                sysUserAccountHistory.setSurplusAmount(byId.getPromotion() == null ? BigDecimal.ZERO.add(sysUserAccountEntity.getPromotion()) : byId.getPromotion().add(sysUserAccountEntity.getPromotion()));
+                sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
+            }
+        }
+    }
 }
 
 

+ 63 - 5
src/main/java/com/ydtech/modules/admin/service/impl/SysUserBankCardServiceImpl.java

@@ -1,20 +1,78 @@
 package com.ydtech.modules.admin.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.admin.dao.SysUserBankCardMapper;
 import com.ydtech.modules.admin.model.po.SysUserBankCard;
+import com.ydtech.modules.admin.model.vo.SysUserBankCardVO;
 import com.ydtech.modules.admin.service.SysUserBankCardService;
+import com.ydtech.modules.order.entity.BasePageResult;
+import com.ydtech.modules.protocol.utils.AssertionUtils;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.HashMap;
 
 /**
-* @author Administrator
-* @description 针对表【sys_user_bank_card(银行卡号)】的数据库操作Service实现
-* @createDate 2024-03-05 11:52:30
-*/
+ * @author Administrator
+ * @description 针对表【sys_user_bank_card(银行卡号)】的数据库操作Service实现
+ * @createDate 2024-03-05 11:52:30
+ */
 @Service
 public class SysUserBankCardServiceImpl extends ServiceImpl<SysUserBankCardMapper, SysUserBankCard>
-    implements SysUserBankCardService {
+        implements SysUserBankCardService {
+
+
+
+    @Override
+    public BasePageResult<SysUserBankCard> queryByVo(SysUserBankCardVO sysUserBankCardVO) {
+        Page<SysUserBankCard> page = new Page<>(sysUserBankCardVO.getPageNum(), sysUserBankCardVO.getPageSize());
+
+
+        LambdaQueryWrapper<SysUserBankCard> wrapper = new LambdaQueryWrapper<>();
+        if(StringUtils.isNotEmpty(sysUserBankCardVO.getBankNumber())){
+            wrapper.eq(SysUserBankCard::getBankNumber, ObjectUtils.isNotEmpty(sysUserBankCardVO.getBankNumber()));
+
+        }
+        if(StringUtils.isNotEmpty(sysUserBankCardVO.getBankAccount())){
+            wrapper.eq(SysUserBankCard::getBankAccount, sysUserBankCardVO.getBankAccount());
+        }
+        Page<SysUserBankCard> insOrdersPage = page(page, wrapper);
+        return new BasePageResult<>(sysUserBankCardVO.getPageNum(), page.getSize(), insOrdersPage.getTotal(), page.getPages(),
+                insOrdersPage.getRecords());
+    }
+
+    @Override
+    @Transactional
+    public boolean inert(SysUserBankCardVO sysUserBankCardVO) {
+        SysUserBankCard sysUserBankCard = new SysUserBankCard();
+        BeanUtils.copyProperties(sysUserBankCardVO, sysUserBankCard);
+        return super.save(sysUserBankCard);
+    }
+
+    @Override
+    public void deleteSysUserBank(Long id) {
+        boolean b = removeById(id);
+        AssertionUtils.isSucceed(b, "删除失败");
+    }
+
+    @Override
+    public void uodate(SysUserBankCardVO sysUserBankCardVO) {
+        SysUserBankCard sysUserBankCard = new SysUserBankCard();
+        BeanUtils.copyProperties(sysUserBankCardVO, sysUserBankCard);
+        super.updateById(sysUserBankCard);
+    }
 
+    @Override
+    public HttpResult<SysUserBankCardVO> getByUserId(String userId) {
+      return   baseMapper.getByUserId(userId) ;
+    }
 }
 
 

+ 57 - 42
src/main/java/com/ydtech/modules/fee/dto/vo/RuleAttrMappingVo.java

@@ -18,10 +18,10 @@ import java.util.Objects;
 import java.util.regex.Pattern;
 
 /**
-*@author: tz
-*@description: 规则属性映射费用因子Vo
-*@create: 2024-2-28 08:35:57
-*/
+ * @author: tz
+ * @description: 规则属性映射费用因子Vo
+ * @create: 2024-2-28 08:35:57
+ */
 @Data
 public class RuleAttrMappingVo {
     @ApiModelProperty(value = "因子属性Code")
@@ -35,7 +35,7 @@ public class RuleAttrMappingVo {
         this.value = value;
     }
 
-    public static List<RuleAttrMappingVo> getRuleAttrMappingVoList(InsAreaCompany insAreaCompany,InsOrders insOrders) {
+    public static List<RuleAttrMappingVo> getRuleAttrMappingVoList(InsAreaCompany insAreaCompany, InsOrders insOrders) {
         List<RuleAttrMappingVo> ruleAttrMappingVoList = new ArrayList<>();
         CarInfoVo carInfo = insOrders.getCarinfo().toJavaObject(CarInfoVo.class);
         //车牌号
@@ -100,60 +100,73 @@ public class RuleAttrMappingVo {
         //险别信息
         kindInfoVos.forEach(kindInfoVo -> {
             //机动车损失险
-            if(InsurKind.A.getCode().equals(kindInfoVo.getKindCode()))
+            if (InsurKind.A.getCode().equals(kindInfoVo.getKindCode()))
                 ruleAttrMappingVoList.add(new RuleAttrMappingVo("MotorVehicleDamageInsurance", String.valueOf(kindInfoVo.getAmount())));
             //第三者责任险
-            if(InsurKind.B.getCode().equals(kindInfoVo.getKindCode()))
+            if (InsurKind.B.getCode().equals(kindInfoVo.getKindCode()))
                 ruleAttrMappingVoList.add(new RuleAttrMappingVo("ThirdPartyLiabilityInsurance", String.valueOf(kindInfoVo.getAmount())));
             //司机责任险
-            if(InsurKind.D3.getCode().equals(kindInfoVo.getKindCode()))
+            if (InsurKind.D3.getCode().equals(kindInfoVo.getKindCode()))
                 ruleAttrMappingVoList.add(new RuleAttrMappingVo("DriverLiabilityInsurance", String.valueOf(kindInfoVo.getAmount())));
             //乘客责任险
-            if(InsurKind.D4.getCode().equals(kindInfoVo.getKindCode()))
+            if (InsurKind.D4.getCode().equals(kindInfoVo.getKindCode()))
                 ruleAttrMappingVoList.add(new RuleAttrMappingVo("PassengerLiabilityInsurance", String.valueOf(kindInfoVo.getUnitAmount())));
             //车身划痕险
-            if(InsurKind.L.getCode().equals(kindInfoVo.getKindCode()))
+            if (InsurKind.L.getCode().equals(kindInfoVo.getKindCode()))
                 ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarScratchInsurance", String.valueOf(kindInfoVo.getAmount())));
             //绝对免赔率特约险(车损)
-            if(InsurKind.MJ1.getCode().equals(kindInfoVo.getKindCode()))
-                ruleAttrMappingVoList.add(new RuleAttrMappingVo("VehicleDamageAbsoluteDeductibleSpecialInsurance", String.valueOf(kindInfoVo.getAmount())));
+            if (InsurKind.MJ1.getCode().equals(kindInfoVo.getKindCode()))
+                ruleAttrMappingVoList.add(new RuleAttrMappingVo("VehicleDamageAbsoluteDeductibleSpecialInsurance",
+                        String.valueOf(kindInfoVo.getAmount())));
             //绝对免赔率特约险(三者)
-            if(InsurKind.MJ2.getCode().equals(kindInfoVo.getKindCode()))
-                ruleAttrMappingVoList.add(new RuleAttrMappingVo("ThirdAbsoluteDeductibleSpecialInsurance", String.valueOf(kindInfoVo.getAmount())));
+            if (InsurKind.MJ2.getCode().equals(kindInfoVo.getKindCode()))
+                ruleAttrMappingVoList.add(new RuleAttrMappingVo("ThirdAbsoluteDeductibleSpecialInsurance",
+                        String.valueOf(kindInfoVo.getAmount())));
             //绝对免赔率特约险(司机)
-            if(InsurKind.MJ3.getCode().equals(kindInfoVo.getKindCode()))
-                ruleAttrMappingVoList.add(new RuleAttrMappingVo("DriverAbsoluteDeductibleSpecialInsurance", String.valueOf(kindInfoVo.getAmount())));
+            if (InsurKind.MJ3.getCode().equals(kindInfoVo.getKindCode()))
+                ruleAttrMappingVoList.add(new RuleAttrMappingVo("DriverAbsoluteDeductibleSpecialInsurance",
+                        String.valueOf(kindInfoVo.getAmount())));
             //绝对免赔率特约险(乘客)
-            if(InsurKind.MJ4.getCode().equals(kindInfoVo.getKindCode()))
-                ruleAttrMappingVoList.add(new RuleAttrMappingVo("PassengerAbsoluteDeductibleSpecialInsurance", String.valueOf(kindInfoVo.getAmount())));
+            if (InsurKind.MJ4.getCode().equals(kindInfoVo.getKindCode()))
+                ruleAttrMappingVoList.add(new RuleAttrMappingVo("PassengerAbsoluteDeductibleSpecialInsurance",
+                        String.valueOf(kindInfoVo.getAmount())));
             //附加医保-三者
-            if(InsurKind.SY_FJ_YBW1.getCode().equals(kindInfoVo.getKindCode()))
-                ruleAttrMappingVoList.add(new RuleAttrMappingVo("ThirdPartyAdditionalMedicalInsurance", String.valueOf(kindInfoVo.getAmount())));
+            if (InsurKind.SY_FJ_YBW1.getCode().equals(kindInfoVo.getKindCode()))
+                ruleAttrMappingVoList.add(new RuleAttrMappingVo("ThirdPartyAdditionalMedicalInsurance",
+                        String.valueOf(kindInfoVo.getAmount())));
             //附加医保-座位险(乘客)
-            if(InsurKind.SY_FJ_YBW2.getCode().equals(kindInfoVo.getKindCode()))
-                ruleAttrMappingVoList.add(new RuleAttrMappingVo("PassengerAdditionalMedicalInsurance", String.valueOf(kindInfoVo.getAmount())));
+            if (InsurKind.SY_FJ_YBW2.getCode().equals(kindInfoVo.getKindCode()))
+                ruleAttrMappingVoList.add(new RuleAttrMappingVo("PassengerAdditionalMedicalInsurance",
+                        String.valueOf(kindInfoVo.getAmount())));
             //附加医保-座位险(司机)
-            if(InsurKind.SY_FJ_YBW3.getCode().equals(kindInfoVo.getKindCode()))
-                ruleAttrMappingVoList.add(new RuleAttrMappingVo("DriverAdditionalMedicalInsurance", String.valueOf(kindInfoVo.getAmount())));
+            if (InsurKind.SY_FJ_YBW3.getCode().equals(kindInfoVo.getKindCode()))
+                ruleAttrMappingVoList.add(new RuleAttrMappingVo("DriverAdditionalMedicalInsurance",
+                        String.valueOf(kindInfoVo.getAmount())));
             //法定节假日限额翻倍险
-            if(InsurKind.BD.getCode().equals(kindInfoVo.getKindCode()))
-                ruleAttrMappingVoList.add(new RuleAttrMappingVo("LegalHolidayLimitDoublingInsurance", String.valueOf(kindInfoVo.getAmount())));
+            if (InsurKind.BD.getCode().equals(kindInfoVo.getKindCode()))
+                ruleAttrMappingVoList.add(new RuleAttrMappingVo("LegalHolidayLimitDoublingInsurance",
+                        String.valueOf(kindInfoVo.getAmount())));
             //道路救援服务特约条款
-            if(InsurKind.TY1.getCode().equals(kindInfoVo.getKindCode()))
-                ruleAttrMappingVoList.add(new RuleAttrMappingVo("RoadsideAssistanceServiceSpecialClause", String.valueOf(kindInfoVo.getServiceTimes())));
+            if (InsurKind.TY1.getCode().equals(kindInfoVo.getKindCode()))
+                ruleAttrMappingVoList.add(new RuleAttrMappingVo("RoadsideAssistanceServiceSpecialClause",
+                        String.valueOf(kindInfoVo.getServiceTimes())));
             //车辆安全检测特约条款
-            if(InsurKind.TY2.getCode().equals(kindInfoVo.getKindCode()))
-                ruleAttrMappingVoList.add(new RuleAttrMappingVo("VehicleSafetyInspectionSpecialClause", String.valueOf(kindInfoVo.getServiceTimes())));
+            if (InsurKind.TY2.getCode().equals(kindInfoVo.getKindCode()))
+                ruleAttrMappingVoList.add(new RuleAttrMappingVo("VehicleSafetyInspectionSpecialClause",
+                        String.valueOf(kindInfoVo.getServiceTimes())));
             //代为驾驶服务特约条款
-            if(InsurKind.TY3.getCode().equals(kindInfoVo.getKindCode()))
-                ruleAttrMappingVoList.add(new RuleAttrMappingVo("SubstituteDrivingServiceSpecialClause", String.valueOf(kindInfoVo.getServiceTimes())));
+            if (InsurKind.TY3.getCode().equals(kindInfoVo.getKindCode()))
+                ruleAttrMappingVoList.add(new RuleAttrMappingVo("SubstituteDrivingServiceSpecialClause",
+                        String.valueOf(kindInfoVo.getServiceTimes())));
             //代为送检服务特约条款
-            if(InsurKind.TY4.getCode().equals(kindInfoVo.getKindCode()))
-                ruleAttrMappingVoList.add(new RuleAttrMappingVo("SubstituteInspectionServiceSpecialClause", String.valueOf(kindInfoVo.getServiceTimes())));
+            if (InsurKind.TY4.getCode().equals(kindInfoVo.getKindCode()))
+                ruleAttrMappingVoList.add(new RuleAttrMappingVo("SubstituteInspectionServiceSpecialClause",
+                        String.valueOf(kindInfoVo.getServiceTimes())));
         });
 
         //交强保费
-        ruleAttrMappingVoList.add(new RuleAttrMappingVo("CompulsoryTrafficAccidentLiabilityInsurancePremium", String.valueOf(insAreaCompany.getJqpremium())));
+        ruleAttrMappingVoList.add(new RuleAttrMappingVo("CompulsoryTrafficAccidentLiabilityInsurancePremium",
+                String.valueOf(insAreaCompany.getJqpremium())));
         //车船税
         ruleAttrMappingVoList.add(new RuleAttrMappingVo("VehicleandVesselTax", String.valueOf(insAreaCompany.getTaxamount())));
         //非车险
@@ -166,7 +179,7 @@ public class RuleAttrMappingVo {
 //        ruleAttrMappingVoList.add(new RuleAttrMappingVo("CommercialDiscount", String.valueOf(quoteRespVo.getSyAdjustRate())));
         //数值型总评分
         Pattern pattern = Pattern.compile("[0-9]*");
-        if(insAreaCompany.getScore() != null) {
+        if (insAreaCompany.getScore() != null) {
             if (pattern.matcher(insAreaCompany.getScore()).matches()) {
                 //数值型评分
                 ruleAttrMappingVoList.add(new RuleAttrMappingVo("NumericalOverallRating", String.valueOf(insAreaCompany.getScore())));
@@ -176,24 +189,26 @@ public class RuleAttrMappingVo {
             }
         }
         //交强评分
-        if(insAreaCompany.getJqScore() != null){
-            if(pattern.matcher(insAreaCompany.getJqScore()).matches()) {
+        if (insAreaCompany.getJqScore() != null) {
+            if (pattern.matcher(insAreaCompany.getJqScore()).matches()) {
                 //数值型评分
                 ruleAttrMappingVoList.add(new RuleAttrMappingVo("CompulsoryInsuranceRating", String.valueOf(insAreaCompany.getJqScore())));
             } else {
                 //字母型评分
-                ruleAttrMappingVoList.add(new RuleAttrMappingVo("CharacterBasedCompulsoryInsuranceRating", String.valueOf(insAreaCompany.getJqScore())));
+                ruleAttrMappingVoList.add(new RuleAttrMappingVo("CharacterBasedCompulsoryInsuranceRating",
+                        String.valueOf(insAreaCompany.getJqScore())));
             }
         }
 //        ruleAttrMappingVoList.add(new RuleAttrMappingVo("CompulsoryInsuranceRating", String.valueOf(insAreaCompany.getJqScore())));
         //商业评分
-        if(insAreaCompany.getSyScore() != null){
-            if(pattern.matcher(insAreaCompany.getSyScore()).matches()) {
+        if (insAreaCompany.getSyScore() != null) {
+            if (pattern.matcher(insAreaCompany.getSyScore()).matches()) {
                 //数值型评分
                 ruleAttrMappingVoList.add(new RuleAttrMappingVo("CommercialRating", String.valueOf(insAreaCompany.getSyScore())));
             } else {
                 //字母型评分
-                ruleAttrMappingVoList.add(new RuleAttrMappingVo("CharacterBasedCommercialRating", String.valueOf(insAreaCompany.getSyScore())));
+                ruleAttrMappingVoList.add(new RuleAttrMappingVo("CharacterBasedCommercialRating",
+                        String.valueOf(insAreaCompany.getSyScore())));
             }
         }
         //交强赔付率

+ 60 - 2
src/main/java/com/ydtech/modules/fee/service/impl/FeeRuleSchemeServiceNewImpl.java

@@ -5,10 +5,14 @@ import com.ydtech.constants.enums.dict.insurance.EnergyType;
 import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.model.SysDept;
 import com.ydtech.modules.admin.model.SysUser;
+import com.ydtech.modules.admin.model.po.SysUserAccount;
 import com.ydtech.modules.admin.service.SysDeptService;
+import com.ydtech.modules.admin.service.SysUserAccountService;
 import com.ydtech.modules.admin.service.SysUserService;
 import com.ydtech.modules.esm.model.EsmRetail;
+import com.ydtech.modules.esm.model.EsmUserReferrer;
 import com.ydtech.modules.esm.service.EsmRetailService;
+import com.ydtech.modules.esm.service.EsmUserReferrerService;
 import com.ydtech.modules.fee.dto.vo.RuleAttrMappingVo;
 import com.ydtech.modules.fee.service.FeeRuleSchemeNewService;
 import com.ydtech.modules.order.entity.InsAreaCompany;
@@ -19,11 +23,15 @@ import com.ydtech.modules.protocol.service.*;
 import com.ydtech.modules.protocols.entity.po.*;
 import com.ydtech.modules.protocols.entity.vo.AgreementProductCosts;
 import com.ydtech.modules.protocols.service.*;
+import com.ydtech.utils.StringUtils;
 import com.ydtech.utils.idgen.IdGenerate;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -59,6 +67,11 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
 
     @Resource
     private InsFeeOrderNewService insFeeOrderNewService;
+    @Autowired
+    private EsmUserReferrerService esmUserReferrerService;
+
+    @Autowired
+    private SysUserAccountService  sysUserAccountService;
 
 
     @Override
@@ -362,9 +375,54 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                 }
             }
         }
-
+//      判断分销等级   通过userId  去查询  esm_user_referrer  如果 referrer_id  与 userId  相同时 一级分销   不同且还有上级为三级分销   其余  则二级分销
+        String userId = insFeeOrderNew.getUserId();
+        EsmUserReferrer esmUserReferrerServiceById = esmUserReferrerService.getById(userId);
+        if (ObjectUtils.isNotEmpty(esmUserReferrerServiceById)) {
+            String referrerId = esmUserReferrerServiceById.getReferrerId();
+//              如果相等则为一级
+            if (StringUtils.isNotEmpty(referrerId) && referrerId.equals(userId)) {
+                BigDecimal jqPremium = insFeeOrderNew.getJqPremium();  // 交强
+                BigDecimal bigdecimalFomat = new BigDecimal("100");
+                BigDecimal firstDetailProportion = insFeeOrderNew.getFirstDetailProportion();   // 一级分销比例
+                BigDecimal divide = firstDetailProportion.divide(bigdecimalFomat, 2, RoundingMode.HALF_UP);
+                BigDecimal jqAmount = jqPremium.multiply(divide);    //交强分销费用
+
+                BigDecimal jaLevelAmount1 = insFeeOrderNew.getJqDeptProportionLevel1() != null ? jqAmount.multiply(insFeeOrderNew.getJqDeptProportionLevel1().divide(bigdecimalFomat, 2, RoundingMode.HALF_UP)) : BigDecimal.ZERO;
+                BigDecimal jaLevelAmount2 = insFeeOrderNew.getJqDeptProportionLevel2() != null ? jqAmount.multiply(insFeeOrderNew.getJqDeptProportionLevel2().divide(bigdecimalFomat, 2, RoundingMode.HALF_UP)) : BigDecimal.ZERO;
+                BigDecimal jaLevelAmount3 = insFeeOrderNew.getJqDeptProportionLevel3() != null ? jqAmount.multiply(insFeeOrderNew.getJqDeptProportionLevel3().divide(bigdecimalFomat, 2, RoundingMode.HALF_UP)) : BigDecimal.ZERO;
+                BigDecimal jaLevelAmount4 = insFeeOrderNew.getJqDeptProportionLevel4() != null ? jqAmount.multiply(insFeeOrderNew.getJqDeptProportionLevel4().divide(bigdecimalFomat, 2, RoundingMode.HALF_UP)) : BigDecimal.ZERO;
+                BigDecimal jaLevelAmount5 = insFeeOrderNew.getJqDeptProportionLevel4() != null ? jqAmount.multiply(insFeeOrderNew.getJqDeptProportionLevel5().divide(bigdecimalFomat, 2, RoundingMode.HALF_UP)) : BigDecimal.ZERO;
+
+                insFeeOrderNew.setJqDeptPremiumsLevel1(insFeeOrderNew.getJqDeptPremiumsLevel1().add(jaLevelAmount1));//    交强一级机构管理费
+                insFeeOrderNew.setJqDeptPremiumsLevel2(insFeeOrderNew.getJqDeptPremiumsLevel2().add(jaLevelAmount2));//    交强二级机构管理费
+                insFeeOrderNew.setJqDeptPremiumsLevel3(insFeeOrderNew.getJqDeptPremiumsLevel3().add(jaLevelAmount3));//    交强三级机构管理费
+                insFeeOrderNew.setJqDeptPremiumsLevel4(insFeeOrderNew.getJqDeptPremiumsLevel4().add(jaLevelAmount4));//    交强四级机构管理费
+                insFeeOrderNew.setJqDeptPremiumsLevel5(insFeeOrderNew.getJqDeptPremiumsLevel5().add(jaLevelAmount5));//    交强五级机构管理费
+
+            } else {
+                EsmUserReferrer secondReferrer = esmUserReferrerService.getById(referrerId);
+                if (ObjectUtils.isNotEmpty(secondReferrer)) {
+                    //                二级分销
+                    BigDecimal secondDetailPremiums = insFeeOrderNew.getSecondDetailPremiums();
+                    BigDecimal thirdDetailPremiums = insFeeOrderNew.getThirdDetailPremiums();
+                    if (StringUtils.isNotEmpty(secondReferrer.getReferrerId()) && secondReferrer.getReferrerId().equals(referrerId)) {
+//                     二级分销  则  添加到 sys_user_account  表的 promotion  推广金 字段里
+                        SysUserAccount sysUserAccount = new SysUserAccount();
+                        sysUserAccount.setUserId(referrerId);
+                        sysUserAccount.setPromotion(secondDetailPremiums);
+                        sysUserAccountService.addOrUpdate(sysUserAccount);
+                    } else {
+//                     最后为三级
+                        SysUserAccount sysUserAccount = new SysUserAccount();
+                        sysUserAccount.setUserId(secondReferrer.getReferrerId());
+                        sysUserAccount.setPromotion(thirdDetailPremiums);
+                        sysUserAccountService.addOrUpdate(sysUserAccount);
+                    }
+                }
+            }
+        }
         insFeeOrderNewService.saveOrUpdate(insFeeOrderNew);
-
     }
 
 

+ 1 - 0
src/main/java/com/ydtech/modules/fnc/controller/CarSettleController.java

@@ -78,6 +78,7 @@ public class CarSettleController extends BaseController {
     @PostMapping("/auditFee")
     @ApiOperation(value = "[3]费用审核")
     public HttpResult auditFee(@RequestBody @Valid AuditOrderFeeVo auditOrderFeeVo) {
+//        订单号
         String orderNo = auditOrderFeeVo.getOrderNo();
         //查询改订单是已审核
         List<InsFeeAudit> feeList =insFeeAuditService.query().eq("orderno",orderNo).list();

+ 138 - 69
src/main/java/com/ydtech/modules/fnc/service/impl/InsFeeAuditServiceImpl.java

@@ -1,10 +1,15 @@
 package com.ydtech.modules.fnc.service.impl;
 
 import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.util.NumberUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.ydtech.modules.admin.model.SysDept;
+import com.ydtech.modules.admin.model.SysDeptAccountEntity;
 import com.ydtech.modules.admin.model.SysUser;
+import com.ydtech.modules.admin.model.po.SysUserAccount;
+import com.ydtech.modules.admin.service.SysDeptAccountService;
 import com.ydtech.modules.admin.service.SysDeptService;
+import com.ydtech.modules.admin.service.SysUserAccountService;
 import com.ydtech.modules.admin.service.SysUserService;
 import com.ydtech.modules.esm.service.EsmUserReferrerService;
 import com.ydtech.modules.fnc.dao.FncInsAreaCompanyMapper;
@@ -30,6 +35,8 @@ import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
 import com.ydtech.modules.protocols.service.InsFeeOrderNewService;
 import com.ydtech.utils.DateUtil;
 import com.ydtech.utils.StringUtils;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.math.NumberUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -68,8 +75,13 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
     @Autowired
     private InsFeeOrderNewService insFeeOrderNewService;
 
+    @Autowired
+    private SysUserAccountService sysUserAccountService;
+
     @Autowired
     private SysDeptService sysDeptService;
+    @Autowired
+    private SysDeptAccountService sysDeptAccountService;
 
 
     public InsFeeAuditServiceImpl(FncInsAreaCompanyMapper insAreaCompanyMapper, InsOrdersMapper insOrdersMapper, InsFeeOrderService insFeeOrderService,InsDeptFeeService insDeptFeeService,EsmUserReferrerService esmUserReferrerService,SysUserService sysUserService,InsCommissionService insCommissionService,InsCompanyFeeService insCompanyFeeService,InsPlyIncomeMapper insPlyIncomeMapper) {
@@ -110,7 +122,8 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
 
         List<SysDept> teamList = sysDeptService.findTeamList(deptId);
         teamList.forEach(sysDept -> {
-            if(sysDept.getComlevel().equals("1")){
+
+            if(StringUtils.isNotEmpty(sysDept.getComlevel()) &&  sysDept.getComlevel().equals("1")){
                 BigDecimal jqDeptPremiumsLevel1 = insFeeOrderNew.getJqDeptPremiumsLevel1();
             }
         });
@@ -126,6 +139,47 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
         saveRetail(order,insFeeOrder,insAreaCompany);
         //个代费用生成
         saveInsCompanyFee(order,insFeeOrder,insAreaCompany);
+
+
+//      生成  用户账户表  数据
+        if(StringUtils.isNotEmpty(order.getUserid())){
+//            用戶賬戶表
+            SysUserAccount sysUserAccount = new SysUserAccount();
+//            部門金額表
+            SysDeptAccountEntity sysDeptAccountEntity = new SysDeptAccountEntity();
+            sysUserAccount.setUserId(order.getUserid());
+            if (ObjectUtils.isNotEmpty(insFeeOrderNew) ) {
+                BigDecimal jqPremium = insFeeOrderNew.getJqSuperviseCostsPremiums(); //交强险保费
+                BigDecimal syPremium = insFeeOrderNew.getSySuperviseCostsPremiums(); //商业险保费
+                BigDecimal noPremium = insFeeOrderNew.getNoSuperviseCostsPremiums(); //非车险保费
+
+                if(jqPremium==null){
+                    jqPremium= BigDecimal.ZERO;
+                }
+                if(syPremium==null){
+                    syPremium= BigDecimal.ZERO;
+                }
+                if(noPremium==null){
+                    noPremium= BigDecimal.ZERO;
+                }
+//              用戶
+                sysUserAccount.setHandlingFee(jqPremium);
+                sysUserAccount.setDocumentary(syPremium);
+                sysUserAccount.setPromotion(noPremium);
+                sysUserAccount.setDocumentaryStatus("2");  // 收入
+                sysUserAccount.setSuborderId(orderNo);  // 订单Id
+//              部门金额
+                sysDeptAccountEntity.setHandlingFee(jqPremium);
+                sysDeptAccountEntity.setDocumentary(syPremium);
+                sysDeptAccountEntity.setPromotion(noPremium);
+                sysDeptAccountEntity.setDeptId(order.getDeptid());
+                sysUserAccountService.addOrUpdate(sysUserAccount);
+                sysDeptAccountService.addOrUpdate(sysDeptAccountEntity);
+
+
+            }
+        }
+
     }
 
     /**
@@ -149,24 +203,28 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
             insPlyIncome.setPolicyno(plyDto.getJqpolicyno());
             insPlyIncome.setRiskcode("交强");
             insPlyIncome.setTaxamount(plyDto.getTaxamount());
-            insPlyIncome.setNoTaxPremium(insFeeOrder.getJqNoTaxPremium());
-            insPlyIncome.setCommissionFeerate(insFeeOrder.getJqSuperviseCostsProportion());
-            insPlyIncome.setOtherFeerate(insFeeOrder.getJqCostsProportion().subtract(insFeeOrder.getJqSuperviseCostsProportion()));
-            insPlyIncome.setCommissionFeevalue(insFeeOrder.getJqSuperviseCostsPremiums());
-            insPlyIncome.setOtherFeevalue(insFeeOrder.getJqCostsPremiums().subtract(insFeeOrder.getJqSuperviseCostsPremiums()));
-            insPlyIncome.setAllFeeValue(insFeeOrder.getJqCostsPremiums());
+            if(!ObjectUtils.isEmpty(insFeeOrder)){
+                insPlyIncome.setNoTaxPremium(insFeeOrder.getJqNoTaxPremium());
+                insPlyIncome.setCommissionFeerate(insFeeOrder.getJqSuperviseCostsProportion());
+                insPlyIncome.setOtherFeerate(insFeeOrder.getJqCostsProportion().subtract(insFeeOrder.getJqSuperviseCostsProportion()));
+                insPlyIncome.setCommissionFeevalue(insFeeOrder.getJqSuperviseCostsPremiums());
+                insPlyIncome.setOtherFeevalue(insFeeOrder.getJqCostsPremiums().subtract(insFeeOrder.getJqSuperviseCostsPremiums()));
+                insPlyIncome.setAllFeeValue(insFeeOrder.getJqCostsPremiums());
+            }
             insPlyIncomeMapper.insert(insPlyIncome);
         }
         if(StringUtils.isNotEmpty(plyDto.getSypolicyno())){
             insPlyIncome.setPolicyno(plyDto.getSypolicyno());
             insPlyIncome.setRiskcode("商业");
             insPlyIncome.setTaxamount(new BigDecimal(0));
-            insPlyIncome.setNoTaxPremium(insFeeOrder.getSyNoTaxPremium());
-            insPlyIncome.setCommissionFeerate(insFeeOrder.getSySuperviseCostsProportion());
-            insPlyIncome.setOtherFeerate(insFeeOrder.getSyCostsProportion().subtract(insFeeOrder.getSySuperviseCostsProportion()));
-            insPlyIncome.setCommissionFeevalue(insFeeOrder.getSySuperviseCostsPremiums());
-            insPlyIncome.setOtherFeevalue(insFeeOrder.getSyCostsPremiums().subtract(insFeeOrder.getSySuperviseCostsPremiums()));
-            insPlyIncome.setAllFeeValue(insFeeOrder.getSyCostsPremiums());
+            if(!ObjectUtils.isEmpty(insFeeOrder)){
+                insPlyIncome.setNoTaxPremium(insFeeOrder.getSyNoTaxPremium());
+                insPlyIncome.setCommissionFeerate(insFeeOrder.getSySuperviseCostsProportion());
+                insPlyIncome.setOtherFeerate(insFeeOrder.getSyCostsProportion().subtract(insFeeOrder.getSySuperviseCostsProportion()));
+                insPlyIncome.setCommissionFeevalue(insFeeOrder.getSySuperviseCostsPremiums());
+                insPlyIncome.setOtherFeevalue(insFeeOrder.getSyCostsPremiums().subtract(insFeeOrder.getSySuperviseCostsPremiums()));
+                insPlyIncome.setAllFeeValue(insFeeOrder.getSyCostsPremiums());
+            }
             insPlyIncomeMapper.insert(insPlyIncome);
         }
 
@@ -180,11 +238,16 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
     private void gene_deptfee( InsOrders order, InsFeeOrder insFeeOrder,InsAreaCompany plyDto) throws Exception{
         InsDeptFee deptFee = new InsDeptFee();
         deptFee.setOrderno(order.getOrderno());
-        deptFee.setQuoteno(insFeeOrder.getInsOrderNo());
+        if(!ObjectUtils.isEmpty(insFeeOrder)){
+            deptFee.setQuoteno(insFeeOrder.getInsOrderNo());
+        }
         deptFee.setAgreeid(String.valueOf(plyDto.getAgreementId()));
         deptFee.setAuditstatus("1");
         deptFee.setSettlestatus("0");
-        deptFee.setSignDate(DateUtil.formatFullTime(plyDto.getInsidePayTime(),DateUtil.FULL_TIME_SPLIT_PATTERN));
+        if(plyDto.getInsidePayTime()!=null){
+            deptFee.setSignDate(DateUtil.formatFullTime(plyDto.getInsidePayTime(),DateUtil.FULL_TIME_SPLIT_PATTERN));
+
+        }
         deptFee.setInscompany(plyDto.getCompanyId());
         if(StringUtils.isNotEmpty(plyDto.getJqpolicyno())){
             deptFee.setPolicyno(plyDto.getJqpolicyno());
@@ -202,30 +265,32 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
     }
 
     private void geneInsDeptFee(InsOrders order, InsFeeOrder insFeeOrder, InsDeptFee deptFee) {
-        if (insFeeOrder.getFirstDeptPremiums().doubleValue() > 0) {
-            deptFee.setComcode(order.getDeptid().substring(0, 2));  //99140302M01D01
-            deptFee.setComlevel("一级");
-            insDeptFeeService.insert(deptFee);
-        }
-        if (insFeeOrder.getSecondDeptPremiums().doubleValue() > 0) {
-            deptFee.setComcode(order.getDeptid().substring(0, 4));  //99140302M01D01
-            deptFee.setComlevel("二级");
-            insDeptFeeService.insert(deptFee);
-        }
-        if (insFeeOrder.getThirdDeptPremiums().doubleValue() > 0) {
-            deptFee.setComcode(order.getDeptid().substring(0, 6));  //99140302M01D01
-            deptFee.setComlevel("三级");
-            insDeptFeeService.insert(deptFee);
-        }
-        if (insFeeOrder.getForthDeptPremiums().doubleValue() > 0) {
-            deptFee.setComcode(order.getDeptid().substring(0, 8));  //99140302M01D01
-            deptFee.setComlevel("四级");
-            insDeptFeeService.insert(deptFee);
-        }
-        if (insFeeOrder.getFifthDeptPremiums().doubleValue() > 0) {
-            deptFee.setComcode(order.getDeptid().substring(0, 11));  //99140302M01D01
-            deptFee.setComlevel("五级");
-            insDeptFeeService.insert(deptFee);
+        if(!ObjectUtils.isEmpty(insFeeOrder)){
+            if (insFeeOrder.getFirstDeptPremiums().doubleValue() > 0) {
+                deptFee.setComcode(order.getDeptid().substring(0, 2));  //99140302M01D01
+                deptFee.setComlevel("一级");
+                insDeptFeeService.insert(deptFee);
+            }
+            if (insFeeOrder.getSecondDeptPremiums().doubleValue() > 0) {
+                deptFee.setComcode(order.getDeptid().substring(0, 4));  //99140302M01D01
+                deptFee.setComlevel("二级");
+                insDeptFeeService.insert(deptFee);
+            }
+            if (insFeeOrder.getThirdDeptPremiums().doubleValue() > 0) {
+                deptFee.setComcode(order.getDeptid().substring(0, 6));  //99140302M01D01
+                deptFee.setComlevel("三级");
+                insDeptFeeService.insert(deptFee);
+            }
+            if (insFeeOrder.getForthDeptPremiums().doubleValue() > 0) {
+                deptFee.setComcode(order.getDeptid().substring(0, 8));  //99140302M01D01
+                deptFee.setComlevel("四级");
+                insDeptFeeService.insert(deptFee);
+            }
+            if (insFeeOrder.getFifthDeptPremiums().doubleValue() > 0) {
+                deptFee.setComcode(order.getDeptid().substring(0, 11));  //99140302M01D01
+                deptFee.setComlevel("五级");
+                insDeptFeeService.insert(deptFee);
+            }
         }
     }
 
@@ -376,37 +441,41 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
         insCompanyFee.setSettletype("B");
         insCompanyFee.setSettlestatus("0");
         insCompanyFee.setCreatetime(DateUtil.getDateFormat(new Date(),DateUtil.FULL_TIME_SPLIT_PATTERN));
-        insCompanyFee.setSignDate(DateUtil.formatFullTime(plyDto.getInsidePayTime(),DateUtil.FULL_TIME_SPLIT_PATTERN));
-        BigDecimal dept_rate=insFeeOrder.getFirstDeptProportion()
-                .add(insFeeOrder.getSecondDeptProportion())
-                .add(insFeeOrder.getThirdDeptProportion())
-                .add(insFeeOrder.getForthDeptProportion())
-                .add(insFeeOrder.getFifthDeptProportion());
-        BigDecimal retail_rate=insFeeOrder.getFirstRetailProportion()
-                .add(insFeeOrder.getSecondRetailProportion())
-                .add(insFeeOrder.getThirdRetailProportion());
-        if(StringUtils.isNotEmpty(plyDto.getJqpolicyno())){
-            insCompanyFee.setPolicyno(plyDto.getJqpolicyno());
-            insCompanyFee.setRiskcode("交强");
-            //交强费用比例=交强险费用比例-五级机构管理费比例-三级分销比例
-            insCompanyFee.setFeerate(insFeeOrder.getJqCostsProportion().subtract(dept_rate).subtract(retail_rate).doubleValue());
-            insCompanyFee.setFeeamount(insFeeOrder.getJqNoTaxPremium().multiply(insFeeOrder.getJqCostsProportion().subtract(dept_rate).subtract(retail_rate)).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
-            insCompanyFee.setJqpremium(insFeeOrder.getJqNoTaxPremium().doubleValue());
-            //保存业务员费用
-            insCompanyFeeService.insert(insCompanyFee);
+        if(plyDto.getInsidePayTime()!=null){
+            insCompanyFee.setSignDate(DateUtil.formatFullTime(plyDto.getInsidePayTime(),DateUtil.FULL_TIME_SPLIT_PATTERN));
         }
-        if(StringUtils.isNotEmpty(plyDto.getSypolicyno())){
-            insCompanyFee.setPolicyno(plyDto.getSypolicyno());
-            insCompanyFee.setRiskcode("商业");
-            insCompanyFee.setFeerate(0);
-            insCompanyFee.setFeeamount(0);
-            insCompanyFee.setJqpremium(0);
-            //商业费用比例=商业险费用比例-五级机构管理费比例-三级分销比例
-            insCompanyFee.setDisrate(insFeeOrder.getSyCostsProportion().subtract(dept_rate).subtract(retail_rate).doubleValue());
-            insCompanyFee.setDisamount(insFeeOrder.getSyNoTaxPremium().multiply(insFeeOrder.getSyCostsProportion().subtract(dept_rate).subtract(retail_rate)).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
-            insCompanyFee.setSypremium(insFeeOrder.getSyNoTaxPremium().doubleValue());
-            //保存业务员费用
-            insCompanyFeeService.insert(insCompanyFee);
+        if(ObjectUtils.isNotEmpty(insFeeOrder)){
+            BigDecimal dept_rate=insFeeOrder.getFirstDeptProportion()
+                    .add(insFeeOrder.getSecondDeptProportion())
+                    .add(insFeeOrder.getThirdDeptProportion())
+                    .add(insFeeOrder.getForthDeptProportion())
+                    .add(insFeeOrder.getFifthDeptProportion());
+            BigDecimal retail_rate=insFeeOrder.getFirstRetailProportion()
+                    .add(insFeeOrder.getSecondRetailProportion())
+                    .add(insFeeOrder.getThirdRetailProportion());
+            if(StringUtils.isNotEmpty(plyDto.getJqpolicyno())){
+                insCompanyFee.setPolicyno(plyDto.getJqpolicyno());
+                insCompanyFee.setRiskcode("交强");
+                //交强费用比例=交强险费用比例-五级机构管理费比例-三级分销比例
+                insCompanyFee.setFeerate(insFeeOrder.getJqCostsProportion().subtract(dept_rate).subtract(retail_rate).doubleValue());
+                insCompanyFee.setFeeamount(insFeeOrder.getJqNoTaxPremium().multiply(insFeeOrder.getJqCostsProportion().subtract(dept_rate).subtract(retail_rate)).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
+                insCompanyFee.setJqpremium(insFeeOrder.getJqNoTaxPremium().doubleValue());
+                //保存业务员费用
+                insCompanyFeeService.insert(insCompanyFee);
+            }
+            if(StringUtils.isNotEmpty(plyDto.getSypolicyno())){
+                insCompanyFee.setPolicyno(plyDto.getSypolicyno());
+                insCompanyFee.setRiskcode("商业");
+                insCompanyFee.setFeerate(0);
+                insCompanyFee.setFeeamount(0);
+                insCompanyFee.setJqpremium(0);
+                //商业费用比例=商业险费用比例-五级机构管理费比例-三级分销比例
+                insCompanyFee.setDisrate(insFeeOrder.getSyCostsProportion().subtract(dept_rate).subtract(retail_rate).doubleValue());
+                insCompanyFee.setDisamount(insFeeOrder.getSyNoTaxPremium().multiply(insFeeOrder.getSyCostsProportion().subtract(dept_rate).subtract(retail_rate)).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
+                insCompanyFee.setSypremium(insFeeOrder.getSyNoTaxPremium().doubleValue());
+                //保存业务员费用
+                insCompanyFeeService.insert(insCompanyFee);
+            }
         }
 
     }

+ 4 - 5
src/main/java/com/ydtech/modules/ins/model/yc/YcBuildData.java

@@ -17,6 +17,7 @@ import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 /**
@@ -214,7 +215,7 @@ public class YcBuildData {
         }
 
         //出险信息
-        quoteRespVo.setAccidentInfoStr(String.format("%s%s", ciSB.toString(), biSB.toString()));
+        quoteRespVo.setAccidentInfoStr(String.format("%s%s", ciSB, biSB));
 
 
         //欠税信息
@@ -234,11 +235,9 @@ public class YcBuildData {
         if (null != rd.getTfiWarnList()) {
             //排空
             List<TfiWarnListResponse.TfiWarnData> tfiWarnData =
-                    rd.getTfiWarnList().getTfiWarnData().stream().filter(item -> null != item).filter(item -> StringUtils.isNotEmpty(item.getWarnMessage())).collect(Collectors.toList());
+                    rd.getTfiWarnList().getTfiWarnData().stream().filter(Objects::nonNull).filter(item -> StringUtils.isNotEmpty(item.getWarnMessage())).collect(Collectors.toList());
             List<String> warnMessageList = new ArrayList<>();
-            tfiWarnData.stream().forEach(a -> {
-                warnMessageList.add(a.getWarnMessage());
-            });
+            tfiWarnData.forEach(a -> warnMessageList.add(a.getWarnMessage()));
             quoteRespVo.setWarnMessageList(warnMessageList);
         }
 

+ 31 - 1
src/main/java/com/ydtech/modules/inv/controller/InvReceivableController.java

@@ -16,9 +16,21 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.core.io.UrlResource;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.util.ResourceUtils;
 import org.springframework.web.bind.annotation.*;
 
-import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.MalformedURLException;
+import java.net.URLEncoder;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -136,6 +148,15 @@ public class InvReceivableController extends BaseController {
         return HttpResult.ok(uploadUrl + "excel/" + fileName);
     }
 
+    @ApiOperation("结算导入新增")
+    @PostMapping("addSettlement")
+    public HttpResult addSettlement(@RequestBody InvSettlementSource invSettlementSource){
+        Boolean b = invReceivableService.addSettlement(invSettlementSource);
+        return b ? HttpResult.ok("新增成功") : HttpResult.error("新增失败");
+    }
+
+
+
     @ApiOperation("结算导入删除")
     @PostMapping("deleteSettlement")
     public HttpResult deleteSettlement(@RequestBody String[] ids) {
@@ -231,4 +252,13 @@ public class InvReceivableController extends BaseController {
         return HttpResult.ok("", false);
     }
 
+    @GetMapping("getAccountsReceivable")
+    public HttpResult getAccountsReceivable(){
+        return HttpResult.ok("下载成功","template/finance/accountsReceivable.xlsx");
+    }
+
+    @GetMapping("/getSettlement")
+    public HttpResult getSettlement(){
+       return HttpResult.ok("下载成功","template/finance/settlement.xlsx");
+    }
 }

+ 48 - 0
src/main/java/com/ydtech/modules/inv/model/po/InvSettlementSource.java

@@ -224,6 +224,54 @@ public class InvSettlementSource implements Serializable {
     @ExcelProperty("代理结算时间")
     private String agencySettlementTime;
 
+    /**
+     * 导入日期
+     */
+    @TableField(value = "revenue_time")
+    @ApiModelProperty("导入日期")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @ExcelProperty("导入日期")
+    private String revenueTime;
+
+    /**
+     * 导入人名字
+     */
+    @TableField(value = "revenue_name")
+    @ApiModelProperty("导入人名字")
+    @ExcelProperty("导入人名字")
+    private String revenueName;
+
+    /**
+     * 导入人Id
+     */
+    @TableField(value = "revenue_userid")
+    @ApiModelProperty("导入人Id")
+    @ExcelProperty("导入人Id")
+    private String revenueUserId;
+
+
+
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
+
+    public void builder(){
+        if(null == this.getJqPremiumTax()){
+            this.setJqPremiumTax(new BigDecimal(0));
+        }
+        if(null == this.getSyPremiumTax()){
+            this.setSyPremiumTax(new BigDecimal(0));
+        }
+        if(null == this.getNonCarPremiumTax()){
+            this.setNonCarPremiumTax(new BigDecimal(0));
+        }
+        if(null == this.getCompulsoryExportRatio()){
+            this.setCompulsoryExportRatio(new BigDecimal(0));
+        }
+        if(null == this.getCommercialExportRatio()){
+            this.setCommercialExportRatio(new BigDecimal(0));
+        }
+        if(null == this.getNonVehicleExportRatio()){
+            this.setNonVehicleExportRatio(new BigDecimal(0));
+        }
+    }
 }

+ 11 - 2
src/main/java/com/ydtech/modules/inv/model/po/InvSource.java

@@ -349,7 +349,6 @@ public class InvSource implements Serializable {
     @TableField(value = "revenue_time")
     @ApiModelProperty("导入日期")
     @JsonFormat(pattern = "yyyy-MM-dd")
-    @ExcelProperty("导入日期")
     private String revenueTime;
 
     /**
@@ -357,9 +356,19 @@ public class InvSource implements Serializable {
      */
     @TableField(value = "revenue_name")
     @ApiModelProperty("导入人名字")
-    @ExcelProperty("导入人名字")
     private String revenueName;
 
+    /**
+     * 导入人Id
+     */
+    @TableField(value = "revenue_userid")
+    @ApiModelProperty("导入人Id")
+    private String revenueUserId;
+
+    @TableField(value = "inv_source_type")
+    @ApiModelProperty("应收类型(平台,私有)")
+    private String invSourceType;
+
     @TableField(exist = false)
     private String[] ids;
 

+ 23 - 0
src/main/java/com/ydtech/modules/inv/model/vo/InvSettlementSourceQueryVo.java

@@ -1,5 +1,6 @@
 package com.ydtech.modules.inv.model.vo;
 
+import com.alibaba.excel.annotation.ExcelProperty;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -181,6 +182,28 @@ public class InvSettlementSourceQueryVo extends PageRequest implements Serializa
     @JsonFormat(pattern = "yyyy-MM-dd")
     private String agencySettlementTime;
 
+    /**
+     * 导入日期
+     */
+    @TableField(value = "revenue_time")
+    @ApiModelProperty("导入日期")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private String revenueTime;
+
+    /**
+     * 导入人名字
+     */
+    @TableField(value = "revenue_name")
+    @ApiModelProperty("导入人名字")
+    private String revenueName;
+
+    /**
+     * 导入人Id
+     */
+    @TableField(value = "revenue_userid")
+    @ApiModelProperty("导入人Id")
+    private String revenueUserId;
+
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
 }

+ 3 - 3
src/main/java/com/ydtech/modules/inv/model/vo/InvSourceQueryVo.java

@@ -310,10 +310,10 @@ public class InvSourceQueryVo extends PageRequest implements Serializable {
     @ApiModelProperty("导入人名字")
     private String revenueName;
 
+    @TableField(value = "inv_source_type")
+    @ApiModelProperty("应收类型")
+    private String invSourceType;
 
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
-
-
-
 }

+ 2 - 0
src/main/java/com/ydtech/modules/inv/service/InvReceivableService.java

@@ -53,6 +53,8 @@ public interface InvReceivableService {
 
     Boolean addReceivable(InvSource invSource);
 
+    Boolean addSettlement(InvSettlementSource invSettlementSource);
+
     List<String> dataMatching();
 
     Boolean deleteSettlement(String[] ids);

+ 76 - 25
src/main/java/com/ydtech/modules/inv/service/impl/InvReceivableServiceImpl.java

@@ -616,50 +616,101 @@ public class InvReceivableServiceImpl implements InvReceivableService {
         invSource.setId(IdGenerate.nextId());
         invSource.builder();
         BigDecimal tax = new BigDecimal(1.06);
-        //处理交强不含税
-        invSource.setJqPremium(invSource.getJqPremiumTax().divide(tax, 2, RoundingMode.HALF_UP));
-        //处理商业不含税
-        invSource.setSyPremium(invSource.getSyPremiumTax().divide(tax, 2, RoundingMode.HALF_UP));
-        //处理非车不含税
-        invSource.setNonCarPremium(invSource.getNonCarPremiumTax().divide(tax, 2, RoundingMode.HALF_UP));
-
+        /**
+         * jqPremiumTax  交强险保费
+         * syPremiumTax  商业险保费
+         * nonCarPremiumTax 非车保费
+         * jqReceivableRatio 交强应收比例
+         * syReceivableRatio 商业应收比列
+         * nonCarReceivableRatio 非车应收比列
+         * jqPremium  交强险保费(不含税)
+         * syPremium  商业险保费(不含税)
+         * nonCarPremium 非车保费(不含税)
+         * jqPremiumRatio 交强手续费比例
+         * syPremiumRatio 商业手续费比例
+         * nonCarPremiumRatio 非车手续费比例
+         * jqNonCopyingRatio 交强非跟单比例
+         * syNonCopyingRatio 商业非跟单比例
+         * nonCarNonCopyingRatio 非车非跟单比例
+         */
         //处理非跟单比例
         invSource.setJqNonCopyingRatio(invSource.getJqReceivableRatio().subtract(invSource.getJqPremiumRatio()));
         invSource.setSyNonCopyingRatio(invSource.getSyReceivableRatio().subtract(invSource.getSyPremiumRatio()));
         invSource.setNonCarNonCopyingRatio(invSource.getNonCarReceivableRatio().subtract(invSource.getNonCarPremiumRatio()));
 
-        //处理手续费金额
-        invSource.setPremium(
-                invSource.getJqPremium().multiply(invSource.getJqPremiumRatio())
-                        .add(invSource.getSyPremium().multiply(invSource.getSyPremiumRatio()))
-                        .add(invSource.getNonCarPremium().multiply(invSource.getNonCarPremiumRatio())));
-        //处理非跟单金额
-        invSource.setNonCopying(
-                invSource.getJqPremium().multiply(invSource.getJqNonCopyingRatio())
-                        .add(invSource.getSyPremium().multiply(invSource.getSyNonCopyingRatio()))
-                        .add(invSource.getNonCarPremium().multiply(invSource.getNonCarNonCopyingRatio())));
-        //处理保司应收金额
-        invSource.setReceivable(
-                invSource.getJqPremium().multiply(invSource.getJqReceivableRatio())
-                        .add(invSource.getSyPremium().multiply(invSource.getSyReceivableRatio()))
-                        .add(invSource.getNonCarPremium().multiply(invSource.getNonCarReceivableRatio())));
         //处理补贴金额
         invSource.setSubsidyAmount(
                 invSource.getJqPremiumTax().multiply(invSource.getSubsidyRatio())
                         .add(invSource.getSyPremiumTax().multiply(invSource.getSubsidyRatio()))
                         .add(invSource.getNonCarPremiumTax().multiply(invSource.getSubsidyRatio())));
-        //处理应收总金额
-        invSource.setTotalReceivableAmount(
-                invSource.getReceivable().add(invSource.getSubsidyAmount()));
         //处理最大应付金额
         invSource.setMaxReceivable(
                 invSource.getJqPremiumTax().multiply(invSource.getMaxJqReceivableRatio())
                         .add(invSource.getSyPremiumTax().multiply(invSource.getMaxSyReceivableRatio()))
                         .add(invSource.getNonCarPremiumTax().multiply(invSource.getMaxNonCarReceivableRatio())));
+        //处理不含税保费
+        invSource.setJqPremium(invSource.getJqPremiumTax().divide(tax, 2, RoundingMode.HALF_UP));
+        invSource.setSyPremium(invSource.getSyPremiumTax().divide(tax, 2, RoundingMode.HALF_UP));
+        invSource.setNonCarPremium(invSource.getNonCarPremiumTax().divide(tax, 2, RoundingMode.HALF_UP));
+
+        //手续费金额  premium
+        invSource.setPremium(invSource.getJqPremium().multiply(invSource.getJqPremiumRatio())
+                .add(invSource.getSyPremium().multiply(invSource.getSyPremiumRatio())
+                        .add(invSource.getNonCarPremium().multiply(invSource.getNonCarPremiumRatio()))));
+
+        //非跟单金额  nonCopying
+        invSource.setNonCopying(invSource.getJqPremium().multiply(invSource.getJqNonCopyingRatio())
+                .add(invSource.getSyPremium().multiply(invSource.getSyNonCopyingRatio())
+                        .add(invSource.getNonCarPremium().multiply(invSource.getNonCarNonCopyingRatio()))));
+
+
+
+        //选择类型为平台类型时 应收金额 = 含税保费 * 应收比例
+        if (invSource.getInvSourceType().equals("platform")) {
+            //处理应收金额
+            invSource.setReceivable(invSource.getJqPremiumTax().multiply(invSource.getJqReceivableRatio())
+                    .add(invSource.getSyPremiumTax().multiply(invSource.getSyReceivableRatio())
+                    .add(invSource.getNonCarPremiumTax().multiply(invSource.getNonCarReceivableRatio()))));
+            //处理应收总金额
+            invSource.setTotalReceivableAmount(
+                    invSource.getReceivable().add(invSource.getSubsidyAmount()));
+        }
+
+        //选择类型为私有类型时 应收金额 = ( 不含税保费 * 手续费 )+ (不含税保费 * 非跟单比例)
+        if (invSource.getInvSourceType().equals("privately")) {
+            //应收金额
+            invSource.setReceivable(invSource.getPremium().add(invSource.getNonCopying()));
+
+            //处理应收总金额
+            invSource.setTotalReceivableAmount(
+                    invSource.getReceivable().add(invSource.getSubsidyAmount()));
+        }
+
         boolean save = invSourceMapper.insert(invSource) > 0 ? true : false;
         return save;
     }
 
+    @Override
+    public Boolean addSettlement(InvSettlementSource invSettlementSource) {
+        invSettlementSource.setId(IdGenerate.nextId());
+        invSettlementSource.builder();
+        //处理补贴金额
+        invSettlementSource.setSubsidyAmount(
+                invSettlementSource.getJqPremiumTax().multiply(invSettlementSource.getSubsidyRatio())
+                        .add(invSettlementSource.getSyPremiumTax().multiply(invSettlementSource.getSubsidyRatio()))
+                        .add(invSettlementSource.getNonCarPremiumTax().multiply(invSettlementSource.getSubsidyRatio())));
+        // 处理结算金额
+        invSettlementSource.setSettlementAmount(
+                invSettlementSource.getJqPremiumTax().multiply(invSettlementSource.getCompulsoryExportRatio())
+                        .add(invSettlementSource.getSyPremiumTax().multiply(invSettlementSource.getCommercialExportRatio())
+                        .add(invSettlementSource.getNonCarPremiumTax().multiply(invSettlementSource.getNonVehicleExportRatio())))
+        );
+        DateTime dateTime = new DateTime();
+        invSettlementSource.setRevenueTime(dateTime.toString());
+        boolean save = invSettlementSourceMapper.insert(invSettlementSource) > 0 ? true : false;
+        return save;
+    }
+
     @Override
     public List<String> dataMatching() {
         List<String> data = invSourceMapper.dataMatching();

+ 8 - 0
src/main/java/com/ydtech/modules/inv/service/impl/InvSettlementSourceServiceImpl.java

@@ -1,9 +1,12 @@
 package com.ydtech.modules.inv.service.impl;
 
+import cn.hutool.core.date.DateTime;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.admin.model.SysUser;
+import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.inv.dao.InvSettlementSourceMapper;
 import com.ydtech.modules.inv.model.excel.InvSettlementSourceExcel;
 import com.ydtech.modules.inv.model.po.InvSettlementSource;
@@ -60,6 +63,11 @@ public class InvSettlementSourceServiceImpl extends ServiceImpl<InvSettlementSou
                 invSettlementSource.setId(one.getId());
                 baseMapper.updateById(invSettlementSource);
             } else {
+                SysUser user = BaseController.getUser();
+                DateTime dateTime = new DateTime();
+                invSettlementSource.setRevenueTime(dateTime.toString());
+                invSettlementSource.setRevenueName(user.getName());
+                invSettlementSource.setRevenueUserId(user.getId());
                 baseMapper.insert(invSettlementSource);
             }
         }

+ 2 - 1
src/main/java/com/ydtech/modules/inv/service/impl/InvSourceServiceImpl.java

@@ -45,10 +45,11 @@ public class InvSourceServiceImpl extends ServiceImpl<InvSourceMapper, InvSource
         SysUser user = BaseController.getUser();
 
         DateTime dateTime = new DateTime();
-
         for (InvSource invSource : invSources) {
             invSource.setRevenueName(user.getName());
             invSource.setRevenueTime(dateTime.toString());
+            invSource.setRevenueUserId(user.getId());
+            invSource.setInvSourceType("platform");
         }
 
         boolean result = invSourceService.saveOrUpdateBatchWithConditions(invSources);

+ 1 - 0
src/main/java/com/ydtech/modules/order/components/ConfigureParametersComponents.java

@@ -10,6 +10,7 @@ import com.ydtech.modules.protocol.utils.AssertionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 import org.springframework.util.ReflectionUtils;
+import org.springframework.util.StringUtils;
 
 import java.lang.reflect.Field;
 import java.util.LinkedHashMap;

+ 81 - 3
src/main/java/com/ydtech/modules/order/components/FileComponents.java

@@ -1,9 +1,19 @@
 package com.ydtech.modules.order.components;
 
+import com.ydtech.exception.SystemException;
 import com.ydtech.utils.baidu.FileUtil;
+import net.lingala.zip4j.core.ZipFile;
+import net.lingala.zip4j.exception.ZipException;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
 
 @Component
 public class FileComponents {
@@ -17,9 +27,77 @@ public class FileComponents {
     @Value("${api.url}")
     private String apiUrl;
 
-    public String gainCarInsPolicy(String url, String fileName, String licensePlate) {
-        String dir = "carInsPolicy/" + licensePlate + "/";
-        return FileUtil.netUrlToFile(url, dir, fileName, uploadFilePath, apiUrl + showFileUrl);
+    public String gainCarInsPolicy(String url, String fileName, String licensePlate, String password) {
+        try {
+            String dir = uploadFilePath + "carInsPolicy/" + licensePlate + "/";
+            String showPath = apiUrl + showFileUrl + "carInsPolicy/" + licensePlate + "/" + fileName;
+            File existFile = new File(dir + fileName);
+            if (existFile.exists()) {
+                return showPath;
+            }
+
+            File folder = new File(dir);
+            if (!folder.isDirectory()) {
+                folder.mkdirs();
+            }
+
+            unzipFile(url, dir, password + ".zip", password, fileName);
+            return showPath;
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new SystemException("文件异常");
+        }
+    }
+
+    public static void unzipFile(String url, String zipPath, String zipName, String password, String newFileName) throws ZipException,
+            IOException {
+        String path = zipPath + zipName;
+        URI u = URI.create(url);
+        InputStream inputStream = u.toURL().openStream();
+        File file = new File(path);
+        FileUtil.copyInputStreamToFile(inputStream, file);
+        ZipFile zipFile = new ZipFile(path);
+        zipFile.setPassword(password);
+
+        String s = zipPath + password + "/";
+        zipFile.extractAll(s);
+
+        String fileName = getFileNames(s).get(0);
+        File oldFile = new File(s + fileName);
+        File newFile = new File(zipPath, newFileName);
+
+        oldFile.renameTo(newFile);
+    }
+
+    /**
+     * 得到文件名称
+     */
+    public static List<String> getFileNames(String path) {
+        File file = new File(path);
+        if (!file.exists()) {
+            return null;
+        }
+        List<String> fileNames = new ArrayList<>();
+        return getFileNames(file, fileNames);
+    }
+
+    /**
+     * 得到文件名称
+     *
+     * @param file      文件
+     * @param fileNames 文件名
+     * @return {@link List}<{@link String}>
+     */
+    public static List<String> getFileNames(File file, List<String> fileNames) {
+        File[] files = file.listFiles();
+        for (File f : files) {
+            if (f.isDirectory()) {
+                getFileNames(f, fileNames);
+            } else {
+                fileNames.add(f.getName());
+            }
+        }
+        return fileNames;
     }
 
 

+ 45 - 32
src/main/java/com/ydtech/modules/order/components/bohai/BoHaiRequestApiComponent.java

@@ -7,6 +7,7 @@ import com.ydtech.config.properties.BohaiApiConfigurationProperties;
 import com.ydtech.constants.InsuranceEnum;
 import com.ydtech.exception.SystemException;
 import com.ydtech.modules.order.entity.api.bohai.BoHaiEncrypted;
+import com.ydtech.modules.order.entity.api.bohai.constants.RequestType;
 import com.ydtech.modules.order.entity.api.bohai.constants.ResponseCode;
 import com.ydtech.modules.order.entity.api.bohai.request.*;
 import com.ydtech.modules.order.entity.api.bohai.response.*;
@@ -47,13 +48,16 @@ public class BoHaiRequestApiComponent {
      * @param <S>    Response 响应体
      * @return <S>
      */
-    private <Q extends BoHaiBaseRequest, S extends BoHaiBaseResponse> S post(Q q, String url, Class<S> tClass) throws Exception {
+    private <Q extends BoHaiBaseRequest, S extends BoHaiBaseResponse> S post(Q q, String url, Class<S> tClass, String sysSourceCode,
+                                                                             RequestType requestType) throws Exception {
+        q.setBaseParamRequestType(requestType.getCode());
         HttpHeaders httpHeaders = new HttpHeaders();
         httpHeaders.setContentType(MediaType.APPLICATION_JSON);
 
         String busReqString = JSON.toJSONString(q, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
-        InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> URl: {} \n---------> 请求参数:{}", url, busReqString);
-        BoHaiEncrypted boHaiEncrypted = new BoHaiEncrypted(busReqString, properties);
+        InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> {} \n\t---------> URl: {} \n\t---------> 请求参数:{}",
+                requestType.getDesc(), url, busReqString);
+        BoHaiEncrypted boHaiEncrypted = new BoHaiEncrypted(busReqString, properties, sysSourceCode);
         String json = JSON.toJSONString(boHaiEncrypted, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
         // 获取请求头signature 和加密后的内容
         Map<String, String> stringStringMap = SignatureUtils.encryptAndSign(properties.getSelfPrivateKey(),
@@ -61,21 +65,28 @@ public class BoHaiRequestApiComponent {
         String signature = stringStringMap.get("signature");
         String content = stringStringMap.get("content");
         httpHeaders.set("signature", signature);
-        InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> 加密后的参数:{} \n\t---------> 请求头内容signature:{}", content,
-                signature);
+        InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> {} \n\t---------> 加密后的参数:{} \n\t---------> " +
+                "请求头内容signature:{}", requestType.getDesc(), content, signature);
         // 请求
         HttpEntity<String> httpEntity = new HttpEntity<>(content, httpHeaders);
         ResponseEntity<String> response = restTemplate.postForEntity(url, httpEntity, String.class);
         String body = response.getBody();
-        InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> 解密前的参数:{}", body);
+        InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> {} \n\t---------> 解密前的参数:{}", requestType.getDesc(), body);
 
         // 解密响应
         BoHaiEncrypted encrypted = JSON.parseObject(body).toJavaObject(BoHaiEncrypted.class);
         String info = SignatureUtils.decryptByPrivateKey(encrypted.getBizContent(), properties.getSelfPrivateKey());
-        InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> 解密后的参数:{}", info);
+        InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> {} \n\t---------> 解密后的参数:{}", requestType.getDesc(), info);
         return JSON.parseObject(info).toJavaObject(tClass);
     }
 
+    public <Q extends BoHaiBaseRequest, S extends BoHaiBaseResponse> S verificationResponse(Q q, String url, Class<S> tClass,
+                                                                                            String sysSourceCode,
+                                                                                            RequestType requestType) throws Exception {
+        S response = post(q, url, tClass, sysSourceCode, requestType);
+        verificationResponseCode(response.getResponseCode(), response.getResponseMsg());
+        return response;
+    }
 
     /**
      * 生成订单号请求
@@ -83,8 +94,8 @@ public class BoHaiRequestApiComponent {
      * @param request 生成订单号请求实体
      * @return 返回订单号响应
      */
-    public GenerateOrderNoResponse generateOrderNo(GenerateOrderNoRequest request) throws Exception {
-        return post(request, properties.getUrl(), GenerateOrderNoResponse.class);
+    public GenerateOrderNoResponse generateOrderNo(GenerateOrderNoRequest request, String sysSourceCode) throws Exception {
+        return verificationResponse(request, properties.getUrl(), GenerateOrderNoResponse.class, sysSourceCode, RequestType.Z00002);
     }
 
     /**
@@ -93,8 +104,8 @@ public class BoHaiRequestApiComponent {
      * @param request 车辆查询请求实体
      * @return 响应
      */
-    public VehicleTypeQueryResponse vehicleTypeQuery(VehicleTypeQueryRequest request) throws Exception {
-        return post(request, properties.getUrl(), VehicleTypeQueryResponse.class);
+    public VehicleTypeQueryResponse vehicleTypeQuery(VehicleTypeQueryRequest request, String sysSourceCode) throws Exception {
+        return verificationResponse(request, properties.getUrl(), VehicleTypeQueryResponse.class, sysSourceCode, RequestType.Z00004);
     }
 
     /**
@@ -103,10 +114,11 @@ public class BoHaiRequestApiComponent {
      * @param request 车辆确认 请求实体
      * @return 响应
      */
-    public VehicleConfirmationResponse vehicleConfirmation(VehicleConfirmationReqeust request) throws Exception {
-        VehicleConfirmationResponse response = post(request, properties.getUrl(), VehicleConfirmationResponse.class);
+    public VehicleConfirmationResponse vehicleConfirmation(VehicleConfirmationReqeust request, String sysSourceCode) throws Exception {
+        VehicleConfirmationResponse response = post(request, properties.getUrl(), VehicleConfirmationResponse.class, sysSourceCode,
+                RequestType.Z00005);
         if (ResponseCode.R_Z00002.getCode().equals(response.getResponseCode())) {
-            response = post(request, properties.getUrl(), VehicleConfirmationResponse.class);
+            response = post(request, properties.getUrl(), VehicleConfirmationResponse.class, sysSourceCode, RequestType.Z00005);
         }
         if (ResponseCode.R_Z00001.getCode().equals(response.getResponseCode())) {
             return response;
@@ -120,8 +132,8 @@ public class BoHaiRequestApiComponent {
      * @param imageUploadRequest 影像请求
      * @return 响应
      */
-    public ImageUploadResponse imageUpload(ImageUploadRequest imageUploadRequest) throws Exception {
-        return post(imageUploadRequest, properties.getUrl(), ImageUploadResponse.class);
+    public ImageUploadResponse imageUpload(ImageUploadRequest imageUploadRequest, String sysSourceCode) throws Exception {
+        return verificationResponse(imageUploadRequest, properties.getUrl(), ImageUploadResponse.class, sysSourceCode, RequestType.Z00014);
     }
 
 
@@ -131,8 +143,8 @@ public class BoHaiRequestApiComponent {
      * @param request 车辆确认 请求实体
      * @return 响应
      */
-    public NonAutomotiveProductsResponse products(NonAutomotiveProductsRequest request) throws Exception {
-        return post(request, properties.getUrl(), NonAutomotiveProductsResponse.class);
+    public NonAutomotiveProductsResponse products(NonAutomotiveProductsRequest request, String sysSourceCode) throws Exception {
+        return verificationResponse(request, properties.getUrl(), NonAutomotiveProductsResponse.class, sysSourceCode, RequestType.Z00018);
     }
 
     /**
@@ -141,8 +153,9 @@ public class BoHaiRequestApiComponent {
      * @param request 车辆确认 请求实体
      * @return 响应
      */
-    public NonAutomotiveProductsDetailsResponse productsDetails(NonAutomotiveProductsDetailsRequest request) throws Exception {
-        return post(request, properties.getUrl(), NonAutomotiveProductsDetailsResponse.class);
+    public NonAutomotiveProductsDetailsResponse productsDetails(NonAutomotiveProductsDetailsRequest request, String sysSourceCode) throws Exception {
+        return verificationResponse(request, properties.getUrl(), NonAutomotiveProductsDetailsResponse.class, sysSourceCode,
+                RequestType.Z00019);
     }
 
 
@@ -152,8 +165,8 @@ public class BoHaiRequestApiComponent {
      * @param request 车辆确认 请求实体
      * @return 响应
      */
-    public QuotationResponse quotation(QuotationRequest request) throws Exception {
-        return post(request, properties.getUrl(), QuotationResponse.class);
+    public QuotationResponse quotation(QuotationRequest request, String sysSourceCode) throws Exception {
+        return post(request, properties.getUrl(), QuotationResponse.class, sysSourceCode, RequestType.Z00006);
     }
 
     /**
@@ -162,8 +175,8 @@ public class BoHaiRequestApiComponent {
      * @param underwritingRequest 核保 请求实体
      * @return 响应
      */
-    public UnderwritingResponse underwriting(UnderwritingRequest underwritingRequest) throws Exception {
-        return post(underwritingRequest, properties.getUrl(), UnderwritingResponse.class);
+    public UnderwritingResponse underwriting(UnderwritingRequest underwritingRequest, String sysSourceCode) throws Exception {
+        return post(underwritingRequest, properties.getUrl(), UnderwritingResponse.class, sysSourceCode, RequestType.Z00007);
     }
 
     /**
@@ -172,8 +185,8 @@ public class BoHaiRequestApiComponent {
      * @param paymentRequest 车辆确认 请求实体
      * @return 响应
      */
-    public PaymentResponse payment(PaymentRequest paymentRequest) throws Exception {
-        return post(paymentRequest, properties.getUrl(), PaymentResponse.class);
+    public PaymentResponse payment(PaymentRequest paymentRequest, String sysSourceCode) throws Exception {
+        return post(paymentRequest, properties.getUrl(), PaymentResponse.class, sysSourceCode, RequestType.Z00008);
     }
 
     /**
@@ -182,8 +195,9 @@ public class BoHaiRequestApiComponent {
      * @param electronicPolicyRequest 保单请求
      * @return 响应
      */
-    public ElectronicPolicyResponse electronicPolicy(ElectronicPolicyRequest electronicPolicyRequest) throws Exception {
-        return post(electronicPolicyRequest, properties.getUrl(), ElectronicPolicyResponse.class);
+    public ElectronicPolicyResponse electronicPolicy(ElectronicPolicyRequest electronicPolicyRequest, String sysSourceCode) throws Exception {
+        return verificationResponse(electronicPolicyRequest, properties.getUrl(), ElectronicPolicyResponse.class, sysSourceCode,
+                RequestType.Z00020);
     }
 
     /**
@@ -192,10 +206,9 @@ public class BoHaiRequestApiComponent {
      * @param statusDocumentsRequest 单证查询
      * @return 响应
      */
-    public StatusDocumentsResponse statusDocuments(StatusDocumentsRequest statusDocumentsRequest) throws Exception {
-        StatusDocumentsResponse response = post(statusDocumentsRequest, properties.getUrl(), StatusDocumentsResponse.class);
-        verificationResponseCode(response.getResponseCode(), response.getResponseMsg());
-        return response;
+    public StatusDocumentsResponse statusDocuments(StatusDocumentsRequest statusDocumentsRequest, String sysSourceCode) throws Exception {
+        return verificationResponse(statusDocumentsRequest, properties.getUrl(), StatusDocumentsResponse.class, sysSourceCode,
+                RequestType.Z00021);
     }
 
     /**

+ 6 - 0
src/main/java/com/ydtech/modules/order/constants/OrderCacheConstant.java

@@ -67,6 +67,12 @@ public class OrderCacheConstant {
      */
     public static final String GR_SPECIAL_AGREEMENT_KEY = "gr:specialAgreement:";
 
+
+    /**
+     * 图片识别 key
+     */
+    public static final String IMAGE_IDENTIFY_KEY = "image:identify:";
+
     /**
      * 国任特别约定 存储时间
      */

+ 8 - 0
src/main/java/com/ydtech/modules/order/controller/BoHaiOrderApiController.java

@@ -10,6 +10,7 @@ import com.ydtech.modules.order.components.InsOrdersComponents;
 import com.ydtech.modules.order.entity.api.bohai.BoHaiEncrypted;
 import com.ydtech.modules.order.entity.api.bohai.request.ManualReviewRequest;
 import com.ydtech.modules.order.entity.api.bohai.request.PaymentCallbackRequest;
+import com.ydtech.modules.order.entity.api.bohai.request.PolicyResultCallbackRequest;
 import com.ydtech.modules.order.entity.api.bohai.response.NonAutomotiveProductsDetailsResponse;
 import com.ydtech.modules.order.entity.api.bohai.response.NonAutomotiveProductsResponse;
 import com.ydtech.modules.order.entity.crawler.vo.CrawlerPolicyPrintVo;
@@ -111,5 +112,12 @@ public class BoHaiOrderApiController {
         return this.boHaiOrderApiService.auditCallback(approvedRequest);
     }
 
+    @PostMapping("/policyResultCallback")
+    @ApiOperation(value = "保单回调")
+    public String policyResultCallback(@RequestBody BoHaiEncrypted s) throws Exception {
+        PolicyResultCallbackRequest policyResultCallbackRequest = SignatureUtils.decryptMessage(s.getBizContent(), PolicyResultCallbackRequest.class, "保单结果回调",
+                properties.getSelfPrivateKey());
+        return this.boHaiOrderApiService.policyResultCallback(policyResultCallbackRequest);
+    }
 
 }

+ 3 - 2
src/main/java/com/ydtech/modules/order/controller/IdentifyController.java

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.IOException;
 import java.util.Map;
 
 @RestController
@@ -27,13 +28,13 @@ public class IdentifyController {
 
     @PostMapping("/idCard")
     @ApiOperation(value = "身份证正反面识别")
-    public HttpResult<Map<String, Object>> idCard(MultipartFile image1, MultipartFile image2) {
+    public HttpResult<Map<String, Object>> idCard(MultipartFile image1, MultipartFile image2) throws IOException {
         return identifyService.idCard(image1, image2);
     }
 
     @PostMapping("/drivingPermit")
     @ApiOperation(value = "行驶证正反面识别")
-    public HttpResult<Map<String, Object>> drivingPermit(MultipartFile image1, MultipartFile image2) {
+    public HttpResult<Map<String, Object>> drivingPermit(MultipartFile image1, MultipartFile image2) throws IOException {
         return identifyService.drivingPermit(image1, image2);
     }
 

+ 3 - 0
src/main/java/com/ydtech/modules/order/dao/InsAreaCompanyMapper.java

@@ -41,6 +41,9 @@ public interface InsAreaCompanyMapper extends BaseMapper<InsAreaCompany> {
     InsAreaCompany queryLatestStatus(@Param("orderNo") String orderNo);
 
 
+    List<InsAreaCompany> getorDerIds();
+
+
 }
 
 

+ 0 - 3
src/main/java/com/ydtech/modules/order/entity/InsAreaCompany.java

@@ -389,9 +389,6 @@ public class InsAreaCompany implements Serializable {
         this.lossRation = quoteRespVo.getLossRation();
         this.jqLossRation = quoteRespVo.getJqLossRation();
         this.syLossRation = quoteRespVo.getSyLossRation();
-
-        this.jqapplyno = quoteRespVo.getJqApplyNo();
-        this.syapplyno = quoteRespVo.getSyApplyNo();
     }
 
     public void setPaymentLink(String paymentLink) {

+ 2 - 2
src/main/java/com/ydtech/modules/order/entity/api/bohai/BoHaiEncrypted.java

@@ -38,10 +38,10 @@ public class BoHaiEncrypted implements Serializable {
     private String sysSourceCode;
 
 
-    public BoHaiEncrypted(String bizContent, BohaiApiConfigurationProperties properties) {
+    public BoHaiEncrypted(String bizContent, BohaiApiConfigurationProperties properties, String sysSourceCode) {
         this.bizContent = bizContent;
         this.insurerCode = properties.getInsurerCode();
-        this.sysSourceCode = properties.getSysSourceCode();
+        this.sysSourceCode = sysSourceCode;
     }
 
 

+ 18 - 0
src/main/java/com/ydtech/modules/order/entity/api/bohai/constants/InsuranceType.java

@@ -0,0 +1,18 @@
+package com.ydtech.modules.order.entity.api.bohai.constants;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@AllArgsConstructor
+@Getter
+public enum InsuranceType {
+
+    IT_0("0", "商业"),
+    IT_1("1", "交强");
+
+    private final String code;
+
+    private final String desc;
+
+}

+ 0 - 4
src/main/java/com/ydtech/modules/order/entity/api/bohai/constants/RequestType.java

@@ -25,11 +25,7 @@ public enum RequestType {
     Z00009("Z00009", "撤销核保"),
     Z00010("Z00010", "获取短信验证码"),
     Z00011("Z00011", "回收短信验证码"),
-    Z00012("Z00012", "客户信息审核"),
-    Z00013("Z00013", "电子签名支付"),
     Z00014("Z00014", "公共影像上传"),
-    Z00015("Z00015", "人工审核"),
-    Z00016("Z00016", "投保单继续支付"),
     Z00017("Z00017", "续保查询"),
     Z00018("Z00018", "车+X产品查询"),
     Z00019("Z00019", "车+X产品详情查询"),

+ 14 - 5
src/main/java/com/ydtech/modules/order/entity/api/bohai/request/BoHaiBaseRequest.java

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
 import com.ydtech.modules.order.entity.config.BoHaiConfigureParameters;
 import lombok.Data;
 import lombok.NoArgsConstructor;
+import org.springframework.util.ObjectUtils;
 
 import java.io.Serializable;
 import java.time.LocalDateTime;
@@ -19,19 +20,27 @@ public class BoHaiBaseRequest implements Serializable {
     @JsonProperty("baseParam")
     private BaseParamDTO baseParam;
 
-    public void setBaseParam(BoHaiConfigureParameters parameters, String requestType) {
-        baseParam = new BaseParamDTO();
+    public void setBaseParam(BoHaiConfigureParameters parameters) {
+        if (ObjectUtils.isEmpty(this.baseParam)) {
+            baseParam = new BaseParamDTO();
+        }
         baseParam.requestNo = UUID.randomUUID().toString().replace("-", "");
         baseParam.requestTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
-        baseParam.requestType = requestType;
         baseParam.ip = "118.81.124.183";
         baseParam.insurerBranchCode = parameters.getInsurerBranchCode();
         baseParam.franchiserInstitutionCode = parameters.getFranchiserInstitutionCode();
         baseParam.franchiserChannel = new BaseParamDTO.FranchiserChannelDTO(parameters);
     }
 
-    public void setBaseParam(BoHaiConfigureParameters parameters, String requestType, String orderNo) {
-        setBaseParam(parameters, requestType);
+    public void setBaseParamRequestType(String requestType) {
+        if (ObjectUtils.isEmpty(this.baseParam)) {
+            baseParam = new BaseParamDTO();
+        }
+        this.baseParam.requestType = requestType;
+    }
+
+    public void setBaseParam(BoHaiConfigureParameters parameters, String orderNo) {
+        setBaseParam(parameters);
         baseParam.orderNo = orderNo;
     }
 

+ 1 - 1
src/main/java/com/ydtech/modules/order/entity/api/bohai/request/ElectronicPolicyRequest.java

@@ -28,7 +28,7 @@ public class ElectronicPolicyRequest extends BoHaiBaseRequest {
     private String policyType;
 
     public ElectronicPolicyRequest(BoHaiConfigureParameters parameters, String id, String jqpolicyno, String sypolicyno) {
-        this.setBaseParam(parameters, RequestType.Z00020.getCode(), id);
+        this.setBaseParam(parameters, id);
         this.policyNo = StringUtils.isNotEmpty(jqpolicyno) ? jqpolicyno : sypolicyno;
         if (StringUtils.isEmpty(jqpolicyno)) {
             this.policyType = "0";

+ 1 - 1
src/main/java/com/ydtech/modules/order/entity/api/bohai/request/GenerateOrderNoRequest.java

@@ -24,7 +24,7 @@ public class GenerateOrderNoRequest extends BoHaiBaseRequest {
     private static final long serialVersionUID = 8713399532011104295L;
 
     public GenerateOrderNoRequest(BoHaiConfigureParameters parameters) {
-        this.setBaseParam(parameters, RequestType.Z00002.getCode());
+        this.setBaseParam(parameters);
     }
 
 }

+ 1 - 1
src/main/java/com/ydtech/modules/order/entity/api/bohai/request/ImageUploadRequest.java

@@ -34,7 +34,7 @@ public class ImageUploadRequest extends BoHaiBaseRequest {
     private String busUniqueId;
 
     public ImageUploadRequest(BoHaiConfigureParameters parameters, String id, String insOrderNo, List<InsTaskImagesBase64> insTaskImagesBase64s) {
-        this.setBaseParam(parameters, RequestType.Z00014.getCode(), id);
+        this.setBaseParam(parameters, id);
         this.setBusUniqueId(insOrderNo);
         this.fileInfos = FileInfosDTO.toFileInfosDTOList(insTaskImagesBase64s);
     }

+ 6 - 1
src/main/java/com/ydtech/modules/order/entity/api/bohai/request/PaymentRequest.java

@@ -23,9 +23,14 @@ public class PaymentRequest extends BoHaiBaseRequest{
     @JsonProperty("busUniqueId")
     private String busUniqueId;
 
+    @JsonProperty("payWay")
+    private String payWay;
+
+
     public PaymentRequest(BoHaiConfigureParameters parameters, String orderNo, String insOrderNo) {
-        this.setBaseParam(parameters, RequestType.Z00013.getCode(), orderNo);
+        this.setBaseParam(parameters, orderNo);
         this.busUniqueId = insOrderNo;
+        this.payWay = "82";
     }
 
 }

+ 36 - 0
src/main/java/com/ydtech/modules/order/entity/api/bohai/request/PolicyResultCallbackRequest.java

@@ -0,0 +1,36 @@
+package com.ydtech.modules.order.entity.api.bohai.request;
+
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@Data
+public class PolicyResultCallbackRequest extends BoHaiBaseRequest {
+
+    private static final long serialVersionUID = -5610907874268772164L;
+
+    @JsonProperty("busUniqueId")
+    private String busUniqueId;
+
+    @JsonProperty("businessStatus")
+    private String businessStatus;
+
+    @JsonProperty("businessApplicationNo")
+    private String businessApplicationNo;
+
+    @JsonProperty("businessPolicyNo")
+    private String businessPolicyNo;
+
+    @JsonProperty("trafficStatus")
+    private String trafficStatus;
+
+    @JsonProperty("trafficApplicationNo")
+    private String trafficApplicationNo;
+
+    @JsonProperty("trafficPolicyNo")
+    private String trafficPolicyNo;
+}

+ 1 - 1
src/main/java/com/ydtech/modules/order/entity/api/bohai/request/QuotationRequest.java

@@ -58,7 +58,7 @@ public class QuotationRequest extends BoHaiBaseRequest {
                             String orderNO,
                             CarInfoVo carInfo,
                             List<BoHaiQuoteAccidentVo> accidentVo) {
-        this.setBaseParam(parameters, RequestType.Z00006.getCode(), orderNO);
+        this.setBaseParam(parameters, orderNO);
         this.argueSolution = "1";
         for (RiskInfoVo riskInfoVo : riskList) {
             if (InsuranceRisk.TRAFFIC.getCode().equals(riskInfoVo.getRiskCode())) {

+ 1 - 1
src/main/java/com/ydtech/modules/order/entity/api/bohai/request/StatusDocumentsRequest.java

@@ -24,7 +24,7 @@ public class StatusDocumentsRequest extends BoHaiBaseRequest {
     private String applicationNo;
 
     public StatusDocumentsRequest(BoHaiConfigureParameters parameters, String id, String applicationNo) {
-        this.setBaseParam(parameters, RequestType.Z00021.getCode(), id);
+        this.setBaseParam(parameters, id);
         this.applicationNo = applicationNo;
     }
 

+ 1 - 1
src/main/java/com/ydtech/modules/order/entity/api/bohai/request/UnderwritingRequest.java

@@ -31,7 +31,7 @@ public class UnderwritingRequest extends BoHaiBaseRequest {
     private TrafficPolicyDTO trafficPolicy;
 
     public UnderwritingRequest(BoHaiConfigureParameters parameters, String orderNo) {
-        this.setBaseParam(parameters, RequestType.Z00007.getCode(), orderNo);
+        this.setBaseParam(parameters, orderNo);
     }
 
     @NoArgsConstructor

+ 1 - 1
src/main/java/com/ydtech/modules/order/entity/api/bohai/request/VehicleConfirmationReqeust.java

@@ -59,7 +59,7 @@ public class VehicleConfirmationReqeust extends BoHaiBaseRequest {
             effectDate = quoteInfoVo.getRiskList().get(0).getStartDate();
         }
 
-        this.setBaseParam(parameters, RequestType.Z00005.getCode(), orderNo);
+        this.setBaseParam(parameters, orderNo);
         // 车辆信息
         CarInfoVo carInfo = quoteInfoVo.getCarInfo();
         this.vehicle = new VehicleDTO(carInfo, vehicleModelsDTO, effectDate);

+ 1 - 1
src/main/java/com/ydtech/modules/order/entity/api/bohai/request/VehicleTypeQueryRequest.java

@@ -51,7 +51,7 @@ public class VehicleTypeQueryRequest extends BoHaiBaseRequest {
     private String newVehicleFlag;
 
     public VehicleTypeQueryRequest(BoHaiConfigureParameters parameters, String vehicleBrandModelKey, String orderNo) {
-        this.setBaseParam(parameters, RequestType.Z00004.getCode(), orderNo);
+        this.setBaseParam(parameters, orderNo);
         this.vehicleBrandModelKey = vehicleBrandModelKey;
     }
 

+ 3 - 0
src/main/java/com/ydtech/modules/order/entity/api/bohai/response/ElectronicPolicyResponse.java

@@ -23,6 +23,9 @@ public class ElectronicPolicyResponse extends BoHaiBaseResponse {
         @JsonProperty("trafficEPolicyUrl")
         private String trafficEPolicyUrl;
 
+        @JsonProperty("trafficEFlagUrl")
+        private String trafficEFlagUrl;
+
         @JsonProperty("businessEPolicyUrl")
         private String businessEPolicyUrl;
 

+ 12 - 10
src/main/java/com/ydtech/modules/order/entity/api/bohai/response/PaymentResponse.java

@@ -6,8 +6,6 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
 
-import java.io.Serializable;
-
 /**
  * @description: 支付响应
  * @author: wenks
@@ -26,17 +24,21 @@ public class PaymentResponse extends BoHaiBaseResponse {
 
     @NoArgsConstructor
     @Data
-    public static class DataDTO implements Serializable {
+    public static class DataDTO {
+
+        @JsonProperty("payNo")
+        private String payNo;
 
-        private static final long serialVersionUID = 3700311849033773101L;
+        @JsonProperty("checkCode")
+        private String checkCode;
 
-        @JsonProperty("proposalNo")
-        private String proposalNo;
+        @JsonProperty("amount")
+        private String amount;
 
-        @JsonProperty("qrCodeUrl")
-        private String qrCodeUrl;
+        @JsonProperty("payUrl")
+        private String payUrl;
 
-        @JsonProperty("signQRCodeDateValid")
-        private String signQRCodeDateValid;
+        @JsonProperty("paymentEndDate")
+        private String paymentEndDate;
     }
 }

+ 2 - 2
src/main/java/com/ydtech/modules/order/entity/crawler/vo/CrawlerPolicyPrintVo.java

@@ -23,10 +23,10 @@ public class CrawlerPolicyPrintVo implements Serializable {
     @ApiModelProperty("交强险保单地址")
     private String jqxPolicyUrl;
 
-    @ApiModelProperty("交强险标志地址")
+    @ApiModelProperty("商业险保单地址")
     private String syxPolicyUrl;
 
-    @ApiModelProperty("商业险保单地址")
+    @ApiModelProperty("交强险标志地址")
     private String jqxFlagUrl;
 
     @ApiModelProperty("驾意险列表")

+ 13 - 2
src/main/java/com/ydtech/modules/order/service/BoHaiOrderApiService.java

@@ -4,6 +4,7 @@ import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.ins.model.vo.QuoteRespVo;
 import com.ydtech.modules.order.entity.api.bohai.request.ManualReviewRequest;
 import com.ydtech.modules.order.entity.api.bohai.request.PaymentCallbackRequest;
+import com.ydtech.modules.order.entity.api.bohai.request.PolicyResultCallbackRequest;
 import com.ydtech.modules.order.entity.api.bohai.response.NonAutomotiveProductsDetailsResponse;
 import com.ydtech.modules.order.entity.api.bohai.response.NonAutomotiveProductsResponse;
 import com.ydtech.modules.order.entity.crawler.vo.CrawlerPolicyPrintVo;
@@ -80,14 +81,24 @@ public interface BoHaiOrderApiService {
     HttpResult<Object> auditStatusQuery(String subOrderNo) throws Exception;
 
     /**
-     * @param coverageRequest
+     * 支付回调
+     * @param coverageRequest 支付回调参数
      * @return
      */
     String underwritingCallback(PaymentCallbackRequest coverageRequest) throws Exception;
 
     /**
-     * @param approvedRequest
+     * 核保回调
+     * @param approvedRequest 支付回调参数
      * @return
      */
     String auditCallback(ManualReviewRequest approvedRequest) throws Exception;
+
+    /**
+     * 保单结果
+     * @param policyResultCallbackRequest 保单结果回调参数
+     * @return
+     */
+    String policyResultCallback(PolicyResultCallbackRequest policyResultCallbackRequest)  throws Exception;
+
 }

+ 3 - 2
src/main/java/com/ydtech/modules/order/service/IdentifyService.java

@@ -4,6 +4,7 @@ import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.order.entity.BusinessLicense;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.IOException;
 import java.util.Map;
 
 public interface IdentifyService {
@@ -15,7 +16,7 @@ public interface IdentifyService {
      * @param image2 反面
      * @return
      */
-    HttpResult<Map<String, Object>> idCard(MultipartFile image1, MultipartFile image2);
+    HttpResult<Map<String, Object>> idCard(MultipartFile image1, MultipartFile image2) throws IOException;
 
 
     /**
@@ -25,7 +26,7 @@ public interface IdentifyService {
      * @param image2 反面
      * @return
      */
-    HttpResult<Map<String, Object>> drivingPermit(MultipartFile image1, MultipartFile image2);
+    HttpResult<Map<String, Object>> drivingPermit(MultipartFile image1, MultipartFile image2) throws IOException;
 
     /**
      * 营业执照识别

+ 4 - 0
src/main/java/com/ydtech/modules/order/service/InsAreaCompanyService.java

@@ -58,4 +58,8 @@ public interface InsAreaCompanyService extends IService<InsAreaCompany> {
      * @param orderNo 主订单号
      */
     InsAreaCompany queryLatestStatus(String orderNo);
+
+    List<InsAreaCompany> getorDerIds();
+
+
 }

+ 72 - 34
src/main/java/com/ydtech/modules/order/service/impl/BoHaiOrderApiServiceImpl.java

@@ -71,7 +71,8 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
         BoHaiConfigureParameters parameters = configureParametersComponents.toEntity(BoHaiConfigureParameters.class,
                 ptlAgreementAttribution);
         NonAutomotiveProductsRequest nonAutomotiveProductsRequest = new NonAutomotiveProductsRequest(parameters, productQueryVo);
-        NonAutomotiveProductsResponse response = boHaiRequestApiComponent.products(nonAutomotiveProductsRequest);
+        NonAutomotiveProductsResponse response = boHaiRequestApiComponent.products(nonAutomotiveProductsRequest,
+                parameters.getSysSourceCode());
         List<NonAutomotiveProductsResponse.DataDTO.ProductsDTO> products = response.getData().getProducts();
         return HttpResult.ok(products);
     }
@@ -85,7 +86,8 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
                 ptlAgreementAttribution);
         NonAutomotiveProductsDetailsRequest nonAutomotiveProductsDetailsRequest = new NonAutomotiveProductsDetailsRequest(parameters,
                 productDetailsQueryVo);
-        NonAutomotiveProductsDetailsResponse response = boHaiRequestApiComponent.productsDetails(nonAutomotiveProductsDetailsRequest);
+        NonAutomotiveProductsDetailsResponse response = boHaiRequestApiComponent.productsDetails(nonAutomotiveProductsDetailsRequest,
+                parameters.getSysSourceCode());
         List<NonAutomotiveProductsDetailsResponse.DataDTO.CoveragesDTO> coverages = response.getData().getCoverages();
         return HttpResult.ok(coverages);
     }
@@ -102,13 +104,15 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
         GenerateOrderNoRequest generateOrderNoRequest = new GenerateOrderNoRequest(parameters);
 
         // 1 生成生成订单
-        GenerateOrderNoResponse generateOrderNoResponse = boHaiRequestApiComponent.generateOrderNo(generateOrderNoRequest);
+        GenerateOrderNoResponse generateOrderNoResponse = boHaiRequestApiComponent.generateOrderNo(generateOrderNoRequest,
+                parameters.getSysSourceCode());
         String orderNo = generateOrderNoResponse.getData().getOrderNo();
 
         // 2 车型查询接口
         CarInfoVo carInfo = quoteInfoVo.getCarInfo();
         VehicleTypeQueryRequest vehicleTypeQueryRequest = new VehicleTypeQueryRequest(parameters, carInfo.getModelcname(), orderNo);
-        VehicleTypeQueryResponse vehicleTypeQueryResponse = boHaiRequestApiComponent.vehicleTypeQuery(vehicleTypeQueryRequest);
+        VehicleTypeQueryResponse vehicleTypeQueryResponse = boHaiRequestApiComponent.vehicleTypeQuery(vehicleTypeQueryRequest,
+                parameters.getSysSourceCode());
         List<VehicleTypeQueryResponse.DataDTO.VehicleModelsDTO> vehicleModels = vehicleTypeQueryResponse.getData().getVehicleModels();
         VehicleTypeQueryResponse.DataDTO.VehicleModelsDTO vehicleModelsDTO =
                 new CarModelsFilterUtils<VehicleTypeQueryResponse.DataDTO.VehicleModelsDTO>().to(vehicleModels, quoteInfoVo.getCarInfo());
@@ -126,14 +130,15 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
                 policyHolderInfo.getIdentifyNumber());
         VehicleConfirmationReqeust vehicleConfirmationReqeust = new VehicleConfirmationReqeust(parameters, quoteInfoVo, vehicleModelsDTO,
                 orderNo, ownerInfoArea, insuredPersonArea, policyHolderArea);
-        VehicleConfirmationResponse vehicleConfirmationResponse = boHaiRequestApiComponent.vehicleConfirmation(vehicleConfirmationReqeust);
+        VehicleConfirmationResponse vehicleConfirmationResponse = boHaiRequestApiComponent.vehicleConfirmation(vehicleConfirmationReqeust
+                , parameters.getSysSourceCode());
         // 车辆实际价值
         String currentValue = vehicleConfirmationResponse.getData().getVehicleModels().get(0).getCurrentValue();
 
         // 4. 报价接口
         QuotationRequest quotationRequest = new QuotationRequest(parameters, quoteInfoVo.getRiskList(), quoteInfoVo.getKindList(),
                 currentValue, orderNo, carInfo, quoteVo.getAccidentalDrivingVo());
-        QuotationResponse response = boHaiRequestApiComponent.quotation(quotationRequest);
+        QuotationResponse response = boHaiRequestApiComponent.quotation(quotationRequest, parameters.getSysSourceCode());
         return getQuoteRespVo(response, quoteInfoVo, vehicleModelsDTO, ptlAgreementAttribution, orderNo);
     }
 
@@ -154,7 +159,7 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
 
         ImageUploadRequest imageUploadRequest = new ImageUploadRequest(parameters, insAreaCompany.getId(), insAreaCompany.getInsOrderNo()
                 , insTaskImagesBase64s);
-        ImageUploadResponse response = boHaiRequestApiComponent.imageUpload(imageUploadRequest);
+        ImageUploadResponse response = boHaiRequestApiComponent.imageUpload(imageUploadRequest, parameters.getSysSourceCode());
         if (ResponseCode.R_Z00001.getCode().equals(response.getResponseCode())) {
             return HttpResult.ok("上传成功");
         }
@@ -173,15 +178,26 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
 
         // 核保请求
         UnderwritingRequest underwritingRequest = new UnderwritingRequest(parameters, insAreaCompany.getId());
-        UnderwritingResponse underwritingResponse = boHaiRequestApiComponent.underwriting(underwritingRequest);
+        UnderwritingResponse underwritingResponse = boHaiRequestApiComponent.underwriting(underwritingRequest,
+                parameters.getSysSourceCode());
         int i = underwritingResponse.getData().verificationUnderwriting();
+        // 交强
+        UnderwritingResponse.DataDTO.TrafficPolicyDTO trafficPolicy = underwritingResponse.getData().getTrafficPolicy();
+        if (!ObjectUtils.isEmpty(trafficPolicy)) {
+            insAreaCompany.setJqapplyno(trafficPolicy.getApplicationNo());
+        }
+        // 商业
+        UnderwritingResponse.DataDTO.BusinessPolicyDTO businessPolicy = underwritingResponse.getData().getBusinessPolicy();
+        if (!ObjectUtils.isEmpty(businessPolicy)) {
+            insAreaCompany.setSyapplyno(businessPolicy.getApplicationNo());
+        }
 
         if (i == 1) {
             insAreaCompany.setOrderstatus(InsOrderStatusEnum.WAIT_PAY.getCode());
             // 支付请求
             PaymentRequest paymentRequest = new PaymentRequest(parameters, insAreaCompany.getId(), insAreaCompany.getInsOrderNo());
-            PaymentResponse paymentResponse = boHaiRequestApiComponent.payment(paymentRequest);
-            String payUrl = paymentResponse.getData().getQrCodeUrl();
+            PaymentResponse paymentResponse = boHaiRequestApiComponent.payment(paymentRequest, parameters.getSysSourceCode());
+            String payUrl = paymentResponse.getData().getPayUrl();
             insAreaCompany.setPaymentLink(payUrl);
             insAreaCompanyService.updateCompanyAndOrders(insAreaCompany);
             return HttpResult.ok("核保通过");
@@ -190,6 +206,7 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
         } else {
             insAreaCompany.setOrderstatus(InsOrderStatusEnum.TO_BACK.getCode());
         }
+
         String trafficResultMsg = underwritingResponse.getData().getTrafficResultMsg();
         String businessResultMsg = underwritingResponse.getData().getBusinessResultMsg();
         insAreaCompanyService.updateCompanyAndOrders(insAreaCompany);
@@ -200,6 +217,7 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
     public HttpResult<CrawlerPolicyPrintVo> getPolicyPrint(String subOrderNo) throws Exception {
         InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(subOrderNo);
         InsOrders insOrders = insOrdersService.existOrder(insAreaCompany.getOrderno());
+        CustomerInfoVo customerInfoVo = insOrders.getApplyinfo().toJavaObject(CustomerInfoVo.class);
 
         // 账号信息
         PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
@@ -209,20 +227,21 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
 
         ElectronicPolicyRequest electronicPolicyRequest = new ElectronicPolicyRequest(parameters, insAreaCompany.getId(),
                 insAreaCompany.getJqpolicyno(), insAreaCompany.getSypolicyno());
-        ElectronicPolicyResponse response = boHaiRequestApiComponent.electronicPolicy(electronicPolicyRequest);
+        ElectronicPolicyResponse response = boHaiRequestApiComponent.electronicPolicy(electronicPolicyRequest,
+                parameters.getSysSourceCode());
 
         ElectronicPolicyResponse.DataDTO data = response.getData();
         CrawlerPolicyPrintVo crawlerPolicyPrintVo = new CrawlerPolicyPrintVo();
         String licenseno = insOrders.getLicenseno();
-
         if (StringUtils.isNotEmpty(data.getTrafficEPolicyUrl())) {
+            crawlerPolicyPrintVo.setJqxPolicyUrl(fileComponents.gainCarInsPolicy(data.getTrafficEPolicyUrl(),
+                    licenseno + "-" + insAreaCompany.getJqpolicyno() + "-交强险保单.pdf", licenseno, customerInfoVo.getIdentifyNumber()));
             crawlerPolicyPrintVo.setJqxFlagUrl(fileComponents.gainCarInsPolicy(data.getTrafficEPolicyUrl(),
-                    licenseno + insAreaCompany.getJqpolicyno() + "-交强险标志.pdf", licenseno));
+                    licenseno + "-" + insAreaCompany.getJqpolicyno() + "-交强险标志.pdf", licenseno, customerInfoVo.getIdentifyNumber()));
         }
-
         if (StringUtils.isNotEmpty(data.getBusinessEPolicyUrl())) {
             crawlerPolicyPrintVo.setSyxPolicyUrl(fileComponents.gainCarInsPolicy(data.getBusinessEPolicyUrl(),
-                    licenseno + insAreaCompany.getSypolicyno() + "-交强险保单.pdf", licenseno));
+                    licenseno + "-" + insAreaCompany.getSypolicyno() + "-商业险保单.pdf", licenseno, customerInfoVo.getIdentifyNumber()));
         }
 
         return HttpResult.ok(crawlerPolicyPrintVo);
@@ -234,7 +253,16 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
         List<StatusDocumentsResponse.DataDTO.DocumentListDTO> documentList = getDocumentListDTO(insAreaCompany);
         List<StatusDocumentsResponse.DataDTO.DocumentListDTO> documentListDTOS =
                 documentList.stream().filter(x -> ResultCode.RC_B5.getCode().equals(x.getStatus())).collect(Collectors.toList());
+
         if (documentListDTOS.size() == documentList.size()) {
+            for (StatusDocumentsResponse.DataDTO.DocumentListDTO documentListDTO : documentListDTOS) {
+                if (InsuranceType.IT_0.getCode().equals(documentListDTO.getInsuranceType())) {
+                    insAreaCompany.setSypolicyno(documentListDTO.getPolicyNo());
+                } else if (InsuranceType.IT_1.getCode().equals(documentListDTO.getInsuranceType())) {
+                    insAreaCompany.setJqpolicyno(documentListDTO.getPolicyNo());
+                }
+            }
+
             insAreaCompany.setOrderstatus(InsOrderStatusEnum.ACCEPT_INSURANCE.getCode());
             insAreaCompanyService.updateCompanyAndOrders(insAreaCompany);
             return HttpResult.ok("承保成功");
@@ -303,6 +331,24 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
         return boHaiRequestApiComponent.encryptionCallbackResponse(responseCode, requestNo);
     }
 
+    @Override
+    public String policyResultCallback(PolicyResultCallbackRequest policyResultCallbackRequest) throws Exception {
+        String requestNo = policyResultCallbackRequest.getBaseParam().getRequestNo();
+        ResponseCode responseCode;
+        try {
+            String busUniqueId = policyResultCallbackRequest.getBusUniqueId();
+            InsAreaCompany insAreaCompany = insAreaCompanyService.getByInsOrderNo(busUniqueId);
+            insAreaCompany.setJqapplyno(policyResultCallbackRequest.getTrafficApplicationNo());
+            insAreaCompany.setJqpolicyno(policyResultCallbackRequest.getTrafficPolicyNo());
+            insAreaCompany.setSyapplyno(policyResultCallbackRequest.getBusinessApplicationNo());
+            insAreaCompany.setSypolicyno(policyResultCallbackRequest.getBusinessPolicyNo());
+            responseCode = ResponseCode.R_Z00001;
+        } catch (Exception e) {
+            responseCode = ResponseCode.R_Z00002;
+        }
+        return boHaiRequestApiComponent.encryptionCallbackResponse(responseCode, requestNo);
+    }
+
     private String getQrCodeUrl(InsAreaCompany insAreaCompany) throws Exception {
         // 账号信息
         PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
@@ -310,8 +356,8 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
         BoHaiConfigureParameters parameters = configureParametersComponents.toEntity(BoHaiConfigureParameters.class,
                 ptlAgreementAttribution);
         PaymentRequest paymentRequest = new PaymentRequest(parameters, insAreaCompany.getId(), insAreaCompany.getInsOrderNo());
-        PaymentResponse paymentResponse = boHaiRequestApiComponent.payment(paymentRequest);
-        return paymentResponse.getData().getQrCodeUrl();
+        PaymentResponse paymentResponse = boHaiRequestApiComponent.payment(paymentRequest, parameters.getSysSourceCode());
+        return paymentResponse.getData().getPayUrl();
     }
 
 
@@ -322,33 +368,30 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
         BoHaiConfigureParameters parameters = configureParametersComponents.toEntity(BoHaiConfigureParameters.class,
                 ptlAgreementAttribution);
 
-        String applyno = !StringUtils.isEmpty(insAreaCompany.getJqapplyno()) ? insAreaCompany.getJqapplyno() : insAreaCompany.getSyapplyno();
+        String applyno = !StringUtils.isEmpty(insAreaCompany.getJqapplyno()) ? insAreaCompany.getJqapplyno() :
+                insAreaCompany.getSyapplyno();
         StatusDocumentsRequest statusDocumentsRequest = new StatusDocumentsRequest(parameters, insAreaCompany.getId(), applyno);
-        StatusDocumentsResponse response = boHaiRequestApiComponent.statusDocuments(statusDocumentsRequest);
+        StatusDocumentsResponse response = boHaiRequestApiComponent.statusDocuments(statusDocumentsRequest, parameters.getSysSourceCode());
         return response.getData().getDocumentList();
     }
 
     public HttpResult<QuoteRespVo> getQuoteRespVo(QuotationResponse response,
-                                      BaseQuoteInfoVo yaQuoteInfoVo,
-                                      VehicleTypeQueryResponse.DataDTO.VehicleModelsDTO vehicleModelsDTO,
-                                      PtlAgreementAttribution ptlAgreementAttribution,
-                                      String orderNo
+                                                  BaseQuoteInfoVo yaQuoteInfoVo,
+                                                  VehicleTypeQueryResponse.DataDTO.VehicleModelsDTO vehicleModelsDTO,
+                                                  PtlAgreementAttribution ptlAgreementAttribution,
+                                                  String orderNo
     ) {
 
         double sumPayTax = 0;
         double jqPremium = 0;
         double syPremium = 0;
         double jyPremium = 0;
-        String jqPolicyNo = null;
-        String syPolicyNo = null;
-
         QuoteRespVo quoteRespVo = new QuoteRespVo();
         // 交强险
         QuotationResponse.DataDTO.TrafficPolicyDTO trafficPolicy = response.getData().getTrafficPolicy();
         if (!ObjectUtils.isEmpty(trafficPolicy)) {
             sumPayTax = Double.parseDouble(trafficPolicy.getVehicleTax().getTotalAmount());
             jqPremium = Double.parseDouble(trafficPolicy.getPremium());
-            jqPolicyNo = trafficPolicy.getPolicyNo();
             quoteRespVo.setJqApplyNo(trafficPolicy.getApplicationNo());
         }
         // 交强
@@ -361,7 +404,6 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
 
         if (!ObjectUtils.isEmpty(businessPolicy)) {
             syPremium = Double.parseDouble(businessPolicy.getPremium());
-            syPolicyNo = businessPolicy.getPolicyNo();
             quoteRespVo.setSyApplyNo(businessPolicy.getApplicationNo());
             // 商业
             quoteRespVo.setStartDateSy(businessPolicy.getStartDate());
@@ -413,19 +455,15 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
         quoteRespVo.setTotalAdjustRate(0);
         quoteRespVo.setOrderno(yaQuoteInfoVo.getOrderNo()); //订单号
         quoteRespVo.setCoreModels(vehicleModelsDTO.toCoreModelsVo());
-        return responseOrder(response, quoteRespVo, ptlAgreementAttribution, orderNo, jqPolicyNo, syPolicyNo);
+        return responseOrder(response, quoteRespVo, ptlAgreementAttribution, orderNo);
     }
 
     public HttpResult<QuoteRespVo> responseOrder(QuotationResponse response,
                                                  QuoteRespVo quoteRespVo,
                                                  PtlAgreementAttribution ptlAgreementAttribution,
-                                                 String orderId,
-                                                 String jqPolicyNo,
-                                                 String syPolicyNo) {
+                                                 String orderId) {
         // 保存订单信息
         InsAreaCompany insAreaCompany = new InsAreaCompany(quoteRespVo, ptlAgreementAttribution);
-        insAreaCompany.setJqpolicyno(jqPolicyNo);
-        insAreaCompany.setSypolicyno(syPolicyNo);
 
         // 渤海业务id
         String busUniqueId = response.getData().getBusUniqueId();

+ 79 - 14
src/main/java/com/ydtech/modules/order/service/impl/IdentifyServiceImpl.java

@@ -8,17 +8,27 @@ import com.ydtech.modules.order.entity.BusinessLicense;
 import com.ydtech.modules.order.service.IdentifyService;
 import com.ydtech.modules.protocol.utils.AssertionUtils;
 import com.ydtech.utils.ImageCompressionUtils;
+import com.ydtech.utils.ObjectUtil;
+import com.ydtech.utils.StringUtils;
 import com.ydtech.utils.baidu.BusinessLicenseRecognition;
 import com.ydtech.utils.baidu.Idcard;
 import com.ydtech.utils.baidu.MultiObjectDetect;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
 import java.io.IOException;
 import java.util.Base64;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+import static com.ydtech.modules.order.constants.OrderCacheConstant.IMAGE_IDENTIFY_KEY;
 
 /**
  * @author wenks
@@ -29,16 +39,45 @@ import java.util.Map;
 @Service
 public class IdentifyServiceImpl implements IdentifyService {
 
+
+    @Resource
+    private RedisTemplate<String, Object> redisTemplate;
+
     @Override
-    public HttpResult<Map<String, Object>> idCard(MultipartFile image1, MultipartFile image2) {
+    public HttpResult<Map<String, Object>> idCard(MultipartFile image1, MultipartFile image2) throws IOException {
         Map<String, Object> map = new HashMap<>();
         CustomerInfoVO customerInfoVO = new CustomerInfoVO();
+        if (image1 != null){
+            String s1MD5 = DigestUtils.md5Hex(image1.getBytes());
+            String s1 = byteToBase64(image1);
+            String s1Key = IMAGE_IDENTIFY_KEY + "idCard:" + "front:" + s1MD5;
+            if (StringUtils.isNotBlank(s1) && !ObjectUtil.isAllFieldNull(redisTemplate.opsForValue().get(s1Key))) {
+                //走缓存
+                BeanUtils.copyProperties(Objects.requireNonNull(redisTemplate.opsForValue().get(s1Key)), customerInfoVO);
+            } else {
+                //识别身份证正面
+                Idcard.getIdCardFront(s1, customerInfoVO);
+                AssertionUtils.isEmpty(customerInfoVO, "身份证识别失败");
+                //设置缓存
+                redisTemplate.opsForValue().set(s1Key, customerInfoVO, 1, TimeUnit.DAYS);
+            }
+        }
 
-        String s1 = byteToBase64(image1);
-        Idcard.getIdCardFront(s1, customerInfoVO);
-
-        String s2 = byteToBase64(image2);
-        Idcard.getIdCardBack(s2, customerInfoVO);
+        if (image2 != null) {
+            String s2MD5 = DigestUtils.md5Hex(image2.getBytes());
+            String s2 = byteToBase64(image2);
+            String s2Key = IMAGE_IDENTIFY_KEY + "idCard:" + "back:" + s2MD5;
+            if (StringUtils.isNotBlank(s2) && !ObjectUtil.isAllFieldNull(redisTemplate.opsForValue().get(s2Key))) {
+                //走缓存
+                BeanUtils.copyProperties(Objects.requireNonNull(redisTemplate.opsForValue().get(s2Key)), customerInfoVO);
+            } else {
+                //识别身份证背面
+                Idcard.getIdCardBack(s2, customerInfoVO);
+                AssertionUtils.isEmpty(customerInfoVO, "身份证识别失败");
+                //设置缓存
+                redisTemplate.opsForValue().set(s2Key, customerInfoVO, 1, TimeUnit.DAYS);
+            }
+        }
 
         AssertionUtils.isEmpty(customerInfoVO, "身份证识别失败");
         map.put("customerInfo", customerInfoVO);
@@ -46,17 +85,41 @@ public class IdentifyServiceImpl implements IdentifyService {
     }
 
     @Override
-    public HttpResult<Map<String, Object>> drivingPermit(MultipartFile image1, MultipartFile image2) {
+    public HttpResult<Map<String, Object>> drivingPermit(MultipartFile image1, MultipartFile image2) throws IOException {
         Map<String, Object> map = new HashMap<>();
         CardUserInfo cardUserInfo = new CardUserInfo();
+        if (image1 != null) {
+            String s1MD5 = DigestUtils.md5Hex(image1.getBytes());
+            String s1 = byteToBase64(image1);
+            String s1Key = IMAGE_IDENTIFY_KEY + "drivingPermit:" + "front:" + s1MD5;
+            if (StringUtils.isNotBlank(s1) && !ObjectUtil.isAllFieldNull(redisTemplate.opsForValue().get(s1Key))) {
+                //走缓存
+                BeanUtils.copyProperties(Objects.requireNonNull(redisTemplate.opsForValue().get(s1Key)), cardUserInfo);
+            } else {
+                //行驶证正面识别
+                MultiObjectDetect.drivingPermitFront(s1, cardUserInfo);
+                AssertionUtils.isEmpty(cardUserInfo, "行驶证正面识别失败");
+                //设置缓存
+                redisTemplate.opsForValue().set(s1Key, cardUserInfo, 1, TimeUnit.DAYS);
+            }
+        }
 
-        String s1 = byteToBase64(image1);
-        MultiObjectDetect.drivingPermitFront(s1, cardUserInfo);
-
-        String s2 = byteToBase64(image2);
-        MultiObjectDetect.drivingPermitBack(s2, cardUserInfo);
-
-        AssertionUtils.isEmpty(cardUserInfo, "身份证识别失败");
+        if (image2 != null) {
+            String s2MD5 = DigestUtils.md5Hex(image2.getBytes());
+            String s2 = byteToBase64(image2);
+            String s2Key = IMAGE_IDENTIFY_KEY + "drivingPermit:" + "back:" + s2MD5;
+            if (StringUtils.isNotBlank(s2) && !ObjectUtil.isAllFieldNull(redisTemplate.opsForValue().get(s2Key))) {
+                //走缓存
+                BeanUtils.copyProperties(Objects.requireNonNull(redisTemplate.opsForValue().get(s2Key)), cardUserInfo);
+            } else {
+                //行驶证反面识别
+                MultiObjectDetect.drivingPermitBack(s2, cardUserInfo);
+                AssertionUtils.isEmpty(cardUserInfo, "行驶证正面识别失败");
+                //设置缓存
+                redisTemplate.opsForValue().set(s2Key, cardUserInfo, 1, TimeUnit.DAYS);
+            }
+        }
+        AssertionUtils.isEmpty(cardUserInfo, "行驶证正面识别失败");
         map.put("carInfo", cardUserInfo);
         return HttpResult.ok("success", map);
     }
@@ -85,4 +148,6 @@ public class IdentifyServiceImpl implements IdentifyService {
     }
 
 
+
+
 }

+ 5 - 0
src/main/java/com/ydtech/modules/order/service/impl/InsAreaCompanyServiceImpl.java

@@ -128,6 +128,11 @@ public class InsAreaCompanyServiceImpl extends ServiceImpl<InsAreaCompanyMapper,
         return baseMapper.queryLatestStatus(orderNo);
     }
 
+    @Override
+    public List<InsAreaCompany> getorDerIds() {
+        return  baseMapper.getorDerIds();
+    }
+
 }
 
 

+ 12 - 1
src/main/java/com/ydtech/modules/order/service/impl/InsOrdersServiceImpl.java

@@ -2,10 +2,12 @@ package com.ydtech.modules.order.service.impl;
 
 import cn.dev33.satoken.session.SaSession;
 import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.collection.CollUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ydtech.constants.InsuranceEnum;
@@ -217,7 +219,6 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
 
     @Override
     public BasePageResult<InsOrders> queryPageOrder(OrderQueryVo orderQueryVo) {
-
         // 领导标志
         boolean isTeamLeader = false;
         //是否出单员标志
@@ -283,6 +284,16 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
             }
         }
 
+        //查出报价状态为 3
+        List<InsAreaCompany>   insAreaCompanies = insAreaCompanyService.getorDerIds();
+//      新的费用订单表
+        if(insAreaCompanies.size()>0){
+            List<String> collect = insAreaCompanies.stream().map(insAreaCompany -> insAreaCompany.getOrderno()).collect(Collectors.toList());
+            if (!collect.isEmpty()) {
+                wrapper.in(InsOrders::getOrderno, collect);
+            }
+        }
+
         Page<InsOrders> insOrdersPage = page(page, wrapper);
 
         return new BasePageResult<>(orderQueryVo.getPageNum(), page.getSize(), insOrdersPage.getTotal(), page.getPages(),

+ 3 - 0
src/main/java/com/ydtech/modules/protocol/service/impl/PtlAgreementServiceImpl.java

@@ -157,6 +157,7 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         ptlAgreementHistory.setEndDate(ptlAgreement.getEndDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
         ptlAgreementHistory.setAgreementId(ptlAgreement.getId());
         ptlAgreementHistory.setId(IdGenerate.nextId());
+        ptlAgreementHistory.setOperatorType("add");
         ptlAgreementHistoryService.saveAgreementHistory(ptlAgreementHistory);
         PtlAgreementAttributionHistory ptlAgreementAttributionHistory = new PtlAgreementAttributionHistory(batchNo,ptlAgreement.getId(),esmInsCompany.getId(),esmInsCompany.getName(),agreement.getAttribution());
         ptlAgreementAttributionHistory.setId(IdGenerate.nextId());
@@ -395,6 +396,7 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         ptlAgreementHistory.setEndDate(byAgreementId.getData().getAgreement().getEndDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
         ptlAgreementHistory.setAgreementId(ptlAgreementHistory.getId());
         ptlAgreementHistory.setId(IdGenerate.nextId());
+        ptlAgreementHistory.setOperatorType("delete");
         ptlAgreementHistoryService.saveAgreementHistory(ptlAgreementHistory);
         PtlAgreementAttributionHistory ptlAgreementAttributionHistory = new PtlAgreementAttributionHistory(batchNo,agreementId,
                 byAgreementId.getData().getAgreement().getInsuranceCompanyId(),
@@ -437,6 +439,7 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         ptlAgreementHistory.setEndDate(ptlAgreement.getEndDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
         ptlAgreementHistory.setAgreementId(ptlAgreement.getId());
         ptlAgreementHistory.setId(IdGenerate.nextId());
+        ptlAgreementHistory.setOperatorType("update");
         ptlAgreementHistoryService.saveAgreementHistory(ptlAgreementHistory);
         PtlAgreementAttributionHistory ptlAgreementAttributionHistory = new PtlAgreementAttributionHistory(batchNo,ptlAgreement.getId(),esmInsCompany.getId(),esmInsCompany.getName(),agreement.getAttribution());
         ptlAgreementAttributionHistory.setId(IdGenerate.nextId());

+ 81 - 0
src/main/java/com/ydtech/modules/protocols/controller/PtlNewAgreementHistoryController.java

@@ -0,0 +1,81 @@
+package com.ydtech.modules.protocols.controller;
+
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.core.page.PageResult;
+import com.ydtech.modules.base.controller.BaseController;
+import com.ydtech.modules.protocol.service.PtlAgreementProductCostsHistoryService;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsNewHistory;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesAttr;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesNewHistory;
+import com.ydtech.modules.protocols.entity.vo.AgreementProductQueryVo;
+import com.ydtech.modules.protocols.entity.vo.AgreementUndwrtRulesQueryVo;
+import com.ydtech.modules.protocols.service.PtlAgreementProductCostsNewHistoryService;
+import com.ydtech.modules.protocols.service.PtlAgreementUndwrtRulesAttrService;
+import com.ydtech.modules.protocols.service.PtlAgreementUndwrtRulesNewHistoryService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @author
+ * @description
+ * @createDate
+ */
+@Api(tags = "协议历史查询")
+@RequestMapping("/plt/new/agreementhistory")
+@RestController
+public class PtlNewAgreementHistoryController extends BaseController {
+
+    @Value("${agreement.shutdown}")
+    private boolean shutdown;
+
+    @Autowired
+    private PtlAgreementProductCostsHistoryService ptlAgreementProductCostsHistoryService;
+
+    @Autowired
+    private PtlAgreementUndwrtRulesNewHistoryService ptlAgreementUndwrtRulesNewHistoryService;
+
+    @Autowired
+    private PtlAgreementProductCostsNewHistoryService ptlAgreementProductCostsNewHistoryService;
+    @Autowired
+    private PtlAgreementUndwrtRulesAttrService ptlAgreementUndwrtRulesAttrService;
+
+
+//
+//    @PostMapping("costsHistoryPage")
+//    @ApiOperation("分页查询协议历史记录")
+//    public HttpResult<PageResult> costsHistoryPage(@RequestBody PtlAgreementProductQueryVo ptlAgreementProductCostsHistory) {
+//        Page page = buildPageRequest(ptlAgreementProductCostsHistory.getPageDto());
+//        Page<PtlAgreementProductCostsHistory> ptlAgreementProductCostsHistoryPage = ptlAgreementProductCostsHistoryService.pageHistory(page,ptlAgreementProductCostsHistory);
+//        return HttpResult.ok(buildPageResponse(ptlAgreementProductCostsHistoryPage));
+//    }
+
+    @PostMapping("agreementHistoryPage")
+    @ApiOperation("分页查询产品费用历史记录")
+    public HttpResult<PageResult> agreementHistoryPage(@RequestBody AgreementProductQueryVo agreementProductQueryVo) {
+        Page page = buildPageRequest(agreementProductQueryVo.getPageDto());
+        List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = ptlAgreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
+        Page<PtlAgreementProductCostsNewHistory> ptlAgreementPage = ptlAgreementProductCostsNewHistoryService.pageHistory(page, agreementProductQueryVo.getAgreementId(),undwrtRulesAttrList);
+        return HttpResult.ok(buildPageResponse(ptlAgreementPage));
+    }
+
+    @PostMapping("rulesHistoryPage")
+    @ApiOperation("分页查询承保规则历史记录")
+    public HttpResult<PageResult> rulesHistoryPage(@RequestBody AgreementUndwrtRulesQueryVo agreementUndwrtRulesQueryVo) {
+        Page page = buildPageRequest(agreementUndwrtRulesQueryVo.getPageDto());
+        List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = ptlAgreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
+        Page<PtlAgreementUndwrtRulesNewHistory> ptlAgreementUndwrtRulesPage = ptlAgreementUndwrtRulesNewHistoryService.pageHistory(page, agreementUndwrtRulesQueryVo.getAgreementId(),undwrtRulesAttrList);
+        return HttpResult.ok(buildPageResponse(ptlAgreementUndwrtRulesPage));
+    }
+
+
+}

+ 19 - 0
src/main/java/com/ydtech/modules/protocols/dao/PtlAgreementProductCostsAttrLinkHistoryMapper.java

@@ -0,0 +1,19 @@
+package com.ydtech.modules.protocols.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsAttrLink;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsAttrLinkHistory;
+
+
+/**
+ * @author
+ * @description
+ * @createDate
+ */
+public interface PtlAgreementProductCostsAttrLinkHistoryMapper extends BaseMapper<PtlAgreementProductCostsAttrLinkHistory> {
+
+}
+
+
+
+

+ 23 - 0
src/main/java/com/ydtech/modules/protocols/dao/PtlAgreementProductCostsNewHistoryMapper.java

@@ -0,0 +1,23 @@
+package com.ydtech.modules.protocols.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsNew;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsNewHistory;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.HashMap;
+
+
+/**
+ * @author
+ * @description
+ * @createDate
+ */
+public interface PtlAgreementProductCostsNewHistoryMapper extends BaseMapper<PtlAgreementProductCostsNewHistory> {
+
+}
+
+
+
+

+ 19 - 0
src/main/java/com/ydtech/modules/protocols/dao/PtlAgreementUndwrtRulesAttrLinkHistoryMapper.java

@@ -0,0 +1,19 @@
+package com.ydtech.modules.protocols.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesAttrLink;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesAttrLinkHistory;
+
+
+/**
+ * @author
+ * @description
+ * @createDate
+ */
+public interface PtlAgreementUndwrtRulesAttrLinkHistoryMapper extends BaseMapper<PtlAgreementUndwrtRulesAttrLinkHistory> {
+
+}
+
+
+
+

+ 24 - 0
src/main/java/com/ydtech/modules/protocols/dao/PtlAgreementUndwrtRulesNewHistoryMapper.java

@@ -0,0 +1,24 @@
+package com.ydtech.modules.protocols.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesNew;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesNewHistory;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.HashMap;
+
+
+/**
+ * @author
+ * @description
+ * @createDate
+ */
+public interface PtlAgreementUndwrtRulesNewHistoryMapper extends BaseMapper<PtlAgreementUndwrtRulesNewHistory> {
+    Page<HashMap> pageHistory(@Param("page") Page page, @Param("agreementId") String agreementId);
+
+}
+
+
+
+

+ 77 - 0
src/main/java/com/ydtech/modules/protocols/entity/po/PtlAgreementProductCostsAttrLinkHistory.java

@@ -0,0 +1,77 @@
+package com.ydtech.modules.protocols.entity.po;
+
+import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDateTime;
+
+/**
+ *
+ */
+@TableName(value = "ptl_agreement_product_costs_attr_link_history", autoResultMap = true)
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class PtlAgreementProductCostsAttrLinkHistory {
+
+    @TableId(value = "id", type = com.baomidou.mybatisplus.annotation.IdType.AUTO)
+    private Integer id;
+
+    @ApiModelProperty(value = "费用id")
+    @TableField(value = "costs_id")
+    private String costsId;
+
+    @ApiModelProperty(value = "属性id")
+    @TableField(value = "attr_id")
+    private String attrId;
+
+    @ApiModelProperty(value = "属性编码")
+    @TableField(value = "attr_code")
+    private String attrCode;
+
+    @ApiModelProperty(value = "左操作数")
+    @TableField(value = "min")
+    private String min;
+
+    @ApiModelProperty(value = "左操作数数组")
+    @TableField(exist = false)
+    private String[] minArray;
+
+    @ApiModelProperty(value = "操作符")
+    @TableField(value = "operator")
+    private String operator;
+
+    @ApiModelProperty(value = "右操作数")
+    @TableField(value = "max")
+    private String max;
+
+
+    @ApiModelProperty(value = "批次")
+    @TableField(value = "batch")
+    private String batch;
+
+    @ApiModelProperty(value = "操作类型")
+    @TableField(value = "operator_type")
+    private String operatorType;
+
+    @ApiModelProperty(value = "操作人")
+    @TableField(value = "modifier")
+    private String modifier;
+
+    @ApiModelProperty(value = "操作时间")
+    @TableField(value = "operator_time")
+    private LocalDateTime operatorTime;
+
+    @TableField(exist = false)
+    private JSONArray dictLabal;
+
+    @ApiModelProperty(value = "关联属性使用")
+    @TableField(exist = false)
+    private PtlAgreementProductCostsAttrLinkHistory children;
+}

+ 203 - 0
src/main/java/com/ydtech/modules/protocols/entity/po/PtlAgreementProductCostsNewHistory.java

@@ -0,0 +1,203 @@
+package com.ydtech.modules.protocols.entity.po;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ *
+ */
+@TableName(value = "ptl_agreement_product_costs_new_history", autoResultMap = true)     //todo 添加数据库表
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class PtlAgreementProductCostsNewHistory {
+
+    @TableId(value = "id",type= IdType.AUTO)
+    private Integer id;
+
+    @ApiModelProperty(value = "协议id")
+    @TableField(value = "agreement_id")
+    private String agreementId;
+
+
+    @ApiModelProperty(value = "费用id")
+    @TableField(value = "costs_id")
+    private String costsId;
+
+
+    @ApiModelProperty(value = "产品id")
+    @TableField(value = "product_id")
+    private String productId;
+
+    @ApiModelProperty(value = "产品名称")
+    @TableField(value = "product_name")
+    private String productName;
+
+    @ApiModelProperty(value = "费用比例(交强)")
+    @TableField(value = "jq_car_costs_proportion")
+    private String jqCarCostsProportion;
+
+    @ApiModelProperty(value = "总费用比例(交强)")
+    @TableField(value = "jq_costs_proportion")
+    private String jqCostsProportion;
+
+    @ApiModelProperty(value = "加投比例(交强)")
+    @TableField(value = "jq_costs_proportion_add_invsestment")
+    private String jqCostsProportionAddInvsestment;
+
+    @ApiModelProperty(value = "其他费用比例(交强)")
+    @TableField(value = "jq_car_other_costs_proportion")
+    private String jqCarOtherCostsProportion;
+
+    @ApiModelProperty(value = "费用比例(商业)")
+    @TableField(value = "sy_car_costs_proportion")
+    private String syCarCostsProportion;
+
+    @ApiModelProperty(value = "总费用比例(商业)")
+    @TableField(value = "sy_costs_proportion")
+    private String syCostsProportion;
+
+    @ApiModelProperty(value = "加投比例(商业)")
+    @TableField(value = "sy_costs_proportion_add_invsestment")
+    private String syCostsProportionAddInvsestment;
+
+    @ApiModelProperty(value = "其他费用比例(商业)")
+    @TableField(value = "sy_car_other_costs_proportion")
+    private String syCarOtherCostsProportion;
+
+
+    @ApiModelProperty(value = "费用比例(非车)")
+    @TableField(value = "no_car_costs_proportion")
+    private String noCarCostsProportion;
+
+    @ApiModelProperty(value = "总费用比例(非车)")
+    @TableField(value = "no_costs_proportion")
+    private String noCostsProportion;
+
+    @ApiModelProperty(value = "其他费用比例(非车)")
+    @TableField(value = "no_car_other_costs_proportion")
+    private String noCarOtherCostsProportion;
+
+    @ApiModelProperty(value = "费用描述")
+    @TableField(value = "costs_description")
+    private String costsDescription;
+
+    @ApiModelProperty(value = "费用起期")
+    @TableField(value = "costs_start_date")
+    private String costsStartDate;
+
+    @ApiModelProperty(value = "费用止期")
+    @TableField(value = "costs_end_date")
+    private String costsEndDate;
+
+    @ApiModelProperty(value = "优先级")
+    @TableField(value = "priority_level")
+    private String priorityLevel;
+
+
+    @ApiModelProperty(value = "交强出口比例一级")
+    @TableField(value = "jq_export_radio_level_1")
+    private BigDecimal jqExportRadioLevel1;
+
+    @ApiModelProperty(value = "交强出口比例二级")
+    @TableField(value = "jq_export_radio_level_2")
+    private BigDecimal jqExportRadioLevel2;
+
+    @ApiModelProperty(value = "交强出口比例三级")
+    @TableField(value = "jq_export_radio_level_3")
+    private BigDecimal jqExportRadioLevel3;
+
+    @ApiModelProperty(value = "交强出口比例四级")
+    @TableField(value = "jq_export_radio_level_4")
+    private BigDecimal jqExportRadioLevel4;
+
+    @ApiModelProperty(value = "交强出口比例五级")
+    @TableField(value = "jq_export_radio_level_5")
+    private BigDecimal jqExportRadioLevel5;
+
+    @ApiModelProperty(value = "交强出口加投比例")
+    @TableField(value = "jq_export_investment_radio")
+    private BigDecimal jqExportInvestmentRadio;
+
+
+    @ApiModelProperty(value = "商业出口比例一级")
+    @TableField(value = "sy_export_radio_level_1")
+    private BigDecimal syExportRadioLevel1;
+
+    @ApiModelProperty(value = "商业出口比例二级")
+    @TableField(value = "sy_export_radio_level_2")
+    private BigDecimal syExportRadioLevel2;
+
+    @ApiModelProperty(value = "商业出口比例三级")
+    @TableField(value = "sy_export_radio_level_3")
+    private BigDecimal syExportRadioLevel3;
+
+    @ApiModelProperty(value = "商业出口比例四级")
+    @TableField(value = "sy_export_radio_level_4")
+    private BigDecimal syExportRadioLevel4;
+
+    @ApiModelProperty(value = "商业出口比例五级")
+    @TableField(value = "sy_export_radio_level_5")
+    private BigDecimal syExportRadioLevel5;
+
+    @ApiModelProperty(value = "商业出口加投比例")
+    @TableField(value = "sy_export_investment_radio")
+    private BigDecimal syExportInvestmentRadio;
+
+    @ApiModelProperty(value = "非车出口比例一级")
+    @TableField(value = "no_car_export_radio_level_1")
+    private BigDecimal noCarExportRadioLevel1;
+
+    @ApiModelProperty(value = "非车出口比例二级")
+    @TableField(value = "no_car_export_radio_level_2")
+    private BigDecimal noCarExportRadioLevel2;
+
+    @ApiModelProperty(value = "非车出口比例三级")
+    @TableField(value = "no_car_export_radio_level_3")
+    private BigDecimal noCarExportRadioLevel3;
+
+    @ApiModelProperty(value = "非车出口比例四级")
+    @TableField(value = "no_car_export_radio_level_4")
+    private BigDecimal noCarExportRadioLevel4;
+
+    @ApiModelProperty(value = "非车出口比例五级")
+    @TableField(value = "no_car_export_radio_level_5")
+    private BigDecimal noCarExportRadioLevel5;
+
+    @ApiModelProperty(value = "非车出口加投比例")
+    @TableField(value = "no_car_export_investment_radio")
+    private BigDecimal noCarExportInvestmentRadio;
+
+    @ApiModelProperty(value = "费用因子属性")
+    @TableField(exist = false)
+    private String costsAttrLinks;
+
+    @ApiModelProperty(value = "批次")
+    @TableField(value = "batch")
+    private String batch;
+
+    @ApiModelProperty(value = "操作类型")
+    @TableField(value = "operator_type")
+    private String operatorType;
+
+    @ApiModelProperty(value = "操作人")
+    @TableField(value = "modifier")
+    private String modifier;
+
+    @ApiModelProperty(value = "操作时间")
+    @TableField(value = "operator_time")
+    private LocalDateTime operatorTime;
+
+
+
+}

+ 76 - 0
src/main/java/com/ydtech/modules/protocols/entity/po/PtlAgreementUndwrtRulesAttrLinkHistory.java

@@ -0,0 +1,76 @@
+package com.ydtech.modules.protocols.entity.po;
+
+import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDateTime;
+
+/**
+ *
+ */
+@TableName(value = "ptl_agreement_undwrt_rules_attr_link_history", autoResultMap = true)
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class PtlAgreementUndwrtRulesAttrLinkHistory {
+
+    @TableId(value = "id", type = com.baomidou.mybatisplus.annotation.IdType.AUTO)
+    private Integer id;
+
+    @ApiModelProperty(value = "承包规则id")
+    @TableField(value = "rules_id")
+    private String rulesId;
+
+    @ApiModelProperty(value = "属性id")
+    @TableField(value = "attr_id")
+    private String attrId;
+
+    @ApiModelProperty(value = "属性编码")
+    @TableField(value = "attr_code")
+    private String attrCode;
+
+    @ApiModelProperty(value = "左操作数")
+    @TableField(value = "min")
+    private String min;
+
+    @ApiModelProperty(value = "左操作数数组")
+    @TableField(exist = false)
+    private String[] minArray;
+
+    @ApiModelProperty(value = "操作符")
+    @TableField(value = "operator")
+    private String operator;
+
+    @ApiModelProperty(value = "右操作数")
+    @TableField(value = "max")
+    private String max;
+
+    @ApiModelProperty(value = "批次")
+    @TableField(value = "batch")
+    private String batch;
+
+    @ApiModelProperty(value = "操作类型")
+    @TableField(value = "operator_type")
+    private String operatorType;
+
+    @ApiModelProperty(value = "操作人")
+    @TableField(value = "modifier")
+    private String modifier;
+
+    @ApiModelProperty(value = "操作时间")
+    @TableField(value = "operator_time")
+    private LocalDateTime operatorTime;
+
+    @TableField(exist = false)
+    private JSONArray dictLabal;
+
+    @ApiModelProperty(value = "关联属性使用")
+    @TableField(exist = false)
+    private PtlAgreementUndwrtRulesAttrLinkHistory children;
+}

+ 4 - 0
src/main/java/com/ydtech/modules/protocols/entity/po/PtlAgreementUndwrtRulesNew.java

@@ -44,6 +44,10 @@ public class PtlAgreementUndwrtRulesNew {
     @TableField(value = "valid_ind")
     private String validInd;
 
+    @ApiModelProperty(value = "生成的描述")
+    @TableField(exist = false)
+    private String desc;
+
     @ApiModelProperty(value = "规则属性")
     @TableField(exist = false)
     private List<PtlAgreementUndwrtRulesAttrLink> rulesAttrList;

+ 72 - 0
src/main/java/com/ydtech/modules/protocols/entity/po/PtlAgreementUndwrtRulesNewHistory.java

@@ -0,0 +1,72 @@
+package com.ydtech.modules.protocols.entity.po;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ *
+ */
+@TableName(value = "ptl_agreement_undwrt_rules_new_history", autoResultMap = true) //todo 添加数据库表
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class PtlAgreementUndwrtRulesNewHistory {
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    @ApiModelProperty(value = "协议id")
+    @TableField(value = "agreement_id")
+    private String agreementId;
+
+    @ApiModelProperty(value = "承包规则id")
+    @TableField(value = "rules_id")
+    private String rulesId;
+
+    @ApiModelProperty(value = "规则类型")
+    @TableField(value = "rules_type")
+    private String rulesType;
+
+    @ApiModelProperty(value = "业务类型")
+    @TableField(value = "product_type")
+    private String productType;
+
+    @ApiModelProperty(value = "规则描述")
+    @TableField(value = "rule_description")
+    private String ruleDescription;
+
+    @ApiModelProperty(value = "是否生效")
+    @TableField(value = "valid_ind")
+    private String validInd;
+
+    @ApiModelProperty(value = "费用因子属性")
+    @TableField(exist = false)
+    private String costsAttrLinks;
+    @ApiModelProperty(value = "批次")
+    @TableField(value = "batch")
+    private String batch;
+
+    @ApiModelProperty(value = "操作类型")
+    @TableField(value = "operator_type")
+    private String operatorType;
+
+    @ApiModelProperty(value = "操作人")
+    @TableField(value = "modifier")
+    private String modifier;
+
+    @ApiModelProperty(value = "操作时间")
+    @TableField(value = "operator_time")
+    private LocalDateTime operatorTime;
+
+
+
+}

+ 19 - 18
src/main/java/com/ydtech/modules/protocols/entity/vo/AgreementProductCosts.java

@@ -6,6 +6,7 @@ import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsAttrLink;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 @Data
@@ -72,58 +73,58 @@ public class AgreementProductCosts {
     // ---------------
     // ---------------
     @ApiModelProperty(value = "交强出口比例一级")
-    private String jqExportRadioLevel1;
+    private BigDecimal jqExportRadioLevel1;
 
     @ApiModelProperty(value = "交强出口比例二级")
-    private String jqExportRadioLevel2;
+    private BigDecimal jqExportRadioLevel2;
 
     @ApiModelProperty(value = "交强出口比例三级")
-    private String jqExportRadioLevel3;
+    private BigDecimal jqExportRadioLevel3;
 
     @ApiModelProperty(value = "交强出口比例四级")
-    private String jqExportRadioLevel4;
+    private BigDecimal jqExportRadioLevel4;
 
     @ApiModelProperty(value = "交强出口比例五级")
-    private String jqExportRadioLevel5;
+    private BigDecimal jqExportRadioLevel5;
 
     @ApiModelProperty(value = "交强出口加投比例")
-    private String jqExportInvestmentRadio;
+    private BigDecimal jqExportInvestmentRadio;
 
     @ApiModelProperty(value = "商业出口比例一级")
-    private String syExportRadioLevel1;
+    private BigDecimal syExportRadioLevel1;
 
     @ApiModelProperty(value = "商业出口比例二级")
-    private String syExportRadioLevel2;
+    private BigDecimal syExportRadioLevel2;
 
     @ApiModelProperty(value = "商业出口比例三级")
-    private String syExportRadioLevel3;
+    private BigDecimal syExportRadioLevel3;
 
     @ApiModelProperty(value = "商业出口比例四级")
-    private String syExportRadioLevel4;
+    private BigDecimal syExportRadioLevel4;
 
     @ApiModelProperty(value = "商业出口比例五级")
-    private String syExportRadioLevel5;
+    private BigDecimal syExportRadioLevel5;
 
     @ApiModelProperty(value = "商业出口加投比例")
-    private String syExportInvestmentRadio;
+    private BigDecimal syExportInvestmentRadio;
 
     @ApiModelProperty(value = "非车出口比例一级")
-    private String noCarExportRadioLevel1;
+    private BigDecimal noCarExportRadioLevel1;
 
     @ApiModelProperty(value = "非车出口比例二级")
-    private String noCarExportRadioLevel2;
+    private BigDecimal noCarExportRadioLevel2;
 
     @ApiModelProperty(value = "非车出口比例三级")
-    private String noCarExportRadioLevel3;
+    private BigDecimal noCarExportRadioLevel3;
 
     @ApiModelProperty(value = "非车出口比例四级")
-    private String noCarExportRadioLevel4;
+    private BigDecimal noCarExportRadioLevel4;
 
     @ApiModelProperty(value = "非车出口比例五级")
-    private String noCarExportRadioLevel5;
+    private BigDecimal noCarExportRadioLevel5;
 
     @ApiModelProperty(value = "非车出口加投比例")
-    private String noCarExportInvestmentRadio;
+    private BigDecimal noCarExportInvestmentRadio;
 
 
     @ApiModelProperty(value = "费用属性")

+ 1 - 1
src/main/java/com/ydtech/modules/protocols/entity/vo/AgreementProductCostsSave.java

@@ -66,7 +66,7 @@ public class AgreementProductCostsSave {
     private String costsEndDate;
 
     @ApiModelProperty(value = "优先级")
-    private String priorityLevel;
+    private Integer priorityLevel;
 
 
     // ---------------

+ 14 - 0
src/main/java/com/ydtech/modules/protocols/service/PtlAgreementProductCostsAttrLinkHistoryService.java

@@ -0,0 +1,14 @@
+package com.ydtech.modules.protocols.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsAttrLink;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsAttrLinkHistory;
+
+/**
+*@author:
+*@description:
+*@create:
+*/
+public interface PtlAgreementProductCostsAttrLinkHistoryService extends IService<PtlAgreementProductCostsAttrLinkHistory> {
+
+}

+ 24 - 0
src/main/java/com/ydtech/modules/protocols/service/PtlAgreementProductCostsNewHistoryService.java

@@ -0,0 +1,24 @@
+package com.ydtech.modules.protocols.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.modules.protocol.entity.vo.PtlAgreementHistoryConvertQueryVo;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsNew;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsNewHistory;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesAttr;
+import com.ydtech.modules.protocols.entity.vo.AgreementProductCosts;
+import com.ydtech.modules.protocols.entity.vo.AgreementProductCostsSave;
+
+import java.util.List;
+
+/**
+ * @author:
+ * @description:
+ * @create:
+ */
+public interface PtlAgreementProductCostsNewHistoryService extends IService<PtlAgreementProductCostsNewHistory> {
+
+    Page<PtlAgreementProductCostsNewHistory> pageHistory(Page page, String agreementId, List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList);
+
+
+}

+ 14 - 0
src/main/java/com/ydtech/modules/protocols/service/PtlAgreementUndwrtRulesAttrLinkHistoryService.java

@@ -0,0 +1,14 @@
+package com.ydtech.modules.protocols.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesAttrLink;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesAttrLinkHistory;
+
+/**
+*@author:
+*@description:
+*@create:
+*/
+public interface PtlAgreementUndwrtRulesAttrLinkHistoryService extends IService<PtlAgreementUndwrtRulesAttrLinkHistory> {
+
+}

+ 24 - 0
src/main/java/com/ydtech/modules/protocols/service/PtlAgreementUndwrtRulesNewHistoryService.java

@@ -0,0 +1,24 @@
+package com.ydtech.modules.protocols.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.modules.protocol.entity.dto.history.PtlAgreementUndwrtRulesHistory;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesAttr;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesNew;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesNewHistory;
+import com.ydtech.modules.protocols.entity.vo.AgreementUndwrtRules;
+import com.ydtech.modules.protocols.entity.vo.AgreementUndwrtRulesSave;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+*@author:
+*@description:
+*@create:
+*/
+public interface PtlAgreementUndwrtRulesNewHistoryService extends IService<PtlAgreementUndwrtRulesNewHistory> {
+
+
+    Page<PtlAgreementUndwrtRulesNewHistory> pageHistory(Page page, String agreementId,List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList);
+}

+ 21 - 0
src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementProductCostsAttrLinkHistoryServiceImpl.java

@@ -0,0 +1,21 @@
+package com.ydtech.modules.protocols.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.modules.protocols.dao.PtlAgreementProductCostsAttrLinkHistoryMapper;
+import com.ydtech.modules.protocols.dao.PtlAgreementProductCostsAttrLinkMapper;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsAttrLink;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsAttrLinkHistory;
+import com.ydtech.modules.protocols.service.PtlAgreementProductCostsAttrLinkHistoryService;
+import com.ydtech.modules.protocols.service.PtlAgreementProductCostsAttrLinkService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @description
+ * @createDate
+ * @Entity
+ */
+@Service
+public class PtlAgreementProductCostsAttrLinkHistoryServiceImpl extends ServiceImpl<PtlAgreementProductCostsAttrLinkHistoryMapper, PtlAgreementProductCostsAttrLinkHistory>
+        implements PtlAgreementProductCostsAttrLinkHistoryService {
+
+}

+ 119 - 0
src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementProductCostsNewHistoryServiceImpl.java

@@ -0,0 +1,119 @@
+package com.ydtech.modules.protocols.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.modules.protocol.entity.po.PtlAreaLicense;
+import com.ydtech.modules.protocol.service.PtlAreaLicenseService;
+import com.ydtech.modules.protocols.dao.PtlAgreementProductCostsNewHistoryMapper;
+import com.ydtech.modules.protocols.entity.po.*;
+import com.ydtech.modules.protocols.service.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @description
+ * @createDate
+ * @Entity
+ */
+@Service
+public class PtlAgreementProductCostsNewHistoryServiceImpl extends ServiceImpl<PtlAgreementProductCostsNewHistoryMapper, PtlAgreementProductCostsNewHistory>
+        implements PtlAgreementProductCostsNewHistoryService {
+
+
+    @Autowired
+    PtlAgreementProductCostsAttrLinkHistoryService costsAttrLinkHistoryService;
+    @Autowired
+    PtlAreaLicenseService ptlAreaLicenseService;
+    @Autowired
+    PtlAgreementUndwrtRulesAttrService ptlAgreementUndwrtRulesAttrService;
+
+    @Override
+    public Page<PtlAgreementProductCostsNewHistory> pageHistory(Page page, String agreementId, List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList) {
+        Page<PtlAgreementProductCostsNewHistory> historyVoPage = new Page<>();
+        //获取当前协议下的产品
+        LambdaQueryWrapper<PtlAgreementProductCostsNewHistory> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(PtlAgreementProductCostsNewHistory::getAgreementId, agreementId);
+        Page selectPage = baseMapper.selectPage(page, wrapper);
+        List<PtlAgreementProductCostsNewHistory> records = selectPage.getRecords();
+
+
+        //获取所有历史记录产品批次
+        List<String> batch = new ArrayList<>();
+        records.forEach(x -> {
+            batch.add(x.getBatch());
+        });
+
+        //获取当前协议所有产品下的所有费用因子的历史记录
+        List<PtlAgreementUndwrtRulesAttr> rulesAttrList = ptlAgreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
+        List<PtlAgreementProductCostsAttrLinkHistory> list = costsAttrLinkHistoryService.list(new LambdaQueryWrapper<PtlAgreementProductCostsAttrLinkHistory>()
+                .in(PtlAgreementProductCostsAttrLinkHistory::getBatch, batch));
+
+        Map<String, List<PtlAgreementProductCostsAttrLinkHistory>> groupedByCostsId = list.stream()
+                .collect(Collectors.groupingBy(PtlAgreementProductCostsAttrLinkHistory::getBatch));
+
+        groupedByCostsId.forEach((k, v) -> {
+            records.stream().filter(x -> x.getBatch().equals(k)).findFirst().ifPresent(x -> x.setCostsAttrLinks(buildDesc(v, undwrtRulesAttrList)));
+        });
+
+        //封装返回
+        historyVoPage.setCurrent(selectPage.getCurrent());
+        historyVoPage.setSize(selectPage.getSize());
+        historyVoPage.setPages(selectPage.getPages());
+        historyVoPage.setRecords(records);
+        historyVoPage.setTotal(selectPage.getTotal());
+        return historyVoPage;
+    }
+
+    /**
+     * 遍历费用属性描述文字
+     *
+     * @param v
+     * @param undwrtRulesAttrList
+     * @return
+     */
+    private String buildDesc(List<PtlAgreementProductCostsAttrLinkHistory> v, List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList) {
+        String desc = "";
+        for (int i = 0; i < v.size(); i++) {
+            int finalI = i;
+            PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = undwrtRulesAttrList.stream().filter(x -> x.getAttrCode().equals(v.get(finalI).getAttrCode())).findAny().get();
+            //数值范围判断
+            if ("inputNumber".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
+                desc += inputNumberIdentifying(ptlAgreementUndwrtRulesAttr, v.get(i)) + "\n";
+            }
+            if ("radio".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
+                desc += radioIdentifying(ptlAgreementUndwrtRulesAttr, v.get(i)) + "\n";
+            }
+            if ("checkbox".equals(ptlAgreementUndwrtRulesAttr.getAttrType()) || "select".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
+                desc += ptlAgreementUndwrtRulesAttr.getAttrName() + "包含" + v.get(i).getMin() + "\n";
+            }
+        }
+        return desc;
+    }
+
+    private String radioIdentifying(PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, PtlAgreementProductCostsAttrLinkHistory ptlAgreementProductCostsAttrLinkHistory) {
+        PtlAgreementUndwrtRulesDictLabal ptlAgreementUndwrtRulesDictLabal = ptlAgreementUndwrtRulesAttr.getDictLabal().stream().filter(x ->
+                x.getCode().equals(ptlAgreementProductCostsAttrLinkHistory.getMin())).findAny().get();
+        return ptlAgreementUndwrtRulesAttr.getAttrName() + "为" + ptlAgreementUndwrtRulesDictLabal.getName();
+    }
+
+    private String inputNumberIdentifying(PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, PtlAgreementProductCostsAttrLinkHistory ptlAgreementProductCostsAttrLink) {
+        if ("1".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+            return ptlAgreementUndwrtRulesAttr.getAttrName() + "范围值" + ptlAgreementProductCostsAttrLink.getMin() + "到" + ptlAgreementProductCostsAttrLink.getMax();
+        } else if ("2".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+            return ptlAgreementUndwrtRulesAttr.getAttrName() + "小于" + ptlAgreementProductCostsAttrLink.getMin();
+        } else if ("3".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+            return ptlAgreementUndwrtRulesAttr.getAttrName() + "小于等于" + ptlAgreementProductCostsAttrLink.getMin();
+        } else if ("4".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+            return ptlAgreementUndwrtRulesAttr.getAttrName() + "大于" + ptlAgreementProductCostsAttrLink.getMax();
+        } else if ("5".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+            return ptlAgreementUndwrtRulesAttr.getAttrName() + "大于等于" + ptlAgreementProductCostsAttrLink.getMax();
+        }
+        return "";
+    }
+
+}

+ 171 - 43
src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementProductCostsNewServiceImpl.java

@@ -3,7 +3,7 @@ package com.ydtech.modules.protocols.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ydtech.modules.protocol.entity.po.PtlAgreementProductCosts;
+import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.protocol.entity.po.PtlAreaLicense;
 import com.ydtech.modules.protocol.service.PtlAreaLicenseService;
 import com.ydtech.modules.protocols.dao.PtlAgreementProductCostsNewMapper;
@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -41,6 +42,12 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
     @Autowired
     PtlAgreementProductCostsExportService ptlAgreementProductCostsExportService;
 
+    @Autowired
+    PtlAgreementProductCostsNewHistoryServiceImpl ptlAgreementProductCostsNewHistoryService;
+
+    @Autowired
+    PtlAgreementProductCostsAttrLinkHistoryService ptlAgreementProductCostsAttrLinkHistoryService;
+
     @Override
     public Page<PtlAgreementProductCostsNew> getByAgreementId(Page page, String agreementId) {
         Page<PtlAgreementProductCostsNew> pages = baseMapper.selectPage(page, new LambdaQueryWrapper<PtlAgreementProductCostsNew>()
@@ -96,55 +103,53 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
 
     /**
      * 遍历费用属性描述文字
+     *
      * @param v
      * @param undwrtRulesAttrList
      * @return
      */
-    private String buildDesc(List<PtlAgreementProductCostsAttrLink> v, List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList){
+    private String buildDesc(List<PtlAgreementProductCostsAttrLink> v, List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList) {
         String desc = "";
-        for(int i=0;i<v.size();i++){
+        for (int i = 0; i < v.size(); i++) {
             int finalI = i;
             PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = undwrtRulesAttrList.stream().filter(x -> x.getAttrCode().equals(v.get(finalI).getAttrCode())).findAny().get();
             //数值范围判断
-            if("inputNumber".equals(ptlAgreementUndwrtRulesAttr.getAttrType()))
-            {
-                desc += inputNumberIdentifying(ptlAgreementUndwrtRulesAttr,v.get(i)) + "\n";
+            if ("inputNumber".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
+                desc += inputNumberIdentifying(ptlAgreementUndwrtRulesAttr, v.get(i)) + "\n";
             }
-            if("radio".equals(ptlAgreementUndwrtRulesAttr.getAttrType()))
-            {
-                desc += radioIdentifying(ptlAgreementUndwrtRulesAttr,v.get(i)) + "\n";
+            if ("radio".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
+                desc += radioIdentifying(ptlAgreementUndwrtRulesAttr, v.get(i)) + "\n";
             }
-            if("checkbox".equals(ptlAgreementUndwrtRulesAttr.getAttrType()) || "select".equals(ptlAgreementUndwrtRulesAttr.getAttrType()))
-            {
+            if ("checkbox".equals(ptlAgreementUndwrtRulesAttr.getAttrType()) || "select".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
                 desc += ptlAgreementUndwrtRulesAttr.getAttrName() + "包含" + v.get(i).getMin() + "\n";
             }
         }
         return desc;
     }
 
-    private String radioIdentifying(PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr,PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink){
+    private String radioIdentifying(PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink) {
         PtlAgreementUndwrtRulesDictLabal ptlAgreementUndwrtRulesDictLabal = ptlAgreementUndwrtRulesAttr.getDictLabal().stream().filter(x ->
                 x.getCode().equals(ptlAgreementProductCostsAttrLink.getMin())).findAny().get();
         return ptlAgreementUndwrtRulesAttr.getAttrName() + "为" + ptlAgreementUndwrtRulesDictLabal.getName();
     }
 
-    private String inputNumberIdentifying(PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr,PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink){
-        if("1".equals(ptlAgreementProductCostsAttrLink.getOperator())){
+    private String inputNumberIdentifying(PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink) {
+        if ("1".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
             return ptlAgreementUndwrtRulesAttr.getAttrName() + "范围值" + ptlAgreementProductCostsAttrLink.getMin() + "到" + ptlAgreementProductCostsAttrLink.getMax();
-        }else if("2".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+        } else if ("2".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
             return ptlAgreementUndwrtRulesAttr.getAttrName() + "小于" + ptlAgreementProductCostsAttrLink.getMin();
-        }else if("3".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+        } else if ("3".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
             return ptlAgreementUndwrtRulesAttr.getAttrName() + "小于等于" + ptlAgreementProductCostsAttrLink.getMin();
-        }else if("4".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+        } else if ("4".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
             return ptlAgreementUndwrtRulesAttr.getAttrName() + "大于" + ptlAgreementProductCostsAttrLink.getMax();
-        }else if("5".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+        } else if ("5".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
             return ptlAgreementUndwrtRulesAttr.getAttrName() + "大于等于" + ptlAgreementProductCostsAttrLink.getMax();
         }
         return "";
     }
 
     @Override
-    public AgreementProductCostsSave costsGet(String costsId,List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList) {
+    public AgreementProductCostsSave costsGet(String costsId, List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList) {
         //设置费用入口信息
         PtlAgreementProductCostsNew ptlAgreementProductCostsNew = baseMapper.selectOne(new LambdaQueryWrapper<PtlAgreementProductCostsNew>().eq(PtlAgreementProductCostsNew::getId, costsId));
         if (ptlAgreementProductCostsNew == null) {
@@ -156,7 +161,7 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         //设置费用出口信息
         PtlAgreementProductCostsExport ptlAgreementProductCostsExport = ptlAgreementProductCostsExportService.getOne(new LambdaQueryWrapper<PtlAgreementProductCostsExport>()
                 .eq(PtlAgreementProductCostsExport::getCostsId, costsId));
-        if(!Objects.isNull(ptlAgreementProductCostsExport)) {
+        if (!Objects.isNull(ptlAgreementProductCostsExport)) {
             agreementProductCosts.setExportRadio(ptlAgreementProductCostsExport);
         }
 
@@ -168,12 +173,11 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
 
         undwrtRulesAttrList.stream().forEach(x -> {
             //处理多选和下拉
-            if("checkbox".equals(x.getAttrType()) || "select".equals(x.getAttrType()))
-            {
+            if ("checkbox".equals(x.getAttrType()) || "select".equals(x.getAttrType())) {
                 //处理车牌
-                if("select".equals(x.getAttrType()) && "LicenseNo".equals(x.getAttrCode())){
+                if ("select".equals(x.getAttrType()) && "LicenseNo".equals(x.getAttrCode())) {
                     PtlAgreementProductCostsAttrLink licenseNo = list.stream().filter(l -> l.getAttrCode().equals("LicenseNo")).findFirst().orElse(null);
-                    if(licenseNo != null) {
+                    if (licenseNo != null) {
                         //根据operator 获取车牌的地区id
                         List<PtlAreaLicense> byParentNumber = ptlAreaLicenseService.getByParentNumber(licenseNo.getOperator());
                         List<PtlAgreementUndwrtRulesDictLabal> dictLabal = byParentNumber.stream().map(y -> {
@@ -188,14 +192,14 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
                 }
                 x.setMinArray(new String[]{});
                 list.stream().filter(y -> y.getAttrCode().equals(x.getAttrCode())).findFirst().ifPresent(z -> {
-                    if(null != z.getMin()) {
+                    if (null != z.getMin()) {
                         x.setId(z.getId());
                         x.setMinArray(z.getMin().split(","));
                         x.setMax(z.getMax());
                         x.setOperator(z.getOperator());
                     }
                 });
-            }else{
+            } else {
                 list.stream().filter(y -> y.getAttrCode().equals(x.getAttrCode())).findFirst().ifPresent(z -> {
                     x.setId(z.getId());
                     x.setMin(z.getMin());
@@ -212,6 +216,7 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         return agreementProductCosts;
     }
 
+
     @Override
     public List<AgreementProductCosts> costsGetList(String agreementId) {
         List<PtlAgreementProductCostsNew> ptlAgreementProductCostsNews = baseMapper.selectList(new LambdaQueryWrapper<PtlAgreementProductCostsNew>()
@@ -225,15 +230,14 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
             BeanUtils.copyProperties(news, productCosts);
             agreementProductCosts.add(productCosts);
         });
-        if(ptlAgreementProductCostsNews.size() > 0)
-        {
+        if (ptlAgreementProductCostsNews.size() > 0) {
             List<PtlAgreementProductCostsAttrLink> list = ptlAgreementProductCostsAttrLinkService.list(new LambdaQueryWrapper<PtlAgreementProductCostsAttrLink>()
                     .in(PtlAgreementProductCostsAttrLink::getCostsId, ptlAgreementProductCostsNews.stream().map(PtlAgreementProductCostsNew::getId).collect(Collectors.toList())));
             agreementProductCosts.forEach(x -> {
                 List<PtlAgreementProductCostsAttrLink> collect = list.stream().filter(y -> y.getCostsId().equals(x.getId())).collect(Collectors.toList());
                 x.setCostsAttrLinks(collect);
             });
-        }else{
+        } else {
             agreementProductCosts.forEach(x -> {
                 x.setCostsAttrLinks(new ArrayList<>());
             });
@@ -256,15 +260,14 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
             BeanUtils.copyProperties(news, productCosts);
             agreementProductCosts.add(productCosts);
         });
-        if(ptlAgreementProductCostsNews.size() > 0)
-        {
+        if (ptlAgreementProductCostsNews.size() > 0) {
             List<PtlAgreementProductCostsAttrLink> list = ptlAgreementProductCostsAttrLinkService.list(new LambdaQueryWrapper<PtlAgreementProductCostsAttrLink>()
                     .in(PtlAgreementProductCostsAttrLink::getCostsId, ptlAgreementProductCostsNews.stream().map(PtlAgreementProductCostsNew::getId).collect(Collectors.toList())));
             agreementProductCosts.forEach(x -> {
                 List<PtlAgreementProductCostsAttrLink> collect = list.stream().filter(y -> y.getCostsId().equals(x.getId())).collect(Collectors.toList());
                 x.setCostsAttrLinks(collect);
             });
-        }else{
+        } else {
             agreementProductCosts.forEach(x -> {
                 x.setCostsAttrLinks(new ArrayList<>());
             });
@@ -272,6 +275,7 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         return agreementProductCosts;
     }
 
+
     @Transactional
     @Override
     public boolean costsAdd(AgreementProductCosts agreementProductCosts) {
@@ -289,28 +293,61 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         ptlAgreementProductCostsExport.setId(null);
         ptlAgreementProductCostsExport.blank();
         ptlAgreementProductCostsExportService.save(ptlAgreementProductCostsExport);
-
+        //保存产品费用历史记录
+        PtlAgreementProductCostsNewHistory ptlAgreementProductCostsNewHistory = new PtlAgreementProductCostsNewHistory();
+        BeanUtils.copyProperties(agreementProductCosts, ptlAgreementProductCostsNewHistory);
+        //添加费用ID
+        ptlAgreementProductCostsNewHistory.setCostsId(ptlAgreementProductCostsNew.getId());
+        //生成批次ID
+        String uuid = UUID.randomUUID().toString();
+        ptlAgreementProductCostsNewHistory.setBatch(uuid);
+        ptlAgreementProductCostsNewHistory.setOperatorType("add");
+        ptlAgreementProductCostsNewHistory.setModifier(BaseController.getUser().getId());
+        ptlAgreementProductCostsNewHistory.setOperatorTime(LocalDateTime.now());
+        ptlAgreementProductCostsNewHistoryService.save(ptlAgreementProductCostsNewHistory);
+        //创建产品费用因子历史记录容器
+        List<PtlAgreementProductCostsAttrLinkHistory> costsAttrLinkHistories = new ArrayList<>();
         //遍历费用属性
         List<PtlAgreementProductCostsAttrLink> costsAttrLinks = agreementProductCosts.getCostsAttrLinks();
         List<PtlAgreementProductCostsAttrLink> costsAttrLink = new ArrayList<>();
         costsAttrLinks.forEach(x -> {
+            PtlAgreementProductCostsAttrLinkHistory costsAttrLinkHistory = new PtlAgreementProductCostsAttrLinkHistory();
+
             //单独处理车牌号
-            if("LicenseNo".equals(x.getAttrCode()) && (x.getMin() != null && !x.getMin().equals(""))){
+            if ("LicenseNo".equals(x.getAttrCode()) && (x.getMin() != null && !x.getMin().equals(""))) {
                 x.setOperator(x.getDictLabal().getJSONObject(0).getString("parentNumber"));
                 x.setCostsId(ptlAgreementProductCostsNew.getId());
                 x.setId(0);
                 costsAttrLink.add(x);
-            }else {
+                BeanUtils.copyProperties(x, costsAttrLinkHistory);
+                //设置产品费用因子历史记录
+                costsAttrLinkHistory.setBatch(uuid);
+                costsAttrLinkHistory.setOperatorType("add");
+                costsAttrLinkHistory.setModifier(BaseController.getUser().getId());
+                costsAttrLinkHistory.setOperatorTime(LocalDateTime.now());
+                costsAttrLinkHistories.add(costsAttrLinkHistory);
+            } else {
                 if ((!"0".equals(x.getMin()) && null != x.getMin()) || (!"0".equals(x.getMax()) && null != x.getMax())) {
 
                     x.setCostsId(ptlAgreementProductCostsNew.getId());
                     x.setId(0);
                     costsAttrLink.add(x);
+                    BeanUtils.copyProperties(x, costsAttrLinkHistory);
+                    //设置产品费用因子历史记录
+                    costsAttrLinkHistory.setBatch(uuid);
+
+                    costsAttrLinkHistory.setOperatorType("add");
+                    costsAttrLinkHistory.setModifier(BaseController.getUser().getId());
+                    costsAttrLinkHistory.setOperatorTime(LocalDateTime.now());
+                    costsAttrLinkHistories.add(costsAttrLinkHistory);
                 }
             }
         });
+        //保存产品费用因子历史记录
+        ptlAgreementProductCostsAttrLinkHistoryService.saveBatch(costsAttrLinkHistories);
         ptlAgreementProductCostsAttrLinkService.saveBatch(costsAttrLink);
         return true;
+
     }
 
     @Transactional
@@ -324,13 +361,15 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         //更新费用出口表信息
         PtlAgreementProductCostsExport ptlAgreementProductCostsExport = ptlAgreementProductCostsExportService.getOne(
                 new LambdaQueryWrapper<PtlAgreementProductCostsExport>()
-                .eq(PtlAgreementProductCostsExport::getCostsId, ptlAgreementProductCostsNew.getId()));
-        if(Objects.isNull(ptlAgreementProductCostsExport)){
+                        .eq(PtlAgreementProductCostsExport::getCostsId, ptlAgreementProductCostsNew.getId()));
+
+
+        if (Objects.isNull(ptlAgreementProductCostsExport)) {
             ptlAgreementProductCostsExport = new PtlAgreementProductCostsExport();
             BeanUtils.copyProperties(agreementProductCosts, ptlAgreementProductCostsExport);
             ptlAgreementProductCostsExport.setCostsId(ptlAgreementProductCostsNew.getId());
             ptlAgreementProductCostsExport.setId(null);
-        }else{
+        } else {
             //保存原始id
             String id = ptlAgreementProductCostsExport.getId();
             BeanUtils.copyProperties(agreementProductCosts, ptlAgreementProductCostsExport);
@@ -339,41 +378,86 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         }
         ptlAgreementProductCostsExportService.saveOrUpdate(ptlAgreementProductCostsExport);
 
+        //保存产品费用历史记录
+        PtlAgreementProductCostsNewHistory ptlAgreementProductCostsNewHistory = new PtlAgreementProductCostsNewHistory();
+        BeanUtils.copyProperties(agreementProductCosts, ptlAgreementProductCostsNewHistory);
+        //添加费用ID
+        ptlAgreementProductCostsNewHistory.setCostsId(ptlAgreementProductCostsNew.getId());
+        //生成批次ID
+        String uuid = UUID.randomUUID().toString();
+        ptlAgreementProductCostsNewHistory.setBatch(uuid);
+
+        ptlAgreementProductCostsNewHistory.setOperatorType("update");
+        ptlAgreementProductCostsNewHistory.setModifier(BaseController.getUser().getId());
+        ptlAgreementProductCostsNewHistory.setOperatorTime(LocalDateTime.now());
+        ptlAgreementProductCostsNewHistoryService.save(ptlAgreementProductCostsNewHistory);
+
+
         //设置费用因子属性
         //先删除属性值
         ptlAgreementProductCostsAttrLinkService.remove(new LambdaQueryWrapper<PtlAgreementProductCostsAttrLink>()
                 .eq(PtlAgreementProductCostsAttrLink::getCostsId, ptlAgreementProductCostsNew.getId()));
         List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = ptlAgreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
+        //创建产品费用因子历史记录容器
+        List<PtlAgreementProductCostsAttrLinkHistory> costsAttrLinkHistories = new ArrayList<>();
         //再添加属性值
         List<PtlAgreementProductCostsAttrLink> costsAttrLinks = agreementProductCosts.getCostsAttrLinks();
         List<PtlAgreementProductCostsAttrLink> costsAttrLink = new ArrayList<>();
         costsAttrLinks.forEach(x -> {
             //单独处理车牌号
-            if("LicenseNo".equals(x.getAttrCode()) && (x.getMin() != null && x.getMin() != "")){
+            if ("LicenseNo".equals(x.getAttrCode()) && (x.getMin() != null && x.getMin() != "")) {
                 x.setOperator(x.getDictLabal().getJSONObject(0).getString("parentNumber"));
                 x.setCostsId(ptlAgreementProductCostsNew.getId());
                 x.setId(0);
                 costsAttrLink.add(x);
-            }else {
+                //设置产品费用因子历史记录
+                PtlAgreementProductCostsAttrLinkHistory costsAttrLinkHistory = new PtlAgreementProductCostsAttrLinkHistory();
+                BeanUtils.copyProperties(x, costsAttrLinkHistory);
+                costsAttrLinkHistory.setBatch(uuid);
+
+                costsAttrLinkHistory.setOperatorType("update");
+                costsAttrLinkHistory.setModifier(BaseController.getUser().getId());
+                costsAttrLinkHistory.setOperatorTime(LocalDateTime.now());
+                costsAttrLinkHistories.add(costsAttrLinkHistory);
+            } else {
                 PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = undwrtRulesAttrList.stream().filter(y -> y.getAttrCode().equals(x.getAttrCode())).findFirst().orElse(null);
                 //单独判断radio  radio中存在0的属性值
-                if("radio".equals(ptlAgreementUndwrtRulesAttr.getAttrType())){
+                if ("radio".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
                     if (null != x.getMin()) {
-
                         x.setCostsId(ptlAgreementProductCostsNew.getId());
                         x.setId(0);
                         costsAttrLink.add(x);
+                        //设置产品费用因子历史记录
+                        PtlAgreementProductCostsAttrLinkHistory costsAttrLinkHistory = new PtlAgreementProductCostsAttrLinkHistory();
+                        BeanUtils.copyProperties(x, costsAttrLinkHistory);
+                        costsAttrLinkHistory.setBatch(uuid);
+
+                        costsAttrLinkHistory.setOperatorType("update");
+                        costsAttrLinkHistory.setModifier(BaseController.getUser().getId());
+                        costsAttrLinkHistory.setOperatorTime(LocalDateTime.now());
+                        costsAttrLinkHistories.add(costsAttrLinkHistory);
                     }
-                }else {
+                } else {
                     if ((!"0".equals(x.getMin()) && null != x.getMin()) || (!"0".equals(x.getMax()) && null != x.getMax())) {
 
                         x.setCostsId(ptlAgreementProductCostsNew.getId());
                         x.setId(0);
                         costsAttrLink.add(x);
+                        //设置产品费用因子历史记录
+                        PtlAgreementProductCostsAttrLinkHistory costsAttrLinkHistory = new PtlAgreementProductCostsAttrLinkHistory();
+                        BeanUtils.copyProperties(x, costsAttrLinkHistory);
+                        costsAttrLinkHistory.setBatch(uuid);
+
+                        costsAttrLinkHistory.setOperatorType("update");
+                        costsAttrLinkHistory.setModifier(BaseController.getUser().getId());
+                        costsAttrLinkHistory.setOperatorTime(LocalDateTime.now());
+                        costsAttrLinkHistories.add(costsAttrLinkHistory);
                     }
                 }
             }
         });
+        //保存产品费用因子历史记录
+        ptlAgreementProductCostsAttrLinkHistoryService.saveBatch(costsAttrLinkHistories);
         ptlAgreementProductCostsAttrLinkService.saveBatch(costsAttrLink);
         return true;
     }
@@ -381,8 +465,52 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
     @Transactional
     @Override
     public boolean costsDelete(String costsId) {
+        //获取产品费用历史记录
+        PtlAgreementProductCostsNew ptlAgreementProductCostsNew = baseMapper.selectById(costsId);
+        //获取产品费用出口历史记录
+        PtlAgreementProductCostsExport productCostsExport = ptlAgreementProductCostsExportService.getOne(new LambdaQueryWrapper<PtlAgreementProductCostsExport>().eq(PtlAgreementProductCostsExport::getCostsId, costsId));
+
+
+        //保存产品费用历史记录
+        PtlAgreementProductCostsNewHistory ptlAgreementProductCostsNewHistory = new PtlAgreementProductCostsNewHistory();
+        BeanUtils.copyProperties(ptlAgreementProductCostsNew, ptlAgreementProductCostsNewHistory);
+        BeanUtils.copyProperties(productCostsExport, ptlAgreementProductCostsNewHistory);
+        //添加费用ID
+        ptlAgreementProductCostsNewHistory.setCostsId(ptlAgreementProductCostsNew.getId());
+        //生成批次ID
+        String uuid = UUID.randomUUID().toString();
+        ptlAgreementProductCostsNewHistory.setBatch(uuid);
+
+        ptlAgreementProductCostsNewHistory.setOperatorType("delete");
+        ptlAgreementProductCostsNewHistory.setModifier(BaseController.getUser().getId());
+        ptlAgreementProductCostsNewHistory.setOperatorTime(LocalDateTime.now());
+        ptlAgreementProductCostsNewHistoryService.save(ptlAgreementProductCostsNewHistory);
+
+        //创建产品费用因子历史记录容器
+        List<PtlAgreementProductCostsAttrLinkHistory> costsAttrLinkHistories = new ArrayList<>();
+
+        //获取产品费用因子出口历史记录
+        List<PtlAgreementProductCostsAttrLink> costsAttrLinks = ptlAgreementProductCostsAttrLinkService.list(new LambdaQueryWrapper<PtlAgreementProductCostsAttrLink>()
+                .eq(PtlAgreementProductCostsAttrLink::getCostsId, costsId));
+
+        costsAttrLinks.forEach(x -> {
+            PtlAgreementProductCostsAttrLinkHistory costsAttrLinkHistory = new PtlAgreementProductCostsAttrLinkHistory();
+            BeanUtils.copyProperties(x, costsAttrLinkHistory);
+            //设置产品费用因子历史记录
+            costsAttrLinkHistory.setBatch(uuid);
+            costsAttrLinkHistory.setOperatorType("add");
+            costsAttrLinkHistory.setModifier(BaseController.getUser().getId());
+            costsAttrLinkHistory.setOperatorTime(LocalDateTime.now());
+            costsAttrLinkHistories.add(costsAttrLinkHistory);
+        });
+
+        //保存产品费用因子历史记录
+        ptlAgreementProductCostsAttrLinkHistoryService.saveBatch(costsAttrLinkHistories);
+
+        //删除产品费用及费用因子
         baseMapper.deleteById(costsId);
         ptlAgreementProductCostsAttrLinkService.remove(new LambdaQueryWrapper<PtlAgreementProductCostsAttrLink>().eq(PtlAgreementProductCostsAttrLink::getCostsId, costsId));
+
         return true;
     }
 }

+ 21 - 0
src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementUndwrtRulesAttrLinkHistoryServiceImpl.java

@@ -0,0 +1,21 @@
+package com.ydtech.modules.protocols.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.modules.protocols.dao.PtlAgreementUndwrtRulesAttrLinkHistoryMapper;
+import com.ydtech.modules.protocols.dao.PtlAgreementUndwrtRulesAttrLinkMapper;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesAttrLink;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesAttrLinkHistory;
+import com.ydtech.modules.protocols.service.PtlAgreementUndwrtRulesAttrLinkHistoryService;
+import com.ydtech.modules.protocols.service.PtlAgreementUndwrtRulesAttrLinkService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @description
+ * @createDate
+ * @Entity
+ */
+@Service
+public class PtlAgreementUndwrtRulesAttrLinkHistoryServiceImpl extends ServiceImpl<PtlAgreementUndwrtRulesAttrLinkHistoryMapper, PtlAgreementUndwrtRulesAttrLinkHistory>
+        implements PtlAgreementUndwrtRulesAttrLinkHistoryService {
+
+}

+ 131 - 0
src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementUndwrtRulesNewHistoryServiceImpl.java

@@ -0,0 +1,131 @@
+package com.ydtech.modules.protocols.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.modules.protocol.entity.po.PtlAreaLicense;
+import com.ydtech.modules.protocol.service.PtlAreaLicenseService;
+import com.ydtech.modules.protocols.dao.PtlAgreementUndwrtRulesNewHistoryMapper;
+import com.ydtech.modules.protocols.entity.po.*;
+import com.ydtech.modules.protocols.service.PtlAgreementUndwrtRulesAttrLinkHistoryService;
+import com.ydtech.modules.protocols.service.PtlAgreementUndwrtRulesAttrService;
+import com.ydtech.modules.protocols.service.PtlAgreementUndwrtRulesNewHistoryService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+
+/**
+ * @description
+ * @createDate
+ * @Entity
+ */
+@Service
+public class PtlAgreementUndwrtRulesNewHistoryServiceImpl extends ServiceImpl<PtlAgreementUndwrtRulesNewHistoryMapper, PtlAgreementUndwrtRulesNewHistory>
+        implements PtlAgreementUndwrtRulesNewHistoryService {
+
+
+    @Autowired
+    PtlAgreementUndwrtRulesAttrLinkHistoryService undwrtRulesAttrLinkHistoryService;
+
+    @Autowired
+    PtlAreaLicenseService ptlAreaLicenseService;
+
+    @Autowired
+    PtlAgreementUndwrtRulesAttrService ptlAgreementUndwrtRulesAttrService;
+
+    @Override
+    public Page<PtlAgreementUndwrtRulesNewHistory> pageHistory(Page page, String agreementId, List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList) {
+        Page<PtlAgreementUndwrtRulesNewHistory> historyVoPage = new Page<>();
+        //获取当前协议下的承包规则
+        LambdaQueryWrapper<PtlAgreementUndwrtRulesNewHistory> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(PtlAgreementUndwrtRulesNewHistory::getAgreementId, agreementId);
+        Page selectPage = baseMapper.selectPage(page, wrapper);
+        List<PtlAgreementUndwrtRulesNewHistory> records = selectPage.getRecords();
+
+        //获取所有历史记录承包规则批次
+        List<String> batch = new ArrayList<>();
+        records.forEach(x -> {
+            batch.add(x.getBatch());
+        });
+
+        //获取当前协议所有承包规则下的所有费用因子的历史记录
+        List<PtlAgreementUndwrtRulesAttr> rulesAttrList = ptlAgreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
+        List<PtlAgreementUndwrtRulesAttrLinkHistory> list = undwrtRulesAttrLinkHistoryService.list(new LambdaQueryWrapper<PtlAgreementUndwrtRulesAttrLinkHistory>()
+                .in(PtlAgreementUndwrtRulesAttrLinkHistory::getBatch, batch));
+
+        Map<String, List<PtlAgreementUndwrtRulesAttrLinkHistory>> groupedByCostsId = list.stream()
+                .collect(Collectors.groupingBy(PtlAgreementUndwrtRulesAttrLinkHistory::getBatch));
+
+        groupedByCostsId.forEach((k, v) -> {
+            records.stream().filter(x -> x.getBatch().equals(k)).findFirst().ifPresent(x -> x.setCostsAttrLinks(buildDesc(v, undwrtRulesAttrList)));
+        });
+
+        //封装返回
+        historyVoPage.setCurrent(selectPage.getCurrent());
+        historyVoPage.setSize(selectPage.getSize());
+        historyVoPage.setPages(selectPage.getPages());
+        historyVoPage.setRecords(records);
+        historyVoPage.setTotal(selectPage.getTotal());
+        return historyVoPage;
+    }
+
+    /**
+     * 遍历费用属性描述文字
+     *
+     * @param v
+     * @param undwrtRulesAttrList
+     * @return
+     */
+    private String buildDesc(List<PtlAgreementUndwrtRulesAttrLinkHistory> v, List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList) {
+        String desc = "";
+        for (int i = 0; i < v.size(); i++) {
+            int finalI = i;
+            PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = undwrtRulesAttrList.stream().filter(x -> x.getAttrCode().equals(v.get(finalI).getAttrCode())).findAny().get();
+            //数值范围判断
+            if ("inputNumber".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
+                desc += inputNumberIdentifying(ptlAgreementUndwrtRulesAttr, v.get(i)) + "\n";
+            }
+            if ("radio".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
+                desc += radioIdentifying(ptlAgreementUndwrtRulesAttr, v.get(i)) + "\n";
+            }
+            if ("checkbox".equals(ptlAgreementUndwrtRulesAttr.getAttrType()) || "select".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
+                desc += ptlAgreementUndwrtRulesAttr.getAttrName() + "包含" + v.get(i).getMin() + "\n";
+            }
+        }
+        return desc;
+    }
+
+    private String radioIdentifying(PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, PtlAgreementUndwrtRulesAttrLinkHistory ptlAgreementProductCostsAttrLinkHistory) {
+        PtlAgreementUndwrtRulesDictLabal ptlAgreementUndwrtRulesDictLabal = ptlAgreementUndwrtRulesAttr.getDictLabal().stream().filter(x ->
+                x.getCode().equals(ptlAgreementProductCostsAttrLinkHistory.getMin())).findAny().get();
+        return ptlAgreementUndwrtRulesAttr.getAttrName() + "为" + ptlAgreementUndwrtRulesDictLabal.getName();
+    }
+
+    private String inputNumberIdentifying(PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, PtlAgreementUndwrtRulesAttrLinkHistory ptlAgreementProductCostsAttrLink) {
+        if ("1".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+            return ptlAgreementUndwrtRulesAttr.getAttrName() + "范围值" + ptlAgreementProductCostsAttrLink.getMin() + "到" + ptlAgreementProductCostsAttrLink.getMax();
+        } else if ("2".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+            return ptlAgreementUndwrtRulesAttr.getAttrName() + "小于" + ptlAgreementProductCostsAttrLink.getMin();
+        } else if ("3".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+            return ptlAgreementUndwrtRulesAttr.getAttrName() + "小于等于" + ptlAgreementProductCostsAttrLink.getMin();
+        } else if ("4".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+            return ptlAgreementUndwrtRulesAttr.getAttrName() + "大于" + ptlAgreementProductCostsAttrLink.getMax();
+        } else if ("5".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+            return ptlAgreementUndwrtRulesAttr.getAttrName() + "大于等于" + ptlAgreementProductCostsAttrLink.getMax();
+        }
+        return "";
+    }
+}
+
+
+
+

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików