22 lines
920 B
TypeScript
22 lines
920 B
TypeScript
import { NextRequest, NextResponse } from "next/server"
|
|
import { updateOrderStatusInSourceMongo } from "@/lib/db/admin-queries-mongo"
|
|
|
|
export async function PATCH(request: NextRequest) {
|
|
try {
|
|
const body = await request.json()
|
|
const { id, sourceTable, status } = body as { id: string; sourceTable: string; status: string }
|
|
if (!id || !sourceTable || !status) {
|
|
return NextResponse.json({ success: false, message: "缺少 id / sourceTable / status" }, { status: 400 })
|
|
}
|
|
await updateOrderStatusInSourceMongo(
|
|
sourceTable as "productOrders" | "companionOrders" | "pointCardOrders" | "rechargeOrders" | "venueBookings" | "accountPawns",
|
|
id,
|
|
status
|
|
)
|
|
return NextResponse.json({ success: true })
|
|
} catch (e) {
|
|
console.error("PATCH /api/admin/orders/status error:", e)
|
|
return NextResponse.json({ success: false, message: "更新失败" }, { status: 500 })
|
|
}
|
|
}
|