增加客服分组管理
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hfb_sys/backend/internal/model"
|
||||
"hfb_sys/backend/internal/modules/supportgroup"
|
||||
)
|
||||
|
||||
// 会话类型常量
|
||||
@@ -56,10 +57,16 @@ func EnsureListingConversation(tx *gorm.DB, listing model.RentalListing, preferr
|
||||
},
|
||||
}
|
||||
|
||||
// 获取客服。开放上传场景优先拉上传管理员,普通发布回退到默认客服。
|
||||
supportID := preferredSupportAdminID
|
||||
// 获取收号组客服。分组未配置时回退到开放上传管理员或默认客服。
|
||||
supportID, err := supportgroup.PickSupportAdmin(tx, supportgroup.GroupCodeOwnerOnboarding)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if supportID <= 0 {
|
||||
supportID = defaultSupportAdminID(tx)
|
||||
supportID = preferredSupportAdminID
|
||||
if supportID <= 0 {
|
||||
supportID = defaultSupportAdminID(tx)
|
||||
}
|
||||
}
|
||||
if supportID > 0 {
|
||||
participants = append(participants, model.ChatParticipant{
|
||||
@@ -123,7 +130,7 @@ func EnsureListingConversation(tx *gorm.DB, listing model.RentalListing, preferr
|
||||
return &conversation, nil
|
||||
}
|
||||
|
||||
// AddRenterToListingConversation 拉租客进发布群
|
||||
// AddRenterToListingConversation 拉租客与卖号组客服进发布群
|
||||
func AddRenterToListingConversation(tx *gorm.DB, listingID uint64, renterID uint64, orderNo string) error {
|
||||
// 1. 查找发布群
|
||||
var conv model.ChatConversation
|
||||
@@ -150,8 +157,29 @@ func AddRenterToListingConversation(tx *gorm.DB, listingID uint64, renterID uint
|
||||
return err
|
||||
}
|
||||
|
||||
// 3. 发系统消息
|
||||
// 3. 支付后由卖号组客服接入跟进交接和售后。
|
||||
handoffSupportID, err := supportgroup.PickSupportAdmin(tx, supportgroup.GroupCodeRenterHandoff)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if handoffSupportID > 0 {
|
||||
support := model.ChatParticipant{
|
||||
ConversationID: conv.ID,
|
||||
ParticipantType: "admin",
|
||||
ParticipantID: handoffSupportID,
|
||||
Role: "support",
|
||||
JoinedAt: now,
|
||||
}
|
||||
if err := tx.Clauses(clause.OnConflict{DoNothing: true}).Create(&support).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 发系统消息
|
||||
message := "租客已加入群聊(订单 " + orderNo + ")"
|
||||
if handoffSupportID > 0 {
|
||||
message += ",卖号组客服已接入"
|
||||
}
|
||||
return sendSystemMessage(tx, conv.ID, message)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user