feat(order): add sealed review reveal, timeout rules, and dispatch behavior

This commit is contained in:
zetaloop
2026-02-22 08:16:35 +08:00
parent 33b7e4d0b9
commit a7d56240ff
5 changed files with 288 additions and 19 deletions
+45 -10
View File
@@ -1,6 +1,14 @@
"use client"
import { AlertTriangle, CheckCircle2, MessageSquare, RefreshCw, Star, XCircle } from "lucide-react"
import {
AlertTriangle,
CheckCircle2,
Clock,
MessageSquare,
RefreshCw,
Star,
XCircle,
} from "lucide-react"
import Link from "next/link"
import { useEffect, useState } from "react"
import { Button } from "@/components/ui/button"
@@ -8,6 +16,7 @@ import { notifySuccess } from "@/lib/toast"
import type { OrderStatus } from "@/lib/types"
import { useChatStore } from "@/store/chat"
import { useOrderStore } from "@/store/orders"
import { useShopStore } from "@/store/shops"
interface OrderActionsProps {
orderId: string
@@ -29,6 +38,11 @@ export default function OrderActions({
const order = useOrderStore((state) => state.orders.find((item) => item.id === orderId))
const updateOrderStatus = useOrderStore((state) => state.updateOrderStatus)
const ensureOrderSession = useChatStore((state) => state.ensureOrderSession)
const dispatchMode = useShopStore((state) => {
if (!order?.shopId) return "manual"
const shop = state.shops.find((item) => item.id === order.shopId)
return shop?.dispatchMode ?? "manual"
})
const [resolvedChatSessionId, setResolvedChatSessionId] = useState(chatSessionId)
const status = order?.status ?? initialStatus
@@ -44,6 +58,20 @@ export default function OrderActions({
setResolvedChatSessionId(session.id)
}, [chatSessionId, order, ensureOrderSession])
useEffect(() => {
if (!order) return
if (order.status !== "pending_accept") return
if (!order.shopId) return
if (dispatchMode !== "auto") return
const timer = setTimeout(() => {
updateOrderStatus(orderId, "in_progress")
showFeedback("系统已自动派单")
}, 3000)
return () => clearTimeout(timer)
}, [dispatchMode, order, orderId, updateOrderStatus])
return (
<div className="flex gap-2 flex-wrap">
{status === "pending_payment" && (
@@ -81,15 +109,22 @@ export default function OrderActions({
<XCircle className="mr-1 h-4 w-4" />
</Button>
<Button
onClick={() => {
updateOrderStatus(orderId, "in_progress")
showFeedback("已接单")
}}
>
<CheckCircle2 className="mr-1 h-4 w-4" />
</Button>
{order?.shopId && dispatchMode === "auto" ? (
<Button disabled>
<Clock className="mr-1 h-4 w-4" />
</Button>
) : (
<Button
onClick={() => {
updateOrderStatus(orderId, "in_progress")
showFeedback("已接单")
}}
>
<CheckCircle2 className="mr-1 h-4 w-4" />
</Button>
)}
</>
)}