changes of boursecu

This commit is contained in:
2026-06-03 19:54:23 +03:30
parent eab6b0df52
commit 198f0a164b
12 changed files with 165 additions and 31 deletions
+13
View File
@@ -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']
}
}
+4
View File
@@ -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
+8 -6
View File
@@ -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,
+67 -5
View File
@@ -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)} ناکافی است`
}
+3 -2
View File
@@ -62,13 +62,13 @@
<!-- {{walletStore?.walletInfo?.gold}}-->
<Transition mode="out-in" name="fade">
<div v-if="!isBuy" class="font-bold text-xs">
<div> {{ `موجودی کیف طلا: ${walletStore?.walletInfo?.gold ?? 0} گرم` }}</div>
<div>{{ formatGoldWalletBalanceText(walletStore?.walletInfo?.gold ?? 0, props?.ProductItem?.group_type) }}</div>
<!-- <div v-if="walletStore?.walletInfo?.gold_block !== 0">
{{ `موجودی قابل برداشت طلا: ${walletStore?.walletInfo?.gold_block ?? 0} گرم` }}
</div>-->
</div>
<div v-else class="font-bold text-xs">
{{ `موجودی کیف پول: ${usePriceWithoutType(walletStore?.walletInfo?.cash ?? 0)} ریال` }}
{{ formatCashWalletBalanceText(usePriceWithoutType(walletStore?.walletInfo?.cash ?? 0), props?.ProductItem?.group_type) }}
</div>
</Transition>
<Transition mode="out-in" name="fade">
@@ -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()
+35
View File
@@ -10,6 +10,33 @@
<img :src="img" alt="" class="w-full absolute bottom-0 left-0 opacity-5 pointer-events-none z-0" />
<div class="pt-15 flex flex-col relative z-10">
<div class="text-tertiary font-bold mr-5 z-20">موجودی دارایی ها</div>
<template v-if="isBoursecuProject()">
<div class="flex justify-center mt-2 w-full z-20">
{{ BOURSECU_ASSET_LABEL_KATOD }}:
<div class="text-l mr-4 font-bold">
{{ formatBoursecuAssetAmount(walletStore.walletInfo?.count_katod_mes) }}
</div>
</div>
<div class="flex justify-center mt-2 w-full z-20">
{{ BOURSECU_ASSET_LABEL_MAFTOL }}:
<div class="text-l mr-4 font-bold">
{{ formatBoursecuAssetAmount(walletStore.walletInfo?.count_maftol_mes) }}
</div>
</div>
<div class="flex justify-center mt-2 w-full z-20">
{{ BOURSECU_ASSET_LABEL_GOLD }}:
<div class="text-l mr-4 font-bold">
{{ formatBoursecuAssetAmount(walletStore.walletInfo?.count_gold) }}
</div>
</div>
<div class="flex justify-center mt-2 w-full z-20">
دارایی ریالی:
<div class="text-l mr-4 font-bold">
{{ usePriceWithoutType(walletStore.walletInfo?.count_cash ?? 0) }}ریال
</div>
</div>
</template>
<template v-else>
<div class="flex mt-4 justify-center mt-2 w-full z-20">
محصولات:
<div class="text-l mr-4 font-bold">{{ walletStore.walletInfo?.count_product ?? 0}}عدد</div>
@@ -34,6 +61,7 @@
معادل ریالی مجموع دارایی ها:
<div class="text-l mr-4 font-bold">{{ usePriceWithoutType(walletStore.walletInfo?.count_cash_total ?? 0) }}ریال</div>
</div>
</template>
</div>
</div>
<div class="pt-[20rem] ">
@@ -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<Fund[]>([])
+2 -1
View File
@@ -58,7 +58,7 @@
type="text" inputmode="decimal"
size="large" />
<div v-if="isDeposit" class="mt-2 text-xs font-bold leading-5">
<div>موجودی کیف طلا: {{ walletStore?.walletInfo?.gold }} گرم</div>
<div>{{ formatGoldWalletBalanceText(walletStore?.walletInfo?.gold ?? 0) }}</div>
<div v-if="info?.wallet?.gold !== 0">
{{ `موجودی قابل برداشت گنج: ${info?.wallet?.gold ?? 0} گرم` }}
</div>
@@ -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'
+3 -2
View File
@@ -61,13 +61,13 @@
<!-- {{walletStore?.walletInfo?.gold}}-->
<Transition mode="out-in" name="fade">
<div v-if="!isBuy" class="font-bold text-xs">
<div> {{ `موجودی کیف طلا: ${walletStore?.walletInfo?.gold ?? 0} گرم` }}</div>
<div>{{ formatGoldWalletBalanceText(walletStore?.walletInfo?.gold ?? 0, props?.ProductItem?.group_type) }}</div>
<!-- <div v-if="walletStore?.walletInfo?.gold_block !== 0">
{{ `موجودی قابل برداشت طلا: ${walletStore?.walletInfo?.gold_block ?? 0} گرم` }}
</div>-->
</div>
<div v-else class="font-bold text-xs">
{{ `موجودی کیف پول: ${usePriceWithoutType(walletStore?.walletInfo?.cash ?? 0)} ریال` }}
{{ formatCashWalletBalanceText(usePriceWithoutType(walletStore?.walletInfo?.cash ?? 0), props?.ProductItem?.group_type) }}
</div>
</Transition>
<Transition mode="out-in" name="fade">
@@ -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()
@@ -60,7 +60,7 @@
</a-form-item>
<a-form-item v-if="isBuy" name="goldValue"
:rules="[justNumber2(props?.ProductItem?.price , form.method , props?.ProductItem?.amount, true)]">
:rules="[justNumber2(props?.ProductItem?.price , form.method , props?.ProductItem?.amount, true, props?.ProductItem?.group_type)]">
<BasicInput v-model:value="form.goldValue" addon-before="تعداد" addon-bg-color="#000000FF"
addon-text-color="white"
place-holder="تعداد"
@@ -81,16 +81,16 @@
<div v-if="props?.ProductItem?.group_type !== 'سکه'" class="flex justify-between">
<div> وزن کل</div>
<div>{{ form.goldVazn ?? 0 }} گرم</div>
<div>{{ form.goldVazn ?? 0 }} {{ getWeightUnit() }}</div>
</div>
<!-- {{walletStore?.walletInfo?.gold}}-->
<Transition mode="out-in" name="fade" class="mt-2">
<div v-if="isBuy && form.method === 'gold'" class="font-bold text-xs">
<div> {{ `موجودی کیف طلا: ${walletStore?.walletInfo?.gold ?? 0} گرم` }}</div>
<div>{{ goldWalletBalanceText }}</div>
</div>
<div v-else-if="isBuy" class="font-bold text-xs">
{{ `موجودی کیف پول: ${usePriceWithoutType(walletStore?.walletInfo?.cash ?? 0)} ریال` }}
{{ cashWalletBalanceText }}
</div>
<div class="font-bold text-xs" v-else>{{ `موجودی محصول: ${getInventoryById(props?.ProductItem?.id)}` }}
</div>
@@ -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()
@@ -68,7 +68,7 @@
</div>
</div>
<div class="flex justify-between mb-3">
<div class="text-primary">موجودی کیف پول:</div>
<div class="text-primary">{{ getCashWalletLabel(item.wallet?.product?.group_type) }}:</div>
<div :class="item.cash > 0? 'text-green-600' : 'text-red-600'" class="flex text-xs items-center number-ltr">
<div class="text-base">{{ usePriceWithoutType(item.balance_cash ?? 0) }}</div>
ریال
@@ -82,10 +82,10 @@
</div>
</div>
<div class="flex justify-between mb-3" v-else>
<div class="text-primary">موجودی کیف آبشده:</div>
<div class="text-primary">{{ getGoldWalletLabel(item.wallet?.product?.group_type) }}:</div>
<div class="flex text-xs text-yellow-700 items-center">
<div class="text-base ml-1">{{ item.balance_gold }}</div>
گرم
{{ getWeightUnit() }}
</div>
</div>
<!-- <div class="flex justify-between mb-3">
@@ -138,6 +138,7 @@ import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
import { computed, ref } from 'vue'
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
import type { Transaction } from '@/models/transaction'
import { getCashWalletLabel, getGoldWalletLabel, getWeightUnit } from '@/utils/productDealMethod'
import { toJalaliNotime, toJalaliOutOfUTC, toTime } from '../../../../utils/useDateTime'
const infoVisible = ref<boolean>(false)
+4 -3
View File
@@ -79,17 +79,17 @@
</div>
</div>
<div class="flex justify-between mb-3">
<div class="text-black">موجودی کیف پول:</div>
<div class="text-black">{{ getCashWalletLabel() }}:</div>
<div :class="item.cash > 0? 'text-green-600' : 'text-red-600'" class="flex text-xs items-center">
<div class="text-base number-ltr">{{ usePriceWithoutType(item.balance_cash ?? 0) }}</div>
ریال
</div>
</div>
<div class="flex justify-between mb-3">
<div class="text-black">موجودی کیف طلا:</div>
<div class="text-black">{{ getGoldWalletLabel() }}:</div>
<div class="flex text-xs text-yellow-700 items-center">
<div class="text-base ml-1">{{ item.balance_gold }}</div>
گرم
{{ getWeightUnit() }}
</div>
</div>
<!-- <div class="flex justify-between mb-3">
@@ -143,6 +143,7 @@ import BasicActionSheet from "@/components/BasicPacks/BasicActionSheet.vue";
import {computed, ref} from "vue";
import BasicButton from "@/components/BasicPacks/BasicButton.vue";
import type {Transaction} from "@/models/transaction";
import {getCashWalletLabel, getGoldWalletLabel, getWeightUnit} from '@/utils/productDealMethod'
import {toJalaliNotime, toJalaliOutOfUTC, toTime} from "../../../../utils/useDateTime";
const infoVisible = ref<boolean>(false)
+2 -5
View File
@@ -48,11 +48,7 @@
<div v-if="!isDeposit">
<div class="text-red text-xs font-bold mb-2">حداقل مبلغ برداشتی 100 هزار تومان می باشد.</div>
<div class="font-bold text-xs">
{{
`موجودی کیف پول: ${usePriceWithoutType(
walletStore?.walletInfo?.cash ?? 0
)} ریال`
}}
{{ formatCashWalletBalanceText(usePriceWithoutType(walletStore?.walletInfo?.cash ?? 0)) }}
</div>
<a-form-item v-if="walletStore?.walletInfo" class="!mt-3">
<a-slider
@@ -359,6 +355,7 @@
<script lang="ts" setup>
import { computed, onMounted, ref } from 'vue'
import { formatCashWalletBalanceText } from '@/utils/productDealMethod'
import { usePriceWithoutType } from '@/utils/usePrice'
import { loading, loadingMore } from '@/utils'
import BasicButton from '@/components/BasicPacks/BasicButton.vue'