chore(init): 初始化解忧商行项目并完成 Phase 0 基座
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"hfb_sys/backend/internal/modules/supportgroup"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// 客服入口业务场景(与前端 POST /chats/support 的 scene 对齐)。
|
||||
const (
|
||||
SupportSceneGeneral = "general"
|
||||
SupportSceneCrash = "crash"
|
||||
// SupportSceneMohong 兼容旧 scene 值,与 crash 同一客服分组。
|
||||
SupportSceneMohong = "mohong"
|
||||
)
|
||||
|
||||
// resolveSupportScene 规范化场景并返回标题、客服分组 code、欢迎语。
|
||||
// groupCode 为空时表示不走分组,使用默认客服选取逻辑。
|
||||
func resolveSupportScene(raw string) (scene, title, groupCode, welcome string) {
|
||||
switch strings.ToLower(strings.TrimSpace(raw)) {
|
||||
case SupportSceneCrash, SupportSceneMohong:
|
||||
return SupportSceneCrash,
|
||||
"撞车客服",
|
||||
supportgroup.GroupCodeMohong, // 分组 code 仍为 mohong,后台可改显示名
|
||||
"您好,这里是撞车客服。请直接描述问题,可将订单信息复制后发送。"
|
||||
default:
|
||||
// 未知场景回落平台客服,避免随意 scene 绕开分配策略
|
||||
return SupportSceneGeneral,
|
||||
"平台客服",
|
||||
"",
|
||||
"您好,客服会尽快回复,请直接描述您遇到的问题。"
|
||||
}
|
||||
}
|
||||
|
||||
// pickSupportAdminForScene 按分组选人;分组无成员或失败时回退默认客服逻辑。
|
||||
func pickSupportAdminForScene(tx *gorm.DB, groupCode string) uint64 {
|
||||
groupCode = strings.TrimSpace(groupCode)
|
||||
if groupCode != "" {
|
||||
if id, err := supportgroup.PickSupportAdmin(tx, groupCode); err == nil && id > 0 {
|
||||
return id
|
||||
}
|
||||
}
|
||||
return defaultSupportAdminID(tx)
|
||||
}
|
||||
Reference in New Issue
Block a user