diff --git a/dbproxy/svc/u_invitescore.go b/dbproxy/svc/u_invitescore.go index 2684de5..2ed2b1a 100644 --- a/dbproxy/svc/u_invitescore.go +++ b/dbproxy/svc/u_invitescore.go @@ -30,6 +30,8 @@ func InviteScoreCollection(plt string) *mongo.Collection { c.EnsureIndex(mgo.Index{Key: []string{"invitesnid"}, Background: true, Sparse: true}) c.EnsureIndex(mgo.Index{Key: []string{"tp"}, Background: true, Sparse: true}) c.EnsureIndex(mgo.Index{Key: []string{"ts"}, Background: true, Sparse: true}) + c.EnsureIndex(mgo.Index{Key: []string{"weekindex"}, Background: true, Sparse: true}) + c.EnsureIndex(mgo.Index{Key: []string{"monthindex"}, Background: true, Sparse: true}) } return c } @@ -136,6 +138,25 @@ func (b *BindScoreSvc) SaveInviteScore(req *model.InviteScore, ret *bool) error return InviteScoreColError } + ts := req.Ts + if req.Tp != common.InviteScoreTypeBind { + a := &model.InviteScore{} + err = c.Find(bson.M{"snid": req.SnId, "tp": common.InviteScoreTypeBind}).One(a) + if err != nil && !errors.Is(err, mgo.ErrNotFound) { + logger.Logger.Errorf("GetInviteScore Find BindTime error:%v", err) + return err + } + ts = a.Ts + } + + bindTime := time.Unix(0, ts).Local() + year, month, day := bindTime.Date() + today := time.Date(year, month, day, 0, 0, 0, 0, time.Local) + // 本周起始日期(周日) + req.WeekIndex = today.AddDate(0, 0, -int(today.Weekday())).Unix() + // 本月起始日期 + req.MonthIndex = time.Date(year, month, 1, 0, 0, 0, 0, time.Local).Unix() + err = c.Insert(req) if err != nil { logger.Logger.Errorf("SaveInviteScore Insert error:%v", err) @@ -158,19 +179,21 @@ func (b *BindScoreSvc) GetInviteRankList(req *model.FindPlayerRankInviteListArgs return InviteScoreColError } - NowTime := time.Now().Local() - endTime := NowTime.UnixNano() - startTime := NowTime.AddDate(-100, 0, 0).UnixNano() - - year, month, day := NowTime.Date() + matchParam := bson.M{ + "score": bson.M{"$gt": 0}, + } + now := time.Now().Local() + startTime := now.AddDate(-100, 0, 0).UnixNano() + year, month, day := now.Date() today := time.Date(year, month, day, 0, 0, 0, 0, time.Local) if req.RankType == int32(rankproto.RankInvite_InviteType_Week) { // 本周起始日期(周日) - startTime = today.AddDate(0, 0, -int(today.Weekday())).UnixNano() + matchParam["weekindex"] = today.AddDate(0, 0, -int(today.Weekday())).Unix() } else if req.RankType == int32(rankproto.RankInvite_InviteType_Month) { // 本月起始日期 - startTime = time.Date(year, month, 1, 0, 0, 0, 0, time.Local).UnixNano() - //startTime = NowTime.AddDate(0, 0, -NowTime.Day()+1).UnixNano() + matchParam["monthindex"] = time.Date(year, month, 1, 0, 0, 0, 0, time.Local).Unix() + } else { + matchParam["ts"] = bson.M{"$gte": startTime, "$lte": now.UnixNano()} } type M struct { @@ -180,10 +203,7 @@ func (b *BindScoreSvc) GetInviteRankList(req *model.FindPlayerRankInviteListArgs var tc []M err := c.Pipe([]bson.M{ - {"$match": bson.M{ - "score": bson.M{"$gt": 0}, - "ts": bson.M{"$gte": startTime, "$lte": endTime}, - }}, + {"$match": matchParam}, {"$group": bson.M{ "_id": bson.M{ "invitesnid": "$invitesnid", diff --git a/mgrsrv/main.go b/mgrsrv/main.go index 090961e..b35563e 100644 --- a/mgrsrv/main.go +++ b/mgrsrv/main.go @@ -28,7 +28,6 @@ func main() { }) core.RegisteHook(core.HOOK_AFTER_STOP, func() error { mq.StopPublisher() - model.ShutdownRPClient() return nil }) // module模块 diff --git a/model/gameparam.go b/model/gameparam.go index 8e10069..d834e6b 100644 --- a/model/gameparam.go +++ b/model/gameparam.go @@ -89,7 +89,6 @@ type GameParam struct { RankPlayerLevelMaxNum int //等级榜最大人数 CloseChannelSwitch bool //关闭渠道开关功能 BackendTimeLocal int //后台时区 - GameStaticsFightVersion int // 对战场游戏统计数据版本号 } var GameParamPath = "../data/gameparam.json" diff --git a/model/invitecode.go b/model/invitecode.go index 598dc9d..4ab55c8 100644 --- a/model/invitecode.go +++ b/model/invitecode.go @@ -54,6 +54,8 @@ type InviteScore struct { Score int64 // 积分 Ts int64 // 时间戳 Money int64 // 充值金额 + WeekIndex int64 // 所在周 + MonthIndex int64 // 所在月 } type InviteScoreReq struct { diff --git a/ranksrv/main.go b/ranksrv/main.go index 65b527f..c30cfb7 100644 --- a/ranksrv/main.go +++ b/ranksrv/main.go @@ -28,7 +28,6 @@ func main() { }) core.RegisteHook(core.HOOK_AFTER_STOP, func() error { mq.StopConsumer() - model.ShutdownRPClient() return nil }) // module模块 diff --git a/robot/main.go b/robot/main.go index 6d2992e..ac3dee8 100644 --- a/robot/main.go +++ b/robot/main.go @@ -30,7 +30,6 @@ func main() { return nil }) core.RegisteHook(core.HOOK_AFTER_STOP, func() error { - model.ShutdownRPClient() return nil }) // module模块 diff --git a/worldsrv/main.go b/worldsrv/main.go index 0425128..6a8a383 100644 --- a/worldsrv/main.go +++ b/worldsrv/main.go @@ -50,7 +50,6 @@ func main() { core.RegisteHook(core.HOOK_AFTER_STOP, func() error { mq.StopPublisher() mq.StopConsumer() - model.ShutdownRPClient() return nil }) //启动定时任务