added pargar accounting
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
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`
|
||||
)
|
||||
|
||||
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,
|
||||
})
|
||||
Reference in New Issue
Block a user