|
|
@@ -12,6 +12,7 @@ import com.ydtech.modules.ins.model.vo.*;
|
|
|
import com.ydtech.modules.order.components.InsCrawlerOrderComponents;
|
|
|
import com.ydtech.modules.order.components.InsImagesUploadCacheComponents;
|
|
|
import com.ydtech.modules.order.components.huatai.HuaTaiUploadImageComponents;
|
|
|
+import com.ydtech.modules.order.constants.OrderCacheConstant;
|
|
|
import com.ydtech.modules.order.constants.QuoteNumberConstant;
|
|
|
import com.ydtech.modules.order.constants.UnderwritingStatus;
|
|
|
import com.ydtech.modules.order.dao.SysQuoteRecordMapper;
|
|
|
@@ -42,6 +43,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
@@ -49,14 +51,14 @@ import org.springframework.util.ObjectUtils;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static com.ydtech.modules.order.constants.OrderCacheConstant.GR_SPECIAL_AGREEMENT_TIME;
|
|
|
+
|
|
|
|
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
|
@@ -79,6 +81,9 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
|
|
|
private final InsDrivingIntentionInsuranceService insDrivingIntentionInsuranceService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private StringRedisTemplate redisTemplate;
|
|
|
+
|
|
|
@Value("${upload.file.path}")
|
|
|
private String uploadFilePath;
|
|
|
|
|
|
@@ -161,33 +166,34 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
if (response.getCode() != 200) {
|
|
|
|
|
|
//判断错误订单是否是重复投保
|
|
|
- InsOrderStatusEnum insOrderStatusEnum = InsOrderStatusEnum.QUOTE_FAILED;
|
|
|
- if (response.getMessage()
|
|
|
- .contains("重复投保")) {
|
|
|
- insOrderStatusEnum = InsOrderStatusEnum.REPEAT_INSURE;
|
|
|
- }
|
|
|
- String subOrderNo = insOrdersService.responseFailedOrder(t, quoteInfoVo, ptlAgreementAttribution, order, response.getMessage(), insOrderStatusEnum);
|
|
|
- if (!Objects.isNull(response.getOther()
|
|
|
- .getMaxQuoteNum())) {
|
|
|
- int quoteNum = maxQuoteNum - Integer.parseInt(response.getOther()
|
|
|
- .getMaxQuoteNum());
|
|
|
- for (int i = 0; i < quoteNum; i++) {
|
|
|
- SysQuoteRecord sysQuoteRecord = new SysQuoteRecord(quoteInfoVo.getUserid(), t.getCompanyId(), quoteInfoVo.getCarInfo()
|
|
|
- .getLicenseNo(),
|
|
|
- QuoteNumberConstant.QuoteAction.QUOTE_FAILED.getCode()
|
|
|
- .toString(), QuoteNumberConstant.QuoteResult.FAIL.getCode()
|
|
|
- .toString());
|
|
|
- sysQuoteRecords.add(sysQuoteRecord);
|
|
|
- }
|
|
|
- sysQuoteRecords.forEach(item -> {
|
|
|
- item.setSubOrderNo(subOrderNo);
|
|
|
- });
|
|
|
- if (sysQuoteRecords.size() > 0) {
|
|
|
- sysQuoteRecordMapper.insertBatch(sysQuoteRecords);
|
|
|
- //刷新redis中的报价次数
|
|
|
- sysQuoteRedisService.refreshQuoteNum(t.getCompanyId(), quoteInfoVo.getUserid(), sysQuoteRecords);
|
|
|
- }
|
|
|
- }
|
|
|
+// InsOrderStatusEnum insOrderStatusEnum = InsOrderStatusEnum.QUOTE_FAILED;
|
|
|
+// if (response.getMessage()
|
|
|
+// .contains("重复投保")) {
|
|
|
+// insOrderStatusEnum = InsOrderStatusEnum.REPEAT_INSURE;
|
|
|
+// }
|
|
|
+// String subOrderNo = insOrdersService.responseFailedOrder(t, quoteInfoVo, ptlAgreementAttribution, order, response.getMessage(), insOrderStatusEnum);
|
|
|
+// if (!Objects.isNull(response.getOther()
|
|
|
+// .getMaxQuoteNum())) {
|
|
|
+// int quoteNum = maxQuoteNum - Integer.parseInt(response.getOther()
|
|
|
+// .getMaxQuoteNum());
|
|
|
+// for (int i = 0; i < quoteNum; i++) {
|
|
|
+// SysQuoteRecord sysQuoteRecord = new SysQuoteRecord(quoteInfoVo.getUserid(), t.getCompanyId(), quoteInfoVo.getCarInfo()
|
|
|
+// .getLicenseNo(),
|
|
|
+// QuoteNumberConstant.QuoteAction.QUOTE_FAILED.getCode()
|
|
|
+// .toString(), QuoteNumberConstant.QuoteResult.FAIL.getCode()
|
|
|
+// .toString());
|
|
|
+// sysQuoteRecords.add(sysQuoteRecord);
|
|
|
+// }
|
|
|
+// sysQuoteRecords.forEach(item -> {
|
|
|
+// item.setSubOrderNo(subOrderNo);
|
|
|
+// });
|
|
|
+// if (sysQuoteRecords.size() > 0) {
|
|
|
+// sysQuoteRecordMapper.insertBatch(sysQuoteRecords);
|
|
|
+// //刷新redis中的报价次数
|
|
|
+// sysQuoteRedisService.refreshQuoteNum(t.getCompanyId(), quoteInfoVo.getUserid(), sysQuoteRecords);
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
throw new SystemException(response.getMessage());
|
|
|
}
|
|
|
|
|
|
@@ -265,6 +271,9 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
//泰康
|
|
|
return HttpResult.ok("上传成功");
|
|
|
}
|
|
|
+
|
|
|
+ // 账号信息
|
|
|
+ PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
|
|
|
// 请求地址
|
|
|
String apiUrl = ptlCrawlerApiService.getApiUrl(insAreaCompany.getAgreementId(), PtlCrawlerApiType.API_3);
|
|
|
// 获取缓存中的影像信息
|
|
|
@@ -276,7 +285,7 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
}
|
|
|
|
|
|
CrawlerImageRequest crawlerImageRequest = new CrawlerImageRequest(insAreaCompany.getInsOrderNo(),
|
|
|
- CrawlerImageRequest.toB64phoListDTO(insTaskImagesBase64s));
|
|
|
+ CrawlerImageRequest.toB64phoListDTO(insTaskImagesBase64s),ptlAgreementAttribution.getUsername());
|
|
|
// 发送请求
|
|
|
CrawlerBaseResponse response = insCrawlerOrderComponents.request(apiUrl, insAreaCompany.getCompanyId(),
|
|
|
PtlCrawlerApiType.API_3.getDesc(), crawlerImageRequest, CrawlerBaseResponse.class);
|
|
|
@@ -293,10 +302,12 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
@Override
|
|
|
public HttpResult<Object> audit(String subOrderNo) {
|
|
|
InsAreaCompany insAreaCompany = insAreaCompanyService.getById(subOrderNo);
|
|
|
+ // 账号信息
|
|
|
+ PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
|
|
|
// 请求地址
|
|
|
String apiUrl = ptlCrawlerApiService.getApiUrl(insAreaCompany.getAgreementId(), PtlCrawlerApiType.API_4);
|
|
|
//组装参数
|
|
|
- CrawlerBaseRequest crawlerBaseRequest = new CrawlerBaseRequest(insAreaCompany.getInsOrderNo());
|
|
|
+ CrawlerBaseRequest crawlerBaseRequest = new CrawlerBaseRequest(insAreaCompany.getInsOrderNo(),ptlAgreementAttribution.getUsername());
|
|
|
CrawlerAuditResponse crawlerAuditResponse = insCrawlerOrderComponents.request(apiUrl, insAreaCompany.getCompanyId(),
|
|
|
PtlCrawlerApiType.API_4.getDesc(), crawlerBaseRequest, CrawlerAuditResponse.class);
|
|
|
|
|
|
@@ -335,7 +346,9 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
// 请求地址
|
|
|
String apiUrl = ptlCrawlerApiService.getApiUrl(insAreaCompany.getAgreementId(), PtlCrawlerApiType.API_5);
|
|
|
//组装参数
|
|
|
- CrawlerBaseRequest crawlerBaseRequest = new CrawlerBaseRequest(insAreaCompany.getInsOrderNo());
|
|
|
+ // 账号信息
|
|
|
+ PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
|
|
|
+ CrawlerBaseRequest crawlerBaseRequest = new CrawlerBaseRequest(insAreaCompany.getInsOrderNo(),ptlAgreementAttribution.getUsername());
|
|
|
CrawlerVerifyPaymentResponse crawlerAuditResponse = insCrawlerOrderComponents.request(apiUrl, insAreaCompany.getCompanyId(),
|
|
|
PtlCrawlerApiType.API_5.getDesc(), crawlerBaseRequest, CrawlerVerifyPaymentResponse.class);
|
|
|
|
|
|
@@ -368,8 +381,10 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
|
|
|
// 请求地址
|
|
|
String apiUrl = ptlCrawlerApiService.getApiUrl(insAreaCompany.getAgreementId(), PtlCrawlerApiType.API_6);
|
|
|
+ // 账号信息
|
|
|
+ PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
|
|
|
//组装参数
|
|
|
- CrawlerBaseRequest crawlerBaseRequest = new CrawlerBaseRequest(insAreaCompany.getInsOrderNo());
|
|
|
+ CrawlerBaseRequest crawlerBaseRequest = new CrawlerBaseRequest(insAreaCompany.getInsOrderNo(),ptlAgreementAttribution.getUsername());
|
|
|
CrawlerPolicyPrintResponse response = insCrawlerOrderComponents.request(apiUrl, insAreaCompany.getCompanyId(),
|
|
|
PtlCrawlerApiType.API_6.getDesc(), crawlerBaseRequest, CrawlerPolicyPrintResponse.class);
|
|
|
|
|
|
@@ -625,8 +640,10 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
InsAreaCompany insAreaCompany = insAreaCompanyService.getById(subOrderNo);
|
|
|
String agreementId = insAreaCompany.getAgreementId();
|
|
|
String apiUrl = ptlCrawlerApiService.getApiUrl(agreementId, PtlCrawlerApiType.API_8);
|
|
|
+ // 账号信息
|
|
|
+ PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
|
|
|
//组装参数
|
|
|
- CrawlerBaseRequest crawlerBaseRequest = new CrawlerBaseRequest(insAreaCompany.getInsOrderNo());
|
|
|
+ CrawlerBaseRequest crawlerBaseRequest = new CrawlerBaseRequest(insAreaCompany.getInsOrderNo(),ptlAgreementAttribution.getUsername());
|
|
|
|
|
|
CrawlerAuditResponse crawlerAuditResponse = insCrawlerOrderComponents.request(apiUrl, insAreaCompany.getCompanyId(),
|
|
|
PtlCrawlerApiType.API_8.getDesc(), crawlerBaseRequest, CrawlerAuditResponse.class);
|
|
|
@@ -661,8 +678,10 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
InsAreaCompany insAreaCompany = insAreaCompanyService.getById(insAreaCompanyId);
|
|
|
// 请求地址
|
|
|
String apiUrl = ptlCrawlerApiService.getApiUrl(insAreaCompany.getAgreementId(), PtlCrawlerApiType.API_5);
|
|
|
+ // 账号信息
|
|
|
+ PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
|
|
|
//组装参数
|
|
|
- CrawlerBaseRequest crawlerBaseRequest = new CrawlerBaseRequest(insAreaCompany.getInsOrderNo());
|
|
|
+ CrawlerBaseRequest crawlerBaseRequest = new CrawlerBaseRequest(insAreaCompany.getInsOrderNo(),ptlAgreementAttribution.getUsername());
|
|
|
CrawlerVerifyPaymentResponse crawlerAuditResponse = insCrawlerOrderComponents.request(apiUrl, insAreaCompany.getCompanyId(),
|
|
|
PtlCrawlerApiType.API_5.getDesc(), crawlerBaseRequest, CrawlerVerifyPaymentResponse.class);
|
|
|
|
|
|
@@ -703,7 +722,9 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
}
|
|
|
|
|
|
private boolean quashOrder(InsAreaCompany insAreaCompany) {
|
|
|
- CrawlerBaseRequest crawlerBaseRequest = new CrawlerBaseRequest(insAreaCompany.getInsOrderNo());
|
|
|
+ // 账号信息
|
|
|
+ PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
|
|
|
+ CrawlerBaseRequest crawlerBaseRequest = new CrawlerBaseRequest(insAreaCompany.getInsOrderNo(),ptlAgreementAttribution.getUsername());
|
|
|
CrawlerBaseResponse request = insCrawlerOrderComponents.request(apiUrl, insAreaCompany.getCompanyId(),
|
|
|
PtlCrawlerApiType.API_9.getDesc(), crawlerBaseRequest, CrawlerBaseResponse.class);
|
|
|
if (request.getCode() == CrawlerAuditStatus.CAS_200.getCode()) {
|
|
|
@@ -742,8 +763,11 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
String pathPrefix = insAreaCompany.getInscompany() + "-" + insOrders.getLicenseno() + "-" + insAreaCompany.getId() + "-";
|
|
|
// 请求地址
|
|
|
String apiUrl = ptlCrawlerApiService.getApiUrl(insAreaCompany.getAgreementId(), PtlCrawlerApiType.API_6);
|
|
|
+ // 账号信息
|
|
|
+ PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
|
|
|
+
|
|
|
//组装参数
|
|
|
- CrawlerBaseRequest crawlerBaseRequest = new CrawlerBaseRequest(insAreaCompany.getInsOrderNo());
|
|
|
+ CrawlerBaseRequest crawlerBaseRequest = new CrawlerBaseRequest(insAreaCompany.getInsOrderNo(),ptlAgreementAttribution.getUsername());
|
|
|
CrawlerPolicyPrintResponse response = insCrawlerOrderComponents.request(apiUrl, insAreaCompany.getCompanyId(), PtlCrawlerApiType.API_6.getDesc(), crawlerBaseRequest, CrawlerPolicyPrintResponse.class);
|
|
|
if (response.getCode() == 200) {
|
|
|
//交强险标志地址
|
|
|
@@ -787,4 +811,44 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
return FileUtil.netUrlToFileNew(url, dir, fileName, uploadFilePath, apiUrl + showFileUrl, flag);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void sendcode(String agreementId) {
|
|
|
+ // 获取协议的用户名密码
|
|
|
+ PtlAgreementAttribution attribution = ptlAgreementAttributionService.getById(agreementId);
|
|
|
+ PtlAgreementAttributionDto attributionDto = new PtlAgreementAttributionDto();
|
|
|
+ BeanUtils.copyProperties(attribution, attributionDto);
|
|
|
+ String apiUrl = attribution.getFields().getJSONObject(0).getString("value");
|
|
|
+ TsCrawlerLoginRequest crawlerLoginRequest = new TsCrawlerLoginRequest(attributionDto);
|
|
|
+ TsCrawlerBaseResponse response = insCrawlerOrderComponents.request(apiUrl, attribution.getInsCompanyId(), "获取验证码",
|
|
|
+ crawlerLoginRequest, TsCrawlerBaseResponse.class);
|
|
|
+ if(!response.getCode().equals(200)){
|
|
|
+ throw new SystemException(response.getMessage());
|
|
|
+ }
|
|
|
+ // 将返回参数放入redis
|
|
|
+ redisTemplate.opsForValue().set(OrderCacheConstant.TS_ACCESS_TOKEN + attributionDto.getUsername(), JSON.toJSONString(response.getData()), OrderCacheConstant.TS_ACCESS_TOKEN_TIME,
|
|
|
+ TimeUnit.SECONDS);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void taishanLogin(String agreementId, String smscode) {
|
|
|
+ // 获取协议的用户名密码
|
|
|
+ PtlAgreementAttribution attribution = ptlAgreementAttributionService.getById(agreementId);
|
|
|
+ PtlAgreementAttributionDto attributionDto = new PtlAgreementAttributionDto();
|
|
|
+ BeanUtils.copyProperties(attribution, attributionDto);
|
|
|
+ String apiUrl = ptlCrawlerApiService.getByTemplateId(attribution.getTemplateId(), PtlCrawlerApiType.API_1);
|
|
|
+ String token = redisTemplate.opsForValue().get(OrderCacheConstant.TS_ACCESS_TOKEN + attributionDto.getUsername());
|
|
|
+ if(StringUtils.isNotBlank(token)){
|
|
|
+ TsCrawlerLoginRequest request = JSON.parseObject(token).toJavaObject(TsCrawlerLoginRequest.class);
|
|
|
+ TsCrawlerLoginRequest tsRequest = new TsCrawlerLoginRequest(attributionDto,smscode,request);
|
|
|
+ TsCrawlerBaseResponse response = insCrawlerOrderComponents.request(apiUrl, attribution.getInsCompanyId(), "登录",
|
|
|
+ tsRequest, TsCrawlerBaseResponse.class);
|
|
|
+ if(!response.getCode().equals(200)){
|
|
|
+ throw new SystemException("泰山登录失败:" + response.getMessage());
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ throw new SystemException("验证码已失效!请重新发送!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|