Sync Tahesab wallet balance on import and let admins resolve conflicts.

Add customer search on the Tahesab-only list, bulk/per-customer mande sync UI, and a decision modal when app balance differs from Tahesab.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-30 14:16:36 +03:30
co-authored by Cursor
parent 084b449177
commit 04cc03fe25
7 changed files with 761 additions and 8 deletions
+69
View File
@@ -131,3 +131,72 @@ export const importFromTahesab = async (customers: TahesabOnlyCustomer[]) =>
await useAxios.post<SyncPanelResult>('/admin/tahesab/customer-sync/import-from-tahesab', {
customers,
})
export interface TahesabWalletSyncResult {
ok: boolean
needs_decision?: boolean
message: string
result?: {
applied: boolean
needs_decision?: boolean
skipped?: boolean
gold_delta?: number
rial_delta?: number
app_gold?: number
app_cash?: number
tahesab_gold?: number
tahesab_cash?: number
message: string
}
}
/** همگام‌سازی مانده یک مشتری با ته‌حساب */
export const syncCustomerWalletFromTahesab = async (
customerId: number,
opts?: { overwrite?: boolean; keep?: boolean; ask_if_conflict?: boolean }
) =>
await useAxios.post<TahesabWalletSyncResult>(
`/admin/customer/${customerId}/tahesab/sync-wallet`,
{
overwrite: opts?.overwrite ?? false,
keep: opts?.keep ?? false,
ask_if_conflict: opts?.ask_if_conflict ?? true,
}
)
export interface TahesabBulkWalletSyncChunk {
ok: boolean
message: string
total: number
offset: number
processed: number
next_offset: number
done: boolean
success: number
changed: number
needs_decision: number
failed: number
errors: { id: number; name: string; mobile?: string; error: string }[]
decisions: {
id: number
name: string
mobile?: string
app_gold?: number
app_cash?: number
tahesab_gold?: number
tahesab_cash?: number
message: string
}[]
}
/** یک دسته از همگام‌سازی ماندهٔ همهٔ مشتریان دارای کد ته‌حساب */
export const syncAllWalletsFromTahesabChunk = async (params?: {
offset?: number
limit?: number
overwrite?: boolean
}) =>
await useAxios.post<TahesabBulkWalletSyncChunk>('/admin/tahesab/wallet-sync/all', {
offset: params?.offset ?? 0,
limit: params?.limit ?? 20,
overwrite: params?.overwrite ?? false,
})