转盘活动结束 抽奖卷转换成其他道具
This commit is contained in:
parent
e20f15544a
commit
13ad24eecc
@ -591,8 +591,8 @@ type (
|
|||||||
|
|
||||||
IActivity interface {
|
IActivity interface {
|
||||||
GetHdInfoByHdId(oid string) (result *pb.DBHuodong, err error) // 通过活动id 获取活动信息
|
GetHdInfoByHdId(oid string) (result *pb.DBHuodong, err error) // 通过活动id 获取活动信息
|
||||||
GetAllHdInfo() (result []*pb.DBHuodong, err error) // 获取所有活动信息
|
GetAllHdInfo() (hdList map[int32][]*pb.DBHuodong) // 获取所有活动信息
|
||||||
|
GetHdInfoByItype(itype int32) (result []*pb.DBHuodong, err error) //
|
||||||
UpdateActivitySlider(session IUserSession) // 修改活动进度
|
UpdateActivitySlider(session IUserSession) // 修改活动进度
|
||||||
}
|
}
|
||||||
//每日任务
|
//每日任务
|
||||||
|
@ -13,18 +13,18 @@ func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.ActivityGet
|
|||||||
|
|
||||||
// 获取所有活动信息
|
// 获取所有活动信息
|
||||||
func (this *apiComp) GetList(session comm.IUserSession, req *pb.ActivityGetListReq) (errdata *pb.ErrorData) {
|
func (this *apiComp) GetList(session comm.IUserSession, req *pb.ActivityGetListReq) (errdata *pb.ErrorData) {
|
||||||
|
var (
|
||||||
|
data []*pb.DBHuodong
|
||||||
|
)
|
||||||
|
list := this.module.modelhdList.getHdInfo()
|
||||||
|
|
||||||
list, err := this.module.modelhdList.getHdInfo()
|
for _, szhd := range list {
|
||||||
if err != nil {
|
for _, v := range szhd {
|
||||||
errdata = &pb.ErrorData{
|
data = append(data, v)
|
||||||
Code: pb.ErrorCode_DBError,
|
|
||||||
Title: pb.ErrorCode_DBError.ToString(),
|
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
session.SendMsg(string(this.module.GetType()), "getlist", &pb.ActivityGetListResp{
|
session.SendMsg(string(this.module.GetType()), "getlist", &pb.ActivityGetListResp{
|
||||||
Data: list,
|
Data: data,
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
@ -15,6 +16,9 @@ import (
|
|||||||
type modelHdList struct {
|
type modelHdList struct {
|
||||||
modules.MCompModel
|
modules.MCompModel
|
||||||
module *Activity
|
module *Activity
|
||||||
|
|
||||||
|
hlock sync.RWMutex
|
||||||
|
activity map[int32][]*pb.DBHuodong
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *modelHdList) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *modelHdList) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
@ -30,20 +34,9 @@ func (this *modelHdList) Init(service core.IService, module core.IModule, comp c
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *modelHdList) getHdInfo() (result []*pb.DBHuodong, err error) {
|
func (this *modelHdList) getHdInfo() (activity map[int32][]*pb.DBHuodong) {
|
||||||
|
|
||||||
if _data, err := this.DBModel.DB.Find(comm.TableHdInfo, bson.M{}); err == nil {
|
return this.activity
|
||||||
for _data.Next(context.TODO()) {
|
|
||||||
temp := &pb.DBHuodong{}
|
|
||||||
if err = _data.Decode(temp); err != nil {
|
|
||||||
this.module.Errorln(err)
|
|
||||||
|
|
||||||
} else {
|
|
||||||
result = append(result, temp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通过活动ID查找
|
// 通过活动ID查找
|
||||||
@ -77,8 +70,26 @@ func (this *modelHdList) getHdInfoByHdType(iType int32) (result *pb.DBHuodong, e
|
|||||||
|
|
||||||
result = &pb.DBHuodong{}
|
result = &pb.DBHuodong{}
|
||||||
if err = _data.Decode(result); err != nil {
|
if err = _data.Decode(result); err != nil {
|
||||||
this.module.Errorln(err)
|
this.module.Errorln("活动配置没找到:活动类型:%d,错误信息:%v", iType, err.Error())
|
||||||
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *modelHdList) LoadActivityData() {
|
||||||
|
if c, err := this.DB.Find(core.SqlTable(this.TableName), bson.M{}); err != nil {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
this.hlock.Lock()
|
||||||
|
defer this.hlock.Unlock()
|
||||||
|
this.activity = make(map[int32][]*pb.DBHuodong)
|
||||||
|
for c.Next(context.Background()) {
|
||||||
|
hd := &pb.DBHuodong{}
|
||||||
|
if err = c.Decode(hd); err != nil {
|
||||||
|
this.module.Errorf("err:%v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
this.activity[hd.Itype] = append(this.activity[hd.Itype], hd)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package activity
|
package activity
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
@ -76,6 +77,7 @@ func (this *Activity) Start() (err error) {
|
|||||||
// Val: 1,
|
// Val: 1,
|
||||||
// }
|
// }
|
||||||
// this.modelhdData.InsertHddata("", ac)
|
// this.modelhdData.InsertHddata("", ac)
|
||||||
|
this.modelhdList.LoadActivityData()
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -136,9 +138,18 @@ func (this *Activity) CreateHdData() (err error) {
|
|||||||
this.modelhdList.getHdInfo()
|
this.modelhdList.getHdInfo()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func (this *Activity) GetAllHdInfo() (result []*pb.DBHuodong, err error) {
|
|
||||||
|
|
||||||
result, err = this.modelhdList.getHdInfo()
|
func (this *Activity) GetAllHdInfo() (activity map[int32][]*pb.DBHuodong) {
|
||||||
|
return this.modelhdList.getHdInfo()
|
||||||
|
}
|
||||||
|
func (this *Activity) GetHdInfoByItype(itype int32) (result []*pb.DBHuodong, err error) {
|
||||||
|
if c := this.modelhdList.getHdInfo(); c != nil {
|
||||||
|
if _, ok := c[itype]; ok {
|
||||||
|
result = c[itype]
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = fmt.Errorf("Not found :%d type activity", itype)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ type ModuleBase struct {
|
|||||||
ModuleTools comm.ITools //工具类 获取一些通用配置
|
ModuleTools comm.ITools //工具类 获取一些通用配置
|
||||||
ModuleBuried comm.IBuried //触发埋点中心
|
ModuleBuried comm.IBuried //触发埋点中心
|
||||||
ModuleMail comm.Imail //邮件
|
ModuleMail comm.Imail //邮件
|
||||||
|
ModuleActivity comm.IActivity //活动模块
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重构模块配置对象
|
// 重构模块配置对象
|
||||||
@ -145,6 +146,11 @@ func (this *ModuleBase) Start() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.ModuleMail = module.(comm.Imail)
|
this.ModuleMail = module.(comm.Imail)
|
||||||
|
|
||||||
|
if module, err = this.service.GetModule(comm.ModuleActivity); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.ModuleActivity = module.(comm.IActivity)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
)
|
)
|
||||||
@ -165,6 +166,26 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (err
|
|||||||
this.module.modelSign.UserSign(session)
|
this.module.modelSign.UserSign(session)
|
||||||
go this.module.ModuleBuried.TriggerBuried(session.Clone(), comm.GetBuriedParam(comm.Rtype8, 1))
|
go this.module.ModuleBuried.TriggerBuried(session.Clone(), comm.GetBuriedParam(comm.Rtype8, 1))
|
||||||
}
|
}
|
||||||
|
// 转盘活动
|
||||||
|
if a, err := this.module.ModuleActivity.GetHdInfoByItype(comm.HdTypeTurntable); err != nil { //
|
||||||
|
bEnd := false
|
||||||
|
for _, v := range a {
|
||||||
|
if configure.Now().Unix() > v.Etime {
|
||||||
|
bEnd = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if bEnd { // 活动结束 活动道具转换
|
||||||
|
tick := this.module.ModuleTools.GetGlobalConf().VenturegiftsDraw
|
||||||
|
|
||||||
|
if item, err := this.module.configure.GetItemConfigureData(strconv.Itoa(int(tick))); err != nil {
|
||||||
|
|
||||||
|
if err := this.module.DispenseRes(session, item.Sale, true); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
this.module.ModuleHero.CheckPeachReward(session, user.Ctime)
|
this.module.ModuleHero.CheckPeachReward(session, user.Ctime)
|
||||||
this.module.RecoverUserPsStart(user.Uid)
|
this.module.RecoverUserPsStart(user.Uid)
|
||||||
// 日常登录任务
|
// 日常登录任务
|
||||||
|
Loading…
Reference in New Issue
Block a user