update users service
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user