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

[众安] feat(报价): cacheInputQuery

wlq 1 год назад
Родитель
Сommit
c971fdef23

+ 1 - 0
tenant/insurance/quotation-zhongan/src/main/java/com/jzg/quotation/zhongan/crawler/client/ZhongAnAPI.java

@@ -8,6 +8,7 @@ public enum ZhongAnAPI implements CrawlerRequestUrlStandard {
     QueryPolicyDetail("/policy/policy_detail_controller/query_policy_detail.json", "获取保单详情"),
     QueryPolicyList("/open/bmw/query_controller/query_policy_list.json", "查询保单列表"),
     PremiumTrial("/open/bmw/n/quote_controller/premium_trial.json", "报价接口"),
+    CacheInputQuery("/open/bmw/index_controller/cache_input_query.json", "发起创建保单"),
     CacheCarInfo("/open/bmw/car_controller/cache_car_info.json", "缓存保单数据"),
     QueryCarInfo("/open/bmw/car_controller/query_car_info.json", "查询车信息"),
 

+ 59 - 0
tenant/insurance/quotation-zhongan/src/main/java/com/jzg/quotation/zhongan/crawler/model/result/ZhongAnCacheInputQueryParam.java

@@ -0,0 +1,59 @@
+package com.jzg.quotation.zhongan.crawler.model.result;
+
+import com.jzg.quotation.commons.utils.UnknownFieldEntity;
+import lombok.Getter;
+import lombok.Setter;
+
+@Setter
+@Getter
+public class ZhongAnCacheInputQueryParam extends UnknownFieldEntity {
+    /**
+     * 投保地点
+     */
+    private String insurePlace;
+
+    /**
+     * 投保地点代码
+     */
+    private String insurePlaceCode;
+
+    /**
+     * 第三方机构代码(可能为空)
+     */
+    private String thirdOrgCode;
+
+    /**
+     * 车辆牌照号
+     */
+    private String licenseNo;
+
+    /**
+     * 分支机构代码(可能为空)
+     */
+    private String branchCode;
+
+    /**
+     * 是否开启续保标志(0-否,1-是,此处为0)
+     */
+    private String isOpenRenewalFlag;
+
+    /**
+     * 流程ID
+     */
+    private String flowId;
+
+    /**
+     * 页面路径
+     */
+    private String page;
+
+    /**
+     * 未知参数 i 的值
+     */
+    private String i;
+
+    /**
+     * 标志位(此处为0)
+     */
+    private String flag;
+}

+ 13 - 0
tenant/insurance/quotation-zhongan/src/main/java/com/jzg/quotation/zhongan/crawler/model/result/ZhongAnCacheInputQueryResult.java

@@ -0,0 +1,13 @@
+package com.jzg.quotation.zhongan.crawler.model.result;
+
+import com.jzg.quotation.commons.utils.UnknownFieldEntity;
+import com.jzg.quotation.zhongan.crawler.client.ZhongAnResponse2;
+import lombok.Getter;
+import lombok.Setter;
+
+@Setter
+@Getter
+public class ZhongAnCacheInputQueryResult extends UnknownFieldEntity {
+    public static class Response extends ZhongAnResponse2<ZhongAnCacheInputQueryResult, Object> {
+    }
+}

+ 30 - 1
tenant/insurance/quotation-zhongan/src/main/java/com/jzg/quotation/zhongan/crawler/service/ZhongAnAPIService.java

@@ -168,6 +168,35 @@ public class ZhongAnAPIService {
         return response.getValue();
     }
 
+    /**
+     * 发起创建保险单
+     *
+     * @param token
+     * @param flowId
+     * @param zhongAnCacheInputQueryParam
+     * @return
+     */
+    public ZhongAnCacheInputQueryResult cacheInputQuery(String token, String flowId, ZhongAnCacheInputQueryParam zhongAnCacheInputQueryParam) {
+        HttpHeaders headers = new HttpHeaders();
+        headers.add("Cookie", token);
+
+        MultiValueMap<String, String> param  = new LinkedMultiValueMap<>();
+        param.add("insurePlaceCode", zhongAnCacheInputQueryParam.getInsurePlaceCode());
+        param.add("insurePlace", zhongAnCacheInputQueryParam.getInsurePlace());
+        param.add("thirdOrgCode", zhongAnCacheInputQueryParam.getThirdOrgCode());
+        param.add("licenseNo", zhongAnCacheInputQueryParam.getLicenseNo());
+        param.add("branchCode", zhongAnCacheInputQueryParam.getBranchCode());
+        param.add("isOpenRenewalFlag", zhongAnCacheInputQueryParam.getIsOpenRenewalFlag());
+        param.add("flowId", flowId);
+        param.add("page", "%2FinsureEntry");
+        param.add("i", "e");
+        param.add("flag", "0");
+
+        ZhongAnCacheInputQueryResult.Response response = form(ZhongAnAPI.CacheInputQuery, param, ZhongAnCacheInputQueryResult.Response.class, headers);
+
+        return response.getValue();
+    }
+
     /**
      * 将保单数据缓存起来
      *
@@ -175,7 +204,7 @@ public class ZhongAnAPIService {
      *    目前观察到的一次登录会话中, cacheCarInfo 保存的数据是全局共享的,不具备数据隔离性:
      *    1、会被后续的报价接口 {@link #premiumTrial}、 {@link #queryCarInfo} 使用到。
      *    2、如果同时对多个车信息保存并报价,最后一次保存的车数据会将之前的其它车的数据覆盖,最终导致 premiumTrial 只会对最后一个车进行报价。
-     *    3、也可能与 flowId 有关系
+     *    3、也可能与 flowId 有关系,可以测试一下 flowId 不一样的情况
      *
      * @param token
      * @param zhongAnCacheCarInfoParam

+ 10 - 0
tenant/insurance/quotation-zhongan/src/main/java/com/jzg/quotation/zhongan/crawler/service/ZhongAnQuotaionApiBaseServiceImpl.java

@@ -27,6 +27,16 @@ public class ZhongAnQuotaionApiBaseServiceImpl implements QuotationApiBaseServic
         String token = "";
         String flowId = "";
 
+        ZhongAnCacheInputQueryParam zhongAnCacheInputQueryParam = new ZhongAnCacheInputQueryParam();
+        zhongAnCacheInputQueryParam.setInsurePlace("晋城市");
+        zhongAnCacheInputQueryParam.setInsurePlaceCode("140500");
+        zhongAnCacheInputQueryParam.setLicenseNo(quoteVo.getCarInfoVo().getLicenseNo());
+
+
+        // 发起保险
+        // 此接口可能不支持并发,参看 cacheCarInfo 接口注释。
+        zhongAnAPIService.cacheInputQuery(token, flowId, zhongAnCacheInputQueryParam);
+
         ZhongAnCacheCarInfoParam zhongAnCacheCarInfoParam = new ZhongAnCacheCarInfoParam();
 
         // 保存车辆信息