fix(wallet-service): 修复提现订单查询使用 userId 的问题

将提现订单查询从 userId 改为使用 accountSequence:
- getWithdrawals: 使用 findByAccountSequence 替代 findByUserId
- getFiatWithdrawals: 使用 findByAccountSequence 替代 findByUserId
- 新增 withdrawal-order.repository 的 findByAccountSequence 方法

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-08 11:24:31 -08:00
parent 217be89c43
commit 641612a5d0
6 changed files with 22 additions and 6 deletions

View File

@ -103,7 +103,7 @@ export class FiatWithdrawalController {
async getFiatWithdrawals( async getFiatWithdrawals(
@CurrentUser() user: CurrentUserPayload, @CurrentUser() user: CurrentUserPayload,
): Promise<FiatWithdrawalListItemDTO[]> { ): Promise<FiatWithdrawalListItemDTO[]> {
return this.fiatWithdrawalService.getFiatWithdrawals(user.userId); return this.fiatWithdrawalService.getFiatWithdrawals(user.accountSequence);
} }
/** /**

View File

@ -132,7 +132,7 @@ export class WalletController {
async getWithdrawals( async getWithdrawals(
@CurrentUser() user: CurrentUserPayload, @CurrentUser() user: CurrentUserPayload,
): Promise<WithdrawalListItemDTO[]> { ): Promise<WithdrawalListItemDTO[]> {
return this.walletService.getWithdrawals(user.userId); return this.walletService.getWithdrawals(user.accountSequence);
} }
@Get('pending-rewards') @Get('pending-rewards')

View File

@ -325,8 +325,9 @@ export class FiatWithdrawalApplicationService {
/** /**
* *
*/ */
async getFiatWithdrawals(userId: string): Promise<FiatWithdrawalListItemDTO[]> { async getFiatWithdrawals(accountSequence: string): Promise<FiatWithdrawalListItemDTO[]> {
const orders = await this.fiatWithdrawalRepo.findByUserId(BigInt(userId)); // 使用 accountSequence 查询法币提现订单(废弃 userId 查询)
const orders = await this.fiatWithdrawalRepo.findByAccountSequence(accountSequence);
return orders.map(order => this.toListItemDTO(order)); return orders.map(order => this.toListItemDTO(order));
} }

View File

@ -1754,7 +1754,7 @@ export class WalletApplicationService {
/** /**
* *
*/ */
async getWithdrawals(userId: string): Promise<Array<{ async getWithdrawals(accountSequence: string): Promise<Array<{
orderNo: string; orderNo: string;
amount: number; amount: number;
fee: number; fee: number;
@ -1765,7 +1765,8 @@ export class WalletApplicationService {
status: string; status: string;
createdAt: string; createdAt: string;
}>> { }>> {
const orders = await this.withdrawalRepo.findByUserId(BigInt(userId)); // 使用 accountSequence 查询提现订单(废弃 userId 查询)
const orders = await this.withdrawalRepo.findByAccountSequence(accountSequence);
return orders.map(order => ({ return orders.map(order => ({
orderNo: order.orderNo, orderNo: order.orderNo,
amount: order.amount.value, amount: order.amount.value,

View File

@ -7,6 +7,7 @@ export interface IWithdrawalOrderRepository {
findById(orderId: bigint): Promise<WithdrawalOrder | null>; findById(orderId: bigint): Promise<WithdrawalOrder | null>;
findByOrderNo(orderNo: string): Promise<WithdrawalOrder | null>; findByOrderNo(orderNo: string): Promise<WithdrawalOrder | null>;
findByUserId(userId: bigint, status?: WithdrawalStatus): Promise<WithdrawalOrder[]>; findByUserId(userId: bigint, status?: WithdrawalStatus): Promise<WithdrawalOrder[]>;
findByAccountSequence(accountSequence: string, status?: WithdrawalStatus): Promise<WithdrawalOrder[]>;
findPendingOrders(): Promise<WithdrawalOrder[]>; findPendingOrders(): Promise<WithdrawalOrder[]>;
findFrozenOrders(): Promise<WithdrawalOrder[]>; findFrozenOrders(): Promise<WithdrawalOrder[]>;
findBroadcastedOrders(): Promise<WithdrawalOrder[]>; findBroadcastedOrders(): Promise<WithdrawalOrder[]>;

View File

@ -74,6 +74,19 @@ export class WithdrawalOrderRepositoryImpl implements IWithdrawalOrderRepository
return records.map(r => this.toDomain(r)); return records.map(r => this.toDomain(r));
} }
async findByAccountSequence(accountSequence: string, status?: WithdrawalStatus): Promise<WithdrawalOrder[]> {
const where: Record<string, unknown> = { accountSequence };
if (status) {
where.status = status;
}
const records = await this.prisma.withdrawalOrder.findMany({
where,
orderBy: { createdAt: 'desc' },
});
return records.map(r => this.toDomain(r));
}
async findPendingOrders(): Promise<WithdrawalOrder[]> { async findPendingOrders(): Promise<WithdrawalOrder[]> {
const records = await this.prisma.withdrawalOrder.findMany({ const records = await this.prisma.withdrawalOrder.findMany({
where: { status: WithdrawalStatus.PENDING }, where: { status: WithdrawalStatus.PENDING },