price handling

This commit is contained in:
2026-06-22 21:10:25 +03:30
parent 9d11616ec7
commit bfc4bec4cd
9 changed files with 388 additions and 50 deletions
+12 -3
View File
@@ -151,6 +151,7 @@ let amountP =0
let isBuyP=true
let NumP=0
let groupTypeP: string | undefined
let meltedBalanceP = 0
const checkNumber = async (_rule: Rule, value: number) => {
@@ -165,12 +166,12 @@ if (isBuyP){
if (!availableCash && isCashLikeDealMethod(methodP)){
return Promise.reject(getInsufficientCashWalletMessage(groupTypeP))
}
if (!walletCash?.walletInfo?.gold && isMainMetalWalletDealMethod(methodP)){
if (!meltedBalanceP && isMainMetalWalletDealMethod(methodP)){
return Promise.reject(getInsufficientGoldWalletMessage(groupTypeP, methodP))
}
if (priceP * value > availableCash && isCashLikeDealMethod(methodP))
return Promise.reject(getInsufficientCashWalletMessage(groupTypeP))
if (amountP * value > walletCash?.walletInfo?.gold && isMainMetalWalletDealMethod(methodP))
if (amountP * value > meltedBalanceP && isMainMetalWalletDealMethod(methodP))
return Promise.reject(getInsufficientGoldWalletMessage(groupTypeP, methodP))
else
return Promise.resolve();
@@ -182,12 +183,20 @@ if (isBuyP){
}
}
export const justNumber2 = (price: number, method?: string , amount?:number ,isBuy?:boolean, groupType?: string) => {
export const justNumber2 = (
price: number,
method?: string,
amount?: number,
isBuy?: boolean,
groupType?: string,
meltedBalance?: number,
) => {
priceP = price
methodP = method
amountP=amount
isBuyP=isBuy
groupTypeP = groupType
meltedBalanceP = meltedBalance ?? 0
return {
required: true,
validator: checkNumber,