|
@@ -19,7 +19,7 @@ import (
|
|
// 类型的顺序
|
|
// 类型的顺序
|
|
const order = "1,4"
|
|
const order = "1,4"
|
|
const MsgCountKey = "count_%s_%d" //redis 消息未读数量 Count.用户id.消息类型=数量
|
|
const MsgCountKey = "count_%s_%d" //redis 消息未读数量 Count.用户id.消息类型=数量
|
|
-const MsgClassCountKey = "msg_class_count_%s_%d" //redis 用户分类消息数量
|
|
|
|
|
|
+const MsgClassCountKey = "msg_class_count_%s_%d" //redis 用户消息class分类消息数量
|
|
const redisModule = "msgCount"
|
|
const redisModule = "msgCount"
|
|
|
|
|
|
func FindUserMsg(this message.FindUserMsgReq, isClean bool) message.FindUserMsgRes {
|
|
func FindUserMsg(this message.FindUserMsgReq, isClean bool) message.FindUserMsgRes {
|
|
@@ -372,8 +372,12 @@ func MessageGetLast(this *message.UserMsgListReq) *message.Messages {
|
|
}
|
|
}
|
|
|
|
|
|
// MsgCountAdd 消息未读数量加1
|
|
// MsgCountAdd 消息未读数量加1
|
|
-func MsgCountAdd(userId, appId string, msgType int64) bool {
|
|
|
|
|
|
+func MsgCountAdd(userId, appId string, msgType int64, msgClassType int64) bool {
|
|
keyString := fmt.Sprintf(MsgCountKey, userId, msgType)
|
|
keyString := fmt.Sprintf(MsgCountKey, userId, msgType)
|
|
|
|
+ classKeyString := fmt.Sprintf(MsgClassCountKey, userId, msgClassType)
|
|
|
|
+ if exist, _ := redis.Exists(redisModule, classKeyString); exist {
|
|
|
|
+ redis.Incr(redisModule, classKeyString)
|
|
|
|
+ }
|
|
exists, _ := redis.Exists(redisModule, keyString)
|
|
exists, _ := redis.Exists(redisModule, keyString)
|
|
if exists {
|
|
if exists {
|
|
in := redis.Incr(redisModule, keyString)
|
|
in := redis.Incr(redisModule, keyString)
|
|
@@ -391,7 +395,13 @@ func MsgCountAdd(userId, appId string, msgType int64) bool {
|
|
}
|
|
}
|
|
|
|
|
|
// MsgCountMinusOne 根据消息类型未读消息数量减1
|
|
// MsgCountMinusOne 根据消息类型未读消息数量减1
|
|
-func MsgCountMinusOne(userId, appId string, msgType int64) bool {
|
|
|
|
|
|
+func MsgCountMinusOne(userId, appId string, msgType int64, msgClassType int64) bool {
|
|
|
|
+ classKeyString := fmt.Sprintf(MsgClassCountKey, userId, msgClassType)
|
|
|
|
+ if exist, _ := redis.Exists(redisModule, classKeyString); exist {
|
|
|
|
+ if redis.GetInt(redisModule, MsgClassCountKey) > 0 {
|
|
|
|
+ redis.Decrby(redisModule, classKeyString, 1)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
keyString := fmt.Sprintf(MsgCountKey, userId, msgType)
|
|
keyString := fmt.Sprintf(MsgCountKey, userId, msgType)
|
|
exists, _ := redis.Exists(redisModule, keyString)
|
|
exists, _ := redis.Exists(redisModule, keyString)
|
|
if exists {
|
|
if exists {
|
|
@@ -489,7 +499,7 @@ func MultSave(this message.MultipleSaveMsgReq) (int64, string) {
|
|
in = entity.Mysql.InsertBySql(sql3, common.If(positionId != 0, positionId, nil))
|
|
in = entity.Mysql.InsertBySql(sql3, common.If(positionId != 0, positionId, nil))
|
|
logx.Info("插入消息返回 in1 id:", in, "消息类型:", this.MsgType, "用户id:", v)
|
|
logx.Info("插入消息返回 in1 id:", in, "消息类型:", this.MsgType, "用户id:", v)
|
|
if in > -1 {
|
|
if in > -1 {
|
|
- ok := MsgCountAdd(v, this.Appid, util.Int64All(group_id))
|
|
|
|
|
|
+ ok := MsgCountAdd(v, this.Appid, util.Int64All(group_id), this.MsgType)
|
|
if !ok {
|
|
if !ok {
|
|
log.Println("存redis:", ok, v)
|
|
log.Println("存redis:", ok, v)
|
|
}
|
|
}
|