fix pargar bugs 2
This commit is contained in:
@@ -35,6 +35,18 @@ export const registerCustomerInPargar = async (customerId: number) =>
|
||||
`/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 {
|
||||
id: number
|
||||
name: string
|
||||
|
||||
@@ -158,6 +158,20 @@
|
||||
title="کد حسابداری"
|
||||
: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
|
||||
title="تاریخ تولد"
|
||||
:value="userInfo?.birth_date ? toJalaliNoTime(userInfo?.birth_date) : '_'"
|
||||
@@ -192,6 +206,7 @@
|
||||
|
||||
<CustomerWalletBalancePanel
|
||||
v-if="userInfo?.id && isMobile"
|
||||
ref="walletPanelMobile"
|
||||
:customer-id="userInfo.id"
|
||||
compact
|
||||
: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"
|
||||
>
|
||||
<CustomerWalletBalancePanel
|
||||
ref="walletPanelDesktop"
|
||||
:customer-id="userInfo.id"
|
||||
layout="sidebar"
|
||||
:interactive="false"
|
||||
@@ -284,9 +300,11 @@ import type { DashboardHelp } from '@/pages/dashboard/dashboardSectionCopy'
|
||||
import DashboardLabelWithHelp from '@/pages/dashboard/components/DashboardLabelWithHelp.vue'
|
||||
import {
|
||||
accountingProviderSetting,
|
||||
initAccountingSettingsFromApi
|
||||
initAccountingSettingsFromApi,
|
||||
pargarEnabledSetting
|
||||
} from '@/utils/config'
|
||||
import { displayAccountingCode } from '@/utils/accountingCode'
|
||||
import { displayAccountingCode, isValidAccountingCode } from '@/utils/accountingCode'
|
||||
import { syncCustomerWalletFromPargar } from '@/api/pargar'
|
||||
|
||||
const fnameHelp: DashboardHelp = {
|
||||
description: 'نام کوچک مشتری که در اپ و پنل نمایش داده میشود.',
|
||||
@@ -553,6 +571,36 @@ const accountingCodeValue = computed(() => {
|
||||
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
|
||||
async function ok() {
|
||||
formRef.value?.validateFields().then(async () => {
|
||||
|
||||
Reference in New Issue
Block a user