update users service

This commit is contained in:
2026-04-16 09:50:59 +03:30
parent 44114b2436
commit 36a57db33b
4 changed files with 56 additions and 18 deletions
+12
View File
@@ -15,6 +15,7 @@ import { ResellerType } from '../auth/DTO/verify-reseller-otp.dto';
import { PaginationDto } from '../../common/DTO/pagination.dto';
import { WalletsService } from '../wallets/providers/wallets.service';
import Decimal from 'decimal.js';
import { IsNull } from 'typeorm';
@Injectable()
export class ResellerService {
@@ -186,6 +187,17 @@ export class ResellerService {
if (!user) {
throw new NotFoundException(AuthMessage.USER_NOT_FOUND)
}
const pendingWithdrawRequest = await this.withdrawRequestRepository.findOne({
where: {
user: { id: userId },
paidAt: IsNull()
}
})
if (pendingWithdrawRequest) {
throw new BadRequestException("امکان ایجاد درخواست برداشت جدید نیست")
}
const { balance } = await this.walletsService.getBalance(userId)
if (new Decimal(balance).lessThan(requestedAmount)) {