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 {
|
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()
|
chatCacheLocker.Lock()
|
||||||
defer chatCacheLocker.Unlock()
|
defer chatCacheLocker.Unlock()
|
||||||
var tl int64
|
var tl int64
|
||||||
if len(total) > 0 {
|
if len(total) > 0 {
|
||||||
tl = total[0]
|
tl = total[0]
|
||||||
}
|
}
|
||||||
|
fmt.Println("ResetNewMessageTotal tl:", tl)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
data := cr.GetNewMessageStat(ctx, ownerId)
|
data := cr.GetNewMessageStat(ctx, ownerId)
|
||||||
|
fmt.Printf("ResetNewMessageTotal data:%+v\n", data)
|
||||||
found := false
|
found := false
|
||||||
for i, v := range data {
|
for i, v := range data {
|
||||||
if v.SessionId == sessionId {
|
if v.SessionId == sessionId {
|
||||||
found = true
|
found = true
|
||||||
data[i].Total = tl
|
data[i].Total = tl
|
||||||
|
fmt.Println("ResetNewMessageTotal found!")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
|
fmt.Println("ResetNewMessageTotal not found!")
|
||||||
data = append(data, dto.UserMsgStatic{
|
data = append(data, dto.UserMsgStatic{
|
||||||
SessionId: sessionId,
|
SessionId: sessionId,
|
||||||
Total: tl,
|
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) {
|
func (cr ChatCache) RecountNewMessageTotal(ownerId int64) {
|
||||||
|
@ -249,7 +249,7 @@ func (cr ChatHandler) MessageList(c *gin.Context) {
|
|||||||
service.Success(c, resp)
|
service.Success(c, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
chatUser, code := jwt.ParseToChatUser(c)
|
accessUser, code := jwt.ParseToChatUser(c)
|
||||||
if code != 0 {
|
if code != 0 {
|
||||||
service.ErrWithCode(c, code)
|
service.ErrWithCode(c, code)
|
||||||
return
|
return
|
||||||
@ -267,7 +267,7 @@ func (cr ChatHandler) MessageList(c *gin.Context) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
//获取最新数据时,重置新消息数量统计
|
//获取最新数据时,重置新消息数量统计
|
||||||
if request.Direction == 2 || request.Recent {
|
if request.Direction == 2 || request.Recent {
|
||||||
cr.cache.ResetNewMessageTotal(chatUser.ID, request.SessionId)
|
cr.cache.ResetNewMessageTotal(accessUser.ID, request.SessionId)
|
||||||
}
|
}
|
||||||
//设置消息已被客服阅读,当客服重新通过通过websocket连接时,这些消息将不被纳入新消息数量统计
|
//设置消息已被客服阅读,当客服重新通过通过websocket连接时,这些消息将不被纳入新消息数量统计
|
||||||
if len(returnDataIdList) > 0 && domain == "fontree" {
|
if len(returnDataIdList) > 0 && domain == "fontree" {
|
||||||
@ -501,7 +501,7 @@ func (cr ChatHandler) UserMessageStat(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if result[i].Name == "" {
|
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)
|
reverse(result)
|
||||||
@ -563,10 +563,10 @@ func (cr ChatHandler) UserDetail(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Printf("chatUser:%#v\n", chatUser)
|
//fmt.Printf("chatUser:%#v\n", chatUser)
|
||||||
if chatUser.Origin == "fiee" {
|
//if chatUser.Origin == "fiee" {
|
||||||
chatUser.Origin = "app"
|
// chatUser.Origin = "app"
|
||||||
}
|
//}
|
||||||
resp, err := service.AccountFieeProvider.Info(c, &accountFiee.InfoRequest{ID: uint64(chatUser.OriginId), Domain: chatUser.Origin})
|
resp, err := service.AccountFieeProvider.Info(c, &accountFiee.InfoRequest{ID: uint64(chatUser.OriginId), Domain: chatUser.Origin})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
service.Error(c, err)
|
service.Error(c, err)
|
||||||
@ -592,3 +592,31 @@ func (cr ChatHandler) UserDetail(c *gin.Context) {
|
|||||||
func beautifulZeroName(name string, userId int64) string {
|
func beautifulZeroName(name string, userId int64) string {
|
||||||
return utils.IfGec(name == "", fmt.Sprintf("未实名用户:%d", userId), name)
|
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