fix: 解决冲突
This commit is contained in:
commit
97753f0578
@ -144,29 +144,36 @@ func (cr ChatCache) IncreaseNewMessageTotal(ownerId int64, sessionId string) (er
|
||||
|
||||
// 重置新消息数量
|
||||
func (cr ChatCache) ResetNewMessageTotal(ownerId int64, sessionId string, total ...int64) error {
|
||||
fmt.Printf("ResetNewMessageTotal: %d ,sessionId:%s ,total:%v\n", ownerId, sessionId, total)
|
||||
chatCacheLocker.Lock()
|
||||
defer chatCacheLocker.Unlock()
|
||||
var tl int64
|
||||
if len(total) > 0 {
|
||||
tl = total[0]
|
||||
}
|
||||
fmt.Println("ResetNewMessageTotal tl:", tl)
|
||||
ctx := context.Background()
|
||||
data := cr.GetNewMessageStat(ctx, ownerId)
|
||||
fmt.Printf("ResetNewMessageTotal data:%+v\n", data)
|
||||
found := false
|
||||
for i, v := range data {
|
||||
if v.SessionId == sessionId {
|
||||
found = true
|
||||
data[i].Total = tl
|
||||
fmt.Println("ResetNewMessageTotal found!")
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
fmt.Println("ResetNewMessageTotal not found!")
|
||||
data = append(data, dto.UserMsgStatic{
|
||||
SessionId: sessionId,
|
||||
Total: tl,
|
||||
})
|
||||
}
|
||||
return cr.coverOwnerNewMessageStat(ctx, ownerId, data)
|
||||
err := cr.coverOwnerNewMessageStat(ctx, ownerId, data)
|
||||
fmt.Println("ResetNewMessageTotal result:", err)
|
||||
return err
|
||||
}
|
||||
|
||||
func (cr ChatCache) RecountNewMessageTotal(ownerId int64) {
|
||||
|
@ -249,7 +249,7 @@ func (cr ChatHandler) MessageList(c *gin.Context) {
|
||||
service.Success(c, resp)
|
||||
return
|
||||
}
|
||||
chatUser, code := jwt.ParseToChatUser(c)
|
||||
accessUser, code := jwt.ParseToChatUser(c)
|
||||
if code != 0 {
|
||||
service.ErrWithCode(c, code)
|
||||
return
|
||||
@ -267,7 +267,7 @@ func (cr ChatHandler) MessageList(c *gin.Context) {
|
||||
defer func() {
|
||||
//获取最新数据时,重置新消息数量统计
|
||||
if request.Direction == 2 || request.Recent {
|
||||
cr.cache.ResetNewMessageTotal(chatUser.ID, request.SessionId)
|
||||
cr.cache.ResetNewMessageTotal(accessUser.ID, request.SessionId)
|
||||
}
|
||||
//设置消息已被客服阅读,当客服重新通过通过websocket连接时,这些消息将不被纳入新消息数量统计
|
||||
if len(returnDataIdList) > 0 && domain == "fontree" {
|
||||
@ -501,7 +501,7 @@ func (cr ChatHandler) UserMessageStat(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
if result[i].Name == "" {
|
||||
result[i].Name = beautifulZeroName(result[i].Name, result[i].UserId)
|
||||
result[i].Name = beautifulZeroNameWithPhone(result[i].Name, result[i].UserId)
|
||||
}
|
||||
}
|
||||
reverse(result)
|
||||
@ -563,10 +563,10 @@ func (cr ChatHandler) UserDetail(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
fmt.Printf("chatUser:%#v\n", chatUser)
|
||||
if chatUser.Origin == "fiee" {
|
||||
chatUser.Origin = "app"
|
||||
}
|
||||
//fmt.Printf("chatUser:%#v\n", chatUser)
|
||||
//if chatUser.Origin == "fiee" {
|
||||
// chatUser.Origin = "app"
|
||||
//}
|
||||
resp, err := service.AccountFieeProvider.Info(c, &accountFiee.InfoRequest{ID: uint64(chatUser.OriginId), Domain: chatUser.Origin})
|
||||
if err != nil {
|
||||
service.Error(c, err)
|
||||
@ -592,3 +592,31 @@ func (cr ChatHandler) UserDetail(c *gin.Context) {
|
||||
func beautifulZeroName(name string, userId int64) string {
|
||||
return utils.IfGec(name == "", fmt.Sprintf("未实名用户:%d", userId), name)
|
||||
}
|
||||
|
||||
var userIdMapPhone = make(map[int64]string)
|
||||
|
||||
func beautifulZeroNameWithPhone(name string, userId int64) string {
|
||||
var ctx = context.Background()
|
||||
if name == "" {
|
||||
telNum, ok := userIdMapPhone[userId]
|
||||
if ok {
|
||||
return telNum
|
||||
}
|
||||
chatUserRes, err := service.AccountFieeProvider.GetChatUserDetail(ctx, &accountFiee.GetChatUserByIdRequest{Id: userId})
|
||||
if err != nil {
|
||||
return fmt.Sprintf("未实名用户:%d", userId)
|
||||
} else {
|
||||
if userRes, errs := service.AccountFieeProvider.Info(ctx, &accountFiee.InfoRequest{
|
||||
Domain: chatUserRes.Origin,
|
||||
ID: uint64(chatUserRes.OriginId),
|
||||
Scene: "",
|
||||
}); errs != nil {
|
||||
return fmt.Sprintf("未实名用户:%d", userId)
|
||||
} else {
|
||||
userIdMapPhone[userId] = userRes.TelNum
|
||||
return userRes.TelNum
|
||||
}
|
||||
}
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user