feat(chat): 新增后台客服会话工作台
This commit is contained in:
@@ -110,6 +110,11 @@ import type {
|
||||
AdminPickupProcessEvent,
|
||||
AdminPickupQuery,
|
||||
AdminPickupShop,
|
||||
AdminChatConversation,
|
||||
AdminChatCounts,
|
||||
AdminChatMessage,
|
||||
AdminChatMessagePage,
|
||||
AdminChatPage,
|
||||
ManualDisbursementPayload,
|
||||
OperatingExpensePage,
|
||||
OperatingExpensePayload,
|
||||
@@ -1554,4 +1559,86 @@ export async function settleAdminPickupFinancialAdjustment(
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function fetchAdminChats(query: {
|
||||
filter?: string
|
||||
stage?: string
|
||||
keyword?: string
|
||||
page?: number
|
||||
page_size?: number
|
||||
}) {
|
||||
const { data } = await adminClient.get<ApiResponse<Partial<AdminChatPage>>>('/admin/chats', {
|
||||
params: compactParams(query),
|
||||
})
|
||||
return {
|
||||
items: data.data.items ?? [],
|
||||
total: data.data.total ?? 0,
|
||||
page: data.data.page ?? query.page ?? 1,
|
||||
page_size: data.data.page_size ?? query.page_size ?? 20,
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchAdminChatCounts(query: {
|
||||
filter?: string
|
||||
stage?: string
|
||||
keyword?: string
|
||||
}) {
|
||||
const { data } = await adminClient.get<ApiResponse<AdminChatCounts>>('/admin/chats/counts', {
|
||||
params: compactParams(query),
|
||||
})
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function fetchAdminChatDetail(id: number) {
|
||||
const { data } = await adminClient.get<ApiResponse<AdminChatConversation>>(`/admin/chats/${id}`)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function fetchAdminChatMessages(id: number, page = 1, pageSize = 50) {
|
||||
const { data } = await adminClient.get<ApiResponse<Partial<AdminChatMessagePage>>>(
|
||||
`/admin/chats/${id}/messages`,
|
||||
{ params: { page, page_size: pageSize } }
|
||||
)
|
||||
return {
|
||||
items: (data.data.items ?? []) as AdminChatMessage[],
|
||||
total: data.data.total ?? 0,
|
||||
page: data.data.page ?? page,
|
||||
page_size: data.data.page_size ?? pageSize,
|
||||
}
|
||||
}
|
||||
|
||||
export async function sendAdminChatMessage(
|
||||
id: number,
|
||||
payload: { content: string; attachment_urls?: string[] }
|
||||
) {
|
||||
const { data } = await adminClient.post<ApiResponse<AdminChatMessage>>(
|
||||
`/admin/chats/${id}/messages`,
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function markAdminChatRead(id: number) {
|
||||
await adminClient.post(`/admin/chats/${id}/read`)
|
||||
}
|
||||
|
||||
export async function markAllAdminChatsRead() {
|
||||
await adminClient.post('/admin/chats/read-all')
|
||||
}
|
||||
|
||||
export async function transferAdminChat(id: number, toAdminId: number) {
|
||||
await adminClient.post(`/admin/chats/${id}/transfer`, { to_admin_id: toAdminId })
|
||||
}
|
||||
|
||||
export async function updateAdminChatRemark(id: number, remark: string) {
|
||||
await adminClient.post(`/admin/chats/${id}/remark`, { remark })
|
||||
}
|
||||
|
||||
export async function fetchAdminChatSupportAdmins() {
|
||||
const { data } = await adminClient.get<
|
||||
ApiResponse<Array<{ id: number; username?: string; nickname: string; support_status: string }>>
|
||||
>('/admin/chats/support-admins')
|
||||
return data.data ?? []
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user