Selaa lähdekoodia

fix: 修改投保错误得问题

luofeiyun 1 viikko sitten
vanhempi
commit
405c7a216a

+ 4 - 1
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/framework/mq/TradeMqReceiver.java

@@ -395,17 +395,20 @@ public class TradeMqReceiver {
                 }
                 String status = policy.getString("status");
                 String service = policy.getString("service");
+                String msg = policy.getString("msg");
                 if("PROCESSING".equals(status)) {
                     log.error("保险查询结果,投保中,继续查询");
                     channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
                 } else if("FAIL".equals(status)) {
                     log.error("保险查询结果,投保失败,不再查询");
+                    Long externalPolicyNumber = policy.getLong("externalPolicyNumber");
+                    insuranceService.handleInsuranceQuery(paiedAmount, "", externalPolicyNumber, status, service, msg);
                     channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
                 } else if("SUCCESS".equals(status)) {
                     log.error("保险查询结果,投保成功,不再查询");
                     Long externalPolicyNumber = policy.getLong("externalPolicyNumber");
                     String policyNo = policy.getString("policyNo");
-                    insuranceService.handleInsuranceQuery(paiedAmount, policyNo, externalPolicyNumber, status, service);
+                    insuranceService.handleInsuranceQuery(paiedAmount, policyNo, externalPolicyNumber, status, service, msg);
                     channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
                 }
             }

+ 10 - 1
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/job/InsuranceApplyJob.java

@@ -4,6 +4,7 @@ import com.yc.ship.framework.quartz.core.handler.JobHandler;
 import com.yc.ship.framework.tenant.core.aop.TenantIgnore;
 import com.yc.ship.framework.tenant.core.util.TenantUtils;
 import com.yc.ship.module.trade.service.insurance.InsuranceService;
+import com.yc.ship.module.trade.service.order.TradeOrderRepositoryService;
 import com.yc.ship.module.trade.service.order.TradeOrderService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
@@ -25,6 +26,9 @@ public class InsuranceApplyJob implements JobHandler {
     @Resource
     private TradeOrderService tradeOrderService;
 
+    @Resource
+    private TradeOrderRepositoryService tradeOrderRepositoryService;
+
     /**
      * 执行定时任务
      * 定时购买保险
@@ -35,8 +39,13 @@ public class InsuranceApplyJob implements JobHandler {
         TenantUtils.execute(1L, () -> {
             List<Long> orderIdList = tradeOrderService.getCanBuyInsuranceOrder();
             orderIdList.stream().forEach(orderId -> {
+                log.info("开始执行保险购买定时任务,订单id{}", orderId);
                 try {
-                    insuranceService.applyInsurance(orderId);
+                    boolean b = insuranceService.applyInsurance(orderId);
+                    if(b) {
+                        //更新订单投保状态为投保中
+                        tradeOrderRepositoryService.updateOrderInsureStatus(orderId, 0);
+                    }
                 }catch (Exception e) {
                     log.error("保险购买定时任务异常,订单id{}", orderId, e);
                 }

+ 1 - 1
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/service/insurance/InsuranceService.java

@@ -71,5 +71,5 @@ public interface InsuranceService {
     /**
      * 保险查询后处理保险数据和订单保险状态
      */
-    void handleInsuranceQuery(BigDecimal amount, String policyNo, Long orderId, String status, String service);
+    void handleInsuranceQuery(BigDecimal amount, String policyNo, Long orderId, String status, String service, String msg);
 }

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

