Переглянути джерело

Merge remote-tracking branch 'origin/main'

lishiqiang 21 годин тому
батько
коміт
336ef28d94

+ 5 - 4
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/controller/admin/notify/NotifyController.java

@@ -11,6 +11,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.Enumeration;
 
 /**
  * 第三方调用的通知接口
@@ -25,10 +27,9 @@ public class NotifyController {
     private NotifyService notifyService;
 
     @PostMapping("/insurance")
-    public String insuranceNotify(JSONObject reqVO) {
-        log.info("收到保险通知:{}", reqVO.toJSONString());
-        JSONObject query = reqVO.getJSONObject("query");
-        String req = query.getString("req");
+    public String insuranceNotify(HttpServletRequest request) {
+        String req = request.getParameter("req");
+        log.info("收到保险通知:{}", req);
         NotifyInsuranceReqVO notifyInsuranceReqVO = JSONObject.parseObject(req, NotifyInsuranceReqVO.class);
         notifyService.notifyInsurance(notifyInsuranceReqVO);
         return "SUCCESS";

+ 4 - 0
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/dal/mysql/insurance/InsuranceMapper.java

@@ -51,4 +51,8 @@ public interface InsuranceMapper extends BaseMapperX<InsuranceDO> {
     default InsuranceDO selectByOrderId(Long orderId) {
         return selectOne(new LambdaQueryWrapper<InsuranceDO>().eq(InsuranceDO::getOrderId, orderId).last("limit 1"));
     }
+
+    default void deleteByOrderId(Long orderId) {
+        delete(new LambdaQueryWrapper<InsuranceDO>().eq(InsuranceDO::getOrderId, orderId));
+    }
 }

+ 12 - 11
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/service/insurance/InsuranceServiceImpl.java

@@ -132,6 +132,8 @@ public class InsuranceServiceImpl implements InsuranceService {
 
         TradeOrderRespVO orderInfo = tradeOrderMapper.getOrderInfo(orderId);
         VoyageDO voyage = voyageService.getVoyage(orderInfo.getVoyageId());
+        InsuranceDO insuranceDO = new InsuranceDO();
+        Long id = IdWorker.getId(insuranceDO);
 
         InsuranceApplyReqDTO insuranceApplyReqDTO = new InsuranceApplyReqDTO();
         insuranceApplyReqDTO.setService("applyTeam");
@@ -142,8 +144,8 @@ public class InsuranceServiceImpl implements InsuranceService {
         InsuranceOrderInfoDTO insuranceOrderInfoDTO = new InsuranceOrderInfoDTO();
 
         //投保人信息
-        insuranceOrderInfoDTO.setExternalOrderNo(orderInfo.getOrderNo());
-        insuranceOrderInfoDTO.setExternalPolicyNumber(orderInfo.getId().toString());
+        insuranceOrderInfoDTO.setExternalOrderNo(id.toString());
+        insuranceOrderInfoDTO.setExternalPolicyNumber(id.toString());
         insuranceOrderInfoDTO.setTeamCode(orderInfo.getGroupNo());
         //TODO: 当前写死
         insuranceOrderInfoDTO.setProductNo("RBLY_JH1");
@@ -191,21 +193,20 @@ public class InsuranceServiceImpl implements InsuranceService {
             throw exception0(commonResult.getCode(), commonResult.getMsg());
         }
         //保存投保信息
-        InsuranceDO insuranceDO = new InsuranceDO();
+        insuranceMapper.deleteByOrderId(orderId);
+
         insuranceDO.setOrderId(orderId);
         insuranceDO.setInsuranceStatus(InsuranceStatusEnum.INSURE.getValue());
         insuranceDO.setInsuredNum(insuredList.size());
         insuranceDO.setInsuranceNo(orderInfo.getOrderNo());
-        insuranceDO.setInsuranceNo(orderInfo.getOrderNo());
         insuranceDO.setTenantId(voyage.getTenantId());
         insuranceDO.setRationType(insuranceOrderInfoDTO.getProductNo());
         insuranceDO.setResMsg(String.valueOf(commonResult.getCheckedData()));
-        insuranceDO.setInsuranceEffectDate(LocalDateTime.parse(DateUtil.format(voyage.getBoardingTime(), "yyyy-MM-dd")));
-        Long id = IdWorker.getId(insuranceDO);
+        insuranceDO.setInsuranceEffectDate(voyage.getBoardingTime());
         insuranceDO.setId(id);
         insuranceMapper.insert(insuranceDO);
         // 发送查询投保接口通知
-        tradePublishUtils.publishInsuranceQueryMsg(orderInfo.getOrderNo());
+        tradePublishUtils.publishInsuranceQueryMsg(id.toString());
         return true;
     }
 
@@ -270,14 +271,14 @@ public class InsuranceServiceImpl implements InsuranceService {
         //订单对象, 一个订单下可以有一批被保险人
         InsuranceOrderInfoCancelDTO insuranceOrderInfoDTO = new InsuranceOrderInfoCancelDTO();
 
-        insuranceOrderInfoDTO.setExternalOrderNo(orderInfo.getOrderNo());
+        insuranceOrderInfoDTO.setExternalOrderNo(id.toString());
         insuranceOrderInfoDTO.setBeginDate(DateUtil.format(voyage.getBoardingTime(), "yyyy-MM-dd"));
         insuranceOrderInfoDTO.setEndDate(DateUtil.format(voyage.getLeaveTime(), "yyyy-MM-dd"));
         insuranceCancelReqDTO.setOrder(insuranceOrderInfoDTO);
 
         List<InsuredCancelDTO> insuredList = new ArrayList<>();
         InsuredCancelDTO insuredDTO = new InsuredCancelDTO();
-        insuredDTO.setExternalPolicyNumber(orderInfo.getId().toString());
+        insuredDTO.setExternalPolicyNumber(id.toString());
         insuredDTO.setPolicyNo(insuranceDO.getPolicyNo());
         insuredList.add(insuredDTO);
         insuranceCancelReqDTO.setInsureds(insuredList);
@@ -309,8 +310,8 @@ public class InsuranceServiceImpl implements InsuranceService {
 
     @Override
     @Transactional
-    public void handleInsuranceQuery(BigDecimal amount, String policyNo, Long orderId, String status) {
-        InsuranceDO insuranceDO = insuranceMapper.selectByOrderId(orderId);
+    public void handleInsuranceQuery(BigDecimal amount, String policyNo, Long id, String status) {
+        InsuranceDO insuranceDO = insuranceMapper.selectById(id);
         insuranceDO.setPremium(amount);
         insuranceDO.setPolicyNo(policyNo);
         Integer insuranceStatus = InsuranceStatusEnum.INSURE.getValue();

+ 6 - 6
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/service/notify/NotifyServiceImpl.java

@@ -26,20 +26,20 @@ public class NotifyServiceImpl implements NotifyService {
         String externalPolicyNumber = reqVO.getExternalPolicyNumber();
         String policyNo = reqVO.getPolicyNo();
         String downloadUrl = reqVO.getDownloadUrl();
-        String successDate = reqVO.getSuccessDate();
-        Long orderId = Long.valueOf(externalPolicyNumber);
+//        String successDate = reqVO.getSuccessDate();
+        Long id = Long.valueOf(externalPolicyNumber);
         String service = reqVO.getService();
         if("SUCCESS".equals(status)) {
-            InsuranceDO insuranceDO = insuranceMapper.selectByOrderId(orderId);
+            InsuranceDO insuranceDO = insuranceMapper.selectById(id);
             insuranceDO.setPolicyNo(policyNo);
             insuranceDO.setElectronicPolicy(downloadUrl);
             if("applyTeam".equals(service)) {
                 insuranceDO.setInsuranceStatus(InsuranceStatusEnum.SUCCESS.getValue());
-            }else if ("cancel".equals(service)) {
+            }else if ("cancelTeam".equals(service)) {
                 insuranceDO.setInsuranceStatus(InsuranceStatusEnum.CANCELLED.getValue());
             }
-            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-            insuranceDO.setInsuranceEffectDate(LocalDateTime.parse(successDate,formatter));
+//            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+//            insuranceDO.setInsuranceEffectDate(LocalDateTime.parse(successDate,formatter));
             insuranceMapper.updateById(insuranceDO);
         }
         return true;

+ 1 - 1
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/utils/InsuranceUtil.java

@@ -308,7 +308,7 @@ public class InsuranceUtil {
 
     public static void main(String[] args) {
         InsuranceUtil insuranceUtil = new InsuranceUtil();
-        CommonResult commonResult = insuranceUtil.queryInsurance("tys-20260725-YC-10");
+        CommonResult commonResult = insuranceUtil.queryInsurance("lfy001-20261217-YC-5");
         System.out.println(commonResult);
     }
 }