Browse Source

为关键门诊接口添加异常捕获

lighter 6 months ago
parent
commit
68d1912b6e

+ 1 - 1
src/main/java/thyyxxk/wxservice_server/entity/hrgresponse/SaveMzFeeResponse.java

@@ -15,6 +15,6 @@ public class SaveMzFeeResponse {
     }
 
     public String getResultMessage() {
-        return null == resultMessage ? "" : resultMessage;
+        return null == resultMessage ? "网络连接失败,保存门诊缴费信息失败。" : resultMessage;
     }
 }

+ 4 - 0
src/main/java/thyyxxk/wxservice_server/entity/wxapi/WxPayOrder.java

@@ -72,4 +72,8 @@ public class WxPayOrder {
         return orderType == OrderType.INSPECTIONS.getCode()
                 && (null == sglCheckNotified || !sglCheckNotified);
     }
+
+    public Boolean nativeOrderNotSaved() {
+        return orderType == OrderType.OUTPATIENT.getCode() && hisStatus != 1;
+    }
 }

+ 32 - 13
src/main/java/thyyxxk/wxservice_server/factory/thmz/ThmzService.java

@@ -273,12 +273,16 @@ public class ThmzService {
                 : "http://172.16.32.160:8088/thmz/api/v1/payChargeDetailFormHaiCi";
         String des = request.isNormalClinic() ? "门诊" : "医美";
         RestTemplate template = new RestTemplate();
-        SaveMzFeeResponse mzFeeResponse = template.postForObject(url, request, SaveMzFeeResponse.class);
-        log.info("第{}次尝试保存{}缴费信息:\n参数:{},\n结果:{}", times, des,
-                JSON.toJSON(request), JSON.toJSON(mzFeeResponse));
+        SaveMzFeeResponse mzFeeResponse = null;
+        try {
+            mzFeeResponse = template.postForObject(url, request, SaveMzFeeResponse.class);
+            log.info("第{}次尝试保存{}缴费信息:\n参数:{},\n结果:{}", times, des,
+                    JSON.toJSON(request), JSON.toJSON(mzFeeResponse));
+        } catch (Exception e) {
+            log.error("网络连接失败,保存门诊缴费信息失败:", e);
+        }
         mzFeeResponse = null == mzFeeResponse ? new SaveMzFeeResponse() : mzFeeResponse;
         if (mzFeeResponse.getResultCode() == 0) {
-
             return ExceptionEnum.SUCCESS;
         }
         if (mzFeeResponse.getResultMessage().contains("获取缴费流水号失败")) {
@@ -291,9 +295,14 @@ public class ThmzService {
 
     public String saveAppointment(SaveAppointmentRequest request) {
         RestTemplate template = new RestTemplate();
-        SaveGhFeeResponse response = template.postForObject(thmzApi + "/payRegistrationFormHaiCi",
-                request, SaveGhFeeResponse.class);
-        log.info("保存挂号信息: \n参数:{},\n结果:{}", JSON.toJSON(request), JSON.toJSON(response));
+        SaveGhFeeResponse response = null;
+        try {
+            response = template.postForObject(thmzApi + "/payRegistrationFormHaiCi",
+                    request, SaveGhFeeResponse.class);
+            log.info("保存挂号信息: \n参数:{},\n结果:{}", JSON.toJSON(request), JSON.toJSON(response));
+        } catch (Exception e) {
+            log.error("网络连接失败,保存挂号信息失败:", e);
+        }
         if (null == response) {
             return "ERROR:网络异常。";
         }
@@ -304,9 +313,14 @@ public class ThmzService {
     }
 
     public String saveClinicRegister(SaveClinicRegisterRequest request) {
-        SaveGhFeeResponse response = new RestTemplate()
-                .postForObject(thmzApi + "/payRegistration", request, SaveGhFeeResponse.class);
-        log.info("保存诊间挂号信息: \n参数:{},\n结果:{}", JSON.toJSON(request), JSON.toJSON(response));
+        SaveGhFeeResponse response = null;
+        try {
+            response = new RestTemplate()
+                    .postForObject(thmzApi + "/payRegistration", request, SaveGhFeeResponse.class);
+            log.info("保存诊间挂号信息: \n参数:{},\n结果:{}", JSON.toJSON(request), JSON.toJSON(response));
+        } catch (Exception e) {
+            log.error("网络连接失败,保存诊间挂号信息失败:", e);
+        }
         if (null == response) {
             return "ERROR:保存诊间挂号信息失败,门诊接口返回空。";
         }
@@ -317,9 +331,14 @@ public class ThmzService {
     }
 
     public String saveTemplate(SaveTemplateRequest request) {
-        HrgCommonResponse response = new RestTemplate().
-                postForObject(thmzApi + "/saveTcPrescription", request, HrgCommonResponse.class);
-        log.info("保存套餐缴费:\n参数:{}\n结果:{}", JSON.toJSON(request), JSON.toJSON(response));
+        HrgCommonResponse response = null;
+        try {
+            response = new RestTemplate().
+                    postForObject(thmzApi + "/saveTcPrescription", request, HrgCommonResponse.class);
+            log.info("保存套餐缴费:\n参数:{}\n结果:{}", JSON.toJSON(request), JSON.toJSON(response));
+        } catch (Exception e) {
+            log.error("网络连接失败,保存套餐缴费信息失败:", e);
+        }
         if (null == response) {
             return "ERROR:保存套餐缴费失败,门诊接口返回空。";
         }

+ 0 - 1
src/main/java/thyyxxk/wxservice_server/service/AssessmentService.java

@@ -7,7 +7,6 @@ import thyyxxk.wxservice_server.dao.AssessmentDao;
 import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
 import thyyxxk.wxservice_server.dao.assessment.InpatientQuestionnaireDao;
 import thyyxxk.wxservice_server.dao.assessment.OutpatientQuestionnaireDao;
-import thyyxxk.wxservice_server.entity.PureCodeName;
 import thyyxxk.wxservice_server.entity.ResultVo;
 import thyyxxk.wxservice_server.entity.assessment.*;
 import thyyxxk.wxservice_server.utils.ResultVoUtil;

+ 3 - 0
src/main/java/thyyxxk/wxservice_server/service/WxPayNotifyService.java

@@ -41,6 +41,9 @@ public class WxPayNotifyService {
             if (order.sglCheckNotNotified()) {
                 savePayResultService.notifyCytj(order, DateUtil.formatDatetime(order.getPayDatetime()));
             }
+            if (order.nativeOrderNotSaved()) {
+                savePayResultService.saveMzChargeInfo(order, DateUtil.formatDatetime(order.getPayDatetime()));
+            }
             return;
         }
         if (dbTradeState == Transaction.TradeStateEnum.REFUND) {