diff --git a/src/actions/batch.ts b/src/actions/batch.ts index 6007310..fce9e34 100644 --- a/src/actions/batch.ts +++ b/src/actions/batch.ts @@ -3,6 +3,11 @@ import {PageRecord} from '@/lib/api' import {Batch} from '@/lib/models/batch' import {callByUser} from './base' -export async function pageBatch(props: {page: number, size: number}) { +export async function pageBatch(props: { + page: number + size: number + time_start?: Date + time_end?: Date + resource_no?: string}) { return callByUser>('/api/batch/page', props) } diff --git a/src/app/admin/bills/page.tsx b/src/app/admin/bills/page.tsx index 7bc8193..9dba1f2 100644 --- a/src/app/admin/bills/page.tsx +++ b/src/app/admin/bills/page.tsx @@ -1,5 +1,5 @@ 'use client' -import {useCallback, useEffect, useState} from 'react' +import {Suspense, useCallback, useEffect, useState} from 'react' import {PageRecord} from '@/lib/api' import {Bill} from '@/lib/models' import {useStatus} from '@/lib/states' @@ -141,158 +141,159 @@ export default function BillsPage(props: BillsPageProps) { - { - await refresh(page, data.size) - }, - onSizeChange: async (size: number) => { - await refresh(data.page, size) - }, - }} - columns={[ - { - accessorKey: 'bill_no', header: `账单编号`, - }, - { - accessorKey: 'info', - header: `账单详情`, - cell: ({row}) => { - const bill = row.original - return ( -
- {/* 类型展示 */} -
- {bill.type === 1 && ( -
- - 消费 -
- )} - {bill.type === 2 && ( -
- - 退款 -
- )} - {bill.type === 3 && ( -
- - 充值 -
- )} -
- - {/* 账单详情 */} -
- {bill.info} -
-
- ) + + { + await refresh(page, data.size) }, - }, - { - accessorKey: 'status', - header: `状态`, - cell: ({row}) => { - const trade = row.original.trade - if (![1, 2, 3, 4, 5].includes(trade?.method)) { + onSizeChange: async (size: number) => { + await refresh(data.page, size) + }, + }} + columns={[ + { + accessorKey: 'bill_no', header: `账单编号`, + }, + { + accessorKey: 'info', + header: `账单详情`, + cell: ({row}) => { + const bill = row.original return (
- - 已完成 + {/* 类型展示 */} +
+ {bill.type === 1 && ( +
+ + 消费 +
+ )} + {bill.type === 2 && ( +
+ + 退款 +
+ )} + {bill.type === 3 && ( +
+ + 充值 +
+ )} +
+ + {/* 账单详情 */} +
+ {bill.info} +
) - } - if (!trade) return - - return ( -
- {trade?.status === 1 ? ( - - ) : trade?.status === 2 ? ( - - ) : trade?.status === 3 ? ( - - ) : null} - - {trade?.status === 1 ? '已完成' - : trade?.status === 2 ? '已取消' - : trade?.status === 3 ? '已退款' : '-'} - -
- ) + }, }, - }, - { - accessorKey: 'amount', - header: '支付信息', - cell: ({row}) => { - const amount = typeof row.original.amount === 'string' - ? parseFloat(row.original.amount) - : row.original.amount || 0 - const trade = row.original.trade - const paymentMethodMap = { - 1: '支付宝*', - 2: '微信*', - 3: '其他', - 4: '支付宝', - 5: '微信', - } - const paymentMethod = trade ? paymentMethodMap[trade.method as keyof typeof paymentMethodMap] || '余额' : '余额' - return ( -
- - {paymentMethod} - - 0 ? 'text-green-500' : 'text-orange-500'}> - ¥{amount.toFixed(2)} - -
- ) + { + accessorKey: 'status', + header: `状态`, + cell: ({row}) => { + const trade = row.original.trade + if (![1, 2, 3, 4, 5].includes(trade?.method)) { + return ( +
+ + 已完成 +
+ ) + } + if (!trade) return - + return ( +
+ {trade?.status === 1 ? ( + + ) : trade?.status === 2 ? ( + + ) : trade?.status === 3 ? ( + + ) : null} + + {trade?.status === 1 ? '已完成' + : trade?.status === 2 ? '已取消' + : trade?.status === 3 ? '已退款' : '-'} + +
+ ) + }, }, - }, - { - accessorKey: 'platform', - header: '支付平台', - cell: ({row}) => { - const trade = row.original.trade - if (!trade) return - - return ( -
- {trade.platform === 1 ? ( - <> - 电脑网站 - - ) : trade.platform === 2 ? ( - <> - 手机网站 - - ) : ( - - - )} -
- ) + { + accessorKey: 'amount', + header: '支付信息', + cell: ({row}) => { + const amount = typeof row.original.amount === 'string' + ? parseFloat(row.original.amount) + : row.original.amount || 0 + const trade = row.original.trade + const paymentMethodMap = { + 1: '支付宝*', + 2: '微信*', + 3: '其他', + 4: '支付宝', + 5: '微信', + } + const paymentMethod = trade ? paymentMethodMap[trade.method as keyof typeof paymentMethodMap] || '余额' : '余额' + return ( +
+ + {paymentMethod} + + 0 ? 'text-green-500' : 'text-orange-500'}> + ¥{amount.toFixed(2)} + +
+ ) + }, }, - }, - { - accessorKey: 'created_at', header: '创建时间', cell: ({row}) => ( - format(new Date(row.original.created_at), 'yyyy-MM-dd HH:mm:ss') - ), - }, - // { - // accessorKey: 'action', header: `操作`, cell: item => ( - //
- // - - //
- // ), - // }, - ]} - /> + { + accessorKey: 'platform', + header: '支付平台', + cell: ({row}) => { + const trade = row.original.trade + if (!trade) return - + return ( +
+ {trade.platform === 1 ? ( + <> + 电脑网站 + + ) : trade.platform === 2 ? ( + <> + 手机网站 + + ) : ( + <> + )} +
+ ) + }, + }, + { + accessorKey: 'created_at', + header: '创建时间', + cell: ({row}) => { + const createdAt = row.original.created_at + if (!createdAt) return + const date = new Date(createdAt) + if (isNaN(date.getTime())) return + return format(date, 'yyyy-MM-dd HH:mm:ss') + }, + }, + ]} + /> +
) } diff --git a/src/app/admin/channels/page.tsx b/src/app/admin/channels/page.tsx index 07629c2..3687921 100644 --- a/src/app/admin/channels/page.tsx +++ b/src/app/admin/channels/page.tsx @@ -93,7 +93,6 @@ export default function ChannelsPage(props: ChannelsPageProps) { // ====================== // render // ====================== - console.log(data.list, 'data.listdata.list') return ( @@ -215,11 +214,35 @@ export default function ChannelsPage(props: ChannelsPageProps) { }, { header: '提取时间', - cell: ({row}) => format(row.original.created_at, 'yyyy-MM-dd HH:mm:ss'), + cell: ({row}) => { + const timeValue = row.original.created_at + if (!timeValue) return
-
+ + try { + const date = new Date(timeValue) + if (isNaN(date.getTime())) return
-
+ return
{format(date, 'yyyy-MM-dd HH:mm:ss')}
+ } + catch { + return
-
+ } + }, }, { header: '过期时间', - cell: ({row}) => format(row.original.expired_at, 'yyyy-MM-dd HH:mm:ss'), + cell: ({row}) => { + const timeValue = row.original.expired_at + if (!timeValue) return
-
+ + try { + const date = new Date(timeValue) + if (isNaN(date.getTime())) return
-
+ return
{format(date, 'yyyy-MM-dd HH:mm:ss')}
+ } + catch { + return
-
+ } + }, }, ]} /> diff --git a/src/app/admin/record/page.tsx b/src/app/admin/record/page.tsx index 0778b99..185f5a5 100644 --- a/src/app/admin/record/page.tsx +++ b/src/app/admin/record/page.tsx @@ -15,6 +15,7 @@ import DatePicker from '@/components/date-picker' import {Button} from '@/components/ui/button' import {EraserIcon, SearchIcon} from 'lucide-react' import {pageBatch} from '@/actions/batch' +import {Input} from '@/components/ui/input' export type RecordPageProps = {} @@ -34,6 +35,7 @@ export default function RecordPage(props: RecordPageProps) { const filterSchema = z.object({ time_start: z.date().optional(), time_end: z.date().optional(), + resource_no: z.string().optional(), }) type FilterSchema = z.infer @@ -42,6 +44,7 @@ export default function RecordPage(props: RecordPageProps) { defaultValues: { time_start: undefined, time_end: undefined, + resource_no: '', }, }) @@ -53,7 +56,9 @@ export default function RecordPage(props: RecordPageProps) { const result = await pageBatch({ page, size, - ...filter, + time_start: filter.time_start, + time_end: filter.time_end, + resource_no: filter.resource_no || undefined, }) if (result.success && result.data) { @@ -88,12 +93,22 @@ export default function RecordPage(props: RecordPageProps) {
+ 套餐编号}> + {({id, field}) => ( + + )} +
- 提取时间 + 过期时间
- name="time_start"> + name="time_start" > {({field}) => ( fetchRecords(1, size), }} columns={[ + { + header: '套餐编号', + accessorKey: 'resource.resource_no', + }, { header: '批次号', cell: ({row}) =>
{row.original.batch_no}
, @@ -174,11 +193,6 @@ export default function RecordPage(props: RecordPageProps) { cell: ({row}) =>
{row.original.count}
, accessorKey: 'count', }, - // { - // header: '资源数量', - // cell: ({row}) =>
{row.original.resource_id}
, - // accessorKey: 'resource_id', - // }, { header: '提取时间', cell: ({row}) => { diff --git a/src/app/admin/resources/_components/list.tsx b/src/app/admin/resources/_components/list.tsx index 537b630..46ad78e 100644 --- a/src/app/admin/resources/_components/list.tsx +++ b/src/app/admin/resources/_components/list.tsx @@ -186,7 +186,7 @@ export default function ResourceList({resourceType}: ResourceListProps) { const live = resourceKey === 'long' ? (row.original as Resource<2>).long.live : (row.original as Resource<1>).short.live - return {isLong ? `${live}小时` : `${live}分钟`} + return {isLong ? `${live}分钟` : `${live}分钟`} }, }, { diff --git a/src/components/composites/extract/index.tsx b/src/components/composites/extract/index.tsx index d4e8f3e..1334068 100644 --- a/src/components/composites/extract/index.tsx +++ b/src/components/composites/extract/index.tsx @@ -73,20 +73,6 @@ export default function Extract(props: ExtractProps) { )} > - {/* - - - 提取IP前需要将本机IP添加到白名单后才可使用 - - - 添加白名单 - - - */} - @@ -516,8 +502,6 @@ function SelectRegion() { const regionType = useWatch({control, name: 'regionType'}) const prov = useWatch({control, name: 'prov'}) const city = useWatch({control, name: 'city'}) - console.log(regionType, 'regionType') - console.log(prov, 'prov', city, 'city') return (
@@ -696,9 +680,9 @@ function name(resource: Resource) { // 短效套餐 switch (resource.short.type) { case 1: - return `短效包时 ${resource.short.live} 分钟` + return `${resource.short?.sku?.name}` case 2: - return `短效包量 ${resource.short.live} 分钟` + return `${resource.short?.sku?.name}` } break @@ -706,9 +690,9 @@ function name(resource: Resource) { // 长效套餐 switch (resource.long.type) { case 1: - return `长效包时 ${resource.long.live} 小时` + return `${resource.long?.sku?.name}` case 2: - return `长效包量 ${resource.long.live} 小时` + return `${resource.long?.sku?.name}` } break } diff --git a/src/components/composites/purchase/shared/side-panel.tsx b/src/components/composites/purchase/shared/side-panel.tsx index a009b85..b18bebf 100644 --- a/src/components/composites/purchase/shared/side-panel.tsx +++ b/src/components/composites/purchase/shared/side-panel.tsx @@ -185,16 +185,14 @@ function usePurchasePrice(profile: User | null, selection: PurchaseSelection) { return } - if (!response.success) { - throw new Error(response.message || '获取价格失败') + if (response.success) { + setPriceData({ + price: response.data.price, + actual: response.data.actual ?? response.data.price ?? '0.00', + discounted: response.data.discounted ?? '0.00', + }) + setIsError(false) } - - setPriceData({ - price: response.data.price, - actual: response.data.actual ?? response.data.price ?? '0.00', - discounted: response.data.discounted ?? '0.00', - }) - setIsError(false) } catch (error) { if (requestId !== requestIdRef.current) { diff --git a/src/lib/models/resource.ts b/src/lib/models/resource.ts index 62dce1c..99b5021 100644 --- a/src/lib/models/resource.ts +++ b/src/lib/models/resource.ts @@ -8,6 +8,11 @@ type ResourceShort = { used: number daily: number last_at?: Date + sku?: sku +} + +type sku = { + name: string } type ResourceLong = { @@ -20,6 +25,7 @@ type ResourceLong = { used: number daily: number last_at?: Date + sku?: sku } export type Resource = {