登录事件

This commit is contained in:
meixiongfeng 2023-08-08 11:47:32 +08:00
parent b74a3a43fb
commit d2d710e6c8
2 changed files with 39 additions and 43 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/event"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure" "go_dreamfactory/sys/configure"
@ -21,6 +22,7 @@ type Activity struct {
modelhdList *modelHdList modelhdList *modelHdList
modelhdData *modelhdData modelhdData *modelhdData
mail *comm.Imail
//warorder comm.IWarorder // 战令 //warorder comm.IWarorder // 战令
} }
@ -50,11 +52,15 @@ func (this *Activity) Init(service core.IService, module core.IModule, options c
} }
func (this *Activity) Start() (err error) { func (this *Activity) Start() (err error) {
err = this.ModuleBase.Start() err = this.ModuleBase.Start()
var module core.IModule
if module, err = this.service.GetModule(comm.ModuleMail); err != nil {
return
}
event.RegisterGO(comm.EventUserLogin, this.EventUserLogin)
if !db.IsCross() { if !db.IsCross() {
if rst, err := this.modelhdList.getHdInfoByHdType(comm.HdTypeWarorder); 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 { if module, err = this.service.GetModule(comm.ModuleWarorder); err == nil {
if m, ok := module.(comm.IWarorder); ok { if m, ok := module.(comm.IWarorder); ok {
m.ActivityOpenNotice(rst) m.ActivityOpenNotice(rst)
@ -63,22 +69,12 @@ func (this *Activity) Start() (err error) {
} }
if rst, err := this.modelhdList.getHdInfoByHdType(comm.HdTypePay); err == nil { 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 module, err = this.service.GetModule(comm.ModulePay); err == nil {
if m, ok := module.(comm.IPay); ok { if m, ok := module.(comm.IPay); ok {
m.ActivityOpenNotice(rst) m.ActivityOpenNotice(rst)
} }
} }
} }
// ac := &pb.DBActivityData{
// Id: "",
// Uid: "",
// Hdoid: "64c8a90e510317d18960964a",
// Gotarr: map[int32]bool{},
// Lasttime: configure.Now().Unix(),
// Val: 1,
// }
// this.modelhdData.InsertHddata("", ac)
this.modelhdList.LoadActivityData() this.modelhdList.LoadActivityData()
} }
@ -273,3 +269,35 @@ func (this *Activity) HDCelebration(session comm.IUserSession, systemtype int32,
} }
return bDouble return bDouble
} }
func (this *Activity) EventUserLogin(session comm.IUserSession) {
// 转盘活动
if a, err := this.GetHdInfoByItype(pb.HdType_HdTypeTurntable); err != nil { //
bEnd := false
for _, v := range a {
if configure.Now().Unix() > v.Etime {
bEnd = true
break
}
}
if bEnd { // 活动结束 活动道具转换
t := this.ModuleTools.GetGlobalConf().VenturegiftsDraw
var reward []*pb.UserAssets
if item, err := this.configure.GetItemConfigureData(t); err != nil {
amount := this.ModuleItems.QueryItemAmount(session.GetUserId(), t)
if amount > 0 {
this.ModuleItems.AddItem(session, t, -int32(amount), true)
for _, v := range item.Sale {
reward = append(reward, &pb.UserAssets{
A: v.A,
T: v.T,
N: v.N * int32(amount),
})
}
// 发邮件
//this.mail.SendMailByCid(session, comm.Venturegifts, reward)
}
}
}
}
}

View File

@ -162,39 +162,7 @@ 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(pb.HdType_HdTypeTurntable); err != nil { //
bEnd := false
for _, v := range a {
if configure.Now().Unix() > v.Etime {
bEnd = true
break
}
}
if bEnd { // 活动结束 活动道具转换
t := this.module.ModuleTools.GetGlobalConf().VenturegiftsDraw
var reward []*pb.UserAssets
if item, err := this.module.configure.GetItemConfigureData(t); err != nil {
amount := this.module.ModuleItems.QueryItemAmount(session.GetUserId(), t)
if amount > 0 {
this.module.ModuleItems.AddItem(session, t, -int32(amount), true)
for _, v := range item.Sale {
reward = append(reward, &pb.UserAssets{
A: v.A,
T: v.T,
N: v.N * int32(amount),
})
}
// 发邮件
this.mail.SendMailByCid(session, comm.Venturegifts, reward)
// 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)
// 日常登录任务 // 日常登录任务