fix: 处理余额方面问题与banner页面不自动加载问题

This commit is contained in:
ZhuRui
2026-08-05 16:28:44 +08:00
parent b3458fd4b8
commit 8951733a2d
7 changed files with 47 additions and 78 deletions
+8 -50
View File
@@ -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<WalletSummaryVO> {
): 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),
};
}