99 lines
2.1 KiB
Go
99 lines
2.1 KiB
Go
package activity
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
)
|
|
|
|
type Activity struct {
|
|
modules.ModuleBase
|
|
api *apiComp
|
|
configure *configureComp
|
|
|
|
service core.IService
|
|
modelhdList *modelHdList
|
|
modelhdData *modelhdData
|
|
}
|
|
|
|
func NewModule() core.IModule {
|
|
return &Activity{}
|
|
}
|
|
|
|
func (this *Activity) GetType() core.M_Modules {
|
|
return comm.ModuleActivity
|
|
}
|
|
|
|
func (this *Activity) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
|
err = this.ModuleBase.Init(service, module, options)
|
|
this.service = service
|
|
|
|
// ticker := time.NewTicker(time.Second * 10)
|
|
// go func() {
|
|
// for {
|
|
// select {
|
|
// case <-ticker.C:
|
|
// this.CreateHdData()
|
|
// return
|
|
// }
|
|
// }
|
|
// }()
|
|
return
|
|
}
|
|
|
|
func (this *Activity) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
|
this.modelhdData = this.RegisterComp(new(modelhdData)).(*modelhdData)
|
|
this.modelhdList = this.RegisterComp(new(modelHdList)).(*modelHdList)
|
|
}
|
|
|
|
// 创建一条活动数据
|
|
func (this *Activity) CreateHdData() (err error) {
|
|
var db *pb.DBHuodong
|
|
db = &pb.DBHuodong{
|
|
Id: primitive.NewObjectID().Hex(),
|
|
Hdid: 10001,
|
|
Rtime: 1680105599,
|
|
Itype: 0,
|
|
Name: "累计充值活动",
|
|
Img: "",
|
|
Showtime: "03月15日00:00-03月20日23:59",
|
|
PressImg: "huodong_btn4_1.png",
|
|
Intr: "累计充值,限时福利",
|
|
Etime: 1680105599,
|
|
NormalImg: "huodong_btn4.png",
|
|
Stime: 1679414400,
|
|
Tab: 2,
|
|
Ttype: 0,
|
|
Icon: "ico_event_yxjl",
|
|
Open: 1,
|
|
Order: 102,
|
|
Stype: 10009,
|
|
Htype: 9,
|
|
Data: &pb.ActivityInfo{},
|
|
}
|
|
for i := 0; i < 6; i++ {
|
|
var p []*pb.UserAssets
|
|
p = append(p, &pb.UserAssets{
|
|
A: "item",
|
|
T: "10000001",
|
|
N: 1,
|
|
})
|
|
db.Data.Prize = append(db.Data.Prize, &pb.Arr{
|
|
Prize: p,
|
|
Val: int32(i) + 1,
|
|
})
|
|
|
|
}
|
|
|
|
this.modelhdList.addHdList(db)
|
|
fmt.Printf("%v", db)
|
|
return
|
|
}
|