This commit is contained in:
meixiongfeng 2023-05-22 18:24:21 +08:00
parent bcd4c9a1a0
commit 519880d6bc
3 changed files with 11 additions and 11 deletions

View File

@ -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 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) data = configure.Get(id)
return return
} }

View File

@ -1,10 +1,8 @@
package timer package timer
import ( import (
"context"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb"
"time" "time"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
@ -12,6 +10,7 @@ import (
"go_dreamfactory/lego/sys/cron" "go_dreamfactory/lego/sys/cron"
"go.mongodb.org/mongo-driver/bson" "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) { func (this *CaravanRank) Start() (err error) {
err = this.MCompModel.Start() err = this.MCompModel.Start()
cron.AddFunc("30 10 1 * * ?", this.TimerSeason) cron.AddFunc("30 10 1 * * ?", this.TimerSeason)
this.TimerSeason()
return return
} }
func (this *CaravanRank) TimerSeason() { func (this *CaravanRank) TimerSeason() {
sTime := time.Now() sTime := time.Now()
if _data, err := this.DB.Find(comm.TableUser, bson.M{}); err == nil { Query := bson.M{}
for _data.Next(context.TODO()) { Query["merchantmoney"] = 0
temp := &pb.DBUser{} _, 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 = _data.Decode(temp); err == nil { if err != nil {
this.DB.UpdateOne(comm.TableUser, bson.M{"_id": temp.Id}, bson.M{"merchantmoney": 0})
}
}
} }
this.module.Debugf("sub time:%d", time.Now().Local().Sub(sTime).Milliseconds()) this.module.Debugf("sub time:%d", time.Now().Local().Sub(sTime).Milliseconds())
} }

View File

@ -30,6 +30,7 @@ type Timer struct {
forum *ForumComp forum *ForumComp
arena *ArenaComp arena *ArenaComp
parkour *ParkourComp parkour *ParkourComp
caravan *CaravanRank
} }
//模块名 //模块名
@ -62,6 +63,7 @@ func (this *Timer) OnInstallComp() {
//this.season = this.RegisterComp(new(SeasonPagoda)).(*SeasonPagoda) //this.season = this.RegisterComp(new(SeasonPagoda)).(*SeasonPagoda)
this.arena = this.RegisterComp(new(ArenaComp)).(*ArenaComp) this.arena = this.RegisterComp(new(ArenaComp)).(*ArenaComp)
this.parkour = this.RegisterComp(new(ParkourComp)).(*ParkourComp) this.parkour = this.RegisterComp(new(ParkourComp)).(*ParkourComp)
this.caravan = this.RegisterComp(new(CaravanRank)).(*CaravanRank)
} }
//跨服对象获取数据操作对象 //跨服对象获取数据操作对象