fix(mining-admin): fix wallet ledger API to match frontend expected format
- Return usdtAvailable, usdtFrozen, pendingUsdt, settleableUsdt, settledTotalUsdt, expiredTotalUsdt instead of old field names - Query SyncedUserWallet table for GREEN_POINTS wallet data - Use miningAccount.availableBalance for pendingUsdt Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c6c875849a
commit
465e398040
|
|
@ -906,7 +906,7 @@ export class UsersService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户钱包流水
|
* 获取用户钱包流水
|
||||||
* TODO: 从 mining-service 同步钱包流水数据
|
* 从 SyncedUserWallet 获取钱包汇总,从 SyncedMiningAccount 获取挖矿余额
|
||||||
*/
|
*/
|
||||||
async getWalletLedger(accountSequence: string, page: number, pageSize: number) {
|
async getWalletLedger(accountSequence: string, page: number, pageSize: number) {
|
||||||
const user = await this.prisma.syncedUser.findUnique({
|
const user = await this.prisma.syncedUser.findUnique({
|
||||||
|
|
@ -918,20 +918,44 @@ export class UsersService {
|
||||||
throw new NotFoundException(`用户 ${accountSequence} 不存在`);
|
throw new NotFoundException(`用户 ${accountSequence} 不存在`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取用户的各类钱包数据
|
||||||
|
const wallets = await this.prisma.syncedUserWallet.findMany({
|
||||||
|
where: { accountSequence },
|
||||||
|
});
|
||||||
|
|
||||||
|
// 按钱包类型分类
|
||||||
|
const walletByType = new Map(wallets.map(w => [w.walletType, w]));
|
||||||
|
const greenPointsWallet = walletByType.get('GREEN_POINTS');
|
||||||
|
const contributionWallet = walletByType.get('CONTRIBUTION');
|
||||||
|
const tokenWallet = walletByType.get('TOKEN_STORAGE');
|
||||||
|
|
||||||
const mining = user.miningAccount;
|
const mining = user.miningAccount;
|
||||||
|
|
||||||
|
// 构建前端期望的钱包汇总格式
|
||||||
|
// usdtAvailable = GREEN_POINTS 钱包的可用余额 (绿积分)
|
||||||
|
// usdtFrozen = GREEN_POINTS 钱包的冻结余额
|
||||||
|
// pendingUsdt = 待领取收益(挖矿余额)
|
||||||
|
// settleableUsdt = 可结算收益
|
||||||
|
// settledTotalUsdt = 已结算收益
|
||||||
|
// expiredTotalUsdt = 过期收益
|
||||||
|
const summary = {
|
||||||
|
usdtAvailable: greenPointsWallet?.balance?.toString() || '0',
|
||||||
|
usdtFrozen: greenPointsWallet?.frozenBalance?.toString() || '0',
|
||||||
|
pendingUsdt: mining?.availableBalance?.toString() || '0', // 挖矿可用余额作为待领取
|
||||||
|
settleableUsdt: '0', // 暂无数据源
|
||||||
|
settledTotalUsdt: greenPointsWallet?.totalInflow?.toString() || '0', // 总流入作为已结算
|
||||||
|
expiredTotalUsdt: '0', // 暂无数据源
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO: 实现钱包流水分页查询
|
||||||
|
// 目前从 SyncedUserWallet 只能获取汇总数据,流水明细需要额外的表
|
||||||
return {
|
return {
|
||||||
summary: {
|
summary,
|
||||||
availableBalance: mining?.availableBalance?.toString() || '0',
|
|
||||||
frozenBalance: mining?.frozenBalance?.toString() || '0',
|
|
||||||
totalMined: mining?.totalMined?.toString() || '0',
|
|
||||||
},
|
|
||||||
items: [],
|
items: [],
|
||||||
total: 0,
|
total: 0,
|
||||||
page,
|
page,
|
||||||
pageSize,
|
pageSize,
|
||||||
totalPages: 0,
|
totalPages: 0,
|
||||||
note: '钱包流水数据需要从 mining-service 同步',
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue