diff --git a/src/api/wallet/index.ts b/src/api/wallet/index.ts index 9d605d5..4714102 100644 --- a/src/api/wallet/index.ts +++ b/src/api/wallet/index.ts @@ -9,6 +9,7 @@ import { buildMockWalletTransactionPage } from '@/config/mock/walletTransactions import type { WalletQueryParams, WalletSummaryVO, + WalletSummaryPageData, WalletTransactionQueryParams, WalletTransactionVO, PageData, @@ -17,6 +18,7 @@ import type { export type { WalletSummaryVO, + WalletSummaryPageData, WalletQueryParams, WalletTransactionVO, WalletTransactionQueryParams, @@ -29,7 +31,7 @@ const delay = (ms: number) => new Promise((r) => setTimeout(r, ms)); /** GET /admin/finance/wallet/summary — 钱包列表分页 */ export async function getWalletList( params: WalletQueryParams, -): Promise>> { +): Promise> { if (USE_MOCK) { await delay(MOCK_DELAY); const page = Number(params.page) || 1; diff --git a/src/api/wallet/types.ts b/src/api/wallet/types.ts index 5f993e9..a0dc2aa 100644 --- a/src/api/wallet/types.ts +++ b/src/api/wallet/types.ts @@ -17,14 +17,25 @@ export interface WalletSummaryVO { frozenAmount: string; /** 累计成功提现金额("0.00"格式) */ withdrawalAmount: string; - /** 汇总行-总余额 */ +} + +/** 钱包汇总扩展数据(与 total 同级) */ +export interface WalletSummaryExData { + /** 总余额 */ totalAmount: string; - /** 汇总行-总冻结金额 */ + /** 总冻结金额 */ totalFrozenAmount: string; - /** 汇总行-总累计提现 */ + /** 总累计提现 */ totalWithdrawalAmount: string; } +/** 钱包列表分页响应 */ +export interface WalletSummaryPageData { + total: number; + list: WalletSummaryVO[]; + exData: WalletSummaryExData; +} + /** 钱包列表查询参数 */ export interface WalletQueryParams { page?: string; diff --git a/src/config/mock/walletList.ts b/src/config/mock/walletList.ts index afd273c..c7b4a5a 100644 --- a/src/config/mock/walletList.ts +++ b/src/config/mock/walletList.ts @@ -2,7 +2,7 @@ * 钱包列表假数据 * 对应接口:GET /admin/finance/wallet/summary */ -import type { WalletSummaryVO, WalletQueryParams, PageData } from '@/api/wallet'; +import type { WalletSummaryVO, WalletQueryParams, WalletSummaryPageData } from '@/api/wallet'; const MOCK_LIST: WalletSummaryVO[] = [ { @@ -12,9 +12,6 @@ const MOCK_LIST: WalletSummaryVO[] = [ amount: '0.00', frozenAmount: '0.00', withdrawalAmount: '0.00', - totalAmount: '0.00', - totalFrozenAmount: '0.00', - totalWithdrawalAmount: '0.00', }, { userId: 1002, @@ -23,9 +20,6 @@ const MOCK_LIST: WalletSummaryVO[] = [ amount: '350.00', frozenAmount: '200.00', withdrawalAmount: '1450.00', - totalAmount: '0.00', - totalFrozenAmount: '0.00', - totalWithdrawalAmount: '0.00', }, { userId: 1003, @@ -34,9 +28,6 @@ const MOCK_LIST: WalletSummaryVO[] = [ amount: '1280.00', frozenAmount: '0.00', withdrawalAmount: '800.00', - totalAmount: '0.00', - totalFrozenAmount: '0.00', - totalWithdrawalAmount: '0.00', }, { userId: 1004, @@ -45,9 +36,6 @@ const MOCK_LIST: WalletSummaryVO[] = [ amount: '560.00', frozenAmount: '100.00', withdrawalAmount: '200.00', - totalAmount: '0.00', - totalFrozenAmount: '0.00', - totalWithdrawalAmount: '0.00', }, { userId: 1005, @@ -56,9 +44,6 @@ const MOCK_LIST: WalletSummaryVO[] = [ amount: '4200.00', frozenAmount: '1500.00', withdrawalAmount: '5600.00', - totalAmount: '0.00', - totalFrozenAmount: '0.00', - totalWithdrawalAmount: '0.00', }, { userId: 1006, @@ -67,9 +52,6 @@ const MOCK_LIST: WalletSummaryVO[] = [ amount: '880.00', frozenAmount: '0.00', withdrawalAmount: '300.00', - totalAmount: '0.00', - totalFrozenAmount: '0.00', - totalWithdrawalAmount: '0.00', }, { userId: 1007, @@ -78,9 +60,6 @@ const MOCK_LIST: WalletSummaryVO[] = [ amount: '2100.00', frozenAmount: '800.00', withdrawalAmount: '3200.00', - totalAmount: '0.00', - totalFrozenAmount: '0.00', - totalWithdrawalAmount: '0.00', }, { userId: 1008, @@ -89,9 +68,6 @@ const MOCK_LIST: WalletSummaryVO[] = [ amount: '650.00', frozenAmount: '0.00', withdrawalAmount: '450.00', - totalAmount: '0.00', - totalFrozenAmount: '0.00', - totalWithdrawalAmount: '0.00', }, { userId: 1009, @@ -100,9 +76,6 @@ const MOCK_LIST: WalletSummaryVO[] = [ amount: '980.00', frozenAmount: '200.00', withdrawalAmount: '1200.00', - totalAmount: '0.00', - totalFrozenAmount: '0.00', - totalWithdrawalAmount: '0.00', }, { userId: 1010, @@ -111,9 +84,6 @@ const MOCK_LIST: WalletSummaryVO[] = [ amount: '320.00', frozenAmount: '50.00', withdrawalAmount: '100.00', - totalAmount: '0.00', - totalFrozenAmount: '0.00', - totalWithdrawalAmount: '0.00', }, { userId: 1011, @@ -122,9 +92,6 @@ const MOCK_LIST: WalletSummaryVO[] = [ amount: '5800.00', frozenAmount: '0.00', withdrawalAmount: '2000.00', - totalAmount: '0.00', - totalFrozenAmount: '0.00', - totalWithdrawalAmount: '0.00', }, { userId: 1012, @@ -133,14 +100,10 @@ const MOCK_LIST: WalletSummaryVO[] = [ amount: '75.00', frozenAmount: '0.00', withdrawalAmount: '75.00', - totalAmount: '0.00', - totalFrozenAmount: '0.00', - totalWithdrawalAmount: '0.00', }, ]; -/** 计算汇总值 */ -function computeSummary(list: WalletSummaryVO[]) { +function computeExData(list: WalletSummaryVO[]) { const totalAmount = list.reduce((s, i) => s + Number(i.amount || 0), 0).toFixed(2); const totalFrozenAmount = list.reduce((s, i) => s + Number(i.frozenAmount || 0), 0).toFixed(2); const totalWithdrawalAmount = list @@ -153,7 +116,7 @@ export function buildMockWalletPage( page: number, limit: number, params: WalletQueryParams, -): PageData { +): WalletSummaryPageData { let filtered = [...MOCK_LIST]; if (params.nickname) { @@ -171,15 +134,10 @@ export function buildMockWalletPage( const total = filtered.length; const start = (page - 1) * limit; - const pageList = filtered.slice(start, start + limit); - // 将汇总值写入每条记录(方便前端提取统计卡数据) - const summary = computeSummary(filtered); - for (const item of pageList) { - item.totalAmount = summary.totalAmount; - item.totalFrozenAmount = summary.totalFrozenAmount; - item.totalWithdrawalAmount = summary.totalWithdrawalAmount; - } - - return { total, list: pageList }; + return { + total, + list: filtered.slice(start, start + limit), + exData: computeExData(filtered), + }; } diff --git a/src/pages/events/banner/model/useBannerModel.ts b/src/pages/events/banner/model/useBannerModel.ts index 132c633..4f96cf1 100644 --- a/src/pages/events/banner/model/useBannerModel.ts +++ b/src/pages/events/banner/model/useBannerModel.ts @@ -64,13 +64,24 @@ export function useBannerModel() { { delay: 300 }, ); + // ===== 构建 API 查询参数 ===== + const buildQueryParams = (): BannerListQueryParams => { + const params: BannerListQueryParams = {}; + if (filterForm.title.trim()) { + params.title = filterForm.title.trim(); + } + if (filterForm.status) { + params.status = filterForm.status; + } + return params; + }; + // ===== 数据请求(API 返回全量,前端分页) ===== const { data, loading, run: fetchList, } = useRequest(() => getBannerList(buildQueryParams()), { - refreshDeps: [], formatResult: (res) => (res.code == 200 ? res.data : []), }); @@ -111,18 +122,6 @@ export function useBannerModel() { { title: '状态', dataIndex: 'status', key: 'status', width: 100, align: 'center' as const }, ]; - // ===== 构建 API 查询参数 ===== - const buildQueryParams = (): BannerListQueryParams => { - const params: BannerListQueryParams = {}; - if (filterForm.title.trim()) { - params.title = filterForm.title.trim(); - } - if (filterForm.status) { - params.status = filterForm.status; - } - return params; - }; - // ===== 计算属性 ===== const hasFilter = computed(() => { return debouncedTitle.value.trim() !== '' || filterForm.status !== ''; diff --git a/src/pages/finance/wallet/model/services.ts b/src/pages/finance/wallet/model/services.ts index 9bcce65..13d90bd 100644 --- a/src/pages/finance/wallet/model/services.ts +++ b/src/pages/finance/wallet/model/services.ts @@ -9,6 +9,7 @@ import { buildMockWalletTransactionPage } from '@/config/mock/walletTransactions import type { WalletQueryParams, WalletSummaryVO, + WalletSummaryPageData, WalletTransactionQueryParams, WalletTransactionVO, PageData, @@ -17,6 +18,7 @@ import type { export type { WalletSummaryVO, + WalletSummaryPageData, WalletQueryParams, WalletTransactionVO, WalletTransactionQueryParams, @@ -39,7 +41,7 @@ const delay = (ms: number) => new Promise((r) => setTimeout(r, ms)); /** 钱包列表分页 */ export async function getWalletList( params: WalletQueryParams, -): Promise>> { +): Promise> { if (USE_MOCK) { await delay(MOCK_DELAY); const page = Number(params.page) || 1; diff --git a/src/pages/finance/wallet/model/useWalletModel.ts b/src/pages/finance/wallet/model/useWalletModel.ts index f98661e..9a63da1 100644 --- a/src/pages/finance/wallet/model/useWalletModel.ts +++ b/src/pages/finance/wallet/model/useWalletModel.ts @@ -102,15 +102,12 @@ export function useWalletModel() { const listData = computed(() => (data.value as any)?.data); const dataSource = computed(() => listData.value?.list || []); - // 汇总:从第一条记录提取 - const summary = computed(() => { - const first = dataSource.value?.[0] as any; - return { - totalBalance: first?.totalAmount ?? '0.00', - frozenAmount: first?.totalFrozenAmount ?? '0.00', - totalWithdraw: first?.totalWithdrawalAmount ?? '0.00', - }; - }); + // 汇总:从 exData 派生(与 list 同级) + const summary = computed(() => ({ + totalBalance: listData.value?.exData?.totalAmount ?? '0.00', + frozenAmount: listData.value?.exData?.totalFrozenAmount ?? '0.00', + totalWithdraw: listData.value?.exData?.totalWithdrawalAmount ?? '0.00', + })); // 同步 total 到 pagination useEffect(() => { diff --git a/src/pages/finance/withdraw/index.tsx b/src/pages/finance/withdraw/index.tsx index bae8d92..c21552c 100644 --- a/src/pages/finance/withdraw/index.tsx +++ b/src/pages/finance/withdraw/index.tsx @@ -31,7 +31,7 @@ function renderBodyCell({ } if (column.key === 'action') { // auditStatus=0(待审核)→ 显示「审核」,其他 → 显示「查看」 - if (canAudit && record.auditStatus === 0) { + if (canAudit && record.auditStatus == 0) { return (