From f1ebe57d044357032ede65e71954698ce1656e94 Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Fri, 28 Jun 2024 18:37:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E9=82=80=E8=AF=B7=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbproxy/mq/c_invite.go | 3 +++ dbproxy/svc/u_player.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dbproxy/mq/c_invite.go b/dbproxy/mq/c_invite.go index 3f4b0ea..88568dc 100644 --- a/dbproxy/mq/c_invite.go +++ b/dbproxy/mq/c_invite.go @@ -115,6 +115,9 @@ func init() { return err } defer session.EndSession(context.Background()) + // 事务不支持创建集合和索引,需要提前创建 + svc.InviteScoreCollection(log.Platform) + svc.RankInviteCollection(log.Platform) var notifySnId []int32 // 修改积分 diff --git a/dbproxy/svc/u_player.go b/dbproxy/svc/u_player.go index 7cbbc64..58744e2 100644 --- a/dbproxy/svc/u_player.go +++ b/dbproxy/svc/u_player.go @@ -1664,7 +1664,7 @@ func AddInviteScore(client *newMongo.Client, sc newMongo.SessionContext, platfor } // 更新排行榜 - data := &model.RankInvite{ + data := model.RankInvite{ Platform: platform, SnId: psnId, Num: res.INum + addNum, @@ -1672,7 +1672,7 @@ func AddInviteScore(client *newMongo.Client, sc newMongo.SessionContext, platfor Ts: now.Unix(), Week: common.GetWeekStartTs(now.Unix()), } - _, err = rankC.UpdateOne(sc, newBson.M{"snid": psnId, "week": data.Week}, data, options.Update().SetUpsert(true)) + _, err = rankC.UpdateOne(sc, newBson.M{"snid": psnId, "week": data.Week}, newBson.M{"$set": data}, options.Update().SetUpsert(true)) if err != nil { logger.Logger.Tracef("SaveRankInvite error:%v", err) return err