转盘活动结束 抽奖卷转换成其他道具
This commit is contained in:
parent
e20f15544a
commit
13ad24eecc
@ -590,10 +590,10 @@ type (
|
||||
}
|
||||
|
||||
IActivity interface {
|
||||
GetHdInfoByHdId(oid string) (result *pb.DBHuodong, err error) // 通过活动id 获取活动信息
|
||||
GetAllHdInfo() (result []*pb.DBHuodong, err error) // 获取所有活动信息
|
||||
|
||||
UpdateActivitySlider(session IUserSession) // 修改活动进度
|
||||
GetHdInfoByHdId(oid string) (result *pb.DBHuodong, err error) // 通过活动id 获取活动信息
|
||||
GetAllHdInfo() (hdList map[int32][]*pb.DBHuodong) // 获取所有活动信息
|
||||
GetHdInfoByItype(itype int32) (result []*pb.DBHuodong, err error) //
|
||||
UpdateActivitySlider(session IUserSession) // 修改活动进度
|
||||
}
|
||||
//每日任务
|
||||
IDailytask interface {
|
||||
|
@ -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) {
|
||||
var (
|
||||
data []*pb.DBHuodong
|
||||
)
|
||||
list := this.module.modelhdList.getHdInfo()
|
||||
|
||||
list, err := this.module.modelhdList.getHdInfo()
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
for _, szhd := range list {
|
||||
for _, v := range szhd {
|
||||
data = append(data, v)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "getlist", &pb.ActivityGetListResp{
|
||||
Data: list,
|
||||
Data: data,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"sync"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
@ -15,6 +16,9 @@ import (
|
||||
type modelHdList struct {
|
||||
modules.MCompModel
|
||||
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) {
|
||||
@ -30,20 +34,9 @@ func (this *modelHdList) Init(service core.IService, module core.IModule, comp c
|
||||
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 {
|
||||
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
|
||||
return this.activity
|
||||
}
|
||||
|
||||
// 通过活动ID查找
|
||||
@ -77,8 +70,26 @@ func (this *modelHdList) getHdInfoByHdType(iType int32) (result *pb.DBHuodong, e
|
||||
|
||||
result = &pb.DBHuodong{}
|
||||
if err = _data.Decode(result); err != nil {
|
||||
this.module.Errorln(err)
|
||||
this.module.Errorln("活动配置没找到:活动类型:%d,错误信息:%v", iType, err.Error())
|
||||
|
||||
}
|
||||
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
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
@ -76,6 +77,7 @@ func (this *Activity) Start() (err error) {
|
||||
// Val: 1,
|
||||
// }
|
||||
// this.modelhdData.InsertHddata("", ac)
|
||||
this.modelhdList.LoadActivityData()
|
||||
}
|
||||
|
||||
return
|
||||
@ -136,9 +138,18 @@ func (this *Activity) CreateHdData() (err error) {
|
||||
this.modelhdList.getHdInfo()
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@ type ModuleBase struct {
|
||||
ModuleTools comm.ITools //工具类 获取一些通用配置
|
||||
ModuleBuried comm.IBuried //触发埋点中心
|
||||
ModuleMail comm.Imail //邮件
|
||||
ModuleActivity comm.IActivity //活动模块
|
||||
}
|
||||
|
||||
// 重构模块配置对象
|
||||
@ -145,6 +146,11 @@ func (this *ModuleBase) Start() (err error) {
|
||||
return
|
||||
}
|
||||
this.ModuleMail = module.(comm.Imail)
|
||||
|
||||
if module, err = this.service.GetModule(comm.ModuleActivity); err != nil {
|
||||
return
|
||||
}
|
||||
this.ModuleActivity = module.(comm.IActivity)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
"go_dreamfactory/utils"
|
||||
"strconv"
|
||||
|
||||
"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)
|
||||
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.RecoverUserPsStart(user.Uid)
|
||||
// 日常登录任务
|
||||
|
Loading…
Reference in New Issue
Block a user