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

1. 解决泰康第三者责任险选择300W后继续提示"请重新选择险种;商业三者险保额请选择300万以上"问题;
2. 调整泰康报价接口请求头参数硬编码

wangrq 1 месяц назад
Родитель
Сommit
41e13ff2ae

+ 43 - 0
tenant/insurance/quotation-taikang/src/main/java/com/jzg/quotation/taikang/crawler/FlowIdUtil.java

@@ -0,0 +1,43 @@
+package com.jzg.quotation.taikang.crawler;
+
+import java.util.concurrent.ThreadLocalRandom;
+
+/**
+ * 生成 carInsurFlowId 的工具类
+ * <p>
+ * 对应前端 Python 代码:
+ * <pre>
+ * headers['carInsurFlowId'] = 'carInsur' + str(int(time.time()*1000)) + str(random.randint(100000, 999999))
+ * </pre>
+ * 即:固定前缀 "carInsur" + 当前时间戳(毫秒) + 6 位随机数(100000~999999)
+ */
+public class FlowIdUtil {
+
+    /** 固定前缀,与前端保持一致 */
+    private static final String PREFIX = "carInsur";
+
+    /** 随机数最小值(含),对应 Python random.randint(100000, 999999) 的下界 */
+    private static final int RANDOM_MIN = 100000;
+
+    /** 随机数上界(不含),配合 nextInt(origin, bound) 实现含 100000、含 999999 */
+    private static final int RANDOM_MAX = 1000000;
+
+    /**
+     * 生成一个 carInsurFlowId
+     * <p>
+     * 格式:carInsur + 13 位毫秒时间戳 + 6 位随机数
+     * 示例:carInsur1780302178294459227
+     *
+     * @return 生成的 carInsurFlowId 字符串
+     */
+    public static String generateCarInsurFlowId() {
+        // 1. 当前时间戳(毫秒),等价于 Python 的 int(time.time() * 1000)
+        long timestamp = System.currentTimeMillis();
+        // 2. 生成 100000~999999 的随机数,等价于 Python 的 random.randint(100000, 999999)
+        //    ThreadLocalRandom.current().nextInt(origin, bound) 返回 [origin, bound) 范围内的随机数
+        //    所以 [100000, 1000000) 即 100000~999999
+        int randomNum = ThreadLocalRandom.current().nextInt(RANDOM_MIN, RANDOM_MAX);
+        // 3. 拼接:carInsur + 时间戳 + 随机数
+        return PREFIX + timestamp + randomNum;
+    }
+}

+ 6 - 4
tenant/insurance/quotation-taikang/src/main/java/com/jzg/quotation/taikang/crawler/service/TKHttpAPIService.java

@@ -6,6 +6,7 @@ import com.jzg.commons.entity.quote.vo.QuoteVo;
 import com.jzg.commons.exception.SystemException;
 import com.jzg.quotation.commons.filter.CarModelsFilterUtils;
 import com.jzg.quotation.taikang.crawler.CodeUtil;
+import com.jzg.quotation.taikang.crawler.FlowIdUtil;
 import com.jzg.quotation.taikang.crawler.JsonUtil;
 import com.jzg.quotation.taikang.crawler.client.*;
 import com.jzg.quotation.taikang.crawler.model.TKLoginSession;
