Преглед на файлове

fix: 修正订单状态码定义,0=待支付 1=已完成 2=已取消 3=已关闭

之前代码定义与数据库实际值不一致:
- 0: 已取消→待支付
- 1: 待支付→已完成
- 2: 已完成→已取消
- 3: 已关闭(不变)

后端全部使用命名常量自动适配,前端同步修正硬编码的状态比对。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
skyline преди 2 седмици
родител
ревизия
e2a3ec869a

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

@@ -218,7 +218,7 @@ async function doPayScoreCancel() {
               详情
             </el-button>
             <el-button
-              v-if="row.status === 2 && row.refundStatus !== 'REFUNDED'"
+              v-if="row.status === 1 && row.refundStatus !== 'REFUNDED'"
               class="reset-margin"
               link
               type="danger"

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

@@ -156,9 +156,9 @@ export function useOrder(tableRef: Ref) {
       minWidth: 85,
       cellRenderer: ({ row }) => {
         const statusMap: Record<number, { text: string; type: string }> = {
-          0: { text: "已取消", type: "info" },
-          1: { text: "待支付", type: "warning" },
-          2: { text: "已完成", type: "success" },
+          0: { text: "待支付", type: "warning" },
+          1: { text: "已完成", type: "success" },
+          2: { text: "已取消", type: "info" },
           3: { text: "已关闭", type: "info" }
         };
         const status = statusMap[row.status] || { text: "未知", type: "info" };
@@ -267,11 +267,10 @@ export function useOrder(tableRef: Ref) {
         ? "danger" : "warning";
       const payStatusText = order.payStatusLabel || (order.payStatus === "PAID" ? "已支付" : order.payStatus === "REFUND" ? "已退款" : "待支付");
   
-      const statusStyle = order.status === 2
+      const statusStyle = order.status === 1
         ? "success" : order.status === 0
-        ? "info" : order.status === 3
-        ? "info" : "warning";
-      const statusText = order.statusText || (order.status === 0 ? "已取消" : order.status === 1 ? "待支付" : order.status === 2 ? "已完成" : "已关闭");
+        ? "warning" : "info";
+      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" },
@@ -398,7 +397,7 @@ export function useOrder(tableRef: Ref) {
   }
 
   async function handleRefund(row: OrderItem) {
-    if (row.status !== 2) {
+    if (row.status !== 1) {
       message("只有已完成的订单才能退款", { type: "warning" });
       return;
     }

+ 8 - 8
haha-common/src/main/java/com/haha/common/constant/OrderConstants.java

@@ -9,20 +9,20 @@ public final class OrderConstants {
     
     // ==================== 订单状态 ====================
     
-    /**
-     * 订单状态:已取消
-     */
-    public static final int STATUS_CANCELLED = 0;
-    
     /**
      * 订单状态:待支付
      */
-    public static final int STATUS_PENDING_PAYMENT = 1;
-    
+    public static final int STATUS_PENDING_PAYMENT = 0;
+
     /**
      * 订单状态:已完成
      */
-    public static final int STATUS_COMPLETED = 2;
+    public static final int STATUS_COMPLETED = 1;
+
+    /**
+     * 订单状态:已取消
+     */
+    public static final int STATUS_CANCELLED = 2;
     
     /**
      * 订单状态:已关闭

+ 3 - 3
haha-common/src/main/java/com/haha/common/enums/OrderStatus.java

@@ -5,9 +5,9 @@ import lombok.Getter;
 @Getter
 public enum OrderStatus {
 
-    CANCELLED(0, "已取消"),
-    PENDING_PAYMENT(1, "待支付"),
-    COMPLETED(2, "已完成"),
+    PENDING_PAYMENT(0, "待支付"),
+    COMPLETED(1, "已完成"),
+    CANCELLED(2, "已取消"),
     CLOSED(3, "已关闭");
 
     private final int code;