refactor: unify cancel logic with cancelOrderCore and show blocked UI

- Extract cancelOrderCore() shared by user cancel, admin cancel, and timeout expire
- Query payment platform before cancelling: if already paid, run confirmPayment
- Simplify timeout.ts to delegate to cancelOrderCore
- Cancel API returns already_paid outcome for frontend handling
- Show "订单已支付,无法取消" prompt with back button when cancel is blocked
This commit is contained in:
erio
2026-03-01 18:44:49 +08:00
parent 5751638f7b
commit 5a315a8f08
5 changed files with 135 additions and 79 deletions

View File

@@ -7,7 +7,10 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{
try {
const { id } = await params;
await adminCancelOrder(id);
const outcome = await adminCancelOrder(id);
if (outcome === 'already_paid') {
return NextResponse.json({ success: true, status: 'PAID', message: '订单已支付完成' });
}
return NextResponse.json({ success: true });
} catch (error) {
if (error instanceof OrderError) {