Explorar el Código

修改险种信息判断逻辑

wks hace 2 años
padre
commit
a30409b74a

+ 12 - 0
src/main/java/com/ydtech/constants/enums/InsurKind.java

@@ -3,6 +3,9 @@ package com.ydtech.constants.enums;
 import lombok.AllArgsConstructor;
 import lombok.Getter;
 
+import java.util.Arrays;
+import java.util.List;
+
 
 /**
  * @description: 险种   保险种类
@@ -36,4 +39,13 @@ public enum InsurKind {
 
     private final String desc;
 
+    /**
+     * 主险排除车损
+     *
+     * @return 排除车损的信息
+     */
+    public static List<String> removalOfVehicleDamage() {
+        return Arrays.asList(B.getCode(), D3.getCode(), D4.getCode());
+    }
+
 }

+ 38 - 0
src/main/java/com/ydtech/constants/enums/InsuranceRisk.java

@@ -1,6 +1,9 @@
 package com.ydtech.constants.enums;
 
 
+import com.ydtech.constants.enums.dict.agreement.ProductsType;
+import com.ydtech.modules.ins.model.vo.KindInfoVo;
+import com.ydtech.modules.ins.model.vo.RiskInfoVo;
 import lombok.AllArgsConstructor;
 import lombok.Getter;
 
@@ -45,4 +48,39 @@ public enum InsuranceRisk {
 
     private final String shortName;
 
+
+    /**
+     * 判断险种信息
+     *
+     * @param kinds 险种信息
+     * @param risks 商业险险种信息
+     * @return
+     */
+    public static ProductsType determineInsuranceInformation(List<KindInfoVo> kinds, List<RiskInfoVo> risks) {
+        boolean haveCarDamageKind = false;//是否含车损
+        boolean haveBusiKind = false;//是否含车损外的商业险种
+        for (KindInfoVo kindInfoVo : kinds) {
+            String code = kindInfoVo.getKindCode();
+            // 车损
+            if (InsurKind.A.getCode().equalsIgnoreCase(code)) {
+                haveCarDamageKind = true;
+            }
+            if (InsurKind.removalOfVehicleDamage().contains(code)) {
+                haveBusiKind = true;
+            }
+        }
+        if (risks.size() == 1 && InsuranceRisk.TRAFFIC.getCode().equals(risks.get(0).getRiskCode())) {
+            return ProductsType.PT_0330;//单交
+        } else if (risks.size() == 1 && !haveCarDamageKind && haveBusiKind) {
+            return ProductsType.PT_034002;//单三
+        } else if (risks.size() == 1) {
+            return ProductsType.PT_034001;//单商
+        } else if (risks.size() == 2 && !haveCarDamageKind && haveBusiKind) {
+            return ProductsType.PT_0330034002;//交三
+        } else {
+            return ProductsType.PT_0330034001;//交商
+        }
+    }
+
+
 }

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

