From 9297d13045c9a4b29d1e7d87cac378094ce11214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Mon, 13 Apr 2026 02:14:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(shop):=20=E4=BF=AE=E5=A4=8D=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E5=9B=9E=E8=B0=83=E7=8A=B6=E6=80=81=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E7=A1=AE=E4=BF=9D=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将支付成功状态判断由字符串比较改为枚举值比较 - 使用 Transaction.TradeStateEnum.SUCCESS 替代 "支付成功" 字符串判断 - 避免因状态描述字符串不一致导致支付回调处理失败 - 保证支付成功后订单状态能够正确更新 --- .workbuddy/expert-history.json | 2 +- .workbuddy/memory/2026-04-13.md | 15 +++++++++++++++ .../shop/controller/ShopOrderController.java | 3 ++- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .workbuddy/memory/2026-04-13.md diff --git a/.workbuddy/expert-history.json b/.workbuddy/expert-history.json index dc1d944..c7baacc 100644 --- a/.workbuddy/expert-history.json +++ b/.workbuddy/expert-history.json @@ -35,5 +35,5 @@ } ] }, - "lastUpdated": 1776002597201 + "lastUpdated": 1776017110068 } \ No newline at end of file diff --git a/.workbuddy/memory/2026-04-13.md b/.workbuddy/memory/2026-04-13.md new file mode 100644 index 0000000..34250a1 --- /dev/null +++ b/.workbuddy/memory/2026-04-13.md @@ -0,0 +1,15 @@ +# 2026-04-13 工作日志 + +## 修复支付回调订单状态不更新问题 + +**问题描述**:支付成功后,订单支付状态没有更新,回调地址 `https://glt-api.websoft.top/api/shop/shop-order/notify` 接收到了通知但订单状态未改变。 + +**问题原因**:`ShopOrderController.java` 的 `wxNotify` 方法中,使用 `StrUtil.equals("支付成功", transaction.getTradeStateDesc())` 来判断支付状态。但微信返回的 `tradeStateDesc` 可能不是固定的 "支付成功" 字符串(可能是 "SUCCESS" 或其他描述),导致支付成功的回调没有被正确处理。 + +**修复方案**:将状态判断从字符串比较改为枚举值比较: +- 原代码:`if (StrUtil.equals("支付成功", transaction.getTradeStateDesc()))` +- 修复后:`if (Transaction.TradeStateEnum.SUCCESS.equals(transaction.getTradeState()))` + +**修改文件**:`src/main/java/com/gxwebsoft/shop/controller/ShopOrderController.java` + +**状态**:已修复 diff --git a/src/main/java/com/gxwebsoft/shop/controller/ShopOrderController.java b/src/main/java/com/gxwebsoft/shop/controller/ShopOrderController.java index ae553dc..1bd1795 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/ShopOrderController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/ShopOrderController.java @@ -888,7 +888,8 @@ public class ShopOrderController extends BaseController { logger.info("✅ 异步通知解析成功 - 交易状态: {}, 商户订单号: {}", transaction.getTradeStateDesc(), transaction.getOutTradeNo()); - if (StrUtil.equals("支付成功", transaction.getTradeStateDesc())) { + // 使用枚举值判断支付状态,避免依赖状态描述字符串 + if (Transaction.TradeStateEnum.SUCCESS.equals(transaction.getTradeState())) { final String outTradeNo = transaction.getOutTradeNo(); final String transactionId = transaction.getTransactionId(); final Integer total = transaction.getAmount().getTotal();