Răsfoiți Sursa

众安登录修改

Qchen 3 luni în urmă
părinte
comite
dccc5fcf8a

+ 5 - 0
tenant/insurance/quotation-commons/src/main/java/com/jzg/quotation/commons/entity/DetectLoginRequest.java

@@ -29,4 +29,9 @@ public class DetectLoginRequest {
      * 密码
      */
     private String password;
+
+    /**
+     * 产品id 众安登录用
+     */
+    private String productId;
 }

+ 0 - 3
tenant/insurance/quotation-summary/src/main/resources/application-prod.yaml

@@ -233,9 +233,6 @@ zijin:
 #    downLoadDocument: http://open.zking.com/temp/api/v1/insurance/nonAutoMobile/queryPolicy/downLoadDocument
 #    # 对接三方渠道验车链接接口
 #    sendCheckCarLink: http://open.zking.com/api/v1/open/open-aggregate/auth/wanJiaYun/sendCheckCarLink
-zhongAn:
-  id: "1402039"
-  productId: "10676"
 
 
 feign:

+ 1 - 1
tenant/insurance/quotation-zhongan/src/main/java/com/jzg/quotation/zhongan/crawler/component/ZhongAnCrawlerCacheComponent.java

@@ -137,7 +137,7 @@ public class ZhongAnCrawlerCacheComponent {
             String firstUrl = "http://zhongan.bjhfbx.cn/subao-proxy-customer/api/redirectToCoopUserProductExclusivePage";
             URI uri1 = new URIBuilder(firstUrl)
                     .addParameter("coopUserId", zhongAnId)
-                    .addParameter("productId", "10805")
+                    .addParameter("productId", productId)
                     .addParameter("isOpenByPC", "N")
                     .addParameter("promotionScene", "16")
                     .addParameter("bizContent", "")

+ 0 - 3
tenant/insurance/quotation-zhongan/src/main/java/com/jzg/quotation/zhongan/crawler/component/ZhongAnCrawlerRequestComponent.java

@@ -46,9 +46,6 @@ public class ZhongAnCrawlerRequestComponent {
 
     private final ZhongAnCrawlerCacheComponent zhongAnCrawlerCacheComponent;
 
-    @Value("${zhongAn.id}")
-    private String zhongAnId;
-
     /**
      * 登录
      *

+ 4 - 0
tenant/insurance/quotation-zhongan/src/main/java/com/jzg/quotation/zhongan/crawler/entity/ZhongAnCrawlerConfigureParameters.java

@@ -21,4 +21,8 @@ public class ZhongAnCrawlerConfigureParameters implements ConfigureParameters {
     private String flowId;
 
     private String flag = "0";
+
+    private String username;
+
+    private String productId;
 }

+ 38 - 37
tenant/insurance/quotation-zhongan/src/main/java/com/jzg/quotation/zhongan/crawler/service/Impl/ZhongAnCrawlerRequestImpl.java

@@ -65,12 +65,6 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
 
     private final ZhongAnCrawlerCacheComponent zhongAnCrawlerCacheComponent;
 
-    @Value("${zhongAn.id}")
-    private String zhongAnId;
-
-    @Value("${zhongAn.productId}")
-    private String productId;
-
     private final PlatformClient platformClient;
 
     @Autowired
@@ -86,23 +80,23 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
     private static final String FLOWID = "flowId";
     private static final String ZHONGAN_COOKIE = "zhongan:cookie:";
 
-    public LoginResult login(String zhongAnId, String productId) {
+    public LoginResult login(ZhongAnCrawlerConfigureParameters parameters) {
         // 先从缓存取
-        Map<Object, Object> cacheMap = redissonClient.getMap(ZHONGAN_COOKIE + zhongAnId);
+        Map<Object, Object> cacheMap = redissonClient.getMap(ZHONGAN_COOKIE + parameters.getUsername());
         if (cacheMap != null && !cacheMap.isEmpty()) {
             String zaLoginCookieKey = (String) cacheMap.get(COOKIE);
             String flowId = (String) cacheMap.get(FLOWID);
 
-            System.out.println("[" + zhongAnId + "] 从 Redisson 缓存读取登录信息");
+            System.out.println("[" + parameters.getUsername() + "] 从 Redisson 缓存读取登录信息");
             return new LoginResult(200, "缓存登录成功", zaLoginCookieKey, flowId);
         }
 
         // 缓存没有 执行登录
-        LoginResult result = zhongAnCrawlerCacheComponent.loginCookieCache(zhongAnId, productId);
+        LoginResult result = zhongAnCrawlerCacheComponent.loginCookieCache( parameters.getUsername(),  parameters.getProductId());
 
         // 登录成功 存缓存
         if (result.getCode() == 200) {
-            zhongAnCrawlerCacheComponent.cacheCookie(result.getZaLoginCookieKey(), result.getFlowId(), zhongAnId);
+            zhongAnCrawlerCacheComponent.cacheCookie(result.getZaLoginCookieKey(), result.getFlowId(),  parameters.getUsername());
         }
 
         return result;
@@ -111,18 +105,18 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
     @Override
     public boolean detectLogin(DetectLoginRequest detectLoginRequest) {
         // 先从缓存取
-        Map<Object, Object> cacheMap = redissonClient.getMap(ZHONGAN_COOKIE + zhongAnId);
+        Map<Object, Object> cacheMap = redissonClient.getMap(ZHONGAN_COOKIE + detectLoginRequest.getUsername());
         if (cacheMap != null && !cacheMap.isEmpty()) {
-            System.out.println("[" + zhongAnId + "] 从 Redisson 缓存读取登录信息");
+            System.out.println("[" + detectLoginRequest.getUsername() + "] 从 Redisson 缓存读取登录信息");
             return true;
         }
 
         // 缓存没有 执行登录
-        LoginResult result = zhongAnCrawlerCacheComponent.loginCookieCache(zhongAnId, productId);
+        LoginResult result = zhongAnCrawlerCacheComponent.loginCookieCache(detectLoginRequest.getUsername(), detectLoginRequest.getProductId());
 
         // 登录成功 存缓存
         if (result.getCode() == 200) {
-            zhongAnCrawlerCacheComponent.cacheCookie(result.getZaLoginCookieKey(), result.getFlowId(), zhongAnId);
+            zhongAnCrawlerCacheComponent.cacheCookie(result.getZaLoginCookieKey(), result.getFlowId(), detectLoginRequest.getProductId());
         }
         return result.getCode() == 200;
     }
@@ -136,18 +130,19 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
      */
     @Override
     public QuoteResultsVo quote(QuoteVo quoteVo) {
+        AttributionInformationVo attributionInformationVo = quoteVo.getOrder().getAttributionInformationVo();
+        //获取配置信息
+        ZhongAnCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(ZhongAnCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
         // 检查登录
-        login(zhongAnId, productId);
+        login(parameters);
+        HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(parameters.getUsername());
+
         zhongAnCrawlerCacheComponent.setCache(quoteVo.getOwnersInfo().getIdentifyNumber(), quoteVo.getOrder().getOrdersNo() + ZhongAnCrawlerCacheComponent.IDENTIFY_NUMBER);
         CarInfoVo carInfoVo = quoteVo.getCarInfoVo();
         zhongAnCrawlerCacheComponent.setCache(carInfoVo.getLicenseNo(), quoteVo.getOrder().getOrdersNo() + ZhongAnCrawlerCacheComponent.LICENSE);
-        AttributionInformationVo attributionInformationVo = quoteVo.getOrder().getAttributionInformationVo();
-        //获取配置信息
-        ZhongAnCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(ZhongAnCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
-        HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(zhongAnId);
         String flowId = parameters.getFlowId();
         if (StringUtils.isEmpty(flowId)) {
-            parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(zhongAnId));
+            parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(parameters.getUsername()));
         }
         // 查询归属信息
         ZhongAnCrawlerQueryInitInfoRequest queryInitInfoRequest = new ZhongAnCrawlerQueryInitInfoRequest(parameters.getFlowId());
@@ -323,14 +318,14 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
      */
     @Override
     public UnderwritingResultsVo underwriting(UnderwritingVo underwritingVo) throws Exception {
-        // 检查登录
-        login(zhongAnId, productId);
         AttributionInformationVo attributionInformationVo = underwritingVo.getOrder().getAttributionInformationVo();
         ZhongAnCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(ZhongAnCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
-        HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(zhongAnId);
+        // 检查登录
+        login(parameters);
+        HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(parameters.getUsername());
         String flowId = parameters.getFlowId();
         if (StringUtils.isEmpty(flowId)) {
-            parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(zhongAnId));
+            parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(parameters.getUsername()));
         }
         ZhongAnCrawlerOrder zhongAnCrawlerOrder = zhongAnCrawlerOrderService.findByOrdersNo(underwritingVo.getOrder().getOrdersNo());
         ZhongAnCrawlerMarkRequest markRequest = new ZhongAnCrawlerMarkRequest(parameters, zhongAnCrawlerOrder.getOrderNo());
@@ -360,12 +355,14 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
      */
     @Override
     public PaymentLinkResultsVo getPaymentLink(PaymentLinkVo paymentLinkVo) {
+        //获取配置信息
+        AttributionInformationVo attributionInformationVo = paymentLinkVo.getOrder().getAttributionInformationVo();
+        ZhongAnCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(ZhongAnCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
         // 检查登录
-        login(zhongAnId, productId);
+        login(parameters);
         PaymentLinkResultsVo paymentLinkResultsVo = new PaymentLinkResultsVo();
         OrderBase orderBase = paymentLinkVo.getOrder();
-        //获取配置信息
-        HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(zhongAnId);
+        HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(parameters.getUsername());
 
         ZhongAnCrawlerOrder zhongAnCrawlerOrder = zhongAnCrawlerOrderService.findByOrdersNo(orderBase.getOrdersNo());
 
@@ -390,16 +387,17 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
      */
     @Override
     public void uploadImage(InsuranceUploadImageVo insuranceUploadImageVo) {
-        // 检查登录
-        login(zhongAnId, productId);
         OrderBase orderBase = insuranceUploadImageVo.getOrder();
         AttributionInformationVo attributionInformationVo = orderBase.getAttributionInformationVo();
         //获取配置信息
         ZhongAnCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(ZhongAnCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
-        HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(zhongAnId);
+        // 检查登录
+        login(parameters);
+
+        HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(parameters.getUsername());
         String flowId = parameters.getFlowId();
         if (StringUtils.isEmpty(flowId)) {
-            parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(zhongAnId));
+            parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(parameters.getUsername()));
         }
         ZhongAnCrawlerOrder zhongAnCrawlerOrder = zhongAnCrawlerOrderService.findByOrdersNo(orderBase.getOrdersNo());
         for (InsuranceImageVo insuranceImageVo : insuranceUploadImageVo.getImageVoList()) {
@@ -472,11 +470,14 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
      */
     @Override
     public DownloadPolicyResultVo downloadPolicy(DownloadPolicyVo downloadPolicyVo) {
+        AttributionInformationVo attributionInformationVo = downloadPolicyVo.getOrder().getAttributionInformationVo();
+        //获取配置信息
+        ZhongAnCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(ZhongAnCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
         // 检查登录
-        login(zhongAnId, productId);
+        login(parameters);
         OrderBase orderBase = downloadPolicyVo.getOrder();
         //获取配置信息
-        HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(zhongAnId);
+        HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(parameters.getUsername());
 
         ZhongAnCrawlerOrder zhongAnCrawlerOrder = zhongAnCrawlerOrderService.findByOrdersNo(orderBase.getOrdersNo());
         String orderNo = zhongAnCrawlerOrder.getOrderNo();
@@ -527,11 +528,11 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
         AttributionInformationVo attributionInformationVo = orderStatusVo.getOrder().getAttributionInformationVo();
         //获取配置信息
         ZhongAnCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(ZhongAnCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
-        login(zhongAnId, productId);
-        HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(zhongAnId);
+        login(parameters);
+        HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(parameters.getUsername());
         String flowId = parameters.getFlowId();
         if (StringUtils.isEmpty(flowId)) {
-            parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(zhongAnId));
+            parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(parameters.getUsername()));
         }
         ZhongAnCrawlerOrder zhongAnCrawlerOrder = zhongAnCrawlerOrderService.findByOrdersNo(orderStatusVo.getOrder().getOrdersNo());
         // 车牌号