From 9a975e1cba318877b84d36263e483ddcf3f5f430 Mon Sep 17 00:00:00 2001 From: adonis Date: Sat, 1 Aug 2026 17:30:37 +0330 Subject: [PATCH] added fund --- src/api/user.ts | 23 +++ src/pages/menuPages/configuration/index.vue | 7 +- .../menuPages/configuration/settingGroups.ts | 2 +- .../menuPages/configuration/settingTypes.ts | 5 + .../customers/base/components/fundsTable.vue | 187 +++++++++++------- .../base/components/piggyFundsTable.vue | 101 ++++++++++ .../customers/base/hooks/fundsColumns.tsx | 51 ++--- .../base/hooks/piggyFundsColumns.tsx | 47 +++++ src/pages/menuPages/customers/base/index.vue | 14 +- src/utils/config.ts | 15 ++ 10 files changed, 348 insertions(+), 104 deletions(-) create mode 100644 src/pages/menuPages/customers/base/components/piggyFundsTable.vue create mode 100644 src/pages/menuPages/customers/base/hooks/piggyFundsColumns.tsx diff --git a/src/api/user.ts b/src/api/user.ts index 65706eb..e438d4b 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -9,6 +9,29 @@ export const getReferralsTable = async (params: TableInput,customer_id: number) //funds export const getFundsTable = async (params: TableInput,customer_id: number) => await useAxios.post>(`/admin/customers/${customer_id}/funds`, params) +export const getPiggyFundsTable = async (params: TableInput, customer_id: number) => + await useAxios.post(`/admin/customers/${customer_id}/piggy-funds`, params) + +export const getAssetPiggyFundsTable = async ( + params: TableInput, + customer_id: number, + product_id: number +) => await useAxios.post(`/admin/customers/${customer_id}/assets/${product_id}/piggy-funds`, params) + +export const getAssetTransactionsTable = async ( + params: TableInput, + customer_id: number, + product_id: number +) => + await useAxios.post(`/admin/customers/${customer_id}/assets/${product_id}/transactions`, params) + +export const getPiggyFundTransactionsTable = async ( + params: TableInput, + customer_id: number, + fund_id: number +) => + await useAxios.post(`/admin/customers/${customer_id}/piggy-funds/${fund_id}/transactions`, params) + export const getReferrals = async (val: Referrals) => await useAxios.post(`/admin/customers/4/referrals`, val) //me export const getMyInformation = async () => await useAxios.get('/admin/me') diff --git a/src/pages/menuPages/configuration/index.vue b/src/pages/menuPages/configuration/index.vue index 234e00f..d1fa22f 100644 --- a/src/pages/menuPages/configuration/index.vue +++ b/src/pages/menuPages/configuration/index.vue @@ -174,7 +174,7 @@ import SettingValueField from './SettingValueField.vue' import SettingCard from './SettingCard.vue' import { refreshAppModeMenu } from '@/router' import { useUserStore } from '@/store/userStore' -import { applyBannerEnabledFromRows, applyTrackingSystemsEnabledFromRows, applyConditionalOrderEnabledFromRows, applyPriceTriggerEnabledFromRows, applyAppNotificationEnabledFromRows, applyPriceProviderFromRows, applySupportChatMenuEnabledFromRows, setBannerEnabledFromSettings, setConditionalOrderEnabledFromSettings, setPriceTriggerEnabledFromSettings, setAppNotificationEnabledFromSettings, setPriceProviderFromSettings, setStoreModeFromSettings, setTrackingSystemsEnabledFromSettings } from '@/utils/config' +import { applyBannerEnabledFromRows, applyTrackingSystemsEnabledFromRows, applyConditionalOrderEnabledFromRows, applyProductFundsEnabledFromRows, applyPriceTriggerEnabledFromRows, applyAppNotificationEnabledFromRows, applyPriceProviderFromRows, applySupportChatMenuEnabledFromRows, setBannerEnabledFromSettings, setConditionalOrderEnabledFromSettings, setProductFundsEnabledFromSettings, setPriceTriggerEnabledFromSettings, setAppNotificationEnabledFromSettings, setPriceProviderFromSettings, setStoreModeFromSettings, setTrackingSystemsEnabledFromSettings } from '@/utils/config' import { EDITABLE_SETTING_GROUPS, SYSTEM_SETTING_GROUPS, @@ -423,6 +423,7 @@ async function initConfig() { applyBannerEnabledFromRows(baseData.value) applyTrackingSystemsEnabledFromRows(baseData.value) applyConditionalOrderEnabledFromRows(baseData.value) + applyProductFundsEnabledFromRows(baseData.value) applyPriceTriggerEnabledFromRows(baseData.value) applyAppNotificationEnabledFromRows(baseData.value) applyPriceProviderFromRows(baseData.value) @@ -483,6 +484,10 @@ function syncMenuFlagsFromSetting(key: string | undefined, value: string) { setConditionalOrderEnabledFromSettings(isSwitchOn(value)) return } + if (key === 'enable_product_funds') { + setProductFundsEnabledFromSettings(isSwitchOn(value)) + return + } if (key === 'has_page_price_trigger') { setPriceTriggerEnabledFromSettings(isSwitchOn(value)) return diff --git a/src/pages/menuPages/configuration/settingGroups.ts b/src/pages/menuPages/configuration/settingGroups.ts index d44daf6..55713fa 100644 --- a/src/pages/menuPages/configuration/settingGroups.ts +++ b/src/pages/menuPages/configuration/settingGroups.ts @@ -134,7 +134,7 @@ export const SYSTEM_SETTING_GROUPS: SettingGroupDef[] = [ title: 'دسترسی مشتری به قابلیت‌ها', icon: 'vuesax-linear:people', match: (k) => - /^(enable_conditional_order|has_page_price_trigger|has_page_notification|banner_enabled|jibit_enabled|customer_direct_sms|has_page_earn_money|group_sms|tracking_systems_enabled|permision__enabled|show_to_users_chat)$/.test( + /^(enable_conditional_order|enable_product_funds|has_page_price_trigger|has_page_notification|banner_enabled|jibit_enabled|customer_direct_sms|has_page_earn_money|group_sms|tracking_systems_enabled|permision__enabled|show_to_users_chat)$/.test( k ) }, diff --git a/src/pages/menuPages/configuration/settingTypes.ts b/src/pages/menuPages/configuration/settingTypes.ts index 4ae6e7c..50daa98 100644 --- a/src/pages/menuPages/configuration/settingTypes.ts +++ b/src/pages/menuPages/configuration/settingTypes.ts @@ -245,6 +245,7 @@ const KEY_TYPE_FALLBACK: Record = { fee_free: 'number', fee_conditional_order: 'price', enable_conditional_order: 'switch', + enable_product_funds: 'switch', has_page_price_trigger: 'switch', has_page_notification: 'switch', min_withdraw: 'price', @@ -627,6 +628,8 @@ const KEY_HELP_FALLBACK: Record = { 'مبلغ ریالی که با هر بار ثبت تریگر سفارش شرطی از کیف پول ریالی مشتری کم می‌شود. صفر = رایگان.', enable_conditional_order: 'روشن: قابلیت سفارش شرطی سراسری فعال است. خاموش: منو و ارزیابی اجرا نمی‌شود. فقط از صفحه دیپلوی قابل تغییر است.', + enable_product_funds: + 'روشن: ساخت و مدیریت قلک per-product در اپ مشتری فعال است (یک محصول در هر قلک؛ انتقال بدون سند حسابداری). خاموش: منو و API ساخت قلک جدید در دسترس نیست. فقط از دیپلوی قابل تغییر است.', has_page_price_trigger: 'روشن: منوی هشدار قیمت در اپ مشتری نمایش داده می‌شود. خاموش: منو و صفحه مخفی است. فقط از صفحه دیپلوی قابل تغییر است.', has_page_notification: @@ -910,6 +913,7 @@ export const KEY_LABEL_FALLBACK: Record = { fee_free: 'معافیت کارمزد سفارش اول', fee_conditional_order: 'کارمزد سفارش شرطی', enable_conditional_order: 'سفارش شرطی', + enable_product_funds: 'قلک محصول', has_page_price_trigger: 'هشدار قیمت', has_page_notification: 'اعلان داخل اپ', jibit_enabled: 'احراز هویت جیبیت', @@ -1021,6 +1025,7 @@ export const SETTING_LOCKED_KEYS = new Set([ 'group_sms', 'customer_direct_sms', 'enable_conditional_order', + 'enable_product_funds', 'has_page_price_trigger', 'has_page_notification', 'jibit_enabled', diff --git a/src/pages/menuPages/customers/base/components/fundsTable.vue b/src/pages/menuPages/customers/base/components/fundsTable.vue index ed7aed5..2844b58 100644 --- a/src/pages/menuPages/customers/base/components/fundsTable.vue +++ b/src/pages/menuPages/customers/base/components/fundsTable.vue @@ -1,103 +1,140 @@ - - diff --git a/src/pages/menuPages/customers/base/components/piggyFundsTable.vue b/src/pages/menuPages/customers/base/components/piggyFundsTable.vue new file mode 100644 index 0000000..ee6f883 --- /dev/null +++ b/src/pages/menuPages/customers/base/components/piggyFundsTable.vue @@ -0,0 +1,101 @@ + + + diff --git a/src/pages/menuPages/customers/base/hooks/fundsColumns.tsx b/src/pages/menuPages/customers/base/hooks/fundsColumns.tsx index 180c970..725ad63 100644 --- a/src/pages/menuPages/customers/base/hooks/fundsColumns.tsx +++ b/src/pages/menuPages/customers/base/hooks/fundsColumns.tsx @@ -1,26 +1,6 @@ import type { BaseTableColumn } from '@core/type/baseTable' -import { toJalaliNoTime, toTime } from '@core/utils/useDataTime' -import CustomTag from '@/components/CustomTag.vue' -import { usePrice } from '@core/utils/usePrice' -/*import BudgetSelect from '@/components/BudgetSelect.vue' -import { useStaticApiListsStore } from '@/store/staticApisStore' -import type { FilterSelect } from '@/model/filterSelect' -import type { DocItem } from '@/model/docType'*/ - -//define store -//const store = useStaticApiListsStore() -//document types -/*let docTypes: DocItem[]*/ -/*onMounted(async () => { - docTypes = await store.readyDocTypeList() -}) -const filteredDocTypes: FilterSelect = docTypes?.map((x: DocItem) => { - return { - label: x.title, - value: x.id - } -})*/ +/** ستون‌های تب دارایی‌ها (جمع آزاد + قلک) */ export const cols: BaseTableColumn[] = [ { title: 'ردیف', @@ -33,11 +13,10 @@ export const cols: BaseTableColumn[] = [ } }, { - title: 'کد قلک', + title: 'کد دارایی', dataIndex: 'id', - key: 'id', + key: 'wallet_id', type: 'Number' - // className: 'column-money' }, { title: 'نام محصول', @@ -48,9 +27,31 @@ export const cols: BaseTableColumn[] = [ record.record?.product_title || record.record?.product?.title || '-' }, { - title: 'موجودی', + title: 'موجودی کل', dataIndex: 'gold', key: 'gold', type: 'Number' }, + { + title: 'آزاد', + dataIndex: 'free_gold', + key: 'free_gold', + type: 'Number', + customRender: (record: any) => record.record?.free_gold ?? record.record?.gold ?? '-' + }, + { + title: 'در قلک', + dataIndex: 'fund_gold', + key: 'fund_gold', + type: 'Number', + customRender: (record: any) => record.record?.fund_gold ?? 0 + }, + { + title: 'عملیات', + dataIndex: 'action', + key: 'action', + slot: 'action', + filterable: false, + sortable: false + } ] diff --git a/src/pages/menuPages/customers/base/hooks/piggyFundsColumns.tsx b/src/pages/menuPages/customers/base/hooks/piggyFundsColumns.tsx new file mode 100644 index 0000000..5a95527 --- /dev/null +++ b/src/pages/menuPages/customers/base/hooks/piggyFundsColumns.tsx @@ -0,0 +1,47 @@ +import type { BaseTableColumn } from '@core/type/baseTable' + +/** ستون‌های تب قلک‌ها (مدل Fund) */ +export const piggyFundsCols: BaseTableColumn[] = [ + { + title: 'ردیف', + dataIndex: 'id', + key: 'row', + filterable: false, + sortable: false, + customRender: (record: any) => record.index + 1 + }, + { + title: 'کد قلک', + dataIndex: 'id', + key: 'id', + type: 'Number' + }, + { + title: 'عنوان قلک', + dataIndex: 'title', + key: 'title', + type: 'Text' + }, + { + title: 'نام محصول', + dataIndex: 'product_title', + key: 'product_title', + type: 'Text', + customRender: (record: any) => + record.record?.product_title || record.record?.product?.title || '-' + }, + { + title: 'موجودی', + dataIndex: 'gold', + key: 'gold', + type: 'Number' + }, + { + title: 'عملیات', + dataIndex: 'action', + key: 'action', + slot: 'action', + filterable: false, + sortable: false + } +] diff --git a/src/pages/menuPages/customers/base/index.vue b/src/pages/menuPages/customers/base/index.vue index 91dbfed..908dcb8 100644 --- a/src/pages/menuPages/customers/base/index.vue +++ b/src/pages/menuPages/customers/base/index.vue @@ -240,9 +240,12 @@ - + + + + @@ -304,6 +307,7 @@ import ordersTbl from '@/pages/menuPages/orders/components/table.vue' import transactionsTbl from '@/pages/menuPages/transactions/components/table.vue' import smsTbl from '@/pages/menuPages/sms/components/table.vue' import FundsTable from '@/pages/menuPages/customers/base/components/fundsTable.vue' +import PiggyFundsTable from '@/pages/menuPages/customers/base/components/piggyFundsTable.vue' import ReferralsTable from '@/pages/menuPages/customers/base/components/referralsTable.vue' import CustomerPargarLogsTable from '@/pages/menuPages/customers/base/components/CustomerPargarLogsTable.vue' import CustomerConditionalOrderTab from '@/pages/menuPages/customers/base/components/CustomerConditionalOrderTab.vue' @@ -378,6 +382,7 @@ const transactionTable = ref(null) const smsTable = ref(null) const referralTable = ref(null) const fundTable = ref(null) +const piggyFundTable = ref(null) const pargarLogsTable = ref<{ fetch?: () => void } | null>(null) const refreshTable = () => table?.value?.fetch() const refreshOrderTable = () => orderTable?.value?.fetch() @@ -385,6 +390,7 @@ const refreshTransactionTable = () => transactionTable?.value?.fetch() const refreshSMSTable = () => smsTable?.value?.fetch() const refreshReferralTable = () => referralTable?.value?.fetch() const refreshFundTable = () => fundTable?.value?.fetch() +const refreshPiggyFundTable = () => piggyFundTable?.value?.fetch() const refreshPargarLogsTable = () => pargarLogsTable.value?.fetch?.() let updateKey = ref(0) @@ -542,10 +548,14 @@ async function refreshInfoTab(key: string) { await nextTick() refreshReferralTable() break - case 'قلک ها': + case 'دارایی ها': await nextTick() refreshFundTable() break + case 'قلک ها': + await nextTick() + refreshPiggyFundTable() + break case 'لاگ پرگار': await nextTick() refreshPargarLogsTable() diff --git a/src/utils/config.ts b/src/utils/config.ts index 074e16a..2e7e89e 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -46,6 +46,9 @@ export const customerDirectSmsEnabledSetting = ref(false) /** reactive — منو و UI سفارش شرطی (ادمین + کنترل‌های مشتری) */ export const conditionalOrderEnabledSetting = ref(false) +/** reactive — قلک per-product در اپ مشتری */ +export const productFundsEnabledSetting = ref(false) + /** reactive — منو و UI هشدار قیمت */ export const priceTriggerEnabledSetting = ref(false) @@ -144,6 +147,10 @@ export function setConditionalOrderEnabledFromSettings(value: boolean): void { conditionalOrderEnabledSetting.value = value } +export function setProductFundsEnabledFromSettings(value: boolean): void { + productFundsEnabledSetting.value = value +} + export function setPriceTriggerEnabledFromSettings(value: boolean): void { priceTriggerEnabledSetting.value = value } @@ -236,6 +243,13 @@ export function applyConditionalOrderEnabledFromRows( if (row) setConditionalOrderEnabledFromSettings(isSwitchOn(row.value)) } +export function applyProductFundsEnabledFromRows( + rows: Array<{ key?: string; value?: string | null }> +) { + const row = rows.find((item) => item.key === 'enable_product_funds') + if (row) setProductFundsEnabledFromSettings(isSwitchOn(row.value)) +} + export function applyPriceTriggerEnabledFromRows( rows: Array<{ key?: string; value?: string | null }> ) { @@ -276,6 +290,7 @@ async function bootstrapSettingsFromApi(): Promise { applyTrackingSystemsEnabledFromRows(list) applyCustomerDirectSmsFromRows(list) applyConditionalOrderEnabledFromRows(list) + applyProductFundsEnabledFromRows(list) applyPriceTriggerEnabledFromRows(list) applyAppNotificationEnabledFromRows(list) applySupportChatMenuEnabledFromRows(list)