'use client'; import { useState } from 'react'; interface Order { id: string; userId: number; userName: string | null; userEmail: string | null; amount: number; status: string; paymentType: string; createdAt: string; paidAt: string | null; completedAt: string | null; failedReason: string | null; expiresAt: string; srcHost: string | null; rechargeRetryable?: boolean; } interface OrderTableProps { orders: Order[]; onRetry: (orderId: string) => void; onCancel: (orderId: string) => void; onViewDetail: (orderId: string) => void; } const STATUS_LABELS: Record = { PENDING: { label: '待支付', className: 'bg-yellow-100 text-yellow-800' }, PAID: { label: '已支付', className: 'bg-blue-100 text-blue-800' }, RECHARGING: { label: '充值中', className: 'bg-blue-100 text-blue-800' }, COMPLETED: { label: '已完成', className: 'bg-green-100 text-green-800' }, EXPIRED: { label: '已超时', className: 'bg-gray-100 text-gray-800' }, CANCELLED: { label: '已取消', className: 'bg-gray-100 text-gray-800' }, FAILED: { label: '充值失败', className: 'bg-red-100 text-red-800' }, REFUNDING: { label: '退款中', className: 'bg-orange-100 text-orange-800' }, REFUNDED: { label: '已退款', className: 'bg-purple-100 text-purple-800' }, REFUND_FAILED: { label: '退款失败', className: 'bg-red-100 text-red-800' }, }; export default function OrderTable({ orders, onRetry, onCancel, onViewDetail }: OrderTableProps) { return (
{orders.map((order) => { const statusInfo = STATUS_LABELS[order.status] || { label: order.status, className: 'bg-gray-100 text-gray-800', }; return ( ); })}
订单号 用户 金额 状态 支付方式 来源 创建时间 操作
{order.userName || '-'}
{order.userEmail || `ID: ${order.userId}`}
¥{order.amount.toFixed(2)} {statusInfo.label} {order.paymentType === 'alipay' ? '支付宝' : '微信支付'} {order.srcHost || '-'} {new Date(order.createdAt).toLocaleString('zh-CN')}
{order.rechargeRetryable && ( )} {order.status === 'PENDING' && ( )}
{orders.length === 0 &&
暂无订单
}
); }