@@ -337,7 +337,7 @@ public class InsuranceServiceImpl implements InsuranceService {
 
     @Override
     @Transactional
-    public void handleInsuranceQuery(BigDecimal amount, String policyNo, Long id, String status, String service) {
+    public void handleInsuranceQuery(BigDecimal amount, String policyNo, Long id, String status, String service, String msg) {
         InsuranceDO insuranceDO = insuranceMapper.selectById(id);
         if(insuranceDO == null){
             log.error("handleInsuranceQuery》insuranceDO is null{}", id);
@@ -345,6 +345,7 @@ public class InsuranceServiceImpl implements InsuranceService {
         }
         insuranceDO.setPremium(amount);
         insuranceDO.setPolicyNo(policyNo);
+        insuranceDO.setResMsg(msg);
         Integer insuranceStatus = InsuranceStatusEnum.INSURE.getValue();
         if ("SUCCESS".equals(status)) {
             if("applyTeam".equals(service)) {
@@ -379,23 +380,26 @@ public class InsuranceServiceImpl implements InsuranceService {
         BigDecimal paiedAmount = jsonObject.getBigDecimal("paiedAmount");
         JSONArray policies = jsonObject.getJSONArray("policies");
         if(policies == null) {
-            handleInsuranceQuery(paiedAmount, "", insuranceDO.getOrderId(), "FAIL", "");
+            return;
         }
         com.alibaba.fastjson.JSONObject policy = policies.getJSONObject(0);
         if(policy == null) {
-            handleInsuranceQuery(paiedAmount, "", insuranceDO.getOrderId(), "FAIL", "");
+            return;
         }
         String status = policy.getString("status");
         String service = policy.getString("service");
+        String msg = policy.getString("msg");
         if("PROCESSING".equals(status)) {
             log.error("保险查询结果,投保中,继续查询"+insuranceDO.getInsuranceNo());
         } else if("FAIL".equals(status)) {
             log.error("保险查询结果,投保失败,不再查询"+insuranceDO.getInsuranceNo());
+            Long externalPolicyNumber = policy.getLong("externalPolicyNumber");
+            handleInsuranceQuery(paiedAmount, "", externalPolicyNumber, status, service, msg);
         } else if("SUCCESS".equals(status)) {
             log.error("保险查询结果,投保成功,不再查询"+insuranceDO.getInsuranceNo());
             Long externalPolicyNumber = policy.getLong("externalPolicyNumber");
             String policyNo = policy.getString("policyNo");
-            handleInsuranceQuery(paiedAmount, policyNo, externalPolicyNumber, status, service);
+            handleInsuranceQuery(paiedAmount, policyNo, externalPolicyNumber, status, service, msg);
         }
     }
 
@@ -418,23 +422,26 @@ public class InsuranceServiceImpl implements InsuranceService {
             BigDecimal paiedAmount = jsonObject.getBigDecimal("paiedAmount");
             JSONArray policies = jsonObject.getJSONArray("policies");
             if(policies == null) {
-                handleInsuranceQuery(paiedAmount, "", insuranceDO.getOrderId(), "FAIL", "");
+                continue;
             }
             com.alibaba.fastjson.JSONObject policy = policies.getJSONObject(0);
             if(policy == null) {
-                handleInsuranceQuery(paiedAmount, "", insuranceDO.getOrderId(), "FAIL", "");
+                continue;
             }
             String status = policy.getString("status");
             String service = policy.getString("service");
+            String msg = policy.getString("msg");
             if("PROCESSING".equals(status)) {
                 log.error("保险查询结果,投保中,继续查询"+insuranceDO.getInsuranceNo());
             } else if("FAIL".equals(status)) {
                 log.error("保险查询结果,投保失败,不再查询"+insuranceDO.getInsuranceNo());
+                Long externalPolicyNumber = policy.getLong("externalPolicyNumber");
+                handleInsuranceQuery(paiedAmount, "", externalPolicyNumber, status, service, msg);
             } else if("SUCCESS".equals(status)) {
                 log.error("保险查询结果,投保成功,不再查询"+insuranceDO.getInsuranceNo());
                 Long externalPolicyNumber = policy.getLong("externalPolicyNumber");
                 String policyNo = policy.getString("policyNo");
-                handleInsuranceQuery(paiedAmount, policyNo, externalPolicyNumber, status, service);
+                handleInsuranceQuery(paiedAmount, policyNo, externalPolicyNumber, status, service, msg);
             }
         }
     }

+ 19 - 4
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/utils/InsuranceUtilBak.java

@@ -31,7 +31,22 @@ import static com.yc.ship.framework.common.exception.util.ServiceExceptionUtil.e
 @Component
 public class InsuranceUtilBak {
 
-    public final String HOST = "https://lbb-admin.anyitech.ltd"; //测试域名
+    //测试环境
+//    public final String HOST = "https://lbb-admin.anyitech.ltd"; //测试域名
+//
+//    public final String VALIDATE_URL = "/policy/validateJson.do"; // 请求校验接口
+//
+//    public final String RECEIVE_URL = "/policy/receiveJson.do"; // JSON投/退保接口
+//
+//    public final String QUERY_URL = "/policy/querystatus.do"; // 保单状态查询接口
+//
+//    public final String APPID = "123456";   // appId
+//
+//    public final String KEY = "goldpalm"; // key
+
+    //  正式环境
+
+    public final String HOST = "http://www.admin.airiskeys.com"; //测试域名
 
     public final String VALIDATE_URL = "/policy/validateJson.do"; // 请求校验接口
 
@@ -39,9 +54,9 @@ public class InsuranceUtilBak {
 
     public final String QUERY_URL = "/policy/querystatus.do"; // 保单状态查询接口
 
-    public final String APPID = "123456";   // appId
+    public final String APPID = "449ddc34";   // appId
 
-    public final String KEY = "goldpalm"; // key
+    public final String KEY = "2HVEZB4Z"; // key
 
     private final Integer VALIDATE_LEVEL = 0; //校验级别,其值有 0/1
 
@@ -314,7 +329,7 @@ public class InsuranceUtilBak {
 
     public static void main(String[] args) {
         InsuranceUtilBak insuranceUtil = new InsuranceUtilBak();
-        CommonResult commonResult = insuranceUtil.queryInsurance("2039502038551883778");
+        CommonResult commonResult = insuranceUtil.queryInsurance("2042633797007175681");
         System.out.println(commonResult);
 
 

+ 1 - 1
ship-module-trade/ship-module-trade-biz/src/main/resources/mapper/order/TradeOrderMapper.xml

@@ -2573,7 +2573,7 @@
         from trade_order
         where deleted = 0
           and order_status in (1,6)
-          and (is_insure in (2,3) or is_insure is null)
+          and (is_insure is null)
           and travel_date BETWEEN now() and CONCAT(DATE_ADD(CURDATE(),INTERVAL 2 DAY), ' 23:59:59')
     </select>
 </mapper>