Files
boursecu_admin/src/api/tahesab.ts
T

93 lines
2.4 KiB
TypeScript
Raw Normal View History

2026-06-26 17:41:52 +03:30
import useAxios from '@core/utils/useAxios'
import type { TableInput } from '@core/type/baseTable'
export interface TahesabRecord {
id: number
customer_id?: number
amount?: number
desc?: string
type?: string
sync_status?: 'pending' | 'success' | 'failed'
sync_log?: string | null
tahesab_id?: string | null
data?: string | null
res?: string | null
created_at?: string
customer?: {
id?: number
name?: string
mobile?: string
moshtari_code?: string | number | null
}
}
export const getTahesabTable = async (params: TableInput) =>
await useAxios.post<TahesabRecord[]>('/admin/tahesab/table', params)
export const getTahesabDetail = async (id: number) =>
await useAxios.get<TahesabRecord>(`/admin/tahesab/${id}`)
export const retryTahesabSanad = async (id: number) =>
await useAxios.post<{ ok: boolean; message: string; tahesab?: TahesabRecord }>(`/admin/tahesab/${id}/retry`)
export const registerCustomerInTahesab = async (customerId: number) =>
await useAxios.post<{ ok: boolean; message: string; moshtari_code?: string | number }>(
`/admin/customer/${customerId}/tahesab/register`
)
2026-06-28 21:48:17 +03:30
export interface PanelOnlyCustomer {
id: number
name: string
mobile: string
created_at: string
}
export interface TahesabOnlyCustomer {
code: number
name: string
tel: string
gid: number | null
group: string
}
export interface CustomerSyncStatus {
panel_total: number
panel_registered: number
panel_only: number
tahesab_total: number
tahesab_only_count: number
panel_only_list: {
data: PanelOnlyCustomer[]
current_page: number
last_page: number
total: number
}
tahesab_only_list: {
data: TahesabOnlyCustomer[]
current_page: number
last_page: number
total: number
}
}
export const getCustomerSyncStatus = async (params?: {
search?: string
page?: number
tahesab_page?: number
}) => await useAxios.get<CustomerSyncStatus>('/admin/tahesab/customer-sync/status', { params })
export interface SyncPanelResult {
ok: boolean
success: number
failed: number
errors: { name: string; mobile: string; error: string }[]
}
export const syncPanelToTahesab = async () =>
await useAxios.post<SyncPanelResult>('/admin/tahesab/customer-sync/panel-to-tahesab')
export const importFromTahesab = async (customers: TahesabOnlyCustomer[]) =>
await useAxios.post<SyncPanelResult>('/admin/tahesab/customer-sync/import-from-tahesab', {
customers,
})