|
@@ -1,24 +1,54 @@
|
|
|
package com.ydtech.modules.order.service.impl;
|
|
package com.ydtech.modules.order.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.ArrayUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
+import com.ydtech.config.properties.YangGuangApiConfigurationProperties;
|
|
|
|
|
+import com.ydtech.constants.enums.InsuranceOrderPdf;
|
|
|
|
|
+import com.ydtech.constants.enums.InsuranceRisk;
|
|
|
|
|
+import com.ydtech.constants.enums.dict.InsOrderStatusEnum;
|
|
|
import com.ydtech.core.page.HttpResult;
|
|
import com.ydtech.core.page.HttpResult;
|
|
|
-import com.ydtech.modules.ins.model.vo.QuoteRespVo;
|
|
|
|
|
|
|
+import com.ydtech.exception.SystemException;
|
|
|
|
|
+import com.ydtech.modules.ins.model.vo.*;
|
|
|
import com.ydtech.modules.order.components.ConfigureParametersComponents;
|
|
import com.ydtech.modules.order.components.ConfigureParametersComponents;
|
|
|
|
|
+import com.ydtech.modules.order.components.InsImagesUploadCacheComponents;
|
|
|
import com.ydtech.modules.order.components.yangguang.YangGuangRequestApiComponents;
|
|
import com.ydtech.modules.order.components.yangguang.YangGuangRequestApiComponents;
|
|
|
-import com.ydtech.modules.order.entity.api.yangguang.request.YangGuangQueryVehicleModelRequest;
|
|
|
|
|
-import com.ydtech.modules.order.entity.api.yangguang.response.YangGuangQueryVehicleModelResponse;
|
|
|
|
|
|
|
+import com.ydtech.modules.order.constants.InsuranceTypeCorrespondence;
|
|
|
|
|
+import com.ydtech.modules.order.constants.UnderwritingStatus;
|
|
|
|
|
+import com.ydtech.modules.order.entity.*;
|
|
|
|
|
+import com.ydtech.modules.order.entity.api.yangguang.request.*;
|
|
|
|
|
+import com.ydtech.modules.order.entity.api.yangguang.response.*;
|
|
|
|
|
+import com.ydtech.modules.order.entity.api.zijin.constants.enums.BusType;
|
|
|
import com.ydtech.modules.order.entity.config.YangGuangConfigureParameters;
|
|
import com.ydtech.modules.order.entity.config.YangGuangConfigureParameters;
|
|
|
|
|
+import com.ydtech.modules.order.entity.dto.ReadPdfUrlListDto;
|
|
|
|
|
+import com.ydtech.modules.order.entity.filter.CarModelsFilterUtils;
|
|
|
|
|
+import com.ydtech.modules.order.entity.po.InsTaskImagesBase64;
|
|
|
import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
|
|
import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
|
|
|
import com.ydtech.modules.order.entity.vo.BaseQuoteVo;
|
|
import com.ydtech.modules.order.entity.vo.BaseQuoteVo;
|
|
|
-import com.ydtech.modules.order.service.YangGuangOrderApiService;
|
|
|
|
|
|
|
+import com.ydtech.modules.order.entity.vo.PolicyPrintVo;
|
|
|
|
|
+import com.ydtech.modules.order.entity.vo.yangguang.YgNonVehicleProductsVo;
|
|
|
|
|
+import com.ydtech.modules.order.entity.vo.yangguang.YgQuoteAccidentVo;
|
|
|
|
|
+import com.ydtech.modules.order.service.*;
|
|
|
import com.ydtech.modules.protocol.entity.po.PtlAgreementAttribution;
|
|
import com.ydtech.modules.protocol.entity.po.PtlAgreementAttribution;
|
|
|
import com.ydtech.modules.protocol.service.PtlAgreementAttributionService;
|
|
import com.ydtech.modules.protocol.service.PtlAgreementAttributionService;
|
|
|
|
|
+import com.ydtech.modules.protocol.utils.AssertionUtils;
|
|
|
|
|
+import com.ydtech.utils.CalculateUtils;
|
|
|
|
|
+import com.ydtech.utils.StringUtils;
|
|
|
|
|
+import com.ydtech.utils.baidu.FileUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
|
|
-import java.util.Date;
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.Collections;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -29,21 +59,647 @@ public class YangGuangOrderApiServiceImpl implements YangGuangOrderApiService {
|
|
|
private final ConfigureParametersComponents configureParametersComponents;
|
|
private final ConfigureParametersComponents configureParametersComponents;
|
|
|
|
|
|
|
|
private final YangGuangRequestApiComponents yangGuangRequestApiComponents;
|
|
private final YangGuangRequestApiComponents yangGuangRequestApiComponents;
|
|
|
|
|
+
|
|
|
|
|
+ private final InsOrdersService insOrdersService;
|
|
|
|
|
+
|
|
|
|
|
+ private final InsAreaCompanyService insAreaCompanyService;
|
|
|
|
|
+
|
|
|
|
|
+ private final InsSubOrderUpdateDetailService insSubOrderUpdateDetailService;
|
|
|
|
|
+
|
|
|
|
|
+ private final YangGuangApiConfigurationProperties yangGuangApiConfigurationProperties;
|
|
|
|
|
+
|
|
|
|
|
+ private final InsTaskImagesService insTaskImagesService;
|
|
|
|
|
+
|
|
|
|
|
+ private InsImagesUploadCacheComponents insImagesUploadCacheComponents;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Value("${upload.file.path}")
|
|
|
|
|
+ private String uploadFilePath;
|
|
|
|
|
+
|
|
|
|
|
+ @Value("${upload.file.url}")
|
|
|
|
|
+ private String showFileUrl;
|
|
|
|
|
+
|
|
|
|
|
+ @Value("${api.url}")
|
|
|
|
|
+ private String apiUrl;
|
|
|
@Override
|
|
@Override
|
|
|
- public HttpResult<QuoteRespVo> quote(BaseQuoteInfoVo quoteInfoVo) {
|
|
|
|
|
|
|
+ public HttpResult<QuoteRespVo> quote(BaseQuoteInfoVo quoteInfoVo, BaseQuoteVo<List<YgQuoteAccidentVo>> quoteVo) throws JsonProcessingException {
|
|
|
// 通过协议获取配置实体
|
|
// 通过协议获取配置实体
|
|
|
-// String agreementId = quoteVo.getAgreementId();
|
|
|
|
|
-// PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(agreementId);
|
|
|
|
|
-// YangGuangConfigureParameters ygConfigureParameters = configureParametersComponents.toEntity(YangGuangConfigureParameters.class,
|
|
|
|
|
-// ptlAgreementAttribution);
|
|
|
|
|
-// HttpHeaders httpHeaders = yangGuangRequestApiComponents.
|
|
|
|
|
-// );
|
|
|
|
|
|
|
+ String agreementId = quoteVo.getAgreementId();
|
|
|
|
|
+ PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(agreementId);
|
|
|
|
|
+ YangGuangConfigureParameters ygConfigureParameters = configureParametersComponents.toEntity(YangGuangConfigureParameters.class,
|
|
|
|
|
+ ptlAgreementAttribution);
|
|
|
// 查询车型
|
|
// 查询车型
|
|
|
- YangGuangQueryVehicleModelRequest yangGuangQueryVehicleModelRequest = new YangGuangQueryVehicleModelRequest(quoteInfoVo.getCarInfo());
|
|
|
|
|
|
|
+ YangGuangQueryVehicleModelRequest yangGuangQueryVehicleModelRequest = new YangGuangQueryVehicleModelRequest(quoteInfoVo.getCarInfo(), ygConfigureParameters);
|
|
|
|
|
+ if (quoteInfoVo.getCarInfo().isNoLicenseFlag()) {
|
|
|
|
|
+ yangGuangQueryVehicleModelRequest.setIsNewCar("1");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ yangGuangQueryVehicleModelRequest.setIsNewCar("0");
|
|
|
|
|
+ }
|
|
|
yangGuangQueryVehicleModelRequest.setIsNewCar("1");
|
|
yangGuangQueryVehicleModelRequest.setIsNewCar("1");
|
|
|
- System.out.println(yangGuangQueryVehicleModelRequest);
|
|
|
|
|
YangGuangQueryVehicleModelResponse yangGuangQueryVehicleModelResponse = yangGuangRequestApiComponents.queryVehicleModel(yangGuangQueryVehicleModelRequest);
|
|
YangGuangQueryVehicleModelResponse yangGuangQueryVehicleModelResponse = yangGuangRequestApiComponents.queryVehicleModel(yangGuangQueryVehicleModelRequest);
|
|
|
- System.out.println(yangGuangQueryVehicleModelResponse);
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ List<YangGuangQueryVehicleModelResponse.carmodellist> carModelList = yangGuangQueryVehicleModelResponse.getCarmodellist();
|
|
|
|
|
+ //过滤车型
|
|
|
|
|
+ YangGuangQueryVehicleModelResponse.carmodellist carModelList1 =
|
|
|
|
|
+ new CarModelsFilterUtils<YangGuangQueryVehicleModelResponse.carmodellist>().to(carModelList, quoteInfoVo.getCarInfo());
|
|
|
|
|
+
|
|
|
|
|
+ String purchasePrice = carModelList1.getPurchasePrice();
|
|
|
|
|
+ String seatCount = carModelList1.getSeatcount();
|
|
|
|
|
+ CarInfoVo carInfo = quoteInfoVo.getCarInfo();
|
|
|
|
|
+ String startDate;
|
|
|
|
|
+
|
|
|
|
|
+ //计算起保日期
|
|
|
|
|
+ List<RiskInfoVo> riskList = quoteInfoVo.getRiskList();
|
|
|
|
|
+ if (riskList.size() == 1 && InsuranceRisk.TRAFFIC.getCode().equals(riskList.get(0).getRiskCode())) {
|
|
|
|
|
+ startDate = riskList.get(0).getStartDate();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ startDate =
|
|
|
|
|
+ Objects.requireNonNull(riskList.stream().filter(x -> InsuranceRisk.BUSINESS.getCode().equals(x.getRiskCode())).findFirst().orElse(null)).getStartDate();
|
|
|
|
|
+ }
|
|
|
|
|
+ // 如果险种为单商或交商 需要报两次价 将第一次报出的车实际价值取到
|
|
|
|
|
+ //报价
|
|
|
|
|
+ InsOrders insOrders = insOrdersService.getById(quoteInfoVo.getOrderNo());
|
|
|
|
|
+
|
|
|
|
|
+ YangGuangAccuracyCalculateRequest yangGuangAccuracyCalculateRequest = new YangGuangAccuracyCalculateRequest(quoteInfoVo, purchasePrice, carModelList1, riskList.get(0),startDate,ygConfigureParameters,quoteVo.getAccidentalDrivingVo());
|
|
|
|
|
+ yangGuangAccuracyCalculateRequest.setInfotransNo(yangGuangQueryVehicleModelResponse.getInfotransNo());
|
|
|
|
|
+ YangGuangAccuracyCalculateResponse yangGuangAccuracyCalculateResponse = yangGuangRequestApiComponents.accuracyCalculaye(yangGuangAccuracyCalculateRequest);
|
|
|
|
|
+ if (insOrders.getProductid().equals("034001") || insOrders.getProductid().equals("0330034001")) {
|
|
|
|
|
+ if (yangGuangAccuracyCalculateResponse.getErrorCode().equals("0")) {
|
|
|
|
|
+ YangGuangAccuracyCalculateResponse.itemcar itemcar = yangGuangAccuracyCalculateResponse.getItemcar();
|
|
|
|
|
+ String actualValue = itemcar.getActualValue();
|
|
|
|
|
+ YangGuangAccuracyCalculateRequest yangGuangAccuracyCalculateRequest1 = new YangGuangAccuracyCalculateRequest(quoteInfoVo, actualValue, carModelList1, riskList.get(0),startDate,ygConfigureParameters,quoteVo.getAccidentalDrivingVo());
|
|
|
|
|
+ yangGuangAccuracyCalculateRequest1.setInfotransNo(yangGuangQueryVehicleModelResponse.getInfotransNo());
|
|
|
|
|
+ YangGuangAccuracyCalculateResponse yangGuangAccuracyCalculateResponse1 = yangGuangRequestApiComponents.accuracyCalculaye(yangGuangAccuracyCalculateRequest1);
|
|
|
|
|
+ boolean isEnergy = carInfo.isNewEnergy();
|
|
|
|
|
+
|
|
|
|
|
+ if (!yangGuangAccuracyCalculateResponse1.getErrorCode().equals("0")) {
|
|
|
|
|
+ QuoteRespVo resp = new QuoteRespVo();
|
|
|
|
|
+ InsOrders order = insOrdersService.getById(quoteInfoVo.getOrderNo());
|
|
|
|
|
+ InsOrderStatusEnum insOrderStatusEnum = InsOrderStatusEnum.QUOTE_FAILED;
|
|
|
|
|
+ if (yangGuangAccuracyCalculateResponse1.getErrorMessage().contains("重复投保")) {
|
|
|
|
|
+ insOrderStatusEnum = InsOrderStatusEnum.REPEAT_INSURE;
|
|
|
|
|
+ }
|
|
|
|
|
+ insOrdersService.responseFailedOrder(quoteVo,ptlAgreementAttribution, order, yangGuangAccuracyCalculateResponse1.getErrorMessage(),insOrderStatusEnum);
|
|
|
|
|
+ throw new SystemException(yangGuangAccuracyCalculateResponse1.getErrorMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 处理数据
|
|
|
|
|
+ QuoteRespVo quoteRespVo = getQuoteRespVo(yangGuangAccuracyCalculateResponse1, quoteInfoVo, quoteVo.getAccidentalDrivingVo(), isEnergy);
|
|
|
|
|
+
|
|
|
|
|
+ // 设置核心报价车型
|
|
|
|
|
+ quoteRespVo.setCoreModels(carModelList1.toCoreModelsVo());
|
|
|
|
|
+ return responseOrder(yangGuangAccuracyCalculateResponse1, quoteRespVo, ptlAgreementAttribution, quoteInfoVo.getOrderNo(),
|
|
|
|
|
+ quoteVo.getAccidentalDrivingVo());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ InsOrders order = insOrdersService.getById(quoteInfoVo.getOrderNo());
|
|
|
|
|
+ InsOrderStatusEnum insOrderStatusEnum = InsOrderStatusEnum.QUOTE_FAILED;
|
|
|
|
|
+ if (yangGuangAccuracyCalculateResponse.getErrorMessage().contains("重复投保")) {
|
|
|
|
|
+ insOrderStatusEnum = InsOrderStatusEnum.REPEAT_INSURE;
|
|
|
|
|
+ }
|
|
|
|
|
+ insOrdersService.responseFailedOrder(quoteVo,ptlAgreementAttribution, order, yangGuangAccuracyCalculateResponse.getErrorMessage(),insOrderStatusEnum);
|
|
|
|
|
+ throw new SystemException(yangGuangAccuracyCalculateResponse.getErrorMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ boolean isEnergy = carInfo.isNewEnergy();
|
|
|
|
|
+
|
|
|
|
|
+ if (!yangGuangAccuracyCalculateResponse.getErrorCode().equals("0")) {
|
|
|
|
|
+ QuoteRespVo resp = new QuoteRespVo();
|
|
|
|
|
+ InsOrders order = insOrdersService.getById(quoteInfoVo.getOrderNo());
|
|
|
|
|
+ InsOrderStatusEnum insOrderStatusEnum = InsOrderStatusEnum.QUOTE_FAILED;
|
|
|
|
|
+ if (yangGuangAccuracyCalculateResponse.getErrorMessage().contains("重复投保")) {
|
|
|
|
|
+ insOrderStatusEnum = InsOrderStatusEnum.REPEAT_INSURE;
|
|
|
|
|
+ }
|
|
|
|
|
+ insOrdersService.responseFailedOrder(quoteVo,ptlAgreementAttribution, order, yangGuangAccuracyCalculateResponse.getErrorMessage(),insOrderStatusEnum);
|
|
|
|
|
+ throw new SystemException(yangGuangAccuracyCalculateResponse.getErrorMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 处理数据
|
|
|
|
|
+ QuoteRespVo quoteRespVo = getQuoteRespVo(yangGuangAccuracyCalculateResponse, quoteInfoVo, quoteVo.getAccidentalDrivingVo(), isEnergy);
|
|
|
|
|
+
|
|
|
|
|
+ // 设置核心报价车型
|
|
|
|
|
+ quoteRespVo.setCoreModels(carModelList1.toCoreModelsVo());
|
|
|
|
|
+ return responseOrder(yangGuangAccuracyCalculateResponse, quoteRespVo, ptlAgreementAttribution, quoteInfoVo.getOrderNo(),
|
|
|
|
|
+ quoteVo.getAccidentalDrivingVo());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public HttpResult<Object> upload(String companyId) throws Exception {
|
|
|
|
|
+ try {
|
|
|
|
|
+ InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(companyId);
|
|
|
|
|
+ PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
|
|
|
|
|
+ YangGuangConfigureParameters parameters = configureParametersComponents.toEntity(YangGuangConfigureParameters.class,
|
|
|
|
|
+ ptlAgreementAttribution);
|
|
|
|
|
+ String InfotransNo = insAreaCompany.getInsOrderNo();
|
|
|
|
|
+
|
|
|
|
|
+ InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
|
|
|
|
|
+ List<InsTaskImagesBase64> insTaskImagesBase64s = insTaskImagesService.findByOrderNo(insOrders.getOrderno(),
|
|
|
|
|
+ insAreaCompany.getId(), true);
|
|
|
|
|
+ if (insTaskImagesBase64s.isEmpty()) {
|
|
|
|
|
+ return HttpResult.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+ for (InsTaskImagesBase64 insTaskImagesBase64 :insTaskImagesBase64s) {
|
|
|
|
|
+ YangGuangUpLoadRequest yangGuangUpLoadRequest = new YangGuangUpLoadRequest(InfotransNo, insTaskImagesBase64, parameters);
|
|
|
|
|
+ String yangGuangUpLoadResponse = yangGuangRequestApiComponents.upload(yangGuangUpLoadRequest);
|
|
|
|
|
+ log.info("上传影像:{}", yangGuangUpLoadResponse);
|
|
|
|
|
+ }
|
|
|
|
|
+ insImagesUploadCacheComponents.setUploadImageCache(companyId, insTaskImagesBase64s);
|
|
|
|
|
+ return HttpResult.ok();
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public HttpResult<Object> submit(String companyId) throws JsonProcessingException {
|
|
|
|
|
+ try{
|
|
|
|
|
+ InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(companyId);
|
|
|
|
|
+ InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
|
|
|
|
|
+
|
|
|
|
|
+ // 通过协议获取配置实体
|
|
|
|
|
+ PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
|
|
|
|
|
+ YangGuangConfigureParameters ygConfigureParameters = configureParametersComponents.toEntity(YangGuangConfigureParameters.class,
|
|
|
|
|
+ ptlAgreementAttribution);
|
|
|
|
|
+
|
|
|
|
|
+ String productid = insOrders.getProductid();
|
|
|
|
|
+ // 提交核保
|
|
|
|
|
+ YangGuangSubmitRequest yangGuangSubmitRequest = new YangGuangSubmitRequest(insOrders, insAreaCompany, productid, ygConfigureParameters);
|
|
|
|
|
+ YangGuangSubmitResponse yangGuangSubmitResponse = yangGuangRequestApiComponents.submit(yangGuangSubmitRequest);
|
|
|
|
|
+ if (!yangGuangSubmitResponse.getErrorCode().equals("0")) {
|
|
|
|
|
+ return HttpResult.error(yangGuangSubmitResponse.getErrorMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 核保转人工
|
|
|
|
|
+ if (yangGuangSubmitResponse.getCiUnderWriteFlag() != null && !yangGuangSubmitResponse.getCiUnderWriteFlag().equals("1")) {
|
|
|
|
|
+ if (yangGuangSubmitResponse.getCiUnderWriteFlag().equals("3")) {
|
|
|
|
|
+ insAreaCompany.setUnderwritingStatus(UnderwritingStatus.US_2.getCode());
|
|
|
|
|
+ insSubOrderUpdateDetailService.insertData(insAreaCompany,insAreaCompany.getOrderstatus(),InsOrderStatusEnum.WAIT_AUDIT.getCode(),"1");
|
|
|
|
|
+ insAreaCompany.setOrderstatus(InsOrderStatusEnum.WAIT_AUDIT.getCode());
|
|
|
|
|
+ String message = yangGuangSubmitResponse.getCiUnderWriteMsg();
|
|
|
|
|
+ insAreaCompany.setJqpolicyno(yangGuangSubmitResponse.getCiProposalNo() != null ? yangGuangSubmitResponse.getCiProposalNo() :"");
|
|
|
|
|
+ insAreaCompanyService.updateCompanyAndOrdersMessage(insAreaCompany, message);
|
|
|
|
|
+ return HttpResult.error("自核转人工,原因:" + message);
|
|
|
|
|
+ }
|
|
|
|
|
+ return HttpResult.error("商业险自核失败,原因:" + yangGuangSubmitResponse.getBiUnderWriteMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (yangGuangSubmitResponse.getBiUnderWriteFlag() != null && !yangGuangSubmitResponse.getBiUnderWriteFlag().equals("1")) {
|
|
|
|
|
+ if (yangGuangSubmitResponse.getBiUnderWriteFlag().equals("3")) {
|
|
|
|
|
+ insAreaCompany.setUnderwritingStatus(UnderwritingStatus.US_2.getCode());
|
|
|
|
|
+ insSubOrderUpdateDetailService.insertData(insAreaCompany,insAreaCompany.getOrderstatus(),InsOrderStatusEnum.WAIT_AUDIT.getCode(),"1");
|
|
|
|
|
+ insAreaCompany.setOrderstatus(InsOrderStatusEnum.WAIT_AUDIT.getCode());
|
|
|
|
|
+ String message = yangGuangSubmitResponse.getBiUnderWriteMsg();
|
|
|
|
|
+ insAreaCompany.setSypolicyno(yangGuangSubmitResponse.getBiProposalNo() != null ? yangGuangSubmitResponse.getBiProposalNo() :"");
|
|
|
|
|
+ insAreaCompanyService.updateCompanyAndOrdersMessage(insAreaCompany, message);
|
|
|
|
|
+ return HttpResult.error("自核转人工,原因:" + message);
|
|
|
|
|
+ }
|
|
|
|
|
+ return HttpResult.error("商业险自核失败,原因:" + yangGuangSubmitResponse.getBiUnderWriteMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 投保单号
|
|
|
|
|
+ insAreaCompany.setJqpolicyno(yangGuangSubmitResponse.getCiProposalNo() != null ? yangGuangSubmitResponse.getCiProposalNo() :"");
|
|
|
|
|
+ insAreaCompany.setSypolicyno(yangGuangSubmitResponse.getBiProposalNo() != null ? yangGuangSubmitResponse.getBiProposalNo() :"");
|
|
|
|
|
+ insAreaCompany.setOrderstatus(InsOrderStatusEnum.WAIT_PAY.getCode());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //获取支付链接
|
|
|
|
|
+ YangGuangPaymentRequest yangGuangPaymentRequest = new YangGuangPaymentRequest(insAreaCompany, insOrders,yangGuangApiConfigurationProperties.getPayCallBack(),yangGuangSubmitResponse,ygConfigureParameters);
|
|
|
|
|
+ YangGuangPaymentResponse yangGuangPaymentResponse = yangGuangRequestApiComponents.payment(yangGuangPaymentRequest);
|
|
|
|
|
+ if (!yangGuangPaymentResponse.getErrorCode().equals("0")) {
|
|
|
|
|
+ return HttpResult.error(yangGuangPaymentResponse.getErrorMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ insAreaCompany.setPaymentLink(yangGuangPaymentResponse.getPayUrl());
|
|
|
|
|
+ insAreaCompanyService.updateCompanyAndOrders(insAreaCompany);
|
|
|
|
|
+ return HttpResult.ok("核保成功");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new RuntimeException(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public InsAreaCompany payment(InsAreaCompany insAreaCompany) {
|
|
|
|
|
+ InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 获取协议配置信息
|
|
|
|
|
+ YangGuangConfigureParameters ygConfigureParameters = configureParametersComponents.toEntity(YangGuangConfigureParameters.class,
|
|
|
|
|
+ insAreaCompany.getAgreementId());
|
|
|
|
|
+ // 支付请求
|
|
|
|
|
+ YangGuangPaymentRequest yangGuangPaymentRequest = new YangGuangPaymentRequest(insAreaCompany, insOrders,yangGuangApiConfigurationProperties.getPayCallBack(),null,ygConfigureParameters);
|
|
|
|
|
+ YangGuangPaymentResponse yangGuangPaymentResponse = yangGuangRequestApiComponents.payment(yangGuangPaymentRequest);
|
|
|
|
|
+ if (yangGuangPaymentResponse.getErrorCode().equals("0")) {
|
|
|
|
|
+ insAreaCompany.setPaymentLink(yangGuangPaymentResponse.getPayUrl());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.error("阳光API - 获取支付链接失败" + yangGuangPaymentResponse.getErrorMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ throw new SystemException("获取支付连接失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ return insAreaCompany;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public HttpResult<Object> paymentCallback(String companyId) throws JsonProcessingException {
|
|
|
|
|
+ InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(companyId);
|
|
|
|
|
+ InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
|
|
|
|
|
+ AssertionUtils.isEmpty(insAreaCompany,"报价单不存在");
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isEmpty(insAreaCompany.getAgreementId())){
|
|
|
|
|
+ return HttpResult.error("订单协议ID为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ YangGuangConfigureParameters yangGuangConfigureParameters = configureParametersComponents.toEntity(YangGuangConfigureParameters.class,
|
|
|
|
|
+ insAreaCompany.getAgreementId());
|
|
|
|
|
+ YangGuangPaymentCallbackRequest yangGuangPaymentCallbackRequest = new YangGuangPaymentCallbackRequest(insAreaCompany, insOrders,yangGuangConfigureParameters);
|
|
|
|
|
+ YangGuangCallbackResponse yangGuangPaymentCallbackResponse = yangGuangRequestApiComponents.callback(yangGuangPaymentCallbackRequest);
|
|
|
|
|
+ log.info("阳光API - 保单生效通知 - 参数:{},车牌号:{}",JSON.toJSONString(yangGuangPaymentCallbackRequest),insOrders.getLicenseno());
|
|
|
|
|
+
|
|
|
|
|
+ String oldStatus = insAreaCompany.getOrderstatus();
|
|
|
|
|
+ if (yangGuangPaymentCallbackResponse.getErrorCode().equals("0")) {
|
|
|
|
|
+ if (insAreaCompany.getOrderstatus().equals(InsOrderStatusEnum.WAIT_PAY.getCode())) {
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ insAreaCompany = bulidCallBack(insAreaCompany, yangGuangPaymentCallbackResponse);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (insAreaCompany.getPayDate() == null) {
|
|
|
|
|
+ insAreaCompany.setPayDate(LocalDateTime.now());
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("变更前订单状态:" + insOrders.getOrderstatus());
|
|
|
|
|
+ log.info("变更前子订单状态:" + insAreaCompany.getOrderstatus());
|
|
|
|
|
+ log.info("变更后订单状态:" + insOrders.getOrderstatus());
|
|
|
|
|
+ insSubOrderUpdateDetailService.insertData(insAreaCompany,oldStatus,insAreaCompany.getOrderstatus(),"1");
|
|
|
|
|
+ insAreaCompanyService.updateCompanyAndOrdersNew(insAreaCompany);
|
|
|
|
|
+ return HttpResult.ok(yangGuangPaymentCallbackResponse);
|
|
|
|
|
+ }
|
|
|
|
|
+ return HttpResult.error(yangGuangPaymentCallbackResponse.getErrorMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ private InsAreaCompany bulidCallBack(InsAreaCompany insAreaCompany, YangGuangCallbackResponse yangGuangPaymentCallbackResponse) {
|
|
|
|
|
+ if (yangGuangPaymentCallbackResponse.getErrorCode().equals("0")) {
|
|
|
|
|
+ insAreaCompany = buildCallBackStatus(insAreaCompany, yangGuangPaymentCallbackResponse.getErrorCode());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ insAreaCompany = buildCallBackStatus(insAreaCompany, yangGuangPaymentCallbackResponse.getErrorCode());
|
|
|
|
|
+ }
|
|
|
|
|
+ return insAreaCompany;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private InsAreaCompany buildCallBackStatus(InsAreaCompany iac, String status) {
|
|
|
|
|
+ if (status.equals("1")) {
|
|
|
|
|
+ iac.setOrderstatus(InsOrderStatusEnum.WAIT_PAY.getCode());
|
|
|
|
|
+ //更新支付连接
|
|
|
|
|
+ log.debug("准备进入获取支付连接######################");
|
|
|
|
|
+ iac = payment(iac);
|
|
|
|
|
+ log.debug("结束 - 准备进入获取支付连接######################");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (status.equals("0")) {
|
|
|
|
|
+ iac.setOrderstatus(InsOrderStatusEnum.ACCEPT_INSURANCE.getCode());
|
|
|
|
|
+ }
|
|
|
|
|
+ return iac;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public HttpResult<List<YangGuangGetNonVehicleProductsResponse.nonVehicleProducts>> getNonVehicleProducts(YgNonVehicleProductsVo ygNonVehicleProductsVo) throws JsonProcessingException {
|
|
|
|
|
+ YangGuangConfigureParameters ygConfigureParameters = configureParametersComponents.toEntity(YangGuangConfigureParameters.class,
|
|
|
|
|
+ ygNonVehicleProductsVo.getAgreementId());
|
|
|
|
|
+ InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(ygNonVehicleProductsVo.getCompanyId());
|
|
|
|
|
+ InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
|
|
|
|
|
+ YangGuangGetNonVehicleProductsRequest yangGuangGetNonVehicleProductsRequest = new YangGuangGetNonVehicleProductsRequest(ygNonVehicleProductsVo.getSeatCount(),insOrders,ygConfigureParameters);
|
|
|
|
|
+ YangGuangGetNonVehicleProductsResponse yangGuangGetNonVehicleProductsResponse = yangGuangRequestApiComponents.getNonVehicleProducts(yangGuangGetNonVehicleProductsRequest);
|
|
|
|
|
+ if (!yangGuangGetNonVehicleProductsResponse.getErrorCode().equals("0")) {
|
|
|
|
|
+ return HttpResult.error(yangGuangGetNonVehicleProductsResponse.getErrorMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return HttpResult.ok(yangGuangGetNonVehicleProductsResponse.getNonVehicleProducts());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public HttpResult<Object> proposalStatusQuery(String companyId) throws JsonProcessingException {
|
|
|
|
|
+ InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(companyId);
|
|
|
|
|
+ InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
|
|
|
|
|
+ // 通过协议获取配置实体
|
|
|
|
|
+ PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
|
|
|
|
|
+ YangGuangConfigureParameters yangGuangConfigureParameters = configureParametersComponents.toEntity(YangGuangConfigureParameters.class,
|
|
|
|
|
+ ptlAgreementAttribution);
|
|
|
|
|
+ //接参查看订单核保状态
|
|
|
|
|
+ YangGuangProposalStatusQueryRequest yangGuangProposalStatusQueryRequest = new YangGuangProposalStatusQueryRequest(insAreaCompany,yangGuangConfigureParameters);
|
|
|
|
|
+ YangGuangProposalStatusQueryResponse yangGuangProposalStatusQueryResponse = yangGuangRequestApiComponents.proposalStatusQuery(yangGuangProposalStatusQueryRequest);
|
|
|
|
|
+ if (yangGuangProposalStatusQueryResponse.getErrorCode().equals("0")) {
|
|
|
|
|
+ if (yangGuangProposalStatusQueryResponse.getBiUnderWriteFlag().equals("3")) {
|
|
|
|
|
+ return HttpResult.error("商业险自核失败,原因:" + yangGuangProposalStatusQueryResponse.getBiUnderWriteMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (yangGuangProposalStatusQueryResponse.getCiUnderWriteFlag().equals("3")) {
|
|
|
|
|
+ return HttpResult.error("交强险自核失败,原因:" + yangGuangProposalStatusQueryResponse.getCiUnderWriteMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+ insSubOrderUpdateDetailService.insertData(insAreaCompany, insAreaCompany.getOrderstatus(), InsOrderStatusEnum.WAIT_PAY.getCode(), "1");
|
|
|
|
|
+ insAreaCompany.setOrderstatus(InsOrderStatusEnum.WAIT_PAY.getCode());
|
|
|
|
|
+ //更新投保单号和保单号
|
|
|
|
|
+ insAreaCompany.setJqpolicyno(yangGuangProposalStatusQueryResponse.getCiPolicyNo());
|
|
|
|
|
+ insAreaCompany.setSypolicyno(yangGuangProposalStatusQueryResponse.getBiPolicyNo());
|
|
|
|
|
+ insAreaCompany.setJqapplyno(yangGuangProposalStatusQueryResponse.getCiProposalNo());
|
|
|
|
|
+ insAreaCompany.setSyapplyno(yangGuangProposalStatusQueryResponse.getBiProposalNo());
|
|
|
|
|
+ //支付链接
|
|
|
|
|
+ YangGuangPaymentRequest yangGuangPaymentRequest = new YangGuangPaymentRequest(insAreaCompany, insOrders,yangGuangApiConfigurationProperties.getPayCallBack(),null,yangGuangConfigureParameters);
|
|
|
|
|
+ YangGuangPaymentResponse yangGuangPaymentResponse = yangGuangRequestApiComponents.payment(yangGuangPaymentRequest);
|
|
|
|
|
+ insAreaCompany.setPaymentLink(yangGuangPaymentResponse.getPayUrl());
|
|
|
|
|
+ insAreaCompanyService.updateCompanyAndOrders(insAreaCompany);
|
|
|
|
|
+ return HttpResult.ok("核保成功");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ insSubOrderUpdateDetailService.insertData(insAreaCompany, insAreaCompany.getOrderstatus(), InsOrderStatusEnum.TO_BACK.getCode(), "1");
|
|
|
|
|
+ insAreaCompany.setOrderstatus(InsOrderStatusEnum.TO_BACK.getCode());
|
|
|
|
|
+ insAreaCompanyService.updateCompanyAndOrdersMessage(insAreaCompany, yangGuangProposalStatusQueryResponse.getErrorMessage());
|
|
|
|
|
+ return HttpResult.error(yangGuangProposalStatusQueryResponse.getErrorMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public HttpResult getEpolicyPDFURL(PolicyPrintVo policyPrintVo) throws JsonProcessingException {
|
|
|
|
|
+ InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(policyPrintVo.getCompanyId());
|
|
|
|
|
+ if (!InsOrderStatusEnum.ACCEPT_INSURANCE.getCode().equals(insAreaCompany.getOrderstatus())) {
|
|
|
|
|
+ throw new SystemException("此订单还未承保");
|
|
|
|
|
+ }
|
|
|
|
|
+ YangGuangConfigureParameters ygConfigureParameters = configureParametersComponents.toEntity(YangGuangConfigureParameters.class,
|
|
|
|
|
+ insAreaCompany.getAgreementId());
|
|
|
|
|
+ InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
|
|
|
|
|
+ // 车牌号
|
|
|
|
|
+ String licensePlate = insOrders.getLicenseno();
|
|
|
|
|
+ //被保人信息
|
|
|
|
|
+ JSONObject ownerInfo = insOrders.getInsureinfo();
|
|
|
|
|
+ CustomerInfoVo customerInfoVo = ownerInfo.toJavaObject(CustomerInfoVo.class);
|
|
|
|
|
+ String busNo;
|
|
|
|
|
+ BusType busType;
|
|
|
|
|
+ String templateName;
|
|
|
|
|
+ switch (policyPrintVo.getRiskCode()) {
|
|
|
|
|
+ case InsuranceRisk.TRAFFIC_CODE:
|
|
|
|
|
+ busNo = insAreaCompany.getJqpolicyno();
|
|
|
|
|
+ busType = BusType.BT_1;
|
|
|
|
|
+ templateName = "-交强险保单.pdf";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case InsuranceRisk.BUSINESS_CODE:
|
|
|
|
|
+ busNo = insAreaCompany.getSypolicyno();
|
|
|
|
|
+ busType = BusType.BT_3;
|
|
|
|
|
+ templateName = "-商业险保单.pdf";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case InsuranceRisk.ACCIDENT_CODE:
|
|
|
|
|
+ busNo = policyPrintVo.getPolicyNumber();
|
|
|
|
|
+ busType = BusType.BT_4;
|
|
|
|
|
+ templateName = busNo + "-非车险保单.pdf";
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ throw new SystemException("保险编号异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ YangGuangGetEpolicyPdfUrlRequest yangGuangGetEpolicyPdfUrlRequest = new YangGuangGetEpolicyPdfUrlRequest(ygConfigureParameters, busNo);
|
|
|
|
|
+ YangGuangGetEpolicyPdfUrlResponse yangGuangGetEpolicyPdfUrlResponse = yangGuangRequestApiComponents.getEpolicyPDFURL(yangGuangGetEpolicyPdfUrlRequest);
|
|
|
|
|
+ if (!yangGuangGetEpolicyPdfUrlResponse.getErrorCode().equals("0")) {
|
|
|
|
|
+ return HttpResult.error("电子保单生成失败, 原因:" + yangGuangGetEpolicyPdfUrlResponse.getErrorMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ String transferUrl = gainCarInsPolicy(yangGuangGetEpolicyPdfUrlResponse.getEPolicyPDFURL(), licensePlate + templateName, insAreaCompany.getId());
|
|
|
|
|
+ return HttpResult.ok("电子保单生成成功", transferUrl);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public HttpResult<Object> elecApplicationSign(String companyId) throws JsonProcessingException {
|
|
|
|
|
+ InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(companyId);
|
|
|
|
|
+ InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
|
|
|
|
|
+ // 投保人手机号
|
|
|
|
|
+ JSONObject applyInfo = insOrders.getApplyinfo();
|
|
|
|
|
+ String mobile = applyInfo.getString("mobile");
|
|
|
|
|
+ PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
|
|
|
|
|
+ YangGuangConfigureParameters ygConfigureParameters = configureParametersComponents.toEntity(YangGuangConfigureParameters.class,
|
|
|
|
|
+ ptlAgreementAttribution);
|
|
|
|
|
+
|
|
|
|
|
+ YangGuangElecApplicationSignRequest yangGuangElecApplicationSignRequest =
|
|
|
|
|
+ new YangGuangElecApplicationSignRequest(ygConfigureParameters,
|
|
|
|
|
+ insAreaCompany.getJqapplyno() != null ? insAreaCompany.getJqapplyno() : "",
|
|
|
|
|
+ insAreaCompany.getSyapplyno() != null ? insAreaCompany.getSyapplyno() : "",
|
|
|
|
|
+ mobile);
|
|
|
|
|
+ YangGuangElecApplicationSignResponse yangGuangElecApplicationSignResponse = yangGuangRequestApiComponents.elecApplicationSign(yangGuangElecApplicationSignRequest);
|
|
|
|
|
+ if (yangGuangElecApplicationSignResponse.getErrorCode().equals("1")) {
|
|
|
|
|
+ HttpResult.error(yangGuangElecApplicationSignResponse.getErrorMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return HttpResult.ok("保单电子签名生成成功", yangGuangElecApplicationSignResponse.getSignURL());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public ReadPdfUrlListDto getPolicyByCompanyIdPdfList(InsAreaCompany insAreaCompany, InsOrders insOrders, boolean flag) {
|
|
|
|
|
+ String jqPath = getPdfUrl(insAreaCompany, insOrders,InsuranceRisk.TRAFFIC_CODE,PolicyPrintVo.PolicyPrintType.PPT_2.getCode(),insAreaCompany.getJqpolicyno(),flag);
|
|
|
|
|
+ String syPath = getPdfUrl(insAreaCompany,insOrders,InsuranceRisk.BUSINESS_CODE,PolicyPrintVo.PolicyPrintType.PPT_2.getCode(), insAreaCompany.getSypolicyno(),flag);
|
|
|
|
|
+ InsAreaCompanyExternalPolicy insAreaCompanyExternalPolicy =new InsAreaCompanyExternalPolicy(insAreaCompany.getId(),jqPath,syPath,null,null);
|
|
|
|
|
+ return new ReadPdfUrlListDto(insAreaCompanyExternalPolicy,insAreaCompany,null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public String getPdfUrl(InsAreaCompany insAreaCompany, InsOrders insOrders,String jqFlag,String jqSignFlag,String policyNo,boolean flag) {
|
|
|
|
|
+ if (!InsOrderStatusEnum.ACCEPT_INSURANCE.getCode().equals(insAreaCompany.getOrderstatus())) {
|
|
|
|
|
+ throw new SystemException("此订单还未承保");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 被保人信息
|
|
|
|
|
+ String pathPrefix = insAreaCompany.getInscompany()+"-"+insOrders.getLicenseno()+"-"+insAreaCompany.getId() +"-"+policyNo+"-";
|
|
|
|
|
+ if(org.apache.commons.lang3.StringUtils.isBlank(policyNo)){
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 1 通过 协议id获取配置实体
|
|
|
|
|
+ PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
|
|
|
|
|
+ YangGuangConfigureParameters parameters = configureParametersComponents.toEntity(YangGuangConfigureParameters.class,
|
|
|
|
|
+ ptlAgreementAttribution);
|
|
|
|
|
+ // 车牌号
|
|
|
|
|
+ String licensePlate = insOrders.getLicenseno();
|
|
|
|
|
+ // 被保人信息
|
|
|
|
|
+ String templateName = null;
|
|
|
|
|
+ String url = null;
|
|
|
|
|
+ try{
|
|
|
|
|
+ YangGuangGetEpolicyPdfUrlRequest request = new YangGuangGetEpolicyPdfUrlRequest(parameters,policyNo);
|
|
|
|
|
+ YangGuangGetEpolicyPdfUrlResponse response = yangGuangRequestApiComponents.getEpolicyPDFURL(request);
|
|
|
|
|
+ switch (jqFlag) {
|
|
|
|
|
+ case InsuranceRisk.TRAFFIC_CODE:
|
|
|
|
|
+ templateName = pathPrefix + InsuranceOrderPdf.JQBD.getDesc();
|
|
|
|
|
+ url = response.getEPolicyPDFURL();
|
|
|
|
|
+ break;
|
|
|
|
|
+ case InsuranceRisk.BUSINESS_CODE:
|
|
|
|
|
+ templateName = pathPrefix + InsuranceOrderPdf.SYBD.getDesc();
|
|
|
|
|
+ url = response.getEPolicyPDFURL();
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e){
|
|
|
|
|
+ throw new SystemException(e.toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ String transferUrl = gainCarInsPolicyNew(url, templateName, insAreaCompany.getId(),flag);
|
|
|
|
|
+ return transferUrl;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean autoWriteOff(String companyId) throws Exception {
|
|
|
|
|
+ InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(companyId);
|
|
|
|
|
+ YangGuangConfigureParameters ygConfigureParameters = configureParametersComponents.toEntity(YangGuangConfigureParameters.class,
|
|
|
|
|
+ insAreaCompany.getAgreementId());
|
|
|
|
|
+ String productid = insAreaCompany.getProductid();
|
|
|
|
|
+ //单交
|
|
|
|
|
+ if (productid.equals("0330")) {
|
|
|
|
|
+ YangGuangAutoWriteOffRequest yangGuangAutoWriteOffRequest = new YangGuangAutoWriteOffRequest(ygConfigureParameters, insAreaCompany.getJqpolicyno());
|
|
|
|
|
+ YangGuangAutoWriteOffResponse yangGuangAutoWriteOffResponse = yangGuangRequestApiComponents.autoWriteOff(yangGuangAutoWriteOffRequest);
|
|
|
|
|
+ if (yangGuangAutoWriteOffResponse.getErrorCode().equals("0")) {
|
|
|
|
|
+ HttpResult.ok(yangGuangAutoWriteOffResponse);
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 单商
|
|
|
|
|
+ if (productid.equals("034001")) {
|
|
|
|
|
+ YangGuangAutoWriteOffRequest yangGuangAutoWriteOffRequest = new YangGuangAutoWriteOffRequest(ygConfigureParameters, insAreaCompany.getSypolicyno());
|
|
|
|
|
+ YangGuangAutoWriteOffResponse yangGuangAutoWriteOffResponse = yangGuangRequestApiComponents.autoWriteOff(yangGuangAutoWriteOffRequest);
|
|
|
|
|
+ if (yangGuangAutoWriteOffResponse.getErrorCode().equals("0")) {
|
|
|
|
|
+ HttpResult.ok(yangGuangAutoWriteOffResponse);
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ //交商同保
|
|
|
|
|
+ if (insAreaCompany.getJqpolicyno() != null && insAreaCompany.getSypolicyno() != null && !insAreaCompany.getJqpolicyno().equals("") && !insAreaCompany.getSypolicyno().equals("")) {
|
|
|
|
|
+ YangGuangAutoWriteOffRequest yangGuangAutoWriteOffRequestJq = new YangGuangAutoWriteOffRequest(ygConfigureParameters, insAreaCompany.getJqpolicyno());
|
|
|
|
|
+ YangGuangAutoWriteOffResponse yangGuangAutoWriteOffResponseJq = yangGuangRequestApiComponents.autoWriteOff(yangGuangAutoWriteOffRequestJq);
|
|
|
|
|
+ YangGuangAutoWriteOffRequest yangGuangAutoWriteOffRequestSy = new YangGuangAutoWriteOffRequest(ygConfigureParameters, insAreaCompany.getSypolicyno());
|
|
|
|
|
+ YangGuangAutoWriteOffResponse yangGuangAutoWriteOffResponseSy = yangGuangRequestApiComponents.autoWriteOff(yangGuangAutoWriteOffRequestSy);
|
|
|
|
|
+ if (yangGuangAutoWriteOffResponseJq.getErrorCode().equals("0") && yangGuangAutoWriteOffResponseSy.getErrorCode().equals("0")) {
|
|
|
|
|
+ HttpResult.ok("撤单成功");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public QuoteRespVo getQuoteRespVo (YangGuangAccuracyCalculateResponse yangGuangAccuracyCalculateResponse, BaseQuoteInfoVo yaQuoteInfoVo, List<YgQuoteAccidentVo> accidentalDrivingVo, boolean isEnergy) {
|
|
|
|
|
+ double jqPremium = 0;
|
|
|
|
|
+ double syPremium = 0;
|
|
|
|
|
+ double sumPayTax = 0;
|
|
|
|
|
+ double jyPremium = 0;
|
|
|
|
|
+ QuoteRespVo quoteRespVo = new QuoteRespVo();
|
|
|
|
|
+
|
|
|
|
|
+ if (yangGuangAccuracyCalculateResponse.getCiSumPremium() != null) {
|
|
|
|
|
+ jqPremium = Double.parseDouble(yangGuangAccuracyCalculateResponse.getCiSumPremium());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (yangGuangAccuracyCalculateResponse.getBiSumPremium() != null) {
|
|
|
|
|
+ syPremium = Double.parseDouble(yangGuangAccuracyCalculateResponse.getBiSumPremium());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (yangGuangAccuracyCalculateResponse.getSumPayTax() != null) {
|
|
|
|
|
+ sumPayTax = Double.parseDouble(yangGuangAccuracyCalculateResponse.getSumPayTax());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 交强时间
|
|
|
|
|
+ if (yangGuangAccuracyCalculateResponse.getCiStartDate() != null && yangGuangAccuracyCalculateResponse.getCiEndDate() != null) {
|
|
|
|
|
+ quoteRespVo.setStartDateJq(yangGuangAccuracyCalculateResponse.getCiStartDate());
|
|
|
|
|
+ quoteRespVo.setEndDateJq(yangGuangAccuracyCalculateResponse.getCiEndDate());
|
|
|
|
|
+ }
|
|
|
|
|
+ //商业时间
|
|
|
|
|
+ if (yangGuangAccuracyCalculateResponse.getBiStartDate() != null && yangGuangAccuracyCalculateResponse.getBiEndDate() != null) {
|
|
|
|
|
+ quoteRespVo.setStartDateSy(yangGuangAccuracyCalculateResponse.getBiStartDate());
|
|
|
|
|
+ quoteRespVo.setEndDateSy(yangGuangAccuracyCalculateResponse.getBiEndDate());
|
|
|
|
|
+ }
|
|
|
|
|
+ YangGuangAccuracyCalculateResponse.discount discount = yangGuangAccuracyCalculateResponse.getDiscount();
|
|
|
|
|
+ if (discount != null) {
|
|
|
|
|
+ quoteRespVo.setILogPreUdwMess(discount.getFinalmarkingnobc() != null ? discount.getFinalmarkingnobc() : "");
|
|
|
|
|
+ quoteRespVo.setJqScore(discount.getMarkingnobcCI() != null ? discount.getMarkingnobcCI() : "");
|
|
|
|
|
+ quoteRespVo.setSyScore(discount.getMarkingnobcBI() != null ? discount.getMarkingnobcBI() : "");
|
|
|
|
|
+ quoteRespVo.setSyClaims(discount.getClaimTimes() != null ? discount.getClaimTimes() : "");
|
|
|
|
|
+ //自主定价系数
|
|
|
|
|
+ quoteRespVo.setPricingCoefficient(discount.getActualautoundwrtfactor() != null ? discount.getActualautoundwrtfactor() : "");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<QuoteKindRespVo> kindList1 = new ArrayList<>();
|
|
|
|
|
+ List<RiskInfoVo> riskList = yaQuoteInfoVo.getRiskList();
|
|
|
|
|
+ // 报价险种放入保费
|
|
|
|
|
+ List<QuoteRiskRespVo> riskList1 = QuoteRiskRespVo.toQuoteRiskRespVoList(riskList, jqPremium, syPremium);
|
|
|
|
|
+
|
|
|
|
|
+ QuoteKindRespVo kind;
|
|
|
|
|
+
|
|
|
|
|
+ List<YangGuangAccuracyCalculateResponse.kindList> itemKindList = yangGuangAccuracyCalculateResponse.getKindList();
|
|
|
|
|
+ //商业险险种
|
|
|
|
|
+ List<KindInfoVo> kindList = yaQuoteInfoVo.getKindList();
|
|
|
|
|
+ for (KindInfoVo kindInfoVo : kindList) {
|
|
|
|
|
+ kind = new QuoteKindRespVo();
|
|
|
|
|
+ kind.setKindCode(kindInfoVo.getKindCode());
|
|
|
|
|
+ kind.setKindName(kindInfoVo.getKindName());
|
|
|
|
|
+ int i = ArrayUtil.indexOf(InsuranceTypeCorrespondence.getJinZhangGuiType(), kindInfoVo.getKindCode());
|
|
|
|
|
+ YangGuangAccuracyCalculateResponse.kindList itemKind;
|
|
|
|
|
+ if (isEnergy) {
|
|
|
|
|
+ itemKind = itemKindList.stream().filter(a -> a.getKindCode().equals(InsuranceTypeCorrespondence.getYangGuangConnectInsuranceTypeNewEnergy()[i])).collect(Collectors.toList()).get(0);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ itemKind = itemKindList.stream().filter(a -> a.getKindCode().equals(InsuranceTypeCorrespondence.getYangGuangConnectInsuranceType()[i])).collect(Collectors.toList()).get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ kind.setAmount(Double.parseDouble(itemKind.getAmount()));
|
|
|
|
|
+ kind.setCoveragePremium(Double.parseDouble(itemKind.getActualPremium()));
|
|
|
|
|
+ kind.setUnitAmount(Double.parseDouble(itemKind.getUnitAmount()));
|
|
|
|
|
+ if (!ObjectUtils.isEmpty(kindInfoVo.getDeductibleRate())) {
|
|
|
|
|
+ kind.setDeductibleRate(Double.parseDouble(kindInfoVo.getDeductibleRate()));
|
|
|
|
|
+ }
|
|
|
|
|
+ kindList1.add(kind);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 驾意险
|
|
|
|
|
+ List<YangGuangAccuracyCalculateResponse.PtptNonVehicleProductInformationList> notCarList = yangGuangAccuracyCalculateResponse.getPtptNonVehicleProductInformationList();
|
|
|
|
|
+
|
|
|
|
|
+ if (notCarList != null && !notCarList.isEmpty()) {
|
|
|
|
|
+ List<AccidentResponseVo> accidentResponseVos =
|
|
|
|
|
+ YangGuangAccuracyCalculateResponse.PtptNonVehicleProductInformationList.toAccidentResponseVoList(notCarList,accidentalDrivingVo);
|
|
|
|
|
+ quoteRespVo.setAccident(accidentResponseVos);
|
|
|
|
|
+
|
|
|
|
|
+ //驾意险价格
|
|
|
|
|
+ BigDecimal bigDecimal = YangGuangAccuracyCalculateResponse.PtptNonVehicleProductInformationList.sumPremium(notCarList);
|
|
|
|
|
+ jyPremium = bigDecimal.doubleValue();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ quoteRespVo.setRiskList(riskList1);
|
|
|
|
|
+ quoteRespVo.setKindList(kindList1);
|
|
|
|
|
+ quoteRespVo.setJqPremium(jqPremium);
|
|
|
|
|
+ quoteRespVo.setSyPremium(syPremium);
|
|
|
|
|
+ quoteRespVo.setTaxAmount(sumPayTax);
|
|
|
|
|
+ quoteRespVo.setJyPremium(jyPremium);
|
|
|
|
|
+ quoteRespVo.setCiSumPermium(CalculateUtils.add(jqPremium, sumPayTax));//交强险和车船税合计
|
|
|
|
|
+ quoteRespVo.setSumPermium(CalculateUtils.add(jqPremium, syPremium, sumPayTax, jyPremium));//保费合计
|
|
|
|
|
+ quoteRespVo.setTotalAdjustRate(0);
|
|
|
|
|
+ quoteRespVo.setOrderno(yaQuoteInfoVo.getOrderNo()); //订单号
|
|
|
|
|
+ return quoteRespVo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public HttpResult<QuoteRespVo> responseOrder(YangGuangAccuracyCalculateResponse yangGuangAccuracyCalculateResponse,
|
|
|
|
|
+ QuoteRespVo quoteRespVo,
|
|
|
|
|
+ PtlAgreementAttribution ptlAgreementAttribution,
|
|
|
|
|
+ String orderId,
|
|
|
|
|
+ List<YgQuoteAccidentVo> accidentalDrivingVo) {
|
|
|
|
|
+ //保存订单信息
|
|
|
|
|
+ InsAreaCompany insAreaCompany = new InsAreaCompany(quoteRespVo, ptlAgreementAttribution);
|
|
|
|
|
+ //协议id
|
|
|
|
|
+ insAreaCompany.setOrderno(orderId);
|
|
|
|
|
+ insAreaCompany.setReptxt(JSON.parseObject(JSON.toJSONString(yangGuangAccuracyCalculateResponse)));
|
|
|
|
|
+ insAreaCompany.setOrderstatus(InsOrderStatusEnum.QUOTE_ING.getCode());
|
|
|
|
|
+ insAreaCompany.setInsOrderNo(yangGuangAccuracyCalculateResponse.getInfotransNo());
|
|
|
|
|
+ InsOrders insOrders = insOrdersService.getById(orderId);
|
|
|
|
|
+ //车船税
|
|
|
|
|
+ if (!insOrders.getProductid().equals("034001") && !insOrders.getProductid().equals("034002")) {
|
|
|
|
|
+ YangGuangAccuracyCalculateResponse.cartax cartax= yangGuangAccuracyCalculateResponse.getCartax();
|
|
|
|
|
+ TaxArrears taxArrears = new TaxArrears("往年欠税", Double.parseDouble(yangGuangAccuracyCalculateResponse.getPayBalanceFee()),
|
|
|
|
|
+ Double.parseDouble(yangGuangAccuracyCalculateResponse.getLateFee()));
|
|
|
|
|
+ List<TaxArrears> taxArrearsList = Collections.singletonList(taxArrears);
|
|
|
|
|
+ insAreaCompany.setTaxArrears(JSON.parseArray(JSON.toJSONString(taxArrearsList)));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ List<InsAreaCompanyAccidentalDriving> insAreaCompanyAccidentalDrivings = new ArrayList<>();
|
|
|
|
|
+ if (accidentalDrivingVo != null) {
|
|
|
|
|
+ accidentalDrivingVo.forEach(accidentalDriving -> {
|
|
|
|
|
+ InsAreaCompanyAccidentalDriving insAreaCompanyAccidentalDriving = new InsAreaCompanyAccidentalDriving();
|
|
|
|
|
+ insAreaCompanyAccidentalDriving.setCompanyId(insAreaCompany.getCompanyId());
|
|
|
|
|
+ insAreaCompanyAccidentalDriving.setQuantity(Integer.parseInt(accidentalDriving.getQuantityCasualty()));
|
|
|
|
|
+ insAreaCompanyAccidentalDriving.setRideRiskCode(accidentalDriving.getProductCode());
|
|
|
|
|
+ insAreaCompanyAccidentalDriving.setRideRiskName(accidentalDriving.getProductName());
|
|
|
|
|
+ insAreaCompanyAccidentalDrivings.add(insAreaCompanyAccidentalDriving);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ insAreaCompanyService.insertCompanyAndOrders(insAreaCompany, insAreaCompanyAccidentalDrivings);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ insAreaCompanyService.insertCompanyAndOrders(insAreaCompany, new ArrayList<>());
|
|
|
|
|
+ }
|
|
|
|
|
+ quoteRespVo.setCompanyId(insAreaCompany.getId());
|
|
|
|
|
+ return HttpResult.ok("报价成功", quoteRespVo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String gainCarInsPolicyNew(String url, String fileName, String subOrderId,boolean flag) {
|
|
|
|
|
+ String dir = "carInsPolicyNew/" + subOrderId + "/";
|
|
|
|
|
+ return FileUtil.netUrlToFileNew(url, dir, fileName, uploadFilePath, apiUrl + showFileUrl,flag);
|
|
|
|
|
+ }
|
|
|
|
|
+ private String gainCarInsPolicy(String url, String fileName, String licensePlate) {
|
|
|
|
|
+ String dir = "carInsPolicy/" + licensePlate + "/";
|
|
|
|
|
+ return FileUtil.netUrlToFile(url, dir, fileName, uploadFilePath, apiUrl + showFileUrl);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|