go_dreamfactory/modules/timer/caravanrank.go
2023-05-22 19:08:34 +08:00

61 lines
1.5 KiB
Go

package timer
import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/cron"
)
// 此组件废弃
type CaravanRank struct {
cbase.ModuleBase
modules.MCompModel
service base.IRPCXService
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.(base.IRPCXService)
return
}
func (this *CaravanRank) Start() (err error) {
err = this.MCompModel.Start()
cron.AddFunc("30 10 1 * * ?", this.TimerSeason)
return
}
func (this *CaravanRank) TimerSeason() {
if _, err := this.service.RpcGo(context.Background(),
comm.Service_Worker,
string(comm.Rpc_ModuleCaravanSettlement),
pb.EmptyReq{},
nil,
); err != nil {
this.module.Errorln(err)
}
// 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.Errorf("UpdateMany error: %v", err)
// }
// this.module.Debugf("sub time:%d", time.Now().Local().Sub(sTime).Milliseconds())
}