|
|
@@ -29,6 +29,7 @@ import com.ydtech.modules.ins.model.dto.CarInsPolicyDto;
|
|
|
import com.ydtech.modules.ins.model.vo.CarInfoVo;
|
|
|
import com.ydtech.modules.ins.model.vo.CustomerInfoVo;
|
|
|
import com.ydtech.modules.ins.model.vo.QuoteRespVo;
|
|
|
+import com.ydtech.modules.ins.model.vo.RiskInfoVo;
|
|
|
import com.ydtech.modules.ins.model.ya.CarModel_Req;
|
|
|
import com.ydtech.modules.ins.model.yc.CallBackRequest;
|
|
|
import com.ydtech.modules.ins.model.yc.YcBuildData;
|
|
|
@@ -65,8 +66,10 @@ import com.ydtech.modules.order.entity.InsAreaCompanyExternalPolicy;
|
|
|
import com.ydtech.modules.order.entity.InsOrders;
|
|
|
import com.ydtech.modules.order.entity.api.yongcheng.constants.MessageStatusCode;
|
|
|
import com.ydtech.modules.order.entity.api.yongcheng.request.AccidentUnderwritingRequest;
|
|
|
+import com.ydtech.modules.order.entity.api.yongcheng.request.PriceDiscountRatioRequest;
|
|
|
import com.ydtech.modules.order.entity.api.yongcheng.request.ProposalPolicyReturnRequest;
|
|
|
import com.ydtech.modules.order.entity.api.yongcheng.response.AccidentUnderwritingResponse;
|
|
|
+import com.ydtech.modules.order.entity.api.yongcheng.response.PriceDiscountRatioResponse;
|
|
|
import com.ydtech.modules.order.entity.crawler.request.RecognitionRequest;
|
|
|
import com.ydtech.modules.order.entity.crawler.response.RecognitionResponse;
|
|
|
import com.ydtech.modules.order.entity.dto.DrivingInsuranceDto;
|
|
|
@@ -98,6 +101,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
@@ -261,7 +266,7 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
|
|
|
* @param quoteVo
|
|
|
* @return
|
|
|
*/
|
|
|
- private Ruote builderParams(BaseQuoteVo<AccidentalDrivingVo> quoteVo, BaseQuoteInfoVo yaQuoteInfoVo, CoreModelsVo coreModelsVo) {
|
|
|
+ private Ruote builderParams(BaseQuoteVo<AccidentalDrivingVo> quoteVo, BaseQuoteInfoVo yaQuoteInfoVo, CoreModelsVo coreModelsVo,String negotiatedPrice) {
|
|
|
// 获取协议配置信息
|
|
|
YcConfigureParameters ycConfigureParameters = gainYcConfigParams(quoteVo.getAgreementId());
|
|
|
CarInfoVo carInfo = yaQuoteInfoVo.getCarInfo();
|
|
|
@@ -275,7 +280,7 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
|
|
|
String cQryCdeSY = redisTemplate.opsForValue().get(REDIS_YONGCHENG_QUERY_CODE_SY + yaQuoteInfoVo.getUserId() + carInfo.getVinNo() + carInfo.getLicenseNo());
|
|
|
|
|
|
//组装参数
|
|
|
- Ruote m = Ruote.buildQuoteParam(yaQuoteInfoVo, ycConfigureParameters, adVo, cQryCdeJQ, cQryCdeSY);
|
|
|
+ Ruote m = Ruote.buildQuoteParam(yaQuoteInfoVo, ycConfigureParameters, adVo, cQryCdeJQ, cQryCdeSY,negotiatedPrice);
|
|
|
//企业车不构建地区
|
|
|
String property = carInfo.getProperty();
|
|
|
if (!"2".equals(property)) {
|
|
|
@@ -470,7 +475,7 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
|
|
|
* 2 报价-
|
|
|
*/
|
|
|
@Override
|
|
|
- public HttpResult quoteApi(BaseQuoteVo<AccidentalDrivingVo> quoteVo) throws JsonProcessingException {
|
|
|
+ public HttpResult quoteApi(BaseQuoteVo<AccidentalDrivingVo> quoteVo) throws JsonProcessingException, ParseException {
|
|
|
Integer maxQuoteNum = quoteVo.getMaxQuoteNum();
|
|
|
|
|
|
List<String> requestInfoList = new ArrayList<>();
|
|
|
@@ -483,10 +488,48 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
|
|
|
//查询订单信息
|
|
|
InsOrders order = insOrdersService.getById(yaQuoteInfoVo.getOrderNo());
|
|
|
|
|
|
- //build参数
|
|
|
- Ruote m = this.builderParams(quoteVo, yaQuoteInfoVo, coreModelsVo);
|
|
|
-
|
|
|
List<SysQuoteRecord> sysQuoteRecords = new ArrayList<>();
|
|
|
+
|
|
|
+ BigDecimal negotiatedPrice = null; // 协商价
|
|
|
+ //接口调用前提条件:
|
|
|
+ //旧车,0326/0364, 10座以下非营业个人客车业务”才调该接口查询协商价浮动比例
|
|
|
+ //协商价 = 折旧价*返回的协商价浮动比例
|
|
|
+ if (yaQuoteInfoVo.getCarInfo().getVehicleUse().equals("05") && Integer.parseInt(yaQuoteInfoVo.getCarInfo().getSeatCount()) <= 10 ) {
|
|
|
+ YcConfigureParameters ycConfigureParameters = gainYcConfigParams(quoteVo.getAgreementId());
|
|
|
+ List<RiskInfoVo> riskList = yaQuoteInfoVo.getRiskList();
|
|
|
+ //交强
|
|
|
+ RiskInfoVo ciRiskInfo = riskList.stream().filter(x -> x.getRiskCode().equals(InsuranceRisk.TRAFFIC.getCode())).findFirst().orElse(null);
|
|
|
+ //商业
|
|
|
+ RiskInfoVo biRiskInfo = riskList.stream().filter(x -> x.getRiskCode().equals(InsuranceRisk.BUSINESS.getCode())).findFirst().orElse(null);
|
|
|
+ String startDate; // 起保日期
|
|
|
+ if (biRiskInfo != null) {
|
|
|
+ startDate = biRiskInfo.getStartDate();
|
|
|
+ } else {
|
|
|
+ startDate = ciRiskInfo.getStartDate();
|
|
|
+ }
|
|
|
+ BigDecimal vehiclePrice = new BigDecimal(yaQuoteInfoVo.getCarInfo().getPurchasePrice()); // 新车购置价
|
|
|
+ String registerDate = yaQuoteInfoVo.getCarInfo().getRegisterDate(); // 初登日期
|
|
|
+ //转换日期格式
|
|
|
+ SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date startDateAsDate = inputFormat.parse(startDate);
|
|
|
+ String formattedStartDate = outputFormat.format(startDateAsDate);
|
|
|
+
|
|
|
+ BigDecimal depreciationPrice = new BigDecimal(YcBuildData.getDefValue(vehiclePrice, registerDate, formattedStartDate)); // 折旧价
|
|
|
+ PriceDiscountRatioRequest priceDiscountRatioRequest = new PriceDiscountRatioRequest(ycConfigureParameters, yaQuoteInfoVo.getCarInfo(), quoteVo.getKinds(), startDate);
|
|
|
+ PriceDiscountRatioResponse priceDiscountRatioResponse = yongchengRequestApiComponents.priceDiscount(priceDiscountRatioRequest);
|
|
|
+ if (priceDiscountRatioResponse.getCode().equals("E0000")) {
|
|
|
+ if (priceDiscountRatioResponse.getVal() != null) {
|
|
|
+ // 协商价 = 折旧价 * 返回的协商价浮动比例
|
|
|
+ negotiatedPrice = depreciationPrice.multiply(new BigDecimal(priceDiscountRatioResponse.getVal())) ;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ negotiatedPrice = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //build参数
|
|
|
+ Ruote m = this.builderParams(quoteVo, yaQuoteInfoVo, coreModelsVo, negotiatedPrice.toString());
|
|
|
//递归报价
|
|
|
RuoteResponse rr = this.getResponse(m, yaQuoteInfoVo.getCarInfo().getVinNo(), requestInfoList, yaQuoteInfoVo,quoteVo.getCompanyId(),maxQuoteNum,sysQuoteRecords);
|
|
|
|