package timer import ( "context" "go_dreamfactory/comm" "go_dreamfactory/modules" "go_dreamfactory/pb" "time" "go_dreamfactory/lego/core" "go_dreamfactory/lego/core/cbase" "go_dreamfactory/lego/sys/cron" "go.mongodb.org/mongo-driver/bson" ) // 此组件废弃 type CaravanRank struct { cbase.ModuleBase modules.MCompModel service core.IService module *Timer } //组件初始化接口 func (this *CaravanRank) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { this.TableName = comm.TableCaravan this.MCompModel.Init(service, module, comp, options) this.module = module.(*Timer) this.service = service return } func (this *CaravanRank) Start() (err error) { err = this.MCompModel.Start() cron.AddFunc("30 10 1 * * ?", 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}) } } } this.module.Debugf("sub time:%d", time.Now().Local().Sub(sTime).Milliseconds()) }