53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
package timer
|
|
|
|
import (
|
|
"context"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
|
|
"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)
|
|
return
|
|
}
|
|
|
|
func (this *CaravanRank) TimerSeason() {
|
|
|
|
if _data, err := this.DB.Find(comm.TableUser, bson.M{}, options.Find().SetSort(bson.M{"merchantmoney": -1}).SetLimit(comm.MaxRankList)); 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": 10000})
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|