This commit is contained in:
2025-12-21 17:22:27 +03:30
parent 80fe9168b6
commit 7fc6918ded
11 changed files with 160 additions and 70 deletions
+16 -12
View File
@@ -135,6 +135,7 @@ let methodP = 'cash'
let amountP = 0
let isBuyP = true
let NumP = 0
let gatewayP = false
const checkNumber = async (_rule: Rule, value: number) => {
@@ -145,18 +146,20 @@ const checkNumber = async (_rule: Rule, value: number) => {
return Promise.reject('استفاده از اعداد اعشاری مجاز نمی باشد')
}
if (isBuyP) {
if (!walletCash?.walletInfo?.cash && methodP == 'cash') {
return Promise.reject('موجودی کیف پول ناکافی است')
// Skip wallet balance check if gateway is enabled
if (!gatewayP) {
if (!walletCash?.walletInfo?.cash && methodP == 'cash') {
return Promise.reject('موجودی کیف پول ناکافی است')
}
if (!walletCash?.walletInfo?.gold && methodP == 'gold') {
return Promise.reject('موجودی کیف طلا ناکافی است')
}
if (priceP * value > walletCash?.walletInfo?.cash && methodP == 'cash')
return Promise.reject('موجودی کیف پول ناکافی است')
if (amountP * value > walletCash?.walletInfo?.gold && methodP == 'gold')
return Promise.reject('موجودی کیف طلا ناکافی است')
}
if (!walletCash?.walletInfo?.gold && methodP == 'gold') {
return Promise.reject('موجودی کیف طلا ناکافی است')
}
if (priceP * value > walletCash?.walletInfo?.cash && methodP == 'cash')
return Promise.reject('موجودی کیف پول ناکافی است')
if (amountP * value > walletCash?.walletInfo?.gold && methodP == 'gold')
return Promise.reject('موجودی کیف طلا ناکافی است')
else
return Promise.resolve()
return Promise.resolve()
} else {
if (value > NumP)
return Promise.reject('موجودی محصول ناکافی است')
@@ -165,11 +168,12 @@ const checkNumber = async (_rule: Rule, value: number) => {
}
}
export const justNumber2 = (price: number, method?: string, amount?: number, isBuy?: boolean) => {
export const justNumber2 = (price: number, method?: string, amount?: number, isBuy?: boolean, gateway?: boolean) => {
priceP = price
methodP = method
amountP = amount
isBuyP = isBuy
gatewayP = gateway ?? false
return {
required: true,
validator: checkNumber,