上传用户属性埋点优化

This commit is contained in:
liwei 2023-08-10 15:22:49 +08:00
parent 1791302429
commit 08b16d62e7
3 changed files with 36 additions and 31 deletions

View File

@ -741,11 +741,9 @@ const (
Rtype101 TaskType = 101 //获得X星职业武器N件历史(从创号开始记录每获得1件X星职业武器则进度+1) Rtype101 TaskType = 101 //获得X星职业武器N件历史(从创号开始记录每获得1件X星职业武器则进度+1)
Rtype102 TaskType = 102 //阵营饰品强化成功N次历史(从创号开始记录,强化成功进度+1) Rtype102 TaskType = 102 //阵营饰品强化成功N次历史(从创号开始记录,强化成功进度+1)
Rtype103 TaskType = 103 //获得X星阵营饰品N件历史(从创号开始记录每获得1件X星阵营饰品则进度+1) Rtype103 TaskType = 103 //获得X星阵营饰品N件历史(从创号开始记录每获得1件X星阵营饰品则进度+1)
//消费N个钻石历史(从创号开始记录,每次消耗钻石增加消耗额的进度) Rtype104 TaskType = 104 //消费N个钻石历史(从创号开始记录,每次消耗钻石增加消耗额的进度)
Rtype104 TaskType = 104
Rtype105 TaskType = 105 //商店刷新N次(从接到任务开始,每次刷新商店进度+1) Rtype105 TaskType = 105 //商店刷新N次(从接到任务开始,每次刷新商店进度+1)
Rtype106 TaskType = 106 //跨服聊天发言N次(从接到任务开始,每次跨服发言成功进度+1) Rtype106 TaskType = 106 //跨服聊天发言N次(从接到任务开始,每次跨服发言成功进度+1)
Rtype108 TaskType = 108 //助战英雄被使用X次(从接到任务开始每被使用1次则进度+1) Rtype108 TaskType = 108 //助战英雄被使用X次(从接到任务开始每被使用1次则进度+1)
Rtype109 TaskType = 109 //加入公会(打开任务时,检查是否加入了公会,加入则完成) Rtype109 TaskType = 109 //加入公会(打开任务时,检查是否加入了公会,加入则完成)
Rtype110 TaskType = 110 //激活X个英雄图鉴(打开任务时,检查英雄图鉴激活数量并计入进度,达到了任务所需个数则完成任务。) Rtype110 TaskType = 110 //激活X个英雄图鉴(打开任务时,检查英雄图鉴激活数量并计入进度,达到了任务所需个数则完成任务。)
@ -842,6 +840,7 @@ const (
Rtype211 TaskType = 211 // 向指定X城市贩卖价值X虚拟币以上的对应城市急需货物 Rtype211 TaskType = 211 // 向指定X城市贩卖价值X虚拟币以上的对应城市急需货物
Rtype212 TaskType = 212 // 接取任务后,商队抵达指定城市 Rtype212 TaskType = 212 // 接取任务后,商队抵达指定城市
Rtype213 TaskType = 213 // 消耗X体力 Rtype213 TaskType = 213 // 消耗X体力
Rtype214 TaskType = 214 // 获得x充值积分
) )
const ( const (
MailLineEasy int32 = 1 // 简单 MailLineEasy int32 = 1 // 简单

View File

@ -394,17 +394,6 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn
this.Warn("资源不足", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "T", Value: k}, log.Field{Key: "N", Value: v}) this.Warn("资源不足", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "T", Value: k}, log.Field{Key: "N", Value: v})
return return
} }
// 统计今天消耗的体力
if k == "ps" && v < 0 {
if userexpand, err := this.ModuleUser.GetUserExpand(session.GetUserId()); err == nil {
userexpand.ConsumPs += (-v)
this.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
"consumPs": userexpand.ConsumPs,
})
go this.ModuleUiGame.HDPSTodayConsum(session.GetUserId(), userexpand.ConsumPs) //
}
}
} }
for k, v := range items { for k, v := range items {
amount := this.ModuleItems.QueryItemAmount(session.GetUserId(), k) amount := this.ModuleItems.QueryItemAmount(session.GetUserId(), k)
@ -426,10 +415,6 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn
return return
} }
this.Debug("消耗玩家资源", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "attrs", Value: attrs}) this.Debug("消耗玩家资源", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "attrs", Value: attrs})
if count, ok := attrs[comm.ResDiamond]; ok {
// this.ModuleBuried.SendToRtask(session, comm.Rtype104, -count)
go this.ModuleBuried.TriggerBuried(session.Clone(), comm.GetBuriedParam(comm.Rtype104, -count))
}
} }
if len(items) > 0 { if len(items) > 0 {
_, errdata = this.ModuleItems.AddItems(session, items, bPush) _, errdata = this.ModuleItems.AddItems(session, items, bPush)

View File

@ -441,7 +441,6 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha
} }
return return
} }
this.ModuleBuried.TriggerBuried(session.Clone(), comm.GetBuriedParam(comm.Rtype68, -(add)))
} }
change.Gold += int64(add) change.Gold += int64(add)
case comm.ResExp: case comm.ResExp:
@ -546,6 +545,7 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha
return return
} }
change.Ps += add change.Ps += add
userEx.ConsumPs += -add
} else { } else {
if change.Ps+add > ggd.PsUl { if change.Ps+add > ggd.PsUl {
change.Ps = ggd.PsUl change.Ps = ggd.PsUl
@ -652,6 +652,7 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha
comm.ResFriend: change.Friend, comm.ResFriend: change.Friend,
comm.SociatyCoin: change.Guildcoin, comm.SociatyCoin: change.Guildcoin,
comm.ArenaCoin: change.Arenacoin, comm.ArenaCoin: change.Arenacoin,
"consumPs": userEx.ConsumPs,
} }
if err := this.modelUser.updateUserAttr(uid, update); err != nil { if err := this.modelUser.updateUserAttr(uid, update); err != nil {
@ -696,27 +697,47 @@ func (this *User) AddAttributeValue(session comm.IUserSession, attr string, add
// 用户资源 // 用户资源
func (this *User) AddAttributeValues(session comm.IUserSession, attrs map[string]int32, bPush bool) (errdata *pb.ErrorData) { func (this *User) AddAttributeValues(session comm.IUserSession, attrs map[string]int32, bPush bool) (errdata *pb.ErrorData) {
var (
expChange bool
vipExpChange bool
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
_change *pb.UserResChangedPush
)
for key, add := range attrs { for key, add := range attrs {
var _change *pb.UserResChangedPush
_change, errdata = this.change(session, key, add) _change, errdata = this.change(session, key, add)
if errdata != nil { if errdata != nil {
return return
} }
if key == comm.ResExp {
if _change == nil { expChange = true
continue } else if key == comm.VipExp {
vipExpChange = true
}
if key == comm.ResPs && add < 0 { //消耗体力
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype213, -add))
}
if key == comm.ResGold && add < 0 { //消耗体力
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype68, -add))
}
if key == comm.ResDiamond && add < 0 { //消耗钻石
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype104, -add))
}
if key == comm.Integral && add > 0 { //积分获取
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype214, add))
}
} }
if bPush { //推送玩家账号信息变化消息 if bPush { //推送玩家账号信息变化消息
session.SendMsg(string(this.GetType()), "reschanged", _change) session.SendMsg(string(this.GetType()), "reschanged", _change)
} }
if key == comm.ResExp { if expChange {
this.ModuleUser.EventUserChanged(session) this.ModuleUser.EventUserChanged(session)
} else if key == comm.VipExp { }
if vipExpChange {
this.ModuleUser.EventUserVipChanged(session) this.ModuleUser.EventUserVipChanged(session)
} }
if len(tasks) > 0 {
go this.ModuleBuried.TriggerBuried(session.Clone(), tasks...)
} }
return return
} }