Просмотр исходного кода

缺失功能:
解决平台应收,批量结算的导入接口,导入失败的问题

jiakai 4 месяцев назад
Родитель
Сommit
2785dd8a47

+ 6 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/JyExcelVo.java

@@ -29,6 +29,12 @@ public class JyExcelVo {
     @Schema(description = "驾意险保单号")
     private String jyPolicyNo;
 
+    @Schema(description = "订单号")
+    private String orderNo;
+
+    @Schema(description = "协议类型")
+    private String agreementType;
+
     @Schema(description = "驾意险保费")
     private BigDecimal jyPremium;
 

+ 6 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/OtherExcelVo.java

@@ -29,6 +29,12 @@ public class OtherExcelVo {
     @Schema(description = "交强险保单号")
     private String jqPolicyNo;
 
+    @Schema(description = "订单号")
+    private String orderNo;
+
+    @Schema(description = "协议类型")
+    private String agreementType;
+
     @Schema(description = "交强险保费")
     private BigDecimal jqPremium;
 

+ 6 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/SuperviseExcelVo.java

@@ -26,6 +26,12 @@ public class SuperviseExcelVo {
     @Schema(description = "车牌号")
     private String licenseNo;
 
+    @Schema(description = "订单号")
+    private String orderNo;
+
+    @Schema(description = "协议类型")
+    private String agreementType;
+
     @Schema(description = "交强险保单号")
     private String jqPolicyNo;
 

+ 11 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/controller/InsOrdersController.java

@@ -1,6 +1,7 @@
 package com.jzg.quotation.summary.controller;
 
 
+import cn.hutool.core.util.NumberUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -98,6 +99,16 @@ public class InsOrdersController extends BaseController {
         return HttpResult.ok(insOrdersService.selectById(id));
     }
 
+    @PostMapping("/selectInsOrdersById/{id}")
+    @Operation(summary = "通过ID查询订单信息")
+    public HttpResult<InsOrdersVo> selectInsOrdersById(@NotNull(message = "id不能为空") @PathVariable String id) {
+        InsOrdersVo insOrdersVo = null;
+        if (NumberUtil.isLong(id)){
+            insOrdersVo = insOrdersService.selectById(Long.parseLong(id));
+        }
+        return HttpResult.ok(insOrdersVo);
+    }
+
     @PostMapping("pageList")
     @Operation(summary = "订单分页列表")
     public HttpResult pageList(@RequestBody InsOrdersParam insOrdersParam) {

+ 26 - 0
tenant/organization/src/main/java/com/jzg/organization/client/InsOrdersClient.java

@@ -0,0 +1,26 @@
+package com.jzg.organization.client;
+
+import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.quote.vo.orders.InsOrdersVo;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * 订单接口
+ */
+@FeignClient(name = "quotation-summary")
+public interface InsOrdersClient {
+
+    /**
+     * 订单列表通过订单号查询
+     * @param id 订单号
+     * @return List<InsFeeOrders>
+     */
+    @PostMapping("/supplementOrder/selectInsOrdersById/{id}")
+    HttpResult<InsOrdersVo> selectById(@PathVariable String id);
+
+
+}

+ 65 - 2
tenant/organization/src/main/java/com/jzg/organization/controller/ReceivableController.java

@@ -1,5 +1,6 @@
 package com.jzg.organization.controller;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jzg.commons.core.base.BaseController;
@@ -93,6 +94,26 @@ public class ReceivableController {
         return HttpResult.ok(new InsPlyIncomeVO(data, receivablePageIds));
     }
 
+    @PostMapping("getCommissionReceivableTotalAmount")
+    @Operation(summary = "获取私有协议手续费应收费用总金额")
+    public HttpResult<BigDecimal> getCommissionReceivableTotalAmount(@RequestBody ReceivableQueryVo receivableQueryVo){
+        if (StrUtil.isBlank(receivableQueryVo.getQueryType())){
+            receivableQueryVo.setQueryType("2");
+        }
+        // 协议类型 1 平台协议  2 私有协议
+        if (StrUtil.isBlank(receivableQueryVo.getAgreementType())){
+            receivableQueryVo.setAgreementType("2");
+        }
+        HttpResult<Page<InsPlyIncome>> ok = HttpResult.ok(receivableService.getReceivablePage(receivableQueryVo));
+        Page<InsPlyIncome> data = ok.getData();
+        if (null == data || CollUtil.isEmpty(data.getRecords())){
+            return HttpResult.ok(BigDecimal.ZERO);
+        }
+        BigDecimal reduce = data.getRecords().stream().map(income -> StrUtil.isNotBlank(income.getSuperviseCostsPremiums()) ? new BigDecimal(income.getSuperviseCostsPremiums()) : BigDecimal.ZERO)
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+        return HttpResult.ok(reduce);
+    }
+
     @PostMapping("/exportTemplateReceivableList")
     @Operation(summary = "导出模板私有协议手续费")
     public HttpResult<String> exportTemplateReceivableList(){
@@ -136,8 +157,12 @@ public class ReceivableController {
     @PostMapping("getOtherReceivableList")
     @Operation(summary = "获取私有协议跟单费列表")
     public HttpResult<InsPlyIncomeVO> getOtherReceivableList(@RequestBody ReceivableQueryVo receivableQueryVo){
-        receivableQueryVo.setQueryType("2");
-        receivableQueryVo.setAgreementType("2");
+        if (StrUtil.isBlank(receivableQueryVo.getQueryType())){
+            receivableQueryVo.setQueryType("2");
+        }
+        if (StrUtil.isBlank(receivableQueryVo.getAgreementType())) {
+            receivableQueryVo.setAgreementType("2");
+        }
         //return HttpResult.ok(receivableService.getReceivablePage(receivableQueryVo));
         HttpResult<Page<InsPlyIncome>> ok = HttpResult.ok(receivableService.getReceivablePage(receivableQueryVo));
         Page<InsPlyIncome> data = ok.getData();
@@ -145,6 +170,25 @@ public class ReceivableController {
         return HttpResult.ok(new InsPlyIncomeVO(data, receivablePageIds));
     }
 
+    @PostMapping("getOtherReceivableTotalAmount")
+    @Operation(summary = "获取私有协议跟单费应收费用总金额")
+    public HttpResult<BigDecimal> getOtherReceivableTotalAmount(@RequestBody ReceivableQueryVo receivableQueryVo){
+        if (StrUtil.isBlank(receivableQueryVo.getQueryType())){
+            receivableQueryVo.setQueryType("2");
+        }
+        if (StrUtil.isBlank(receivableQueryVo.getAgreementType())) {
+            receivableQueryVo.setAgreementType("2");
+        }
+        HttpResult<Page<InsPlyIncome>> ok = HttpResult.ok(receivableService.getReceivablePage(receivableQueryVo));
+        Page<InsPlyIncome> data = ok.getData();
+        if (null == data || CollUtil.isEmpty(data.getRecords())){
+            return HttpResult.ok(BigDecimal.ZERO);
+        }
+        BigDecimal reduce = data.getRecords().stream().map(income -> StrUtil.isNotBlank(income.getOtherCostsPremiums()) ? new BigDecimal(income.getOtherCostsPremiums()) : BigDecimal.ZERO)
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+        return HttpResult.ok(reduce);
+    }
+
     @PostMapping("getJyCommissionReceivableList")
     @Operation(summary = "获取私有协议驾意险手续费列表")
     public HttpResult<InsPlyIncomeVO> getJyCommissionReceivableList(@RequestBody ReceivableQueryVo receivableQueryVo){
@@ -326,6 +370,25 @@ public class ReceivableController {
         return HttpResult.ok(new InsPlyIncomeVO(data, receivablePageIds));
     }
 
+    @PostMapping("/getPlatFormReceivableTotalAmount")
+    @Operation(summary = "获取平台协议总金额")
+    public HttpResult<BigDecimal> getPlatFormReceivableTotalAmount(@RequestBody ReceivableQueryVo receivableQueryVo){
+        if (StrUtil.isBlank(receivableQueryVo.getQueryType())){
+            receivableQueryVo.setQueryType("1");
+        }
+        // 协议类型 1 平台协议  2 私有协议
+        if (StrUtil.isBlank(receivableQueryVo.getAgreementType())){
+            receivableQueryVo.setAgreementType("1");
+        }
+        Page<InsPlyIncome> data = receivableService.getPlatFormReceivableList(receivableQueryVo);
+        if (null == data || CollUtil.isEmpty(data.getRecords())){
+            return HttpResult.ok(BigDecimal.ZERO);
+        }
+        BigDecimal reduce = data.getRecords().stream().map(income -> null != income.getInsFeeOrders().getTotalReceivablePremium() ? income.getInsFeeOrders().getTotalReceivablePremium() : BigDecimal.ZERO)
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+        return HttpResult.ok(reduce);
+    }
+
     @PostMapping("/exportTemplatePlatFormReceivable")
     @Operation(summary = "导出平台协议模板")
     public HttpResult exportTemplatePlatFormReceivable() throws IOException {

+ 126 - 14
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -23,12 +23,14 @@ import com.jzg.commons.entity.po.EsmInsCompany;
 import com.jzg.commons.entity.po.InsFeeOrders;
 import com.jzg.commons.entity.po.PtlAgreement;
 import com.jzg.commons.entity.po.SysUploadFiles;
+import com.jzg.commons.entity.quote.vo.orders.InsOrdersVo;
 import com.jzg.commons.exception.ServiceException;
 import com.jzg.commons.exception.SystemException;
 import com.jzg.commons.util.*;
 import com.jzg.commons.util.idgen.IdGenerate;
 import com.jzg.organization.client.EsmInsCompanyClient;
 import com.jzg.organization.client.InsFeeOrdersClient;
+import com.jzg.organization.client.InsOrdersClient;
 import com.jzg.organization.excel.listener.*;
 import com.jzg.organization.mapper.*;
 import com.jzg.organization.service.ReceivableService;
@@ -107,6 +109,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
 
     @Autowired
     private InsFeeOrdersClient insFeeOrdersClient;
+    @Autowired
+    private InsOrdersClient insOrdersClient;
 
     @Value("${upload.file.path}")
     private String uploadPath;
@@ -1067,6 +1071,28 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 continue;
             }
 
+            // 查询订单
+            HttpResult<InsOrdersVo> insOrdersVoHttpResult = insOrdersClient.selectById(vo.getOrderNo());
+            InsOrdersVo data = insOrdersVoHttpResult.getData();
+            if (null == data){
+                failedNumber++;
+                vo.setErrorMessage("订单号不存在");
+                failedExcel.add(vo);
+                continue;
+            }
+
+            // 查询数据库中是否已存在该协议
+            PtlAgreement ptlAgreement = ptlAgreementMapper.selectOne(new LambdaQueryWrapper<PtlAgreement>()
+                    .eq(PtlAgreement::getId, data.getAgreementId()));
+
+            // 数据库不存在 → 直接失败
+            if (Objects.isNull(ptlAgreement) || !ptlAgreement.getAgreementType().toString().equals(vo.getAgreementType())) {
+                failedNumber++;
+                vo.setErrorMessage("协议编码在协议中不存在");
+                failedExcel.add(vo);
+                continue;
+            }
+
             // 封装修改数据
             InsPlyIncome insPlyIncome = new InsPlyIncome();
             insPlyIncome.setId(existIncome.getId());
@@ -1082,6 +1108,11 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             insPlyIncome.setJyOtherCostsProportion(vo.getJyOtherCostsProportion());
             insPlyIncome.setContactPerson(vo.getDockingPerson());
             insPlyIncome.setContactPersonPhone(vo.getDockingPersonPhone());
+            // 协议编号
+            insPlyIncome.setAgreementId(ptlAgreement.getId());
+            insPlyIncome.setAgreementName(ptlAgreement.getAgreementName());
+            insPlyIncome.setAgreementType(ptlAgreement.getAgreementType().toString());
+            insPlyIncome.setSystemCode(ptlAgreement.getSystemCode());
 
             // 加入修改列表
             updateExcel.add(insPlyIncome);
@@ -1188,13 +1219,22 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 continue;
             }
 
+            // 查询订单
+            HttpResult<InsOrdersVo> insOrdersVoHttpResult = insOrdersClient.selectById(vo.getOrderNo());
+            InsOrdersVo data = insOrdersVoHttpResult.getData();
+            if (null == data){
+                failedNumber++;
+                vo.setErrorMessage("订单号不存在");
+                failedExcel.add(vo);
+                continue;
+            }
+
             // 查询数据库中是否已存在该协议
             PtlAgreement ptlAgreement = ptlAgreementMapper.selectOne(new LambdaQueryWrapper<PtlAgreement>()
-                    .eq(PtlAgreement::getAgreementCode, vo.getAgreementCode())
-                    .eq(PtlAgreement::getAgreementType, vo.getAgreementType()));
+                    .eq(PtlAgreement::getId, data.getAgreementId()));
 
             // 数据库不存在 → 直接失败
-            if (Objects.isNull(ptlAgreement)) {
+            if (Objects.isNull(ptlAgreement) || !ptlAgreement.getAgreementType().toString().equals(vo.getAgreementType())) {
                 failedNumber++;
                 vo.setErrorMessage("协议编码在协议中不存在");
                 failedExcel.add(vo);
@@ -1225,6 +1265,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             insPlyIncome.setAgreementId(ptlAgreement.getId());
             insPlyIncome.setAgreementName(ptlAgreement.getAgreementName());
             insPlyIncome.setAgreementType(ptlAgreement.getAgreementType().toString());
+            insPlyIncome.setSystemCode(ptlAgreement.getSystemCode());
             // 险种编号
             insPlyIncome.setProductId(vo.getProductId());
             // 险种名称
@@ -1462,10 +1503,21 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 continue;
             }
 
-            //匹配协议号
+            // 查询订单
+            HttpResult<InsOrdersVo> insOrdersVoHttpResult = insOrdersClient.selectById(vo.getOrderNo());
+            InsOrdersVo data = insOrdersVoHttpResult.getData();
+            if (null == data){
+                failedNumber++;
+                vo.setErrorMessage("订单号不存在");
+                failedExcel.add(vo);
+                continue;
+            }
+
+            // 查询数据库中是否已存在该协议
             PtlAgreement ptlAgreement = ptlAgreementMapper.selectOne(new LambdaQueryWrapper<PtlAgreement>()
-                    .eq(PtlAgreement::getAgreementCode, vo.getAgreementCode()));
-            if (Objects.isNull(ptlAgreement)) {
+                    .eq(PtlAgreement::getId, data.getAgreementId()));
+
+            if (Objects.isNull(ptlAgreement) || !ptlAgreement.getAgreementType().toString().equals(vo.getAgreementType())) {
                 failedNumber++;
                 vo.setErrorMessage("匹配协议编号失败");
                 failedExcel.add(vo);
@@ -1512,13 +1564,17 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             insPlyIncome.setCompanyId(matchCompany.getId());
             insPlyIncome.setCompanyName(matchCompany.getName());
 //            insPlyIncome.setSigningTime(signDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-            insPlyIncome.setAgreementId(ptlAgreement.getId());
             insPlyIncome.setLicenseNo(vo.getLicenseNo());
             insPlyIncome.setJqPolicyNo(vo.getJqPolicyNo());
             insPlyIncome.setJqPremium(vo.getJqPremium().toString());
             insPlyIncome.setJqSuperviseCostsProportion(vo.getJqSuperviseRatio().toString());
             insPlyIncome.setContactPerson(vo.getContactPerson());
             insPlyIncome.setContactPersonPhone(vo.getContactPersonPhone());
+            // 协议编号
+            insPlyIncome.setAgreementId(ptlAgreement.getId());
+            insPlyIncome.setAgreementName(ptlAgreement.getAgreementName());
+            insPlyIncome.setAgreementType(ptlAgreement.getAgreementType().toString());
+            insPlyIncome.setSystemCode(ptlAgreement.getSystemCode());
             successExcel.add(insPlyIncome);
         }
 
@@ -1558,10 +1614,20 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 continue;
             }
 
-            //匹配协议号
+            // 查询订单
+            HttpResult<InsOrdersVo> insOrdersVoHttpResult = insOrdersClient.selectById(vo.getOrderNo());
+            InsOrdersVo data = insOrdersVoHttpResult.getData();
+            if (null == data){
+                failedNumber++;
+                vo.setErrorMessage("订单号不存在");
+                failedExcel.add(vo);
+                continue;
+            }
+
+            // 查询数据库中是否已存在该协议
             PtlAgreement ptlAgreement = ptlAgreementMapper.selectOne(new LambdaQueryWrapper<PtlAgreement>()
-                    .eq(PtlAgreement::getAgreementCode, vo.getAgreementCode()));
-            if (Objects.isNull(ptlAgreement)) {
+                    .eq(PtlAgreement::getId, data.getAgreementId()));
+            if (Objects.isNull(ptlAgreement) || !ptlAgreement.getAgreementType().toString().equals(vo.getAgreementType())) {
                 failedNumber++;
                 vo.setErrorMessage("匹配协议编号失败");
                 failedExcel.add(vo);
@@ -1607,13 +1673,17 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             insPlyIncome.setId(IdGenerate.nextId());
             insPlyIncome.setCompanyId(matchCompany.getId());
 //            insPlyIncome.setSigningTime(signDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-            insPlyIncome.setAgreementId(ptlAgreement.getId());
             insPlyIncome.setLicenseNo(vo.getLicenseNo());
             insPlyIncome.setJqPolicyNo(vo.getJqPolicyNo());
             insPlyIncome.setJqPremium(vo.getJqPremium().toString());
             insPlyIncome.setJqOtherCostsProportion(vo.getJqOtherRatio().toString());
             insPlyIncome.setContactPerson(vo.getContactPerson());
             insPlyIncome.setContactPersonPhone(vo.getContactPersonPhone());
+            // 协议编号
+            insPlyIncome.setAgreementId(ptlAgreement.getId());
+            insPlyIncome.setAgreementName(ptlAgreement.getAgreementName());
+            insPlyIncome.setAgreementType(ptlAgreement.getAgreementType().toString());
+            insPlyIncome.setSystemCode(ptlAgreement.getSystemCode());
             successExcel.add(insPlyIncome);
         }
 
@@ -1678,6 +1748,28 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 continue;
             }
 
+            // 查询订单
+            HttpResult<InsOrdersVo> insOrdersVoHttpResult = insOrdersClient.selectById(vo.getOrderNo());
+            InsOrdersVo data = insOrdersVoHttpResult.getData();
+            if (null == data){
+                failedNumber++;
+                vo.setErrorMessage("订单号不存在");
+                failedExcel.add(vo);
+                continue;
+            }
+
+            // 查询数据库中是否已存在该协议
+            PtlAgreement ptlAgreement = ptlAgreementMapper.selectOne(new LambdaQueryWrapper<PtlAgreement>()
+                    .eq(PtlAgreement::getId, data.getAgreementId()));
+
+            // 数据库不存在 → 直接失败
+            if (Objects.isNull(ptlAgreement) || !ptlAgreement.getAgreementType().toString().equals(vo.getAgreementType())) {
+                failedNumber++;
+                vo.setErrorMessage("协议编码在协议中不存在");
+                failedExcel.add(vo);
+                continue;
+            }
+
             // 3. 查询数据库中是否已存在该保单号
             InsPlyIncome existIncome = baseMapper.selectOne(new LambdaQueryWrapper<InsPlyIncome>()
                     .eq(InsPlyIncome::getJqPolicyNo, vo.getJqPolicyNo()));
@@ -1717,6 +1809,11 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             insPlyIncome.setJyOtherCostsProportion(vo.getJyOtherCostsProportion());
             insPlyIncome.setContactPerson(vo.getDockingPerson());
             insPlyIncome.setContactPersonPhone(vo.getDockingPersonPhone());
+            // 协议编号
+            insPlyIncome.setAgreementId(ptlAgreement.getId());
+            insPlyIncome.setAgreementName(ptlAgreement.getAgreementName());
+            insPlyIncome.setAgreementType(ptlAgreement.getAgreementType().toString());
+            insPlyIncome.setSystemCode(ptlAgreement.getSystemCode());
 
             // 加入修改列表
             updateExcel.add(insPlyIncome);
@@ -1772,10 +1869,20 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 continue;
             }
 
-            //匹配协议号
+            // 查询订单
+            HttpResult<InsOrdersVo> insOrdersVoHttpResult = insOrdersClient.selectById(vo.getOrderNo());
+            InsOrdersVo data = insOrdersVoHttpResult.getData();
+            if (null == data){
+                failedNumber++;
+                vo.setErrorMessage("订单号不存在");
+                failedExcel.add(vo);
+                continue;
+            }
+
+            // 查询数据库中是否已存在该协议
             PtlAgreement ptlAgreement = ptlAgreementMapper.selectOne(new LambdaQueryWrapper<PtlAgreement>()
-                    .eq(PtlAgreement::getAgreementCode, vo.getAgreementCode()));
-            if (Objects.isNull(ptlAgreement)) {
+                    .eq(PtlAgreement::getId, data.getAgreementId()));
+            if (Objects.isNull(ptlAgreement) || !ptlAgreement.getAgreementType().toString().equals(vo.getAgreementType())) {
                 failedNumber++;
                 vo.setErrorMessage("匹配协议编号失败");
                 failedExcel.add(vo);
@@ -1829,6 +1936,11 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             insPlyIncome.setJyOtherCostsProportion(vo.getJyOtherRatio().toString());
             insPlyIncome.setContactPerson(vo.getContactPerson());
             insPlyIncome.setContactPersonPhone(vo.getContactPersonPhone());
+            // 协议编号
+            insPlyIncome.setAgreementId(ptlAgreement.getId());
+            insPlyIncome.setAgreementName(ptlAgreement.getAgreementName());
+            insPlyIncome.setAgreementType(ptlAgreement.getAgreementType().toString());
+            insPlyIncome.setSystemCode(ptlAgreement.getSystemCode());
             successExcel.add(insPlyIncome);
         }