From 198f0a164bb847ee72c9b88df5e9c3fe1afea928 Mon Sep 17 00:00:00 2001 From: safavimohadeseh78 Date: Wed, 3 Jun 2026 19:54:23 +0330 Subject: [PATCH] changes of boursecu --- components.d.ts | 13 ++++ src/models/wallet.ts | 4 ++ src/utils/inputRules.ts | 14 ++-- src/utils/productDealMethod.ts | 72 +++++++++++++++++-- src/views/base/copper&silver/index.vue | 5 +- src/views/base/fund/index.vue | 35 +++++++++ src/views/base/fund/info/index.vue | 3 +- src/views/base/gold/index.vue | 5 +- .../base/products/components/DealProduct.vue | 24 +++++-- .../base/transactions/components/Item.vue | 7 +- src/views/base/wallet/components/Item.vue | 7 +- src/views/base/wallet/index.vue | 7 +- 12 files changed, 165 insertions(+), 31 deletions(-) diff --git a/components.d.ts b/components.d.ts index 1c2a547..2da2181 100644 --- a/components.d.ts +++ b/components.d.ts @@ -8,13 +8,24 @@ export {} declare module 'vue' { export interface GlobalComponents { AButton: typeof import('ant-design-vue/es')['Button'] + ADivider: typeof import('ant-design-vue/es')['Divider'] AForm: typeof import('ant-design-vue/es')['Form'] AFormItem: typeof import('ant-design-vue/es')['FormItem'] + AInput: typeof import('ant-design-vue/es')['Input'] + AInputPassword: typeof import('ant-design-vue/es')['InputPassword'] + AModal: typeof import('ant-design-vue/es')['Modal'] ARadio: typeof import('ant-design-vue/es')['Radio'] ARadioButton: typeof import('ant-design-vue/es')['RadioButton'] ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup'] + ASelect: typeof import('ant-design-vue/es')['Select'] + ASelectOption: typeof import('ant-design-vue/es')['SelectOption'] ASlider: typeof import('ant-design-vue/es')['Slider'] ASpin: typeof import('ant-design-vue/es')['Spin'] + ASwitch: typeof import('ant-design-vue/es')['Switch'] + ATag: typeof import('ant-design-vue/es')['Tag'] + ATextarea: typeof import('ant-design-vue/es')['Textarea'] + ATooltip: typeof import('ant-design-vue/es')['Tooltip'] + AUpload: typeof import('ant-design-vue/es')['Upload'] BaseDatePicker: typeof import('./src/components/BasicPacks/BaseDatePicker/src/BaseDatePicker.vue')['default'] Basic: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/basic.vue')['default'] BasicActionSheet: typeof import('./src/components/BasicPacks/BasicActionSheet.vue')['default'] @@ -56,6 +67,8 @@ declare module 'vue' { Text: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/text.vue')['default'] Time: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/time.vue')['default'] TransactionSkeleton: typeof import('./src/components/TransactionSkeleton.vue')['default'] + VanActionSheet: typeof import('vant/es')['ActionSheet'] VanDialog: typeof import('vant/es')['Dialog'] + VanField: typeof import('vant/es')['Field'] } } diff --git a/src/models/wallet.ts b/src/models/wallet.ts index 25b5405..b1e8c6a 100644 --- a/src/models/wallet.ts +++ b/src/models/wallet.ts @@ -35,6 +35,10 @@ export interface Wallet { count_copper: number count_product: number count_cash_total: number + /** boursecu: موجودی دارایی کاتد مس (کیلوگرم) — API field: count_katod_mes */ + count_katod_mes?: number + /** boursecu: موجودی دارایی مفتول مس (کیلوگرم) */ + count_maftol_mes?: number } export interface Wallets { cash : number diff --git a/src/utils/inputRules.ts b/src/utils/inputRules.ts index e290d62..238f928 100644 --- a/src/utils/inputRules.ts +++ b/src/utils/inputRules.ts @@ -31,7 +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' +import { isCashLikeDealMethod, getInsufficientCashWalletMessage, getInsufficientGoldWalletMessage } from '@/utils/productDealMethod' export const mobileValidation = (title?: string) => { return {len: 11, message: `شماره همراه باید 11 رقم باشد`} @@ -136,6 +136,7 @@ let methodP = 'cash' let amountP =0 let isBuyP=true let NumP=0 +let groupTypeP: string | undefined const checkNumber = async (_rule: Rule, value: number) => { @@ -147,15 +148,15 @@ const checkNumber = async (_rule: Rule, value: number) => { } if (isBuyP){ if (!walletCash?.walletInfo?.cash && isCashLikeDealMethod(methodP)){ - return Promise.reject('موجودی کیف پول ناکافی است') + return Promise.reject(getInsufficientCashWalletMessage(groupTypeP)) } if (!walletCash?.walletInfo?.gold && methodP == 'gold'){ - return Promise.reject('موجودی کیف طلا ناکافی است') + return Promise.reject(getInsufficientGoldWalletMessage(groupTypeP)) } if (priceP * value > walletCash?.walletInfo?.cash && isCashLikeDealMethod(methodP)) - return Promise.reject('موجودی کیف پول ناکافی است') + return Promise.reject(getInsufficientCashWalletMessage(groupTypeP)) if (amountP * value > walletCash?.walletInfo?.gold && methodP == 'gold') - return Promise.reject('موجودی کیف طلا ناکافی است') + return Promise.reject(getInsufficientGoldWalletMessage(groupTypeP)) else return Promise.resolve(); }else { @@ -166,11 +167,12 @@ if (isBuyP){ } } -export const justNumber2 = (price: number, method?: string , amount?:number ,isBuy?:boolean) => { +export const justNumber2 = (price: number, method?: string , amount?:number ,isBuy?:boolean, groupType?: string) => { priceP = price methodP = method amountP=amount isBuyP=isBuy + groupTypeP = groupType return { required: true, validator: checkNumber, diff --git a/src/utils/productDealMethod.ts b/src/utils/productDealMethod.ts index 1ea7e05..b9215d0 100644 --- a/src/utils/productDealMethod.ts +++ b/src/utils/productDealMethod.ts @@ -2,16 +2,24 @@ 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_KATOD = 'کاتد مس' export const BOURSECU_GROUP_ABSHODE = 'آبشده' +export const BOURSECU_ASSET_LABEL_KATOD = 'دارایی کاتد مس' +export const BOURSECU_ASSET_LABEL_MAFTOL = 'دارایی مفتول مس' +export const BOURSECU_ASSET_LABEL_GOLD = 'دارایی طلایی' + const DEFAULT_TYPE_DEAL: SelectItem[] = [ { value: 'نقدی', key: 'cash' }, { value: 'طلایی', key: 'gold' }, ] const MAFTOL_TYPE_DEAL: SelectItem[] = [ - { value: 'کاتد', key: 'katod' }, + { value: BOURSECU_GROUP_KATOD, key: 'katod' }, + { value: 'نقدی', key: 'cash' }, +] + +const CASH_ONLY_TYPE_DEAL: SelectItem[] = [ { value: 'نقدی', key: 'cash' }, ] @@ -30,7 +38,7 @@ export function isBoursecuDealProductGroup(groupType?: string | null) { const group = normalizeProductGroupType(groupType) return group === BOURSECU_GROUP_MAFTOL - || group === BOURSECU_GROUP_KATAD + || group === BOURSECU_GROUP_KATOD || group === BOURSECU_GROUP_ABSHODE } @@ -38,9 +46,12 @@ export function isMaftolMesGroup(groupType?: string | null) { return normalizeProductGroupType(groupType) === BOURSECU_GROUP_MAFTOL } +export function isKatodMesGroup(groupType?: string | null) { + return normalizeProductGroupType(groupType) === BOURSECU_GROUP_KATOD +} + export function isGoldOnlyDealGroup(groupType?: string | null) { - const group = normalizeProductGroupType(groupType) - return group === BOURSECU_GROUP_KATAD || group === BOURSECU_GROUP_ABSHODE + return normalizeProductGroupType(groupType) === BOURSECU_GROUP_ABSHODE } export function getProductDealMethodOptions(groupType?: string | null): SelectItem[] { @@ -52,6 +63,10 @@ export function getProductDealMethodOptions(groupType?: string | null): SelectIt return MAFTOL_TYPE_DEAL } + if (isKatodMesGroup(groupType)) { + return CASH_ONLY_TYPE_DEAL + } + if (isGoldOnlyDealGroup(groupType)) { return GOLD_ONLY_TYPE_DEAL } @@ -66,3 +81,50 @@ export function getDefaultProductDealMethod(groupType?: string | null) { export function isCashLikeDealMethod(method?: string | null) { return method === 'cash' || method === 'katod' } + +export const BOURSECU_WALLET_LABEL_GENERIC = 'موجودی کیف' + +export function getGoldWalletLabel(groupType?: string | null) { + if (!isBoursecuProject()) return 'موجودی کیف طلا' + + const group = normalizeProductGroupType(groupType) + if (group === BOURSECU_GROUP_KATOD) return `موجودی کیف ${BOURSECU_GROUP_KATOD}` + if (group === BOURSECU_GROUP_MAFTOL) return `موجودی کیف ${BOURSECU_GROUP_MAFTOL}` + if (group === BOURSECU_GROUP_ABSHODE) return 'موجودی کیف طلا' + + return BOURSECU_WALLET_LABEL_GENERIC +} + +export function getCashWalletLabel(groupType?: string | null) { + if (!isBoursecuProject()) return 'موجودی کیف پول' + + const group = normalizeProductGroupType(groupType) + if (group === BOURSECU_GROUP_KATOD) return `موجودی کیف ${BOURSECU_GROUP_KATOD}` + if (group === BOURSECU_GROUP_MAFTOL) return `موجودی کیف ${BOURSECU_GROUP_MAFTOL}` + + return BOURSECU_WALLET_LABEL_GENERIC +} + +export function getWeightUnit() { + return isBoursecuProject() ? 'کیلوگرم' : 'گرم' +} + +export function formatBoursecuAssetAmount(amount?: number | null) { + return `${amount ?? 0}${getWeightUnit()}` +} + +export function formatGoldWalletBalanceText(gold: number, groupType?: string | null) { + return `${getGoldWalletLabel(groupType)}: ${gold} ${getWeightUnit()}` +} + +export function formatCashWalletBalanceText(cashFormatted: string | number, groupType?: string | null) { + return `${getCashWalletLabel(groupType)}: ${cashFormatted} ریال` +} + +export function getInsufficientGoldWalletMessage(groupType?: string | null) { + return `${getGoldWalletLabel(groupType)} ناکافی است` +} + +export function getInsufficientCashWalletMessage(groupType?: string | null) { + return `${getCashWalletLabel(groupType)} ناکافی است` +} diff --git a/src/views/base/copper&silver/index.vue b/src/views/base/copper&silver/index.vue index 1ddafd7..b3f8988 100644 --- a/src/views/base/copper&silver/index.vue +++ b/src/views/base/copper&silver/index.vue @@ -62,13 +62,13 @@
-
{{ `موجودی کیف طلا: ${walletStore?.walletInfo?.gold ?? 0} گرم` }}
+
{{ formatGoldWalletBalanceText(walletStore?.walletInfo?.gold ?? 0, props?.ProductItem?.group_type) }}
- {{ `موجودی کیف پول: ${usePriceWithoutType(walletStore?.walletInfo?.cash ?? 0)} ریال` }} + {{ formatCashWalletBalanceText(usePriceWithoutType(walletStore?.walletInfo?.cash ?? 0), props?.ProductItem?.group_type) }}
@@ -237,6 +237,7 @@ import type { Product } from '@/models/products' import { useFundUserStore } from '@/store/fundStore' import {useConfigStore} from "@/store/configStore"; import { calcFeeInGrams } from '@/utils/serviceFee' +import { formatCashWalletBalanceText, formatGoldWalletBalanceText } from '@/utils/productDealMethod' const infoVisible = ref(false) const walletStore = useWalletStore() diff --git a/src/views/base/fund/index.vue b/src/views/base/fund/index.vue index 1e4bafe..f65a09a 100644 --- a/src/views/base/fund/index.vue +++ b/src/views/base/fund/index.vue @@ -10,6 +10,33 @@
موجودی دارایی ها
+ +
@@ -81,6 +109,13 @@ import type { User } from '@/models/login' import {usePriceWithoutType} from "../../../utils/usePrice"; import {useWalletStore} from "@/store/walletStore"; import {useConfigStore} from "@/store/configStore"; +import { isBoursecuProject } from '@/utils/config' +import { + BOURSECU_ASSET_LABEL_GOLD, + BOURSECU_ASSET_LABEL_KATOD, + BOURSECU_ASSET_LABEL_MAFTOL, + formatBoursecuAssetAmount, +} from '@/utils/productDealMethod' const nameProject = useConfigStore().config.name const items = ref([]) diff --git a/src/views/base/fund/info/index.vue b/src/views/base/fund/info/index.vue index b39ade9..9d21b76 100644 --- a/src/views/base/fund/info/index.vue +++ b/src/views/base/fund/info/index.vue @@ -58,7 +58,7 @@ type="text" inputmode="decimal" size="large" />
-
موجودی کیف طلا: {{ walletStore?.walletInfo?.gold }} گرم
+
{{ formatGoldWalletBalanceText(walletStore?.walletInfo?.gold ?? 0) }}
{{ `موجودی قابل برداشت گنج: ${info?.wallet?.gold ?? 0} گرم` }}
@@ -144,6 +144,7 @@ import { required } from '@/utils/inputRules' import type { FormInstance } from 'ant-design-vue' import { message } from 'ant-design-vue' import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue' +import { formatGoldWalletBalanceText } from '@/utils/productDealMethod' import BasicInput from '@/components/BasicPacks/BasicInput.vue' import { useWalletStore } from '@/store/walletStore' import ListAnim from '@/components/ListAnim.vue' diff --git a/src/views/base/gold/index.vue b/src/views/base/gold/index.vue index 53ec07c..0efecf9 100644 --- a/src/views/base/gold/index.vue +++ b/src/views/base/gold/index.vue @@ -61,13 +61,13 @@
-
{{ `موجودی کیف طلا: ${walletStore?.walletInfo?.gold ?? 0} گرم` }}
+
{{ formatGoldWalletBalanceText(walletStore?.walletInfo?.gold ?? 0, props?.ProductItem?.group_type) }}
- {{ `موجودی کیف پول: ${usePriceWithoutType(walletStore?.walletInfo?.cash ?? 0)} ریال` }} + {{ formatCashWalletBalanceText(usePriceWithoutType(walletStore?.walletInfo?.cash ?? 0), props?.ProductItem?.group_type) }}
@@ -232,6 +232,7 @@ import type { Product } from '@/models/products' import { useFundUserStore } from '@/store/fundStore' import {useConfigStore} from "@/store/configStore"; import { calcFeeInGrams, loadServiceFeeFromSettings } from '@/utils/serviceFee' +import { formatCashWalletBalanceText, formatGoldWalletBalanceText } from '@/utils/productDealMethod' const infoVisible = ref(false) const walletStore = useWalletStore() diff --git a/src/views/base/products/components/DealProduct.vue b/src/views/base/products/components/DealProduct.vue index 38c1817..c79dd90 100644 --- a/src/views/base/products/components/DealProduct.vue +++ b/src/views/base/products/components/DealProduct.vue @@ -60,7 +60,7 @@ + :rules="[justNumber2(props?.ProductItem?.price , form.method , props?.ProductItem?.amount, true, props?.ProductItem?.group_type)]">
وزن کل
-
{{ form.goldVazn ?? 0 }} گرم
+
{{ form.goldVazn ?? 0 }} {{ getWeightUnit() }}
-
{{ `موجودی کیف طلا: ${walletStore?.walletInfo?.gold ?? 0} گرم` }}
+
{{ goldWalletBalanceText }}
- {{ `موجودی کیف پول: ${usePriceWithoutType(walletStore?.walletInfo?.cash ?? 0)} ریال` }} + {{ cashWalletBalanceText }}
{{ `موجودی محصول: ${getInventoryById(props?.ProductItem?.id)}` }}
@@ -259,9 +259,25 @@ import { getDefaultProductDealMethod, getProductDealMethodOptions, isCashLikeDealMethod, + formatCashWalletBalanceText, + formatGoldWalletBalanceText, + getWeightUnit, } from '@/utils/productDealMethod' const typeDeal = computed(() => getProductDealMethodOptions(props?.ProductItem?.group_type)) + +const productGroupType = computed(() => props?.ProductItem?.group_type) + +const goldWalletBalanceText = computed(() => + formatGoldWalletBalanceText(walletStore?.walletInfo?.gold ?? 0, productGroupType.value) +) + +const cashWalletBalanceText = computed(() => + formatCashWalletBalanceText( + usePriceWithoutType(walletStore?.walletInfo?.cash ?? 0), + productGroupType.value + ) +) const infoVisible = ref(false) const walletStore = useWalletStore() const userStore = useUserStore() diff --git a/src/views/base/transactions/components/Item.vue b/src/views/base/transactions/components/Item.vue index 3acd3d4..c02e385 100644 --- a/src/views/base/transactions/components/Item.vue +++ b/src/views/base/transactions/components/Item.vue @@ -68,7 +68,7 @@
-
موجودی کیف پول:
+
{{ getCashWalletLabel(item.wallet?.product?.group_type) }}:
{{ usePriceWithoutType(item.balance_cash ?? 0) }}
ریال @@ -82,10 +82,10 @@
-
موجودی کیف آبشده:
+
{{ getGoldWalletLabel(item.wallet?.product?.group_type) }}:
{{ item.balance_gold }}
- گرم + {{ getWeightUnit() }}