fix pargar bugs 2

This commit is contained in:
2026-07-21 13:26:04 +03:30
parent c1c1ab501d
commit cb50119f56
2 changed files with 62 additions and 2 deletions
+12
View File
@@ -35,6 +35,18 @@ export const registerCustomerInPargar = async (customerId: number) =>
`/admin/customer/${customerId}/pargar/register` `/admin/customer/${customerId}/pargar/register`
) )
export interface PargarSyncWalletResult {
ok: boolean
message: string
result?: {
documents: { applied: number; skipped: number; errors: string[]; logs: number[] }
mande: { applied: boolean; gold_delta?: number; rial_delta?: number; message: string }
}
}
export const syncCustomerWalletFromPargar = async (customerId: number) =>
await useAxios.post<PargarSyncWalletResult>(`/admin/customer/${customerId}/pargar/sync-wallet`)
export interface PanelOnlyCustomer { export interface PanelOnlyCustomer {
id: number id: number
name: string name: string
+50 -2
View File
@@ -158,6 +158,20 @@
title="کد حسابداری" title="کد حسابداری"
:value="accountingCodeValue" :value="accountingCodeValue"
/> />
<div
v-if="pargarWalletSyncVisible"
class="col-span-2 flex items-end md:col-span-3 xl:col-span-4"
>
<a-button
type="primary"
ghost
size="small"
:loading="pargarSyncLoading"
@click="syncPargarWallet"
>
دریافت مانده از پرگار
</a-button>
</div>
<BasicInfoItem <BasicInfoItem
title="تاریخ تولد" title="تاریخ تولد"
:value="userInfo?.birth_date ? toJalaliNoTime(userInfo?.birth_date) : '_'" :value="userInfo?.birth_date ? toJalaliNoTime(userInfo?.birth_date) : '_'"
@@ -192,6 +206,7 @@
<CustomerWalletBalancePanel <CustomerWalletBalancePanel
v-if="userInfo?.id && isMobile" v-if="userInfo?.id && isMobile"
ref="walletPanelMobile"
:customer-id="userInfo.id" :customer-id="userInfo.id"
compact compact
:charge-targets="infoChargeTargets" :charge-targets="infoChargeTargets"
@@ -205,6 +220,7 @@
class="surface-muted min-w-0 rounded-xl border border-base p-2.5 lg:order-1 lg:sticky lg:top-0" class="surface-muted min-w-0 rounded-xl border border-base p-2.5 lg:order-1 lg:sticky lg:top-0"
> >
<CustomerWalletBalancePanel <CustomerWalletBalancePanel
ref="walletPanelDesktop"
:customer-id="userInfo.id" :customer-id="userInfo.id"
layout="sidebar" layout="sidebar"
:interactive="false" :interactive="false"
@@ -284,9 +300,11 @@ import type { DashboardHelp } from '@/pages/dashboard/dashboardSectionCopy'
import DashboardLabelWithHelp from '@/pages/dashboard/components/DashboardLabelWithHelp.vue' import DashboardLabelWithHelp from '@/pages/dashboard/components/DashboardLabelWithHelp.vue'
import { import {
accountingProviderSetting, accountingProviderSetting,
initAccountingSettingsFromApi initAccountingSettingsFromApi,
pargarEnabledSetting
} from '@/utils/config' } from '@/utils/config'
import { displayAccountingCode } from '@/utils/accountingCode' import { displayAccountingCode, isValidAccountingCode } from '@/utils/accountingCode'
import { syncCustomerWalletFromPargar } from '@/api/pargar'
const fnameHelp: DashboardHelp = { const fnameHelp: DashboardHelp = {
description: 'نام کوچک مشتری که در اپ و پنل نمایش داده می‌شود.', description: 'نام کوچک مشتری که در اپ و پنل نمایش داده می‌شود.',
@@ -553,6 +571,36 @@ const accountingCodeValue = computed(() => {
return '-' return '-'
}) })
const pargarSyncLoading = ref(false)
const walletPanelDesktop = ref<{ reload?: () => void } | null>(null)
const walletPanelMobile = ref<{ reload?: () => void } | null>(null)
const pargarWalletSyncVisible = computed(
() =>
pargarEnabledSetting.value &&
accountingProviderSetting.value === 'pargar' &&
isValidAccountingCode(userInfo.value?.pargar_account_id)
)
async function syncPargarWallet() {
if (!userInfo.value?.id) return
pargarSyncLoading.value = true
try {
const res = await syncCustomerWalletFromPargar(userInfo.value.id)
message.success(res.message || 'مانده از پرگار اعمال شد')
walletPanelDesktop.value?.reload?.()
walletPanelMobile.value?.reload?.()
refreshTransactionTable()
} catch (e: unknown) {
const msg =
(e as { response?: { data?: { message?: string } } })?.response?.data?.message ||
'اعمال مانده از پرگار ناموفق بود'
message.warning(msg)
} finally {
pargarSyncLoading.value = false
}
}
//submit user //submit user
async function ok() { async function ok() {
formRef.value?.validateFields().then(async () => { formRef.value?.validateFields().then(async () => {