This commit is contained in:
2026-03-09 11:38:43 +03:30
commit 5fda2d6d8c
339 changed files with 186841 additions and 0 deletions
@@ -0,0 +1,21 @@
import { Injectable } from '@nestjs/common';
import { EntityManager, EntityRepository } from '@mikro-orm/postgresql';
import { WalletTransaction } from '../entities/wallet-transaction.entity';
@Injectable()
export class WalletTransactionRepository extends EntityRepository<WalletTransaction> {
constructor(readonly em: EntityManager) {
super(em, WalletTransaction);
}
async getCurrentWalletBalance(userId: string, restaurantId: string): Promise<number> {
const walletTransaction = await this.em.findOne(
WalletTransaction,
{
user: { id: userId },
restaurant: { id: restaurantId },
},
{ orderBy: { createdAt: 'desc' } },
);
return walletTransaction?.balance || 0;
}
}