|
|
@@ -1,15 +1,18 @@
|
|
|
package com.jzg.quotation.zhongan.crawler.service.Impl;
|
|
|
|
|
|
+import cn.hutool.cache.Cache;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.google.common.cache.CacheBuilder;
|
|
|
import com.jzg.commons.constants.dict.InsOrderStatusEnum;
|
|
|
-import com.jzg.commons.entity.po.SysUploadFiles;
|
|
|
+import com.jzg.commons.entity.orders.po.InsOrdersCarInfo;
|
|
|
+import com.jzg.commons.entity.orders.po.InsOrdersCarUserInfo;
|
|
|
import com.jzg.commons.entity.quote.vo.AttributionInformationVo;
|
|
|
import com.jzg.commons.entity.quote.vo.CarInfoVo;
|
|
|
import com.jzg.commons.entity.quote.vo.QuoteVo;
|
|
|
import com.jzg.commons.entity.quote.vo.aggregated.*;
|
|
|
import com.jzg.commons.exception.SystemException;
|
|
|
-import com.jzg.commons.util.MinioUtils;
|
|
|
import com.jzg.commons.util.StringUtils;
|
|
|
import com.jzg.quotation.commons.annotation.QuoteCrawlerService;
|
|
|
import com.jzg.quotation.commons.client.PlatformClient;
|
|
|
@@ -19,9 +22,8 @@ import com.jzg.commons.entity.quote.vo.base.OrderBase;
|
|
|
import com.jzg.commons.entity.quote.vo.image.InsuranceImageVo;
|
|
|
import com.jzg.quotation.commons.filter.CarModelsFilterUtils;
|
|
|
import com.jzg.quotation.commons.standard.conversion.ConfigureParametersConversion;
|
|
|
-import com.jzg.quotation.commons.utils.HttpUtil;
|
|
|
-import com.jzg.quotation.zhongan.crawler.JsonUtil;
|
|
|
import com.jzg.quotation.zhongan.crawler.build.ZhongAnCrawlerQuoteResultsVoBuild;
|
|
|
+import com.jzg.quotation.zhongan.crawler.client.LoginResult;
|
|
|
import com.jzg.quotation.zhongan.crawler.component.ZhongAnCrawlerCacheComponent;
|
|
|
import com.jzg.quotation.zhongan.crawler.component.ZhongAnCrawlerRequestComponent;
|
|
|
import com.jzg.quotation.zhongan.crawler.constant.ZhongAnRequestConstant;
|
|
|
@@ -32,16 +34,19 @@ import com.jzg.quotation.zhongan.crawler.entity.response.*;
|
|
|
import com.jzg.quotation.zhongan.crawler.service.ZhongAnCrawlerOrderService;
|
|
|
import com.jzg.quotation.zhongan.crawler.service.ZhongAnCrawlerRequest;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.redisson.api.RedissonClient;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
|
import java.io.*;
|
|
|
-import java.net.HttpURLConnection;
|
|
|
-import java.net.URL;
|
|
|
-import java.util.Base64;
|
|
|
-import java.util.HashMap;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -51,6 +56,7 @@ import java.util.stream.Collectors;
|
|
|
**/
|
|
|
@QuoteCrawlerService(value = InsuranceCode.INSURANCE_ZAPA)
|
|
|
@RequiredArgsConstructor
|
|
|
+@Slf4j
|
|
|
public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
private final ZhongAnCrawlerRequestComponent zhongAnCrawlerRequestComponent;
|
|
|
|
|
|
@@ -61,16 +67,44 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
@Value("${zhongAn.id}")
|
|
|
private String zhongAnId;
|
|
|
|
|
|
+ @Value("${zhongAn.productId}")
|
|
|
+ private String productId;
|
|
|
+
|
|
|
private final PlatformClient platformClient;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedissonClient redissonClient;
|
|
|
+
|
|
|
/**
|
|
|
* 登录
|
|
|
*
|
|
|
- * @param loginBase 登录信息
|
|
|
+ * @param username 用户名
|
|
|
*/
|
|
|
- @Override
|
|
|
- public void login(LoginBase loginBase) {
|
|
|
|
|
|
+ private static final String COOKIE = "zaLoginCookieKey";
|
|
|
+ private static final String FLOWID = "flowId";
|
|
|
+ private static final String ZHONGAN_COOKIE = "zhongan:cookie:";
|
|
|
+
|
|
|
+ public LoginResult login(String zhongAnId, String productId) {
|
|
|
+ // 先从缓存取
|
|
|
+ Map<Object, Object> cacheMap = redissonClient.getMap(ZHONGAN_COOKIE + zhongAnId);
|
|
|
+ if (cacheMap != null && !cacheMap.isEmpty()) {
|
|
|
+ String zaLoginCookieKey = (String) cacheMap.get(COOKIE);
|
|
|
+ String flowId = (String) cacheMap.get(FLOWID);
|
|
|
+
|
|
|
+ System.out.println("[" + zhongAnId + "] 从 Redisson 缓存读取登录信息");
|
|
|
+ return new LoginResult(200, "缓存登录成功", zaLoginCookieKey, flowId);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 缓存没有 执行登录
|
|
|
+ LoginResult result = zhongAnCrawlerCacheComponent.loginCookieCache(zhongAnId,productId);
|
|
|
+
|
|
|
+ // 登录成功 存缓存
|
|
|
+ if (result.getCode() == 200) {
|
|
|
+ zhongAnCrawlerCacheComponent.cacheCookie(result.getZaLoginCookieKey(), result.getFlowId(), zhongAnId);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -81,8 +115,8 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
*/
|
|
|
@Override
|
|
|
public QuoteResultsVo quote(QuoteVo quoteVo) {
|
|
|
- //登录众安
|
|
|
- loginCookieCache(zhongAnId);
|
|
|
+ // 检查登录
|
|
|
+ login(zhongAnId,productId);
|
|
|
zhongAnCrawlerCacheComponent.setCache(quoteVo.getOwnersInfo().getIdentifyNumber(), quoteVo.getOrder().getOrdersNo() + ZhongAnCrawlerCacheComponent.IDENTIFY_NUMBER);
|
|
|
CarInfoVo carInfoVo = quoteVo.getCarInfoVo();
|
|
|
zhongAnCrawlerCacheComponent.setCache(carInfoVo.getLicenseNo(),quoteVo.getOrder().getOrdersNo()+ZhongAnCrawlerCacheComponent.LICENSE);
|
|
|
@@ -94,6 +128,9 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
if (StringUtils.isEmpty(flowId)) {
|
|
|
parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(zhongAnId));
|
|
|
}
|
|
|
+ // 查询归属信息
|
|
|
+ ZhongAnCrawlerQueryInitInfoRequest queryInitInfoRequest = new ZhongAnCrawlerQueryInitInfoRequest(parameters.getFlowId());
|
|
|
+ String queryInitInfoResponse = zhongAnCrawlerRequestComponent.initInfo(queryInitInfoRequest, headers);
|
|
|
//校验key,缓存
|
|
|
ZhongAnCrawlerCacheInputRequest cacheInputRequest = new ZhongAnCrawlerCacheInputRequest(quoteVo, parameters);
|
|
|
String cacheInput = zhongAnCrawlerRequestComponent.CacheInput(cacheInputRequest, headers);
|
|
|
@@ -116,9 +153,7 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
ZhongAnCrawlerLicenseSwitchRequest licenseSwitchRequest = new ZhongAnCrawlerLicenseSwitchRequest(quoteVo, parameters);
|
|
|
String licenseSwitch = zhongAnCrawlerRequestComponent.licenseSwitch(licenseSwitchRequest, headers);
|
|
|
|
|
|
-
|
|
|
ZhongAnCrawlerCacheCarQueryRequest cacheCarQueryRequest = new ZhongAnCrawlerCacheCarQueryRequest(quoteVo, vehicleDTO, parameters);
|
|
|
-// String cacheCarQueryResponse = zhongAnCrawlerRequestComponent.cacheCarInfo(cacheCarQueryRequest,headers);
|
|
|
ZhongAnCrawlerCacheCarQueryResponse cacheCarQueryResponse = zhongAnCrawlerRequestComponent.cacheCarInfo(cacheCarQueryRequest, headers);
|
|
|
if (cacheCarQueryResponse != null && StringUtils.isNotEmpty(cacheCarQueryResponse.getErrorMsg())) {
|
|
|
if (cacheCarQueryResponse.getErrorCode().equals("A12512")) {
|
|
|
@@ -133,24 +168,42 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
if (cacheCarQueryResponse1 != null && StringUtils.isNotEmpty(cacheCarQueryResponse1.getErrorMsg())) {
|
|
|
throw new SystemException(cacheCarQueryResponse1.getErrorMsg());
|
|
|
}
|
|
|
-
|
|
|
} else {
|
|
|
-
|
|
|
throw new SystemException(cacheCarQueryResponse.getErrorMsg());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ZhongAnCrawlerQuoteBaseRequest quoteBaseRequest = new ZhongAnCrawlerQuoteBaseRequest(parameters);
|
|
|
ZhongAnCrawlerQuoteBaseResponse quoteBaseResponse = zhongAnCrawlerRequestComponent.quoteBaseInfo(quoteBaseRequest, headers);
|
|
|
-// ZhongAnCrawlerQuoteBaseResponse zhongAnCrawlerQuoteBaseResponse = JsonUtil.readObjcet(str, ZhongAnCrawlerQuoteBaseResponse.class);
|
|
|
|
|
|
//报价
|
|
|
ZhongAnCrawlerQuoteRequest quoteRequest = new ZhongAnCrawlerQuoteRequest(quoteVo, parameters, quoteBaseResponse);
|
|
|
ZhongAnCrawlerQuoteResponse quoteResponse = zhongAnCrawlerRequestComponent.quote(quoteRequest, headers);
|
|
|
if (quoteResponse != null && StringUtils.isNotEmpty(quoteResponse.getErrorMsg())) {
|
|
|
- throw new SystemException(quoteResponse.getErrorMsg());
|
|
|
+ QuoteResultsVo quoteResultsVo = new QuoteResultsVo();
|
|
|
+ quoteResultsVo.setErrorMessage(quoteResponse.getErrorMsg());
|
|
|
+ quoteResultsVo.setQuoteStatusEnum(InsOrderStatusEnum.QUOTE_FAIL);
|
|
|
+ return quoteResultsVo;
|
|
|
+ }
|
|
|
+ // 处理重复投保
|
|
|
+ if (quoteResponse.getAdditionalInfo() != null) {
|
|
|
+ if (quoteResponse.getAdditionalInfo().getInsureMessageF() != null && quoteResponse.getAdditionalInfo().getInsureMessageF().contains("重复投保")) {
|
|
|
+ String jqExtractDate = jqExtractDate(quoteResponse);
|
|
|
+ if (jqExtractDate != null) {
|
|
|
+ quoteRequest.setCompelInsEffectiveDate(jqExtractDate);
|
|
|
+ }
|
|
|
+ quoteResponse = zhongAnCrawlerRequestComponent.quote(quoteRequest, headers);
|
|
|
+ if (quoteResponse.getAdditionalInfo() != null && quoteResponse.getAdditionalInfo().getInsureMessage().contains("重复投保")) {
|
|
|
+ String syExtractDate = syExtractDate(quoteResponse);
|
|
|
+ if (syExtractDate != null) {
|
|
|
+ quoteRequest.setEffectiveDate(syExtractDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ quoteResponse = zhongAnCrawlerRequestComponent.quote(quoteRequest, headers);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//确认报价
|
|
|
ZhongAnCrawlerConfirmQuoteRequest confirmQuoteRequest = new ZhongAnCrawlerConfirmQuoteRequest(parameters);
|
|
|
String s = zhongAnCrawlerRequestComponent.confirmQuote(confirmQuoteRequest, headers);
|
|
|
@@ -168,11 +221,12 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
zhongAnCrawlerCacheComponent.setCache(dataDTO.getPolicyId(), quoteVo.getOrder().getOrdersNo() + ZhongAnCrawlerCacheComponent.POLICY_ID);
|
|
|
|
|
|
//非车险提交核保
|
|
|
- ZhongAnCrawlerJyxUnderwritingRequest jyxUnderwritingRequest = new ZhongAnCrawlerJyxUnderwritingRequest(parameters, getOrderResponse.getValue().getDatas().getQuoteId());
|
|
|
- ZhongAnCrawlerJyxUnderwritingResponse jyxUnderwritingResponse = zhongAnCrawlerRequestComponent.jyxUnderwriting(jyxUnderwritingRequest, headers);
|
|
|
-
|
|
|
+ if (quoteVo.getAccidentalDrivings() != null && quoteVo.getAccidentalDrivings().size() > 0) {
|
|
|
+ ZhongAnCrawlerJyxUnderwritingRequest jyxUnderwritingRequest = new ZhongAnCrawlerJyxUnderwritingRequest(parameters, getOrderResponse.getValue().getDatas().getQuoteId());
|
|
|
+ ZhongAnCrawlerJyxUnderwritingResponse jyxUnderwritingResponse = zhongAnCrawlerRequestComponent.jyxUnderwriting(jyxUnderwritingRequest, headers);
|
|
|
+ }
|
|
|
ZhongAnCrawlerUploadInitDateRequest zhongAnCrawlerUploadInitDateRequest = new ZhongAnCrawlerUploadInitDateRequest(dataDTO, parameters);
|
|
|
- ZhongAnCrawlerUploadInitDateResponse uploadInitDateResponse = zhongAnCrawlerRequestComponent.uploadInitDate(zhongAnCrawlerUploadInitDateRequest, headers);
|
|
|
+ ZhongAnCrawlerUploadInitDateResponse uploadInitDateResponse = zhongAnCrawlerRequestComponent.uploadInitData(zhongAnCrawlerUploadInitDateRequest, headers);
|
|
|
zhongAnCrawlerCacheComponent.setCache(uploadInitDateResponse.getValue().getDatas(), quoteVo.getOrder().getOrdersNo() + ZhongAnCrawlerCacheComponent.INITDATE);
|
|
|
|
|
|
|
|
|
@@ -180,68 +234,65 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
zhongAnCrawlerOrder.setOrdersNo(quoteVo.getOrder().getOrdersNo());
|
|
|
zhongAnCrawlerOrder.setOrderNo(dataDTO.getOrderNo());
|
|
|
zhongAnCrawlerOrder.setPolicyId(dataDTO.getPolicyId());
|
|
|
+ zhongAnCrawlerOrder.setQuoteId(quoteResponse.getValue().getDatas().getQuoteId());
|
|
|
+ zhongAnCrawlerOrder.setCheckCode(uploadInitDateResponse.getValue().getDatas().getCheckCode());
|
|
|
+ // 交强投保单号
|
|
|
+ if (uploadInitDateResponse.getValue().getDatas().getCompelApplyNo() != null) {
|
|
|
+ zhongAnCrawlerOrder.setJqApplyNo(uploadInitDateResponse.getValue().getDatas().getCompelApplyNo());
|
|
|
+ }
|
|
|
+ // 商业投保单号
|
|
|
+ if (uploadInitDateResponse.getValue().getDatas().getBizApplyNo() != null) {
|
|
|
+ zhongAnCrawlerOrder.setSyApplyNo(uploadInitDateResponse.getValue().getDatas().getBizApplyNo());
|
|
|
+ }
|
|
|
zhongAnCrawlerOrderService.save(zhongAnCrawlerOrder);
|
|
|
- return ZhongAnCrawlerQuoteResultsVoBuild.buildQuoteResultsVo(quoteVo, quoteResponse.getValue().getDatas());
|
|
|
+ return ZhongAnCrawlerQuoteResultsVoBuild.buildQuoteResultsVo(quoteVo, quoteResponse.getValue().getDatas(),uploadInitDateResponse);
|
|
|
}
|
|
|
|
|
|
- //登录
|
|
|
- private void loginCookieCache(String zhongAnId) {
|
|
|
- try {
|
|
|
-
|
|
|
- Map<String, String> params = new HashMap<>();
|
|
|
- params.put("partnerChannelCode", "m18x462r");
|
|
|
- params.put("partnerUserAccount", zhongAnId);
|
|
|
- params.put("partnerChildChannelCode", "");
|
|
|
- params.put("promotionNo", "0c033ab79c6847c0878342480aef76a1");
|
|
|
- params.put("productId", "10676");
|
|
|
- params.put("policySource", "40");
|
|
|
- params.put("subaoBizContent", "");
|
|
|
- params.put("insurerCode", "ZHONGANCAR");
|
|
|
-
|
|
|
-
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36");
|
|
|
- headers.put("Accept", "application/json, text/plain, */*");
|
|
|
-
|
|
|
- // 发送第一个请求,不跟随重定向
|
|
|
- String url = "https://www.cyouzai.com/busi-integration/channel/baoBiaoH5Redirect";
|
|
|
- HttpURLConnection connection = HttpUtil.sendGetRequest(url, params, headers, false);
|
|
|
- String firstLocation = connection.getHeaderField("Location");
|
|
|
- connection.disconnect();
|
|
|
-
|
|
|
- System.out.println(firstLocation);
|
|
|
-
|
|
|
- // 发送第二个请求,不跟随重定向
|
|
|
- connection = HttpUtil.sendGetRequest(firstLocation, null, headers, false);
|
|
|
- String secondLocation = connection.getHeaderField("Location");
|
|
|
- connection.disconnect();
|
|
|
-
|
|
|
- // 发送第三个请求,不跟随重定向
|
|
|
- connection = HttpUtil.sendGetRequest(secondLocation, null, headers, false);
|
|
|
- Map<String, List<String>> responseHeaders = connection.getHeaderFields();
|
|
|
- connection.disconnect();
|
|
|
-
|
|
|
- // 提取zaLoginCookieKey
|
|
|
- String zaLoginCookieKey = HttpUtil.extractZaLoginCookieKey(responseHeaders);
|
|
|
- if (zaLoginCookieKey != null && !zaLoginCookieKey.isEmpty()) {
|
|
|
- // 获取Location头
|
|
|
- String thirdLocation = connection.getHeaderField("Location");
|
|
|
-
|
|
|
- // 提取flowId
|
|
|
- String flowId = HttpUtil.extractFlowId(thirdLocation);
|
|
|
- //缓存数据
|
|
|
- zhongAnCrawlerCacheComponent.cacheCookie(zaLoginCookieKey, flowId, zhongAnId);
|
|
|
-
|
|
|
- System.out.println("key==" + zaLoginCookieKey + "------flowId=" + flowId);
|
|
|
-
|
|
|
- } else {
|
|
|
- throw new SystemException("未获取到-----zaLoginCookieKey");
|
|
|
- }
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- throw new SystemException("message", "请求发生错误: " + e.getMessage());
|
|
|
+ /**
|
|
|
+ * 交强险日期提取
|
|
|
+ */
|
|
|
+ private String jqExtractDate(ZhongAnCrawlerQuoteResponse quoteResponse) {
|
|
|
+ String insureMessageF = quoteResponse.getAdditionalInfo().getInsureMessageF();
|
|
|
+ // 1. 正则提取
|
|
|
+ String regex = "(\\d{4}年\\d{1,2}月\\d{1,2}日 \\d{1,2}:\\d{1,2}:\\d{1,2})";
|
|
|
+ Pattern pattern = Pattern.compile(regex);
|
|
|
+ Matcher matcher = pattern.matcher(insureMessageF);
|
|
|
+
|
|
|
+ String formatTime = null;
|
|
|
+ if (matcher.find()) {
|
|
|
+ String originTime = matcher.group(1); // 提取到的时间
|
|
|
+ formatTime = originTime
|
|
|
+ .replace("年", "-")
|
|
|
+ .replace("月", "-")
|
|
|
+ .replace("日", "");
|
|
|
+ }
|
|
|
+ DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-M-d HH:mm:ss");
|
|
|
+ DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ if (formatTime != null) {
|
|
|
+ LocalDateTime dateTime = LocalDateTime.parse(formatTime, inputFormatter);
|
|
|
+ return dateTime.format(outputFormatter);
|
|
|
}
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 商业险日期提取
|
|
|
+ */
|
|
|
+ private String syExtractDate(ZhongAnCrawlerQuoteResponse quoteResponse) {
|
|
|
+ String insureMessage = quoteResponse.getAdditionalInfo().getInsureMessage();
|
|
|
+ String regex = "(\\d{4})年(\\d{1,2})月(\\d{1,2})日";
|
|
|
+ Matcher matcher = Pattern.compile(regex).matcher(insureMessage);
|
|
|
+ if (matcher.find()) {
|
|
|
+ int year = Integer.parseInt(matcher.group(1));
|
|
|
+ int month = Integer.parseInt(matcher.group(2));
|
|
|
+ int day = Integer.parseInt(matcher.group(3));
|
|
|
+
|
|
|
+ LocalDateTime dateTime = LocalDateTime.of(year, month, day, 0, 0, 0);
|
|
|
+
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ return dateTime.format(formatter);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -251,7 +302,8 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
*/
|
|
|
@Override
|
|
|
public UnderwritingResultsVo underwriting(UnderwritingVo underwritingVo) throws Exception {
|
|
|
- loginCookieCache(zhongAnId);
|
|
|
+ // 检查登录
|
|
|
+ login(zhongAnId, productId);
|
|
|
AttributionInformationVo attributionInformationVo = underwritingVo.getOrder().getAttributionInformationVo();
|
|
|
ZhongAnCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(ZhongAnCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
|
|
|
HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(zhongAnId);
|
|
|
@@ -259,25 +311,24 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
if (StringUtils.isEmpty(flowId)) {
|
|
|
parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(zhongAnId));
|
|
|
}
|
|
|
- String ordersNo = zhongAnCrawlerCacheComponent.getCache(underwritingVo.getOrder().getOrdersNo() + ZhongAnCrawlerCacheComponent.ORDER_NO);
|
|
|
- ZhongAnCrawlerMarkRequest markRequest = new ZhongAnCrawlerMarkRequest(parameters, ordersNo);
|
|
|
- String markCompleted = zhongAnCrawlerRequestComponent.markCompleted(markRequest, headers);
|
|
|
-
|
|
|
ZhongAnCrawlerOrder zhongAnCrawlerOrder = zhongAnCrawlerOrderService.findByOrdersNo(underwritingVo.getOrder().getOrdersNo());
|
|
|
-
|
|
|
- ZhongAnCrawlerUploadInitDateResponse.ValueDTO.DatasDTO initData = zhongAnCrawlerCacheComponent.getInitData(underwritingVo.getOrder().getOrdersNo() + ZhongAnCrawlerCacheComponent.INITDATE);
|
|
|
- ZhongAnCrawlerPaymentRequest paymentRequest = new ZhongAnCrawlerPaymentRequest(zhongAnCrawlerOrder.getPolicyId(), initData.getCheckCode());
|
|
|
+ ZhongAnCrawlerMarkRequest markRequest = new ZhongAnCrawlerMarkRequest(parameters, zhongAnCrawlerOrder.getOrderNo());
|
|
|
+ String markCompleted = zhongAnCrawlerRequestComponent.markCompleted(markRequest, headers);
|
|
|
+ ZhongAnCrawlerPaymentRequest paymentRequest = new ZhongAnCrawlerPaymentRequest(zhongAnCrawlerOrder.getPolicyId(), zhongAnCrawlerOrder.getCheckCode());
|
|
|
ZhongAnCrawlerPaymentResponse payment = zhongAnCrawlerRequestComponent.payment(paymentRequest, headers);
|
|
|
|
|
|
UnderwritingResultsVo underwritingResultsVo = new UnderwritingResultsVo();
|
|
|
underwritingResultsVo.setPaymentLink(payment.getValue().getDatas().getShareShortUrl());
|
|
|
//核保结果
|
|
|
underwritingResultsVo.setUnderwritingResult("核保成功");
|
|
|
-// //核保状态
|
|
|
+ //核保状态
|
|
|
underwritingResultsVo.setUnderwritingStatus(InsOrderStatusEnum.PAY_PENDING);
|
|
|
-// //保司订单号
|
|
|
- underwritingResultsVo.setCompanyOrderNo(ordersNo);
|
|
|
-
|
|
|
+ //保司订单号
|
|
|
+ underwritingResultsVo.setCompanyOrderNo(zhongAnCrawlerOrder.getOrderNo());
|
|
|
+ // 交强险投保单号
|
|
|
+ underwritingResultsVo.setJqApplyNo(zhongAnCrawlerOrder.getJqApplyNo());
|
|
|
+ // 商业投保单号
|
|
|
+ underwritingResultsVo.setSyApplyNo(zhongAnCrawlerOrder.getSyApplyNo());
|
|
|
return underwritingResultsVo;
|
|
|
}
|
|
|
|
|
|
@@ -288,7 +339,8 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
*/
|
|
|
@Override
|
|
|
public PaymentLinkResultsVo getPaymentLink(PaymentLinkVo paymentLinkVo) {
|
|
|
- loginCookieCache(zhongAnId);
|
|
|
+ // 检查登录
|
|
|
+ login(zhongAnId,productId);
|
|
|
PaymentLinkResultsVo paymentLinkResultsVo = new PaymentLinkResultsVo();
|
|
|
OrderBase orderBase = paymentLinkVo.getOrder();
|
|
|
//获取配置信息
|
|
|
@@ -317,7 +369,8 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
*/
|
|
|
@Override
|
|
|
public void uploadImage(InsuranceUploadImageVo insuranceUploadImageVo) {
|
|
|
- loginCookieCache(zhongAnId);
|
|
|
+ // 检查登录
|
|
|
+ login(zhongAnId,productId);
|
|
|
OrderBase orderBase = insuranceUploadImageVo.getOrder();
|
|
|
AttributionInformationVo attributionInformationVo = orderBase.getAttributionInformationVo();
|
|
|
//获取配置信息
|
|
|
@@ -369,10 +422,17 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
private void extracted(ZhongAnCrawlerConfigureParameters parameters, HttpHeaders headers, ZhongAnCrawlerOrder zhongAnCrawlerOrder, String imageType, InsuranceImageVo.ImageDTO imageDTO) {
|
|
|
ZhongAnCrawlerUploadImageRequest uploadImageRequest = new ZhongAnCrawlerUploadImageRequest(imageType, imageDTO, zhongAnCrawlerOrder.getOrderNo(), zhongAnCrawlerOrder.getPolicyId(), parameters);
|
|
|
ZhongAnCrawlerUploadImageResponse uploadImageResponse = zhongAnCrawlerRequestComponent.uploadImage(uploadImageRequest, headers);
|
|
|
- if (uploadImageResponse != null && StringUtils.isNotEmpty(uploadImageResponse.getErrorMsg())) {
|
|
|
- throw new SystemException(uploadImageResponse.getErrorMsg());
|
|
|
+ if (uploadImageResponse != null && uploadImageResponse.getErrorMsg() != null && uploadImageResponse.getErrorMsg().contains("您上传的图片校验失败!请您确认是否要走人工审核")) {
|
|
|
+ uploadImageRequest.setIsSubmitAudit("1");
|
|
|
+ ZhongAnCrawlerUploadImageResponse uploadImageResponse1 = zhongAnCrawlerRequestComponent.uploadImage(uploadImageRequest, headers);
|
|
|
+ if (uploadImageResponse1 != null) {
|
|
|
+ if (uploadImageResponse1.getErrorMsg() != null && !uploadImageResponse1.getErrorMsg().isEmpty()) {
|
|
|
+ throw new SystemException(uploadImageResponse1.getErrorMsg());
|
|
|
+ } else if (uploadImageResponse1.getSuccess()){
|
|
|
+ log.info("上传影像成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public byte[] convert(String filePath) throws IOException {
|
|
|
@@ -391,9 +451,9 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
*/
|
|
|
@Override
|
|
|
public DownloadPolicyResultVo downloadPolicy(DownloadPolicyVo downloadPolicyVo) {
|
|
|
- loginCookieCache(zhongAnId);
|
|
|
+ // 检查登录
|
|
|
+ login(zhongAnId,productId);
|
|
|
OrderBase orderBase = downloadPolicyVo.getOrder();
|
|
|
- AttributionInformationVo attributionInformationVo = orderBase.getAttributionInformationVo();
|
|
|
//获取配置信息
|
|
|
HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(zhongAnId);
|
|
|
|
|
|
@@ -423,7 +483,7 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
String syUrl = ZhongAnRequestConstant.DOWNLOAD_POLICY_URL.replace(ZhongAnRequestConstant.ORDER_NO, orderNo)
|
|
|
.replace(ZhongAnRequestConstant.FILE_NAME, bizDTO.getDocumentName())
|
|
|
.replace(ZhongAnRequestConstant.DOCUMENT_URL, bizDTO.getDocumentUrl());
|
|
|
- //获取交强保单信息
|
|
|
+ //获取驾意保单信息
|
|
|
String jyUrl = ZhongAnRequestConstant.DOWNLOAD_POLICY_URL.replace(ZhongAnRequestConstant.ORDER_NO, orderNo)
|
|
|
.replace(ZhongAnRequestConstant.FILE_NAME, nonAutoDocumentInfo.getNonAutoPolicyName())
|
|
|
.replace(ZhongAnRequestConstant.DOCUMENT_URL, nonAutoDocumentInfo.getNonAutoPolicyUrl());
|
|
|
@@ -443,53 +503,121 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
*/
|
|
|
@Override
|
|
|
public OrderStatusResultVo queryOrderState(OrderStatusVo orderStatusVo) throws JsonProcessingException {
|
|
|
- loginCookieCache(zhongAnId);
|
|
|
AttributionInformationVo attributionInformationVo = orderStatusVo.getOrder().getAttributionInformationVo();
|
|
|
//获取配置信息
|
|
|
ZhongAnCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(ZhongAnCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
|
|
|
+ login(zhongAnId,productId);
|
|
|
HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(zhongAnId);
|
|
|
String flowId = parameters.getFlowId();
|
|
|
if (StringUtils.isEmpty(flowId)) {
|
|
|
parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(zhongAnId));
|
|
|
}
|
|
|
-
|
|
|
- String license = zhongAnCrawlerCacheComponent.getCache(orderStatusVo.getOrder().getOrdersNo() + ZhongAnCrawlerCacheComponent.LICENSE);
|
|
|
- ZhongAnCrawlerPolicyListRequest policyListRequest = new ZhongAnCrawlerPolicyListRequest(license,parameters);
|
|
|
+ ZhongAnCrawlerOrder zhongAnCrawlerOrder = zhongAnCrawlerOrderService.findByOrdersNo(orderStatusVo.getOrder().getOrdersNo());
|
|
|
+ // 车牌号
|
|
|
+ String licenseNo = orderStatusVo.getCarInfo().getLicenseNo();
|
|
|
+ // 先查询是否存在待支付列表里
|
|
|
+ ZhongAnCrawlerPolicyListRequest policyListRequest = new ZhongAnCrawlerPolicyListRequest(licenseNo,parameters,"2");
|
|
|
ZhongAnCrawlerPolicyListResponse response = zhongAnCrawlerRequestComponent.policyList(policyListRequest,headers);
|
|
|
+ OrderStatusResultVo orderStatusResultVo = new OrderStatusResultVo();
|
|
|
if (!response.getSuccess()) {
|
|
|
throw new SystemException(response.getErrorMsg());
|
|
|
- }
|
|
|
- List<ZhongAnCrawlerPolicyListResponse.ValueDTO.DatasDTO.policyListsDto> policyLists = response.getValue().getDatas().getPolicyLists();
|
|
|
-
|
|
|
- OrderStatusResultVo orderStatusResultVo= new OrderStatusResultVo();
|
|
|
- if (policyLists.size() >0) {
|
|
|
- policyLists.forEach(s->{
|
|
|
- if (s.getInsureTypeCode().equals("1")) {
|
|
|
- orderStatusResultVo.setSyPolicyno(s.getTpPolicyNo());
|
|
|
- orderStatusResultVo.setSyApplyNo(s.getApplyNo());
|
|
|
- }else if (s.getInsureTypeCode().equals("2")) {
|
|
|
- orderStatusResultVo.setJqPolicyno(s.getTpPolicyNo());
|
|
|
- orderStatusResultVo.setJqApplyNo(s.getApplyNo());
|
|
|
- }else if (s.getInsureTypeCode().equals("3")) {
|
|
|
- orderStatusResultVo.setJyPolicyno(s.getTpPolicyNo());
|
|
|
- orderStatusResultVo.setJyApplyNo(s.getApplyNo());
|
|
|
+ } else {
|
|
|
+ List<ZhongAnCrawlerPolicyListResponse.ValueDTO.DatasDTO.policyListsDto> policyLists = response.getValue().getDatas().getPolicyLists();
|
|
|
+ // 根据订单号获取记录
|
|
|
+ String orderNo = zhongAnCrawlerOrder.getOrderNo();
|
|
|
+ if (policyLists.size() > 0) {
|
|
|
+ for (ZhongAnCrawlerPolicyListResponse.ValueDTO.DatasDTO.policyListsDto policy : policyLists) {
|
|
|
+ // 匹配当前订单号
|
|
|
+ if (orderNo.equals(policy.getOrderNo())) {
|
|
|
+ if (policy.getInsureTypeCode().equals("2")) {
|
|
|
+ orderStatusResultVo.setJqApplyNo(policy.getApplyNo());
|
|
|
+ } else if (policy.getInsureTypeCode().equals("1")) {
|
|
|
+ orderStatusResultVo.setSyApplyNo(policy.getApplyNo());
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(policy.getManualAuditStatus())) {
|
|
|
+ // 人工审核通过 待支付
|
|
|
+ if ("1".equals(policy.getManualAuditStatus()) || "3".equals(policy.getManualAuditStatus()) || "4".equals(policy.getManualAuditStatus())) {
|
|
|
+ orderStatusResultVo.setOrderStatus(InsOrderStatusEnum.PAY_PENDING);
|
|
|
+ }
|
|
|
+ // 质检中
|
|
|
+ if ("2".equals(policy.getManualAuditStatus())) {
|
|
|
+ orderStatusResultVo.setOrderStatus(InsOrderStatusEnum.STAFF_PROCESS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 人工核保
|
|
|
+ if (StrUtil.isNotBlank(policy.getGreenQuoteStatus())) {
|
|
|
+ if ("3".equals(policy.getGreenQuoteStatus())) {
|
|
|
+ orderStatusResultVo.setOrderStatus(InsOrderStatusEnum.AUDIT_FAIL);
|
|
|
+ // 查看退回原因
|
|
|
+ ZhongAnCrawlerQueryAccommodationRequest queryAccommodationRequest = new ZhongAnCrawlerQueryAccommodationRequest(zhongAnCrawlerOrder.getQuoteId(),parameters);
|
|
|
+ ZhongAnCrawlerQueryAccommodationResponse queryAccommodationResponse = zhongAnCrawlerRequestComponent.queryAccommodation(queryAccommodationRequest,headers);
|
|
|
+ if (queryAccommodationResponse.getSuccess()) {
|
|
|
+ ZhongAnCrawlerQueryAccommodationResponse.ValueDTO.DatasDTO.AccommodationDTO accommodationDTO = queryAccommodationResponse.getValue().getDatas().getAccommodation();
|
|
|
+ if (accommodationDTO.getErrorCode() != null) {
|
|
|
+ orderStatusResultVo.setOrderStatusStr(accommodationDTO.getErrorCode());
|
|
|
+ orderStatusResultVo.setOrderStatus(InsOrderStatusEnum.AUDIT_FAIL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //
|
|
|
+ if ("0".equals(policy.getGreenQuoteStatus())) {
|
|
|
+ // 查看退回原因
|
|
|
+ ZhongAnCrawlerQueryAccommodationRequest queryAccommodationRequest = new ZhongAnCrawlerQueryAccommodationRequest(zhongAnCrawlerOrder.getQuoteId(),parameters);
|
|
|
+ ZhongAnCrawlerQueryAccommodationResponse queryAccommodationResponse = zhongAnCrawlerRequestComponent.queryAccommodation(queryAccommodationRequest,headers);
|
|
|
+ Long id = queryAccommodationResponse.getValue().getDatas().getAccommodation().getId();
|
|
|
+ String identityNo = orderStatusVo.getInsOrdersCarUserInfoList().stream()
|
|
|
+ .filter(insOrdersCarUserInfo -> insOrdersCarUserInfo.getPolicyPersonType() == 2)
|
|
|
+ .findFirst()
|
|
|
+ .map(InsOrdersCarUserInfo::getIdentifyNumber)
|
|
|
+ .orElse(null);
|
|
|
+ // 提交通融
|
|
|
+ ZhongAnCrawlerApplyAccommodationRequest applyAccommodationRequest = new ZhongAnCrawlerApplyAccommodationRequest(id,zhongAnCrawlerOrder.getQuoteId(),identityNo,zhongAnCrawlerOrder.getOrderNo(),parameters);
|
|
|
+ ZhongAnCrawlerApplyAccommodationResponse applyAccommodationResponse = zhongAnCrawlerRequestComponent.applyAccommodation(applyAccommodationRequest,headers);
|
|
|
+ if (applyAccommodationResponse.getSuccess()) {
|
|
|
+ orderStatusResultVo.setOrderStatus(InsOrderStatusEnum.STAFF_PROCESS);
|
|
|
+ orderStatusResultVo.setOrderStatusStr("提交通融成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- });
|
|
|
- ZhongAnCrawlerPolicyListResponse.ValueDTO.DatasDTO.policyListsDto policyListsDto = policyLists.get(0);
|
|
|
- String policyStatus = policyListsDto.getPolicyStatus();
|
|
|
- if (policyStatus == null) {
|
|
|
- orderStatusResultVo.setOrderStatus(InsOrderStatusEnum.QUOTE_FAIL);
|
|
|
- }else {
|
|
|
- if (policyStatus.equals("3")) {
|
|
|
- orderStatusResultVo.setOrderStatus(InsOrderStatusEnum.PAY_PENDING);
|
|
|
- }else if (policyStatus.equals("6")) {
|
|
|
- orderStatusResultVo.setOrderStatus(InsOrderStatusEnum.UNDERWRITED);
|
|
|
+ }
|
|
|
+ // 如果待支付查不到订单 再去已支付列表查 有没有订单
|
|
|
+ if (policyLists.size() == 0) {
|
|
|
+ ZhongAnCrawlerPolicyListRequest policyListPayRequest = new ZhongAnCrawlerPolicyListRequest(licenseNo,parameters,"1");
|
|
|
+ ZhongAnCrawlerPolicyListResponse policyListPayResponse = zhongAnCrawlerRequestComponent.policyList(policyListPayRequest,headers);
|
|
|
+ if (policyListPayResponse.getSuccess()) {
|
|
|
+ List<ZhongAnCrawlerPolicyListResponse.ValueDTO.DatasDTO.policyListsDto> policyPayLists = response.getValue().getDatas().getPolicyLists();
|
|
|
+ if (policyPayLists.size() == 0) {
|
|
|
+ orderStatusResultVo.setOrderStatus(InsOrderStatusEnum.ORDER_CLOSE);
|
|
|
+ orderStatusResultVo.setErrorMsg("未查询到订单信息");
|
|
|
+ }
|
|
|
+ if (policyPayLists.size() > 0) {
|
|
|
+ for (ZhongAnCrawlerPolicyListResponse.ValueDTO.DatasDTO.policyListsDto policy : policyPayLists) {
|
|
|
+ if (orderNo.equals(policy.getOrderNo())) {
|
|
|
+ // 保单号
|
|
|
+ if (policy.getInsureTypeCode().equals("2")) {
|
|
|
+ orderStatusResultVo.setJqPolicyno(policy.getTpPolicyNo());
|
|
|
+ } else if (policy.getInsureTypeCode().equals("1")) {
|
|
|
+ orderStatusResultVo.setSyPolicyno(policy.getTpPolicyNo());
|
|
|
+ } else if (policy.getInsureTypeCode().equals("3")) {
|
|
|
+ orderStatusResultVo.setJyPolicyno(policy.getTpPolicyNo());
|
|
|
+ }
|
|
|
+ orderStatusResultVo.setOrderStatus(InsOrderStatusEnum.UNDERWRITED);
|
|
|
+ } else {
|
|
|
+ orderStatusResultVo.setOrderStatus(InsOrderStatusEnum.ORDER_CLOSE);
|
|
|
+ orderStatusResultVo.setOrderStatusStr("订单不存在,或联系运营查询");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ return orderStatusResultVo;
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public void login(LoginBase loginBase) {
|
|
|
|
|
|
- return orderStatusResultVo;
|
|
|
}
|
|
|
}
|