|
@@ -321,104 +321,106 @@ public class ChengTaiOrderApiServiceImpl implements ChengTaiOrderApiService {
|
|
|
*/
|
|
*/
|
|
|
private PremiumCalculationResponse getResponse(PremiumCalculationRequest premiumCalculationRequest, BaseQuoteInfoVo quoteInfoVo, Integer maxQuoteNum, List<SysQuoteRecord> sysQuoteRecords
|
|
private PremiumCalculationResponse getResponse(PremiumCalculationRequest premiumCalculationRequest, BaseQuoteInfoVo quoteInfoVo, Integer maxQuoteNum, List<SysQuoteRecord> sysQuoteRecords
|
|
|
, BigDecimal carActualValue, ChengTaiConfigureParameters parameters, CarModelQueryResponse.vehicle vehicle, BaseQuoteVo<InsDrivingIntentionInsurance> quoteVo) throws Exception {
|
|
, BigDecimal carActualValue, ChengTaiConfigureParameters parameters, CarModelQueryResponse.vehicle vehicle, BaseQuoteVo<InsDrivingIntentionInsurance> quoteVo) throws Exception {
|
|
|
-
|
|
|
|
|
- PremiumCalculationResponse premiumCalculationResponse = chengTaiRequestApiComponent.premiumCalculation(premiumCalculationRequest);
|
|
|
|
|
- maxQuoteNum--;
|
|
|
|
|
- if (!premiumCalculationResponse.getHead().getErrorMessage().equals("成功")) {
|
|
|
|
|
- /**
|
|
|
|
|
- * 重复投保
|
|
|
|
|
- */
|
|
|
|
|
- // 获取新起保时间 终保时间
|
|
|
|
|
- //判断出现两次起保日期
|
|
|
|
|
- boolean hasTwoStartDates = premiumCalculationResponse.getHead().getErrorMessage() != null
|
|
|
|
|
- && premiumCalculationResponse.getHead().getErrorMessage().indexOf("起保日期") != -1 // 第一次出现
|
|
|
|
|
- && premiumCalculationResponse.getHead().getErrorMessage().indexOf("起保日期",
|
|
|
|
|
- premiumCalculationResponse.getHead().getErrorMessage().indexOf("起保日期") + 1) != -1; // 第二次出现
|
|
|
|
|
-
|
|
|
|
|
- final String startDate = extractEndDate(premiumCalculationResponse);
|
|
|
|
|
- String endDate;
|
|
|
|
|
- if (startDate != null) {
|
|
|
|
|
-
|
|
|
|
|
- //如果出现起保日期两次 就是 交强商业都重复投保了
|
|
|
|
|
- if(hasTwoStartDates)
|
|
|
|
|
- {
|
|
|
|
|
- String jqEndDate,syEndDate = "";
|
|
|
|
|
- List<String> timeList = multipleStartDate(premiumCalculationResponse);
|
|
|
|
|
- for(int i=0;i<timeList.size();i++){
|
|
|
|
|
- timeList.set(i,addOneYear(timeList.get(i)));
|
|
|
|
|
- }
|
|
|
|
|
- if(timeList.size() < 2){
|
|
|
|
|
- throw new SystemException("处理重复投保时间异常");
|
|
|
|
|
- }
|
|
|
|
|
- if (timeList.get(0).endsWith("00:00:00")) {
|
|
|
|
|
- jqEndDate = TimeProcessing.minusOneSecondAfterYear(startDate);
|
|
|
|
|
- } else {
|
|
|
|
|
- jqEndDate = TimeProcessing.plusOneYearToString(startDate);
|
|
|
|
|
- }
|
|
|
|
|
- if (timeList.get(1).endsWith("00:00:00")) {
|
|
|
|
|
- syEndDate = TimeProcessing.minusOneSecondAfterYear(startDate);
|
|
|
|
|
- } else {
|
|
|
|
|
- syEndDate = TimeProcessing.plusOneYearToString(startDate);
|
|
|
|
|
- }
|
|
|
|
|
- String jqFinalEndDate = jqEndDate;
|
|
|
|
|
- String syFinalEndDate = syEndDate;
|
|
|
|
|
- quoteInfoVo.getRiskList().forEach(riskInfoVo -> {
|
|
|
|
|
- // 判断险种代码是 0507
|
|
|
|
|
- if ("0507".equals(riskInfoVo.getRiskCode())) {
|
|
|
|
|
- // 设置起保日期(第一次)
|
|
|
|
|
- riskInfoVo.setStartDate(timeList.get(0));
|
|
|
|
|
- // 设置终保日期
|
|
|
|
|
- riskInfoVo.setEndDate(jqFinalEndDate);
|
|
|
|
|
|
|
+ int index = 0;
|
|
|
|
|
+ PremiumCalculationResponse premiumCalculationResponse = new PremiumCalculationResponse();
|
|
|
|
|
+ while(true) {
|
|
|
|
|
+ if(index >=3){
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ premiumCalculationResponse = chengTaiRequestApiComponent.premiumCalculation(premiumCalculationRequest);
|
|
|
|
|
+ index++;
|
|
|
|
|
+ maxQuoteNum--;
|
|
|
|
|
+ if (!premiumCalculationResponse.getHead().getErrorMessage().equals("成功")) {
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 重复投保
|
|
|
|
|
+ */
|
|
|
|
|
+ // 获取新起保时间 终保时间
|
|
|
|
|
+ //判断出现两次起保日期
|
|
|
|
|
+ boolean hasTwoStartDates = premiumCalculationResponse.getHead().getErrorMessage() != null
|
|
|
|
|
+ && premiumCalculationResponse.getHead().getErrorMessage().indexOf("起保日期") != -1 // 第一次出现
|
|
|
|
|
+ && premiumCalculationResponse.getHead().getErrorMessage().indexOf("起保日期",
|
|
|
|
|
+ premiumCalculationResponse.getHead().getErrorMessage().indexOf("起保日期") + 1) != -1; // 第二次出现
|
|
|
|
|
+
|
|
|
|
|
+ final String startDate = extractEndDate(premiumCalculationResponse);
|
|
|
|
|
+ String endDate;
|
|
|
|
|
+ if (startDate != null) {
|
|
|
|
|
+
|
|
|
|
|
+ //如果出现起保日期两次 就是 交强商业都重复投保了
|
|
|
|
|
+ if (hasTwoStartDates) {
|
|
|
|
|
+ String jqEndDate, syEndDate = "";
|
|
|
|
|
+ List<String> timeList = multipleStartDate(premiumCalculationResponse);
|
|
|
|
|
+ for (int i = 0; i < timeList.size(); i++) {
|
|
|
|
|
+ timeList.set(i, addOneYear(timeList.get(i)));
|
|
|
}
|
|
}
|
|
|
- if("0510".equals(riskInfoVo.getRiskCode())){
|
|
|
|
|
- riskInfoVo.setStartDate(timeList.get(1));
|
|
|
|
|
- riskInfoVo.setEndDate(syFinalEndDate);
|
|
|
|
|
|
|
+ if (timeList.size() < 2) {
|
|
|
|
|
+ throw new SystemException("处理重复投保时间异常");
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
- }else {
|
|
|
|
|
- if (startDate.endsWith("00:00:00")) {
|
|
|
|
|
- endDate = TimeProcessing.minusOneSecondAfterYear(startDate);
|
|
|
|
|
|
|
+ if (timeList.get(0).endsWith("00:00:00")) {
|
|
|
|
|
+ jqEndDate = TimeProcessing.minusOneSecondAfterYear(startDate);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ jqEndDate = TimeProcessing.plusOneYearToString(startDate);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (timeList.get(1).endsWith("00:00:00")) {
|
|
|
|
|
+ syEndDate = TimeProcessing.minusOneSecondAfterYear(startDate);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ syEndDate = TimeProcessing.plusOneYearToString(startDate);
|
|
|
|
|
+ }
|
|
|
|
|
+ String jqFinalEndDate = jqEndDate;
|
|
|
|
|
+ String syFinalEndDate = syEndDate;
|
|
|
|
|
+ quoteInfoVo.getRiskList().forEach(riskInfoVo -> {
|
|
|
|
|
+ // 判断险种代码是 0507
|
|
|
|
|
+ if ("0507".equals(riskInfoVo.getRiskCode())) {
|
|
|
|
|
+ // 设置起保日期(第一次)
|
|
|
|
|
+ riskInfoVo.setStartDate(timeList.get(0));
|
|
|
|
|
+ // 设置终保日期
|
|
|
|
|
+ riskInfoVo.setEndDate(jqFinalEndDate);
|
|
|
|
|
+ }
|
|
|
|
|
+ if ("0510".equals(riskInfoVo.getRiskCode())) {
|
|
|
|
|
+ riskInfoVo.setStartDate(timeList.get(1));
|
|
|
|
|
+ riskInfoVo.setEndDate(syFinalEndDate);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
} else {
|
|
} else {
|
|
|
- endDate = TimeProcessing.plusOneYearToString(startDate);
|
|
|
|
|
- }
|
|
|
|
|
- final String formatStartDate = startDate;
|
|
|
|
|
- final String formatEndDate = endDate;
|
|
|
|
|
- PremiumCalculationResponse finalPremiumCalculationResponse = premiumCalculationResponse;
|
|
|
|
|
- quoteInfoVo.getRiskList().forEach(riskInfoVo -> {
|
|
|
|
|
- String start, end = "";
|
|
|
|
|
-
|
|
|
|
|
- if (riskInfoVo.getRiskCode().equals("0507") && finalPremiumCalculationResponse.getHead().getErrorMessage().contains("交强")) {
|
|
|
|
|
- riskInfoVo.setStartDate(formatStartDate);
|
|
|
|
|
- riskInfoVo.setEndDate(formatEndDate);
|
|
|
|
|
|
|
+ if (startDate.endsWith("00:00:00")) {
|
|
|
|
|
+ endDate = TimeProcessing.minusOneSecondAfterYear(startDate);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ endDate = TimeProcessing.plusOneYearToString(startDate);
|
|
|
}
|
|
}
|
|
|
|
|
+ final String formatStartDate = startDate;
|
|
|
|
|
+ final String formatEndDate = endDate;
|
|
|
|
|
+ PremiumCalculationResponse finalPremiumCalculationResponse = premiumCalculationResponse;
|
|
|
|
|
+ quoteInfoVo.getRiskList().forEach(riskInfoVo -> {
|
|
|
|
|
+ String start, end = "";
|
|
|
|
|
+
|
|
|
|
|
+ if (riskInfoVo.getRiskCode().equals("0507") && finalPremiumCalculationResponse.getHead().getErrorMessage().contains("交强")) {
|
|
|
|
|
+ riskInfoVo.setStartDate(formatStartDate);
|
|
|
|
|
+ riskInfoVo.setEndDate(formatEndDate);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 处理商业险的即时起保
|
|
|
|
|
- if (riskInfoVo.getRiskCode().equals("0510")) {
|
|
|
|
|
- if (!formatStartDate.endsWith("00:00:00")) {
|
|
|
|
|
- start = TimeProcessing.tomorrowDateTime(formatStartDate);
|
|
|
|
|
- end = TimeProcessing.tomorrowDateTime(formatEndDate);
|
|
|
|
|
- riskInfoVo.setStartDate(start);
|
|
|
|
|
- riskInfoVo.setEndDate(end);
|
|
|
|
|
|
|
+ // 处理商业险的即时起保
|
|
|
|
|
+ if (riskInfoVo.getRiskCode().equals("0510") && finalPremiumCalculationResponse.getHead().getErrorMessage().contains("商业险")) {
|
|
|
|
|
+ riskInfoVo.setStartDate(formatStartDate);
|
|
|
|
|
+ riskInfoVo.setEndDate(formatEndDate);
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- premiumCalculationRequest = new PremiumCalculationRequest(quoteInfoVo, carActualValue, parameters, vehicle, quoteVo, quoteInfoVo.getRiskList(), null);
|
|
|
|
|
- premiumCalculationResponse = chengTaiRequestApiComponent.premiumCalculation(premiumCalculationRequest);
|
|
|
|
|
- maxQuoteNum--;
|
|
|
|
|
- SysQuoteRecord sysQuoteRecord = new SysQuoteRecord(quoteInfoVo.getUserid(), quoteVo.getCompanyId(), quoteInfoVo.getCarInfo().getLicenseNo(),
|
|
|
|
|
- QuoteNumberConstant.QuoteAction.DATE_DEAL.getCode().toString(), QuoteNumberConstant.QuoteResult.FAIL.getCode().toString());
|
|
|
|
|
- sysQuoteRecords.add(sysQuoteRecord);
|
|
|
|
|
- if (maxQuoteNum <= 0) {
|
|
|
|
|
- sysQuoteRecordMapper.insertBatch(sysQuoteRecords);
|
|
|
|
|
- //刷新redis中的报价次数
|
|
|
|
|
- sysQuoteRedisService.refreshQuoteNum(quoteVo.getCompanyId(), quoteInfoVo.getUserid(), sysQuoteRecords);
|
|
|
|
|
- throw new SystemException("报价次数限制");
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ premiumCalculationRequest = new PremiumCalculationRequest(quoteInfoVo, carActualValue, parameters, vehicle, quoteVo, quoteInfoVo.getRiskList(), null);
|
|
|
|
|
+
|
|
|
|
|
+ maxQuoteNum--;
|
|
|
|
|
+ SysQuoteRecord sysQuoteRecord = new SysQuoteRecord(quoteInfoVo.getUserid(), quoteVo.getCompanyId(), quoteInfoVo.getCarInfo().getLicenseNo(),
|
|
|
|
|
+ QuoteNumberConstant.QuoteAction.DATE_DEAL.getCode().toString(), QuoteNumberConstant.QuoteResult.FAIL.getCode().toString());
|
|
|
|
|
+ sysQuoteRecords.add(sysQuoteRecord);
|
|
|
|
|
+ if (maxQuoteNum <= 0) {
|
|
|
|
|
+ sysQuoteRecordMapper.insertBatch(sysQuoteRecords);
|
|
|
|
|
+ //刷新redis中的报价次数
|
|
|
|
|
+ sysQuoteRedisService.refreshQuoteNum(quoteVo.getCompanyId(), quoteInfoVo.getUserid(), sysQuoteRecords);
|
|
|
|
|
+ throw new SystemException("报价次数限制");
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (premiumCalculationResponse.getHead().getErrorMessage().contains("重复投保")) {
|
|
|
|
|
+ throw new SystemException(premiumCalculationResponse.getHead().getErrorMessage());
|
|
|
}
|
|
}
|
|
|
- } else if (premiumCalculationResponse.getHead().getErrorMessage().contains("重复投保")) {
|
|
|
|
|
- throw new SystemException(premiumCalculationResponse.getHead().getErrorMessage());
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
// 转保车处理
|
|
// 转保车处理
|
|
|
String ciQuestion = premiumCalculationResponse.getCompRisk() != null
|
|
String ciQuestion = premiumCalculationResponse.getCompRisk() != null
|