邀请积分排行榜
This commit is contained in:
parent
aee5f99d9d
commit
869a2c91d2
|
@ -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",
|
||||
|
|
|
@ -28,7 +28,6 @@ func main() {
|
|||
})
|
||||
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
||||
mq.StopPublisher()
|
||||
model.ShutdownRPClient()
|
||||
return nil
|
||||
})
|
||||
// module模块
|
||||
|
|
|
@ -89,7 +89,6 @@ type GameParam struct {
|
|||
RankPlayerLevelMaxNum int //等级榜最大人数
|
||||
CloseChannelSwitch bool //关闭渠道开关功能
|
||||
BackendTimeLocal int //后台时区
|
||||
GameStaticsFightVersion int // 对战场游戏统计数据版本号
|
||||
}
|
||||
|
||||
var GameParamPath = "../data/gameparam.json"
|
||||
|
|
|
@ -54,6 +54,8 @@ type InviteScore struct {
|
|||
Score int64 // 积分
|
||||
Ts int64 // 时间戳
|
||||
Money int64 // 充值金额
|
||||
WeekIndex int64 // 所在周
|
||||
MonthIndex int64 // 所在月
|
||||
}
|
||||
|
||||
type InviteScoreReq struct {
|
||||
|
|
|
@ -28,7 +28,6 @@ func main() {
|
|||
})
|
||||
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
||||
mq.StopConsumer()
|
||||
model.ShutdownRPClient()
|
||||
return nil
|
||||
})
|
||||
// module模块
|
||||
|
|
|
@ -30,7 +30,6 @@ func main() {
|
|||
return nil
|
||||
})
|
||||
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
||||
model.ShutdownRPClient()
|
||||
return nil
|
||||
})
|
||||
// module模块
|
||||
|
|
|
@ -50,7 +50,6 @@ func main() {
|
|||
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
||||
mq.StopPublisher()
|
||||
mq.StopConsumer()
|
||||
model.ShutdownRPClient()
|
||||
return nil
|
||||
})
|
||||
//启动定时任务
|
||||
|
|
Loading…
Reference in New Issue