diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/OpenCallbackController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/OpenCallbackController.java
index d0a0576..207adef 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/OpenCallbackController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/OpenCallbackController.java
@@ -17,7 +17,9 @@ import java.security.NoSuchAlgorithmException;
/**
* 闲管家开放平台推送回调(请在开放平台填写真实 URL)
* 订单:POST .../open/callback/order/receive?appid=×tamp=&sign=
- * 响应须与平台「强校验」一致:一般 {@code {"code":0,"msg":"OK","data":{}}} ,勿使用 {@code result} 等非标准字段。
+ *
+ * 成功/失败体须与《订单推送通知》OpenAPI 一致:{@code result=success|fail} + {@code msg};
+ * 仅当 {@code result} 为 success 时平台认为接收成功(失败最多重试 3 次;建议业务异步处理、快速返回)。
*/
@Anonymous
@RestController
@@ -41,7 +43,7 @@ public class OpenCallbackController {
String normalizedBody = normalizeJsonBody(rawBody);
IERPAccount account = erpAccountResolver.resolveStrict(appid);
if (!verifyGoofishSign(account, timestamp, sellerId, sign, normalizedBody)) {
- return failCallback(1, "签名失败");
+ return failCallback("签名失败");
}
return successCallback();
}
@@ -57,21 +59,21 @@ public class OpenCallbackController {
String normalizedBody = normalizeJsonBody(rawBody);
IERPAccount account = erpAccountResolver.resolveStrict(appid);
if (account == null) {
- return failCallback(1, "未找到启用的 AppKey 配置");
+ return failCallback("未找到启用的 AppKey 配置");
}
if (!verifyGoofishSign(account, timestamp, sellerId, sign, normalizedBody)) {
- return failCallback(1, "签名失败");
+ return failCallback("签名失败");
}
JSONObject body;
try {
body = "{}".equals(normalizedBody) ? new JSONObject() : JSON.parseObject(normalizedBody);
} catch (Exception e) {
- return failCallback(2, "请求体不是合法JSON");
+ return failCallback("请求体不是合法JSON");
}
try {
erpGoofishOrderService.publishOrProcessNotify(appid, timestamp, body);
} catch (Exception e) {
- return failCallback(3, "入队异常");
+ return failCallback("入队异常");
}
return successCallback();
}
@@ -105,20 +107,19 @@ public class OpenCallbackController {
return t.isEmpty() ? "{}" : t;
}
- /** 与平台开放接口成功响应字段类型对齐:code 为数值、msg 为字符串、data 为对象 */
+ /** 与《订单推送通知》notify_resp_ok 一致:result=success 时平台才停止重试 */
private static JSONObject successCallback() {
JSONObject ok = new JSONObject();
- ok.put("code", 0);
- ok.put("msg", "OK");
- ok.put("data", new JSONObject());
+ ok.put("result", "success");
+ ok.put("msg", "接收成功");
return ok;
}
- private static JSONObject failCallback(int code, String msg) {
+ /** 与 notify_resp_fail 一致:result=fail */
+ private static JSONObject failCallback(String msg) {
JSONObject j = new JSONObject();
- j.put("code", code);
- j.put("msg", msg == null ? "fail" : msg);
- j.put("data", new JSONObject());
+ j.put("result", "fail");
+ j.put("msg", msg == null || msg.isEmpty() ? "处理失败" : msg);
return j;
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/goofish/GoofishOrderChangeLogger.java b/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/goofish/GoofishOrderChangeLogger.java
index 3ad3999..2cd2d97 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/goofish/GoofishOrderChangeLogger.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/goofish/GoofishOrderChangeLogger.java
@@ -84,10 +84,10 @@ public class GoofishOrderChangeLogger {
List orderParts = new ArrayList<>();
if (!Objects.equals(b.orderStatus, a.orderStatus)) {
- orderParts.add("订单状态 " + str(b.orderStatus) + "→" + str(a.orderStatus));
+ orderParts.add("订单状态 " + GoofishStatusLabels.orderStatusChange(b.orderStatus, a.orderStatus));
}
if (!Objects.equals(b.refundStatus, a.refundStatus)) {
- orderParts.add("退款状态 " + str(b.refundStatus) + "→" + str(a.refundStatus));
+ orderParts.add("退款状态 " + GoofishStatusLabels.refundStatusChange(b.refundStatus, a.refundStatus));
}
if (!orderParts.isEmpty()) {
append(afterRow.getId(), afterRow.getAppKey(), afterRow.getOrderNo(), TYPE_ORDER, source,
diff --git a/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/goofish/GoofishOrderPipeline.java b/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/goofish/GoofishOrderPipeline.java
index c73fb04..b117f37 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/goofish/GoofishOrderPipeline.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/goofish/GoofishOrderPipeline.java
@@ -143,15 +143,17 @@ public class GoofishOrderPipeline {
if (existingBeforeUpdate == null) {
goofishOrderChangeLogger.append(loaded.getId(), loaded.getAppKey(), loaded.getOrderNo(),
GoofishOrderChangeLogger.TYPE_ORDER, upsertSource,
- "新订单入库,订单状态 " + loaded.getOrderStatus() + ",退款状态 " + loaded.getRefundStatus());
+ "新订单入库,订单状态 " + GoofishStatusLabels.orderStatusHuman(loaded.getOrderStatus())
+ + ",退款状态 " + GoofishStatusLabels.refundStatusHuman(loaded.getRefundStatus()));
return;
}
if (!Objects.equals(existingBeforeUpdate.getOrderStatus(), upsertPayload.getOrderStatus())
|| !Objects.equals(existingBeforeUpdate.getRefundStatus(), upsertPayload.getRefundStatus())) {
goofishOrderChangeLogger.append(loaded.getId(), loaded.getAppKey(), loaded.getOrderNo(),
GoofishOrderChangeLogger.TYPE_ORDER, upsertSource,
- "订单状态 " + existingBeforeUpdate.getOrderStatus() + "→" + upsertPayload.getOrderStatus()
- + ";退款状态 " + existingBeforeUpdate.getRefundStatus() + "→" + upsertPayload.getRefundStatus());
+ "订单状态 " + GoofishStatusLabels.orderStatusChange(existingBeforeUpdate.getOrderStatus(), upsertPayload.getOrderStatus())
+ + ";退款状态 " + GoofishStatusLabels.refundStatusChange(
+ existingBeforeUpdate.getRefundStatus(), upsertPayload.getRefundStatus()));
}
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/goofish/GoofishStatusLabels.java b/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/goofish/GoofishStatusLabels.java
new file mode 100644
index 0000000..d02cc49
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/goofish/GoofishStatusLabels.java
@@ -0,0 +1,85 @@
+package com.ruoyi.jarvis.service.goofish;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 闲管家开放平台:订单状态、退款状态中文说明(与 Apifox 订单列表 schema 一致)
+ */
+public final class GoofishStatusLabels {
+
+ private static final Map ORDER = new HashMap<>();
+ private static final Map REFUND = new HashMap<>();
+
+ static {
+ ORDER.put(11, "待付款");
+ ORDER.put(12, "待发货");
+ ORDER.put(21, "已发货");
+ ORDER.put(22, "已完成");
+ ORDER.put(23, "已退款");
+ ORDER.put(24, "已关闭");
+ REFUND.put(0, "未申请退款");
+ REFUND.put(1, "待商家处理");
+ REFUND.put(2, "待买家退货");
+ REFUND.put(3, "待商家收货");
+ REFUND.put(4, "退款关闭");
+ REFUND.put(5, "退款成功");
+ REFUND.put(6, "已拒绝退款");
+ REFUND.put(8, "待确认退货地址");
+ }
+
+ private GoofishStatusLabels() {
+ }
+
+ /** 仅中文;未知时返回 null */
+ public static String orderStatusLabel(Integer s) {
+ if (s == null) {
+ return null;
+ }
+ return ORDER.get(s);
+ }
+
+ /** 仅中文;未知时返回 null */
+ public static String refundStatusLabel(Integer s) {
+ if (s == null) {
+ return null;
+ }
+ return REFUND.get(s);
+ }
+
+ /**
+ * 用于日志/企微:优先中文,未知时带码便于排查
+ */
+ public static String orderStatusHuman(Integer s) {
+ String t = orderStatusLabel(s);
+ if (t != null) {
+ return t;
+ }
+ if (s == null) {
+ return "—";
+ }
+ return "未识别状态(" + s + ")";
+ }
+
+ public static String refundStatusHuman(Integer s) {
+ String t = refundStatusLabel(s);
+ if (t != null) {
+ return t;
+ }
+ if (s == null) {
+ return "—";
+ }
+ return "未识别状态(" + s + ")";
+ }
+
+ /**
+ * 变化摘要:A→B,两边均为人话
+ */
+ public static String orderStatusChange(Integer from, Integer to) {
+ return orderStatusHuman(from) + " → " + orderStatusHuman(to);
+ }
+
+ public static String refundStatusChange(Integer from, Integer to) {
+ return refundStatusHuman(from) + " → " + refundStatusHuman(to);
+ }
+}