上传埋点缓存优化
This commit is contained in:
parent
43504924e5
commit
6beec9638a
@ -1181,4 +1181,5 @@ const (
|
|||||||
const (
|
const (
|
||||||
Session_User = "user"
|
Session_User = "user"
|
||||||
Session_UserExpand = "userexpand"
|
Session_UserExpand = "userexpand"
|
||||||
|
Session_Buried = "buried"
|
||||||
)
|
)
|
||||||
|
@ -550,17 +550,17 @@ type (
|
|||||||
//埋点中心
|
//埋点中心
|
||||||
IBuried interface {
|
IBuried interface {
|
||||||
//完成任务埋点
|
//完成任务埋点
|
||||||
CompleteCondition(uid string, condiId int32) (err error)
|
CompleteCondition(session IUserSession, condiId int32) (err error)
|
||||||
//埋点中心触发
|
//埋点中心触发
|
||||||
TriggerBuried(session IUserSession, burieds ...*pb.BuriedParam)
|
TriggerBuried(session IUserSession, burieds ...*pb.BuriedParam)
|
||||||
//校验条件是否达成 返回未完成列表
|
//校验条件是否达成 返回未完成列表
|
||||||
CheckCondition(uid string, condiIds ...int32) (condis []*pb.ConIProgress, err error)
|
CheckCondition(session IUserSession, condiIds ...int32) (condis []*pb.ConIProgress, err error)
|
||||||
//激活条件
|
//激活条件
|
||||||
ActiveCondition(uid string, condiIds ...int32) (errdata *pb.ErrorData)
|
ActiveCondition(session IUserSession, condiIds ...int32) (errdata *pb.ErrorData)
|
||||||
//完成任务并校验接口
|
//完成任务并校验接口
|
||||||
FinishConditionAndCheck(uid string, finishcondiIds []int32, condiIds ...int32) (condis []*pb.ConIProgress, err error)
|
FinishConditionAndCheck(session IUserSession, finishcondiIds []int32, condiIds ...int32) (condis []*pb.ConIProgress, err error)
|
||||||
//重置埋点 按类型
|
//重置埋点 按类型
|
||||||
ResetBuriedByType(uid string, types ...TaskType) (err error)
|
ResetBuriedByType(session IUserSession, types ...TaskType) (err error)
|
||||||
}
|
}
|
||||||
//红点模块接口
|
//红点模块接口
|
||||||
IReddot interface {
|
IReddot interface {
|
||||||
|
@ -31,7 +31,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.AchieveInfoReq) (er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
tasks = this.module.configure.tasksConf
|
tasks = this.module.configure.tasksConf
|
||||||
if progress, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), tasks...); err != nil {
|
if progress, err = this.module.ModuleBuried.CheckCondition(session, tasks...); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_ExternalModule,
|
Code: pb.ErrorCode_ExternalModule,
|
||||||
Title: pb.ErrorCode_ExternalModule.ToString(),
|
Title: pb.ErrorCode_ExternalModule.ToString(),
|
||||||
|
@ -52,7 +52,7 @@ func (this *apiComp) Award(session comm.IUserSession, req *pb.AchieveAwardReq) (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if progress, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), conf.TaskBuried); err != nil {
|
if progress, err = this.module.ModuleBuried.CheckCondition(session, conf.TaskBuried); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_ExternalModule,
|
Code: pb.ErrorCode_ExternalModule,
|
||||||
Title: pb.ErrorCode_ExternalModule.ToString(),
|
Title: pb.ErrorCode_ExternalModule.ToString(),
|
||||||
|
@ -27,7 +27,7 @@ func (this *apiComp) InquireProgress(session comm.IUserSession, req *pb.BuriedIn
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if condis, err = this.module.CheckCondition(session.GetUserId(), req.Conditions...); err != nil {
|
if condis, err = this.module.CheckCondition(session, req.Conditions...); err != nil {
|
||||||
this.module.Error("查询埋点进度错误!", log.Field{Key: "err", Value: err.Error()})
|
this.module.Error("查询埋点进度错误!", log.Field{Key: "err", Value: err.Error()})
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_ConfigNoFound,
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
@ -36,7 +36,6 @@ func (this *apiComp) InquireProgress(session comm.IUserSession, req *pb.BuriedIn
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
session.SendMsg(string(this.module.GetType()), "inquireprogress", &pb.BuriedInquireProgressResp{Conditions: condis})
|
session.SendMsg(string(this.module.GetType()), "inquireprogress", &pb.BuriedInquireProgressResp{Conditions: condis})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -112,3 +112,17 @@ func (this *buriedModel) updateUserBurieds(uid string, data *pb.DBBuried) (err e
|
|||||||
func (this *buriedModel) userlock(uid string) (result *redis.RedisMutex, err error) {
|
func (this *buriedModel) userlock(uid string) (result *redis.RedisMutex, err error) {
|
||||||
return this.model.Redis.NewRedisMutex(fmt.Sprintf("ulockburied:%s", uid))
|
return this.model.Redis.NewRedisMutex(fmt.Sprintf("ulockburied:%s", uid))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取埋点数据
|
||||||
|
func (this *buriedModel) getSessionBuried(session comm.IUserSession) (bdatas *pb.DBBuried, err error) {
|
||||||
|
if ok, mate := session.GetMate(comm.Session_Buried); ok {
|
||||||
|
bdatas = mate.(*pb.DBBuried)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
if bdatas, err = this.getUserBurieds(session.GetUserId()); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
session.SetMate(comm.Session_Buried, bdatas)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -91,8 +91,9 @@ func (this *Buried) Rpc_ModuleBuriedTrigger(ctx context.Context, req *pb.Rpc_Mod
|
|||||||
}
|
}
|
||||||
|
|
||||||
//完成任务
|
//完成任务
|
||||||
func (this *Buried) CompleteCondition(uid string, condiId int32) (err error) {
|
func (this *Buried) CompleteCondition(session comm.IUserSession, condiId int32) (err error) {
|
||||||
var (
|
var (
|
||||||
|
uid string
|
||||||
model *buriedModel
|
model *buriedModel
|
||||||
bdatas *pb.DBBuried
|
bdatas *pb.DBBuried
|
||||||
bitem *pb.DBBuriedConItem
|
bitem *pb.DBBuriedConItem
|
||||||
@ -100,14 +101,13 @@ func (this *Buried) CompleteCondition(uid string, condiId int32) (err error) {
|
|||||||
ok bool
|
ok bool
|
||||||
bdata *pb.DBBuriedItem
|
bdata *pb.DBBuriedItem
|
||||||
)
|
)
|
||||||
|
uid = session.GetUserId()
|
||||||
if model, err = this.modelBuried.getburiedModel(uid); err != nil {
|
if model, err = this.modelBuried.getburiedModel(uid); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if bdatas, err = model.getUserBurieds(uid); err != nil {
|
if bdatas, err = model.getSessionBuried(session); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Debug("完成埋点!", log.Field{Key: "condiId", Value: condiId})
|
this.Debug("完成埋点!", log.Field{Key: "condiId", Value: condiId})
|
||||||
lock, _ := model.userlock(uid)
|
lock, _ := model.userlock(uid)
|
||||||
err = lock.Lock()
|
err = lock.Lock()
|
||||||
@ -174,8 +174,9 @@ func (this *Buried) CompleteCondition(uid string, condiId int32) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 激活数据采集点
|
// 激活数据采集点
|
||||||
func (this *Buried) ActiveCondition(uid string, condiIds ...int32) (errdata *pb.ErrorData) {
|
func (this *Buried) ActiveCondition(session comm.IUserSession, condiIds ...int32) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
|
uid string
|
||||||
conf *cfg.GameBuriedCondiData
|
conf *cfg.GameBuriedCondiData
|
||||||
bdatas *pb.DBBuried
|
bdatas *pb.DBBuried
|
||||||
model *buriedModel
|
model *buriedModel
|
||||||
@ -184,6 +185,7 @@ func (this *Buried) ActiveCondition(uid string, condiIds ...int32) (errdata *pb.
|
|||||||
chanage bool
|
chanage bool
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
uid = session.GetUserId()
|
||||||
if model, err = this.modelBuried.getburiedModel(uid); err != nil {
|
if model, err = this.modelBuried.getburiedModel(uid); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_DBError,
|
Code: pb.ErrorCode_DBError,
|
||||||
@ -221,7 +223,7 @@ func (this *Buried) ActiveCondition(uid string, condiIds ...int32) (errdata *pb.
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if bdatas == nil { //放在后面 可以减少网络io
|
if bdatas == nil { //放在后面 可以减少网络io
|
||||||
if bdatas, err = model.getUserBurieds(uid); err != nil {
|
if bdatas, err = model.getSessionBuried(session); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_DBError,
|
Code: pb.ErrorCode_DBError,
|
||||||
Title: pb.ErrorCode_DBError.String(),
|
Title: pb.ErrorCode_DBError.String(),
|
||||||
@ -271,14 +273,16 @@ func (this *Buried) ActiveCondition(uid string, condiIds ...int32) (errdata *pb.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 重置所有对应的子任务 按埋点类型
|
// 重置所有对应的子任务 按埋点类型
|
||||||
func (this *Buried) ResetBuriedByType(uid string, types ...comm.TaskType) (err error) {
|
func (this *Buried) ResetBuriedByType(session comm.IUserSession, types ...comm.TaskType) (err error) {
|
||||||
var (
|
var (
|
||||||
|
uid string
|
||||||
bdatas *pb.DBBuried
|
bdatas *pb.DBBuried
|
||||||
model *buriedModel
|
model *buriedModel
|
||||||
bdata *pb.DBBuriedItem
|
bdata *pb.DBBuriedItem
|
||||||
ok bool
|
ok bool
|
||||||
chanage bool
|
chanage bool
|
||||||
)
|
)
|
||||||
|
uid = session.GetUserId()
|
||||||
if model, err = this.modelBuried.getburiedModel(uid); err != nil {
|
if model, err = this.modelBuried.getburiedModel(uid); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -290,7 +294,7 @@ func (this *Buried) ResetBuriedByType(uid string, types ...comm.TaskType) (err e
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer lock.Unlock()
|
defer lock.Unlock()
|
||||||
if bdatas, err = model.getUserBurieds(uid); err != nil {
|
if bdatas, err = model.getSessionBuried(session); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range types {
|
for _, v := range types {
|
||||||
@ -313,18 +317,20 @@ func (this *Buried) ResetBuriedByType(uid string, types ...comm.TaskType) (err e
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 激活数据采集点
|
// 激活数据采集点
|
||||||
func (this *Buried) CheckCondition(uid string, condiIds ...int32) (condis []*pb.ConIProgress, err error) {
|
func (this *Buried) CheckCondition(session comm.IUserSession, condiIds ...int32) (condis []*pb.ConIProgress, err error) {
|
||||||
var (
|
var (
|
||||||
|
uid string
|
||||||
model *buriedModel
|
model *buriedModel
|
||||||
bdatas *pb.DBBuried
|
bdatas *pb.DBBuried
|
||||||
conf *cfg.GameBuriedCondiData
|
conf *cfg.GameBuriedCondiData
|
||||||
bdata *pb.DBBuriedItem
|
bdata *pb.DBBuriedItem
|
||||||
ok bool
|
ok bool
|
||||||
)
|
)
|
||||||
|
uid = session.GetUserId()
|
||||||
if model, err = this.modelBuried.getburiedModel(uid); err != nil {
|
if model, err = this.modelBuried.getburiedModel(uid); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if bdatas, err = model.getUserBurieds(uid); err != nil {
|
if bdatas, err = model.getSessionBuried(session); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
condis = make([]*pb.ConIProgress, 0)
|
condis = make([]*pb.ConIProgress, 0)
|
||||||
@ -378,8 +384,9 @@ func (this *Buried) CheckCondition(uid string, condiIds ...int32) (condis []*pb.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设置任务完成状态并校验
|
// 设置任务完成状态并校验
|
||||||
func (this *Buried) FinishConditionAndCheck(uid string, finishcondiIds []int32, condiIds ...int32) (condis []*pb.ConIProgress, err error) {
|
func (this *Buried) FinishConditionAndCheck(session comm.IUserSession, finishcondiIds []int32, condiIds ...int32) (condis []*pb.ConIProgress, err error) {
|
||||||
var (
|
var (
|
||||||
|
uid string
|
||||||
model *buriedModel
|
model *buriedModel
|
||||||
bdatas *pb.DBBuried
|
bdatas *pb.DBBuried
|
||||||
bitem *pb.DBBuriedConItem
|
bitem *pb.DBBuriedConItem
|
||||||
@ -388,11 +395,11 @@ func (this *Buried) FinishConditionAndCheck(uid string, finishcondiIds []int32,
|
|||||||
chanage bool
|
chanage bool
|
||||||
bdata *pb.DBBuriedItem
|
bdata *pb.DBBuriedItem
|
||||||
)
|
)
|
||||||
|
uid = session.GetUserId()
|
||||||
if model, err = this.modelBuried.getburiedModel(uid); err != nil {
|
if model, err = this.modelBuried.getburiedModel(uid); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if bdatas, err = model.getUserBurieds(uid); err != nil {
|
if bdatas, err = model.getSessionBuried(session); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,6 +574,7 @@ func (this *Buried) TriggerBuried(session comm.IUserSession, burieds ...*pb.Buri
|
|||||||
|
|
||||||
func (this *Buried) trigger(session comm.IUserSession, burieds ...*pb.BuriedParam) {
|
func (this *Buried) trigger(session comm.IUserSession, burieds ...*pb.BuriedParam) {
|
||||||
var (
|
var (
|
||||||
|
model *buriedModel
|
||||||
pass map[*pb.BuriedParam][]*cfg.GameBuriedCondiData = make(map[*pb.BuriedParam][]*cfg.GameBuriedCondiData)
|
pass map[*pb.BuriedParam][]*cfg.GameBuriedCondiData = make(map[*pb.BuriedParam][]*cfg.GameBuriedCondiData)
|
||||||
bconf *cfg.GameBuriedTypeData
|
bconf *cfg.GameBuriedTypeData
|
||||||
bdatas *pb.DBBuried
|
bdatas *pb.DBBuried
|
||||||
@ -580,9 +588,12 @@ func (this *Buried) trigger(session comm.IUserSession, burieds ...*pb.BuriedPara
|
|||||||
nmodule comm.IBuriedUpdateNotify
|
nmodule comm.IBuriedUpdateNotify
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
if model, err = this.modelBuried.getburiedModel(session.GetUserId()); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.Debug("触发埋点!", log.Field{Key: "burieds", Value: burieds})
|
this.Debug("触发埋点!", log.Field{Key: "burieds", Value: burieds})
|
||||||
lock, _ := this.modelBuried.userlock(session.GetUserId())
|
lock, _ := model.userlock(session.GetUserId())
|
||||||
err = lock.Lock()
|
err = lock.Lock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.Error("埋点分布式锁失效 err!", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "err", Value: err.Error()})
|
this.Error("埋点分布式锁失效 err!", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "err", Value: err.Error()})
|
||||||
@ -607,8 +618,13 @@ func (this *Buried) trigger(session comm.IUserSession, burieds ...*pb.BuriedPara
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(pass) > 0 {
|
if len(pass) > 0 {
|
||||||
if bdatas, err = this.modelBuried.getUserBurieds(session.GetUserId()); err != nil {
|
if ok, mate := session.GetMate(comm.Session_Buried); ok {
|
||||||
|
bdatas = mate.(*pb.DBBuried)
|
||||||
return
|
return
|
||||||
|
} else {
|
||||||
|
if bdatas, err = model.getSessionBuried(session); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notify = make(map[string][]*pb.ConIProgress)
|
notify = make(map[string][]*pb.ConIProgress)
|
||||||
@ -666,7 +682,7 @@ func (this *Buried) trigger(session comm.IUserSession, burieds ...*pb.BuriedPara
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(changes) > 0 { //同步数据
|
if len(changes) > 0 { //同步数据
|
||||||
if err = this.modelBuried.updateUserBurieds(session.GetUserId(), bdatas); err != nil {
|
if err = model.updateUserBurieds(session.GetUserId(), bdatas); err != nil {
|
||||||
this.Error("更新用户埋点数据错误!", log.Field{Key: "err", Value: err.Error()})
|
this.Error("更新用户埋点数据错误!", log.Field{Key: "err", Value: err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -843,3 +859,16 @@ func (this *Buried) checkburied(buried *pb.BuriedParam, bconf *cfg.GameBuriedTyp
|
|||||||
efficient = true
|
efficient = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取埋点数据
|
||||||
|
func (this *Buried) getburied(session comm.IUserSession) (bdatas *pb.DBBuried, err error) {
|
||||||
|
if ok, mate := session.GetMate(comm.Session_Buried); ok {
|
||||||
|
bdatas = mate.(*pb.DBBuried)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
if bdatas, err = this.modelBuried.getUserBurieds(session.GetUserId()); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -66,7 +66,7 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.CombatAskReq) (errda
|
|||||||
|
|
||||||
if level.Pass != 2 {
|
if level.Pass != 2 {
|
||||||
level.Progress = 0
|
level.Progress = 0
|
||||||
if condis, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), lvconf.Maintask...); err != nil {
|
if condis, err = this.module.ModuleBuried.CheckCondition(session, lvconf.Maintask...); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_ExternalModule,
|
Code: pb.ErrorCode_ExternalModule,
|
||||||
Title: pb.ErrorCode_ExternalModule.ToString(),
|
Title: pb.ErrorCode_ExternalModule.ToString(),
|
||||||
@ -102,7 +102,7 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.CombatAskReq) (errda
|
|||||||
pitem.Mainaward = atns
|
pitem.Mainaward = atns
|
||||||
}
|
}
|
||||||
|
|
||||||
if condis, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), lvconf.Subtask...); err != nil {
|
if condis, err = this.module.ModuleBuried.CheckCondition(session, lvconf.Subtask...); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_ExternalModule,
|
Code: pb.ErrorCode_ExternalModule,
|
||||||
Title: pb.ErrorCode_ExternalModule.ToString(),
|
Title: pb.ErrorCode_ExternalModule.ToString(),
|
||||||
|
@ -695,7 +695,7 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (errdata *pb.Er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
module1.(comm.IBuried).CompleteCondition(session.GetUserId(), int32(condiId))
|
module1.(comm.IBuried).CompleteCondition(session, int32(condiId))
|
||||||
|
|
||||||
this.Debug("使用bingo命令:uid = %s ",
|
this.Debug("使用bingo命令:uid = %s ",
|
||||||
log.Field{Key: "uid", Value: session.GetUserId()},
|
log.Field{Key: "uid", Value: session.GetUserId()},
|
||||||
|
@ -33,7 +33,7 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.GrowtaskListReq) (e
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
g, curTaskId := this.module.modelGrowtask.list(uid, req.TaskType, gt)
|
g, curTaskId := this.module.modelGrowtask.list(session, req.TaskType, gt)
|
||||||
rsp := &pb.GrowtaskListResp{
|
rsp := &pb.GrowtaskListResp{
|
||||||
TaskList: g,
|
TaskList: g,
|
||||||
CurTaskType: gt.CurTaskType,
|
CurTaskType: gt.CurTaskType,
|
||||||
|
@ -85,13 +85,14 @@ func (this *ModelGrowtask) getUserGrowtask(uid string) (*pb.DBGrowtask, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 任务列表
|
// 任务列表
|
||||||
func (this *ModelGrowtask) list(uid string, taskType int32, gt *pb.DBGrowtask) ([]*pb.Growtask, int32) {
|
func (this *ModelGrowtask) list(session comm.IUserSession, taskType int32, gt *pb.DBGrowtask) ([]*pb.Growtask, int32) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
uid string
|
||||||
curList []*pb.Growtask
|
curList []*pb.Growtask
|
||||||
curTaskId int32
|
curTaskId int32
|
||||||
)
|
)
|
||||||
|
uid = session.GetUserId()
|
||||||
getList := func(list []*pb.Growtask) []*pb.Growtask {
|
getList := func(list []*pb.Growtask) []*pb.Growtask {
|
||||||
taskStatusMap := make(map[int32]pb.GrowtaskStatus) //任务状态
|
taskStatusMap := make(map[int32]pb.GrowtaskStatus) //任务状态
|
||||||
for _, v := range list {
|
for _, v := range list {
|
||||||
@ -114,7 +115,7 @@ func (this *ModelGrowtask) list(uid string, taskType int32, gt *pb.DBGrowtask) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
//任务完成
|
//任务完成
|
||||||
if _, err := this.moduleGrowtask.ModuleBuried.CheckCondition(uid, v.Fstask); err == nil {
|
if _, err := this.moduleGrowtask.ModuleBuried.CheckCondition(session, v.Fstask); err == nil {
|
||||||
if v.PreTask == 0 {
|
if v.PreTask == 0 {
|
||||||
v.Status = pb.GrowtaskStatus_Wait //待领奖状态
|
v.Status = pb.GrowtaskStatus_Wait //待领奖状态
|
||||||
} else {
|
} else {
|
||||||
|
@ -27,7 +27,7 @@ func (this *apiComp) GetReward(session comm.IUserSession, req *pb.IntegralGetRew
|
|||||||
atno []*pb.UserAtno
|
atno []*pb.UserAtno
|
||||||
)
|
)
|
||||||
update := make(map[string]interface{})
|
update := make(map[string]interface{})
|
||||||
list, err = this.module.modelIntegral.getIntegralList(session.GetUserId())
|
list, err = this.module.modelIntegral.getIntegralList(session)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_DBError,
|
Code: pb.ErrorCode_DBError,
|
||||||
|
@ -45,7 +45,8 @@ func (this *modelIntegral) queryPlayers(uIds []string) (result []*pb.DBIntegralB
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取列表信息
|
// 获取列表信息
|
||||||
func (this *modelIntegral) getIntegralList(uid string) (result *pb.DBIntegralBoss, err error) {
|
func (this *modelIntegral) getIntegralList(session comm.IUserSession) (result *pb.DBIntegralBoss, err error) {
|
||||||
|
uid := session.GetUserId()
|
||||||
result = &pb.DBIntegralBoss{}
|
result = &pb.DBIntegralBoss{}
|
||||||
if err = this.Get(uid, result); mgo.MongodbNil == err {
|
if err = this.Get(uid, result); mgo.MongodbNil == err {
|
||||||
result.Id = primitive.NewObjectID().Hex()
|
result.Id = primitive.NewObjectID().Hex()
|
||||||
@ -78,7 +79,7 @@ func (this *modelIntegral) getIntegralList(uid string) (result *pb.DBIntegralBos
|
|||||||
for _, v := range this.module.configure.GetIntegralCondition() {
|
for _, v := range this.module.configure.GetIntegralCondition() {
|
||||||
szTaskid = append(szTaskid, v.TaskId) // 获取任务id
|
szTaskid = append(szTaskid, v.TaskId) // 获取任务id
|
||||||
}
|
}
|
||||||
if data, err := this.module.ModuleBuried.CheckCondition(uid, szTaskid...); err == nil {
|
if data, err := this.module.ModuleBuried.CheckCondition(session, szTaskid...); err == nil {
|
||||||
for _, v := range data {
|
for _, v := range data {
|
||||||
|
|
||||||
if v.State == pb.BuriedItemFinishState_buried_finish {
|
if v.State == pb.BuriedItemFinishState_buried_finish {
|
||||||
|
@ -62,7 +62,7 @@ func (this *Integral) OnInstallComp() {
|
|||||||
func (this *Integral) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIProgress) {
|
func (this *Integral) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIProgress) {
|
||||||
var bChange bool
|
var bChange bool
|
||||||
this.Debug("积分boss条件达成通知", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "conds", Value: conds})
|
this.Debug("积分boss条件达成通知", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "conds", Value: conds})
|
||||||
dt, err := this.modelIntegral.getIntegralList(session.GetUserId())
|
dt, err := this.modelIntegral.getIntegralList(session)
|
||||||
|
|
||||||
if dt.Itype != 2 { // 只有事件模式才有debuff
|
if dt.Itype != 2 { // 只有事件模式才有debuff
|
||||||
return
|
return
|
||||||
|
@ -52,7 +52,7 @@ func (this *apiComp) TaskReceive(session comm.IUserSession, req *pb.MainlineTask
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if progress, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), conf.Taskid); err != nil {
|
if progress, err = this.module.ModuleBuried.CheckCondition(session, conf.Taskid); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ func (this *apiComp) TaskAward(session comm.IUserSession, req *pb.MoonlvTaskAwar
|
|||||||
if errdata = this.TaskAwardCheck(session, req); errdata != nil {
|
if errdata = this.TaskAwardCheck(session, req); errdata != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
list, err = this.module.modelMoonlv.getMoonlvList(session.GetUserId())
|
list, err = this.module.modelMoonlv.getMoonlvList(session)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_DBError,
|
Code: pb.ErrorCode_DBError,
|
||||||
|
@ -27,7 +27,8 @@ func (this *modelMoonlv) Init(service core.IService, module core.IModule, comp c
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *modelMoonlv) getMoonlvList(uid string) (result *pb.DBMoonLv, err error) {
|
func (this *modelMoonlv) getMoonlvList(session comm.IUserSession) (result *pb.DBMoonLv, err error) {
|
||||||
|
uid := session.GetUserId()
|
||||||
result = &pb.DBMoonLv{}
|
result = &pb.DBMoonLv{}
|
||||||
if err = this.Get(uid, result); err != nil {
|
if err = this.Get(uid, result); err != nil {
|
||||||
if mongo.ErrNoDocuments == err {
|
if mongo.ErrNoDocuments == err {
|
||||||
@ -43,7 +44,7 @@ func (this *modelMoonlv) getMoonlvList(uid string) (result *pb.DBMoonLv, err err
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if data, err := this.module.ModuleBuried.CheckCondition(uid, szTaskid...); err == nil {
|
if data, err := this.module.ModuleBuried.CheckCondition(session, szTaskid...); err == nil {
|
||||||
for _, v := range data {
|
for _, v := range data {
|
||||||
tmp := &pb.MoonTask{
|
tmp := &pb.MoonTask{
|
||||||
TaskId: v.Conid,
|
TaskId: v.Conid,
|
||||||
|
@ -42,7 +42,7 @@ func (this *Moonlv) OnInstallComp() {
|
|||||||
func (this *Moonlv) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIProgress) {
|
func (this *Moonlv) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIProgress) {
|
||||||
var groupID int32
|
var groupID int32
|
||||||
this.Debug("护月任务通知", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "conds", Value: conds})
|
this.Debug("护月任务通知", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "conds", Value: conds})
|
||||||
dt, err := this.modelMoonlv.getMoonlvList(session.GetUserId())
|
dt, err := this.modelMoonlv.getMoonlvList(session)
|
||||||
if c, e := this.configure.GetMoonLvConf(dt.Lv); e == nil {
|
if c, e := this.configure.GetMoonLvConf(dt.Lv); e == nil {
|
||||||
groupID = c.TaskGroupId
|
groupID = c.TaskGroupId
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ func (this *PushGiftbag) BuriedsNotify(session comm.IUserSession, condis []*pb.C
|
|||||||
|
|
||||||
for _, v := range comdisScils {
|
for _, v := range comdisScils {
|
||||||
if _, ok = condisMap[v]; !ok { //条件不全需要查询全部条件
|
if _, ok = condisMap[v]; !ok { //条件不全需要查询全部条件
|
||||||
if condis, err = this.ModuleBuried.CheckCondition(session.GetUserId(), comdisScils...); err != nil {
|
if condis, err = this.ModuleBuried.CheckCondition(session, comdisScils...); err != nil {
|
||||||
this.Error("校验玩家子任务进度数据 失败", log.Field{Key: "err", Value: err.Error()})
|
this.Error("校验玩家子任务进度数据 失败", log.Field{Key: "err", Value: err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,9 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := this.module.modelSociaty.agree(req.Uid, sociaty); err != nil {
|
tempsession, _ := this.module.GetUserSession(req.Uid)
|
||||||
|
|
||||||
|
if err := this.module.modelSociaty.agree(tempsession, sociaty); err != nil {
|
||||||
var customError = new(comm.CustomError)
|
var customError = new(comm.CustomError)
|
||||||
if errors.As(err, &customError) {
|
if errors.As(err, &customError) {
|
||||||
code := customError.Code
|
code := customError.Code
|
||||||
|
@ -115,7 +115,7 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 申请
|
// 申请
|
||||||
isCheck, err := this.module.modelSociaty.apply(uid, sociaty)
|
isCheck, err := this.module.modelSociaty.apply(session, sociaty)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var customError = new(comm.CustomError)
|
var customError = new(comm.CustomError)
|
||||||
if errors.As(err, &customError) {
|
if errors.As(err, &customError) {
|
||||||
|
@ -212,7 +212,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
|
|||||||
}
|
}
|
||||||
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype188, 1))
|
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype188, 1))
|
||||||
// 初始化玩家公会任务
|
// 初始化玩家公会任务
|
||||||
if err := this.module.modelSociatyTask.initSociatyTask(user.Uid, sociaty.Id); err != nil {
|
if err := this.module.modelSociatyTask.initSociatyTask(session, sociaty.Id); err != nil {
|
||||||
this.module.Error("初始化玩家公会任务",
|
this.module.Error("初始化玩家公会任务",
|
||||||
log.Field{Key: "uid", Value: uid},
|
log.Field{Key: "uid", Value: uid},
|
||||||
log.Field{Key: "err", Value: err.Error()},
|
log.Field{Key: "err", Value: err.Error()},
|
||||||
|
@ -64,7 +64,7 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (er
|
|||||||
// 删除任务
|
// 删除任务
|
||||||
if err := this.module.modelSociatyTask.deleTask(sociaty.Id, uid); err == nil {
|
if err := this.module.modelSociatyTask.deleTask(sociaty.Id, uid); err == nil {
|
||||||
// 初始新的公会任务
|
// 初始新的公会任务
|
||||||
if err = this.module.modelSociatyTask.initSociatyTask(uid, sociaty.Id); err != nil {
|
if err = this.module.modelSociatyTask.initSociatyTask(session, sociaty.Id); err != nil {
|
||||||
this.module.Error("初始化玩家公会任务",
|
this.module.Error("初始化玩家公会任务",
|
||||||
log.Field{Key: "uid", Value: uid},
|
log.Field{Key: "uid", Value: uid},
|
||||||
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
||||||
|
@ -43,7 +43,7 @@ func (this *apiComp) TaskList(session comm.IUserSession, req *pb.SociatyTaskList
|
|||||||
tasklist = append(tasklist, v.TaskId)
|
tasklist = append(tasklist, v.TaskId)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
condis, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), tasklist...)
|
condis, err = this.module.ModuleBuried.CheckCondition(session, tasklist...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_ExternalModule,
|
Code: pb.ErrorCode_ExternalModule,
|
||||||
|
@ -259,8 +259,9 @@ func (this *ModelSociaty) getUserSociaty(uid string) (sociaty *pb.DBSociaty) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 申请公会
|
// 申请公会
|
||||||
func (this *ModelSociaty) apply(uid string, sociaty *pb.DBSociaty) (isCheck bool, err error) {
|
func (this *ModelSociaty) apply(season comm.IUserSession, sociaty *pb.DBSociaty) (isCheck bool, err error) {
|
||||||
// 判断公会审批设置
|
// 判断公会审批设置
|
||||||
|
uid := season.GetUserId()
|
||||||
if sociaty.IsApplyCheck { //需要审核
|
if sociaty.IsApplyCheck { //需要审核
|
||||||
isCheck = true
|
isCheck = true
|
||||||
sociaty.ApplyRecord = append(sociaty.ApplyRecord, &pb.ApplyRecord{
|
sociaty.ApplyRecord = append(sociaty.ApplyRecord, &pb.ApplyRecord{
|
||||||
@ -276,7 +277,7 @@ func (this *ModelSociaty) apply(uid string, sociaty *pb.DBSociaty) (isCheck bool
|
|||||||
return isCheck, err
|
return isCheck, err
|
||||||
}
|
}
|
||||||
//初始玩家公会任务
|
//初始玩家公会任务
|
||||||
this.module.modelSociatyTask.initSociatyTask(uid, sociaty.Id)
|
this.module.modelSociatyTask.initSociatyTask(season, sociaty.Id)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -505,7 +506,8 @@ func (this *ModelSociaty) getMemberInfo(sociaty *pb.DBSociaty, uid string) *pb.S
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 同意
|
// 同意
|
||||||
func (this *ModelSociaty) agree(uid string, sociaty *pb.DBSociaty) error {
|
func (this *ModelSociaty) agree(session comm.IUserSession, sociaty *pb.DBSociaty) error {
|
||||||
|
uid := session.GetUserId()
|
||||||
if this.isMember(uid, sociaty) {
|
if this.isMember(uid, sociaty) {
|
||||||
return comm.NewCustomError(pb.ErrorCode_SociatyBelongTo)
|
return comm.NewCustomError(pb.ErrorCode_SociatyBelongTo)
|
||||||
}
|
}
|
||||||
@ -533,7 +535,7 @@ func (this *ModelSociaty) agree(uid string, sociaty *pb.DBSociaty) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//初始玩家公会任务
|
//初始玩家公会任务
|
||||||
return this.module.modelSociatyTask.initSociatyTask(uid, sociaty.Id)
|
return this.module.modelSociatyTask.initSociatyTask(session, sociaty.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拒绝
|
// 拒绝
|
||||||
|
@ -28,7 +28,8 @@ func (this *ModelSociatyTask) Init(service core.IService, module core.IModule, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 初始化公会任务 加入成员时初始化
|
// 初始化公会任务 加入成员时初始化
|
||||||
func (this *ModelSociatyTask) initSociatyTask(uid, sociatyId string) error {
|
func (this *ModelSociatyTask) initSociatyTask(session comm.IUserSession, sociatyId string) error {
|
||||||
|
uid := session.GetUserId()
|
||||||
sociatyTask := &pb.DBSociatyTask{
|
sociatyTask := &pb.DBSociatyTask{
|
||||||
SociatyId: sociatyId,
|
SociatyId: sociatyId,
|
||||||
Uid: uid,
|
Uid: uid,
|
||||||
@ -60,7 +61,7 @@ func (this *ModelSociatyTask) initSociatyTask(uid, sociatyId string) error {
|
|||||||
sociatyTask.TaskList = taskList
|
sociatyTask.TaskList = taskList
|
||||||
sociatyTask.LastUpdateTime = configure.Now().Unix()
|
sociatyTask.LastUpdateTime = configure.Now().Unix()
|
||||||
// 激活所有任务
|
// 激活所有任务
|
||||||
this.moduleSociaty.ModuleBuried.ActiveCondition(uid, condIds...)
|
this.moduleSociaty.ModuleBuried.ActiveCondition(session, condIds...)
|
||||||
return this.moduleSociaty.modelSociatyTask.AddList(sociatyId, uid, sociatyTask)
|
return this.moduleSociaty.modelSociatyTask.AddList(sociatyId, uid, sociatyTask)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.WarorderInfoReq) (e
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(activation) > 0 {
|
if len(activation) > 0 {
|
||||||
if errdata = this.module.ModuleBuried.ActiveCondition(session.GetUserId(), activation...); errdata != nil {
|
if errdata = this.module.ModuleBuried.ActiveCondition(session, activation...); errdata != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.WarorderInfoReq) (e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if progress, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), condiIds...); err != nil {
|
if progress, err = this.module.ModuleBuried.CheckCondition(session, condiIds...); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_ExternalModule,
|
Code: pb.ErrorCode_ExternalModule,
|
||||||
Title: pb.ErrorCode_ExternalModule.ToString(),
|
Title: pb.ErrorCode_ExternalModule.ToString(),
|
||||||
|
Loading…
Reference in New Issue
Block a user