From 3d2c87b003a23d9245ea11986826aef7bb9f93cf Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 31 Jul 2023 17:20:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 3 ++- modules/activity/model_hdlist.go | 17 ++++++++++++++++- modules/activity/module.go | 6 +++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/comm/const.go b/comm/const.go index 46feabba3..e29997c76 100644 --- a/comm/const.go +++ b/comm/const.go @@ -959,5 +959,6 @@ const ( ) const ( - HuodongWarorder = 100002 // 战令活动 + HdTypeWarorder = 1 // 圣桃战令类型 + HdTypePay = 2 // 限时类型 ) diff --git a/modules/activity/model_hdlist.go b/modules/activity/model_hdlist.go index 1e748e4f8..5ad08810f 100644 --- a/modules/activity/model_hdlist.go +++ b/modules/activity/model_hdlist.go @@ -24,7 +24,9 @@ func (this *modelHdList) Init(service core.IService, module core.IModule, comp c this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ Keys: bsonx.Doc{{Key: "hdid", Value: bsonx.Int32(1)}}, }) - + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "itype", Value: bsonx.Int32(1)}}, + }) return } @@ -67,3 +69,16 @@ func (this *modelHdList) addHdInfo(hd *pb.DBHuodong) error { } return nil } + +// 通过活动类型查找 +func (this *modelHdList) getHdInfoByHdType(iType int32) (result *pb.DBHuodong, err error) { + + _data := this.DBModel.DB.FindOne(comm.TableHdInfo, bson.M{"itype": iType}) + + result = &pb.DBHuodong{} + if err = _data.Decode(result); err != nil { + this.module.Errorln(err) + + } + return +} diff --git a/modules/activity/module.go b/modules/activity/module.go index 435c0237c..43c984744 100644 --- a/modules/activity/module.go +++ b/modules/activity/module.go @@ -48,7 +48,7 @@ func (this *Activity) Start() (err error) { err = this.ModuleBase.Start() if !db.IsCross() { - if rst, err := this.modelhdList.getHdInfoByHdId(comm.HuodongWarorder); err == nil { + if rst, err := this.modelhdList.getHdInfoByHdType(comm.HdTypeWarorder); err == nil { // 服务启动 获取活动信息 var module core.IModule if module, err = this.service.GetModule(comm.ModuleWarorder); err == nil { @@ -57,6 +57,10 @@ func (this *Activity) Start() (err error) { 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.OpenActivity(1, rst.Stime)