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 configure, ok := v.(*cfg.GameCaravanRvent); ok {
if configure, ok := v.(*cfg.GameCaravanEvent); ok {
data = configure.Get(id)
return
}

View File

@ -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())
}

View File

@ -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)
}
//跨服对象获取数据操作对象