price handling
This commit is contained in:
+12
-3
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user