From a97c34898612011b648657465a8c0aec5e4ae7f0 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 14 Mar 2023 14:42:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E9=99=84=E4=BB=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/hero_test.go | 32 +++++++++++++++++++++++++++++++- modules/hero/module.go | 6 +++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/modules/hero/hero_test.go b/modules/hero/hero_test.go index 1697337f3..dce0a1d87 100644 --- a/modules/hero/hero_test.go +++ b/modules/hero/hero_test.go @@ -7,6 +7,7 @@ import ( "go_dreamfactory/lego" "go_dreamfactory/lego/base/rpcx" "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/cron" "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules/equipment" "go_dreamfactory/modules/hero" @@ -26,7 +27,9 @@ import ( "time" "github.com/golang/protobuf/ptypes" + "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo/options" flag "github.com/spf13/pflag" ) @@ -71,8 +74,35 @@ func GetMonthStartEnd() (int64, int64) { fmt.Printf("%d,%d", _d1, _d2) return _d1, _d2 } -func Test_Main(t *testing.T) { +func TimerStar() { + //star := configure.Now() + if !db.IsCross() { + conn, err := db.Cross() + if err == nil { + model := db.NewDBModel(comm.TableSeasonData, 0, conn) + model.DB.DeleteMany(comm.TableSeasonPagoda, bson.M{}, options.Delete()) + model.DB.DeleteMany(comm.TableSeasonRecord, bson.M{}, options.Delete()) + for pos := 0; pos < comm.MaxRankNum; pos++ { + key1 := fmt.Sprintf("pagodaList%d", pos) + if err := model.Redis.Delete(key1); err != nil { + log.Errorf("delete failed") + } + } + + if err := model.Redis.Delete("pagodaSeasonRank"); err != nil { + log.Errorf("delete failed") + } + } + + // DB.DeleteMany(comm.TableSeasonRecord, bson.M{}, options.Delete()) + + } + //this.module.Debugf("=====%d,", time.Since(star).Milliseconds()) +} + +func Test_Main(t *testing.T) { + cron.AddFunc("0 0 5 /* * ?", TimerStar) //每月第一天5点执行一次 sz := make([]string, 0) for i := 0; i < 10; i++ { sz = append(sz, "1") diff --git a/modules/hero/module.go b/modules/hero/module.go index d5371c5af..0999779ac 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -96,9 +96,9 @@ func (this *Hero) createRepeatHero(session comm.IUserSession, heroCfgId string, cfg := this.configure.GetHeroConfig(heroCfgId) if cfg != nil { var szTask []*comm.TaskParam - szTask = append(szTask, comm.GettaskParam(comm.Rtype1, utils.ToInt32(heroCfgId))) - szTask = append(szTask, comm.GettaskParam(comm.Rtype30, cfg.Color)) - szTask = append(szTask, comm.GettaskParam(comm.Rtype31, cfg.Color)) + szTask = append(szTask, comm.GettaskParam(comm.Rtype1, 1, utils.ToInt32(heroCfgId))) + szTask = append(szTask, comm.GettaskParam(comm.Rtype30, 1, cfg.Color)) + szTask = append(szTask, comm.GettaskParam(comm.Rtype31, 1, cfg.Color)) go this.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) }