|
|
@@ -0,0 +1,160 @@
|
|
|
+package com.ydtech.modules.order.components.huatai;
|
|
|
+
|
|
|
+
|
|
|
+import com.ydtech.constants.InsuranceEnum;
|
|
|
+import com.ydtech.constants.enums.InsuranceRisk;
|
|
|
+import com.ydtech.modules.ins.model.vo.RiskInfoVo;
|
|
|
+import com.ydtech.modules.order.components.ZhongmeiRequestApiComponents;
|
|
|
+import com.ydtech.modules.order.entity.api.huatai.request.HuaTaiQuotedPriceRequest;
|
|
|
+import com.ydtech.modules.order.entity.api.huatai.response.HuaTaiQuotedPriceResponse;
|
|
|
+import com.ydtech.modules.order.entity.api.zhongmei.constants.TimeConstants;
|
|
|
+import com.ydtech.modules.order.entity.api.zhongmei.request.QuotedPriceRequest;
|
|
|
+import com.ydtech.modules.order.entity.api.zhongmei.response.QuotedPriceResponse;
|
|
|
+import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
|
|
|
+import com.ydtech.modules.order.utils.InsuranceLog;
|
|
|
+import com.ydtech.utils.DateTimeUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 华泰重复投保保期处理
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class HuaTaiRepeatInsuranceComponents {
|
|
|
+
|
|
|
+ private final HuaTaiRequestApiComponents huaTaiRequestApiComponents;
|
|
|
+
|
|
|
+ public HuaTaiRepeatInsuranceComponents(@Lazy HuaTaiRequestApiComponents huaTaiRequestApiComponents) {
|
|
|
+ this.huaTaiRequestApiComponents = huaTaiRequestApiComponents;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public HuaTaiQuotedPriceResponse dealRepeatDate(HuaTaiQuotedPriceRequest huaTaiQuotedPriceRequest, HuaTaiQuotedPriceResponse huaTaiQuotedPriceResponse, BaseQuoteInfoVo quoteInfo) {
|
|
|
+ String rtnMsgBz = "";
|
|
|
+ String rtnMsgBusi = "";
|
|
|
+ List<RiskInfoVo> riskList = quoteInfo.getRiskList();
|
|
|
+ InsuranceLog.infoLog(InsuranceEnum.ZMBX.getPinyin(), "\n\t---------> {}\n\t---------> {}", "中煤财险重复投保处理", rtnMsgBz + rtnMsgBusi);
|
|
|
+ /* rtnMsgBz = "交强险平台返回:号牌号码“晋HQE092”的保单发生重复投保,与其重复投保的其它公司的保单信息如下:投保确认码 02CCIC140022102196416712744293;保单号 PDFA22140123250000001413;起保日期 2022-10-24 00:00;终保日期 2023-10-24 00:00;号牌号码 晋HQE092;号牌种类 02;车架号 LSGBC5356HG101426;发动机号 170971343;地区 山西。";
|
|
|
+ rtnMsgBusi = "平台校验:成功 投保查询码:V0101ZMBX140023092205710579353 平台校验,可能存在重复投保,请关注以下平台返回的信息。保单号:6605212022140193005587; 保险公司:中国人寿财产保险公司: 起保日期:2022-10-1600:00:00; 终保日期:2023-10-16; 录单日期:2022-09-15; 险种名称:机动车第三者责任保险: 号牌号码:晋A711BW; 号牌种类代码:02; 号牌底色:01; 车辆识别代号: LGWEF4A52HF424155; 发动机号:1725091016";
|
|
|
+ 投保查询码:V0101ZMBX140023102198367810970平台校验,可能存在重复投保,请关注以下平台返回的信息。保单号:;保险公司:;起保日期:;终保日期:;录单日期:;车辆识别代号:LVHRE4876B5049915;发动机号:5049956;重复投保公司种类:其他公司
|
|
|
+*/
|
|
|
+ HuaTaiQuotedPriceRequest.ContractDto.ContractMainDto contractMainDTOBiz = null;
|
|
|
+ HuaTaiQuotedPriceRequest.ContractDto.ContractMainDto contractMainDTOBusi = null;
|
|
|
+ List<HuaTaiQuotedPriceRequest.ContractDto> contractDtoList = huaTaiQuotedPriceRequest.getBusinessData().getContract();
|
|
|
+
|
|
|
+ for (HuaTaiQuotedPriceRequest.ContractDto contractDto : contractDtoList) {
|
|
|
+ HuaTaiQuotedPriceRequest.ContractDto.ContractMainDto contractMainDTO = contractDto.getContractMain();
|
|
|
+ if ("1002".equals(contractMainDTO.getRiskCode())) {
|
|
|
+ contractMainDTOBiz = contractDto.getContractMain();
|
|
|
+ } else {
|
|
|
+ contractMainDTOBusi = contractDto.getContractMain();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ String jqEndDate = "";
|
|
|
+ String syEndDate = "";
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(rtnMsgBz) && rtnMsgBz.contains("起保日期") && rtnMsgBz.contains("终保日期")) {
|
|
|
+ String coverageEndDate = rtnMsgBz.substring(rtnMsgBz.indexOf("终保日期") + 5, rtnMsgBz.indexOf("终保日期") + 5 + 16);
|
|
|
+ if(coverageEndDate.contains("-")){
|
|
|
+ LocalDateTime start = DateTimeUtil.parseLocalDateTime(coverageEndDate, DateTimeUtil.DATETIME_PATTERN_EXT1);
|
|
|
+ jqEndDate = DateTimeUtil.getStartTimeOfDayStr(start, DateTimeUtil.DATETIME_PATTERN);
|
|
|
+ contractMainDTOBiz = getPeriodDate(jqEndDate, contractMainDTOBiz);
|
|
|
+ for (RiskInfoVo riskInfoVo : riskList) {
|
|
|
+ if (InsuranceRisk.TRAFFIC.getCode().equals(riskInfoVo.getRiskCode())) {
|
|
|
+ riskInfoVo.setStartDate(contractMainDTOBiz.getValidDate());
|
|
|
+ riskInfoVo.setEndDate(contractMainDTOBiz.getExpiryDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return huaTaiQuotedPriceResponse;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 商业险
|
|
|
+ if (StringUtils.isNotEmpty(rtnMsgBusi) && rtnMsgBusi.contains("起保日期") && rtnMsgBusi.contains("终保日期")) {
|
|
|
+ String coverageEndDate = rtnMsgBusi.substring(rtnMsgBusi.indexOf("终保日期") + 5, rtnMsgBusi.indexOf("终保日期") + 5 + 10);
|
|
|
+ if(coverageEndDate.contains("-")){
|
|
|
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LocalDateTime start = LocalDate.parse(coverageEndDate, dateTimeFormatter).atStartOfDay();
|
|
|
+ syEndDate = DateTimeUtil.getStartTimeOfDayStr(start, DateTimeUtil.DATETIME_PATTERN);
|
|
|
+ contractMainDTOBusi = getPeriodDate(syEndDate, contractMainDTOBusi);
|
|
|
+ for (RiskInfoVo riskInfoVo : riskList) {
|
|
|
+ if (InsuranceRisk.BUSINESS.getCode().equals(riskInfoVo.getRiskCode())) {
|
|
|
+ riskInfoVo.setStartDate(contractMainDTOBusi.getValidDate());
|
|
|
+ riskInfoVo.setEndDate(contractMainDTOBusi.getExpiryDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return huaTaiQuotedPriceResponse;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return huaTaiRequestApiComponents.quotedPrice(huaTaiQuotedPriceRequest, HuaTaiQuotedPriceResponse.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ public HuaTaiQuotedPriceResponse dealRepeatDateFormError(HuaTaiQuotedPriceRequest quotedPriceRequest, HuaTaiQuotedPriceResponse quotedPriceResponse, BaseQuoteInfoVo quoteInfo) {
|
|
|
+ InsuranceLog.infoLog(InsuranceEnum.ZMBX.getPinyin(), "\n\t---------> {}\n\t---------> {}", "华泰财险重复投保处理", quotedPriceResponse.getHead().getReturnMessage());
|
|
|
+ String rtnMsgBusi = quotedPriceResponse.getHead().getReturnMessage();
|
|
|
+ List<RiskInfoVo> riskList = quoteInfo.getRiskList();
|
|
|
+
|
|
|
+ HuaTaiQuotedPriceRequest.ContractDto.ContractMainDto contractMainDTOBiz = null;
|
|
|
+ HuaTaiQuotedPriceRequest.ContractDto.ContractMainDto contractMainDTOBusi = null;
|
|
|
+ List<HuaTaiQuotedPriceRequest.ContractDto> contractDTOList = quotedPriceRequest.getBusinessData().getContract();
|
|
|
+
|
|
|
+ for (HuaTaiQuotedPriceRequest.ContractDto contractDTO : contractDTOList) {
|
|
|
+ HuaTaiQuotedPriceRequest.ContractDto.ContractMainDto contractMainDTO = contractDTO.getContractMain();
|
|
|
+ if ("1002".equals(contractMainDTO.getRiskCode())) {
|
|
|
+ contractMainDTOBiz = contractDTO.getContractMain();
|
|
|
+ } else {
|
|
|
+ contractMainDTOBusi = contractDTO.getContractMain();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ String syEndDate = "";
|
|
|
+ // 商业险
|
|
|
+ if (StringUtils.isNotEmpty(rtnMsgBusi) && rtnMsgBusi.contains("起保日期") && rtnMsgBusi.contains("终保日期")) {
|
|
|
+ String coverageEndDate = rtnMsgBusi.substring(rtnMsgBusi.indexOf("终保日期") + 5, rtnMsgBusi.indexOf("终保日期") + 5 + 10);
|
|
|
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LocalDateTime start = LocalDate.parse(coverageEndDate, dateTimeFormatter).atStartOfDay().plusDays(1);
|
|
|
+ syEndDate = DateTimeUtil.getStartTimeOfDayStr(start, DateTimeUtil.DATETIME_PATTERN);
|
|
|
+ contractMainDTOBusi = getPeriodDate(syEndDate, contractMainDTOBusi);
|
|
|
+ for (RiskInfoVo riskInfoVo : riskList) {
|
|
|
+ if (InsuranceRisk.BUSINESS.getCode().equals(riskInfoVo.getRiskCode())) {
|
|
|
+ riskInfoVo.setStartDate(contractMainDTOBusi.getValidDate());
|
|
|
+ riskInfoVo.setEndDate(contractMainDTOBusi.getExpiryDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return huaTaiRequestApiComponents.quotedPrice(quotedPriceRequest, HuaTaiQuotedPriceResponse.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ private HuaTaiQuotedPriceRequest.ContractDto.ContractMainDto getPeriodDate(String startDate, HuaTaiQuotedPriceRequest.ContractDto.ContractMainDto contractMainDto) {
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ LocalDate localDate = LocalDate.parse(startDate, formatter);
|
|
|
+ LocalDate nextYears = localDate.plusYears(1);
|
|
|
+ if (startDate.contains(TimeConstants.START_TIME)) {
|
|
|
+ LocalDate expiry = nextYears.minusDays(1);
|
|
|
+ contractMainDto.setValidDate(startDate);
|
|
|
+ contractMainDto.setExpiryDate(expiry + " " + TimeConstants.END_TIME);
|
|
|
+ } else {
|
|
|
+ // 及时
|
|
|
+ LocalDateTime localDateTime = LocalDateTime.parse(startDate, formatter);
|
|
|
+ LocalDateTime expiryDateTime = localDateTime.plusYears(1);
|
|
|
+ contractMainDto.setValidDate(startDate);
|
|
|
+ contractMainDto.setExpiryDate(expiryDateTime.format(formatter));
|
|
|
+ }
|
|
|
+ return contractMainDto;
|
|
|
+ }
|
|
|
+}
|