From 356a22a4c891b4c2c18006d89e9cc4bcddd1edf2 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 1 Jun 2023 18:06:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E9=98=9F=E7=BB=93=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/caravan/comp_configure.go | 6 +++++- modules/caravan/module.go | 7 +++++-- modules/timer/caravanrank.go | 16 +++++++++++----- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/modules/caravan/comp_configure.go b/modules/caravan/comp_configure.go index da9dfc71b..3a924b9ea 100644 --- a/modules/caravan/comp_configure.go +++ b/modules/caravan/comp_configure.go @@ -199,12 +199,16 @@ func (this *configureComp) GetCaravanReward() (reward []*cfg.GameCaravanRewardDa } func (this *configureComp) GetCaravanRank(index int32) (reward *cfg.GameCaravanRankData, err error) { - if v, err := this.GetConfigure(game_caravan_rank); err == nil { + var ( + v interface{} + ) + if v, err = this.GetConfigure(game_caravan_rank); err == nil { if configure, ok := v.(*cfg.GameCaravanRank); ok { if reward = configure.Get(index); reward == nil { err = comm.NewNotFoundConfErr(moduleName, game_caravan_rank, index) this.module.Errorln(err) } + return } } err = comm.NewNotFoundConfErr(moduleName, game_caravan_rank, index) diff --git a/modules/caravan/module.go b/modules/caravan/module.go index a02d889f7..96d4fb6d9 100644 --- a/modules/caravan/module.go +++ b/modules/caravan/module.go @@ -354,11 +354,14 @@ func (this *Caravan) TestFunc(session comm.IUserSession) { } // 赛季结算 -func (this *Caravan) Rpc_ModuleCaravanSettlement(ctx context.Context, args *pb.EmptyReq, reply *pb.EmptyResp) { +func (this *Caravan) Rpc_ModuleCaravanSettlement(ctx context.Context, args *pb.EmptyReq, reply *pb.EmptyResp) (err error) { + this.Debug("Rpc_ModuleCaravanSettlement", + log.Field{Key: "args", Value: args.String()}, + ) go func() { sTime := time.Now() var rankIndex int32 - if _data, err := this.modelCaravan.DB.Find(comm.TableUser, bson.M{}, options.Find().SetSort(bson.M{"merchantmoney": -1}).SetLimit(comm.MaxRankList)); err == nil { + if _data, err := this.modelCaravan.DB.Find(comm.TableUser, bson.M{"merchantmoney": bson.M{"$gt": 0}}, options.Find().SetSort(bson.M{"merchantmoney": -1}).SetLimit(comm.MaxRankList)); err == nil { for _data.Next(context.TODO()) { rankIndex++ temp := &pb.DBUser{} diff --git a/modules/timer/caravanrank.go b/modules/timer/caravanrank.go index d7cc2ce1d..b08f6eb8a 100644 --- a/modules/timer/caravanrank.go +++ b/modules/timer/caravanrank.go @@ -14,6 +14,7 @@ import ( "go_dreamfactory/pb" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" + "go_dreamfactory/sys/db" "time" ) @@ -68,6 +69,9 @@ func (this *CaravanRank) GetGlobalConf() *cfg.GameGlobalData { return configure.GetDataList()[0] // 返回对象信息 } func (this *CaravanRank) Start() (err error) { + if db.IsCross() { + return + } err = this.MCompModel.Start() opentime := this.service.GetOpentime().Unix() if configure.Now().Unix() < opentime { // 开服时间是未来可能存在问题 @@ -77,16 +81,19 @@ func (this *CaravanRank) Start() (err error) { currentTime := time.Unix(opentime, 0) m := currentTime.Minute() s := currentTime.Second() + h := currentTime.Hour() day := this.GetGlobalConf().BusinessRewardday - cronStr := fmt.Sprintf("%d %d */%d * * ?", m, s, day) // 每天的 + cronStr := fmt.Sprintf("%d %d %d */%d * ?", m, s, h, day) // + this.module.Debugf("cron start: %s", cronStr) cron.AddFunc(cronStr, this.TimerSeason) - + //this.TimerSeason() return } func (this *CaravanRank) TimerSeason() { - - if _, err := this.service.RpcGo(context.Background(), + this.module.Debugf("TimerSeason start: %d", configure.Now().Unix()) + if err := this.service.RpcCall( + context.Background(), comm.Service_Worker, string(comm.Rpc_ModuleCaravanSettlement), pb.EmptyReq{}, @@ -94,5 +101,4 @@ func (this *CaravanRank) TimerSeason() { ); err != nil { this.module.Errorln(err) } - }