'use client'; interface Order { id: string; userId: number; userName: string | null; userEmail: string | null; userNotes: 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; dark?: boolean; } const STATUS_LABELS: Record = { PENDING: { label: '待支付', light: 'bg-yellow-100 text-yellow-800', dark: 'bg-yellow-500/20 text-yellow-300' }, PAID: { label: '已支付', light: 'bg-blue-100 text-blue-800', dark: 'bg-blue-500/20 text-blue-300' }, RECHARGING: { label: '充值中', light: 'bg-blue-100 text-blue-800', dark: 'bg-blue-500/20 text-blue-300' }, COMPLETED: { label: '已完成', light: 'bg-green-100 text-green-800', dark: 'bg-green-500/20 text-green-300' }, EXPIRED: { label: '已超时', light: 'bg-gray-100 text-gray-800', dark: 'bg-slate-600/30 text-slate-400' }, CANCELLED: { label: '已取消', light: 'bg-gray-100 text-gray-800', dark: 'bg-slate-600/30 text-slate-400' }, FAILED: { label: '充值失败', light: 'bg-red-100 text-red-800', dark: 'bg-red-500/20 text-red-300' }, REFUNDING: { label: '退款中', light: 'bg-orange-100 text-orange-800', dark: 'bg-orange-500/20 text-orange-300' }, REFUNDED: { label: '已退款', light: 'bg-purple-100 text-purple-800', dark: 'bg-purple-500/20 text-purple-300' }, REFUND_FAILED: { label: '退款失败', light: 'bg-red-100 text-red-800', dark: 'bg-red-500/20 text-red-300' }, }; export default function OrderTable({ orders, onRetry, onCancel, onViewDetail, dark }: OrderTableProps) { const thCls = `px-4 py-3 text-left text-xs font-medium uppercase ${dark ? 'text-slate-400' : 'text-gray-500'}`; const tdMuted = `whitespace-nowrap px-4 py-3 text-sm ${dark ? 'text-slate-400' : 'text-gray-500'}`; return (
{orders.map((order) => { const statusInfo = STATUS_LABELS[order.status] || { label: order.status, light: 'bg-gray-100 text-gray-800', dark: 'bg-slate-600/30 text-slate-400', }; return ( ); })}
订单号 用户名 邮箱 备注 金额 状态 支付方式 来源 创建时间 操作
{order.userName || `#${order.userId}`} {order.userEmail || '-'} {order.userNotes || '-'} ¥{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 &&
暂无订单
}
); }