|
@@ -99,23 +99,11 @@ func UserMsgList(this *message.UserMsgListReq) *message.UserMsgList {
|
|
var (
|
|
var (
|
|
unread, count int64
|
|
unread, count int64
|
|
)
|
|
)
|
|
|
|
+ m := &MessageService{}
|
|
data := new(message.UserMsgList)
|
|
data := new(message.UserMsgList)
|
|
if !this.IsMsgList && !this.IsColumnNewMsg && !this.IsColumn { //消息未读数统计
|
|
if !this.IsMsgList && !this.IsColumnNewMsg && !this.IsColumn { //消息未读数统计
|
|
- var isUnread, isColumn int
|
|
|
|
- for _, v := range entity.MessageColumn {
|
|
|
|
- if util.IntAll(v["group_id"]) > 0 && util.IntAll(v["group_id"]) < 999 {
|
|
|
|
- isColumn++ //去除全部与私信
|
|
|
|
- key := fmt.Sprintf(MsgCountKey, this.UserId, util.IntAll(v["group_id"]))
|
|
|
|
- if exists, _ := redis.Exists(redisModule, key); exists {
|
|
|
|
- isUnread++
|
|
|
|
- unread += util.Int64All(redis.GetInt(redisModule, key))
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if isUnread != isColumn {
|
|
|
|
- m := &MessageService{}
|
|
|
|
- unread = m.CountUnread(this.UserId)
|
|
|
|
- }
|
|
|
|
|
|
+ //获取总未读数 初始化
|
|
|
|
+ _, unread = m.CountUnread(this.UserId, true)
|
|
if this.IsContainLetter { //私信统计
|
|
if this.IsContainLetter { //私信统计
|
|
unread += unreadMsg(this)
|
|
unread += unreadMsg(this)
|
|
}
|
|
}
|
|
@@ -176,6 +164,8 @@ func UserMsgList(this *message.UserMsgListReq) *message.UserMsgList {
|
|
//消息栏目下的最新消息
|
|
//消息栏目下的最新消息
|
|
var columnData []*message.AllSortData
|
|
var columnData []*message.AllSortData
|
|
if this.IsColumn {
|
|
if this.IsColumn {
|
|
|
|
+ //获取所有分类未读数 不初始化
|
|
|
|
+ sortUnread, _ := m.CountUnread(this.UserId, false)
|
|
for _, v := range entity.MessageColumn {
|
|
for _, v := range entity.MessageColumn {
|
|
var column message.AllSortData
|
|
var column message.AllSortData
|
|
column.Name = common.InterfaceToStr(v["name"])
|
|
column.Name = common.InterfaceToStr(v["name"])
|
|
@@ -186,10 +176,10 @@ func UserMsgList(this *message.UserMsgListReq) *message.UserMsgList {
|
|
} else if common.IntAll(v["group_id"]) > 0 {
|
|
} else if common.IntAll(v["group_id"]) > 0 {
|
|
//消息未读数
|
|
//消息未读数
|
|
msgType := common.InterfaceToStr(v["group_id"])
|
|
msgType := common.InterfaceToStr(v["group_id"])
|
|
- column.UnreadMessages = util.Int64All(redis.GetInt(redisModule, fmt.Sprintf(MsgCountKey, this.UserId, util.IntAll(msgType))))
|
|
|
|
|
|
+ column.UnreadMessages = sortUnread[msgType]
|
|
|
|
+ unread += sortUnread[msgType]
|
|
column.Data = sData[msgType]
|
|
column.Data = sData[msgType]
|
|
}
|
|
}
|
|
- unread += column.UnreadMessages
|
|
|
|
columnData = append(columnData, &column)
|
|
columnData = append(columnData, &column)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -227,7 +217,7 @@ func UserMsgList(this *message.UserMsgListReq) *message.UserMsgList {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
data.Count = count
|
|
data.Count = count
|
|
- if !this.IsColumn && this.Read == 0 {
|
|
|
|
|
|
+ if this.Read == 0 {
|
|
unread = count
|
|
unread = count
|
|
if this.IsContainLetter { //是否需要统计私信未读数
|
|
if this.IsContainLetter { //是否需要统计私信未读数
|
|
unread += unreadMsg(this)
|
|
unread += unreadMsg(this)
|
|
@@ -393,17 +383,20 @@ func MsgCountMinusOne(userId, appId string, msgType int64) bool {
|
|
|
|
|
|
// MsgCountZero 把该消息类型未读数量置0
|
|
// MsgCountZero 把该消息类型未读数量置0
|
|
func MsgCountZero(userId, appId string, msgType int64) bool {
|
|
func MsgCountZero(userId, appId string, msgType int64) bool {
|
|
- keyString := fmt.Sprintf(MsgCountKey, userId, msgType)
|
|
|
|
- fool := redis.Put(redisModule, keyString, 0, -1)
|
|
|
|
- FindUserMsg(message.FindUserMsgReq{
|
|
|
|
- UserId: userId,
|
|
|
|
- Appid: appId,
|
|
|
|
- OffSet: 1,
|
|
|
|
- PageSize: 5,
|
|
|
|
- MsgType: -1,
|
|
|
|
- Read: 0,
|
|
|
|
- }, true)
|
|
|
|
- return fool
|
|
|
|
|
|
+ if msgType > 0 && msgType < 999 { //全部私信不统计
|
|
|
|
+ keyString := fmt.Sprintf(MsgCountKey, userId, msgType)
|
|
|
|
+ fool := redis.Put(redisModule, keyString, 0, -1)
|
|
|
|
+ FindUserMsg(message.FindUserMsgReq{
|
|
|
|
+ UserId: userId,
|
|
|
|
+ Appid: appId,
|
|
|
|
+ OffSet: 1,
|
|
|
|
+ PageSize: 5,
|
|
|
|
+ MsgType: -1,
|
|
|
|
+ Read: 0,
|
|
|
|
+ }, true)
|
|
|
|
+ return fool
|
|
|
|
+ }
|
|
|
|
+ return true
|
|
}
|
|
}
|
|
|
|
|
|
func MultSave(this message.MultipleSaveMsgReq) (int64, string) {
|
|
func MultSave(this message.MultipleSaveMsgReq) (int64, string) {
|