diff --git a/internal/msg_transfer/logic/db.go b/internal/msg_transfer/logic/db.go index 052b5f000..bfe5bd77d 100644 --- a/internal/msg_transfer/logic/db.go +++ b/internal/msg_transfer/logic/db.go @@ -22,7 +22,7 @@ func saveUserChat(uid string, msg *pbMsg.MsgDataToMQ) error { // return db.DB.SaveUserChatMongo2(uid, pbSaveData.MsgData.SendTime, &pbSaveData) } -func saveUserChatList(uid string, msgList []*pbMsg.MsgDataToMQ, operationID string) error { - log.Info(operationID, utils.GetSelfFuncName(), "args ", uid, len(msgList)) - return db.DB.BatchInsertChat(uid, msgList, operationID) +func saveUserChatList(userID string, msgList []*pbMsg.MsgDataToMQ, operationID string) error { + log.Info(operationID, utils.GetSelfFuncName(), "args ", userID, len(msgList)) + return db.DB.BatchInsertChat(userID, msgList, operationID) } diff --git a/pkg/common/db/batch_insert_chat.go b/pkg/common/db/batch_insert_chat.go index 9c23244f6..f64fc4a18 100644 --- a/pkg/common/db/batch_insert_chat.go +++ b/pkg/common/db/batch_insert_chat.go @@ -74,5 +74,5 @@ func (d *DataBases) BatchInsertChat(userID string, msgList []*pbMsg.MsgDataToMQ, } } log.NewDebug(operationID, "find mgo uid cost time", getCurrentTimestampByMill()-newTime) - return nil + return utils.Wrap(d.SetUserMaxSeq(userID, uint32(currentMaxSeq)), "") } diff --git a/pkg/common/db/redisModel.go b/pkg/common/db/redisModel.go index 2faa9a6d8..43b26b64c 100644 --- a/pkg/common/db/redisModel.go +++ b/pkg/common/db/redisModel.go @@ -62,6 +62,13 @@ func (d *DataBases) GetUserMaxSeq(uid string) (uint64, error) { return redis.Uint64(d.Exec("GET", key)) } +//set the largest Seq +func (d *DataBases) SetUserMaxSeq(uid string, maxSeq uint32) error { + key := userIncrSeq + uid + _, err := redis.Uint64(d.Exec("SET", key, maxSeq)) + return err +} + //Set the user's minimum seq func (d *DataBases) SetUserMinSeq(uid string, minSeq uint32) (err error) { key := userMinSeq + uid