上传任务代码调整
This commit is contained in:
parent
0bde395d6a
commit
1318e14db0
@ -508,8 +508,10 @@ type (
|
|||||||
//埋点中心触发
|
//埋点中心触发
|
||||||
TriggerBuried(uid string, burieds ...*BuriedParam)
|
TriggerBuried(uid string, burieds ...*BuriedParam)
|
||||||
//校验条件是否达成
|
//校验条件是否达成
|
||||||
CheckCondition(uid string, condiIds ...int32) (condIds []int32)
|
CheckCondition(uid string, condiIds ...int32) (condIds []int32, err error)
|
||||||
//激活条件
|
//激活条件
|
||||||
ActiveCondition(uid string, condiIds ...int32)
|
ActiveCondition(uid string, condiIds ...int32) (err error)
|
||||||
|
//校验的同时激活条件
|
||||||
|
CheckAndActiveCondition(uid string, condiIds ...int32) (condIds []int32, err error)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -51,6 +51,25 @@ func (this *configureComp) getburiedtypedata(tt comm.TaskType) (result *cfg.Game
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//读取条件任务id配置
|
||||||
|
func (this *configureComp) getburiedcondidata(cid int32) (result *cfg.GameBuriedCondiData, err error) {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
ok bool
|
||||||
|
)
|
||||||
|
if v, err = this.GetConfigure(game_buriedcondi); err != nil {
|
||||||
|
this.module.Errorf("err:%v", err)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
if result, ok = v.(*cfg.GameBuriedCondi).GetDataMap()[cid]; !ok {
|
||||||
|
err = comm.NewNotFoundConfErr(moduleName, game_buriedtype, cid)
|
||||||
|
this.module.Errorf("err:%v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//动态更新配置
|
//动态更新配置
|
||||||
func (this *configureComp) updateconfigure() {
|
func (this *configureComp) updateconfigure() {
|
||||||
if v, err := this.GetConfigure(game_buriedcondi); err != nil {
|
if v, err := this.GetConfigure(game_buriedcondi); err != nil {
|
||||||
|
@ -58,15 +58,132 @@ func (this *Buried) OnInstallComp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//激活数据采集点
|
//激活数据采集点
|
||||||
func (this *Buried) ActiveCondition(uid string, condiIds ...int32) {
|
func (this *Buried) ActiveCondition(uid string, condiIds ...int32) (err error) {
|
||||||
|
var (
|
||||||
|
model *buriedModel
|
||||||
|
conf *cfg.GameBuriedCondiData
|
||||||
|
bdatas map[int32]*pb.DBBuried
|
||||||
|
chanage []*pb.DBBuried //变化埋点
|
||||||
|
)
|
||||||
|
if model, err = this.modelBuried.getburiedModel(uid); err != nil {
|
||||||
|
this.Error("获取用户埋点数据模型对象失败!", log.Field{Key: "err", Value: err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if bdatas, err = model.getUserBurieds(uid); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
chanage = make([]*pb.DBBuried, 0)
|
||||||
|
for _, v := range condiIds {
|
||||||
|
if conf, err = this.configure.getburiedcondidata(v); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if bdata, ok := bdatas[conf.Type]; ok {
|
||||||
|
if conf.Rtype == rtype2 {
|
||||||
|
if item, ok := bdata.Items[v]; !ok {
|
||||||
|
bdata.Items[v] = &pb.DBBuriedItem{
|
||||||
|
Conid: v,
|
||||||
|
State: pb.BuriedItemState_Activated,
|
||||||
|
Value: 0,
|
||||||
|
Statistics: make([]string, 0),
|
||||||
|
Timestamp: time.Now().Unix(),
|
||||||
|
}
|
||||||
|
chanage = append(chanage, bdata)
|
||||||
|
} else {
|
||||||
|
item.Value = 0
|
||||||
|
item.Statistics = make([]string, 0)
|
||||||
|
item.Timestamp = time.Now().Unix()
|
||||||
|
item.State = pb.BuriedItemState_Activated
|
||||||
|
chanage = append(chanage, bdata)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(chanage) > 0 {
|
||||||
|
err = model.updateUserBurieds(uid, chanage)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//激活数据采集点
|
//激活数据采集点
|
||||||
func (this *Buried) CheckCondition(uid string, condiIds ...int32) (condIds []int32) {
|
func (this *Buried) CheckCondition(uid string, condiIds ...int32) (condIds []int32, err error) {
|
||||||
|
var (
|
||||||
|
model *buriedModel
|
||||||
|
bdatas map[int32]*pb.DBBuried
|
||||||
|
conf *cfg.GameBuriedCondiData
|
||||||
|
)
|
||||||
|
if model, err = this.modelBuried.getburiedModel(uid); err != nil {
|
||||||
|
this.Error("获取用户埋点数据模型对象失败!", log.Field{Key: "err", Value: err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if bdatas, err = model.getUserBurieds(uid); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
condIds = make([]int32, 0)
|
||||||
|
for _, v := range condiIds {
|
||||||
|
if conf, err = this.configure.getburiedcondidata(v); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if bdata, ok := bdatas[conf.Type]; ok {
|
||||||
|
if data, ok := bdata.Items[v]; ok {
|
||||||
|
if data.Value >= conf.Value {
|
||||||
|
condIds = append(condIds, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//校验同时激活
|
||||||
|
func (this *Buried) CheckAndActiveCondition(uid string, condiIds ...int32) (condIds []int32, err error) {
|
||||||
|
var (
|
||||||
|
model *buriedModel
|
||||||
|
bdatas map[int32]*pb.DBBuried
|
||||||
|
conf *cfg.GameBuriedCondiData
|
||||||
|
chanage []*pb.DBBuried //变化埋点
|
||||||
|
)
|
||||||
|
if model, err = this.modelBuried.getburiedModel(uid); err != nil {
|
||||||
|
this.Error("获取用户埋点数据模型对象失败!", log.Field{Key: "err", Value: err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if bdatas, err = model.getUserBurieds(uid); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
condIds = make([]int32, 0)
|
||||||
|
chanage = make([]*pb.DBBuried, 0)
|
||||||
|
for _, v := range condiIds {
|
||||||
|
if conf, err = this.configure.getburiedcondidata(v); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if bdata, ok := bdatas[conf.Type]; ok {
|
||||||
|
if data, ok := bdata.Items[v]; ok {
|
||||||
|
if data.Value >= conf.Value {
|
||||||
|
condIds = append(condIds, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if conf.Rtype == rtype2 {
|
||||||
|
if item, ok := bdata.Items[v]; !ok {
|
||||||
|
bdata.Items[v] = &pb.DBBuriedItem{
|
||||||
|
Conid: v,
|
||||||
|
State: pb.BuriedItemState_Activated,
|
||||||
|
Value: 0,
|
||||||
|
Statistics: make([]string, 0),
|
||||||
|
Timestamp: time.Now().Unix(),
|
||||||
|
}
|
||||||
|
chanage = append(chanage, bdata)
|
||||||
|
} else {
|
||||||
|
item.Value = 0
|
||||||
|
item.Statistics = make([]string, 0)
|
||||||
|
item.Timestamp = time.Now().Unix()
|
||||||
|
item.State = pb.BuriedItemState_Activated
|
||||||
|
chanage = append(chanage, bdata)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(chanage) > 0 {
|
||||||
|
err = model.updateUserBurieds(uid, chanage)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user