|
@@ -1,10 +1,8 @@
|
|
|
package com.jzg.quotation.taikang.crawler.service;
|
|
package com.jzg.quotation.taikang.crawler.service;
|
|
|
|
|
|
|
|
-import com.jzg.commons.constants.quote.enums.quote.CarKindCode;
|
|
|
|
|
-import com.jzg.commons.constants.quote.enums.quote.VehicleUseCode;
|
|
|
|
|
import com.jzg.commons.entity.orders.po.InsOrdersCarUserInfo;
|
|
import com.jzg.commons.entity.orders.po.InsOrdersCarUserInfo;
|
|
|
import com.jzg.commons.entity.quote.vo.*;
|
|
import com.jzg.commons.entity.quote.vo.*;
|
|
|
-import com.jzg.commons.util.IDCardUtils;
|
|
|
|
|
|
|
+
|
|
|
import com.jzg.quotation.commons.filter.CarModelsFilterUtils;
|
|
import com.jzg.quotation.commons.filter.CarModelsFilterUtils;
|
|
|
import com.jzg.quotation.taikang.crawler.CodeUtil;
|
|
import com.jzg.quotation.taikang.crawler.CodeUtil;
|
|
|
import com.jzg.quotation.taikang.crawler.model.TKLoginSession;
|
|
import com.jzg.quotation.taikang.crawler.model.TKLoginSession;
|
|
@@ -19,7 +17,9 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.function.Consumer;
|
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
|
|
|
+import java.util.function.Supplier;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -29,6 +29,62 @@ public class TKSimpleService {
|
|
|
@Resource
|
|
@Resource
|
|
|
private TKHttpAPIService httpService;
|
|
private TKHttpAPIService httpService;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 车船税减免标志映射表:公司系统标志 -> 保司系统标志
|
|
|
|
|
+ */
|
|
|
|
|
+ private static final Map<String, String> TAX_RELIEF_FLAG_MAP = Map.of(
|
|
|
|
|
+ "1", "T",
|
|
|
|
|
+ "2", "E",
|
|
|
|
|
+ "3", "C",
|
|
|
|
|
+ "4", "P"
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 通用空值检查与初始化方法
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * 如果 getter 返回值为 null,则通过 constructor 创建新实例并通过 setter 设置
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param getter 获取当前值的函数
|
|
|
|
|
+ * @param setter 设置新值的函数
|
|
|
|
|
+ * @param constructor 创建新实例的函数
|
|
|
|
|
+ * @param <T> 对象类型
|
|
|
|
|
+ * @return 非空的目标对象
|
|
|
|
|
+ */
|
|
|
|
|
+ private <T> T ensureNonNull(Supplier<T> getter, Consumer<T> setter, Supplier<T> constructor) {
|
|
|
|
|
+ T value = getter.get();
|
|
|
|
|
+ if (value == null) {
|
|
|
|
|
+ value = constructor.get();
|
|
|
|
|
+ setter.accept(value);
|
|
|
|
|
+ }
|
|
|
|
|
+ return value;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 重置驾意险信息为"不投保"状态
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param driverAccidentVo 驾意险信息对象
|
|
|
|
|
+ */
|
|
|
|
|
+ private void resetDriverAccidentVo(TKDriverAccidentVo driverAccidentVo) {
|
|
|
|
|
+ driverAccidentVo.setIsSelect("0");
|
|
|
|
|
+ driverAccidentVo.setQuantity(0);
|
|
|
|
|
+ driverAccidentVo.setQuantityCname("不投保");
|
|
|
|
|
+ driverAccidentVo.setPremium(BigDecimal.ZERO);
|
|
|
|
|
+ driverAccidentVo.setNonCarStartDate(null);
|
|
|
|
|
+ driverAccidentVo.setNonCarEndDate(null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 重置非车险产品信息为"不投保"状态
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param nonCarProductListDTO 非车险产品列表项
|
|
|
|
|
+ */
|
|
|
|
|
+ private void resetNonCarProduct(PreciseInitResult.NonCarProductListDTO nonCarProductListDTO) {
|
|
|
|
|
+ nonCarProductListDTO.setIsSelect("0");
|
|
|
|
|
+ nonCarProductListDTO.setPremium("0");
|
|
|
|
|
+ nonCarProductListDTO.setStartDate(null);
|
|
|
|
|
+ nonCarProductListDTO.setEndDate(null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public TKLoginSession login(String username, String password) {
|
|
public TKLoginSession login(String username, String password) {
|
|
|
IdentityTokenResult identityTokenResult = httpService.identityToken();
|
|
IdentityTokenResult identityTokenResult = httpService.identityToken();
|
|
|
|
|
|
|
@@ -274,15 +330,8 @@ public class TKSimpleService {
|
|
|
carInfoVo.setOperateFlag("6");
|
|
carInfoVo.setOperateFlag("6");
|
|
|
carInfoVo.setLicenseNo(commonCarInfoVo.getLicenseNo());
|
|
carInfoVo.setLicenseNo(commonCarInfoVo.getLicenseNo());
|
|
|
|
|
|
|
|
- // 车辆大类
|
|
|
|
|
- String carKindCode = commonCarInfoVo.getCarKindCode();
|
|
|
|
|
- if (carKindCode.equals(CarKindCode.CAR_KIND_CODE_A0.getCode())) {
|
|
|
|
|
- carInfoVo.setCarType("A");
|
|
|
|
|
- } else if (carKindCode.equals(CarKindCode.CAR_KIND_CODE_A1.getCode())) {
|
|
|
|
|
- carInfoVo.setCarType("D");
|
|
|
|
|
- } else {
|
|
|
|
|
- throw new RuntimeException("未知车辆大类:" + carKindCode);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 车辆大类(通过辅助方法解析)
|
|
|
|
|
+ carInfoVo.setCarType(TKCommonUtil.resolveCarType(commonCarInfoVo.getCarKindCode()));
|
|
|
|
|
|
|
|
setLicenseTypeByLicenseNo(carInfoVo, carInfoVo.getLicenseNo());
|
|
setLicenseTypeByLicenseNo(carInfoVo, carInfoVo.getLicenseNo());
|
|
|
carInfoVo.setLocalCarFlag(null); // todo 车型查询时没有传这个参数,暂时不知什么地方用到。
|
|
carInfoVo.setLocalCarFlag(null); // todo 车型查询时没有传这个参数,暂时不知什么地方用到。
|
|
@@ -325,16 +374,8 @@ public class TKSimpleService {
|
|
|
carInfoVo.setVinNo(commonCarInfoVo.getVinNo());
|
|
carInfoVo.setVinNo(commonCarInfoVo.getVinNo());
|
|
|
carInfoVo.setVehicleModel(commonCarInfoVo.getBrandName());
|
|
carInfoVo.setVehicleModel(commonCarInfoVo.getBrandName());
|
|
|
|
|
|
|
|
- // 车辆大类
|
|
|
|
|
- String carKindCode = commonCarInfoVo.getCarKindCode();
|
|
|
|
|
-
|
|
|
|
|
- if (carKindCode.equals(CarKindCode.CAR_KIND_CODE_A0.getCode())) {
|
|
|
|
|
- carInfoVo.setCarType("A");
|
|
|
|
|
- } else if (carKindCode.equals(CarKindCode.CAR_KIND_CODE_A1.getCode())) {
|
|
|
|
|
- carInfoVo.setCarType("D");
|
|
|
|
|
- } else {
|
|
|
|
|
- throw new RuntimeException("未知车辆大类:" + carKindCode);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 车辆大类(通过辅助方法解析)
|
|
|
|
|
+ carInfoVo.setCarType(TKCommonUtil.resolveCarType(commonCarInfoVo.getCarKindCode()));
|
|
|
|
|
|
|
|
carInfoVo.setLocalCarFlag(null); // todo 车型查询时没有传这个参数,暂时不知什么地方用到。
|
|
carInfoVo.setLocalCarFlag(null); // todo 车型查询时没有传这个参数,暂时不知什么地方用到。
|
|
|
|
|
|
|
@@ -379,11 +420,7 @@ public class TKSimpleService {
|
|
|
if (StringUtils.isBlank(commonCarInfoVo.getVinNo())) {
|
|
if (StringUtils.isBlank(commonCarInfoVo.getVinNo())) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
- TKCarOwnerVo carOwnerVo = new TKCarOwnerVo();
|
|
|
|
|
- carOwnerVo.setCarOwnerNature("1"); // todo
|
|
|
|
|
- carOwnerVo.setCertificateType("01"); // 身份证
|
|
|
|
|
- carOwnerVo.setId(ownersInfo.getIdentifyNumber());
|
|
|
|
|
- carOwnerVo.setName(ownersInfo.getName());
|
|
|
|
|
|
|
+ TKCarOwnerVo carOwnerVo = TKCommonUtil.buildCarOwnerVo(ownersInfo);
|
|
|
|
|
|
|
|
TKCarInfoVo carInfoVo = new TKCarInfoVo();
|
|
TKCarInfoVo carInfoVo = new TKCarInfoVo();
|
|
|
TKCarModel tkCarModel = CarModelsFilterUtils.to(tkCarModels, commonCarInfoVo);
|
|
TKCarModel tkCarModel = CarModelsFilterUtils.to(tkCarModels, commonCarInfoVo);
|
|
@@ -414,16 +451,8 @@ public class TKSimpleService {
|
|
|
carInfoVo.setExhaustScale(tkCarModel.getDisplacement());
|
|
carInfoVo.setExhaustScale(tkCarModel.getDisplacement());
|
|
|
carInfoVo.setBillNo("");
|
|
carInfoVo.setBillNo("");
|
|
|
carInfoVo.setCarCheckVo(new TKCarInfoVo.CarCheckVo("", 1, ""));
|
|
carInfoVo.setCarCheckVo(new TKCarInfoVo.CarCheckVo("", 1, ""));
|
|
|
- // 车辆大类
|
|
|
|
|
- String carKindCode = commonCarInfoVo.getCarKindCode();
|
|
|
|
|
-
|
|
|
|
|
- if (carKindCode.equals(CarKindCode.CAR_KIND_CODE_A0.getCode())) {
|
|
|
|
|
- carInfoVo.setCarType("A");
|
|
|
|
|
- } else if (carKindCode.equals(CarKindCode.CAR_KIND_CODE_A1.getCode())) {
|
|
|
|
|
- carInfoVo.setCarType("D");
|
|
|
|
|
- } else {
|
|
|
|
|
- throw new RuntimeException("未知车辆大类:" + carKindCode);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 车辆大类(通过辅助方法解析)
|
|
|
|
|
+ carInfoVo.setCarType(TKCommonUtil.resolveCarType(commonCarInfoVo.getCarKindCode()));
|
|
|
|
|
|
|
|
carInfoVo.setLocalCarFlag(null); // todo 车型查询时没有传这个参数,暂时不知什么地方用到。
|
|
carInfoVo.setLocalCarFlag(null); // todo 车型查询时没有传这个参数,暂时不知什么地方用到。
|
|
|
CarModelinfoQueryParam carModelinfoQueryParam = new CarModelinfoQueryParam();
|
|
CarModelinfoQueryParam carModelinfoQueryParam = new CarModelinfoQueryParam();
|
|
@@ -588,157 +617,148 @@ public class TKSimpleService {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 保存车险投保单
|
|
* 保存车险投保单
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * 该方法负责将公司系统的投保单参数转换为泰康保司系统的参数,
|
|
|
|
|
+ * 并调用保司接口保存投保单信息。
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * 主要处理逻辑:
|
|
|
|
|
+ * 1. 参数准备:获取全局固定参数和车型信息
|
|
|
|
|
+ * 2. 车主信息构建:从公司系统参数提取车主信息
|
|
|
|
|
+ * 3. 投保人信息构建:初始化投保人、被保险人、联系人信息
|
|
|
|
|
+ * 4. 车辆信息构建:设置车辆基本信息、类型、过户状态、使用性质等
|
|
|
|
|
+ * 5. 车船税信息构建:设置车船税代缴标志
|
|
|
|
|
+ * 6. 其他信息构建:设置查询标志、OCR标志等
|
|
|
|
|
+ * 7. 请求组装:组装完整的保存参数并调用保司接口
|
|
|
*
|
|
*
|
|
|
- * @param session
|
|
|
|
|
- * @param mainOrderId
|
|
|
|
|
- * @param commonQuoteVo
|
|
|
|
|
- * @param tkAreaInfoVo
|
|
|
|
|
- * @param carModelinfoQueryResult
|
|
|
|
|
|
|
+ * @param session 登录会话信息
|
|
|
|
|
+ * @param mainOrderId 主订单ID
|
|
|
|
|
+ * @param commonQuoteVo 公司系统报价参数
|
|
|
|
|
+ * @param tkAreaInfoVo 区域信息(含代理人信息)
|
|
|
|
|
+ * @param carModelinfoQueryResult 车型查询结果
|
|
|
*/
|
|
*/
|
|
|
public void orderCreate(TKLoginSession session,
|
|
public void orderCreate(TKLoginSession session,
|
|
|
String mainOrderId,
|
|
String mainOrderId,
|
|
|
QuoteVo commonQuoteVo,
|
|
QuoteVo commonQuoteVo,
|
|
|
TKAreaInfoVo tkAreaInfoVo,
|
|
TKAreaInfoVo tkAreaInfoVo,
|
|
|
CarModelinfoQueryResult carModelinfoQueryResult) {
|
|
CarModelinfoQueryResult carModelinfoQueryResult) {
|
|
|
|
|
+ // 从报价参数中提取车辆信息
|
|
|
CarInfoVo commonCarInfoVo = commonQuoteVo.getCarInfoVo();
|
|
CarInfoVo commonCarInfoVo = commonQuoteVo.getCarInfoVo();
|
|
|
- // 全局固定参数
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // ========== 1. 参数准备 ==========
|
|
|
|
|
+
|
|
|
|
|
+ // 全局固定参数:从登录会话中获取
|
|
|
String tplatformId = session.getTplatformId();
|
|
String tplatformId = session.getTplatformId();
|
|
|
String tplatLoginKey = session.getTplatLoginKey();
|
|
String tplatLoginKey = session.getTplatLoginKey();
|
|
|
String fromId = session.getFromid();
|
|
String fromId = session.getFromid();
|
|
|
|
|
|
|
|
- // 找到车型,后面要使用
|
|
|
|
|
- TKCarModel tkCarModel = CarModelsFilterUtils.to(carModelinfoQueryResult.getCarModel(), commonQuoteVo.getCarInfoVo());
|
|
|
|
|
|
|
+ // 获取车型信息并设置必要字段
|
|
|
|
|
+ TKCarModel tkCarModel = CarModelsFilterUtils.to(
|
|
|
|
|
+ carModelinfoQueryResult.getCarModel(),
|
|
|
|
|
+ commonQuoteVo.getCarInfoVo()
|
|
|
|
|
+ );
|
|
|
tkCarModel.setVehicleStyleUniqueId("");
|
|
tkCarModel.setVehicleStyleUniqueId("");
|
|
|
tkCarModel.setLicenseNo(commonCarInfoVo.getLicenseNo());
|
|
tkCarModel.setLicenseNo(commonCarInfoVo.getLicenseNo());
|
|
|
- CarModelinfoQueryResult.CarInfoDto carInfoDto = carModelinfoQueryResult.getCarInfoDto();
|
|
|
|
|
|
|
|
|
|
- // 车辆所有人信息
|
|
|
|
|
- TKCarOwnerVo carOwnerVo = new TKCarOwnerVo();
|
|
|
|
|
- CustomerInfoVo commonCustomersInfo = commonQuoteVo.getOwnersInfo();
|
|
|
|
|
- if (commonCustomersInfo != null) {
|
|
|
|
|
- carOwnerVo.setCarOwnerNature("1"); // todo
|
|
|
|
|
- carOwnerVo.setCertificateType("01"); // 身份证
|
|
|
|
|
- carOwnerVo.setId(commonCustomersInfo.getIdentifyNumber());
|
|
|
|
|
- carOwnerVo.setName(commonCustomersInfo.getName());
|
|
|
|
|
- carOwnerVo.setBirthDate(commonCustomersInfo.getBirthday());
|
|
|
|
|
- carOwnerVo.setSerialno(BigDecimal.ZERO);
|
|
|
|
|
- carOwnerVo.setSex(IDCardUtils.getSex(commonCustomersInfo.getIdentifyNumber()));
|
|
|
|
|
- carOwnerVo.setInsuredAddress("");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // ========== 2. 车主信息构建 ==========
|
|
|
|
|
+
|
|
|
|
|
+ TKCarOwnerVo carOwnerVo = TKCommonUtil.buildCarOwnerVo(commonQuoteVo.getOwnersInfo());
|
|
|
|
|
+
|
|
|
|
|
+ // ========== 3. 投保人信息构建 ==========
|
|
|
|
|
|
|
|
- // 投保人信息
|
|
|
|
|
SaveBasicInfoParam.InsureInfo insureInfo = new SaveBasicInfoParam.InsureInfo();
|
|
SaveBasicInfoParam.InsureInfo insureInfo = new SaveBasicInfoParam.InsureInfo();
|
|
|
insureInfo.setAppliInfo(new SaveBasicInfoParam.AppliInfo());
|
|
insureInfo.setAppliInfo(new SaveBasicInfoParam.AppliInfo());
|
|
|
insureInfo.setInsuredInfo(new SaveBasicInfoParam.InsuredInfo());
|
|
insureInfo.setInsuredInfo(new SaveBasicInfoParam.InsuredInfo());
|
|
|
insureInfo.setContacts(new SaveBasicInfoParam.Contacts());
|
|
insureInfo.setContacts(new SaveBasicInfoParam.Contacts());
|
|
|
|
|
|
|
|
- // 车辆信息
|
|
|
|
|
|
|
+ // ========== 4. 车辆信息构建 ==========
|
|
|
|
|
+
|
|
|
TKCar car = new TKCar();
|
|
TKCar car = new TKCar();
|
|
|
- car.setFuelType(tkCarModel.getFuelType());
|
|
|
|
|
- car.setModelName(tkCarModel.getModelName());
|
|
|
|
|
- car.setBillDate(""); // 页面上没有输入框,可能是北京地区才用到
|
|
|
|
|
- car.setCarBookingTime(""); // 页面上没有输入框,原注释为“上海地区开具发票日期”,但感觉是车辆时间。
|
|
|
|
|
- car.setBillNo(""); // 页面上没有输入框,发票号
|
|
|
|
|
- car.setColorCode("010"); // 默认黑色
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 设置车辆基本信息
|
|
|
|
|
+ TKCommonUtil.buildCarBasicInfo(car, tkCarModel);
|
|
|
|
|
+ car.setColorCode("010");
|
|
|
car.setCuringQuality(tkCarModel.getVehicleWeight());
|
|
car.setCuringQuality(tkCarModel.getVehicleWeight());
|
|
|
car.setVehicleType(tkCarModel.getVehicleType());
|
|
car.setVehicleType(tkCarModel.getVehicleType());
|
|
|
car.setVehicleTypeCname(tkCarModel.getVehicleTypeCname());
|
|
car.setVehicleTypeCname(tkCarModel.getVehicleTypeCname());
|
|
|
|
|
|
|
|
- // 车辆大类
|
|
|
|
|
- String carKindCode = commonCarInfoVo.getCarKindCode();
|
|
|
|
|
- if (carKindCode.equals(CarKindCode.CAR_KIND_CODE_A0.getCode())) {
|
|
|
|
|
- car.setCarType("A");
|
|
|
|
|
- } else if (carKindCode.equals(CarKindCode.CAR_KIND_CODE_A1.getCode())) {
|
|
|
|
|
- car.setCarType("D");
|
|
|
|
|
- } else {
|
|
|
|
|
- throw new RuntimeException("未知车辆大类:" + carKindCode);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 设置车辆大类(通过辅助方法解析)
|
|
|
|
|
+ car.setCarType(TKCommonUtil.resolveCarType(commonCarInfoVo.getCarKindCode()));
|
|
|
|
|
|
|
|
|
|
+ // 使用 autoSetter 设置可选字段(优先使用公司系统值,其次使用车型查询值)
|
|
|
CodeUtil.autoSetter(car::setLicenseNo, commonCarInfoVo::getLicenseNo, tkCarModel::getLicenseNo);
|
|
CodeUtil.autoSetter(car::setLicenseNo, commonCarInfoVo::getLicenseNo, tkCarModel::getLicenseNo);
|
|
|
CodeUtil.autoSetter(car::setTransferDate, commonCarInfoVo::getTransferDate, null);
|
|
CodeUtil.autoSetter(car::setTransferDate, commonCarInfoVo::getTransferDate, null);
|
|
|
CodeUtil.autoSetter(car::setPurchasePrice, commonCarInfoVo::getPurchasePrice, tkCarModel::getReplacementValue);
|
|
CodeUtil.autoSetter(car::setPurchasePrice, commonCarInfoVo::getPurchasePrice, tkCarModel::getReplacementValue);
|
|
|
CodeUtil.autoSetter(car::setSelectedSeat, commonCarInfoVo::getSeatCount, () -> tkCarModel.getVehicleJingyou().getSeat());
|
|
CodeUtil.autoSetter(car::setSelectedSeat, commonCarInfoVo::getSeatCount, () -> tkCarModel.getVehicleJingyou().getSeat());
|
|
|
- CodeUtil.autoSetter(car::setExhaustScale, commonCarInfoVo::getDisplacement, tkCarModel::getDisplacement); // 排量
|
|
|
|
|
- CodeUtil.autoSetter(car::setBrandName, commonCarInfoVo::getBrandName, tkCarModel::getModelName); // todo 与 tkCarModel.getModelName() 重复
|
|
|
|
|
|
|
+ CodeUtil.autoSetter(car::setExhaustScale, commonCarInfoVo::getDisplacement, tkCarModel::getDisplacement);
|
|
|
|
|
+ CodeUtil.autoSetter(car::setBrandName, commonCarInfoVo::getBrandName, tkCarModel::getModelName);
|
|
|
|
|
|
|
|
- car.setSeatFlag(1); // todo
|
|
|
|
|
- car.setExhaustScale(tkCarModel.getDisplacement().substring(0, tkCarModel.getDisplacement().indexOf(".")));
|
|
|
|
|
- car.setPurchasePrice(tkCarModel.getPurchasePrice().substring(0, tkCarModel.getPurchasePrice().indexOf(".")));
|
|
|
|
|
|
|
+ // 设置固定字段和从车型提取的字段(去掉小数部分)
|
|
|
|
|
+ car.setSeatFlag(1);
|
|
|
|
|
+ car.setExhaustScale(TKCommonUtil.substringBeforeDot(tkCarModel.getDisplacement()));
|
|
|
|
|
+ car.setPurchasePrice(TKCommonUtil.substringBeforeDot(tkCarModel.getPurchasePrice()));
|
|
|
car.setVinNo(commonCarInfoVo.getVinNo());
|
|
car.setVinNo(commonCarInfoVo.getVinNo());
|
|
|
car.setEngineNo(commonCarInfoVo.getEngineNo());
|
|
car.setEngineNo(commonCarInfoVo.getEngineNo());
|
|
|
car.setEnrollDate(commonCarInfoVo.getRegisterDate());
|
|
car.setEnrollDate(commonCarInfoVo.getRegisterDate());
|
|
|
|
|
|
|
|
- Double tonCount = commonCarInfoVo.getTonCountDouble();
|
|
|
|
|
- if (tonCount != null && tonCount > 2) {
|
|
|
|
|
- // 好像主要是货车使用此字段
|
|
|
|
|
- car.setTonnageFlag("1");
|
|
|
|
|
- } else {
|
|
|
|
|
- car.setTonnageFlag("0");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 设置吨位标志(两吨以上货车标记为1)
|
|
|
|
|
+ car.setTonnageFlag(Optional.ofNullable(commonCarInfoVo.getTonCountDouble())
|
|
|
|
|
+ .filter(ton -> ton > 2)
|
|
|
|
|
+ .map(ton -> "1")
|
|
|
|
|
+ .orElse("0"));
|
|
|
|
|
|
|
|
|
|
+ // 设置过户标志和过户时间
|
|
|
if (commonCarInfoVo.isTransfer()) {
|
|
if (commonCarInfoVo.isTransfer()) {
|
|
|
- car.setChgOwnerFlag("1"); // 是过户
|
|
|
|
|
- car.setTransferDate(commonCarInfoVo.getTransferDate()); // 过户时间
|
|
|
|
|
|
|
+ car.setChgOwnerFlag("1");
|
|
|
|
|
+ car.setTransferDate(commonCarInfoVo.getTransferDate());
|
|
|
} else {
|
|
} else {
|
|
|
- car.setChgOwnerFlag("0"); // 不是过户
|
|
|
|
|
|
|
+ car.setChgOwnerFlag("0");
|
|
|
car.setTransferDate("");
|
|
car.setTransferDate("");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 设置车辆使用性质(通过映射表转换,默认8B非营业企业)
|
|
|
String vehicleUseCode = commonCarInfoVo.getVehicleUseCode();
|
|
String vehicleUseCode = commonCarInfoVo.getVehicleUseCode();
|
|
|
|
|
+ car.setUseNatureCodeCode(TKCommonUtil.VEHICLE_USE_CODE_MAP.getOrDefault(vehicleUseCode, "8B"));
|
|
|
|
|
|
|
|
- if (vehicleUseCode.equals(VehicleUseCode.VEHICLE_USE_CODE_05.getCode())) {
|
|
|
|
|
- // 05 家庭自用 = 8A 家庭自用
|
|
|
|
|
- car.setUseNatureCodeCode("8A"); // 页面上选择的家庭自用、非营业企业、、、、
|
|
|
|
|
- } else if (vehicleUseCode.equals(VehicleUseCode.VEHICLE_USE_CODE_06.getCode())) {
|
|
|
|
|
- // 06 非营业企业 = 8C 非营业党政机关事业团体
|
|
|
|
|
- car.setUseNatureCodeCode("8C");
|
|
|
|
|
- } else if (vehicleUseCode.equals(VehicleUseCode.VEHICLE_USE_CODE_07.getCode())) {
|
|
|
|
|
- // 07 非营业企业 = 8B 非营业企业
|
|
|
|
|
- car.setUseNatureCodeCode("8B");
|
|
|
|
|
- } else if (vehicleUseCode.equals(VehicleUseCode.VEHICLE_USE_CODE_01.getCode())) {
|
|
|
|
|
- // 01 营业出租租赁 = 9 营业
|
|
|
|
|
- car.setUseNatureCodeCode("9");
|
|
|
|
|
- } else if (vehicleUseCode.equals(VehicleUseCode.VEHICLE_USE_CODE_02.getCode())) {
|
|
|
|
|
- // 02 营业城市公交 = 9 营业
|
|
|
|
|
- car.setUseNatureCodeCode("9");
|
|
|
|
|
- } else if (vehicleUseCode.equals(VehicleUseCode.VEHICLE_USE_CODE_03.getCode())) {
|
|
|
|
|
- // 03 营业公路客运 = 9 营业
|
|
|
|
|
- car.setUseNatureCodeCode("9");
|
|
|
|
|
- } else if (vehicleUseCode.equals(VehicleUseCode.VEHICLE_USE_CODE_04.getCode())) {
|
|
|
|
|
- // 04 营业货运 = 9 营业
|
|
|
|
|
- car.setUseNatureCodeCode("9");
|
|
|
|
|
- } else {
|
|
|
|
|
- // 默认 8B 非营业企业
|
|
|
|
|
- car.setUseNatureCodeCode("8B");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // 设置车牌类型并根据渠道调整车辆类型
|
|
|
TKSimpleService.setLicenseTypeByLicenseNo(car, car.getLicenseNo());
|
|
TKSimpleService.setLicenseTypeByLicenseNo(car, car.getLicenseNo());
|
|
|
- String passengerSeat = httpService.carTypePassengerSeat(session.getToken(), session.getTplatformId(), session.getFromid(), session.getComCode());
|
|
|
|
|
- String carType = carType(passengerSeat, car.getCarType(), carOwnerVo.getCarOwnerNature());
|
|
|
|
|
- if (carType != null) {
|
|
|
|
|
- car.setCarType(carType);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ String passengerSeat = httpService.carTypePassengerSeat(
|
|
|
|
|
+ session.getToken(),
|
|
|
|
|
+ session.getTplatformId(),
|
|
|
|
|
+ session.getFromid(),
|
|
|
|
|
+ session.getComCode()
|
|
|
|
|
+ );
|
|
|
|
|
+ Optional.ofNullable(carType(passengerSeat, car.getCarType(), carOwnerVo.getCarOwnerNature()))
|
|
|
|
|
+ .ifPresent(car::setCarType);
|
|
|
|
|
+
|
|
|
|
|
+ // 预留扩展方法调用(当前传入null,内部直接返回,作为未来扩展占位)
|
|
|
orderCreateOther(null);
|
|
orderCreateOther(null);
|
|
|
- car.setCarModel(Arrays.asList(tkCarModel));
|
|
|
|
|
- car.setBrandName(tkCarModel.getModelName()); // todo 与 commonCarInfoVo.getBrandName() 重复
|
|
|
|
|
|
|
|
|
|
- // 车船税信息
|
|
|
|
|
|
|
+ // 设置车型列表和品牌名称
|
|
|
|
|
+ car.setCarModel(List.of(tkCarModel));
|
|
|
|
|
+ car.setBrandName(tkCarModel.getModelName());
|
|
|
|
|
+
|
|
|
|
|
+ // ========== 5. 车船税信息构建 ==========
|
|
|
|
|
+
|
|
|
TKCarTax carTax = new TKCarTax();
|
|
TKCarTax carTax = new TKCarTax();
|
|
|
- carTax.setIsPayTax("1"); // 是否代缴车船税
|
|
|
|
|
|
|
+ carTax.setIsPayTax("1");
|
|
|
|
|
+
|
|
|
|
|
+ // ========== 6. 其他信息构建 ==========
|
|
|
|
|
|
|
|
- // 其他信息
|
|
|
|
|
SaveBasicInfoParam.OtherInfo otherInfo = new SaveBasicInfoParam.OtherInfo();
|
|
SaveBasicInfoParam.OtherInfo otherInfo = new SaveBasicInfoParam.OtherInfo();
|
|
|
otherInfo.setIsQueryVehicleFlag(false);
|
|
otherInfo.setIsQueryVehicleFlag(false);
|
|
|
- // 经测试:单交设置:1, 交强+商业设置:"0"
|
|
|
|
|
- otherInfo.setShowEngineNoFlag(commonQuoteVo.getBiRiskInfoVo() == null ? "1" : "0");
|
|
|
|
|
otherInfo.setJyQueryFlag(false);
|
|
otherInfo.setJyQueryFlag(false);
|
|
|
otherInfo.setOcrFlag(1);
|
|
otherInfo.setOcrFlag(1);
|
|
|
- otherInfo.setNewCarFlag("0"); // todo
|
|
|
|
|
|
|
+ otherInfo.setNewCarFlag("0");
|
|
|
|
|
+ otherInfo.setRetrospectId(UUID.randomUUID().toString());
|
|
|
|
|
+
|
|
|
|
|
+ // 根据是否包含商业险设置特殊标志
|
|
|
|
|
+ boolean hasBiRisk = commonQuoteVo.getBiRiskInfoVo() != null;
|
|
|
|
|
+ // 经测试:单交设置:1, 交强+商业设置:"0"
|
|
|
|
|
+ otherInfo.setShowEngineNoFlag(hasBiRisk ? "0" : "1");
|
|
|
// 经测试:单交设置:1, 交强+商业设置:""
|
|
// 经测试:单交设置:1, 交强+商业设置:""
|
|
|
- otherInfo.setKindLimitCode(commonQuoteVo.getBiRiskInfoVo() == null ? "1" : "");
|
|
|
|
|
- otherInfo.setRetrospectId(UUID.randomUUID().toString()); // 可回溯ID ,好像不是很需要
|
|
|
|
|
|
|
+ otherInfo.setKindLimitCode(hasBiRisk ? "" : "1");
|
|
|
|
|
|
|
|
|
|
+ // ========== 7. 请求组装与调用 ==========
|
|
|
|
|
|
|
|
SaveBasicInfoParam param = new SaveBasicInfoParam();
|
|
SaveBasicInfoParam param = new SaveBasicInfoParam();
|
|
|
param.setChannelCode("OffWeb");
|
|
param.setChannelCode("OffWeb");
|
|
@@ -746,8 +766,8 @@ public class TKSimpleService {
|
|
|
param.setFromId(fromId);
|
|
param.setFromId(fromId);
|
|
|
param.setTplatformId(tplatformId);
|
|
param.setTplatformId(tplatformId);
|
|
|
param.setTplatLoginKey(tplatLoginKey);
|
|
param.setTplatLoginKey(tplatLoginKey);
|
|
|
- param.setPreFilledLastPolicyFlag(""); // 抓包查到没有值
|
|
|
|
|
- param.setIsJgFlag(""); // 抓包查到没有值
|
|
|
|
|
|
|
+ param.setPreFilledLastPolicyFlag("");
|
|
|
|
|
+ param.setIsJgFlag("");
|
|
|
param.setAuthFailContinueFlag("");
|
|
param.setAuthFailContinueFlag("");
|
|
|
param.setInsureInfo(insureInfo);
|
|
param.setInsureInfo(insureInfo);
|
|
|
param.setAreaInfoVo(tkAreaInfoVo);
|
|
param.setAreaInfoVo(tkAreaInfoVo);
|
|
@@ -756,6 +776,8 @@ public class TKSimpleService {
|
|
|
param.setCarTaxVo(carTax);
|
|
param.setCarTaxVo(carTax);
|
|
|
param.setOtherInfo(otherInfo);
|
|
param.setOtherInfo(otherInfo);
|
|
|
param.setOrderVersion("1");
|
|
param.setOrderVersion("1");
|
|
|
|
|
+
|
|
|
|
|
+ // 调用保司保存接口
|
|
|
SaveBasicInfoResult saveBasicInfoResult = httpService.saveBasicInfo(session.getToken(), param);
|
|
SaveBasicInfoResult saveBasicInfoResult = httpService.saveBasicInfo(session.getToken(), param);
|
|
|
if (saveBasicInfoResult == null) {
|
|
if (saveBasicInfoResult == null) {
|
|
|
throw new RuntimeException("HttpService#saveBasicInfo 失败!");
|
|
throw new RuntimeException("HttpService#saveBasicInfo 失败!");
|
|
@@ -892,215 +914,237 @@ public class TKSimpleService {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 车险投保单报价
|
|
* 车险投保单报价
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * 该方法负责将公司系统的报价参数转换为泰康保司系统的报价参数,
|
|
|
|
|
+ * 并调用保司接口进行报价,返回报价结果。
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * 主要处理逻辑:
|
|
|
|
|
+ * 1. 参数初始化:确保各子对象非空,设置全局固定参数
|
|
|
|
|
+ * 2. 险种标志设置:处理交强险、商业险标志
|
|
|
|
|
+ * 3. 时间信息同步:同步交强险和商业险的起止日期
|
|
|
|
|
+ * 4. 车船税信息同步:映射车船税减免标志
|
|
|
|
|
+ * 5. 商业险险种覆盖:根据公司系统选择的险种覆盖保司默认险种
|
|
|
|
|
+ * 6. 驾意险同步:匹配公司系统选择的驾意险产品
|
|
|
|
|
+ * 7. 非车险产品同步:匹配泰乐途等非车险产品
|
|
|
|
|
+ * 8. 调用报价接口:提交参数获取报价结果
|
|
|
*
|
|
*
|
|
|
- * @param session
|
|
|
|
|
- * @param mainOrderId
|
|
|
|
|
- * @param preciseInitResult
|
|
|
|
|
- * @param commonQuoteVo
|
|
|
|
|
|
|
+ * @param session 登录会话信息
|
|
|
|
|
+ * @param mainOrderId 主订单ID
|
|
|
|
|
+ * @param preciseInitResult 初始化结果
|
|
|
|
|
+ * @param commonQuoteVo 公司系统报价参数
|
|
|
|
|
+ * @return 报价结果
|
|
|
*/
|
|
*/
|
|
|
public PreciseInitResult orderQuote(TKLoginSession session, String mainOrderId, PreciseInitResult preciseInitResult, QuoteVo commonQuoteVo) {
|
|
public PreciseInitResult orderQuote(TKLoginSession session, String mainOrderId, PreciseInitResult preciseInitResult, QuoteVo commonQuoteVo) {
|
|
|
|
|
+ // 将初始化结果转换为报价参数对象
|
|
|
PreciseInitParam preciseInitParam = Converter.Instance.convertToParam(preciseInitResult);
|
|
PreciseInitParam preciseInitParam = Converter.Instance.convertToParam(preciseInitResult);
|
|
|
|
|
|
|
|
- // 全局固定参数
|
|
|
|
|
|
|
+ // 全局固定参数:从登录会话中获取
|
|
|
String tplatformId = session.getTplatformId();
|
|
String tplatformId = session.getTplatformId();
|
|
|
String tplatLoginKey = session.getTplatLoginKey();
|
|
String tplatLoginKey = session.getTplatLoginKey();
|
|
|
String fromId = session.getFromid();
|
|
String fromId = session.getFromid();
|
|
|
|
|
|
|
|
- // 险种选中标志
|
|
|
|
|
- TKFlag flag = preciseInitParam.getFlag();
|
|
|
|
|
- if (flag == null) {
|
|
|
|
|
- flag = new TKFlag();
|
|
|
|
|
- preciseInitParam.setFlag(flag);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // ========== 1. 参数初始化与险种标志设置 ==========
|
|
|
|
|
+
|
|
|
|
|
+ // 确保险种选中标志对象非空,设置默认标志值
|
|
|
|
|
+ TKFlag flag = ensureNonNull(
|
|
|
|
|
+ preciseInitParam::getFlag,
|
|
|
|
|
+ preciseInitParam::setFlag,
|
|
|
|
|
+ TKFlag::new
|
|
|
|
|
+ );
|
|
|
flag.setVipWeekFlag("0");
|
|
flag.setVipWeekFlag("0");
|
|
|
flag.setQuoteLinkageFlag("0");
|
|
flag.setQuoteLinkageFlag("0");
|
|
|
flag.setInstantInsureBZAllowed("0");
|
|
flag.setInstantInsureBZAllowed("0");
|
|
|
flag.setPriceDifferFlag("0");
|
|
flag.setPriceDifferFlag("0");
|
|
|
|
|
|
|
|
- // 无商业险
|
|
|
|
|
|
|
+ // 无商业险时设置商业险标志为"0"
|
|
|
if (CollectionUtils.isEmpty(commonQuoteVo.getKindInfoVo())) {
|
|
if (CollectionUtils.isEmpty(commonQuoteVo.getKindInfoVo())) {
|
|
|
flag.setCiFlag("0");
|
|
flag.setCiFlag("0");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 其他参数
|
|
|
|
|
- TKOther other = preciseInitParam.getOther();
|
|
|
|
|
- if (other == null) {
|
|
|
|
|
- other = new TKOther();
|
|
|
|
|
- preciseInitParam.setOther(other);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 确保其他参数对象非空,设置渠道信息
|
|
|
|
|
+ TKOther other = ensureNonNull(
|
|
|
|
|
+ preciseInitParam::getOther,
|
|
|
|
|
+ preciseInitParam::setOther,
|
|
|
|
|
+ TKOther::new
|
|
|
|
|
+ );
|
|
|
other.setFromID(fromId);
|
|
other.setFromID(fromId);
|
|
|
other.setChannelCode("OffWeb");
|
|
other.setChannelCode("OffWeb");
|
|
|
|
|
|
|
|
- // 时间参数
|
|
|
|
|
|
|
+ // 获取时间参数对象(保司系统已初始化,无需创建)
|
|
|
TKDateInfo date = preciseInitParam.getDate();
|
|
TKDateInfo date = preciseInitParam.getDate();
|
|
|
|
|
|
|
|
- // 同步交强险
|
|
|
|
|
- TKBzKindVo bzKindVo = preciseInitParam.getBzKindVo();
|
|
|
|
|
- if (bzKindVo == null) {
|
|
|
|
|
- bzKindVo = new TKBzKindVo();
|
|
|
|
|
- preciseInitParam.setBzKindVo(bzKindVo);
|
|
|
|
|
- }
|
|
|
|
|
- bzKindVo.setIsSelect("1"); // 选择交纳交强险
|
|
|
|
|
|
|
+ // ========== 2. 交强险信息同步 ==========
|
|
|
|
|
+
|
|
|
|
|
+ // 确保交强险对象非空,设置为"选择交纳"状态
|
|
|
|
|
+ TKBzKindVo bzKindVo = ensureNonNull(
|
|
|
|
|
+ preciseInitParam::getBzKindVo,
|
|
|
|
|
+ preciseInitParam::setBzKindVo,
|
|
|
|
|
+ TKBzKindVo::new
|
|
|
|
|
+ );
|
|
|
|
|
+ bzKindVo.setIsSelect("1");
|
|
|
|
|
|
|
|
- // 同步交强险时间信息,从前端参数获取
|
|
|
|
|
|
|
+ // 从前端参数获取交强险时间信息
|
|
|
RiskInfoVo commonCiRiskInfoVo = commonQuoteVo.getCiRiskInfoVo();
|
|
RiskInfoVo commonCiRiskInfoVo = commonQuoteVo.getCiRiskInfoVo();
|
|
|
if (commonCiRiskInfoVo != null) {
|
|
if (commonCiRiskInfoVo != null) {
|
|
|
- // 交强险的时间
|
|
|
|
|
date.setStartDateBZ(commonCiRiskInfoVo.getStartDate());
|
|
date.setStartDateBZ(commonCiRiskInfoVo.getStartDate());
|
|
|
date.setEndDateBZ(commonCiRiskInfoVo.getEndDate());
|
|
date.setEndDateBZ(commonCiRiskInfoVo.getEndDate());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 同步车船税
|
|
|
|
|
- TKCarTaxInfo carTaxInfo = preciseInitParam.getCarTaxInfo();
|
|
|
|
|
- if (carTaxInfo == null) {
|
|
|
|
|
- carTaxInfo = new TKCarTaxInfo();
|
|
|
|
|
- preciseInitParam.setCarTaxInfo(carTaxInfo);
|
|
|
|
|
- }
|
|
|
|
|
- // 同步车船税信息,从前端参数获取
|
|
|
|
|
- VehicleAndVesselTaxVo vehicleAndVesselTax = commonQuoteVo.getVehicleAndVesselTaxVo();
|
|
|
|
|
- if (vehicleAndVesselTax != null) {
|
|
|
|
|
- // 车船税标志
|
|
|
|
|
- String taxRelifFlag = vehicleAndVesselTax.getTaxRelifFlag();
|
|
|
|
|
- // 转换为保司的参数
|
|
|
|
|
- if (taxRelifFlag.equals("1")) {
|
|
|
|
|
- carTaxInfo.setTaxFlag("T");
|
|
|
|
|
- } else if (taxRelifFlag.equals("2")) {
|
|
|
|
|
- carTaxInfo.setTaxFlag("E");
|
|
|
|
|
- } else if (taxRelifFlag.equals("3")) {
|
|
|
|
|
- carTaxInfo.setTaxFlag("C");
|
|
|
|
|
- } else if (taxRelifFlag.equals("4")) {
|
|
|
|
|
- carTaxInfo.setTaxFlag("P");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 同步商业险时间信息,从前端参数获取
|
|
|
|
|
- RiskInfoVo commonBiRiskInfoVo = commonQuoteVo.getBiRiskInfoVo();
|
|
|
|
|
- if (commonBiRiskInfoVo != null) {
|
|
|
|
|
- date.setStartDateCI(commonBiRiskInfoVo.getStartDate());
|
|
|
|
|
- date.setEndDateCI(commonBiRiskInfoVo.getEndDate());
|
|
|
|
|
|
|
+ // ========== 3. 车船税信息同步 ==========
|
|
|
|
|
+
|
|
|
|
|
+ // 确保车船税对象非空
|
|
|
|
|
+ TKCarTaxInfo carTaxInfo = ensureNonNull(
|
|
|
|
|
+ preciseInitParam::getCarTaxInfo,
|
|
|
|
|
+ preciseInitParam::setCarTaxInfo,
|
|
|
|
|
+ TKCarTaxInfo::new
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ // 从前端参数获取车船税信息,通过映射表转换减免标志
|
|
|
|
|
+ Optional.ofNullable(commonQuoteVo.getVehicleAndVesselTaxVo())
|
|
|
|
|
+ .map(VehicleAndVesselTaxVo::getTaxRelifFlag)
|
|
|
|
|
+ .map(TAX_RELIEF_FLAG_MAP::get)
|
|
|
|
|
+ .ifPresent(carTaxInfo::setTaxFlag);
|
|
|
|
|
+
|
|
|
|
|
+ // ========== 4. 商业险时间信息同步 ==========
|
|
|
|
|
+
|
|
|
|
|
+ // 从前端参数获取商业险时间信息,若无则保持保司默认值(无需额外处理)
|
|
|
|
|
+ Optional.ofNullable(commonQuoteVo.getBiRiskInfoVo())
|
|
|
|
|
+ .ifPresent(biRiskInfo -> {
|
|
|
|
|
+ date.setStartDateCI(biRiskInfo.getStartDate());
|
|
|
|
|
+ date.setEndDateCI(biRiskInfo.getEndDate());
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // ========== 5. 商业险险种覆盖 ==========
|
|
|
|
|
+
|
|
|
|
|
+ // 使用 Stream 将保司默认商险信息转换为 Map,同时重置为"不投保"状态
|
|
|
|
|
+ Map<String, TKCiKindsVo> tkCiKindsVoMap = Optional.ofNullable(preciseInitParam.getCiKindsVo())
|
|
|
|
|
+ .orElseGet(Collections::emptyList)
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .peek(tkCiKindVo -> {
|
|
|
|
|
+ tkCiKindVo.setBjSelect("0");
|
|
|
|
|
+ tkCiKindVo.setDeductibleAmount(BigDecimal.ZERO);
|
|
|
|
|
+ tkCiKindVo.setIsSelect("0");
|
|
|
|
|
+ tkCiKindVo.setQuantity(0);
|
|
|
|
|
+ tkCiKindVo.setQuoteAmountCN("不投保");
|
|
|
|
|
+ })
|
|
|
|
|
+ .collect(Collectors.toMap(TKCiKindsVo::getKindCode, Function.identity()));
|
|
|
|
|
+
|
|
|
|
|
+ // 根据公司系统选择的险种覆盖保司默认险种
|
|
|
|
|
+ Optional.ofNullable(commonQuoteVo.getKindInfoVo())
|
|
|
|
|
+ .orElseGet(Collections::emptyList)
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .filter(kindInfo -> tkCiKindsVoMap.containsKey(kindInfo.getKindCode()))
|
|
|
|
|
+ .forEach(commonBiKindInfoVo -> {
|
|
|
|
|
+ TKCiKindsVo tkCiKindVo = tkCiKindsVoMap.get(commonBiKindInfoVo.getKindCode());
|
|
|
|
|
+ tkCiKindVo.setIsSelect("1");
|
|
|
|
|
+ tkCiKindVo.setQuoteAmount(commonBiKindInfoVo.getAmount());
|
|
|
|
|
+ tkCiKindVo.setQuoteAmountCN(commonBiKindInfoVo.getAmount());
|
|
|
|
|
+
|
|
|
|
|
+ // 设置数量:优先使用 quantity,其次使用 serviceTimes
|
|
|
|
|
+ String quantity = commonBiKindInfoVo.getQuantity();
|
|
|
|
|
+ String serviceTimes = commonBiKindInfoVo.getServiceTimes();
|
|
|
|
|
+ if (StringUtils.isNotBlank(quantity)) {
|
|
|
|
|
+ tkCiKindVo.setQuantity(Integer.parseInt(quantity));
|
|
|
|
|
+ } else if (StringUtils.isNotBlank(serviceTimes)) {
|
|
|
|
|
+ tkCiKindVo.setQuantity(Integer.parseInt(serviceTimes));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // ========== 6. 驾意险信息同步 ==========
|
|
|
|
|
+
|
|
|
|
|
+ // 将驾意险方案列表转换为 Map(按方案代码索引)
|
|
|
|
|
+ Map<String, TKCarPlanInfo> carPlanInfoMap = Optional.ofNullable(preciseInitParam.getDriverAccidentVo())
|
|
|
|
|
+ .map(TKDriverAccidentVo::getCarPlanInfoList)
|
|
|
|
|
+ .orElseGet(Collections::emptyList)
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .collect(Collectors.toMap(TKCarPlanInfo::getPlanCode, Function.identity()));
|
|
|
|
|
+
|
|
|
|
|
+ // 获取保司驾意险对象和公司系统驾意险参数
|
|
|
|
|
+ TKDriverAccidentVo driverAccidentVo = preciseInitParam.getDriverAccidentVo();
|
|
|
|
|
+ List<AccidentalDrivingVo> accidentalDrivings = commonQuoteVo.getAccidentalDrivings();
|
|
|
|
|
+
|
|
|
|
|
+ // 根据公司系统驾意险参数进行匹配覆盖
|
|
|
|
|
+ // 注意:当 carPlanInfoMap 为空时,跳过处理,保持 driverAccidentVo 原有状态
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(accidentalDrivings) && !carPlanInfoMap.isEmpty()) {
|
|
|
|
|
+ accidentalDrivings.stream()
|
|
|
|
|
+ .filter(accidentalDriving -> accidentalDriving.getProductCode() != null)
|
|
|
|
|
+ .forEach(accidentalDriving -> {
|
|
|
|
|
+ TKCarPlanInfo tkCarPlanInfo = carPlanInfoMap.get(accidentalDriving.getProductCode());
|
|
|
|
|
+ if (tkCarPlanInfo != null) {
|
|
|
|
|
+ // 匹配成功:设置为"投保"状态
|
|
|
|
|
+ driverAccidentVo.setIsSelect("1");
|
|
|
|
|
+ driverAccidentVo.setQuantity(accidentalDriving.getQuantity());
|
|
|
|
|
+ driverAccidentVo.setSelectPlanCode(tkCarPlanInfo.getPlanCode());
|
|
|
|
|
+ driverAccidentVo.setQuoteAmountCN(tkCarPlanInfo.getPlanName());
|
|
|
|
|
+ driverAccidentVo.setPremium(new BigDecimal(tkCarPlanInfo.getSumPremium()));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 匹配失败:重置为"不投保"状态
|
|
|
|
|
+ resetDriverAccidentVo(driverAccidentVo);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
} else {
|
|
} else {
|
|
|
- date.setStartDateCI(date.getStartDateCI());
|
|
|
|
|
- date.setEndDateCI(date.getEndDateCI());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 获取保司默认选中的商险信息
|
|
|
|
|
- Map<String, TKCiKindsVo> tkCiKindsVoMap = new HashMap<>();
|
|
|
|
|
- for (TKCiKindsVo tkCiKindVo : preciseInitParam.getCiKindsVo()) {
|
|
|
|
|
- tkCiKindVo.setBjSelect("0");
|
|
|
|
|
- tkCiKindVo.setDeductibleAmount(BigDecimal.ZERO);
|
|
|
|
|
- tkCiKindVo.setIsSelect("0");
|
|
|
|
|
- tkCiKindVo.setQuantity(0);
|
|
|
|
|
- tkCiKindVo.setQuoteAmountCN("不投保");
|
|
|
|
|
- tkCiKindsVoMap.put(tkCiKindVo.getKindCode(), tkCiKindVo);
|
|
|
|
|
|
|
+ // 公司系统未选择驾意险或驾意险方案列表为空:重置为"不投保"状态
|
|
|
|
|
+ resetDriverAccidentVo(driverAccidentVo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 根据公司系统选择的险种进行覆盖
|
|
|
|
|
- List<KindInfoVo> commonBiKindInfoVos = commonQuoteVo.getKindInfoVo();
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(commonBiKindInfoVos)) {
|
|
|
|
|
- for (KindInfoVo commonBiKindInfoVo : commonBiKindInfoVos) {
|
|
|
|
|
- if (tkCiKindsVoMap.isEmpty() || tkCiKindsVoMap.get(commonBiKindInfoVo.getKindCode()) == null) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- TKCiKindsVo tkCiKindVo = tkCiKindsVoMap.get(commonBiKindInfoVo.getKindCode());
|
|
|
|
|
- tkCiKindVo.setIsSelect("1");
|
|
|
|
|
- tkCiKindVo.setQuoteAmount(commonBiKindInfoVo.getAmount());
|
|
|
|
|
- tkCiKindVo.setQuoteAmountCN(commonBiKindInfoVo.getAmount());
|
|
|
|
|
-
|
|
|
|
|
- String quantity = commonBiKindInfoVo.getQuantity();
|
|
|
|
|
- String serviceTimes = commonBiKindInfoVo.getServiceTimes();
|
|
|
|
|
- if (StringUtils.isNotBlank(quantity)) {
|
|
|
|
|
- tkCiKindVo.setQuantity(Integer.parseInt(quantity));
|
|
|
|
|
- } else if (StringUtils.isNotBlank(serviceTimes)) {
|
|
|
|
|
- tkCiKindVo.setQuantity(Integer.parseInt(serviceTimes));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // ========== 7. 非车险产品同步(泰乐途等) ==========
|
|
|
|
|
|
|
|
- // 同步驾意险, 系统有选择驾意险进行匹配覆盖(泰康要求必须有驾意险)
|
|
|
|
|
- Map<String, TKCarPlanInfo> carPlanInfoMap = Optional.ofNullable(preciseInitParam.getDriverAccidentVo().getCarPlanInfoList()).orElseGet(Collections::emptyList).stream().collect(Collectors.toMap(TKCarPlanInfo::getPlanCode, Function.identity()));
|
|
|
|
|
- TKDriverAccidentVo driverAccidentVo = preciseInitParam.getDriverAccidentVo();// 泰康系统默认的驾意险信息
|
|
|
|
|
- List<AccidentalDrivingVo> accidentalDrivings = commonQuoteVo.getAccidentalDrivings(); // 公司系统的驾意险参数
|
|
|
|
|
- // 公司系统的驾意险参数为空证明没有选择驾意险
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(accidentalDrivings)) {
|
|
|
|
|
- for (AccidentalDrivingVo accidentalDriving : accidentalDrivings) {
|
|
|
|
|
- if (carPlanInfoMap.isEmpty() || accidentalDriving.getProductCode() == null) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- TKCarPlanInfo tkCarPlanInfo = carPlanInfoMap.get(accidentalDriving.getProductCode());
|
|
|
|
|
- if (tkCarPlanInfo != null) {
|
|
|
|
|
- driverAccidentVo.setIsSelect("1");
|
|
|
|
|
- driverAccidentVo.setQuantity(accidentalDriving.getQuantity());
|
|
|
|
|
- driverAccidentVo.setSelectPlanCode(tkCarPlanInfo.getPlanCode());
|
|
|
|
|
- driverAccidentVo.setQuoteAmountCN(tkCarPlanInfo.getPlanName());
|
|
|
|
|
- driverAccidentVo.setPremium(new BigDecimal(tkCarPlanInfo.getSumPremium()));
|
|
|
|
|
- } else {
|
|
|
|
|
- driverAccidentVo.setIsSelect("0");
|
|
|
|
|
- driverAccidentVo.setQuantity(0);
|
|
|
|
|
- driverAccidentVo.setQuantityCname("不投保");
|
|
|
|
|
- driverAccidentVo.setPremium(BigDecimal.ZERO);
|
|
|
|
|
- driverAccidentVo.setNonCarStartDate(null);
|
|
|
|
|
- driverAccidentVo.setNonCarEndDate(null);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- driverAccidentVo.setIsSelect("0");
|
|
|
|
|
- driverAccidentVo.setQuantity(0);
|
|
|
|
|
- driverAccidentVo.setQuantityCname("不投保");
|
|
|
|
|
- driverAccidentVo.setPremium(BigDecimal.ZERO);
|
|
|
|
|
- driverAccidentVo.setNonCarStartDate(null);
|
|
|
|
|
- driverAccidentVo.setNonCarEndDate(null);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 使用 flatMap 将嵌套的产品列表展平并转换为 Map(按产品代码索引)
|
|
|
|
|
+ Map<String, PreciseInitResult.ProductInfoListDTO> productInfoListMap = Optional.ofNullable(preciseInitParam.getNonCarProductList())
|
|
|
|
|
+ .orElseGet(Collections::emptyList)
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .flatMap(nonCarProduct -> nonCarProduct.getProductInfoList().stream())
|
|
|
|
|
+ .collect(Collectors.toMap(
|
|
|
|
|
+ PreciseInitResult.ProductInfoListDTO::getProductCode,
|
|
|
|
|
+ Function.identity()
|
|
|
|
|
+ ));
|
|
|
|
|
|
|
|
- // 泰康系统默认的泰乐途
|
|
|
|
|
- Map<String, PreciseInitResult.ProductInfoListDTO> productInfoListMap = new HashMap<>();
|
|
|
|
|
|
|
+ // 获取非车险产品列表
|
|
|
List<PreciseInitResult.NonCarProductListDTO> nonCarProductList = preciseInitParam.getNonCarProductList();
|
|
List<PreciseInitResult.NonCarProductListDTO> nonCarProductList = preciseInitParam.getNonCarProductList();
|
|
|
- if (CollectionUtils.isNotEmpty(nonCarProductList)) {
|
|
|
|
|
- for (PreciseInitResult.NonCarProductListDTO nonCarProductListDTO : nonCarProductList) {
|
|
|
|
|
- for (PreciseInitResult.ProductInfoListDTO productInfoListDTO : nonCarProductListDTO.getProductInfoList()) {
|
|
|
|
|
- productInfoListMap.put(productInfoListDTO.getProductCode(), productInfoListDTO);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- // 泰乐途
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(accidentalDrivings)) {
|
|
|
|
|
- for (AccidentalDrivingVo accidentalDriving : accidentalDrivings) {
|
|
|
|
|
- if (productInfoListMap.isEmpty() || accidentalDriving.getProductCode() == null) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- PreciseInitResult.ProductInfoListDTO productInfoListDTO = productInfoListMap.get(accidentalDriving.getProductCode());
|
|
|
|
|
- PreciseInitResult.NonCarProductListDTO nonCarProductListDTO = nonCarProductList.get(0);
|
|
|
|
|
- if (productInfoListDTO != null) {
|
|
|
|
|
- nonCarProductListDTO.setIsSelect("1");
|
|
|
|
|
- nonCarProductListDTO.setPremium(productInfoListDTO.getPremium());
|
|
|
|
|
- nonCarProductListDTO.setSelectProductCode(accidentalDriving.getProductCode());
|
|
|
|
|
- nonCarProductListDTO.setSelectProductName(productInfoListDTO.getProductName());
|
|
|
|
|
- nonCarProductListDTO.setStartDate(commonCiRiskInfoVo != null ? commonCiRiskInfoVo.getStartDate() : null);
|
|
|
|
|
- nonCarProductListDTO.setEndDate(commonCiRiskInfoVo != null ? commonCiRiskInfoVo.getEndDate() : null);
|
|
|
|
|
- } else {
|
|
|
|
|
- nonCarProductListDTO.setIsSelect("0");
|
|
|
|
|
- nonCarProductListDTO.setPremium("0");
|
|
|
|
|
- nonCarProductListDTO.setStartDate(null);
|
|
|
|
|
- nonCarProductListDTO.setEndDate(null);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 根据公司系统驾意险参数匹配非车险产品
|
|
|
|
|
+ // 注意:当 productInfoListMap 为空或 nonCarProductList 为空时,跳过处理
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(accidentalDrivings) && !productInfoListMap.isEmpty() && CollectionUtils.isNotEmpty(nonCarProductList)) {
|
|
|
|
|
+ accidentalDrivings.stream()
|
|
|
|
|
+ .filter(accidentalDriving -> accidentalDriving.getProductCode() != null)
|
|
|
|
|
+ .forEach(accidentalDriving -> {
|
|
|
|
|
+ PreciseInitResult.ProductInfoListDTO productInfoListDTO = productInfoListMap.get(accidentalDriving.getProductCode());
|
|
|
|
|
+ PreciseInitResult.NonCarProductListDTO nonCarProductListDTO = nonCarProductList.get(0);
|
|
|
|
|
+
|
|
|
|
|
+ if (productInfoListDTO != null) {
|
|
|
|
|
+ // 匹配成功:设置为"投保"状态
|
|
|
|
|
+ nonCarProductListDTO.setIsSelect("1");
|
|
|
|
|
+ nonCarProductListDTO.setPremium(productInfoListDTO.getPremium());
|
|
|
|
|
+ nonCarProductListDTO.setSelectProductCode(accidentalDriving.getProductCode());
|
|
|
|
|
+ nonCarProductListDTO.setSelectProductName(productInfoListDTO.getProductName());
|
|
|
|
|
+ nonCarProductListDTO.setStartDate(commonCiRiskInfoVo != null ? commonCiRiskInfoVo.getStartDate() : null);
|
|
|
|
|
+ nonCarProductListDTO.setEndDate(commonCiRiskInfoVo != null ? commonCiRiskInfoVo.getEndDate() : null);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 匹配失败:重置为"不投保"状态
|
|
|
|
|
+ resetNonCarProduct(nonCarProductListDTO);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
} else {
|
|
} else {
|
|
|
- nonCarProductList.forEach(nonCarProductListDTO -> {
|
|
|
|
|
- nonCarProductListDTO.setIsSelect("0");
|
|
|
|
|
- nonCarProductListDTO.setPremium("0");
|
|
|
|
|
- nonCarProductListDTO.setStartDate(null);
|
|
|
|
|
- nonCarProductListDTO.setEndDate(null);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ // 公司系统未选择驾意险或产品列表为空:所有非车险产品重置为"不投保"状态
|
|
|
|
|
+ Optional.ofNullable(nonCarProductList)
|
|
|
|
|
+ .orElseGet(Collections::emptyList)
|
|
|
|
|
+ .forEach(this::resetNonCarProduct);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 请求接口
|
|
|
|
|
|
|
+ // ========== 8. 调用报价接口 ==========
|
|
|
|
|
+
|
|
|
|
|
+ // 设置请求参数
|
|
|
preciseInitParam.setChannelCode("OffWeb");
|
|
preciseInitParam.setChannelCode("OffWeb");
|
|
|
preciseInitParam.setInitFlag("quote");
|
|
preciseInitParam.setInitFlag("quote");
|
|
|
preciseInitParam.setTplatformId(tplatformId);
|
|
preciseInitParam.setTplatformId(tplatformId);
|
|
|
preciseInitParam.setTplatLoginKey(tplatLoginKey);
|
|
preciseInitParam.setTplatLoginKey(tplatLoginKey);
|
|
|
preciseInitParam.setOrderID(mainOrderId);
|
|
preciseInitParam.setOrderID(mainOrderId);
|
|
|
preciseInitParam.setRiskType("0808");
|
|
preciseInitParam.setRiskType("0808");
|
|
|
|
|
+
|
|
|
|
|
+ // 调用保司报价接口
|
|
|
PreciseInitResult preciseQuoteResult = httpService.preciseInitToQuote(session.getToken(), preciseInitParam);
|
|
PreciseInitResult preciseQuoteResult = httpService.preciseInitToQuote(session.getToken(), preciseInitParam);
|
|
|
|
|
|
|
|
|
|
+ // 校验报价结果
|
|
|
if (preciseQuoteResult == null) {
|
|
if (preciseQuoteResult == null) {
|
|
|
throw new RuntimeException("HttpService#preciseInitToQuote (报价)失败!");
|
|
throw new RuntimeException("HttpService#preciseInitToQuote (报价)失败!");
|
|
|
}
|
|
}
|