Files
gitlab-instance-0a899031_salon/app/api/salon/complete-order/route.ts
2026-03-15 11:19:52 -05:00

28 lines
1.0 KiB
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { postSalonApi } from "@/app/lib/salonApi";
export async function POST(request: NextRequest) {
try {
const body = await request.json().catch(() => ({}));
const order_id = String(body?.order_id || "").trim();
if (!order_id) {
return NextResponse.json({ ok: false, error: "缺少 order_id" }, { status: 400 });
}
const { status, data } = await postSalonApi(request, "/api/salon/complete-order", {
order_id,
});
if (status >= 500) {
const payload = typeof data === "object" && data !== null ? (data as Record<string, unknown>) : {};
return NextResponse.json(
{ ok: false, error: (payload.detail as string) || (payload.error as string) || "操作失败" },
{ status: 503 }
);
}
return NextResponse.json(data, { status });
} catch (error) {
console.error("salon complete-order error:", error);
return NextResponse.json({ ok: false, error: "操作失败" }, { status: 500 });
}
}