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