lighter преди 2 години
родител
ревизия
3679c27557

+ 1 - 1
src/main/java/thyyxxk/wxservice_server/dao/WxApiDao.java

@@ -74,7 +74,7 @@ public interface WxApiDao {
     @Update("update t_wechat_pay_order set pay_status=4 where trade_no=#{tradeNo}")
     void updateRefundStatus(@Param("tradeNo") String tradeNo);
 
-    @Update("update t_wechat_pay_order set his_status=1,pay_status=1 where trade_no=#{tradeNo}")
+    @Update("update t_wechat_pay_order set his_status=1 where trade_no=#{tradeNo}")
     void updateSuccessHisStatus(@Param("tradeNo") String tradeNo);
 
     @Select("select * from t_wechat_pay_order with(nolock) where trade_no=#{tradeNo}")

+ 9 - 8
src/main/java/thyyxxk/wxservice_server/service/SavePayResultService.java

@@ -117,16 +117,22 @@ public class SavePayResultService {
         hrgParam.put("agtOrdNum", order.getSerialNo());
         hrgParam.put("payTime", successTime);
         int tryTimes = 1;
-        ExceptionEnum mzFeeResponse = saveMzPayResult(hrgParam, tryTimes, hisOrdNum, tradeNo);
+        ExceptionEnum mzFeeResponse = saveMzPayResult(hrgParam, tryTimes);
         if (mzFeeResponse == ExceptionEnum.SUCCESS) {
+            updateHisChargeStatus(hisOrdNum, tradeNo);
             return ResultVoUtil.success("保存门诊缴费信息成功。");
         }
         while (mzFeeResponse == ExceptionEnum.FETCH_SERIAL_NO_FAILURE && tryTimes < 5) {
             tryTimes ++;
             TimeUnit.SECONDS.sleep(tryTimes > 3 ? 2 : tryTimes);
-            mzFeeResponse = saveMzPayResult(hrgParam, tryTimes, hisOrdNum, tradeNo);
+            mzFeeResponse = saveMzPayResult(hrgParam, tryTimes);
         }
         if (mzFeeResponse == ExceptionEnum.SUCCESS) {
+            updateHisChargeStatus(hisOrdNum, tradeNo);
+            return ResultVoUtil.success("保存门诊缴费信息成功。");
+        }
+        if (dao.alreadyPayed(tradeNo) == 1) {
+            updateHisChargeStatus(hisOrdNum, tradeNo);
             return ResultVoUtil.success("保存门诊缴费信息成功。");
         }
         log.info("【订单号:{}】发起自动退款:{}", tradeNo, mzFeeResponse.getMessage());
@@ -140,18 +146,13 @@ public class SavePayResultService {
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【" + mzFeeResponse.getMessage() +  "】自动退款失败,请联系服务中心进行退款。");
     }
 
-    private ExceptionEnum saveMzPayResult(JSONObject hrgParam, int times, String hisOrdNum, String tradeNo) {
+    private ExceptionEnum saveMzPayResult(JSONObject hrgParam, int times) {
         RestTemplate template = new RestTemplate();
         SaveMzFeeResponse mzFeeResponse = template.postForObject(hrgApiUrl + "/payChargeDetailFormHaiCi",
                 hrgParam, SaveMzFeeResponse.class);
         log.info("第{}次尝试保存门诊缴费信息:\n参数:{},\n结果:{}", times, hrgParam, mzFeeResponse);
         mzFeeResponse = null == mzFeeResponse ? new SaveMzFeeResponse() : mzFeeResponse;
         if (mzFeeResponse.getResultCode() == 0) {
-            updateHisChargeStatus(hisOrdNum, tradeNo);
-            return ExceptionEnum.SUCCESS;
-        }
-        if (dao.alreadyPayed(tradeNo) == 1) {
-            updateHisChargeStatus(hisOrdNum, tradeNo);
             return ExceptionEnum.SUCCESS;
         }
         if (mzFeeResponse.getResultMessage().contains("获取缴费流水号失败")) {