整理 优化
This commit is contained in:
parent
f512a18dac
commit
ebf65a0c2a
@ -35,7 +35,7 @@ func (this *apiComp) RankList(session comm.IUserSession, req *pb.PagodaRankListR
|
|||||||
pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
|
pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
|
||||||
)
|
)
|
||||||
if req.FloorId == 0 {
|
if req.FloorId == 0 {
|
||||||
rd = pipe.ZRange("pagodaSeasonRank"+strconv.Itoa(int(req.FloorId)), 0, 50)
|
rd = pipe.ZRange("pagodaSeasonRank", 0, 50)
|
||||||
} else {
|
} else {
|
||||||
rd = pipe.ZRange("pagodaList"+strconv.Itoa(int(req.FloorId)), 0, 50)
|
rd = pipe.ZRange("pagodaList"+strconv.Itoa(int(req.FloorId)), 0, 50)
|
||||||
}
|
}
|
||||||
|
@ -169,18 +169,15 @@ func (this *configureComp) GetPassCheckByID(id int32) *cfg.GamePassCheckData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取
|
// 获取
|
||||||
func (this *configureComp) GetPagodaSeasonReward() [][]int32 {
|
func (this *configureComp) GetPagodaSeasonReward() []*cfg.GamePagodaSeasonRewardData {
|
||||||
rank := make([][]int32, 0)
|
|
||||||
if v, err := this.GetConfigure(game_pagodaseasonreward); err == nil {
|
if v, err := this.GetConfigure(game_pagodaseasonreward); err == nil {
|
||||||
var (
|
var (
|
||||||
configure *cfg.GamePagodaSeasonReward
|
configure *cfg.GamePagodaSeasonReward
|
||||||
ok bool
|
ok bool
|
||||||
)
|
)
|
||||||
if configure, ok = v.(*cfg.GamePagodaSeasonReward); ok {
|
if configure, ok = v.(*cfg.GamePagodaSeasonReward); ok {
|
||||||
for _, v := range configure.GetDataList() {
|
return configure.GetDataList()
|
||||||
rank = append(rank, v.Ranking)
|
|
||||||
}
|
|
||||||
return rank
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -248,14 +248,19 @@ func (this *ModelRank) seasonSettlement() {
|
|||||||
if list == nil {
|
if list == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rankReward := this.modulePagoda.configure.GetPagodaSeasonReward()
|
||||||
|
if rankReward == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
if !db.IsCross() {
|
if !db.IsCross() {
|
||||||
if conn, err := db.Cross(); err == nil {
|
if conn, err := db.Cross(); err == nil {
|
||||||
var (
|
var (
|
||||||
pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
|
pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
|
||||||
//Items []*pb.UserAssets
|
Items []*pb.UserAssets
|
||||||
)
|
)
|
||||||
|
|
||||||
rd := pipe.ZRange("pagodaSeasonRank0", 0, 50)
|
rd := pipe.ZRange("pagodaSeasonRank", 0, 50)
|
||||||
|
|
||||||
if _, err = pipe.Exec(); err != nil {
|
if _, err = pipe.Exec(); err != nil {
|
||||||
this.modulePagoda.Errorln(err)
|
this.modulePagoda.Errorln(err)
|
||||||
@ -263,20 +268,27 @@ func (this *ModelRank) seasonSettlement() {
|
|||||||
}
|
}
|
||||||
uids := rd.Val()
|
uids := rd.Val()
|
||||||
|
|
||||||
if len(uids) > 0 {
|
for index, uid := range uids {
|
||||||
//Items = make([]*pb.UserAssets, 0) //TO 排名配置
|
Items = make([]*pb.UserAssets, 0) //TO 排名配置
|
||||||
// for i, v := range v.RankReward {
|
for _, v := range rankReward {
|
||||||
// Items[i] = &pb.UserAssets{
|
if len(v.Ranking) != 2 {
|
||||||
// A: v.A,
|
continue
|
||||||
// T: v.T,
|
}
|
||||||
// N: v.N,
|
if index >= int(v.Ranking[0]) && index <= int(v.Ranking[1]) {
|
||||||
// }
|
for _, v1 := range v.Reward {
|
||||||
// }
|
Items = append(Items, &pb.UserAssets{
|
||||||
//发邮件
|
A: v1.A,
|
||||||
// this.modulePagoda.mail.SendNewMail(&pb.DBMailData{
|
T: v1.T,
|
||||||
// CreateTime: uint64(configure.Now().Unix()),
|
N: v1.N,
|
||||||
// Items: Items,
|
})
|
||||||
// }, uids...)
|
}
|
||||||
|
this.modulePagoda.mail.SendNewMail(&pb.DBMailData{
|
||||||
|
CreateTime: uint64(configure.Now().Unix()),
|
||||||
|
Items: Items,
|
||||||
|
}, uid)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ type Pagoda struct {
|
|||||||
configure *configureComp
|
configure *configureComp
|
||||||
battle comm.IBattle
|
battle comm.IBattle
|
||||||
service base.IRPCXService
|
service base.IRPCXService
|
||||||
//mail comm.Imail
|
mail comm.Imail
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewModule() core.IModule {
|
func NewModule() core.IModule {
|
||||||
@ -73,11 +73,14 @@ func (this *Pagoda) Start() (err error) {
|
|||||||
if module, err = this.service.GetModule(comm.ModuleBattle); err != nil {
|
if module, err = this.service.GetModule(comm.ModuleBattle); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// if module, err = this.service.GetModule(comm.ModuleMail); err != nil {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//this.mail = module.(comm.Imail)
|
|
||||||
this.battle = module.(comm.IBattle)
|
this.battle = module.(comm.IBattle)
|
||||||
|
|
||||||
|
if module, err = this.service.GetModule(comm.ModuleMail); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.mail = module.(comm.Imail)
|
||||||
|
|
||||||
this.service.RegisterFunctionName(string(comm.Rpc_ModuleSeasonPagodaReward), this.Rpc_ModuleSeasonPagodaReward)
|
this.service.RegisterFunctionName(string(comm.Rpc_ModuleSeasonPagodaReward), this.Rpc_ModuleSeasonPagodaReward)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ type Timer struct {
|
|||||||
cbase.ModuleBase
|
cbase.ModuleBase
|
||||||
options *Options
|
options *Options
|
||||||
service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口
|
service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口
|
||||||
rank *PagodaRank
|
//rank *PagodaRank
|
||||||
rank2 *VikingRank
|
rank2 *VikingRank
|
||||||
rank3 *HuntingRank
|
rank3 *HuntingRank
|
||||||
chat *ChatComp //俩天系统定时任务
|
chat *ChatComp //俩天系统定时任务
|
||||||
@ -59,7 +59,7 @@ func (this *Timer) Start() (err error) {
|
|||||||
|
|
||||||
func (this *Timer) OnInstallComp() {
|
func (this *Timer) OnInstallComp() {
|
||||||
this.ModuleBase.OnInstallComp()
|
this.ModuleBase.OnInstallComp()
|
||||||
this.rank = this.RegisterComp(new(PagodaRank)).(*PagodaRank)
|
//this.rank = this.RegisterComp(new(PagodaRank)).(*PagodaRank)
|
||||||
this.rank2 = this.RegisterComp(new(VikingRank)).(*VikingRank)
|
this.rank2 = this.RegisterComp(new(VikingRank)).(*VikingRank)
|
||||||
this.rank3 = this.RegisterComp(new(HuntingRank)).(*HuntingRank)
|
this.rank3 = this.RegisterComp(new(HuntingRank)).(*HuntingRank)
|
||||||
this.chat = this.RegisterComp(new(ChatComp)).(*ChatComp)
|
this.chat = this.RegisterComp(new(ChatComp)).(*ChatComp)
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
|
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/core/cbase"
|
"go_dreamfactory/lego/core/cbase"
|
||||||
"go_dreamfactory/lego/sys/cron"
|
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
@ -34,11 +33,8 @@ func (this *PagodaRank) Init(service core.IService, module core.IModule, comp co
|
|||||||
|
|
||||||
func (this *PagodaRank) Start() (err error) {
|
func (this *PagodaRank) Start() (err error) {
|
||||||
err = this.MCompModel.Start()
|
err = this.MCompModel.Start()
|
||||||
|
//cron.AddFunc("*/60 * * * * ?", this.TimerPagoda) //每60s执行一次
|
||||||
cron.AddFunc("*/60 * * * * ?", this.TimerPagoda) //每60s执行一次
|
//cron.AddFunc("*/60 * * * * ?", this.TimerSeason) //每60s执行一次
|
||||||
|
|
||||||
cron.AddFunc("*/60 * * * * ?", this.TimerSeason) //每60s执行一次
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
"go_dreamfactory/sys/db"
|
"go_dreamfactory/sys/db"
|
||||||
|
"time"
|
||||||
|
|
||||||
"go_dreamfactory/lego/base"
|
"go_dreamfactory/lego/base"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
@ -53,11 +54,36 @@ func (this *SeasonPagoda) Init(service core.IService, module core.IModule, comp
|
|||||||
func (this *SeasonPagoda) Start() (err error) {
|
func (this *SeasonPagoda) Start() (err error) {
|
||||||
err = this.MCompModel.Start()
|
err = this.MCompModel.Start()
|
||||||
err = this.MCompConfigure.Start()
|
err = this.MCompConfigure.Start()
|
||||||
|
|
||||||
configure.RegisterConfigure(game_seasonloop, cfg.NewGameSeasonLoop, nil)
|
configure.RegisterConfigure(game_seasonloop, cfg.NewGameSeasonLoop, nil)
|
||||||
configure.RegisterConfigure(game_seasonreward, cfg.NewGamePagodaSeasonReward, nil)
|
configure.RegisterConfigure(game_seasonreward, cfg.NewGamePagodaSeasonReward, nil)
|
||||||
cron.AddFunc("0 0 23 L * ?", this.TimerSeasonOver) //每月最后一天23点执行一次
|
cron.AddFunc("0 0 23 L * ?", this.TimerSeasonOver) //每月最后一天23点执行一次
|
||||||
cron.AddFunc("0 0 5 /* * ?", this.TimerSeasonStar) //每月第一天5点执行一次
|
cron.AddFunc("0 0 5 /* * ?", this.TimerSeasonStar) //每月第一天5点执行一次
|
||||||
|
|
||||||
|
conn, err := db.Cross()
|
||||||
|
if err == nil {
|
||||||
|
model := db.NewDBModel(comm.TableServerData, 0, conn)
|
||||||
|
|
||||||
|
_len, err1 := model.DB.CountDocuments(comm.TableServerData, bson.M{})
|
||||||
|
if err1 == nil && _len == 0 {
|
||||||
|
fmt.Printf("%v,%v", _len, err1)
|
||||||
|
server := &pb.DBServerData{
|
||||||
|
Id: primitive.NewObjectID().Hex(),
|
||||||
|
ServerState: 1,
|
||||||
|
DisposableLoop: 1,
|
||||||
|
FixedLoop: 0,
|
||||||
|
SeasonType: 201,
|
||||||
|
OpenTime: time.Now().Unix(),
|
||||||
|
}
|
||||||
|
conf := this.GetSeasonLoop(comm.SeasonType)
|
||||||
|
if len(conf.DisposableLoop) > 0 {
|
||||||
|
server.SeasonType = conf.DisposableLoop[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
model.DB.InsertOne(comm.TableServerData, server)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func (this *SeasonPagoda) CreatTestData(index int) {
|
func (this *SeasonPagoda) CreatTestData(index int) {
|
||||||
|
Loading…
Reference in New Issue
Block a user