|
@@ -50,8 +50,7 @@ import java.util.Map;
|
|
|
|
|
|
|
|
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.INSURANCE_NOT_EXISTS;
|
|
|
|
|
-import static com.yc.ship.module.trade.enums.ErrorCodeConstants.ORDER_NOT_EXISTS;
|
|
|
|
|
|
|
+import static com.yc.ship.module.trade.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -128,10 +127,18 @@ public class InsuranceServiceImpl implements InsuranceService {
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- @Transactional
|
|
|
|
|
|
|
+// @Transactional
|
|
|
public boolean applyInsurance(Long orderId) {
|
|
public boolean applyInsurance(Long orderId) {
|
|
|
|
|
|
|
|
- TradeOrderRespVO orderInfo = tradeOrderMapper.getOrderInfo(orderId);
|
|
|
|
|
|
|
+ TradeOrderDO orderInfo = tradeOrderMapper.selectById(orderId);
|
|
|
|
|
+ Integer isInsure = orderInfo.getIsInsure();
|
|
|
|
|
+ if(isInsure != null ) {
|
|
|
|
|
+ if(isInsure == 1) {
|
|
|
|
|
+ throw exception0(500, "该订单已投保成功");
|
|
|
|
|
+ }else if(isInsure == 0) {
|
|
|
|
|
+ throw exception0(500, "该订单正在投保中");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
VoyageDO voyage = voyageService.getVoyage(orderInfo.getVoyageId());
|
|
VoyageDO voyage = voyageService.getVoyage(orderInfo.getVoyageId());
|
|
|
InsuranceDO insuranceDO = new InsuranceDO();
|
|
InsuranceDO insuranceDO = new InsuranceDO();
|
|
|
Long id = IdWorker.getId(insuranceDO);
|
|
Long id = IdWorker.getId(insuranceDO);
|
|
@@ -170,7 +177,8 @@ public class InsuranceServiceImpl implements InsuranceService {
|
|
|
//被保人对象列表, 其下可多位被保险人, 他们在同个订单下
|
|
//被保人对象列表, 其下可多位被保险人, 他们在同个订单下
|
|
|
List<TradeVisitorRespVO> tradeVisitorRespVOS = tradeVisitorMapper.queryVisitorByOrderId(orderId);
|
|
List<TradeVisitorRespVO> tradeVisitorRespVOS = tradeVisitorMapper.queryVisitorByOrderId(orderId);
|
|
|
if(tradeVisitorRespVOS == null || tradeVisitorRespVOS.size() == 0) {
|
|
if(tradeVisitorRespVOS == null || tradeVisitorRespVOS.size() == 0) {
|
|
|
- return false;
|
|
|
|
|
|
|
+ log.error("订单{}下没有被保人信息, 投保失败", orderId);
|
|
|
|
|
+ throw exception(INSURANCE_NO_INSURED);
|
|
|
}
|
|
}
|
|
|
List<InsuredDTO> insuredList = new ArrayList<>();
|
|
List<InsuredDTO> insuredList = new ArrayList<>();
|
|
|
tradeVisitorRespVOS.forEach(tradeVisitorRespVO -> {
|
|
tradeVisitorRespVOS.forEach(tradeVisitorRespVO -> {
|
|
@@ -210,22 +218,34 @@ public class InsuranceServiceImpl implements InsuranceService {
|
|
|
// throw exception0(commonResult.getCode(), commonResult.getMsg());
|
|
// throw exception0(commonResult.getCode(), commonResult.getMsg());
|
|
|
// }
|
|
// }
|
|
|
// 开始投保
|
|
// 开始投保
|
|
|
- CommonResult commonResult = insuranceUtil.sendInsuranceApply(insuranceApplyReqDTO);
|
|
|
|
|
- if (!commonResult.isSuccess()) {
|
|
|
|
|
- throw exception0(commonResult.getCode(), commonResult.getMsg());
|
|
|
|
|
- }
|
|
|
|
|
- //保存投保信息
|
|
|
|
|
- insuranceMapper.deleteByOrderId(orderId);
|
|
|
|
|
-
|
|
|
|
|
insuranceDO.setOrderId(orderId);
|
|
insuranceDO.setOrderId(orderId);
|
|
|
insuranceDO.setInsuranceStatus(InsuranceStatusEnum.INSURE.getValue());
|
|
insuranceDO.setInsuranceStatus(InsuranceStatusEnum.INSURE.getValue());
|
|
|
insuranceDO.setInsuredNum(insuredList.size());
|
|
insuranceDO.setInsuredNum(insuredList.size());
|
|
|
insuranceDO.setInsuranceNo(orderInfo.getOrderNo());
|
|
insuranceDO.setInsuranceNo(orderInfo.getOrderNo());
|
|
|
insuranceDO.setTenantId(voyage.getTenantId());
|
|
insuranceDO.setTenantId(voyage.getTenantId());
|
|
|
insuranceDO.setRationType(insuranceOrderInfoDTO.getProductNo());
|
|
insuranceDO.setRationType(insuranceOrderInfoDTO.getProductNo());
|
|
|
- insuranceDO.setResMsg(String.valueOf(commonResult.getCheckedData()));
|
|
|
|
|
insuranceDO.setInsuranceEffectDate(voyage.getBoardingTime());
|
|
insuranceDO.setInsuranceEffectDate(voyage.getBoardingTime());
|
|
|
insuranceDO.setId(id);
|
|
insuranceDO.setId(id);
|
|
|
|
|
+ CommonResult commonResult = insuranceUtil.sendInsuranceApply(insuranceApplyReqDTO);
|
|
|
|
|
+ if (!commonResult.isSuccess()) {
|
|
|
|
|
+ log.error("投保失败:{}", commonResult.getMsg());
|
|
|
|
|
+ InsuranceDO insuranceDO1 = insuranceMapper.selectByOrderId(orderId);
|
|
|
|
|
+ if(insuranceDO1 != null) {
|
|
|
|
|
+ insuranceDO1.setInsuranceStatus(InsuranceStatusEnum.FAIL.getValue());
|
|
|
|
|
+ insuranceDO1.setResMsg(commonResult.getMsg());
|
|
|
|
|
+ insuranceMapper.updateById(insuranceDO1);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ insuranceDO.setInsuranceStatus(InsuranceStatusEnum.FAIL.getValue());
|
|
|
|
|
+ insuranceDO.setResMsg(commonResult.getMsg());
|
|
|
|
|
+ insuranceMapper.insert(insuranceDO);
|
|
|
|
|
+ }
|
|
|
|
|
+ tradeOrderMapper.update(new LambdaUpdateWrapper<TradeOrderDO>().set(TradeOrderDO::getIsInsure, InsuranceStatusEnum.FAIL.getValue()).eq(TradeOrderDO::getId, orderId));
|
|
|
|
|
+ throw exception0(commonResult.getCode(), commonResult.getMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+ //保存投保信息
|
|
|
|
|
+ insuranceMapper.deleteByOrderId(orderId);
|
|
|
|
|
+ insuranceDO.setResMsg(String.valueOf(commonResult.getCheckedData()));
|
|
|
|
|
+
|
|
|
insuranceMapper.insert(insuranceDO);
|
|
insuranceMapper.insert(insuranceDO);
|
|
|
// 发送查询投保接口通知
|
|
// 发送查询投保接口通知
|
|
|
tradePublishUtils.publishInsuranceQueryMsg(id.toString());
|
|
tradePublishUtils.publishInsuranceQueryMsg(id.toString());
|