54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
|
|
/**
|
||
|
|
* 用户钱包 API
|
||
|
|
* OpenAPI: GET /admin/finance/wallet/summary, GET /admin/finance/wallet/page
|
||
|
|
*/
|
||
|
|
import { get } from '@/utils/request';
|
||
|
|
import { USE_MOCK, MOCK_DELAY } from '@/config/mock';
|
||
|
|
import { buildMockWalletPage } from '@/config/mock/walletList';
|
||
|
|
import { buildMockWalletTransactionPage } from '@/config/mock/walletTransactions';
|
||
|
|
import type {
|
||
|
|
WalletQueryParams,
|
||
|
|
WalletSummaryVO,
|
||
|
|
WalletTransactionQueryParams,
|
||
|
|
WalletTransactionVO,
|
||
|
|
PageData,
|
||
|
|
ApiResult,
|
||
|
|
} from './types';
|
||
|
|
|
||
|
|
export type {
|
||
|
|
WalletSummaryVO,
|
||
|
|
WalletQueryParams,
|
||
|
|
WalletTransactionVO,
|
||
|
|
WalletTransactionQueryParams,
|
||
|
|
PageData,
|
||
|
|
ApiResult,
|
||
|
|
} from './types';
|
||
|
|
|
||
|
|
const delay = (ms: number) => new Promise<void>((r) => setTimeout(r, ms));
|
||
|
|
|
||
|
|
/** GET /admin/finance/wallet/summary — 钱包列表分页 */
|
||
|
|
export async function getWalletList(
|
||
|
|
params: WalletQueryParams,
|
||
|
|
): Promise<ApiResult<PageData<WalletSummaryVO>>> {
|
||
|
|
if (USE_MOCK) {
|
||
|
|
await delay(MOCK_DELAY);
|
||
|
|
const page = Number(params.page) || 1;
|
||
|
|
const limit = Number(params.limit) || 10;
|
||
|
|
return { code: 200, msg: 'success', data: buildMockWalletPage(page, limit, params) };
|
||
|
|
}
|
||
|
|
return get('/admin/finance/wallet/summary', params as Record<string, any>);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** GET /admin/finance/wallet/page — 交易明细分页 */
|
||
|
|
export async function getWalletTransactionList(
|
||
|
|
params: WalletTransactionQueryParams,
|
||
|
|
): Promise<ApiResult<PageData<WalletTransactionVO>>> {
|
||
|
|
if (USE_MOCK) {
|
||
|
|
await delay(MOCK_DELAY);
|
||
|
|
const page = Number(params.page) || 1;
|
||
|
|
const limit = Number(params.limit) || 10;
|
||
|
|
return { code: 200, msg: 'success', data: buildMockWalletTransactionPage(page, limit, params) };
|
||
|
|
}
|
||
|
|
return get('/admin/finance/wallet/page', params as Record<string, any>);
|
||
|
|
}
|