diff --git a/src/actions/bill.ts b/src/actions/bill.ts index 53dcc1e..5bf944d 100644 --- a/src/actions/bill.ts +++ b/src/actions/bill.ts @@ -7,7 +7,6 @@ export async function listBills(params: { size?: number bill_no?: string type?: number - status?: number create_after?: Date create_before?: Date }) { diff --git a/src/actions/resource.ts b/src/actions/resource.ts index bd1ef16..9654b2b 100644 --- a/src/actions/resource.ts +++ b/src/actions/resource.ts @@ -46,11 +46,15 @@ async function prepareResourceByWechat(props: CreateResourceReq) { return await callByUser('/api/resource/prepare/wechat', props) } -async function createResourceByAlipay(props: CreateResourceReq) { +type PaidResourceReq = { + trade_no: string +} + +async function createResourceByAlipay(props: PaidResourceReq) { return await callByUser('/api/resource/create/alipay', props) } -async function createResourceByWechat(props: CreateResourceReq) { +async function createResourceByWechat(props: PaidResourceReq) { return await callByUser('/api/resource/create/wechat', props) } diff --git a/src/app/(api)/alipay/callback/rouute.ts b/src/app/(api)/alipay/callback/rouute.ts new file mode 100644 index 0000000..4f9ab22 --- /dev/null +++ b/src/app/(api)/alipay/callback/rouute.ts @@ -0,0 +1,5 @@ +import {NextRequest} from 'next/server' + +export async function GET(req: NextRequest) { + +} diff --git a/src/app/(api)/wechatpay/callback/rouute.ts b/src/app/(api)/wechatpay/callback/rouute.ts new file mode 100644 index 0000000..4f9ab22 --- /dev/null +++ b/src/app/(api)/wechatpay/callback/rouute.ts @@ -0,0 +1,5 @@ +import {NextRequest} from 'next/server' + +export async function GET(req: NextRequest) { + +} diff --git a/src/app/(temp)/pay/page.tsx b/src/app/(temp)/pay/page.tsx deleted file mode 100644 index d6ca9d4..0000000 --- a/src/app/(temp)/pay/page.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import {Button} from '@/components/ui/button' -import Link from 'next/link' - -export type PayPageProps = {} - -export default async function PayPage(props: PayPageProps) { - return ( -
-
- 模拟支付页 -
- - 模拟支付成功 - -
- ) -} diff --git a/src/app/admin/bills/page.tsx b/src/app/admin/bills/page.tsx index a11be52..821beaf 100644 --- a/src/app/admin/bills/page.tsx +++ b/src/app/admin/bills/page.tsx @@ -4,7 +4,7 @@ import {PageRecord} from '@/lib/api' import {Bill} from '@/lib/models' import {useStatus} from '@/lib/states' import {listBills} from '@/actions/bill' -import {Search, Eraser, CreditCard, AlertCircle, CheckCircle} from 'lucide-react' +import {Search, Eraser, CreditCard, AlertCircle, CheckCircle, Clock, ClockIcon} from 'lucide-react' import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from '@/components/ui/select' import {Button} from '@/components/ui/button' import DataTable from '@/components/data-table' @@ -20,7 +20,6 @@ import Link from 'next/link' const filterSchema = zod.object({ type: zod.enum(['all', '0', '1', '2']).default('all'), - status: zod.enum(['all', '0', '1', '2']).default('all'), create_after: zod.date().optional(), create_before: zod.date().optional(), }) @@ -47,14 +46,12 @@ export default function BillsPage(props: BillsPageProps) { setStatus('load') try { const typeValue = form.getValues('type') - const statusValue = form.getValues('status') const type = typeValue === 'all' ? undefined : parseInt(typeValue) - const statusParam = statusValue === 'all' ? undefined : parseInt(statusValue) const create_after = form.getValues('create_after') const create_before = form.getValues('create_before') const res = await listBills({ - page, size, type, status: statusParam, create_after, create_before, + page, size, type, create_after, create_before, }) if (res.success) { @@ -82,7 +79,6 @@ export default function BillsPage(props: BillsPageProps) { resolver: zodResolver(filterSchema), defaultValues: { type: 'all', - status: 'all', }, }) @@ -91,34 +87,6 @@ export default function BillsPage(props: BillsPageProps) { await refresh(1, data.size) } - // 获取类型显示内容 - const getBillTypeText = (type: number) => { - switch (type) { - case 1: - return '充值' - case 2: - return '消费' - case 3: - return '退款' - default: - return '未知' - } - } - - // 获取状态显示内容 - const getBillStatusText = (status: number) => { - switch (status) { - case 1: - return '待支付' - case 2: - return '已完成' - case 3: - return '已取消' - default: - return '未知' - } - } - // ====================== // render // ====================== @@ -136,7 +104,7 @@ export default function BillsPage(props: BillsPageProps) { 账单类型}> {({id, field}) => ( )} - 状态}> - {({id, field}) => ( - - )} -
@@ -243,47 +196,41 @@ export default function BillsPage(props: BillsPageProps) { ), }, { - accessorKey: 'info', header: `账单详情`, cell: ({row}) => ( -
- {row.original.info} - - {row.original.type === 1 && row.original.trade.status === 1 && ( - - - {row.original.resource.pss.type === 1 && `包时`} - {row.original.resource.pss.type === 2 && `包量`} - - - - - {row.original.resource.pss.live / 60 + `分钟`} - - - )} -
- ), + accessorKey: 'info', header: `账单详情`, }, { accessorKey: 'status', header: `状态`, cell: ({row}) => ( <> - {row.original.status === 0 && ( -
- - 未完成 -
- )} - {row.original.status === 1 && ( -
- - 已完成 -
- )} - {row.original.status === 2 && ( -
- - 已作废 -
+ {row.original.trade && ( + row.original.trade.status === 0 ? ( +
+
+ + 订单待支付 + + {row.original.trade.inner_no} + +
+ +
+ ) : row.original.trade.status === 1 ? ( +
+ + 已完成 +
+ ) : row.original.trade.status === 2 ? ( +
+ + 已取消 +
+ ) : row.original.trade.status === 3 ? ( +
+ + 已退款 +
+ ) : ( + - + ) )} ), diff --git a/src/app/admin/resources/page.tsx b/src/app/admin/resources/page.tsx index 1acf8e8..be1b604 100644 --- a/src/app/admin/resources/page.tsx +++ b/src/app/admin/resources/page.tsx @@ -293,7 +293,7 @@ export default function ResourcesPage(props: ResourcesPageProps) { { accessorKey: 'daily_last', header: '最近使用时间', cell: ({row}) => { return ( - isEqual(row.original.pss.daily_last, parse('0001-01-01 00:05:43', 'yyyy-MM-dd HH:mm:ss', new Date())) + format(row.original.pss.daily_last, "yyyy-MM-dd") === "0001-01-01" ? '-' : format(row.original.pss.daily_last, 'yyyy-MM-dd HH:mm') ) diff --git a/src/components/composites/purchase/_client/pay.tsx b/src/components/composites/purchase/_client/pay.tsx index 1dfacf4..b80b78a 100644 --- a/src/components/composites/purchase/_client/pay.tsx +++ b/src/components/composites/purchase/_client/pay.tsx @@ -66,10 +66,14 @@ export default function Pay(props: PayProps) { try { switch (props.method) { case 'alipay': - resp = await createResourceByAlipay(props.resource) + resp = await createResourceByAlipay({ + trade_no: payInfo!.trade_no, + }) break case 'wechat': - resp = await createResourceByWechat(props.resource) + resp = await createResourceByWechat({ + trade_no: payInfo!.trade_no, + }) break case 'balance': resp = await createResourceByBalance(props.resource) diff --git a/src/lib/models.ts b/src/lib/models.ts index ce77700..a3a8647 100644 --- a/src/lib/models.ts +++ b/src/lib/models.ts @@ -70,7 +70,6 @@ export type Bill = { bill_no: string info: string type: number - status: number amount: number created_at: Date updated_at: Date