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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user