Require review before Tahesab wallet sync and harden accounting admin UX.
Single-customer and row sync preview balances with documents before overwrite/keep; bulk sync keeps confirm. Also ship Zarin wallet sync actions, field help, and get_user cache improvements. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="h-full min-h-0 min-w-0 max-w-full overflow-hidden">
|
||||
<BasicShowContext title="لیست مشتریان بایگانی شده">
|
||||
<BasicShowContext title="لیست مشتریان بایگانی شده" :help="customersArchivePageIntro">
|
||||
<div class="flex h-full min-h-0 flex-col">
|
||||
<BaseTable v-if="!isMobile" class="h-full min-h-0 min-w-0" v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
@@ -51,6 +51,7 @@ import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import useBaseTable from '@core/components/BaseTable/hooks/useBaseTable'
|
||||
import type { TableInput } from '@core/type/baseTable'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { customersArchivePageIntro } from '@/utils/adminHelpCopy'
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const emits = defineEmits(['delete', 'edit', 'add', 'info', 'charge'])
|
||||
|
||||
@@ -9,7 +9,13 @@
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z" />
|
||||
</svg>
|
||||
</div>
|
||||
<h2 class="text-3xl font-bold text-gray-800 mb-2">احراز هویت</h2>
|
||||
<h2 class="text-3xl font-bold text-gray-800 mb-2 inline-flex items-center justify-center gap-1.5">
|
||||
احراز هویت
|
||||
<AdminFieldHelp
|
||||
text="با کد ملی و اطلاعات کارت بانکی، هویت فرد را از طریق سرویس استعلام بانکی بررسی میکند. نتیجه برای تایید مشتری در پنل استفاده میشود."
|
||||
size="sm"
|
||||
/>
|
||||
</h2>
|
||||
<p class="text-gray-500 text-sm">لطفاً اطلاعات کارت بانکی فرد مورد نظر را وارد کنید</p>
|
||||
</div>
|
||||
|
||||
@@ -93,6 +99,7 @@ import type { CheckCardRequest } from "@/model/user"
|
||||
import { checkCard } from "@/api/customer"
|
||||
import DatePicker from "@core/components/_sample/components/datePicker.vue";
|
||||
import Icon from "@core/components/BaseIcon/src/Icon.vue";
|
||||
import AdminFieldHelp from '@/components/AdminFieldHelp.vue'
|
||||
|
||||
const formState = reactive<CheckCardRequest>({
|
||||
// birth_date: '',
|
||||
|
||||
@@ -27,21 +27,26 @@
|
||||
برای پاک کردن کد، فیلد را خالی بگذارید و ذخیره کنید.
|
||||
</p>
|
||||
<p
|
||||
v-if="provider === 'tahesab'"
|
||||
v-if="provider === 'tahesab' || provider === 'zarin'"
|
||||
class="m-0 text-xs"
|
||||
style="color: var(--admin-text-secondary)"
|
||||
>
|
||||
بعد از ذخیره کد تهحساب، اگر موجودی اپ با مانده تهحساب فرق داشته باشد از شما تصمیم گرفته میشود.
|
||||
قبل از ذخیره، اگر مانده اپ با حسابداری فرق داشته باشد از شما تأیید گرفته میشود؛ بعد اعمال میشود.
|
||||
</p>
|
||||
</div>
|
||||
</BasicModal>
|
||||
|
||||
<TahesabMandeDecisionModal
|
||||
v-model:visible="decisionVisible"
|
||||
:source-label="provider === 'zarin' ? 'زرین' : 'تهحساب'"
|
||||
:app-gold="decision?.app_gold"
|
||||
:app-cash="decision?.app_cash"
|
||||
:tahesab-gold="decision?.tahesab_gold"
|
||||
:tahesab-cash="decision?.tahesab_cash"
|
||||
:tahesab-gold="decision?.tahesab_gold ?? decision?.zarin_gold"
|
||||
:tahesab-cash="decision?.tahesab_cash ?? decision?.zarin_cash"
|
||||
:gold-delta="decision?.gold_delta"
|
||||
:rial-delta="decision?.rial_delta"
|
||||
:wallet-docs="decision?.wallet_docs"
|
||||
:tahesab-docs="decision?.tahesab_docs"
|
||||
@decide="onDecide"
|
||||
/>
|
||||
</template>
|
||||
@@ -52,9 +57,14 @@ import { message } from 'ant-design-vue'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import { updateCustomer } from '@/api/customer'
|
||||
import {
|
||||
previewCustomerWalletFromTahesab,
|
||||
syncCustomerWalletFromTahesab,
|
||||
type TahesabWalletSyncResult,
|
||||
} from '@/api/tahesab'
|
||||
import {
|
||||
previewCustomerWalletFromZarin,
|
||||
syncCustomerWalletFromZarin,
|
||||
} from '@/api/zarin'
|
||||
import type { Customer } from '@/model/customer'
|
||||
import type { AccountingProvider } from '@/utils/config'
|
||||
import { displayAccountingCode, normalizeAccountingCode } from '@/utils/accountingCode'
|
||||
@@ -76,7 +86,7 @@ const loading = ref(false)
|
||||
const code = ref('')
|
||||
const decisionVisible = ref(false)
|
||||
const decision = ref<TahesabWalletSyncResult['result'] | null>(null)
|
||||
const savedCustomerId = ref<number | null>(null)
|
||||
const pendingPayload = ref<{ customerId: number; body: Record<string, string>; nextCode: string } | null>(null)
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
@@ -103,47 +113,44 @@ function close() {
|
||||
visibleProxy.value = false
|
||||
}
|
||||
|
||||
async function maybeSyncTahesabWallet(customerId: number, previousCode: string, nextCode: string) {
|
||||
if (props.provider !== 'tahesab') return
|
||||
if (!nextCode || nextCode === previousCode) return
|
||||
|
||||
try {
|
||||
const res = await syncCustomerWalletFromTahesab(customerId, { ask_if_conflict: true })
|
||||
if (res.needs_decision || res.result?.needs_decision) {
|
||||
decision.value = res.result ?? null
|
||||
savedCustomerId.value = customerId
|
||||
decisionVisible.value = true
|
||||
return
|
||||
}
|
||||
if (res.result?.applied) {
|
||||
message.success(res.message || 'مانده تهحساب روی کیف اعمال شد')
|
||||
} else if (res.message) {
|
||||
message.info(res.message)
|
||||
}
|
||||
} catch (e) {
|
||||
// خطای همگامسازی مانع ذخیره کد نیست
|
||||
console.error(e)
|
||||
}
|
||||
async function saveCode(customerId: number, body: Record<string, string>) {
|
||||
await updateCustomer(customerId, body as Customer)
|
||||
message.success('کد حسابداری ذخیره شد.')
|
||||
emit('success')
|
||||
close()
|
||||
}
|
||||
|
||||
async function onDecide(mode: 'overwrite' | 'keep') {
|
||||
const customerId = savedCustomerId.value
|
||||
decisionVisible.value = false
|
||||
if (!customerId) return
|
||||
try {
|
||||
const res = await syncCustomerWalletFromTahesab(customerId, {
|
||||
async function applyWalletDecision(customerId: number, mode: 'overwrite' | 'keep') {
|
||||
if (props.provider === 'zarin') {
|
||||
return syncCustomerWalletFromZarin(customerId, {
|
||||
overwrite: mode === 'overwrite',
|
||||
keep: mode === 'keep',
|
||||
ask_if_conflict: false,
|
||||
})
|
||||
if (mode === 'keep') {
|
||||
message.info(res.message || 'موجودی اپ حفظ شد')
|
||||
} else {
|
||||
message.success(res.message || 'مانده تهحساب روی کیف اعمال شد')
|
||||
}
|
||||
}
|
||||
return syncCustomerWalletFromTahesab(customerId, {
|
||||
overwrite: mode === 'overwrite',
|
||||
keep: mode === 'keep',
|
||||
ask_if_conflict: false,
|
||||
})
|
||||
}
|
||||
|
||||
async function onDecide(mode: 'overwrite' | 'keep') {
|
||||
const pending = pendingPayload.value
|
||||
decisionVisible.value = false
|
||||
if (!pending) return
|
||||
try {
|
||||
loading.value = true
|
||||
await saveCode(pending.customerId, pending.body)
|
||||
const res = await applyWalletDecision(pending.customerId, mode)
|
||||
if (mode === 'keep') message.info(res.message || 'موجودی اپ حفظ شد')
|
||||
else message.success(res.message || 'مانده حسابداری روی کیف اعمال شد')
|
||||
emit('success')
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
pendingPayload.value = null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,13 +168,38 @@ async function submit() {
|
||||
? { pargar_account_id: normalized }
|
||||
: { moshtari_code: normalized }
|
||||
|
||||
const needsWalletAsk =
|
||||
(props.provider === 'tahesab' || props.provider === 'zarin')
|
||||
&& !!normalized
|
||||
&& normalized !== previousCode
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
await updateCustomer(props.customer.id, payload as Customer)
|
||||
message.success('کد حسابداری ذخیره شد.')
|
||||
emit('success')
|
||||
close()
|
||||
await maybeSyncTahesabWallet(props.customer.id, previousCode, normalized)
|
||||
if (needsWalletAsk) {
|
||||
try {
|
||||
const preview = props.provider === 'zarin'
|
||||
? await previewCustomerWalletFromZarin(props.customer.id, normalized)
|
||||
: await previewCustomerWalletFromTahesab(props.customer.id, normalized)
|
||||
|
||||
if (preview.needs_decision || preview.result?.needs_decision) {
|
||||
pendingPayload.value = {
|
||||
customerId: props.customer.id,
|
||||
body: payload as Record<string, string>,
|
||||
nextCode: normalized,
|
||||
}
|
||||
decision.value = preview.result ?? null
|
||||
decisionVisible.value = true
|
||||
return
|
||||
}
|
||||
if (preview.ok === false && preview.message) {
|
||||
message.warning(preview.message + ' — فقط کد ذخیره میشود')
|
||||
}
|
||||
} catch {
|
||||
message.warning('مانده حسابداری خوانده نشد — فقط کد ذخیره میشود')
|
||||
}
|
||||
}
|
||||
|
||||
await saveCode(props.customer.id, payload as Record<string, string>)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
} finally {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="min-w-0 w-full max-w-full overflow-x-hidden">
|
||||
<BasicShowContext title="لاگها و اسناد پرگار">
|
||||
<BasicShowContext title="لاگها و اسناد پرگار" :help="customerPargarLogsIntro">
|
||||
<div class="min-w-0 w-full max-w-full overflow-x-auto">
|
||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
@@ -110,6 +110,7 @@ import {
|
||||
pargarTypeLabel
|
||||
} from '@/pages/menuPages/accounting/utils/pargarDisplay'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { customerPargarLogsIntro } from '@/utils/adminHelpCopy'
|
||||
|
||||
const props = defineProps<{
|
||||
customerId?: number
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-model:visible="visibleProxy"
|
||||
:width="isMobile ? '92vw' : '28rem'"
|
||||
:width="isMobile ? '92vw' : '36rem'"
|
||||
title="تصمیم برای مانده حساب"
|
||||
:custom-footer="true"
|
||||
cancel-text="بعداً"
|
||||
@@ -9,7 +9,7 @@
|
||||
>
|
||||
<div class="flex flex-col gap-3 text-sm" style="color: var(--admin-text)">
|
||||
<p class="m-0" style="color: var(--admin-text-secondary)">
|
||||
موجودی اپ با مانده تهحساب فرق دارد. کدام را اعمال کنیم؟
|
||||
موجودی اپ با مانده {{ sourceLabel }} فرق دارد. دو مانده جمع نمیشوند؛ یکی را پس از بررسی سندها تأیید کنید.
|
||||
</p>
|
||||
<div class="rounded-lg border border-base p-3 space-y-2" style="background: var(--admin-bg-muted)">
|
||||
<div class="flex justify-between gap-2">
|
||||
@@ -17,8 +17,12 @@
|
||||
<strong dir="ltr">{{ formatGold(appGold) }}</strong>
|
||||
</div>
|
||||
<div class="flex justify-between gap-2">
|
||||
<span style="color: var(--admin-text-secondary)">مانده تهحساب (طلا)</span>
|
||||
<strong dir="ltr">{{ formatGold(tahesabGold) }}</strong>
|
||||
<span style="color: var(--admin-text-secondary)">مانده {{ sourceLabel }} (طلا)</span>
|
||||
<strong dir="ltr">{{ formatGold(sourceGoldValue) }}</strong>
|
||||
</div>
|
||||
<div class="flex justify-between gap-2">
|
||||
<span style="color: var(--admin-text-secondary)">اختلاف طلا</span>
|
||||
<strong dir="ltr">{{ formatDeltaGold(goldDeltaValue) }}</strong>
|
||||
</div>
|
||||
<div class="h-px" style="background: var(--admin-border)" />
|
||||
<div class="flex justify-between gap-2">
|
||||
@@ -26,13 +30,62 @@
|
||||
<strong dir="ltr">{{ formatCash(appCash) }}</strong>
|
||||
</div>
|
||||
<div class="flex justify-between gap-2">
|
||||
<span style="color: var(--admin-text-secondary)">مانده تهحساب (ریال)</span>
|
||||
<strong dir="ltr">{{ formatCash(tahesabCash) }}</strong>
|
||||
<span style="color: var(--admin-text-secondary)">مانده {{ sourceLabel }} (ریال)</span>
|
||||
<strong dir="ltr">{{ formatCash(sourceCashValue) }}</strong>
|
||||
</div>
|
||||
<div class="flex justify-between gap-2">
|
||||
<span style="color: var(--admin-text-secondary)">اختلاف ریال</span>
|
||||
<strong dir="ltr">{{ formatDeltaCash(rialDeltaValue) }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="showDocs" class="grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
<div class="rounded-lg border border-base p-2.5 min-w-0">
|
||||
<p class="m-0 mb-1.5 text-xs font-600">سندهای کیف اپ</p>
|
||||
<p class="m-0 mb-1.5 text-xs" style="color: var(--admin-text-secondary)">آخرین تراکنشهای کیف اصلی</p>
|
||||
<div v-if="walletDocs.length" class="max-h-32 overflow-y-auto flex flex-col gap-1.5">
|
||||
<div
|
||||
v-for="doc in walletDocs"
|
||||
:key="'w-' + doc.id"
|
||||
class="rounded-md border border-base px-2 py-1.5 text-xs"
|
||||
>
|
||||
<div class="font-600 truncate">{{ doc.title || 'تراکنش' }}</div>
|
||||
<div class="flex justify-between gap-2 mt-0.5" style="color: var(--admin-text-secondary)">
|
||||
<span>{{ formatDocDate(doc.created_at) }}</span>
|
||||
<span dir="ltr">{{ formatGold(doc.gold) }} طلا · {{ formatCash(doc.cash) }} ریال</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p v-else class="m-0 text-xs" style="color: var(--admin-text-secondary)">سندی در کیف ثبت نشده</p>
|
||||
</div>
|
||||
<div class="rounded-lg border border-base p-2.5 min-w-0">
|
||||
<p class="m-0 mb-1.5 text-xs font-600">سندهای {{ sourceLabel }}</p>
|
||||
<p class="m-0 mb-1.5 text-xs" style="color: var(--admin-text-secondary)">آخرین اسناد حسابداری این مشتری</p>
|
||||
<div v-if="sourceDocs.length" class="max-h-32 overflow-y-auto flex flex-col gap-1.5">
|
||||
<div
|
||||
v-for="doc in sourceDocs"
|
||||
:key="'s-' + doc.id"
|
||||
class="rounded-md border border-base px-2 py-1.5 text-xs"
|
||||
>
|
||||
<div class="font-600 truncate">{{ doc.title || 'سند' }}</div>
|
||||
<div class="flex justify-between gap-2 mt-0.5" style="color: var(--admin-text-secondary)">
|
||||
<span>{{ formatDocDate(doc.date || doc.created_at) }}</span>
|
||||
<span dir="ltr">
|
||||
<template v-if="doc.gold != null || doc.cash != null">
|
||||
{{ formatGold(doc.gold) }} طلا · {{ formatCash(doc.cash) }} ریال
|
||||
</template>
|
||||
<template v-else>{{ formatGold(doc.amount) }} · {{ doc.type || '—' }}</template>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p v-else class="m-0 text-xs" style="color: var(--admin-text-secondary)">سندی از حسابداری نیست</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<a-button type="primary" block :loading="loading === 'overwrite'" :disabled="!!loading" @click="choose('overwrite')">
|
||||
اعمال مانده تهحساب روی کیف
|
||||
اعمال مانده {{ sourceLabel }} روی کیف
|
||||
</a-button>
|
||||
<a-button block :loading="loading === 'keep'" :disabled="!!loading" @click="choose('keep')">
|
||||
نگه داشتن موجودی فعلی اپ
|
||||
@@ -48,6 +101,7 @@
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import type { TahesabPreviewDoc } from '@/api/tahesab'
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
@@ -55,6 +109,13 @@ const props = defineProps<{
|
||||
appCash?: number | null
|
||||
tahesabGold?: number | null
|
||||
tahesabCash?: number | null
|
||||
sourceGold?: number | null
|
||||
sourceCash?: number | null
|
||||
goldDelta?: number | null
|
||||
rialDelta?: number | null
|
||||
sourceLabel?: string
|
||||
walletDocs?: TahesabPreviewDoc[]
|
||||
tahesabDocs?: TahesabPreviewDoc[]
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -63,6 +124,22 @@ const emit = defineEmits<{
|
||||
}>()
|
||||
|
||||
const loading = ref<'overwrite' | 'keep' | null>(null)
|
||||
const sourceLabel = computed(() => props.sourceLabel || 'تهحساب')
|
||||
const sourceGoldValue = computed(() => props.sourceGold ?? props.tahesabGold)
|
||||
const sourceCashValue = computed(() => props.sourceCash ?? props.tahesabCash)
|
||||
const goldDeltaValue = computed(() => {
|
||||
if (props.goldDelta != null && !Number.isNaN(Number(props.goldDelta))) return Number(props.goldDelta)
|
||||
return Number(sourceGoldValue.value ?? 0) - Number(props.appGold ?? 0)
|
||||
})
|
||||
const rialDeltaValue = computed(() => {
|
||||
if (props.rialDelta != null && !Number.isNaN(Number(props.rialDelta))) return Number(props.rialDelta)
|
||||
return Number(sourceCashValue.value ?? 0) - Number(props.appCash ?? 0)
|
||||
})
|
||||
const walletDocs = computed(() => props.walletDocs ?? [])
|
||||
const sourceDocs = computed(() => props.tahesabDocs ?? [])
|
||||
const showDocs = computed(
|
||||
() => sourceLabel.value === 'تهحساب' || walletDocs.value.length > 0 || sourceDocs.value.length > 0
|
||||
)
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
@@ -86,6 +163,25 @@ function formatCash(v?: number | null) {
|
||||
return Math.round(Number(v)).toLocaleString('fa-IR')
|
||||
}
|
||||
|
||||
function formatDeltaGold(v: number) {
|
||||
if (Number.isNaN(v)) return '—'
|
||||
const sign = v > 0 ? '+' : ''
|
||||
return sign + formatGold(v)
|
||||
}
|
||||
|
||||
function formatDeltaCash(v: number) {
|
||||
if (Number.isNaN(v)) return '—'
|
||||
const sign = v > 0 ? '+' : ''
|
||||
return sign + formatCash(v)
|
||||
}
|
||||
|
||||
function formatDocDate(value?: string | null) {
|
||||
if (!value) return '—'
|
||||
const d = new Date(value)
|
||||
if (Number.isNaN(d.getTime())) return value
|
||||
return d.toLocaleDateString('fa-IR')
|
||||
}
|
||||
|
||||
function close() {
|
||||
visibleProxy.value = false
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<template>
|
||||
<div class="tahesab-wallet-sync">
|
||||
<div class="tahesab-wallet-sync" :class="{ 'tahesab-wallet-sync--row': layout === 'row' }">
|
||||
<div class="tahesab-wallet-sync__head">
|
||||
<div class="tahesab-wallet-sync__icon" aria-hidden="true">
|
||||
<Icon icon="vuesax-linear:refresh-circle" :size="18" color="var(--admin-primary, #10913A)" />
|
||||
</div>
|
||||
<div class="tahesab-wallet-sync__copy min-w-0 flex-1">
|
||||
<p class="tahesab-wallet-sync__title">همگامسازی با تهحساب</p>
|
||||
<p class="tahesab-wallet-sync__title">همگامسازی مانده</p>
|
||||
<p class="tahesab-wallet-sync__hint">
|
||||
{{
|
||||
canSync
|
||||
? 'مانده طلا و ریال تهحساب را با کیف اپ مقایسه میکند؛ اگر تداخل باشد شما تصمیم میگیرید'
|
||||
? 'اول مانده و سندها را میبینید؛ بعد تأیید میکنید. دو مانده جمع نمیشوند'
|
||||
: 'ابتدا کد حسابداری تهحساب را برای این مشتری ثبت کنید'
|
||||
}}
|
||||
</p>
|
||||
@@ -17,9 +17,9 @@
|
||||
</div>
|
||||
<a-button
|
||||
type="primary"
|
||||
block
|
||||
size="small"
|
||||
class="tahesab-wallet-sync__btn"
|
||||
:block="layout !== 'row'"
|
||||
:loading="loading"
|
||||
:disabled="!canSync || loading"
|
||||
@click="$emit('sync', 'ask')"
|
||||
@@ -32,10 +32,14 @@
|
||||
<script setup lang="ts">
|
||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
|
||||
defineProps<{
|
||||
loading?: boolean
|
||||
canSync?: boolean
|
||||
}>()
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
loading?: boolean
|
||||
canSync?: boolean
|
||||
layout?: 'stack' | 'row'
|
||||
}>(),
|
||||
{ layout: 'stack' },
|
||||
)
|
||||
|
||||
defineEmits<{
|
||||
(e: 'sync', mode: 'ask' | 'overwrite' | 'keep'): void
|
||||
@@ -48,6 +52,24 @@ defineEmits<{
|
||||
background: var(--admin-surface-muted, var(--admin-bg-muted, #f8fafc));
|
||||
}
|
||||
|
||||
.tahesab-wallet-sync--row {
|
||||
@apply flex flex-col gap-2.5;
|
||||
}
|
||||
|
||||
.tahesab-wallet-sync--row .tahesab-wallet-sync__head {
|
||||
@apply mb-0 min-w-0 flex-1;
|
||||
}
|
||||
|
||||
@media (min-width: 640px) {
|
||||
.tahesab-wallet-sync--row {
|
||||
@apply flex-row items-center gap-3;
|
||||
}
|
||||
|
||||
.tahesab-wallet-sync--row .tahesab-wallet-sync__btn {
|
||||
@apply shrink-0;
|
||||
}
|
||||
}
|
||||
|
||||
.tahesab-wallet-sync__head {
|
||||
@apply mb-2.5 flex items-start gap-2;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<div class="zarin-wallet-sync">
|
||||
<div class="zarin-wallet-sync__head">
|
||||
<div class="zarin-wallet-sync__icon" aria-hidden="true">
|
||||
<Icon icon="vuesax-linear:refresh-circle" :size="18" color="var(--admin-primary, #10913A)" />
|
||||
</div>
|
||||
<div class="zarin-wallet-sync__copy min-w-0 flex-1">
|
||||
<p class="zarin-wallet-sync__title">همگامسازی با زرین</p>
|
||||
<p class="zarin-wallet-sync__hint">
|
||||
{{
|
||||
canSync
|
||||
? 'مانده طلا و ریال زرین را با کیف اپ مقایسه میکند؛ اگر تداخل باشد شما تصمیم میگیرید'
|
||||
: 'ابتدا کد حسابداری زرین را برای این مشتری ثبت کنید'
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<a-button
|
||||
type="primary"
|
||||
block
|
||||
size="small"
|
||||
class="zarin-wallet-sync__btn"
|
||||
:loading="loading"
|
||||
:disabled="!canSync || loading"
|
||||
@click="$emit('sync', 'ask')"
|
||||
>
|
||||
بررسی و همگامسازی مانده
|
||||
</a-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
|
||||
defineProps<{
|
||||
loading?: boolean
|
||||
canSync?: boolean
|
||||
}>()
|
||||
|
||||
defineEmits<{
|
||||
(e: 'sync', mode: 'ask' | 'overwrite' | 'keep'): void
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.zarin-wallet-sync {
|
||||
@apply mb-2.5 rounded-xl border border-base p-2.5;
|
||||
background: var(--admin-surface-muted, var(--admin-bg-muted, #f8fafc));
|
||||
}
|
||||
|
||||
.zarin-wallet-sync__head {
|
||||
@apply mb-2.5 flex items-start gap-2;
|
||||
}
|
||||
|
||||
.zarin-wallet-sync__icon {
|
||||
@apply flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-50;
|
||||
}
|
||||
|
||||
.zarin-wallet-sync__title {
|
||||
@apply m-0 text-sm font-700;
|
||||
color: var(--admin-text, inherit);
|
||||
}
|
||||
|
||||
.zarin-wallet-sync__hint {
|
||||
@apply m-0 mt-0.5 text-xs leading-5;
|
||||
color: var(--admin-text-secondary, #6b7280);
|
||||
}
|
||||
|
||||
.zarin-wallet-sync__btn {
|
||||
@apply font-600;
|
||||
}
|
||||
</style>
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicShowContext title="لیست دارایی ها">
|
||||
<BasicShowContext title="لیست دارایی ها" :help="customerFundsIntro">
|
||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex items-center justify-center gap-2">
|
||||
@@ -64,6 +64,7 @@ import {
|
||||
import BasicActionSheet from '@/components/BasicActionSheet.vue'
|
||||
import BasicShowContext from '@/components/BasicShowContext.vue'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { customerFundsIntro } from '@/utils/adminHelpCopy'
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const [assetFundsSubmit] = useBaseTable()
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<BaseIcon icon="vuesax-linear:medal-star" Size="16px" />
|
||||
</BaseButton>
|
||||
</div>
|
||||
<BasicShowContext title="لیست اقساط">
|
||||
<BasicShowContext title="لیست اقساط" :help="goldCreditInstallmentsIntro">
|
||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl" />
|
||||
</BasicShowContext>
|
||||
</div>
|
||||
@@ -59,6 +59,7 @@ import type { TableInput } from '@core/type/baseTable'
|
||||
import useBaseTable from '@core/components/BaseTable/hooks/useBaseTable'
|
||||
import { cols } from '@/pages/menuPages/customers/base/hooks/goldCreditColumns'
|
||||
import { getCustomerGoldCreditInstallments, type GoldCredit } from '@/api/goldCredit'
|
||||
import { goldCreditInstallmentsIntro } from '@/utils/adminHelpCopy'
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicShowContext title="لیست قلک ها">
|
||||
<BasicShowContext title="لیست قلک ها" :help="customerPiggyFundsIntro">
|
||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex items-center justify-center gap-2">
|
||||
@@ -45,6 +45,7 @@ import { computed, ref } from 'vue'
|
||||
import { getPiggyFundsTable, getPiggyFundTransactionsTable } from '@/api/user'
|
||||
import BasicActionSheet from '@/components/BasicActionSheet.vue'
|
||||
import BasicShowContext from '@/components/BasicShowContext.vue'
|
||||
import { customerPiggyFundsIntro } from '@/utils/adminHelpCopy'
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const [txSubmit] = useBaseTable()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicShowContext title="لیست معرفی کرده ها">
|
||||
<BasicShowContext title="لیست معرفی کرده ها" :help="customerReferralsIntro">
|
||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
||||
</BaseTable>
|
||||
</BasicShowContext>
|
||||
@@ -28,6 +28,7 @@ import {toJalaliNoTime} from '@core/utils/useDataTime'
|
||||
import type {Customer} from '@/model/customer'
|
||||
import {onMounted} from 'vue'
|
||||
import {getReferralsTable} from "@/api/user";
|
||||
import { customerReferralsIntro } from '@/utils/adminHelpCopy'
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="h-full min-h-0 min-w-0 max-w-full overflow-hidden">
|
||||
<BasicShowContext title="لیست مشتریان">
|
||||
<BasicShowContext title="لیست مشتریان" :help="customersPageIntro">
|
||||
<template #extra>
|
||||
<BaseButton
|
||||
v-if="isMobile"
|
||||
@@ -273,6 +273,7 @@ import {
|
||||
initWalletSettingsFromApi
|
||||
} from '@/utils/config'
|
||||
import { displayAccountingCode, isValidAccountingCode } from '@/utils/accountingCode'
|
||||
import { customersPageIntro } from '@/utils/adminHelpCopy'
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const emits = defineEmits(['delete', 'edit', 'add', 'info', 'chargeWallet'])
|
||||
|
||||
@@ -203,6 +203,12 @@
|
||||
:can-sync="tahesabWalletCanSync"
|
||||
@sync="syncTahesabWallet"
|
||||
/>
|
||||
<ZarinWalletSyncAction
|
||||
v-if="zarinWalletSyncVisible"
|
||||
:loading="zarinSyncLoading"
|
||||
:can-sync="zarinWalletCanSync"
|
||||
@sync="syncZarinWallet"
|
||||
/>
|
||||
<CustomerWalletBalancePanel
|
||||
:key="`wallet-mobile-${walletPanelKey}`"
|
||||
ref="walletPanelMobile"
|
||||
@@ -230,6 +236,12 @@
|
||||
:can-sync="tahesabWalletCanSync"
|
||||
@sync="syncTahesabWallet"
|
||||
/>
|
||||
<ZarinWalletSyncAction
|
||||
v-if="zarinWalletSyncVisible"
|
||||
:loading="zarinSyncLoading"
|
||||
:can-sync="zarinWalletCanSync"
|
||||
@sync="syncZarinWallet"
|
||||
/>
|
||||
<CustomerWalletBalancePanel
|
||||
:key="`wallet-desktop-${walletPanelKey}`"
|
||||
ref="walletPanelDesktop"
|
||||
@@ -262,6 +274,12 @@
|
||||
<CustomerPargarLogsTable ref="pargarLogsTable" :customer-id="userInfo?.id" />
|
||||
</a-tab-pane>
|
||||
<a-tab-pane v-if="tahesabDocsVisible" key="اسناد تهحساب" tab="اسناد تهحساب">
|
||||
<TahesabWalletSyncAction
|
||||
layout="row"
|
||||
:loading="tahesabSyncLoading"
|
||||
:can-sync="tahesabWalletCanSync"
|
||||
@sync="syncTahesabWallet"
|
||||
/>
|
||||
<CustomerTahesabDocsTable ref="tahesabDocsTable" :customer-id="userInfo?.id" />
|
||||
</a-tab-pane>
|
||||
<a-tab-pane v-if="zarinDocsVisible" key="اسناد زرین" tab="اسناد زرین">
|
||||
@@ -289,10 +307,15 @@
|
||||
/>
|
||||
<TahesabMandeDecisionModal
|
||||
v-model:visible="tahesabDecisionVisible"
|
||||
:source-label="walletDecisionLabel"
|
||||
:app-gold="tahesabDecision?.app_gold"
|
||||
:app-cash="tahesabDecision?.app_cash"
|
||||
:tahesab-gold="tahesabDecision?.tahesab_gold"
|
||||
:tahesab-cash="tahesabDecision?.tahesab_cash"
|
||||
:tahesab-gold="tahesabDecision?.tahesab_gold ?? tahesabDecision?.zarin_gold"
|
||||
:tahesab-cash="tahesabDecision?.tahesab_cash ?? tahesabDecision?.zarin_cash"
|
||||
:gold-delta="tahesabDecision?.gold_delta"
|
||||
:rial-delta="tahesabDecision?.rial_delta"
|
||||
:wallet-docs="tahesabDecision?.wallet_docs"
|
||||
:tahesab-docs="tahesabDecision?.tahesab_docs"
|
||||
@decide="onTahesabMandeDecide"
|
||||
/>
|
||||
<BasicInfoModal
|
||||
@@ -359,11 +382,17 @@ import { displayAccountingCode, isValidAccountingCode } from '@/utils/accounting
|
||||
import CustomerPresenceBadge from '@/pages/menuPages/customers/base/components/CustomerPresenceBadge.vue'
|
||||
import { syncCustomerWalletFromPargar, type PargarSyncWalletResult } from '@/api/pargar'
|
||||
import {
|
||||
previewCustomerWalletFromTahesab,
|
||||
syncCustomerWalletFromTahesab,
|
||||
type TahesabWalletSyncResult,
|
||||
} from '@/api/tahesab'
|
||||
import {
|
||||
syncCustomerWalletFromZarin,
|
||||
type ZarinWalletSyncResult,
|
||||
} from '@/api/zarin'
|
||||
import PargarWalletSyncAction from './components/PargarWalletSyncAction.vue'
|
||||
import TahesabWalletSyncAction from './components/TahesabWalletSyncAction.vue'
|
||||
import ZarinWalletSyncAction from './components/ZarinWalletSyncAction.vue'
|
||||
import TahesabMandeDecisionModal from './components/TahesabMandeDecisionModal.vue'
|
||||
|
||||
const fnameHelp: DashboardHelp = {
|
||||
@@ -761,8 +790,11 @@ const accountingCodeValue = computed(() => {
|
||||
|
||||
const pargarSyncLoading = ref(false)
|
||||
const tahesabSyncLoading = ref(false)
|
||||
const zarinSyncLoading = ref(false)
|
||||
const tahesabDecisionVisible = ref(false)
|
||||
const tahesabDecision = ref<TahesabWalletSyncResult['result'] | null>(null)
|
||||
const tahesabDecision = ref<(TahesabWalletSyncResult['result'] & { zarin_gold?: number; zarin_cash?: number }) | null>(null)
|
||||
const walletDecisionProvider = ref<'tahesab' | 'zarin'>('tahesab')
|
||||
const walletDecisionLabel = computed(() => walletDecisionProvider.value === 'zarin' ? 'زرین' : 'تهحساب')
|
||||
const walletPanelDesktop = ref<{ reload?: () => void | Promise<void> } | null>(null)
|
||||
const walletPanelMobile = ref<{ reload?: () => void | Promise<void> } | null>(null)
|
||||
const walletPanelKey = ref(0)
|
||||
@@ -776,6 +808,10 @@ const tahesabWalletSyncVisible = computed(
|
||||
() => accountingProviderSetting.value === 'tahesab'
|
||||
)
|
||||
|
||||
const zarinWalletSyncVisible = computed(
|
||||
() => accountingProviderSetting.value === 'zarin'
|
||||
)
|
||||
|
||||
const tahesabDocsVisible = computed(() => accountingProviderSetting.value === 'tahesab')
|
||||
const zarinDocsVisible = computed(() => accountingProviderSetting.value === 'zarin')
|
||||
|
||||
@@ -787,6 +823,10 @@ const tahesabWalletCanSync = computed(() =>
|
||||
isValidAccountingCode(userInfo.value?.moshtari_code)
|
||||
)
|
||||
|
||||
const zarinWalletCanSync = computed(() =>
|
||||
isValidAccountingCode(userInfo.value?.moshtari_code)
|
||||
)
|
||||
|
||||
async function refreshWalletPanels() {
|
||||
await nextTick()
|
||||
walletPanelKey.value += 1
|
||||
@@ -797,7 +837,8 @@ async function refreshWalletPanels() {
|
||||
])
|
||||
}
|
||||
|
||||
function openTahesabDecision(result?: TahesabWalletSyncResult['result']) {
|
||||
function openTahesabDecision(result?: TahesabWalletSyncResult['result'], provider: 'tahesab' | 'zarin' = 'tahesab') {
|
||||
walletDecisionProvider.value = provider
|
||||
tahesabDecision.value = result ?? null
|
||||
tahesabDecisionVisible.value = true
|
||||
}
|
||||
@@ -806,14 +847,28 @@ async function syncTahesabWallet(mode: 'ask' | 'overwrite' | 'keep' = 'ask') {
|
||||
if (!userInfo.value?.id || !tahesabWalletCanSync.value || tahesabSyncLoading.value) return
|
||||
tahesabSyncLoading.value = true
|
||||
try {
|
||||
if (mode === 'ask') {
|
||||
const preview = await previewCustomerWalletFromTahesab(userInfo.value.id)
|
||||
if (!preview.ok && !preview.result?.ok) {
|
||||
message.warning(preview.message || 'مانده از تهحساب خوانده نشد')
|
||||
return
|
||||
}
|
||||
if (!preview.needs_decision && !preview.result?.needs_decision) {
|
||||
message.info(preview.message || 'مانده با تهحساب یکسان است')
|
||||
return
|
||||
}
|
||||
openTahesabDecision(preview.result, 'tahesab')
|
||||
return
|
||||
}
|
||||
|
||||
const res = await syncCustomerWalletFromTahesab(userInfo.value.id, {
|
||||
ask_if_conflict: mode === 'ask',
|
||||
ask_if_conflict: false,
|
||||
overwrite: mode === 'overwrite',
|
||||
keep: mode === 'keep',
|
||||
})
|
||||
|
||||
if (res.needs_decision || res.result?.needs_decision) {
|
||||
openTahesabDecision(res.result)
|
||||
openTahesabDecision(res.result, 'tahesab')
|
||||
return
|
||||
}
|
||||
|
||||
@@ -846,9 +901,55 @@ async function syncTahesabWallet(mode: 'ask' | 'overwrite' | 'keep' = 'ask') {
|
||||
|
||||
async function onTahesabMandeDecide(mode: 'overwrite' | 'keep') {
|
||||
tahesabDecisionVisible.value = false
|
||||
if (walletDecisionProvider.value === 'zarin') {
|
||||
await syncZarinWallet(mode)
|
||||
return
|
||||
}
|
||||
await syncTahesabWallet(mode)
|
||||
}
|
||||
|
||||
async function syncZarinWallet(mode: 'ask' | 'overwrite' | 'keep' = 'ask') {
|
||||
if (!userInfo.value?.id || !zarinWalletCanSync.value || zarinSyncLoading.value) return
|
||||
zarinSyncLoading.value = true
|
||||
try {
|
||||
const res = await syncCustomerWalletFromZarin(userInfo.value.id, {
|
||||
ask_if_conflict: mode === 'ask',
|
||||
overwrite: mode === 'overwrite',
|
||||
keep: mode === 'keep',
|
||||
})
|
||||
|
||||
if (res.needs_decision || res.result?.needs_decision) {
|
||||
openTahesabDecision(res.result, 'zarin')
|
||||
return
|
||||
}
|
||||
|
||||
if (res.result?.applied || res.ok) {
|
||||
message.success(res.message || 'مانده از زرین روی کیف اعمال شد')
|
||||
} else {
|
||||
message.info(res.message || 'تغییری برای اعمال نبود')
|
||||
}
|
||||
|
||||
await refreshWalletPanels()
|
||||
refreshTransactionTable()
|
||||
refreshTable()
|
||||
} catch (e: unknown) {
|
||||
const data = (e as { response?: { data?: ZarinWalletSyncResult } })?.response?.data
|
||||
const status = (e as { response?: { status?: number } })?.response?.status
|
||||
|
||||
await refreshWalletPanels()
|
||||
refreshTransactionTable()
|
||||
refreshTable()
|
||||
|
||||
if (data?.result?.applied || data?.ok) {
|
||||
message.success(data?.message || 'مانده از زرین روی کیف اعمال شد')
|
||||
} else if (status !== 422) {
|
||||
message.warning(data?.message || 'اعمال مانده از زرین ناموفق بود')
|
||||
}
|
||||
} finally {
|
||||
zarinSyncLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function syncPargarWallet(force = false) {
|
||||
if (!userInfo.value?.id || !pargarWalletCanSync.value || pargarSyncLoading.value) return
|
||||
pargarSyncLoading.value = true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="h-full min-h-0 w-full">
|
||||
<BasicShowContext title="اعتبار">
|
||||
<BasicShowContext title="اعتبار" :help="goldCreditPageIntro">
|
||||
<a-tabs v-model:activeKey="activeTab" class="gold-credit-tabs h-full" destroy-inactive-tab-pane>
|
||||
<a-tab-pane key="requests" tab="درخواستها">
|
||||
<GoldCreditRequestsTab />
|
||||
@@ -17,6 +17,7 @@
|
||||
import { ref } from 'vue'
|
||||
import GoldCreditRequestsTab from './requests/index.vue'
|
||||
import GoldCreditActiveTab from './active/index.vue'
|
||||
import { goldCreditPageIntro } from '@/utils/adminHelpCopy'
|
||||
|
||||
const activeTab = ref('requests')
|
||||
</script>
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
<div class="online-page__hero shrink-0 mb-4">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<h2 class="online-page__title m-0">کاربران آنلاین</h2>
|
||||
<h2 class="online-page__title m-0 inline-flex items-center gap-1.5">
|
||||
کاربران آنلاین
|
||||
<AdminFieldHelp :text="customersOnlinePageIntro" size="sm" />
|
||||
</h2>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="online-page__count">
|
||||
@@ -297,6 +300,8 @@ import { toJalali, toJalaliNoTime } from '@core/utils/useDataTime'
|
||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import BasicActionSheet from '@/components/BasicActionSheet.vue'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import AdminFieldHelp from '@/components/AdminFieldHelp.vue'
|
||||
import { customersOnlinePageIntro } from '@/utils/adminHelpCopy'
|
||||
import { MODAL_ABOVE_ACTION_SHEET_Z_INDEX } from '@/constants/overlayZIndex'
|
||||
import { inputLenRules, inputRules } from '@/utils/inputRules'
|
||||
import CustomerMobileDetailSheet from '@/pages/menuPages/customers/base/components/CustomerMobileDetailSheet.vue'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="h-full min-h-0 min-w-0 max-w-full overflow-hidden">
|
||||
<BasicShowContext title="پکیجهای قیمت ویژه">
|
||||
<BasicShowContext title="پکیجهای قیمت ویژه" :help="specialPricePageIntro">
|
||||
<template v-if="isMobile" #extra>
|
||||
<BaseButton type="primary" size="small" icon="vuesax-linear:add" @click="emits('add')">
|
||||
افزودن
|
||||
@@ -55,6 +55,7 @@ import { getCustomerSpecialPricePackageTable } from '@/api/customerSpecialPrice'
|
||||
import { getSpecialPricePackageColumns } from '../hooks/specialPriceColumns'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { ref } from 'vue'
|
||||
import { specialPricePageIntro } from '@/utils/adminHelpCopy'
|
||||
|
||||
const emits = defineEmits<{
|
||||
(e: 'add'): void
|
||||
|
||||
Reference in New Issue
Block a user