|
|
@@ -1,653 +0,0 @@
|
|
|
-//package com.jzg.quotation.zhongan.crawler.service;
|
|
|
-//
|
|
|
-//import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
-//import com.fasterxml.jackson.databind.JsonNode;
|
|
|
-//import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-//import org.apache.hc.client5.http.classic.methods.HttpPost;
|
|
|
-//import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
|
|
-//import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
|
|
|
-//import org.apache.hc.client5.http.impl.classic.HttpClients;
|
|
|
-//import org.apache.hc.core5.http.ContentType;
|
|
|
-//import org.apache.hc.core5.http.io.entity.StringEntity;
|
|
|
-//import org.apache.hc.core5.http.message.BasicHeader;
|
|
|
-//import redis.clients.jedis.Jedis;
|
|
|
-//import java.io.IOException;
|
|
|
-//import java.nio.charset.StandardCharsets;
|
|
|
-//import java.util.*;
|
|
|
-//import java.util.regex.Matcher;
|
|
|
-//import java.util.regex.Pattern;
|
|
|
-//
|
|
|
-//public class InsuranceCalculator {
|
|
|
-// // 成员变量(对应Python类的self.xxx)
|
|
|
-// private String flowId;
|
|
|
-// private Map<String, String> headers = new HashMap<>();
|
|
|
-// private Map<String, String> cookies = new HashMap<>();
|
|
|
-// private String quoteId;
|
|
|
-// private String zhejiuPrice;
|
|
|
-// private String sanzheChooseFlag;
|
|
|
-// private String sanzheAmount;
|
|
|
-// private String sjzerenChooseFlag;
|
|
|
-// private String sjzerenAmount;
|
|
|
-// private String ckzerenChooseFlag;
|
|
|
-// private String ckzerenAmount;
|
|
|
-// private String ybwSanzheChooseFlag;
|
|
|
-// private String ybwSanzheAmount;
|
|
|
-// private String ybwSijiChooseFlag;
|
|
|
-// private String ybwSijiAmount;
|
|
|
-// private String ybwCkChooseFlag;
|
|
|
-// private String ybwCkAmount;
|
|
|
-// private String huahenChooseFlag;
|
|
|
-// private String huahenAmount;
|
|
|
-// private String chesunChooseFlag;
|
|
|
-// private String fujiaJiejiariChooseFlag;
|
|
|
-// private String wbdwChooseFlag;
|
|
|
-// private Map<String, Object> accidentalDriving;
|
|
|
-// private String jiaoqiangChooseFlag;
|
|
|
-// private String shangyeChooseFlag;
|
|
|
-// private String jiaoqiangStartDate;
|
|
|
-// private String chesunStartDate;
|
|
|
-// private Integer maxQuoteNum;
|
|
|
-// private String zaLoginCookieKey;
|
|
|
-// private String licenseNo;
|
|
|
-// private String vin;
|
|
|
-// private String tbIdentifyNumber;
|
|
|
-// private String username;
|
|
|
-// private String cftbMessage;
|
|
|
-// private String jqRepeatinfo;
|
|
|
-// private String syRepeatinfo;
|
|
|
-// private String seat;
|
|
|
-// private Map<String, Object> carInfo = new HashMap<>();
|
|
|
-// private Map<String, Object> fjxDict = new HashMap<>();
|
|
|
-// private List<Map<String, Object>> coverageInfo = new ArrayList<>();
|
|
|
-// private List<Map<String, Object>> nonAutoInfo = new ArrayList<>();
|
|
|
-// private Map<String, String> data = new HashMap<>();
|
|
|
-//
|
|
|
-// // JSON解析器
|
|
|
-// private static final ObjectMapper objectMapper = new ObjectMapper();
|
|
|
-// // Redis连接(实际使用中建议通过连接池管理)
|
|
|
-// private Jedis redisConn = new Jedis("localhost", 6379);
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 核心计算方法(对应Python的calculation方法)
|
|
|
-// */
|
|
|
-// public Map<String, Object> calculation() throws IOException {
|
|
|
-// // 第一步:发送基础信息请求
|
|
|
-// String baseUrl = "https://c.zhongan.com/open/bmw/n/quote_controller/query_quote_base_info.json";
|
|
|
-// Map<String, String> baseData = new HashMap<>();
|
|
|
-// baseData.put("flowId", flowId);
|
|
|
-// baseData.put("page", "/insureProgram");
|
|
|
-// baseData.put("flag", "0");
|
|
|
-// baseData.put("i", "e");
|
|
|
-// baseData.put("quoteType", "0");
|
|
|
-//
|
|
|
-// String baseResponse = sendPostRequest(baseUrl, headers, cookies, baseData);
|
|
|
-// // 提取quoteId(正则匹配)
|
|
|
-// quoteId = extractByRegex(baseResponse, "\"quoteId\":\"(.*?)\"", 1);
|
|
|
-// // 提取vehicleActualPrice
|
|
|
-// JsonNode baseJson = objectMapper.readTree(baseResponse);
|
|
|
-// zhejiuPrice = baseJson.path("value").path("baseInfo").path("vehicleActualPrice").asText("");
|
|
|
-//
|
|
|
-// // 构建coverageInfo(根据不同选择标志)
|
|
|
-// buildCoverageInfo(baseResponse);
|
|
|
-//
|
|
|
-// // 构建nonAutoInfo(驾意险相关)
|
|
|
-// buildNonAutoInfo();
|
|
|
-//
|
|
|
-// // 构建报价参数data
|
|
|
-// buildQuoteData();
|
|
|
-//
|
|
|
-// // 处理即时起保
|
|
|
-// handleInstantCoverage();
|
|
|
-//
|
|
|
-// // 第二步:发送报价请求
|
|
|
-// return sendQuoteRequest();
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 发送POST请求
|
|
|
-// */
|
|
|
-// private String sendPostRequest(String url, Map<String, String> headers, Map<String, String> cookies, Map<String, String> data) throws IOException {
|
|
|
-// try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
|
|
|
-// HttpPost httpPost = new HttpPost(url);
|
|
|
-//
|
|
|
-// // 设置请求头
|
|
|
-// if (headers != null) {
|
|
|
-// headers.forEach((k, v) -> httpPost.addHeader(new BasicHeader(k, v)));
|
|
|
-// }
|
|
|
-// // 设置Cookie(合并到header)
|
|
|
-// if (cookies != null && !cookies.isEmpty()) {
|
|
|
-// StringBuilder cookieStr = new StringBuilder();
|
|
|
-// cookies.forEach((k, v) -> cookieStr.append(k).append("=").append(v).append("; "));
|
|
|
-// httpPost.addHeader("Cookie", cookieStr.toString().trim());
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 设置请求体(表单格式)
|
|
|
-// StringBuilder dataStr = new StringBuilder();
|
|
|
-// data.forEach((k, v) -> dataStr.append(k).append("=").append(v).append("&"));
|
|
|
-// httpPost.setEntity(new StringEntity(
|
|
|
-// dataStr.toString().replaceAll("&$", ""),
|
|
|
-// ContentType.APPLICATION_FORM_URLENCODED.withCharset(StandardCharsets.UTF_8)
|
|
|
-// ));
|
|
|
-//
|
|
|
-// // 执行请求
|
|
|
-// try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
|
|
|
-// return new String(response.getEntity().getContent().readAllBytes(), StandardCharsets.UTF_8);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 正则提取字符串
|
|
|
-// */
|
|
|
-// private String extractByRegex(String text, String regex, int group) {
|
|
|
-// Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);
|
|
|
-// Matcher matcher = pattern.matcher(text);
|
|
|
-// if (matcher.find()) {
|
|
|
-// return matcher.group(group);
|
|
|
-// }
|
|
|
-// return "";
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 构建coverageInfo列表(对应Python中多个if判断添加coverageInfo的逻辑)
|
|
|
-// */
|
|
|
-// private void buildCoverageInfo(String responseText) {
|
|
|
-// // 第三者责任险
|
|
|
-// if ("on".equals(sanzheChooseFlag)) {
|
|
|
-// Map<String, Object> coverage = new HashMap<>();
|
|
|
-// coverage.put("amount", sanzheAmount);
|
|
|
-// coverage.put("dutyAttributeType", "02");
|
|
|
-// coverage.put("dutyAttributeValue", "0");
|
|
|
-// coverage.put("productId", responseText.contains("新能源") ? "1510052325" : "1510030944");
|
|
|
-// coverageInfo.add(coverage);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 司机责任险
|
|
|
-// if ("on".equals(sjzerenChooseFlag)) {
|
|
|
-// Map<String, Object> coverage = new HashMap<>();
|
|
|
-// coverage.put("amount", sjzerenAmount);
|
|
|
-// coverage.put("dutyAttributeType", "02");
|
|
|
-// coverage.put("dutyAttributeValue", "0");
|
|
|
-// coverage.put("productId", responseText.contains("新能源") ? "1510052326" : "1510030945");
|
|
|
-// coverageInfo.add(coverage);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 乘客责任险
|
|
|
-// if ("on".equals(ckzerenChooseFlag)) {
|
|
|
-// Map<String, Object> coverage = new HashMap<>();
|
|
|
-// coverage.put("amount", ckzerenAmount);
|
|
|
-// coverage.put("dutyAttributeType", "02");
|
|
|
-// coverage.put("dutyAttributeValue", "0");
|
|
|
-// coverage.put("productId", responseText.contains("新能源") ? "1510052327" : "1510030946");
|
|
|
-// coverageInfo.add(coverage);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 医保外第三者
|
|
|
-// if ("on".equals(ybwSanzheChooseFlag)) {
|
|
|
-// Map<String, Object> coverage = new HashMap<>();
|
|
|
-// coverage.put("amount", ybwSanzheAmount);
|
|
|
-// coverage.put("dutyAttributeType", "02");
|
|
|
-// coverage.put("dutyAttributeValue", "0");
|
|
|
-// coverage.put("productId", responseText.contains("新能源") ? "1510052346" : "1510031007");
|
|
|
-// coverageInfo.add(coverage);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 医保外司机
|
|
|
-// if ("on".equals(ybwSijiChooseFlag)) {
|
|
|
-// Map<String, Object> coverage = new HashMap<>();
|
|
|
-// coverage.put("amount", ybwSijiAmount);
|
|
|
-// coverage.put("dutyAttributeType", "02");
|
|
|
-// coverage.put("dutyAttributeValue", "0");
|
|
|
-// coverage.put("productId", responseText.contains("新能源") ? "1510052347" : "1510031006");
|
|
|
-// coverageInfo.add(coverage);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 医保外乘客
|
|
|
-// if ("on".equals(ybwCkChooseFlag)) {
|
|
|
-// Map<String, Object> coverage = new HashMap<>();
|
|
|
-// coverage.put("amount", ybwCkAmount);
|
|
|
-// coverage.put("dutyAttributeType", "02");
|
|
|
-// coverage.put("dutyAttributeValue", "0");
|
|
|
-// coverage.put("productId", responseText.contains("新能源") ? "1510052348" : "1510030950");
|
|
|
-// coverageInfo.add(coverage);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 划痕险相关
|
|
|
-// if ("on".equals(huahenChooseFlag)) {
|
|
|
-// addHuahenCoverage(responseText);
|
|
|
-// }
|
|
|
-// // 车损险(未选划痕险但选了车损险)
|
|
|
-// if (!"on".equals(huahenChooseFlag) && "on".equals(chesunChooseFlag)) {
|
|
|
-// Map<String, Object> coverage = new HashMap<>();
|
|
|
-// coverage.put("amount", zhejiuPrice);
|
|
|
-// coverage.put("dutyAttributeType", "02");
|
|
|
-// coverage.put("dutyAttributeValue", "0");
|
|
|
-// coverage.put("productId", responseText.contains("新能源") ? "1510052324" : "1510030943");
|
|
|
-// coverageInfo.add(coverage);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 附加节假日
|
|
|
-// if ("on".equals(fujiaJiejiariChooseFlag)) {
|
|
|
-// Map<String, Object> coverage = new HashMap<>();
|
|
|
-// coverage.put("amount", sanzheAmount);
|
|
|
-// coverage.put("dutyAttributeType", "02");
|
|
|
-// coverage.put("dutyAttributeValue", "0");
|
|
|
-// coverage.put("productId", responseText.contains("新能源") ? "1510052345" : "1510031005");
|
|
|
-// coverageInfo.add(coverage);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 无法找到第三方
|
|
|
-// if ("on".equals(wbdwChooseFlag)) {
|
|
|
-// Map<String, Object> coverage = new HashMap<>();
|
|
|
-// coverage.put("amount", zhejiuPrice);
|
|
|
-// coverage.put("dutyAttributeType", "02");
|
|
|
-// coverage.put("dutyAttributeValue", "0");
|
|
|
-// coverage.put("productId", "1510052328");
|
|
|
-// coverageInfo.add(coverage);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 处理划痕险覆盖信息(含车损险判断)
|
|
|
-// */
|
|
|
-// private void addHuahenCoverage(String responseText) {
|
|
|
-// // 划痕险基础条目
|
|
|
-// Map<String, Object> huahen = new HashMap<>();
|
|
|
-// huahen.put("amount", huahenAmount);
|
|
|
-// huahen.put("dutyAttributeType", "02");
|
|
|
-// huahen.put("dutyAttributeValue", "0");
|
|
|
-// huahen.put("productId", responseText.contains("新能源") ? "1510052337" : "1510030949");
|
|
|
-// coverageInfo.add(huahen);
|
|
|
-//
|
|
|
-// // 车损险条目(无论是否选车损险,划痕险都需附加)
|
|
|
-// Map<String, Object> chesun = new HashMap<>();
|
|
|
-// chesun.put("amount", zhejiuPrice);
|
|
|
-// chesun.put("dutyAttributeType", "02");
|
|
|
-// chesun.put("dutyAttributeValue", "0");
|
|
|
-// chesun.put("productId", responseText.contains("新能源") ? "1510052324" : "1510030943");
|
|
|
-// coverageInfo.add(chesun);
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 构建nonAutoInfo(驾意险相关)
|
|
|
-// */
|
|
|
-// private void buildNonAutoInfo() {
|
|
|
-// if (accidentalDriving != null && !accidentalDriving.isEmpty()) {
|
|
|
-// Map<String, Object> info = new HashMap<>();
|
|
|
-// info.put("productCode", "kp_jtywx_v24");
|
|
|
-// info.put("insuredFlag", "1");
|
|
|
-// info.put("combination", accidentalDriving.get("combination").toString());
|
|
|
-// nonAutoInfo.add(info);
|
|
|
-// } else {
|
|
|
-// Map<String, Object> info1 = new HashMap<>();
|
|
|
-// info1.put("productCode", "kp_jtywx_v24");
|
|
|
-// info1.put("insuredFlag", "0");
|
|
|
-// nonAutoInfo.add(info1);
|
|
|
-//
|
|
|
-// Map<String, Object> info2 = new HashMap<>();
|
|
|
-// info2.put("productCode", "health_jcwy_jtx_v1");
|
|
|
-// info2.put("insuredFlag", "0");
|
|
|
-// nonAutoInfo.add(info2);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 构建报价参数data
|
|
|
-// */
|
|
|
-// private void buildQuoteData() throws JsonProcessingException {
|
|
|
-// data.put("flowId", flowId);
|
|
|
-// data.put("page", "/insureProgram");
|
|
|
-// data.put("flag", "0");
|
|
|
-// data.put("i", "e");
|
|
|
-// data.put("nonAutoInfo", objectMapper.writeValueAsString(nonAutoInfo));
|
|
|
-//
|
|
|
-// // 单交强
|
|
|
-// if ("on".equals(jiaoqiangChooseFlag) && !"on".equals(shangyeChooseFlag)) {
|
|
|
-// data.put("addBusi", "0");
|
|
|
-// data.put("addCompel", "1");
|
|
|
-// data.put("addTax", "0");
|
|
|
-// data.put("compelInsEffectiveDate", jiaoqiangStartDate);
|
|
|
-// data.put("isTrusted", "true");
|
|
|
-// }
|
|
|
-// // 单商业
|
|
|
-// else if (!"on".equals(jiaoqiangChooseFlag) && "on".equals(shangyeChooseFlag)) {
|
|
|
-// data.put("addBusi", "1");
|
|
|
-// data.put("coverageInfo", objectMapper.writeValueAsString(coverageInfo));
|
|
|
-// data.put("addCompel", "0");
|
|
|
-// data.put("addTax", "0");
|
|
|
-// data.put("effectiveDate", chesunStartDate);
|
|
|
-// }
|
|
|
-// // 交商同投
|
|
|
-// else if ("on".equals(jiaoqiangChooseFlag) && "on".equals(shangyeChooseFlag)) {
|
|
|
-// data.put("addBusi", "1");
|
|
|
-// data.put("coverageInfo", objectMapper.writeValueAsString(coverageInfo));
|
|
|
-// data.put("addCompel", "1");
|
|
|
-// data.put("taxType", "PAY_TAXES");
|
|
|
-// data.put("addTax", "1");
|
|
|
-// data.put("effectiveDate", chesunStartDate);
|
|
|
-// data.put("compelInsEffectiveDate", jiaoqiangStartDate);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 处理即时起保参数
|
|
|
-// */
|
|
|
-// private void handleInstantCoverage() {
|
|
|
-// boolean jqLongEnough = jiaoqiangStartDate != null && jiaoqiangStartDate.length() > 16;
|
|
|
-// boolean syLongEnough = chesunStartDate != null && chesunStartDate.length() > 16;
|
|
|
-//
|
|
|
-// if (jqLongEnough && syLongEnough) {
|
|
|
-// data.put("compInstantFlag", "1");
|
|
|
-// data.put("busiInstantFlag", "1");
|
|
|
-// } else if (jqLongEnough) {
|
|
|
-// data.put("compInstantFlag", "1");
|
|
|
-// } else if (syLongEnough) {
|
|
|
-// data.put("busiInstantFlag", "1");
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 发送报价请求并处理结果
|
|
|
-// */
|
|
|
-// private Map<String, Object> sendQuoteRequest() throws IOException {
|
|
|
-// if (maxQuoteNum == null) {
|
|
|
-// return buildErrorResponse(400, "未获取到报价剩余次数", maxQuoteNum);
|
|
|
-// }
|
|
|
-// if (maxQuoteNum <= 0) {
|
|
|
-// return buildErrorResponse(400, "报价剩余次数不足", maxQuoteNum);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 发送报价请求
|
|
|
-// String quoteUrl = "https://c.zhongan.com/open/bmw/n/quote_controller/premium_trial.json";
|
|
|
-// maxQuoteNum--;
|
|
|
-// String quoteResponse = sendPostRequest(quoteUrl, headers, cookies, data);
|
|
|
-//
|
|
|
-// // 发送理赔信息请求
|
|
|
-// String claimUrl = "https://c.zhongan.com/open/bmw/n/query_controller/query_busi_claim_info.json";
|
|
|
-// Map<String, String> claimData = new HashMap<>();
|
|
|
-// claimData.put("flowId", flowId);
|
|
|
-// claimData.put("page", "%2FinsureProgram");
|
|
|
-// claimData.put("i", "e");
|
|
|
-// claimData.put("flag", "0");
|
|
|
-// sendPostRequest(claimUrl, headers, cookies, claimData); // 仅发送,不处理返回
|
|
|
-//
|
|
|
-// // 处理报价响应
|
|
|
-// JsonNode quoteJson = objectMapper.readTree(quoteResponse);
|
|
|
-// if (!quoteJson.path("success").asBoolean(true)) {
|
|
|
-// return buildErrorResponse(400, quoteJson.path("errorMsg").asText("请求失败"), maxQuoteNum);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 处理"您的爱车上一年"相关逻辑(二次报价)
|
|
|
-// if (quoteResponse.contains("您的爱车上一年")) {
|
|
|
-// return handleYearlyRenewal(quoteResponse);
|
|
|
-// } else {
|
|
|
-// // 直接处理正常报价结果
|
|
|
-// return handleNormalQuote(quoteResponse);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 处理续保相关逻辑(含二次报价)
|
|
|
-// */
|
|
|
-// private Map<String, Object> handleYearlyRenewal(String firstResponse) throws IOException {
|
|
|
-// // 提取续保信息
|
|
|
-// jqRepeatinfo = extractByRegex(firstResponse, "\"insureMessageF\":\"(.*?)\"", 1);
|
|
|
-// syRepeatinfo = extractByRegex(firstResponse, "\"insureMessage\":\"(.*?)\"", 1);
|
|
|
-//
|
|
|
-// // 处理交强险到期日
|
|
|
-// String jqData = extractByRegex(firstResponse, "交强险于(.*?)到期", 1);
|
|
|
-// String formattedJqDate = formatDate(jqData);
|
|
|
-// // 处理商业险到期日
|
|
|
-// String syData = extractByRegex(firstResponse, "商业险于(.*?)到期", 1);
|
|
|
-// String formattedSyDate = formatDate(syData);
|
|
|
-//
|
|
|
-// // 更新data参数并二次报价
|
|
|
-// data.put("effectiveDate", formattedSyDate != null ? formattedSyDate : chesunStartDate);
|
|
|
-// data.put("compelInsEffectiveDate", formattedJqDate != null ? formattedJqDate : jiaoqiangStartDate);
|
|
|
-//
|
|
|
-// if (maxQuoteNum <= 0) {
|
|
|
-// return buildErrorResponse(400, "报价剩余次数不足", maxQuoteNum);
|
|
|
-// }
|
|
|
-// maxQuoteNum--;
|
|
|
-// String secondUrl = "https://c.zhongan.com/open/bmw/n/quote_controller/premium_trial.json";
|
|
|
-// String secondResponse = sendPostRequest(secondUrl, headers, cookies, data);
|
|
|
-//
|
|
|
-// // 若二次响应仍包含续保信息,三次报价(逻辑同Python)
|
|
|
-// if (secondResponse.contains("您的爱车上一年")) {
|
|
|
-// // 重复提取和格式化日期(代码省略,同上述逻辑)
|
|
|
-// // ...(此处省略与上述相同的日期提取和格式化代码)
|
|
|
-//
|
|
|
-// if (maxQuoteNum <= 0) {
|
|
|
-// return buildErrorResponse(400, "报价剩余次数不足", maxQuoteNum);
|
|
|
-// }
|
|
|
-// maxQuoteNum--;
|
|
|
-// String thirdResponse = sendPostRequest(secondUrl, headers, cookies, data);
|
|
|
-// return handleNormalQuote(thirdResponse);
|
|
|
-// } else {
|
|
|
-// return handleNormalQuote(secondResponse);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 处理正常报价结果
|
|
|
-// */
|
|
|
-// private Map<String, Object> handleNormalQuote(String response) throws IOException {
|
|
|
-// JsonNode json = objectMapper.readTree(response);
|
|
|
-// // 提取价格信息
|
|
|
-// String totalPremium = extractByRegex(response, "\"totalPremium\":(.*?),", 1);
|
|
|
-// String taxPremium = extractByRegex(response, "\"taxPremium\":(.*?),", 1);
|
|
|
-// String bizPremium = extractByRegex(response, "\"bizTotalPremium\":(.*?),", 1);
|
|
|
-// String compelPremium = extractByRegex(response, "\"compelPremium\":(.*?),", 1);
|
|
|
-//
|
|
|
-// // 处理附加险信息
|
|
|
-// handleCoveragePremium(json, response.contains("新能源"));
|
|
|
-//
|
|
|
-// // 生成订单号
|
|
|
-// String plyappno = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
-// // 存储Redis信息
|
|
|
-// saveToRedis(plyappno);
|
|
|
-//
|
|
|
-// // 处理评分、折扣率
|
|
|
-// String mark = extractByRegex(response, "policyGradePa\":\"(.*?)\"", 1);
|
|
|
-// String jqDiscount = extractByRegex(response, "compelDiscount\":\"(.*?)\"", 1);
|
|
|
-// String syDiscount = extractByRegex(response, "businessDiscount\":\"(.*?)\"", 1);
|
|
|
-//
|
|
|
-// // 处理起止日期
|
|
|
-// Map<String, String> dateInfo = handleDateRange();
|
|
|
-//
|
|
|
-// // 处理驾意险信息
|
|
|
-// List<Map<String, Object>> fcxInfoList = buildFcxInfoList(json);
|
|
|
-//
|
|
|
-// // 处理车型信息
|
|
|
-// Map<String, Object> carInfo = buildCarInfo();
|
|
|
-//
|
|
|
-// // 处理绿通信息
|
|
|
-// Map<String, Object> greenWayInfo = handleGreenWay(response);
|
|
|
-//
|
|
|
-// // 构建返回结果
|
|
|
-// Map<String, Object> result = new HashMap<>();
|
|
|
-// result.put("code", 200);
|
|
|
-// result.put("INSURANCE_TYPE", fjxDict);
|
|
|
-// result.put("carInsureShiptax", taxPremium);
|
|
|
-// result.put("busiTotalPremium", bizPremium);
|
|
|
-// result.put("forceCarInsureRisk", compelPremium);
|
|
|
-// result.put("carInsureMain", totalPremium);
|
|
|
-// result.put("plyappno", plyappno);
|
|
|
-// result.put("message", cftbMessage);
|
|
|
-// result.put("other", Map.of(
|
|
|
-// "mark", mark,
|
|
|
-// "jq_discount", jqDiscount,
|
|
|
-// "sy_discount", syDiscount,
|
|
|
-// "isQuoteGreenWay", greenWayInfo.get("isQuoteGreenWay"),
|
|
|
-// "errorCodeMap", greenWayInfo.get("errorCodeMap"),
|
|
|
-// "jq_renewalflag", json.path("value").path("datas").path("forceRenewalFlag").asText().equals("ZA") ? "1" : "0",
|
|
|
-// "sy_renewalflag", json.path("value").path("datas").path("forceRenewalFlag").asText().equals("ZA") ? "1" : "0",
|
|
|
-// "maxQuoteNum", maxQuoteNum
|
|
|
-// ));
|
|
|
-// result.put("jq_startDate", dateInfo.get("jqStartDate"));
|
|
|
-// result.put("jq_endDate", dateInfo.get("jqEndDate"));
|
|
|
-// result.put("sy_startDate", dateInfo.get("syStartDate"));
|
|
|
-// result.put("sy_endDate", dateInfo.get("syEndDate"));
|
|
|
-// result.put("jq_repeatinfo", jqRepeatinfo);
|
|
|
-// result.put("sy_repeatinfo", syRepeatinfo);
|
|
|
-// result.put("drivingInsurances", fcxInfoList);
|
|
|
-// result.put("carInfo", carInfo);
|
|
|
-//
|
|
|
-// // 存储结果到Redis
|
|
|
-// redisConn.hset("zhongan_" + plyappno, "ret", objectMapper.writeValueAsString(result));
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 格式化日期字符串
|
|
|
-// */
|
|
|
-// private String formatDate(String dateStr) {
|
|
|
-// if (dateStr == null || dateStr.isEmpty()) return null;
|
|
|
-// dateStr = dateStr.replace("年", "-").replace("月", "-").replace("日", "");
|
|
|
-// // 处理不同长度的日期(逻辑同Python)
|
|
|
-// // ...(此处省略具体日期格式化代码,可根据Python逻辑实现)
|
|
|
-// return dateStr;
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 处理附加险保费信息
|
|
|
-// */
|
|
|
-// private void handleCoveragePremium(JsonNode json, boolean isNewEnergy) {
|
|
|
-// JsonNode coverageList = json.path("value").path("datas").path("vehiclePremium").path("vehicleCoverageList");
|
|
|
-// if (coverageList.isArray()) {
|
|
|
-// for (JsonNode node : coverageList) {
|
|
|
-// String productId = node.path("productId").asText();
|
|
|
-// String premium = node.path("totalCoveragePremium").asText();
|
|
|
-// if (isNewEnergy) {
|
|
|
-// mapPremium(productId, premium,
|
|
|
-// Map.of("1510052324", "A", "1510052325", "B",
|
|
|
-// "1510052326", "D3", "1510052327", "D4",
|
|
|
-// "1510052345", "BD", "1510030943", "L",
|
|
|
-// "1510052346", "SY_FJ_YBW1", "1510052348", "SY_FJ_YBW2",
|
|
|
-// "1510052347", "SY_FJ_YBW3", "1510052328", "SY_WBDWGZ"));
|
|
|
-// } else {
|
|
|
-// mapPremium(productId, premium,
|
|
|
-// Map.of("1510030943", "A", "1510030944", "B",
|
|
|
-// "1510030945", "D3", "1510030946", "D4",
|
|
|
-// "1510031005", "BD", "1510030949", "L",
|
|
|
-// "1510031007", "SY_FJ_YBW1", "1510030950", "SY_FJ_YBW2",
|
|
|
-// "1510031006", "SY_FJ_YBW3"));
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// fjxDict.put("A_amount", zhejiuPrice);
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 映射附加险保费到字典
|
|
|
-// */
|
|
|
-// private void mapPremium(String productId, String premium, Map<String, String> mapping) {
|
|
|
-// if (mapping.containsKey(productId)) {
|
|
|
-// fjxDict.put(mapping.get(productId), premium);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 存储信息到Redis
|
|
|
-// */
|
|
|
-// private void saveToRedis(String plyappno) {
|
|
|
-// redisConn.hset("zhongan_" + plyappno, "flowId", flowId);
|
|
|
-// redisConn.hset("zhongan_" + plyappno, "zaLoginCookieKey", zaLoginCookieKey);
|
|
|
-// redisConn.hset("zhongan_" + plyappno, "license", licenseNo);
|
|
|
-// redisConn.hset("zhongan_" + plyappno, "vin", vin);
|
|
|
-// redisConn.hset("zhongan_" + plyappno, "tb_identifyNumber", tbIdentifyNumber);
|
|
|
-// redisConn.hset("zhongan_" + plyappno, "username", username);
|
|
|
-// redisConn.hset("zhongan_" + plyappno, "jiaoqiang_chooseFlag", jiaoqiangChooseFlag);
|
|
|
-// redisConn.hset("zhongan_" + plyappno, "shangye_chooseFlag", shangyeChooseFlag);
|
|
|
-// redisConn.hset("zhongan_" + plyappno, "accidentalDriving", accidentalDriving.toString());
|
|
|
-// redisConn.expire("zhongan_" + plyappno, 5184000); // 60天过期
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 处理日期范围(起保日和到期日)
|
|
|
-// */
|
|
|
-// private Map<String, String> handleDateRange() {
|
|
|
-// Map<String, String> dateInfo = new HashMap<>();
|
|
|
-// // 逻辑同Python:根据交强和商业险选择情况计算起止日期
|
|
|
-// // ...(此处省略具体日期计算代码)
|
|
|
-// return dateInfo;
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 构建驾意险信息列表
|
|
|
-// */
|
|
|
-// private List<Map<String, Object>> buildFcxInfoList(JsonNode json) {
|
|
|
-// List<Map<String, Object>> list = new ArrayList<>();
|
|
|
-// if (accidentalDriving != null && !accidentalDriving.isEmpty()) {
|
|
|
-// Map<String, Object> info = new HashMap<>();
|
|
|
-// info.put("name", accidentalDriving.get("name"));
|
|
|
-// info.put("price", json.path("value").path("datas").path("vehiclePremium").path("nonTotalPremium").asText());
|
|
|
-// info.put("policy", "");
|
|
|
-// list.add(info);
|
|
|
-// }
|
|
|
-// return list;
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 构建车型信息
|
|
|
-// */
|
|
|
-// private Map<String, Object> buildCarInfo() {
|
|
|
-// Map<String, Object> info = new HashMap<>();
|
|
|
-// info.put("modelcname", carInfo.get("vehicleModelName"));
|
|
|
-// info.put("modelCode", carInfo.get("vehicleModelCode"));
|
|
|
-// info.put("exhaustscale", carInfo.get("exhaustMeasure"));
|
|
|
-// info.put("seatCount", seat);
|
|
|
-// info.put("purchasePrice", carInfo.get("vehicleAcquisitionPrice"));
|
|
|
-// info.put("power", carInfo.get("power"));
|
|
|
-// info.put("caryear", carInfo.get("configName"));
|
|
|
-// return info;
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 处理绿通信息
|
|
|
-// */
|
|
|
-// private Map<String, Object> handleGreenWay(String response) throws IOException {
|
|
|
-// Map<String, Object> greenInfo = new HashMap<>();
|
|
|
-// String isGreen = extractByRegex(response, "isQuoteGreenWay\":\"(.*?)\"", 1);
|
|
|
-// greenInfo.put("isQuoteGreenWay", isGreen.isEmpty() ? "0" : isGreen);
|
|
|
-//
|
|
|
-// if (!isGreen.isEmpty()) {
|
|
|
-// String greenUrl = "https://c.zhongan.com/open/bmw/quote_controller/get_green_base_info.json";
|
|
|
-// Map<String, String> greenData = new HashMap<>();
|
|
|
-// greenData.put("quoteId", quoteId);
|
|
|
-// greenData.put("flowId", flowId);
|
|
|
-// greenData.put("page", "%2FinsureProgram");
|
|
|
-// greenData.put("i", "e");
|
|
|
-// greenData.put("flag", "0");
|
|
|
-//
|
|
|
-// String greenResponse = sendPostRequest(greenUrl, headers, cookies, greenData);
|
|
|
-// JsonNode greenJson = objectMapper.readTree(greenResponse);
|
|
|
-// JsonNode errorCodeMap = greenJson.path("value").path("datas").path("errorCodeMap");
|
|
|
-//
|
|
|
-// List<String> errorList = new ArrayList<>();
|
|
|
-// if (errorCodeMap.isObject()) {
|
|
|
-// errorCodeMap.fieldNames().forEachRemaining(key ->
|
|
|
-// errorList.add(key + ":" + errorCodeMap.path(key).asText())
|
|
|
-// );
|
|
|
-// }
|
|
|
-// greenInfo.put("errorCodeMap", errorList);
|
|
|
-// } else {
|
|
|
-// greenInfo.put("errorCodeMap", new ArrayList<>());
|
|
|
-// }
|
|
|
-// return greenInfo;
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 构建错误响应
|
|
|
-// */
|
|
|
-// private Map<String, Object> buildErrorResponse(int code, String message, Integer maxQuoteNum) {
|
|
|
-// Map<String, Object> error = new HashMap<>();
|
|
|
-// error.put("code", code);
|
|
|
-// error.put("message", message);
|
|
|
-// error.put("other", Map.of("maxQuoteNum", maxQuoteNum));
|
|
|
-// return error;
|
|
|
-// }
|
|
|
-//
|
|
|
-// // Getter和Setter(省略,实际使用中需生成)
|
|
|
-// // ...
|
|
|
-//}
|