@@ -107,7 +107,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
     @Override
     public void verificationCostFactor(InsAreaCompany insAreaCompany,InsOrders insOrders){
 
-        List<AgreementProductCosts> agreementProductCosts = ptlAgreementProductCostsNewService.costsGetList(insAreaCompany.getAgreementId(),insOrders.getProductid());
+        List<AgreementProductCosts> agreementProductCosts = ptlAgreementProductCostsNewService.costsGetList(insAreaCompany.getAgreementId(),insAreaCompany.getProductid());
 //        if(agreementProductCosts == null || agreementProductCosts.size() == 0){
 //            throw new SystemException("协议费用因子为空");
 //        }

+ 50 - 69
src/main/java/com/ydtech/modules/order/aop/aspect/QuoteVerificationAspect.java

@@ -6,7 +6,6 @@ import com.ydtech.constants.enums.dict.InsOrderStatusEnum;
 import com.ydtech.constants.enums.dict.agreement.ProductsType;
 import com.ydtech.constants.sys.SystemConstant;
 import com.ydtech.core.page.HttpResult;
-import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.model.SysUser;
 import com.ydtech.modules.admin.model.SysUserRole;
 import com.ydtech.modules.admin.service.SysUserRoleService;
@@ -80,11 +79,12 @@ public class QuoteVerificationAspect {
     private final SysUserService sysUserService;
 
     @AfterReturning(pointcut = "@annotation(com.ydtech.modules.order.aop.QuoteVerification)", returning = "result")
-    public void doAfter(HttpResult<QuoteRespVo> result){
+    public void doAfter(HttpResult<QuoteRespVo> result) {
         //计算费用因子
-        if(result.getCode() == 200) {
+        if (result.getCode() == 200) {
             InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(result.getData().getCompanyId());
-            InsAreaCompanyAccidentalDriving insAreaCompanyAccidentalDriving = insAreaCompanyAccidentalDrivingService.getByCompanyId(insAreaCompany.getId());
+            InsAreaCompanyAccidentalDriving insAreaCompanyAccidentalDriving =
+                    insAreaCompanyAccidentalDrivingService.getByCompanyId(insAreaCompany.getId());
             insAreaCompany.setAccidentalDriving(insAreaCompanyAccidentalDriving);
             InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
 
@@ -108,7 +108,7 @@ public class QuoteVerificationAspect {
                 log.debug("费用因子异常消息:" + ignored.toString());
                 log.debug("费用因子异常消息:" + ignored.getMessage());
                 //打印异常堆栈信息
-                for(StackTraceElement stackTraceElement : ignored.getStackTrace()){
+                for (StackTraceElement stackTraceElement : ignored.getStackTrace()) {
                     log.debug(stackTraceElement.toString());
                 }
             }
@@ -126,49 +126,28 @@ public class QuoteVerificationAspect {
                 String deptId = ((BaseQuoteVo<?>) arg).getDeptId();
                 String userId = ((BaseQuoteVo<?>) arg).getUserId();
                 //待客录单传入userId
-                if(StringUtils.isNotEmpty(userId)){
-                     //通过用户id查询所在的机构
+                if (StringUtils.isNotEmpty(userId)) {
+                    //通过用户id查询所在的机构
                     SysUser user = sysUserService.getById(userId);
-                    deptId=user.getDeptId();
-                }else{
+                    deptId = user.getDeptId();
+                } else {
                     // 判断协议是否可以报价(代客录单时,机构需要传过来 没传为空时,为车险录单进来的 直接取登录用户机构即可)
                     //if (StringUtils.isEmpty(deptId)) {
-                        deptId = new BaseController().getDeptId();
+                    deptId = new BaseController().getDeptId();
                     //}
                     userId = new BaseController().getUserId();
                 }
                 //税源查询
                 BaseQuoteInfoVo quoteInfo = insOrdersComponents.getQuoteInfo(orderno, agreementId);
-                String productid ;
+
                 List<KindInfoVo> kinds = quoteInfo.getKindList();
                 List<RiskInfoVo> risks = quoteInfo.getRiskList();
 
-                boolean haveCarDamageKind = false;//是否含车损
-                boolean haveBusiKind = false;//是否含车损外的商业险种
-                for (KindInfoVo kindInfoVo : kinds) {
-                    String code = kindInfoVo.getKindCode();
-                    // 车损
-                    if ("A".equalsIgnoreCase(code)) {
-                        haveCarDamageKind = true;
-                    }
-                    if ("B,D3,D4,".contains(code + ",")) {
-                        haveBusiKind = true;
-                    }
-                }
-                if (risks.size() == 1 && InsuranceRisk.TRAFFIC.getCode().equals(risks.get(0).getRiskCode())) {
-                    productid = ProductsType.PT_0330.getCode();//单交
-                } else if (risks.size() == 1 && !haveCarDamageKind && haveBusiKind) {
-                    productid = ProductsType.PT_034002.getCode();//单三
-                } else if (risks.size() == 1) {
-                    productid = ProductsType.PT_034001.getCode();//单商
-                } else if (risks.size() == 2 && !haveCarDamageKind && haveBusiKind) {
-                    productid = ProductsType.PT_0330034002.getCode();//交三
-                } else {
-                    productid = ProductsType.PT_0330034001.getCode();//交商
-                }
+                ProductsType insuranceRisk = InsuranceRisk.determineInsuranceInformation(kinds, risks);
 
-                String taxAgreementId = taxSourceService.getAgreementId(deptId, userId, companyId, quoteInfo.getCarInfo().getLicenseNo(), quoteInfo.getCarInfo().getEnginedesc(), productid);
-                if(!"".equals(taxAgreementId)){
+                String taxAgreementId = taxSourceService.getAgreementId(deptId, userId, companyId, quoteInfo.getCarInfo().getLicenseNo(),
+                        quoteInfo.getCarInfo().getEnginedesc(), insuranceRisk.getCode());
+                if (!"".equals(taxAgreementId)) {
                     ((BaseQuoteVo<?>) arg).setAgreementId(taxAgreementId);
                 }
 
@@ -184,12 +163,12 @@ public class QuoteVerificationAspect {
     }
 
     /**
-     *  @version
-     *  @author: hxl
-     *  @Date: 2024/4/27 15:18
-     *  @Description: 添加报价接口的报价失败状态的后置通知
+     * @version
+     * @author: hxl
+     * @Date: 2024/4/27 15:18
+     * @Description: 添加报价接口的报价失败状态的后置通知
      */
-   // @AfterReturning(value="@annotation(com.ydtech.modules.order.aop.QuoteVerification)", returning="response")
+    // @AfterReturning(value="@annotation(com.ydtech.modules.order.aop.QuoteVerification)", returning="response")
     public void after(JoinPoint point, HttpResult response) {
         Object[] args = point.getArgs();
         if (response.getCode() != 200) {
@@ -204,11 +183,12 @@ public class QuoteVerificationAspect {
             }
         }
     }
+
     /**
-     *  @version
-     *  @author: hxl
-     *  @Date: 2024/4/27 16:54
-     *  @Description: 添加报价接口的报价失败状态的异常通知
+     * @version
+     * @author: hxl
+     * @Date: 2024/4/27 16:54
+     * @Description: 添加报价接口的报价失败状态的异常通知
      */
     //@AfterThrowing(pointcut="@annotation(com.ydtech.modules.order.aop.QuoteVerification)", throwing="ex")
     public void handleException(JoinPoint point, Exception ex) {
@@ -224,6 +204,7 @@ public class QuoteVerificationAspect {
             }
         }
     }
+
     public void insertInsAreaCompany(String companyId, String orderno, String agreementId) {
         EsmInsCompany esmInsCompany = esmInsCompanyService.getById(companyId);
         //保存订单信息
@@ -239,29 +220,29 @@ public class QuoteVerificationAspect {
     }
 
 
-   /**
-    *  @version
-    *  @author: hxl
-    *  @Date: 2024/5/10 15:38
-    *  @Description:   后置处理器更新子订单的险种类型
-    */
-   @AfterReturning(pointcut = "@annotation(com.ydtech.modules.order.aop.QuoteVerification)", returning = "result")
-     public void afterUpdatePruduct(HttpResult<QuoteRespVo> result) {
-       //计算费用因子
-       if(result.getCode() == 200) {
-           InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(result.getData().getCompanyId());
-           InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
-           //通过主订单的信息判断
-           List<RiskInfoVo> risks = insOrders.getRisk().toJavaList(RiskInfoVo.class);
-           List<KindInfoVo> kinds = insOrders.getKing().toJavaList(KindInfoVo.class);
-           //获取订单的险种信息
-           insOrders.productInformation(risks, kinds);
-           String product = insOrders.getProduct();
-           String productid = insOrders.getProductid();
-           insAreaCompany.setProduct(product);
-           insAreaCompany.setProductid(productid);
-           //更新子订单的险种信息
-           insAreaCompanyService.updateById(insAreaCompany);
-       }
+    /**
+     * @version
+     * @author: hxl
+     * @Date: 2024/5/10 15:38
+     * @Description: 后置处理器更新子订单的险种类型
+     */
+    @AfterReturning(pointcut = "@annotation(com.ydtech.modules.order.aop.QuoteVerification)", returning = "result")
+    public void afterUpdatePruduct(HttpResult<QuoteRespVo> result) {
+        //计算费用因子
+        if (result.getCode() == 200) {
+            InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(result.getData().getCompanyId());
+            InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
+            //通过主订单的信息判断
+            List<RiskInfoVo> risks = insOrders.getRisk().toJavaList(RiskInfoVo.class);
+            List<KindInfoVo> kinds = insOrders.getKing().toJavaList(KindInfoVo.class);
+            //获取订单的险种信息
+            insOrders.productInformation(risks, kinds);
+            String product = insOrders.getProduct();
+            String productid = insOrders.getProductid();
+            insAreaCompany.setProduct(product);
+            insAreaCompany.setProductid(productid);
+            //更新子订单的险种信息
+            insAreaCompanyService.updateById(insAreaCompany);
+        }
     }
 }

+ 2 - 27
src/main/java/com/ydtech/modules/order/entity/InsOrders.java

@@ -41,7 +41,7 @@ public class InsOrders implements Serializable {
     /**
      * 订单号
      */
-    @TableId(value = "orderno",type = IdType.AUTO)
+    @TableId(value = "orderno", type = IdType.AUTO)
     private String orderno;
 
     /**
@@ -80,7 +80,6 @@ public class InsOrders implements Serializable {
     private String userid;
 
 
-
     /**
      * 代客录单时操作员ID
      */
@@ -253,7 +252,6 @@ public class InsOrders implements Serializable {
     private LocalDateTime payDate;   //支付时间
 
 
-
     public InsOrders(SysUser user, SysDept dept, BaseQuoteInfoVo quoteInfoVo) {
         // 2. 组装订单
         this.setQuoteno(String.valueOf(quoteInfoVo.getQuoteno()));
@@ -336,30 +334,7 @@ public class InsOrders implements Serializable {
          * 交商:0330034001
          *
          */
-        ProductsType productsType;
-        boolean haveCarDamageKind = false;//是否含车损
-        boolean haveBusiKind = false;//是否含车损外的商业险种
-        for (KindInfoVo kindInfoVo : kinds) {
-            String code = kindInfoVo.getKindCode();
-            // 车损
-            if ("A".equalsIgnoreCase(code)) {
-                haveCarDamageKind = true;
-            }
-            if ("B,D3,D4,".contains(code + ",")) {
-                haveBusiKind = true;
-            }
-        }
-        if (risks.size() == 1 && InsuranceRisk.TRAFFIC.getCode().equals(risks.get(0).getRiskCode())) {
-            productsType = ProductsType.PT_0330;//单交
-        } else if (risks.size() == 1 && !haveCarDamageKind && haveBusiKind) {
-            productsType = ProductsType.PT_034002;//单三
-        } else if (risks.size() == 1) {
-            productsType = ProductsType.PT_034001;//单商
-        } else if (risks.size() == 2 && !haveCarDamageKind && haveBusiKind) {
-            productsType = ProductsType.PT_0330034002;//交三
-        } else {
-            productsType = ProductsType.PT_0330034001;//交商
-        }
+        ProductsType productsType = InsuranceRisk.determineInsuranceInformation(kinds, risks);
         this.setProductid(productsType.getCode());
         this.setProduct(productsType.getDesc());
     }