@@ -300,7 +301,7 @@ public class TKHttpAPIService {
 
         HttpHeaders httpHeaders = new HttpHeaders();
         httpHeaders.add("tkcarrequesttoken", token);
-        httpHeaders.add("carInsurFlowId", "carInsur1778568776607661015");
+        httpHeaders.add("carInsurFlowId", FlowIdUtil.generateCarInsurFlowId());
         httpHeaders.add("carInsurOrderId", orderId);
 
         StringResponse response = client.request(HttpURL.agentQuery, param, httpHeaders, StringResponse.class);
@@ -548,7 +549,7 @@ public class TKHttpAPIService {
     public SaveBasicInfoResult saveBasicInfo(String token, SaveBasicInfoParam param) {
         HttpHeaders httpHeaders = new HttpHeaders();
         httpHeaders.add("tkCarRequestToken", token);
-        httpHeaders.add("carinsurflowid", "carInsur1780310645869550725");
+        httpHeaders.add("carinsurflowid", FlowIdUtil.generateCarInsurFlowId());
         httpHeaders.add("carinsurorderid", param.getOrderID());
 
         SaveBasicInfoResult.Response response = client.request(HttpURL.saveBasicInfo, param, httpHeaders, SaveBasicInfoResult.Response.class);
@@ -590,7 +591,7 @@ public class TKHttpAPIService {
         param.setTplatLoginKey(tplatLoginKey);
         HttpHeaders httpHeaders = new HttpHeaders();
         httpHeaders.add("tkCarRequestToken", token);
-        httpHeaders.add("carinsurflowid", "carInsur1780302178294459227");
+        httpHeaders.add("carinsurflowid", FlowIdUtil.generateCarInsurFlowId());
         httpHeaders.add("carinsurorderid", orderId);
         StringResponse response = client.request(HttpURL.preciseInit, param, httpHeaders, StringResponse.class);
         checkResponseUnknownField(response);
@@ -612,6 +613,7 @@ public class TKHttpAPIService {
         param.setChgOwnerInfo(TKChgOwnerInfo);
 
         HttpHeaders httpHeaders = new HttpHeaders();
+        httpHeaders.add("carinsurflowid", FlowIdUtil.generateCarInsurFlowId());
         httpHeaders.add("tkCarRequestToken", token);
 
         PreciseInitResult.Response response = client.request(HttpURL.preciseInit, param, httpHeaders, PreciseInitResult.Response.class);
@@ -1193,7 +1195,7 @@ public class TKHttpAPIService {
 
         HttpHeaders httpHeaders = new HttpHeaders();
         httpHeaders.add("tkCarRequestToken", token);
-        httpHeaders.add("carInsurFlowId", "carInsur1778568776607661015");
+        httpHeaders.add("carInsurFlowId", FlowIdUtil.generateCarInsurFlowId());
         httpHeaders.add("carInsurOrderId", orderId);
         Object response = client.request(HttpURL.carCheckUploadFileSubmit, param, httpHeaders, Object.class);
         log.info("上传影像提交完成,响应: {}", JSONObject.toJSONString(response));

+ 3 - 4
tenant/insurance/quotation-taikang/src/main/java/com/jzg/quotation/taikang/crawler/service/TKSimpleService.java

@@ -960,10 +960,6 @@ public class TKSimpleService {
                 TKFlag::new
         );
         flag.setVipWeekFlag("0");
-        // flag.setQuoteLinkageFlag("0"); //解决选择三者险300万进行报价时,依然提示:规则管控提示$商业三者险保额请选择300万以上问题,测试正常,不行完了放开
-        // flag.setInstantInsureBZAllowed("0");//解决选择三者险300万进行报价时,依然提示:规则管控提示$商业三者险保额请选择300万以上问题,测试正常,不行完了放开
-        // flag.setPriceDifferFlag("0");//解决选择三者险300万进行报价时,依然提示:规则管控提示$商业三者险保额请选择300万以上问题,测试正常,不行完了放开
-
         // 无商业险时设置商业险标志为"0"
         if (CollectionUtils.isEmpty(commonQuoteVo.getKindInfoVo())) {
             flag.setCiFlag("0");
@@ -979,6 +975,9 @@ public class TKSimpleService {
         other.setChannelCode("OffWeb");
         other.setMessageBZ("");
         other.setMessageCI("");
+        // 清空初始化阶段返回的规则管控提示(如JB-SX-05商业三者险保额提示),与Python代码self.data['other']['notice'] = ''一致
+        // 该提示属于警告信息,不应阻断报价流程;若不清空,保司接口会原样回传,导致buildQuoteFailResultsVo误判为报价失败
+        other.setNotice("");
         other.setPriceDifferFlag("0");
 
         // 获取时间参数对象(保司系统已初始化,无需创建)