|
|
@@ -12,7 +12,6 @@ import com.jzg.commons.exception.SystemException;
|
|
|
import com.jzg.quotation.commons.component.RequestComponent;
|
|
|
import com.jzg.quotation.commons.constant.CacheConstant;
|
|
|
import com.jzg.quotation.commons.service.ExteriorUtilsRequest;
|
|
|
-import com.jzg.quotation.commons.utils.DateUtil;
|
|
|
import com.jzg.quotation.commons.utils.RequestObjectConversion;
|
|
|
import com.jzg.quotation.hengbang.crawler.constant.RequestConstant;
|
|
|
import com.jzg.quotation.hengbang.crawler.constant.enums.RequestUrl;
|
|
|
@@ -329,35 +328,23 @@ public class HengBangCrawlerRequestComponent {
|
|
|
if (status == 500) {
|
|
|
JSONObject resObj = JSONObject.parseObject(responseBody);
|
|
|
String detail = resObj.getString("detail");
|
|
|
- if (StrUtil.isNotBlank(detail) && detail.contains("重复投保")) {
|
|
|
- String time = extractDuplicateEndTime(detail);
|
|
|
- if (time != null) {
|
|
|
- String utcTime = DateUtil.toUtcDateTime(time);
|
|
|
- // 保司返回的终保时间直接作为起保时间会仍然重叠,统一调整为次日北京时间0点(已0点则不变)
|
|
|
- utcTime = DateUtil.getNextDayMidnightUtc(utcTime);
|
|
|
- // 根据重复投保类型分别设置起保时间:交强险只改 begintimeCi,商业险只改 begintimeBi
|
|
|
- // 注意:商业险错误信息不含"商业险平台返回",故通过"交强险平台返回"反推
|
|
|
- if (detail.contains("交强险平台返回")) {
|
|
|
- calculationRequest.setBegintimeCi(utcTime);
|
|
|
- } else {
|
|
|
- calculationRequest.setBegintimeBi(utcTime);
|
|
|
- }
|
|
|
- // 驾意险不支持即时起保:北京时间0点则直接复用,非0点则自动设为下一日0点
|
|
|
- calculationRequest.setBegintimeAccident(DateUtil.isBeijingMidnight(utcTime)
|
|
|
- ? utcTime
|
|
|
- : DateUtil.getNextDayMidnightUtc(utcTime));
|
|
|
- return getCalculationResult(calculationRequest, headers);
|
|
|
- } else {
|
|
|
- return StrUtil.isNotBlank(detail) ? detail : responseBody;
|
|
|
- }
|
|
|
- }
|
|
|
- return StrUtil.isNotBlank(detail) ? detail : responseBody;
|
|
|
+ // HTTP 500 也可能是正常的重复投保业务提示。这里只转换响应格式,
|
|
|
+ // 重试和起保时间调整统一由上层服务处理,避免首次报价在组件内递归重试后丢失提示。
|
|
|
+ return JSON.toJSONString(new JSONObject()
|
|
|
+ .fluentPut("status", status)
|
|
|
+ .fluentPut("message", StrUtil.isNotBlank(detail) ? detail : responseBody)
|
|
|
+ .fluentPut("responseBody", resObj.get("responseBody")));
|
|
|
} else if (status == 400) {
|
|
|
JSONObject resObj = JSONObject.parseObject(responseBody);
|
|
|
String title = resObj.getString("title");
|
|
|
- return StrUtil.isNotBlank(title) ? title : responseBody;
|
|
|
+ return JSON.toJSONString(new JSONObject()
|
|
|
+ .fluentPut("status", status)
|
|
|
+ .fluentPut("message", StrUtil.isNotBlank(title) ? title : responseBody));
|
|
|
}
|
|
|
log.error("恒邦calculation接口返回非2xx: {}, 响应: {}", status, responseBody);
|
|
|
+ return JSON.toJSONString(new JSONObject()
|
|
|
+ .fluentPut("status", status)
|
|
|
+ .fluentPut("message", responseBody));
|
|
|
}
|
|
|
|
|
|
// Jackson解析响应
|