From 135c2c36aa91d195dbba42e21f521847b439dac4 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 10 Feb 2023 11:32:02 +0800 Subject: [PATCH] errcode --- internal/cron_task/clear_msg.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/internal/cron_task/clear_msg.go b/internal/cron_task/clear_msg.go index 08ef74cef..8703b519b 100644 --- a/internal/cron_task/clear_msg.go +++ b/internal/cron_task/clear_msg.go @@ -34,9 +34,7 @@ func ResetUserGroupMinSeq(operationID, groupID string, userIDList []string) erro log.NewError(operationID, utils.GetSelfFuncName(), "GetGroupUserMinSeq failed", groupID, userID, err.Error()) continue } - if userMinSeq > uint64(minSeq) { - err = db.DB.SetGroupUserMinSeq(groupID, userID, userMinSeq) - } else { + if userMinSeq < uint64(minSeq) { err = db.DB.SetGroupUserMinSeq(groupID, userID, uint64(minSeq)) } if err != nil { @@ -56,6 +54,19 @@ func DeleteMongoMsgAndResetRedisSeq(operationID, userID string) error { return nil } log.NewDebug(operationID, utils.GetSelfFuncName(), "delMsgIDStruct: ", delStruct, "minSeq", minSeq) + + userCurrentMinSeq, err := db.DB.GetUserMinSeq(userID) + if err != nil && err != goRedis.Nil { + return err + } + userCurrentMaxSeq, err := db.DB.GetUserMaxSeq(userID) + if err != nil && err != goRedis.Nil { + return err + } + if userCurrentMinSeq > userCurrentMaxSeq { + minSeq = uint32(userCurrentMaxSeq) + } + err = db.DB.SetUserMinSeq(userID, minSeq) return utils.Wrap(err, "") }