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

安盛添加续保、总保额,车辆的实际价 放到 carActualValue 字段

xuqiang 1 месяц назад
Родитель
Сommit
8f5e2f25fa

+ 3 - 2
tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/build/AnShengCrawlerNonContractsBuild.java

@@ -57,7 +57,7 @@ public final class AnShengCrawlerNonContractsBuild {
 
                 AnShengCrawlerNonContractsDTO.Target target = new AnShengCrawlerNonContractsDTO.Target();
                 BeanUtil.copyProperties(contractsDTO.getTargetList().get(0),target);
-                nonContractsDTO.setTargetList(buildNonTargetDTO(contractsDTO.getPolicyPersons(),target));
+                nonContractsDTO.setTargetList(buildNonTargetDTO(contractsDTO.getPolicyPersons(),target,policyBaseDTO.getEngineNo()));
                 nonContractsDTO.setPolicyCoverages(BeanUtil.copyToList(fex.getDtoList(),AnShengCrawlerNonContractsDTO.PolicyCoverage.class));
                 nonContractsDTO.setPolicyPersons(BeanUtil.copyToList(contractsDTO.getPolicyPersons(),AnShengCrawlerNonContractsDTO.PolicyPerson.class));
                 AnShengCrawlerNonContractsDTO.SaleBusinessSource saleBusinessSource = new AnShengCrawlerNonContractsDTO.SaleBusinessSource();
@@ -96,7 +96,7 @@ public final class AnShengCrawlerNonContractsBuild {
     }
 
     public static List<AnShengCrawlerNonContractsDTO.Target> buildNonTargetDTO(List<AnShengCrawlerCalculatePremiumApplyMessage.ContractsDTO.PolicyPersonsDTO> policyPersonsDTOList,
-                                                                                                       AnShengCrawlerNonContractsDTO.Target nonTarget){
+                                                                                                       AnShengCrawlerNonContractsDTO.Target nonTarget,String engineNo){
 
         AnShengCrawlerCalculatePremiumApplyMessage.ContractsDTO.PolicyPersonsDTO  bb = null;
         AnShengCrawlerCalculatePremiumApplyMessage.ContractsDTO.PolicyPersonsDTO  tb = null;
@@ -154,6 +154,7 @@ public final class AnShengCrawlerNonContractsBuild {
         nonTarget.setHomeAddrShow("");
         nonTarget.setGroupCode(null);
         nonTarget.setGroupName(null);
+        nonTarget.setEngineNo(engineNo);
         List<AnShengCrawlerNonContractsDTO.Target> list = new ArrayList<>();
         list.add(nonTarget);
         return list;

+ 21 - 3
tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/build/AnShengCrawlerQuoteResultsVoBuild.java

@@ -4,6 +4,7 @@ package com.jzg.quotation.ansheng.crawler.build;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.jzg.commons.constants.dict.InsOrderStatusEnum;
+import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.quote.vo.KindInfoVo;
 import com.jzg.commons.entity.quote.vo.QuoteVo;
 import com.jzg.commons.entity.quote.vo.RiskInfoVo;
@@ -11,7 +12,9 @@ import com.jzg.commons.entity.quote.vo.aggregated.QuoteResultsVo;
 import com.jzg.commons.util.StringUtils;
 import com.jzg.quotation.ansheng.crawler.constant.enums.DepartmentPlanCode;
 import com.jzg.quotation.ansheng.crawler.entity.response.AnShengCrawlerCalculatePremiumApplyResponse;
+import com.jzg.quotation.ansheng.crawler.entity.response.AnShengCrawlerRenewPolicyResponse;
 import com.jzg.quotation.commons.component.ConversionOfQuoteInformation;
+import com.jzg.quotation.commons.constant.enums.quote.RenewalEnum;
 import lombok.extern.slf4j.Slf4j;
 
 import java.math.BigDecimal;
@@ -37,7 +40,8 @@ public final class AnShengCrawlerQuoteResultsVoBuild {
      * @param calculatePremiumApply 报价响应信息
      * @return 报价返回信息
      */
-    public static QuoteResultsVo buildQuoteResultsVo(final String ordersNo, QuoteVo quoteVo, AnShengCrawlerCalculatePremiumApplyResponse calculatePremiumApply,BigDecimal fcxPrice) {
+    public static QuoteResultsVo buildQuoteResultsVo(final String ordersNo, QuoteVo quoteVo, AnShengCrawlerCalculatePremiumApplyResponse calculatePremiumApply,
+                                                     BigDecimal fcxPrice,BigDecimal carActualValue,AnShengCrawlerRenewPolicyResponse policyResponse) {
         QuoteResultsVo quoteResultsVo = new QuoteResultsVo();
         quoteResultsVo.setOrdersNo(ordersNo);
 
@@ -78,8 +82,9 @@ public final class AnShengCrawlerQuoteResultsVoBuild {
         String totalStr = total.toPlainString();
         costs.setNiPremium(BigDecimal.ZERO.compareTo(fcxPrice) == 0 ? "0" : fcxPrice.toPlainString());
         costs.setSumPremium(totalStr);
-        quoteResultsVo.setScoreVo(buildScoreVo(calculatePremiumApply));
+        quoteResultsVo.setScoreVo(buildScoreVo(calculatePremiumApply,policyResponse));
         quoteResultsVo.setQuoteStatusEnum(InsOrderStatusEnum.WAIT_AUDIT);
+        quoteResultsVo.setCarActualValue(carActualValue);
         return quoteResultsVo;
     }
 
@@ -104,7 +109,7 @@ public final class AnShengCrawlerQuoteResultsVoBuild {
     /**
      * 组装打分ScoreVo
      */
-    private static QuoteResultsVo.ScoreVo buildScoreVo(AnShengCrawlerCalculatePremiumApplyResponse calculatePremiumApply) {
+    private static QuoteResultsVo.ScoreVo buildScoreVo(AnShengCrawlerCalculatePremiumApplyResponse calculatePremiumApply,AnShengCrawlerRenewPolicyResponse policyResponse) {
         QuoteResultsVo.ScoreVo scoreVo = new QuoteResultsVo.ScoreVo();
         JSONArray scoreArray = new JSONArray();
         AnShengCrawlerCalculatePremiumApplyResponse.DataDTO data = calculatePremiumApply.getData();
@@ -112,6 +117,19 @@ public final class AnShengCrawlerQuoteResultsVoBuild {
             scoreVo.setScoreJson(scoreArray);
             return scoreVo;
         }
+        scoreVo.setJqRenewal(String.valueOf(RenewalEnum.Transfer.getCode()));
+        scoreVo.setSyRenewal(String.valueOf(RenewalEnum.Transfer.getCode()));
+        if (HttpResult.ok().getCode() == policyResponse.getCode()){
+            policyResponse.getData().stream().forEach(v ->{
+                if (DepartmentPlanCode.PLAN_105.getCode().equals(v.getPlanCode())){
+                    scoreVo.setJqRenewal(String.valueOf(RenewalEnum.Renewal.getCode()));
+                }
+                if (DepartmentPlanCode.PLAN_109.getCode().equals(v.getPlanCode())){
+                    scoreVo.setSyRenewal(String.valueOf(RenewalEnum.Renewal.getCode()));
+                }
+
+            });
+        }
         // 1. 统一配置:字段key + 取值函数
         record ScoreItem(String scoreKey, Function<AnShengCrawlerCalculatePremiumApplyResponse.DataDTO, String> valueFunc) {}
         List<ScoreItem> itemList = new ArrayList<>();

+ 17 - 0
tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/component/AnShengCrawlerRequestComponent.java

@@ -427,4 +427,21 @@ public class AnShengCrawlerRequestComponent {
                 .map(HttpEntity::getBody)
                 .orElseThrow(() -> new SystemException("程序异常请联系管理员"));
     }
+
+    public AnShengCrawlerRenewPolicyResponse queryRenewPolicy(AnShengCrawlerQueryRenewPolicyRequest queryRenewPolicyRequest, HttpHeaders headers) {
+        MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
+        map.set("information",JSONObject.toJSONString(queryRenewPolicyRequest));
+        ResponseEntity<AnShengCrawlerRenewPolicyResponse> responseEntity = requestComponent.formData(RequestUrl.QUERY_RENEW_POLICY.getRequestUrl(anShengCrawlerProperties.getUrl()), map, AnShengCrawlerRenewPolicyResponse.class, headers);
+        return Optional.ofNullable(responseEntity)
+                .map(HttpEntity::getBody)
+                .orElseThrow(() -> new SystemException("程序异常请联系管理员"));
+    }
+
+    public AnShengCrawlerSearchCheckVehicleCodeResponse searchCheckVehicleCode(HttpHeaders headers) {
+        MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
+        ResponseEntity<AnShengCrawlerSearchCheckVehicleCodeResponse> responseEntity = requestComponent.formData(RequestUrl.SEARCH_CHECK_VEHICLE_CODE.getRequestUrl(anShengCrawlerProperties.getUrl()), map, AnShengCrawlerSearchCheckVehicleCodeResponse.class, headers);
+        return Optional.ofNullable(responseEntity)
+                .map(HttpEntity::getBody)
+                .orElseThrow(() -> new SystemException("程序异常请联系管理员"));
+    }
 }

+ 10 - 1
tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/constant/enums/RequestUrl.java

@@ -66,8 +66,17 @@ public enum RequestUrl implements CrawlerRequestUrlStandard {
     CALCULATE_PREMIUM_NON_APPLY("/portalapi/calculatePremiumNonApply", "非车险计算保费"),
 
     //   非车险计算保费
-    AUTO_RESET_TIME("/portalapi/autoResetTime", "非车险计算保费")
+    AUTO_RESET_TIME("/portalapi/autoResetTime", "非车险计算保费"),
 
+    //   状态查询
+    RENEW_POLICY_CHECK_FOR_CALCULATE("/portalapi/RenewPolicyCheckForCalculate", "状态查询"),
+
+
+    //   续保查询
+    QUERY_RENEW_POLICY("/portalapi/queryRenewPolicy", "续保查询"),
+
+    //   搜索查车码
+    SEARCH_CHECK_VEHICLE_CODE("/portalapi/searchCheckVehicleCode", "搜索查车码"),
 
     ;
 

+ 58 - 0
tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/entity/request/AnShengCrawlerQueryRenewPolicyRequest.java

@@ -0,0 +1,58 @@
+package com.jzg.quotation.ansheng.crawler.entity.request;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.jzg.quotation.ansheng.crawler.entity.response.AnShengCrawlerGetUserDetailResponse;
+import com.jzg.quotation.ansheng.crawler.utils.VehicleCodeEncryptUtil;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@Data
+@AllArgsConstructor
+public class AnShengCrawlerQueryRenewPolicyRequest {
+
+
+    public AnShengCrawlerQueryRenewPolicyRequest(AnShengCrawlerGetUserDetailResponse.DataDTO.AgentDefineDTO userDetailResponse,String licenceCode,String code) {
+        this.checkVehicleCodeSecret = VehicleCodeEncryptUtil.generateCheckVehicleSecret(code,userDetailResponse.getUserId());
+        this.agentCode =  userDetailResponse.getAgentCode();
+        this.departmentCode = userDetailResponse.getDepartmentCode();
+        this.planCode = "109";
+        this.lastPolicyNo = "";
+        this.customerType = "0";
+        this.insurantName = "";
+        this.vehicleLicenceCode = licenceCode;
+        this.engineNo = "";
+        this.vehicleFrameNo = "";
+    }
+
+
+
+    @JsonProperty("checkVehicleCodeSecret")
+    private String checkVehicleCodeSecret;
+
+    @JsonProperty("agentCode")
+    private String agentCode;
+
+    @JsonProperty("departmentCode")
+    private String departmentCode;
+
+    @JsonProperty("planCode")
+    private String planCode;
+
+    @JsonProperty("lastPolicyNo")
+    private String lastPolicyNo;
+
+    @JsonProperty("customerType")
+    private String customerType;
+
+    @JsonProperty("insurantName")
+    private String insurantName;
+
+    @JsonProperty("vehicleLicenceCode")
+    private String vehicleLicenceCode;
+
+    @JsonProperty("engineNo")
+    private String engineNo;
+
+    @JsonProperty("vehicleFrameNo")
+    private String vehicleFrameNo;
+}

+ 76 - 0
tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/entity/response/AnShengCrawlerRenewPolicyResponse.java

@@ -0,0 +1,76 @@
+package com.jzg.quotation.ansheng.crawler.entity.response;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.List;
+
+
+@Data
+public class AnShengCrawlerRenewPolicyResponse {
+
+    @JsonProperty("code")
+    private Integer code;
+
+    @JsonProperty("simpleMessage")
+    private String simpleMessage;
+
+    @JsonProperty("message")
+    private String message;
+
+    @JsonProperty("data")
+    private List<DataDTO> data;
+
+    // ==================== 内部类 ====================
+
+    @Data
+    public static class DataDTO {
+
+        @JsonProperty("insuranceBeginTimeStart")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime insuranceBeginTimeStart;
+
+        @JsonProperty("totalActualPremium")
+        private BigDecimal totalActualPremium;
+
+        @JsonProperty("skeNo")
+        private String skeNo;
+
+        @JsonProperty("policyNo")
+        private String policyNo;
+
+        @JsonProperty("InsuranceBeginTimeEnd")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime insuranceBeginTimeEnd;
+
+        @JsonProperty("canChangeChannel")
+        private String canChangeChannel;
+
+        @JsonProperty("renewType")
+        private String renewType;
+
+        @JsonProperty("appliedName")
+        private String appliedName;
+
+        @JsonProperty("planCode")
+        private String planCode;
+
+        @JsonProperty("vehicleNo")
+        private String vehicleNo;
+
+        @JsonProperty("renewId")
+        private String renewId;
+
+        @JsonProperty("machineNo")
+        private String machineNo;
+
+        @JsonProperty("businessType")
+        private String businessType;
+
+        @JsonProperty("planCodeType")
+        private String planCodeType;
+    }
+}

+ 17 - 0
tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/entity/response/AnShengCrawlerSearchCheckVehicleCodeResponse.java

@@ -0,0 +1,17 @@
+package com.jzg.quotation.ansheng.crawler.entity.response;
+
+
+import lombok.Data;
+
+@Data
+public class AnShengCrawlerSearchCheckVehicleCodeResponse {
+
+    private int code;
+
+    private String simpleMessage;
+
+    private String message;
+
+    private String data;
+
+}

+ 17 - 3
tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/service/impl/AnShengCrawlerRequestImpl.java

@@ -120,7 +120,6 @@ public class AnShengCrawlerRequestImpl implements AnShengCrawlerRequest {
         if (StringUtils.equals("1",quoteVo.getCarInfoVo().getEnergyTypeCode())) {
             departmentPlanCode = DepartmentPlanCode.PLAN_113;
         }
-
         AnShengCrawlerInsureAddRequest anShengCrawlerInsureAddRequest = new AnShengCrawlerInsureAddRequest("1", userDetailResponse.getDepartmentCode(), departmentPlanCode.getCode(), departmentPlanCode.getProductCode());
         AnShengCrawlerInsureAddResponse.DataDTO insureAdd = anShengCrawlerRequestComponent.insureAdd(anShengCrawlerInsureAddRequest, httpHeaders);
         String checkVehicleCode = insureAdd.getCheckVehicleCode();
@@ -213,10 +212,25 @@ public class AnShengCrawlerRequestImpl implements AnShengCrawlerRequest {
             anShengCrawlerCacheComponent.cacheQuoteRequest(ordersNo, autoSpecialPromiseRequest);
         }
         anShengCrawlerOrderService.saveRecordingTime(ordersNo,quoteVo.getCarInfoVo().getLicenseNo());
+        AnShengCrawlerSearchCheckVehicleCodeResponse vehicleCodeResponse = anShengCrawlerRequestComponent.searchCheckVehicleCode(httpHeaders);
+        AnShengCrawlerQueryRenewPolicyRequest queryRenewPolicyRequest = new AnShengCrawlerQueryRenewPolicyRequest(userDetailResponse, quoteVo.getCarInfoVo().getLicenseNo(),vehicleCodeResponse.getData());
+        AnShengCrawlerRenewPolicyResponse policyResponse = anShengCrawlerRequestComponent.queryRenewPolicy(queryRenewPolicyRequest,httpHeaders);
         // 构造返回参数
-        return AnShengCrawlerQuoteResultsVoBuild.buildQuoteResultsVo(ordersNo, quoteVo, calculatePremiumApply, anShengCrawlerNonInsuranceResponse.getFcxPrice());
+        return AnShengCrawlerQuoteResultsVoBuild.buildQuoteResultsVo(ordersNo, quoteVo, calculatePremiumApply, anShengCrawlerNonInsuranceResponse.getFcxPrice(),getCarActualValue(crawlerCalculatePremiumApply),policyResponse);
     }
 
+    public BigDecimal getCarActualValue(AnShengCrawlerCalculatePremiumApplyMessage req) {
+        return req.getContracts().stream()
+                .filter(c -> DepartmentPlanCode.PLAN_105.getCode().equals(
+                        c.getPolicyBase().getPlanCode()))
+                .findFirst()
+                .map(AnShengCrawlerCalculatePremiumApplyMessage.ContractsDTO::getTargetList)
+                .filter(CollectionUtils::isNotEmpty)
+                .map(list -> list.get(0))
+                .map(AnShengCrawlerCalculatePremiumApplyMessage.ContractsDTO.TargetListDTO::getCustomerNegotiatePrice)
+                .map(BigDecimal::new)
+                .orElse(BigDecimal.ZERO);
+    }
 
     public boolean verifyQuotationTime(AnShengCrawlerCalculatePremiumApplyResponse response, AnShengCrawlerCalculatePremiumApplyMessage request, QuoteVo quoteVo) {
         if (isInvalidInput(response, request)) {
@@ -388,7 +402,7 @@ public class AnShengCrawlerRequestImpl implements AnShengCrawlerRequest {
         if (hasNonAutoContracts(applicationRequest)) {
             stringObjectMap = AnShengCrawlerNonContractsBuild.build(applicationRequest, stringObjectMap);
         }
-        log.info("安盛核保参数:{}", JSONObject.toJSONString(applicationRequest));
+        log.info("安盛核保参数:{}", JSONObject.toJSONString(stringObjectMap));
         // 核保
         AnShengCrawlerApplyApplicationResponse applyApplicationResponse = anShengCrawlerRequestComponent.applyApplication(stringObjectMap, httpHeaders);
         // 投保订单号保存

+ 78 - 0
tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/utils/VehicleCodeEncryptUtil.java

@@ -0,0 +1,78 @@
+package com.jzg.quotation.ansheng.crawler.utils;
+
+import lombok.extern.slf4j.Slf4j;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.SecretKeySpec;
+import java.nio.charset.StandardCharsets;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.Base64;
+
+
+@Slf4j
+public class VehicleCodeEncryptUtil {
+
+    /**
+     * 生成AES动态密钥
+     * @return 密钥字符串
+     */
+    public static String getAesKeyStr() {
+        String date = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
+        return "TPAICAST" + date;
+    }
+
+    /**
+     * 加密方法
+     * @param rawText 原始明文 = checkVehicleCode + userId
+     * @return Base64 AES密文
+     * @throws Exception 加密异常
+     */
+    public static String encrypt(String rawText) throws Exception {
+        String keyStr = getAesKeyStr();
+        byte[] keyBytes = keyStr.getBytes(StandardCharsets.UTF_8);
+        SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");
+        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
+        cipher.init(Cipher.ENCRYPT_MODE, keySpec);
+        byte[] rawBytes = rawText.getBytes(StandardCharsets.UTF_8);
+        byte[] encryptBytes = cipher.doFinal(rawBytes);
+        return Base64.getEncoder().encodeToString(encryptBytes);
+    }
+
+    /**
+     * 解密方法(配套,用于校验)
+     * @param cipherText base64密文
+     * @return 原始明文
+     * @throws Exception
+     */
+    public static String decrypt(String cipherText) throws Exception {
+        String keyStr = getAesKeyStr();
+        byte[] keyBytes = keyStr.getBytes(StandardCharsets.UTF_8);
+        SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");
+        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
+        cipher.init(Cipher.DECRYPT_MODE, keySpec);
+        byte[] cipherBytes = Base64.getDecoder().decode(cipherText);
+        byte[] rawBytes = cipher.doFinal(cipherBytes);
+        return new String(rawBytes, StandardCharsets.UTF_8);
+    }
+
+
+    /**
+     * 对外生成 checkVehicleCodeSecret
+     * @param checkVehicleCode 车辆校验编码
+     * @param userId 当前登录用户ID
+     * @return 加密密文
+     * @throws Exception
+     */
+    public static String generateCheckVehicleSecret(String checkVehicleCode, String userId) {
+        try {
+            String raw = checkVehicleCode + userId;
+            return encrypt(raw);
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error("加密错误");
+        }
+        return "";
+    }
+
+}