上传日常开关限制
This commit is contained in:
parent
e7be493477
commit
221ed62dac
@ -20,7 +20,7 @@ type (
|
||||
}
|
||||
//功能开启通知
|
||||
IOpenCmdNotice interface {
|
||||
OpenCmdNotice(uid string, keys ...string)
|
||||
OpenCmdNotice(session IUserSession, keys ...string)
|
||||
}
|
||||
// 活动通知
|
||||
IActivityNotice interface {
|
||||
@ -583,6 +583,7 @@ type (
|
||||
}
|
||||
//每日任务
|
||||
IDailytask interface {
|
||||
IOpenCmdNotice
|
||||
IGetReddot
|
||||
//任务组完成
|
||||
TaskGroupComplete(session IUserSession, group int32)
|
||||
|
@ -46,7 +46,7 @@ func (this *Dailytask) Start() (err error) {
|
||||
return
|
||||
}
|
||||
this.wtask = module.(comm.IWtask)
|
||||
event.RegisterGO(comm.EventUserLogin, this.EventUserLogin)
|
||||
event.Register(comm.EventUserLogin, this.EventUserLogin)
|
||||
return
|
||||
}
|
||||
|
||||
@ -61,56 +61,19 @@ func (this *Dailytask) OnInstallComp() {
|
||||
// 用户登录
|
||||
func (this *Dailytask) EventUserLogin(session comm.IUserSession) {
|
||||
var (
|
||||
dtask *pb.DBDailytask
|
||||
user *pb.DBUser
|
||||
errdata *pb.ErrorData
|
||||
key int32
|
||||
group []int32
|
||||
tasks map[int32][]int32
|
||||
err error
|
||||
isopen bool
|
||||
)
|
||||
|
||||
if db.IsCross() { //跨服不支持
|
||||
return
|
||||
}
|
||||
|
||||
if dtask, err = this.modelDailytask.getUserDTasks(session.GetUserId()); err != nil {
|
||||
this.Errorln(err)
|
||||
return
|
||||
}
|
||||
|
||||
if !utils.IsToday(dtask.Rtime) { //不是同一天 重置
|
||||
if user, err = this.ModuleUser.GetUser(session.GetUserId()); err != nil {
|
||||
this.Error("no found user", log.Field{Key: "uid", Value: session.GetUserId()})
|
||||
return
|
||||
}
|
||||
if key, group, err = this.modelDailytask.resetUserDTasks(user.Lv); err != nil {
|
||||
this.Errorln(err)
|
||||
return
|
||||
}
|
||||
if tasks, errdata = this.wtask.ResetDailytaskTask(session.Clone(), key, group...); errdata != nil {
|
||||
if isopen, errdata = this.ModuleSys.CheckOpenCondCfgById(session.GetUserId(), "annulartask"); isopen {
|
||||
this.Errorln(errdata)
|
||||
return
|
||||
}
|
||||
dtask.Key = key
|
||||
dtask.Groups = make([]*pb.DBDailytaskGroup, 0)
|
||||
for k, v := range tasks {
|
||||
dtask.Groups = append(dtask.Groups, &pb.DBDailytaskGroup{
|
||||
Group: k,
|
||||
Tasks: v,
|
||||
})
|
||||
}
|
||||
dtask.Rtime = configure.Now().Unix()
|
||||
if err = this.modelDailytask.Change(session.GetUserId(), map[string]interface{}{
|
||||
"key": dtask.Key,
|
||||
"groups": dtask.Groups,
|
||||
"rtime": dtask.Rtime,
|
||||
}); err != nil {
|
||||
this.Errorln(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this.refreshtask(session)
|
||||
}
|
||||
|
||||
// 任务组完成
|
||||
@ -137,6 +100,15 @@ func (this *Dailytask) TaskGroupComplete(session comm.IUserSession, group int32)
|
||||
}
|
||||
}
|
||||
|
||||
// 功能是否开启
|
||||
func (this *Dailytask) OpenCmdNotice(session comm.IUserSession, keys ...string) {
|
||||
for _, v := range keys {
|
||||
if v == "annulartask" { //日常功能开启
|
||||
this.refreshtask(session)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 查询每日红点信息
|
||||
func (this *Dailytask) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) {
|
||||
var (
|
||||
@ -168,3 +140,51 @@ func (this *Dailytask) Reddot(session comm.IUserSession, rid ...comm.ReddotType)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Dailytask) refreshtask(session comm.IUserSession) {
|
||||
var (
|
||||
dtask *pb.DBDailytask
|
||||
user *pb.DBUser
|
||||
errdata *pb.ErrorData
|
||||
key int32
|
||||
group []int32
|
||||
tasks map[int32][]int32
|
||||
err error
|
||||
)
|
||||
if dtask, err = this.modelDailytask.getUserDTasks(session.GetUserId()); err != nil {
|
||||
this.Errorln(err)
|
||||
return
|
||||
}
|
||||
|
||||
if !utils.IsToday(dtask.Rtime) { //不是同一天 重置
|
||||
if user, err = this.ModuleUser.GetUser(session.GetUserId()); err != nil {
|
||||
this.Error("no found user", log.Field{Key: "uid", Value: session.GetUserId()})
|
||||
return
|
||||
}
|
||||
if key, group, err = this.modelDailytask.resetUserDTasks(user.Lv); err != nil {
|
||||
this.Errorln(err)
|
||||
return
|
||||
}
|
||||
if tasks, errdata = this.wtask.ResetDailytaskTask(session, key, group...); errdata != nil {
|
||||
this.Errorln(errdata)
|
||||
return
|
||||
}
|
||||
dtask.Key = key
|
||||
dtask.Groups = make([]*pb.DBDailytaskGroup, 0)
|
||||
for k, v := range tasks {
|
||||
dtask.Groups = append(dtask.Groups, &pb.DBDailytaskGroup{
|
||||
Group: k,
|
||||
Tasks: v,
|
||||
})
|
||||
}
|
||||
dtask.Rtime = configure.Now().Unix()
|
||||
if err = this.modelDailytask.Change(session.GetUserId(), map[string]interface{}{
|
||||
"key": dtask.Key,
|
||||
"groups": dtask.Groups,
|
||||
"rtime": dtask.Rtime,
|
||||
}); err != nil {
|
||||
this.Errorln(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -210,9 +210,9 @@ func (this *Practice) TaskComplete(session comm.IUserSession, taskid ...int32) {
|
||||
)
|
||||
}
|
||||
|
||||
func (this *Practice) OpenCmdNotice(uid string, keys ...string) {
|
||||
func (this *Practice) OpenCmdNotice(session comm.IUserSession, keys ...string) {
|
||||
this.Debug("OpenCmdNotice",
|
||||
log.Field{Key: "session", Value: uid},
|
||||
log.Field{Key: "session", Value: session.GetUserId()},
|
||||
log.Field{Key: "key", Value: keys},
|
||||
)
|
||||
if !this.IsCross() {
|
||||
@ -220,7 +220,7 @@ func (this *Practice) OpenCmdNotice(uid string, keys ...string) {
|
||||
if v == "practice_ pillar1" || v == "practice_ pillar2" || v == "practice_ pillar3" {
|
||||
err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
|
||||
comm.Service_Worker, string(comm.RPC_ModulePracticeUnLockPillar),
|
||||
&pb.RPCGeneralReqA2{Param1: uid, Param2: v}, &pb.EmptyResp{})
|
||||
&pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: v}, &pb.EmptyResp{})
|
||||
if err != nil {
|
||||
this.Errorln(err)
|
||||
return
|
||||
@ -231,7 +231,7 @@ func (this *Practice) OpenCmdNotice(uid string, keys ...string) {
|
||||
} else {
|
||||
for _, v := range keys {
|
||||
if v == "practice_ pillar1" || v == "practice_ pillar2" || v == "practice_ pillar3" {
|
||||
this.RPC_ModulePracticeUnLockPillar(context.Background(), &pb.RPCGeneralReqA2{Param1: uid, Param2: v}, &pb.EmptyResp{})
|
||||
this.RPC_ModulePracticeUnLockPillar(context.Background(), &pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: v}, &pb.EmptyResp{})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,8 @@ func (this *apiComp) FuncActivate(session comm.IUserSession, req *pb.SysFuncActi
|
||||
return
|
||||
}
|
||||
|
||||
go this.module.wtask.OpenCmdNotice(session.GetUserId(), req.Cid)
|
||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||
this.module.wtask.OpenCmdNotice(session, req.Cid)
|
||||
//手动激活通知模块
|
||||
for _, m := range opencfg.Notify {
|
||||
i, err := this.service.GetModule(core.M_Modules(m))
|
||||
@ -75,8 +76,10 @@ func (this *apiComp) FuncActivate(session comm.IUserSession, req *pb.SysFuncActi
|
||||
}
|
||||
|
||||
if ic, ok := i.(comm.IOpenCmdNotice); ok {
|
||||
go ic.OpenCmdNotice(session.GetUserId(), req.Cid)
|
||||
ic.OpenCmdNotice(session, req.Cid)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -76,9 +76,13 @@ func (this *apiComp) FuncGetList(session comm.IUserSession, req *pb.SysFuncGetLi
|
||||
"cond": list.Cond,
|
||||
})
|
||||
}
|
||||
if len(change) > 0 {
|
||||
go this.module.wtask.OpenCmdNotice(session.GetUserId(), change...)
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "funcgetlist", rsp)
|
||||
|
||||
if len(change) > 0 {
|
||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||
this.module.wtask.OpenCmdNotice(session, change...)
|
||||
})
|
||||
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ func (this *Turntable) Start() (err error) {
|
||||
if module, err = this.service.GetModule(comm.ModuleWarorder); err != nil {
|
||||
return
|
||||
}
|
||||
event.RegisterGO(comm.EventUserLogin, this.EventUserLogin)
|
||||
event.Register(comm.EventUserLogin, this.EventUserLogin)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ func (this *WTask) BuriedsNotify(session comm.IUserSession, condis []*pb.ConIPro
|
||||
}
|
||||
|
||||
// 功能开启
|
||||
func (this *WTask) OpenCmdNotice(uid string, keys ...string) {
|
||||
func (this *WTask) OpenCmdNotice(session comm.IUserSession, keys ...string) {
|
||||
var (
|
||||
opencmdTask map[string][]*cfg.GameWorldTaskData
|
||||
user *pb.DBUser
|
||||
@ -169,21 +169,16 @@ func (this *WTask) OpenCmdNotice(uid string, keys ...string) {
|
||||
break
|
||||
}
|
||||
}
|
||||
if user, err = this.ModuleUser.GetUser(uid); err != nil {
|
||||
this.Error("获取用户信息失败!", log.Field{Key: "uid", Value: uid})
|
||||
if user, err = this.ModuleUser.GetUser(session.GetUserId()); err != nil {
|
||||
this.Error("获取用户信息失败!", log.Field{Key: "uid", Value: session.GetUserId()})
|
||||
return
|
||||
}
|
||||
|
||||
if wtask, err = this.modelwtask.getUserWTasks(uid); err != nil {
|
||||
this.Error("获取世界任务数据 失败!", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()})
|
||||
if wtask, err = this.modelwtask.getUserWTasks(session.GetUserId()); err != nil {
|
||||
this.Error("获取世界任务数据 失败!", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "err", Value: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
session, _ := this.GetUserSession(uid)
|
||||
defer func() {
|
||||
session.Push()
|
||||
this.PutUserSession(session)
|
||||
}()
|
||||
this.inquireActivations(session, wtask, user.Lv, keys, true)
|
||||
}
|
||||
|
||||
@ -277,11 +272,6 @@ func (this *WTask) ResetDailytaskTask(session comm.IUserSession, dailytaskid int
|
||||
boxchange bool
|
||||
)
|
||||
|
||||
defer func() {
|
||||
session.Push()
|
||||
this.PutUserSession(session)
|
||||
}()
|
||||
|
||||
results = make(map[int32][]int32)
|
||||
for _, v := range this.configure.getdesTask(1) {
|
||||
alltasks[v.Key] = v
|
||||
|
Loading…
Reference in New Issue
Block a user