Forráskód Böngészése

fix: 前端订单状态码映射与后端OrderStatus对齐 + 清理逻辑仅取消CREATED

1. 前端状态码映射错位:0=已取消/1=待支付/2=已完成/3=已关闭,
   之前错误显示为0=待支付/1=已完成/2=已取消/3=已退款
2. 自动清理逻辑改为仅取消CREATED状态孤儿订单,避免误取消
   DOING/USER_PAYING等正常进行中的订单

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
skyline 2 hete
szülő
commit
c666974b55

+ 4 - 4
haha-admin-web/src/views/order/index.vue

@@ -104,10 +104,10 @@ async function doPayScoreCancel() {
           clearable
           class="w-[140px]!"
         >
-          <el-option label="待支付" :value="0" />
-          <el-option label="已完成" :value="1" />
-          <el-option label="已取消" :value="2" />
-          <el-option label="已退款" :value="3" />
+          <el-option label="已取消" :value="0" />
+          <el-option label="待支付" :value="1" />
+          <el-option label="已完成" :value="2" />
+          <el-option label="已关闭" :value="3" />
         </el-select>
       </el-form-item>
       <el-form-item label="下单时间:" prop="dateRange">

+ 8 - 8
haha-admin-web/src/views/order/utils/hook.tsx

@@ -156,10 +156,10 @@ export function useOrder(tableRef: Ref) {
       minWidth: 85,
       cellRenderer: ({ row }) => {
         const statusMap: Record<number, { text: string; type: string }> = {
-          0: { text: "待支付", type: "warning" },
-          1: { text: "已完成", type: "success" },
-          2: { text: "已取消", type: "info" },
-          3: { text: "已退款", type: "danger" }
+          0: { text: "已取消", type: "info" },
+          1: { text: "待支付", type: "warning" },
+          2: { text: "已完成", type: "success" },
+          3: { text: "已关闭", type: "info" }
         };
         const status = statusMap[row.status] || { text: "未知", type: "info" };
         return <el-tag type={status.type as any}>{status.text}</el-tag>;
@@ -267,11 +267,11 @@ export function useOrder(tableRef: Ref) {
         ? "danger" : "warning";
       const payStatusText = order.payStatusLabel || (order.payStatus === "PAID" ? "已支付" : order.payStatus === "REFUND" ? "已退款" : "待支付");
   
-      const statusStyle = order.status === 1
-        ? "success" : order.status === 3
-        ? "danger" : order.status === 2
+      const statusStyle = order.status === 2
+        ? "success" : order.status === 0
+        ? "info" : order.status === 3
         ? "info" : "warning";
-      const statusText = order.statusText || (order.status === 0 ? "待支付" : order.status === 1 ? "已完成" : order.status === 2 ? "已取消" : "已退款");
+      const statusText = order.statusText || (order.status === 0 ? "已取消" : order.status === 1 ? "待支付" : order.status === 2 ? "已完成" : "已关闭");
   
       const payTypeMap: Record<string, { text: string; type: string }> = {
         "wechat": { text: "微信支付", type: "success" },

+ 3 - 3
haha-service/src/main/java/com/haha/service/payment/payscore/impl/PayScoreServiceImpl.java

@@ -857,13 +857,13 @@ public class PayScoreServiceImpl implements PayScoreService {
      * 生产环境下回调正常运转后,此方法只在用户多次快速扫码(测试/异常)时触发
      */
     private void cancelStalePayScoreOrders(Long userId, String deviceId) {
-        // 1. 取消 DB 中该用户进行中的支付分订单
+        // 1. 只取消 CREATED 状态的孤儿订单(创建了但用户从未授权使用)
+        // DOING/USER_PAYING 是正常的进行中状态,不能取消
         try {
             List<Order> inProgressOrders = orderService.lambdaQuery()
                     .eq(Order::getUserId, userId)
                     .eq(Order::getPayChannel, PaymentChannel.WECHAT_PAYSCORE.getCode())
-                    .notIn(Order::getPayScoreState, PayScoreState.DONE.getCode(),
-                            PayScoreState.REVOKED.getCode(), PayScoreState.EXPIRED.getCode())
+                    .eq(Order::getPayScoreState, PayScoreState.CREATED.getCode())
                     .isNotNull(Order::getPayScoreOrderId)
                     .list();