changes of boursemes

This commit is contained in:
2026-06-01 17:19:45 +03:30
parent b0dfe51239
commit f4b98576f5
9 changed files with 272 additions and 135 deletions
+3 -2
View File
@@ -31,6 +31,7 @@ export function inputLenRules(len: number, title?: string) {
import {computed, ref} from 'vue'
import type {Rule} from 'ant-design-vue/es/form'
import {useWalletStore} from "@/store/walletStore";
import { isCashLikeDealMethod } from '@/utils/productDealMethod'
export const mobileValidation = (title?: string) => {
return {len: 11, message: `شماره همراه باید 11 رقم باشد`}
@@ -145,13 +146,13 @@ const checkNumber = async (_rule: Rule, value: number) => {
return Promise.reject('استفاده از اعداد اعشاری مجاز نمی باشد')
}
if (isBuyP){
if (!walletCash?.walletInfo?.cash && methodP == 'cash'){
if (!walletCash?.walletInfo?.cash && isCashLikeDealMethod(methodP)){
return Promise.reject('موجودی کیف پول ناکافی است')
}
if (!walletCash?.walletInfo?.gold && methodP == 'gold'){
return Promise.reject('موجودی کیف طلا ناکافی است')
}
if (priceP * value > walletCash?.walletInfo?.cash && methodP == 'cash')
if (priceP * value > walletCash?.walletInfo?.cash && isCashLikeDealMethod(methodP))
return Promise.reject('موجودی کیف پول ناکافی است')
if (amountP * value > walletCash?.walletInfo?.gold && methodP == 'gold')
return Promise.reject('موجودی کیف طلا ناکافی است')
+68
View File
@@ -0,0 +1,68 @@
import type { SelectItem } from '@/models/SelectItem'
import { isBoursecuProject } from '@/utils/config'
export const BOURSECU_GROUP_MAFTOL = 'مفتول مس'
export const BOURSECU_GROUP_KATAD = 'کاتد مس'
export const BOURSECU_GROUP_ABSHODE = 'آبشده'
const DEFAULT_TYPE_DEAL: SelectItem[] = [
{ value: 'نقدی', key: 'cash' },
{ value: 'طلایی', key: 'gold' },
]
const MAFTOL_TYPE_DEAL: SelectItem[] = [
{ value: 'کاتد', key: 'katod' },
{ value: 'نقدی', key: 'cash' },
]
const GOLD_ONLY_TYPE_DEAL: SelectItem[] = [
{ value: 'طلایی', key: 'gold' },
]
export function normalizeProductGroupType(groupType?: string | null) {
return (groupType ?? '').trim()
}
export function isBoursecuDealProductGroup(groupType?: string | null) {
if (!isBoursecuProject()) {
return false
}
const group = normalizeProductGroupType(groupType)
return group === BOURSECU_GROUP_MAFTOL
|| group === BOURSECU_GROUP_KATAD
|| group === BOURSECU_GROUP_ABSHODE
}
export function isMaftolMesGroup(groupType?: string | null) {
return normalizeProductGroupType(groupType) === BOURSECU_GROUP_MAFTOL
}
export function isGoldOnlyDealGroup(groupType?: string | null) {
const group = normalizeProductGroupType(groupType)
return group === BOURSECU_GROUP_KATAD || group === BOURSECU_GROUP_ABSHODE
}
export function getProductDealMethodOptions(groupType?: string | null): SelectItem[] {
if (!isBoursecuProject()) {
return DEFAULT_TYPE_DEAL
}
if (isMaftolMesGroup(groupType)) {
return MAFTOL_TYPE_DEAL
}
if (isGoldOnlyDealGroup(groupType)) {
return GOLD_ONLY_TYPE_DEAL
}
return DEFAULT_TYPE_DEAL
}
export function getDefaultProductDealMethod(groupType?: string | null) {
return getProductDealMethodOptions(groupType)[0]?.key ?? 'cash'
}
export function isCashLikeDealMethod(method?: string | null) {
return method === 'cash' || method === 'katod'
}