go_dreamfactory/modules/timer/caravanrank.go
2023-05-22 18:24:21 +08:00

51 lines
1.2 KiB
Go

package timer
import (
"go_dreamfactory/comm"
"go_dreamfactory/modules"
"time"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/cron"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo/options"
)
// 此组件废弃
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)
this.TimerSeason()
return
}
func (this *CaravanRank) TimerSeason() {
sTime := time.Now()
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())
}