From 1dfa2e2316b6e1cc7665a70821e416a681ffe268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A3=B7=E5=8F=B6?= <14103883+leaf-phos@user.noreply.gitee.com> Date: Mon, 30 Dec 2024 16:50:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=AA=E7=B1=B3=E9=80=80=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/common/pay/tm/TmPayService.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/pay/tm/TmPayService.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/pay/tm/TmPayService.java index 0d3dd05f..0d8a0ef2 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/pay/tm/TmPayService.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/pay/tm/TmPayService.java @@ -11,6 +11,7 @@ import com.ruoyi.common.pay.tm.vo.TmTradeInfo; import com.ruoyi.common.pay.Payable; import com.ruoyi.common.pay.Refundable; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.http.HttpUtils; import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse; import org.springframework.beans.factory.annotation.Autowired; @@ -63,9 +64,11 @@ public class TmPayService implements PayApi { String response = doPost(config.getHttpUrl() + "/open/Pay/refund", body, config); if (com.ruoyi.common.utils.StringUtils.hasText(response)) { JSONObject jsonResponse = JSON.parseObject(response); - if (jsonResponse.getInteger("errCode") == 0 && "退款成功".equals(jsonResponse.getString("errMsg"))) { - JSONObject tradeInfo = jsonResponse.getJSONObject("refundInfo"); - return tradeInfo.toJavaObject(RefundInfo.class); + if (jsonResponse.getInteger("errCode") == 0) { + JSONObject refundInfo = jsonResponse.getJSONObject("refundInfo"); + ServiceUtil.assertion(refundInfo == null, "退款失败"); + ServiceUtil.assertion(refundInfo.getInteger("refundStatus") != 1, "退款失败:%s", refundInfo.getString("refundMessage")); + return refundInfo.toJavaObject(RefundInfo.class); } else { throw new ServiceException("退款失败: " + jsonResponse.getString("errMsg")); }