2026-07-05 16:41:45 +03:30
|
|
|
import useAxios from '@core/utils/useAxios'
|
|
|
|
|
import type { TableInput } from '@core/type/baseTable'
|
|
|
|
|
|
|
|
|
|
export interface PargarRecord {
|
|
|
|
|
id: number
|
|
|
|
|
customer_id?: number
|
|
|
|
|
amount?: number
|
|
|
|
|
desc?: string
|
|
|
|
|
type?: string
|
|
|
|
|
sync_status?: 'pending' | 'success' | 'failed'
|
|
|
|
|
sync_log?: string | null
|
|
|
|
|
pargar_ref?: string | null
|
|
|
|
|
data?: string | null
|
|
|
|
|
res?: string | null
|
|
|
|
|
created_at?: string
|
|
|
|
|
customer?: {
|
|
|
|
|
id?: number
|
|
|
|
|
name?: string
|
|
|
|
|
mobile?: string
|
|
|
|
|
pargar_account_id?: string | number | null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getPargarTable = async (params: TableInput) =>
|
|
|
|
|
await useAxios.post<PargarRecord[]>('/admin/pargar/table', params)
|
|
|
|
|
|
|
|
|
|
export const getPargarDetail = async (id: number) =>
|
|
|
|
|
await useAxios.get<PargarRecord>(`/admin/pargar/${id}`)
|
|
|
|
|
|
|
|
|
|
export const retryPargarSanad = async (id: number) =>
|
|
|
|
|
await useAxios.post<{ ok: boolean; message: string; pargar?: PargarRecord }>(`/admin/pargar/${id}/retry`)
|
|
|
|
|
|
|
|
|
|
export const registerCustomerInPargar = async (customerId: number) =>
|
|
|
|
|
await useAxios.post<{ ok: boolean; message: string; pargar_account_id?: string | number }>(
|
|
|
|
|
`/admin/customer/${customerId}/pargar/register`
|
|
|
|
|
)
|
|
|
|
|
|
2026-07-21 13:26:04 +03:30
|
|
|
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 }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-21 16:58:21 +03:30
|
|
|
export const syncCustomerWalletFromPargar = async (customerId: number, force = false) =>
|
|
|
|
|
await useAxios.post<PargarSyncWalletResult>(
|
|
|
|
|
`/admin/customer/${customerId}/pargar/sync-wallet`,
|
|
|
|
|
{ force }
|
|
|
|
|
)
|
2026-07-21 13:26:04 +03:30
|
|
|
|
2026-07-05 16:41:45 +03:30
|
|
|
export interface PanelOnlyCustomer {
|
|
|
|
|
id: number
|
|
|
|
|
name: string
|
|
|
|
|
mobile: string
|
|
|
|
|
created_at: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PargarOnlyCustomer {
|
|
|
|
|
code: number
|
|
|
|
|
name: string
|
|
|
|
|
tel: string
|
|
|
|
|
gid: number | null
|
|
|
|
|
group: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface CustomerSyncStatus {
|
|
|
|
|
panel_total: number
|
|
|
|
|
panel_registered: number
|
|
|
|
|
panel_only: number
|
|
|
|
|
pargar_total: number
|
|
|
|
|
pargar_only_count: number
|
|
|
|
|
panel_only_list: {
|
|
|
|
|
data: PanelOnlyCustomer[]
|
|
|
|
|
current_page: number
|
|
|
|
|
last_page: number
|
|
|
|
|
total: number
|
|
|
|
|
}
|
|
|
|
|
pargar_only_list: {
|
|
|
|
|
data: PargarOnlyCustomer[]
|
|
|
|
|
current_page: number
|
|
|
|
|
last_page: number
|
|
|
|
|
total: number
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getCustomerSyncStatus = async (params?: {
|
|
|
|
|
search?: string
|
|
|
|
|
page?: number
|
|
|
|
|
pargar_page?: number
|
|
|
|
|
}) => await useAxios.get<CustomerSyncStatus>('/admin/pargar/customer-sync/status', { params })
|
|
|
|
|
|
|
|
|
|
export interface SyncPanelResult {
|
|
|
|
|
ok: boolean
|
|
|
|
|
success: number
|
|
|
|
|
failed: number
|
|
|
|
|
errors: { name: string; mobile: string; error: string }[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const syncPanelToPargar = async () =>
|
|
|
|
|
await useAxios.post<SyncPanelResult>('/admin/pargar/customer-sync/panel-to-pargar')
|
|
|
|
|
|
|
|
|
|
export const importFromPargar = async (customers: PargarOnlyCustomer[]) =>
|
|
|
|
|
await useAxios.post<SyncPanelResult>('/admin/pargar/customer-sync/import-from-pargar', {
|
|
|
|
|
customers,
|
|
|
|
|
})
|