feat: migrate payment provider to easy-pay, add order history and refund support

- Replace zpay with easy-pay payment provider (new lib/easy-pay/ module)
- Add order history page for users (pay/orders)
- Add GET /api/orders/my endpoint to list user's own orders
- Add GET /api/users/[id] endpoint for sub2api user lookup
- Add order status tracking module (lib/order/status.ts)
- Update config to support easy-pay credentials (merchant ID, key, gateway)
- Update PaymentForm and PaymentQRCode components for easy-pay flow
- Update pay page and admin page with new order management UI
- Update order service to support easy-pay, cancellation, and refund
This commit is contained in:
erio
2026-03-01 03:04:24 +08:00
commit d5719bf213
73 changed files with 10616 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
import { NextRequest, NextResponse } from 'next/server';
import { prisma } from '@/lib/db';
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ id: string }> },
) {
const { id } = await params;
const order = await prisma.order.findUnique({
where: { id },
select: {
id: true,
userId: true,
userName: true,
amount: true,
status: true,
paymentType: true,
payUrl: true,
qrCode: true,
qrCodeImg: true,
expiresAt: true,
paidAt: true,
completedAt: true,
failedReason: true,
createdAt: true,
},
});
if (!order) {
return NextResponse.json({ error: '订单不存在' }, { status: 404 });
}
return NextResponse.json({
order_id: order.id,
user_id: order.userId,
user_name: order.userName,
amount: Number(order.amount),
status: order.status,
payment_type: order.paymentType,
pay_url: order.payUrl,
qr_code: order.qrCode,
qr_code_img: order.qrCodeImg,
expires_at: order.expiresAt,
paid_at: order.paidAt,
completed_at: order.completedAt,
failed_reason: order.failedReason,
created_at: order.createdAt,
});
}