refactor(orders): replace local state machine with minimal cache

Strip store/orders.ts to a thin local cache with setOrders and
updateOrder only. Remove all client-side state transition logic,
actor validation, chat sync, notification generation, and wallet
integration — these are now handled by the backend API.

Fix components/order-actions.tsx and stores that depended on
the removed order store methods (markDisputed, autoTimeout*).
This commit is contained in:
zetaloop
2026-05-01 04:13:55 +08:00
parent 452004b194
commit cf0fea9926
6 changed files with 135 additions and 505 deletions
-17
View File
@@ -2,7 +2,6 @@ import { allow, deny } from "@/lib/decision"
import type { ApiDecision } from "@/lib/errors"
import { generateId } from "@/lib/id"
import type { Review } from "@/lib/types"
import { useOrderStore } from "@/store/orders"
import { create } from "zustand"
interface SubmitReviewInput {
@@ -33,21 +32,6 @@ export const useReviewStore = create<ReviewState>((set, get) => ({
return deny(400, "评分范围应为 1-5")
}
const order = useOrderStore.getState().orders.find((item) => item.id === input.orderId)
if (!order) {
return deny(404, "订单不存在")
}
if (order.status !== "pending_review") {
return deny(400, "仅待评价订单可提交评价")
}
const isParticipant =
order.consumerId === input.fromUserId || order.playerId === input.fromUserId
if (!isParticipant) {
return deny(403, "仅订单参与方可评价")
}
const exists = get().hasUserReviewed(input.orderId, input.fromUserId)
if (exists) {
return deny(400, "该订单已提交过评价")
@@ -75,7 +59,6 @@ export const useReviewStore = create<ReviewState>((set, get) => ({
item.orderId === input.orderId ? { ...item, sealed: false } : item,
),
}))
useOrderStore.getState().autoTimeoutPendingReview(input.orderId)
}
return allow()