Files
admin/src/app/(root)/trade/page.tsx

130 lines
4.1 KiB
TypeScript
Raw Normal View History

"use client"
2026-01-05 09:14:41 +08:00
import { format } from "date-fns"
import { CheckCircle, Clock, XCircle } from "lucide-react"
import { Suspense } from "react"
import { getPageTrade } from "@/actions/trade"
import { DataTable, useDataTable } from "@/components/data-table"
2026-01-05 09:14:41 +08:00
import type { Trade } from "@/models/trade"
2026-01-05 09:14:41 +08:00
export default function TradePage() {
const table = useDataTable<Trade>((page, size) =>
getPageTrade({ page, size }),
)
return (
<Suspense>
2026-01-05 09:14:41 +08:00
<DataTable<Trade>
{...table}
columns={[
{ header: "ID", accessorKey: "id" },
{ header: "套餐号", accessorKey: "inner_no" },
2026-01-05 09:14:41 +08:00
{
header: "支付方式",
accessorKey: "method",
cell: ({ row }) => {
const methodMap: Record<number, string> = {
1: "支付宝",
2: "微信",
3: "其他",
4: "支付宝",
5: "微信",
}
return (
<div>{methodMap[row.original.method as number] || "未知"}</div>
)
},
},
{
header: "支付金额",
accessorKey: "payment",
cell: ({ row }) => {
const payment =
typeof row.original.payment === "string"
? parseFloat(row.original.payment)
: row.original.payment || 0
return (
<div className="flex gap-1">
<span
className={
payment > 0 ? "text-green-500" : "text-orange-500"
}
>
{payment.toFixed(2)}
</span>
</div>
)
},
},
{
header: "支付平台",
accessorKey: "platform",
cell: ({ row }) => {
const platform = row.original.platform
if (!platform) return <span>-</span>
return (
<div className="flex items-center gap-2">
{platform === 1 ? (
<span></span>
) : platform === 2 ? (
<span></span>
) : (
<span>-</span>
)}
</div>
)
},
},
// { header: "已退款", accessorKey: "refunded" },
{
header: "支付状态",
accessorKey: "status",
cell: ({ row }) => {
const status = row.original.status
switch (status) {
case 0:
return (
<div className="flex items-center gap-2 text-yellow-600">
<Clock className="h-4 w-4" />
<span></span>
</div>
)
case 1:
return (
<div className="flex items-center gap-2 text-green-600">
<CheckCircle className="h-4 w-4" />
<span></span>
</div>
)
case 2:
return (
<div className="flex items-center gap-2 text-gray-500">
<XCircle className="h-4 w-4" />
<span></span>
</div>
)
default:
return <span className="text-gray-400">-</span>
}
},
},
{ header: "购买套餐", accessorKey: "subject" },
{ header: "类型", accessorKey: "type" },
2026-01-05 09:14:41 +08:00
{
header: "创建时间",
accessorKey: "created_at",
cell: ({ row }) =>
format(new Date(row.original.created_at), "yyyy-MM-dd HH:mm"),
},
{
header: "更新时间",
accessorKey: "updated_at",
cell: ({ row }) =>
format(new Date(row.original.updated_at), "yyyy-MM-dd HH:mm"),
},
]}
/>
</Suspense>
)
}