feat: 新增账号编码和HTTP连接功能
This commit is contained in:
68
service/account_http_service.go
Normal file
68
service/account_http_service.go
Normal file
@@ -0,0 +1,68 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"customer-server/consts/public"
|
||||
"customer-server/model/dto"
|
||||
"fmt"
|
||||
|
||||
gmq "github.com/bjang03/gmq/core/gmq"
|
||||
"github.com/bjang03/gmq/mq"
|
||||
"github.com/bjang03/gmq/types"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
var (
|
||||
AccountHttpService = new(accountHttpService)
|
||||
)
|
||||
|
||||
type accountHttpService struct{}
|
||||
|
||||
func (s *accountHttpService) DeleteDelayMsg(ctx context.Context) (err error) {
|
||||
return gmq.GetGmq(public.GmqMsgPluginsName).GmqDeleteDelay(ctx, &mq.NatsDelMessage{
|
||||
DelMessage: types.DelMessage{
|
||||
Topic: public.AccountFollowupTopic,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (s *accountHttpService) Connect(ctx context.Context, req *dto.AccountHttpConnectReq) (res *dto.AccountHttpConnectRes, err error) {
|
||||
// 获取客服账号信息
|
||||
accountInfo, err := SessionToolService.GetAccountInfo(ctx, req.AccountCode)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if g.IsEmpty(accountInfo) {
|
||||
return nil, fmt.Errorf("客服账号不存在")
|
||||
}
|
||||
|
||||
// 设置用户信息
|
||||
headers, err := SessionToolService.SetUserInfo(ctx, accountInfo.Creator, accountInfo.TenantId)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
content, err := SessionToolService.PushOpeningRemark(ctx, req.UserId, accountInfo, headers)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if !g.IsEmpty(content) {
|
||||
res = &dto.AccountHttpConnectRes{
|
||||
Content: content,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
dialogContent, err := SessionToolService.PushDialog(ctx, req.UserId, req.QuestionContent, accountInfo, headers)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if !g.IsEmpty(dialogContent) {
|
||||
res = &dto.AccountHttpConnectRes{
|
||||
Content: dialogContent,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user