邀请积分排行榜
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{"invitesnid"}, Background: true, Sparse: true})
|
||||||
c.EnsureIndex(mgo.Index{Key: []string{"tp"}, 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{"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
|
return c
|
||||||
}
|
}
|
||||||
|
@ -136,6 +138,25 @@ func (b *BindScoreSvc) SaveInviteScore(req *model.InviteScore, ret *bool) error
|
||||||
return InviteScoreColError
|
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)
|
err = c.Insert(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Logger.Errorf("SaveInviteScore Insert error:%v", err)
|
logger.Logger.Errorf("SaveInviteScore Insert error:%v", err)
|
||||||
|
@ -158,19 +179,21 @@ func (b *BindScoreSvc) GetInviteRankList(req *model.FindPlayerRankInviteListArgs
|
||||||
return InviteScoreColError
|
return InviteScoreColError
|
||||||
}
|
}
|
||||||
|
|
||||||
NowTime := time.Now().Local()
|
matchParam := bson.M{
|
||||||
endTime := NowTime.UnixNano()
|
"score": bson.M{"$gt": 0},
|
||||||
startTime := NowTime.AddDate(-100, 0, 0).UnixNano()
|
}
|
||||||
|
now := time.Now().Local()
|
||||||
year, month, day := NowTime.Date()
|
startTime := now.AddDate(-100, 0, 0).UnixNano()
|
||||||
|
year, month, day := now.Date()
|
||||||
today := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
|
today := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
|
||||||
if req.RankType == int32(rankproto.RankInvite_InviteType_Week) {
|
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) {
|
} else if req.RankType == int32(rankproto.RankInvite_InviteType_Month) {
|
||||||
// 本月起始日期
|
// 本月起始日期
|
||||||
startTime = time.Date(year, month, 1, 0, 0, 0, 0, time.Local).UnixNano()
|
matchParam["monthindex"] = time.Date(year, month, 1, 0, 0, 0, 0, time.Local).Unix()
|
||||||
//startTime = NowTime.AddDate(0, 0, -NowTime.Day()+1).UnixNano()
|
} else {
|
||||||
|
matchParam["ts"] = bson.M{"$gte": startTime, "$lte": now.UnixNano()}
|
||||||
}
|
}
|
||||||
|
|
||||||
type M struct {
|
type M struct {
|
||||||
|
@ -180,10 +203,7 @@ func (b *BindScoreSvc) GetInviteRankList(req *model.FindPlayerRankInviteListArgs
|
||||||
|
|
||||||
var tc []M
|
var tc []M
|
||||||
err := c.Pipe([]bson.M{
|
err := c.Pipe([]bson.M{
|
||||||
{"$match": bson.M{
|
{"$match": matchParam},
|
||||||
"score": bson.M{"$gt": 0},
|
|
||||||
"ts": bson.M{"$gte": startTime, "$lte": endTime},
|
|
||||||
}},
|
|
||||||
{"$group": bson.M{
|
{"$group": bson.M{
|
||||||
"_id": bson.M{
|
"_id": bson.M{
|
||||||
"invitesnid": "$invitesnid",
|
"invitesnid": "$invitesnid",
|
||||||
|
|
|
@ -28,7 +28,6 @@ func main() {
|
||||||
})
|
})
|
||||||
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
||||||
mq.StopPublisher()
|
mq.StopPublisher()
|
||||||
model.ShutdownRPClient()
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
// module模块
|
// module模块
|
||||||
|
|
|
@ -89,7 +89,6 @@ type GameParam struct {
|
||||||
RankPlayerLevelMaxNum int //等级榜最大人数
|
RankPlayerLevelMaxNum int //等级榜最大人数
|
||||||
CloseChannelSwitch bool //关闭渠道开关功能
|
CloseChannelSwitch bool //关闭渠道开关功能
|
||||||
BackendTimeLocal int //后台时区
|
BackendTimeLocal int //后台时区
|
||||||
GameStaticsFightVersion int // 对战场游戏统计数据版本号
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var GameParamPath = "../data/gameparam.json"
|
var GameParamPath = "../data/gameparam.json"
|
||||||
|
|
|
@ -54,6 +54,8 @@ type InviteScore struct {
|
||||||
Score int64 // 积分
|
Score int64 // 积分
|
||||||
Ts int64 // 时间戳
|
Ts int64 // 时间戳
|
||||||
Money int64 // 充值金额
|
Money int64 // 充值金额
|
||||||
|
WeekIndex int64 // 所在周
|
||||||
|
MonthIndex int64 // 所在月
|
||||||
}
|
}
|
||||||
|
|
||||||
type InviteScoreReq struct {
|
type InviteScoreReq struct {
|
||||||
|
|
|
@ -28,7 +28,6 @@ func main() {
|
||||||
})
|
})
|
||||||
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
||||||
mq.StopConsumer()
|
mq.StopConsumer()
|
||||||
model.ShutdownRPClient()
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
// module模块
|
// module模块
|
||||||
|
|
|
@ -30,7 +30,6 @@ func main() {
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
||||||
model.ShutdownRPClient()
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
// module模块
|
// module模块
|
||||||
|
|
|
@ -50,7 +50,6 @@ func main() {
|
||||||
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
||||||
mq.StopPublisher()
|
mq.StopPublisher()
|
||||||
mq.StopConsumer()
|
mq.StopConsumer()
|
||||||
model.ShutdownRPClient()
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
//启动定时任务
|
//启动定时任务
|
||||||
|
|
Loading…
Reference in New Issue