|
@@ -6,6 +6,7 @@ import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
@@ -17,7 +18,6 @@ import com.yc.ship.module.infra.api.config.ConfigApi;
|
|
|
import com.yc.ship.module.product.dal.dataobject.voyage.VoyageDO;
|
|
import com.yc.ship.module.product.dal.dataobject.voyage.VoyageDO;
|
|
|
import com.yc.ship.module.product.service.voyage.VoyageService;
|
|
import com.yc.ship.module.product.service.voyage.VoyageService;
|
|
|
import com.yc.ship.module.trade.api.insurance.dto.*;
|
|
import com.yc.ship.module.trade.api.insurance.dto.*;
|
|
|
-import com.yc.ship.module.trade.controller.admin.insurance.vo.InsuranceData;
|
|
|
|
|
import com.yc.ship.module.trade.controller.admin.insurance.vo.InsurancePageReqVO;
|
|
import com.yc.ship.module.trade.controller.admin.insurance.vo.InsurancePageReqVO;
|
|
|
import com.yc.ship.module.trade.controller.admin.insurance.vo.InsuranceRespVO;
|
|
import com.yc.ship.module.trade.controller.admin.insurance.vo.InsuranceRespVO;
|
|
|
import com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO;
|
|
import com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO;
|
|
@@ -32,7 +32,6 @@ import com.yc.ship.module.trade.framework.mq.TradePublishUtils;
|
|
|
import com.yc.ship.module.trade.utils.InsuranceRequestHelper;
|
|
import com.yc.ship.module.trade.utils.InsuranceRequestHelper;
|
|
|
import com.yc.ship.module.trade.utils.InsuranceUtil;
|
|
import com.yc.ship.module.trade.utils.InsuranceUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.redisson.api.RLock;
|
|
|
|
|
import org.redisson.api.RedissonClient;
|
|
import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -45,11 +44,11 @@ import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
import static com.yc.ship.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
import static com.yc.ship.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static com.yc.ship.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
|
import static com.yc.ship.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
|
|
-import static com.yc.ship.module.trade.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
|
+import static com.yc.ship.module.trade.enums.ErrorCodeConstants.INSURANCE_NOT_EXISTS;
|
|
|
|
|
+import static com.yc.ship.module.trade.enums.ErrorCodeConstants.ORDER_NOT_EXISTS;
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -181,35 +180,31 @@ public class InsuranceServiceImpl implements InsuranceService {
|
|
|
|
|
|
|
|
//验证投保信息
|
|
//验证投保信息
|
|
|
CommonResult commonResult = insuranceUtil.validateInsuranceRequest(insuranceApplyReqDTO);
|
|
CommonResult commonResult = insuranceUtil.validateInsuranceRequest(insuranceApplyReqDTO);
|
|
|
- if(!commonResult.isSuccess()) {
|
|
|
|
|
- throw exception0(commonResult.getCode(),commonResult.getMsg());
|
|
|
|
|
|
|
+ if (!commonResult.isSuccess()) {
|
|
|
|
|
+ throw exception0(commonResult.getCode(), commonResult.getMsg());
|
|
|
}
|
|
}
|
|
|
// 开始投保
|
|
// 开始投保
|
|
|
commonResult = insuranceUtil.sendInsuranceApply(insuranceApplyReqDTO);
|
|
commonResult = insuranceUtil.sendInsuranceApply(insuranceApplyReqDTO);
|
|
|
- if(!commonResult.isSuccess()) {
|
|
|
|
|
- throw exception0(commonResult.getCode(),commonResult.getMsg());
|
|
|
|
|
|
|
+ if (!commonResult.isSuccess()) {
|
|
|
|
|
+ throw exception0(commonResult.getCode(), commonResult.getMsg());
|
|
|
}
|
|
}
|
|
|
//保存投保信息
|
|
//保存投保信息
|
|
|
InsuranceDO insuranceDO = new InsuranceDO();
|
|
InsuranceDO insuranceDO = new InsuranceDO();
|
|
|
insuranceDO.setOrderId(orderId);
|
|
insuranceDO.setOrderId(orderId);
|
|
|
-// insuranceDO.setAgencyOrderId(applyReqVO.getAgencyOrderId());
|
|
|
|
|
insuranceDO.setInsuranceStatus(InsuranceStatusEnum.INSURE.getValue());
|
|
insuranceDO.setInsuranceStatus(InsuranceStatusEnum.INSURE.getValue());
|
|
|
insuranceDO.setInsuredNum(insuredList.size());
|
|
insuranceDO.setInsuredNum(insuredList.size());
|
|
|
-// insuranceDO.setHolderName(applyReqVO.getHolderName());
|
|
|
|
|
-// insuranceDO.setHolderNo(applyReqVO.getHolderNo());
|
|
|
|
|
-// insuranceDO.setRationType(applyReqVO.getRationType());
|
|
|
|
|
-// insuranceDO.setRiskCode(riskCode);
|
|
|
|
|
-// insuranceDO.setInsuranceEffectDate(LocalDateTime.ofInstant(applyReqVO.getTravelDate().toInstant(), ZoneId.systemDefault()));
|
|
|
|
|
|
|
+ insuranceDO.setInsuranceNo(orderInfo.getOrderNo());
|
|
|
Long id = IdWorker.getId(insuranceDO);
|
|
Long id = IdWorker.getId(insuranceDO);
|
|
|
insuranceDO.setId(id);
|
|
insuranceDO.setId(id);
|
|
|
insuranceMapper.insert(insuranceDO);
|
|
insuranceMapper.insert(insuranceDO);
|
|
|
// 发送查询投保接口通知
|
|
// 发送查询投保接口通知
|
|
|
- tradePublishUtils.publishInsuranceQueryMsg(orderInfo.getOrderNo(),0);
|
|
|
|
|
|
|
+ tradePublishUtils.publishInsuranceQueryMsg(orderInfo.getOrderNo());
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 处理系统证件枚举与保险证件枚举转换
|
|
* 处理系统证件枚举与保险证件枚举转换
|
|
|
|
|
+ *
|
|
|
* @param credentialType
|
|
* @param credentialType
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
@@ -222,7 +217,14 @@ public class InsuranceServiceImpl implements InsuranceService {
|
|
|
case 1:
|
|
case 1:
|
|
|
transCredentialType = 3;
|
|
transCredentialType = 3;
|
|
|
break;
|
|
break;
|
|
|
- case 2: case 3: case 4: case 6: case 7: case 8: case 9: case 99:
|
|
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ case 3:
|
|
|
|
|
+ case 4:
|
|
|
|
|
+ case 6:
|
|
|
|
|
+ case 7:
|
|
|
|
|
+ case 8:
|
|
|
|
|
+ case 9:
|
|
|
|
|
+ case 99:
|
|
|
transCredentialType = 6;
|
|
transCredentialType = 6;
|
|
|
break;
|
|
break;
|
|
|
case 5:
|
|
case 5:
|
|
@@ -239,13 +241,17 @@ public class InsuranceServiceImpl implements InsuranceService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional
|
|
@Transactional
|
|
|
- public void applyCancelInsurance(Long orderId) {
|
|
|
|
|
- TradeOrderRespVO orderInfo = tradeOrderMapper.getOrderInfo(orderId);
|
|
|
|
|
|
|
+ public void applyCancelInsurance(Long id) {
|
|
|
|
|
+ InsuranceDO insuranceDO = insuranceMapper.selectById(id);
|
|
|
|
|
+ if(insuranceDO == null){
|
|
|
|
|
+ throw exception(INSURANCE_NOT_EXISTS);
|
|
|
|
|
+ }
|
|
|
|
|
+ TradeOrderRespVO orderInfo = tradeOrderMapper.getOrderInfo(insuranceDO.getOrderId());
|
|
|
|
|
+ if(orderInfo == null){
|
|
|
|
|
+ throw exception(ORDER_NOT_EXISTS);
|
|
|
|
|
+ }
|
|
|
VoyageDO voyage = voyageService.getVoyage(orderInfo.getVoyageId());
|
|
VoyageDO voyage = voyageService.getVoyage(orderInfo.getVoyageId());
|
|
|
|
|
|
|
|
- //获取投保记录,投保保单号
|
|
|
|
|
- InsuranceDO insuranceDO = insuranceMapper.selectByOrderId(orderId);
|
|
|
|
|
-
|
|
|
|
|
InsuranceCancelReqDTO insuranceCancelReqDTO = new InsuranceCancelReqDTO();
|
|
InsuranceCancelReqDTO insuranceCancelReqDTO = new InsuranceCancelReqDTO();
|
|
|
insuranceCancelReqDTO.setService("cancel");
|
|
insuranceCancelReqDTO.setService("cancel");
|
|
|
insuranceCancelReqDTO.setReplyUrl(notifyUrl);
|
|
insuranceCancelReqDTO.setReplyUrl(notifyUrl);
|
|
@@ -267,8 +273,8 @@ public class InsuranceServiceImpl implements InsuranceService {
|
|
|
|
|
|
|
|
// 开始退保
|
|
// 开始退保
|
|
|
CommonResult commonResult = insuranceUtil.sendInsuranceCancel(insuranceCancelReqDTO);
|
|
CommonResult commonResult = insuranceUtil.sendInsuranceCancel(insuranceCancelReqDTO);
|
|
|
- if(!commonResult.isSuccess()) {
|
|
|
|
|
- throw exception0(commonResult.getCode(),commonResult.getMsg());
|
|
|
|
|
|
|
+ if (!commonResult.isSuccess()) {
|
|
|
|
|
+ throw exception0(commonResult.getCode(), commonResult.getMsg());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -297,11 +303,11 @@ public class InsuranceServiceImpl implements InsuranceService {
|
|
|
insuranceDO.setAmount(amount);
|
|
insuranceDO.setAmount(amount);
|
|
|
insuranceDO.setPolicyNo(policyNo);
|
|
insuranceDO.setPolicyNo(policyNo);
|
|
|
Integer insuranceStatus = InsuranceStatusEnum.INSURE.getValue();
|
|
Integer insuranceStatus = InsuranceStatusEnum.INSURE.getValue();
|
|
|
- if("SUCCESS".equals(status)) {
|
|
|
|
|
|
|
+ if ("SUCCESS".equals(status)) {
|
|
|
insuranceStatus = InsuranceStatusEnum.SUCCESS.getValue();
|
|
insuranceStatus = InsuranceStatusEnum.SUCCESS.getValue();
|
|
|
- } else if ("FAIL".equals(status)){
|
|
|
|
|
|
|
+ } else if ("FAIL".equals(status)) {
|
|
|
insuranceStatus = InsuranceStatusEnum.FAIL.getValue();
|
|
insuranceStatus = InsuranceStatusEnum.FAIL.getValue();
|
|
|
- }else if ("PROCESSING".equals(status)){
|
|
|
|
|
|
|
+ } else if ("PROCESSING".equals(status)) {
|
|
|
insuranceStatus = InsuranceStatusEnum.INSURE.getValue();
|
|
insuranceStatus = InsuranceStatusEnum.INSURE.getValue();
|
|
|
}
|
|
}
|
|
|
insuranceDO.setInsuranceStatus(insuranceStatus);
|
|
insuranceDO.setInsuranceStatus(insuranceStatus);
|
|
@@ -311,6 +317,22 @@ public class InsuranceServiceImpl implements InsuranceService {
|
|
|
tradeOrderMapper.updateById(tradeOrderDO);
|
|
tradeOrderMapper.updateById(tradeOrderDO);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void queryInsuranceByOrderId(Long id) {
|
|
|
|
|
+ InsuranceDO insuranceDO = insuranceMapper.selectById(id);
|
|
|
|
|
+ CommonResult commonResult = insuranceUtil.queryInsuranceNew(insuranceDO.getInsuranceNo(),insuranceDO.getOrderId());
|
|
|
|
|
+ if (!commonResult.isSuccess()) {
|
|
|
|
|
+ throw exception0(commonResult.getCode(), commonResult.getMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void queryInsuranceQuey() {
|
|
|
|
|
+ List<InsuranceDO> list = insuranceMapper.selectList(new LambdaQueryWrapper<InsuranceDO>().eq(InsuranceDO::getInsuranceStatus, 0).ge(InsuranceDO::getCreateTime, DateUtil.yesterday()));
|
|
|
|
|
+ list.forEach(insuranceDO -> insuranceUtil.queryInsurance(insuranceDO.getInsuranceNo()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 电子保单查询
|
|
* 电子保单查询
|
|
|
*/
|
|
*/
|
|
@@ -351,14 +373,14 @@ public class InsuranceServiceImpl implements InsuranceService {
|
|
|
//加密加签
|
|
//加密加签
|
|
|
InsuranceRequestHelper.encryptAndSign(insuranceRequest, publicKey, privateKey);
|
|
InsuranceRequestHelper.encryptAndSign(insuranceRequest, publicKey, privateKey);
|
|
|
String url = configApi.getConfigValueByKey("insurance.url");
|
|
String url = configApi.getConfigValueByKey("insurance.url");
|
|
|
- log.error("电子保险查询 data=" + JSONUtil.toJsonStr(insuranceRequest));
|
|
|
|
|
|
|
+ log.error("电子保险查询 data={}", JSONUtil.toJsonStr(insuranceRequest));
|
|
|
String result = HttpUtil.createPost(url + "/QUERYEPOLICY").contentType("application/json").body(JSONUtil.toJsonStr(insuranceRequest)).timeout(15000).execute().body();
|
|
String result = HttpUtil.createPost(url + "/QUERYEPOLICY").contentType("application/json").body(JSONUtil.toJsonStr(insuranceRequest)).timeout(15000).execute().body();
|
|
|
- log.error("电子保险查询 result=" + result);
|
|
|
|
|
|
|
+ log.error("电子保险查询 result={}", result);
|
|
|
JSONObject insuranceResponse = JSONUtil.parseObj(result);
|
|
JSONObject insuranceResponse = JSONUtil.parseObj(result);
|
|
|
|
|
|
|
|
InsuranceRequestHelper.checkSignAndDecrypt(insuranceResponse, publicKey, privateKey);
|
|
InsuranceRequestHelper.checkSignAndDecrypt(insuranceResponse, publicKey, privateKey);
|
|
|
// 0:失败 1:成功
|
|
// 0:失败 1:成功
|
|
|
- if (insuranceResponse != null && "200".equals(insuranceResponse.get("code"))) {
|
|
|
|
|
|
|
+ if ("200".equals(insuranceResponse.get("code"))) {
|
|
|
String data = insuranceResponse.get("data").toString();
|
|
String data = insuranceResponse.get("data").toString();
|
|
|
if (data != null) {
|
|
if (data != null) {
|
|
|
Map queryEpolicyResult = JSONUtil.toBean(data, Map.class);
|
|
Map queryEpolicyResult = JSONUtil.toBean(data, Map.class);
|
|
@@ -379,7 +401,7 @@ public class InsuranceServiceImpl implements InsuranceService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.error("电子保单查询error:" + e.getMessage());
|
|
|
|
|
|
|
+ log.error("电子保单查询error:{}", e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|