go_dreamfactory/modules/activity/module.go
2023-08-01 13:45:13 +08:00

145 lines
3.4 KiB
Go

package activity
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/db"
)
type Activity struct {
modules.ModuleBase
api *apiComp
configure *configureComp
service core.IService
modelhdList *modelHdList
modelhdData *modelhdData
//warorder comm.IWarorder // 战令
}
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) Start() (err error) {
err = this.ModuleBase.Start()
if !db.IsCross() {
if rst, err := this.modelhdList.getHdInfoByHdType(comm.HdTypeWarorder); err == nil {
// 服务启动 获取活动信息
var module core.IModule
if module, err = this.service.GetModule(comm.ModuleWarorder); err == nil {
if m, ok := module.(comm.IWarorder); ok {
m.ActivityNotice(rst)
}
}
}
if rst, err := this.modelhdList.getHdInfoByHdType(comm.HdTypePay); err == nil {
// 服务启动 获取活动信息
var module core.IModule
if module, err = this.service.GetModule(comm.ModulePay); err == nil {
if m, ok := module.(comm.IPay); ok {
m.ActivityNotice(rst)
}
}
}
}
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.addHdInfo(db)
// fmt.Printf("%v", db)
// return
// }
func (this *Activity) CreateHdData() (err error) {
this.modelhdList.getHdInfo()
return
}
func (this *Activity) GetAllHdInfo() (result []*pb.DBHuodong, err error) {
result, err = this.modelhdList.getHdInfo()
return
}
// 通过活动ID查找
func (this *Activity) GetHdInfoByHdId(oid string) (result *pb.DBHuodong, err error) {
result, err = this.modelhdList.getHdInfoByHdId(oid)
return
}
func (this *Activity) UpdateActivitySlider(session comm.IUserSession, oid string, val int32) {
}