客户转接系统
This commit is contained in:
@@ -144,7 +144,20 @@ func (r *Repository) ensureDefaultAdmin() error {
|
||||
Nickname: "超级管理员",
|
||||
Status: "active",
|
||||
}
|
||||
return r.db.Create(&admin).Error
|
||||
if err := r.db.Create(&admin).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 自动关联 super_admin 角色
|
||||
var superAdminRole model.Role
|
||||
if err := r.db.Where("code = ?", "super_admin").First(&superAdminRole).Error; err == nil {
|
||||
r.db.Create(&model.AdminUserRole{
|
||||
AdminID: admin.ID,
|
||||
RoleID: superAdminRole.ID,
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func toDTO(admin model.AdminUser) AdminDTO {
|
||||
|
||||
@@ -686,12 +686,11 @@ func (r *Repository) GetAvailableSupportAdmins() ([]SupportAdminDTO, error) {
|
||||
}
|
||||
var admins []adminRow
|
||||
err := r.db.Table("admin_users AS au").
|
||||
Select("au.id, au.nickname").
|
||||
Select("DISTINCT au.id, COALESCE(NULLIF(au.nickname, ''), au.username) AS nickname").
|
||||
Joins("JOIN admin_user_roles AS aur ON aur.admin_user_id = au.id").
|
||||
Joins("JOIN role_permissions AS rp ON rp.role_id = aur.role_id").
|
||||
Joins("JOIN permissions AS p ON p.id = rp.permission_id").
|
||||
Where("au.status = ? AND p.code = ?", "active", "chat:view").
|
||||
Distinct("au.id").
|
||||
Scan(&admins).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -722,9 +721,9 @@ func (r *Repository) GetAvailableSupportAdmins() ([]SupportAdminDTO, error) {
|
||||
result := make([]SupportAdminDTO, len(admins))
|
||||
for i, a := range admins {
|
||||
result[i] = SupportAdminDTO{
|
||||
ID: a.ID,
|
||||
Nickname: a.Nickname,
|
||||
ChatCount: loadMap[a.ID],
|
||||
ID: a.ID,
|
||||
Nickname: a.Nickname,
|
||||
ChatCount: loadMap[a.ID],
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
|
||||
@@ -41,7 +41,7 @@ var defaultConfigs = []defaultConfig{
|
||||
{Key: "settlement.platform_fee_rate", Value: "0.00", Description: "平台抽成比例"},
|
||||
{Key: "settlement.owner_cycle_days", Value: "0", Description: "号主结算周期天数"},
|
||||
{Key: "withdraw.min_amount", Value: "100", Description: "提现最低金额预留"},
|
||||
{Key: "chat.default_support_admin_id", Value: "1", Description: "订单群聊默认接入的客服管理员 ID"},
|
||||
{Key: "chat.default_support_admin_id", Value: "1", Description: "订单群聊回退客服 ID(仅当无可用客服时使用)"},
|
||||
{Key: homeAnnouncementsConfigKey, Value: defaultHomeAnnouncementsConfigValue(), Description: "移动端首页公告 JSON 数组"},
|
||||
{Key: homeBannersConfigKey, Value: defaultHomeBannersConfigValue(), Description: "移动端首页轮播图 JSON 数组"},
|
||||
{Key: publishOptionsConfigKey, Value: defaultPublishOptionsConfigValue(), Description: "发布页选项配置 JSON"},
|
||||
|
||||
Reference in New Issue
Block a user