支持客服入口按业务场景分流到客服分组

联系客服支持 scene(general/mohong),按用户与场景复用会话;摸大红入口走摸大红分组选人。
This commit is contained in:
yml2213
2026-07-16 20:05:10 +08:00
parent e07532a188
commit 66ca2693b3
17 changed files with 224 additions and 21 deletions
+20 -2
View File
@@ -14,6 +14,8 @@ export interface ChatParticipant {
joined_at: string
}
export type SupportScene = 'general' | 'mohong'
export interface ChatConversation {
id: number
order_id: number | null
@@ -24,6 +26,7 @@ export interface ChatConversation {
latest_handoff_status?: string
latest_refund_status?: string
type: string
support_scene?: string
title: string
status: string
role: 'renter' | 'owner' | 'support' | 'customer' | 'admin'
@@ -39,6 +42,19 @@ export interface ChatConversation {
updated_at: string
}
/** 根据当前路由推断客服场景:摸大红页 → mohong,其它 → general */
export function resolveSupportScene(path: string): SupportScene {
if (
path === '/mohong' ||
path.startsWith('/mohong/') ||
path === '/m/mohong' ||
path.startsWith('/m/mohong/')
) {
return 'mohong'
}
return 'general'
}
export interface AdminChatCounts {
ownership?: Record<string, number>
stages?: Record<string, number>
@@ -97,8 +113,10 @@ export async function fetchOrderChat(orderId: number) {
return data.data
}
export async function ensureSupportChat() {
const { data } = await apiClient.post<ApiResponse<ChatConversation>>('/chats/support')
export async function ensureSupportChat(scene: SupportScene | string = 'general') {
const { data } = await apiClient.post<ApiResponse<ChatConversation>>('/chats/support', {
scene: scene || 'general',
})
return data.data
}