diff --git a/modules/caravan/comp_configure.go b/modules/caravan/comp_configure.go index 2d5909b49..f56fbfca6 100644 --- a/modules/caravan/comp_configure.go +++ b/modules/caravan/comp_configure.go @@ -117,9 +117,9 @@ func (this *configureComp) GetAllCaravanItem() (data []*cfg.GameCaravanThingData } // 获取随机事件 -func (this *configureComp) GetCaravanEventById(id int32) (data *cfg.GameCaravanRventData) { +func (this *configureComp) GetCaravanEventById(id int32) (data *cfg.GameCaravanEventData) { if v, err := this.GetConfigure(game_caravan_event); err == nil { - if configure, ok := v.(*cfg.GameCaravanRvent); ok { + if configure, ok := v.(*cfg.GameCaravanEvent); ok { data = configure.Get(id) return } diff --git a/modules/timer/caravanrank.go b/modules/timer/caravanrank.go index 9cfaae7ea..0ee071bf5 100644 --- a/modules/timer/caravanrank.go +++ b/modules/timer/caravanrank.go @@ -1,10 +1,8 @@ package timer import ( - "context" "go_dreamfactory/comm" "go_dreamfactory/modules" - "go_dreamfactory/pb" "time" "go_dreamfactory/lego/core" @@ -12,6 +10,7 @@ import ( "go_dreamfactory/lego/sys/cron" "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo/options" ) // 此组件废弃 @@ -35,18 +34,17 @@ func (this *CaravanRank) Init(service core.IService, module core.IModule, comp c func (this *CaravanRank) Start() (err error) { err = this.MCompModel.Start() cron.AddFunc("30 10 1 * * ?", this.TimerSeason) + this.TimerSeason() return } func (this *CaravanRank) TimerSeason() { sTime := time.Now() - if _data, err := this.DB.Find(comm.TableUser, bson.M{}); err == nil { - for _data.Next(context.TODO()) { - temp := &pb.DBUser{} - if err = _data.Decode(temp); err == nil { - this.DB.UpdateOne(comm.TableUser, bson.M{"_id": temp.Id}, bson.M{"merchantmoney": 0}) - } - } + Query := bson.M{} + Query["merchantmoney"] = 0 + _, err := this.DB.UpdateMany(core.SqlTable(comm.TableUser), bson.M{}, bson.M{"$set": Query}, options.MergeUpdateOptions().SetUpsert(true)) //, new(options.UpdateOptions).SetUpsert(true) + if err != nil { } + this.module.Debugf("sub time:%d", time.Now().Local().Sub(sTime).Milliseconds()) } diff --git a/modules/timer/module.go b/modules/timer/module.go index fe1340958..54d0eab8b 100644 --- a/modules/timer/module.go +++ b/modules/timer/module.go @@ -30,6 +30,7 @@ type Timer struct { forum *ForumComp arena *ArenaComp parkour *ParkourComp + caravan *CaravanRank } //模块名 @@ -62,6 +63,7 @@ func (this *Timer) OnInstallComp() { //this.season = this.RegisterComp(new(SeasonPagoda)).(*SeasonPagoda) this.arena = this.RegisterComp(new(ArenaComp)).(*ArenaComp) this.parkour = this.RegisterComp(new(ParkourComp)).(*ParkourComp) + this.caravan = this.RegisterComp(new(CaravanRank)).(*CaravanRank) } //跨服对象获取数据操作对象