From f4a376ad1046f505744afa947092a2d4b5cba1f7 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 29 May 2023 15:46:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E9=85=8D=E7=BD=AE=E5=90=8C?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_initial.json | 240 ------------------------------- bin/json/game_skillafteratk.json | 2 +- modules/buried/configure.go | 20 +++ modules/buried/core.go | 4 +- modules/buried/module.go | 48 ++++--- modules/user/api_create.go | 2 +- pb/buried_db.pb.go | 56 +++++--- 7 files changed, 83 insertions(+), 289 deletions(-) diff --git a/bin/json/game_initial.json b/bin/json/game_initial.json index 8003b132a..4e4951ef0 100644 --- a/bin/json/game_initial.json +++ b/bin/json/game_initial.json @@ -1619,246 +1619,6 @@ } ] }, - { - "index": "328", - "var": [ - { - "a": "item", - "t": "14010101", - "n": 10 - } - ] - }, - { - "index": "329", - "var": [ - { - "a": "item", - "t": "14010102", - "n": 11 - } - ] - }, - { - "index": "330", - "var": [ - { - "a": "item", - "t": "14010203", - "n": 12 - } - ] - }, - { - "index": "331", - "var": [ - { - "a": "item", - "t": "14010204", - "n": 13 - } - ] - }, - { - "index": "332", - "var": [ - { - "a": "item", - "t": "14010305", - "n": 14 - } - ] - }, - { - "index": "333", - "var": [ - { - "a": "item", - "t": "14010306", - "n": 15 - } - ] - }, - { - "index": "334", - "var": [ - { - "a": "item", - "t": "14010407", - "n": 16 - } - ] - }, - { - "index": "335", - "var": [ - { - "a": "item", - "t": "14010408", - "n": 17 - } - ] - }, - { - "index": "336", - "var": [ - { - "a": "item", - "t": "14020101", - "n": 18 - } - ] - }, - { - "index": "337", - "var": [ - { - "a": "item", - "t": "14020102", - "n": 19 - } - ] - }, - { - "index": "338", - "var": [ - { - "a": "item", - "t": "14020203", - "n": 20 - } - ] - }, - { - "index": "339", - "var": [ - { - "a": "item", - "t": "14020204", - "n": 21 - } - ] - }, - { - "index": "340", - "var": [ - { - "a": "item", - "t": "14020305", - "n": 22 - } - ] - }, - { - "index": "341", - "var": [ - { - "a": "item", - "t": "14020306", - "n": 23 - } - ] - }, - { - "index": "342", - "var": [ - { - "a": "item", - "t": "14020407", - "n": 24 - } - ] - }, - { - "index": "343", - "var": [ - { - "a": "item", - "t": "14020408", - "n": 25 - } - ] - }, - { - "index": "344", - "var": [ - { - "a": "item", - "t": "14030101", - "n": 26 - } - ] - }, - { - "index": "345", - "var": [ - { - "a": "item", - "t": "14030102", - "n": 27 - } - ] - }, - { - "index": "346", - "var": [ - { - "a": "item", - "t": "14030203", - "n": 28 - } - ] - }, - { - "index": "347", - "var": [ - { - "a": "item", - "t": "14030204", - "n": 29 - } - ] - }, - { - "index": "348", - "var": [ - { - "a": "item", - "t": "14030305", - "n": 30 - } - ] - }, - { - "index": "349", - "var": [ - { - "a": "item", - "t": "14030306", - "n": 31 - } - ] - }, - { - "index": "350", - "var": [ - { - "a": "item", - "t": "14030407", - "n": 32 - } - ] - }, - { - "index": "351", - "var": [ - { - "a": "item", - "t": "14030408", - "n": 33 - } - ] - }, { "index": "352", "var": [ diff --git a/bin/json/game_skillafteratk.json b/bin/json/game_skillafteratk.json index 0158fe6b0..17a639c42 100644 --- a/bin/json/game_skillafteratk.json +++ b/bin/json/game_skillafteratk.json @@ -9116,7 +9116,7 @@ 390001211, 1000, 5, - 1 + -1 ], "FollowSK": [], "SucFollowSK": [], diff --git a/modules/buried/configure.go b/modules/buried/configure.go index 3f040b33a..8a1cf613b 100644 --- a/modules/buried/configure.go +++ b/modules/buried/configure.go @@ -11,6 +11,7 @@ import ( ) const ( + game_buriedtype = "game_buriedtype.json" game_buriedcondi = "game_buriedcondi.json" ) @@ -31,6 +32,25 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp return } +//读取埋点配置数据 +func (this *configureComp) getburiedtypedata(tt comm.TaskType) (result *cfg.GameBuriedTypeData, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(game_buriedtype); err != nil { + this.module.Errorf("err:%v", err) + return + } else { + if result, ok = v.(*cfg.GameBuriedType).GetDataMap()[int32(tt)]; !ok { + err = comm.NewNotFoundConfErr(moduleName, game_buriedtype, tt) + this.module.Errorf("err:%v", err) + return + } + } + return +} + //动态更新配置 func (this *configureComp) updateconfigure() { if v, err := this.GetConfigure(game_buriedcondi); err != nil { diff --git a/modules/buried/core.go b/modules/buried/core.go index 30f7f5eb9..5a9db5b57 100644 --- a/modules/buried/core.go +++ b/modules/buried/core.go @@ -18,8 +18,8 @@ const ( cover = 1 //累加 overlay = 2 - //查询 - query = 3 + //统计 + stats = 3 ) const ( diff --git a/modules/buried/module.go b/modules/buried/module.go index 68e71a5d1..40c36350f 100644 --- a/modules/buried/module.go +++ b/modules/buried/module.go @@ -1,6 +1,7 @@ package buried import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" @@ -20,6 +21,8 @@ import ( 开发人员:李伟 */ +const moduleName = "埋点统计中心" + type Buried struct { modules.ModuleBase service base.IRPCXService @@ -64,6 +67,7 @@ func (this *Buried) ActivationBuried(uid string, conids ...int32) (err error) { func (this *Buried) TriggerBuried(uid string, burieds ...*comm.BuriedParam) { var ( pass map[*comm.BuriedParam][]*cfg.GameBuriedCondiData = make(map[*comm.BuriedParam][]*cfg.GameBuriedCondiData) + bconf *cfg.GameBuriedTypeData model *buriedModel bdatas map[int32]*pb.DBBuried change []*pb.DBBuried @@ -97,6 +101,10 @@ func (this *Buried) TriggerBuried(uid string, burieds ...*comm.BuriedParam) { change = make([]*pb.DBBuried, 0) //处理校验通过埋点数据 for buried, conds := range pass { + if bconf, err = this.configure.getburiedtypedata(buried.Btype); err != nil { + this.Error("未找到目标埋点类型配置", log.Field{Key: "type", Value: buried.Btype}) + continue + } if bdata, ok = bdatas[bdata.Btype]; !ok { bdatas[bdata.Btype] = &pb.DBBuried{ Id: primitive.NewObjectID().Hex(), @@ -108,11 +116,11 @@ func (this *Buried) TriggerBuried(uid string, burieds ...*comm.BuriedParam) { } for _, cond := range conds { if cond.Rtype == rtype1 { //创号后入录 - if complete, err = this.updateAndCheckBuried(bdata, buried, cond, true); complete { + if complete, err = this.updateAndCheckBuried(bconf, bdata, buried, cond, true); complete { completeConIds = append(completeConIds, cond.Id) } } else if cond.Rtype == rtype2 { //任务接取后才会录入 判断用户埋点数据是否存在 不存在等待任务系统调用接口 ActivationBuried 激活 - if complete, err = this.updateAndCheckBuried(bdata, buried, cond, false); complete { + if complete, err = this.updateAndCheckBuried(bconf, bdata, buried, cond, false); complete { completeConIds = append(completeConIds, cond.Id) } } @@ -134,7 +142,7 @@ func (this *Buried) TriggerBuried(uid string, burieds ...*comm.BuriedParam) { } //更新并校验完成 -func (this *Buried) updateAndCheckBuried(bdata *pb.DBBuried, collec *comm.BuriedParam, cond *cfg.GameBuriedCondiData, autoActivated bool) (complete bool, err error) { +func (this *Buried) updateAndCheckBuried(bconf *cfg.GameBuriedTypeData, bdata *pb.DBBuried, collec *comm.BuriedParam, cond *cfg.GameBuriedCondiData, autoActivated bool) (complete bool, err error) { var ( ok bool bitem *pb.DBBuriedItem @@ -145,7 +153,8 @@ func (this *Buried) updateAndCheckBuried(bdata *pb.DBBuried, collec *comm.Buried bitem = &pb.DBBuriedItem{ Conid: cond.Id, State: pb.BuriedItemState_Activated, - Value: make([]int32, 0), + Value: 0, + Stats: make([]string, 0), Timestamp: time.Now().Unix(), } } else { @@ -157,25 +166,20 @@ func (this *Buried) updateAndCheckBuried(bdata *pb.DBBuried, collec *comm.Buried return } - // switch cond.Vtype { //数据接入方式 - // case overlay: //累加数据 - // bitem.Value[0] += collec.Value - // case cover: - // bitem.Value[0] = collec.Value - // case query: - // switch collec.Btype { - // case comm.Rtype1: - // default: - // err = fmt.Errorf("未实现的数据查询类型 埋点类型:%d", collec.Btype) - // return - // } + switch bconf.Insert { //数据接入方式 + case overlay: //累加数据 + bitem.Value += collec.Value + case cover: + bitem.Value = collec.Value + case stats: + bitem.Stats = append(bitem.Stats, "") + bitem.Value = int32(len(bitem.Stats)) + default: + err = fmt.Errorf("未知的埋点数据处理类型:%d", bconf.Insert) + return + } - // default: - // err = fmt.Errorf("未知的埋点数据处理类型:%d", cond.Vtype) - // return - // } - - if bitem.Value[0] >= cond.Value { //完成进度 + if bitem.Value >= cond.Value { //完成进度 complete = true } return diff --git a/modules/user/api_create.go b/modules/user/api_create.go index bdd268d8b..f85e4e402 100644 --- a/modules/user/api_create.go +++ b/modules/user/api_create.go @@ -85,7 +85,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c res []*cfg.Gameatn ) - //初始化英雄卡 + //初始化创角资源 if val, err := this.module.configure.GetGlobalInitConf(); err == nil { for _, v := range val.GetDataList() { res = append(res, v.Var...) diff --git a/pb/buried_db.pb.go b/pb/buried_db.pb.go index 926d9b6f8..f266bff11 100644 --- a/pb/buried_db.pb.go +++ b/pb/buried_db.pb.go @@ -81,7 +81,8 @@ type DBBuriedItem struct { Conid int32 `protobuf:"varint,1,opt,name=conid,proto3" json:"conid" bson:"conid"` //条件id State BuriedItemState `protobuf:"varint,2,opt,name=state,proto3,enum=BuriedItemState" json:"state" bson:"state"` //状态 - Value []int32 `protobuf:"varint,3,rep,packed,name=value,proto3" json:"value" bson:"value"` //条件值 + Value int32 `protobuf:"varint,3,opt,name=value,proto3" json:"value" bson:"value"` //条件值 + Stats []string `protobuf:"bytes,4,rep,name=stats,proto3" json:"stats" bson:"stats"` //统计值 Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp" bson:"timestamp"` //最后一次操作时间 } @@ -131,10 +132,17 @@ func (x *DBBuriedItem) GetState() BuriedItemState { return BuriedItemState_Inactivated } -func (x *DBBuriedItem) GetValue() []int32 { +func (x *DBBuriedItem) GetValue() int32 { if x != nil { return x.Value } + return 0 +} + +func (x *DBBuriedItem) GetStats() []string { + if x != nil { + return x.Stats + } return nil } @@ -221,32 +229,34 @@ var File_buried_buried_db_proto protoreflect.FileDescriptor var file_buried_buried_db_proto_rawDesc = []byte{ 0x0a, 0x16, 0x62, 0x75, 0x72, 0x69, 0x65, 0x64, 0x2f, 0x62, 0x75, 0x72, 0x69, 0x65, 0x64, 0x5f, - 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x80, 0x01, 0x0a, 0x0c, 0x44, 0x42, 0x42, + 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x96, 0x01, 0x0a, 0x0c, 0x44, 0x42, 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6e, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x6e, 0x69, 0x64, 0x12, 0x26, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1c, 0x0a, - 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xb7, 0x01, 0x0a, 0x08, - 0x44, 0x42, 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x62, 0x74, 0x79, 0x70, 0x65, - 0x12, 0x2a, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x14, 0x2e, 0x44, 0x42, 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x73, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x1a, 0x47, 0x0a, 0x0a, - 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x23, 0x0a, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, - 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, 0x48, 0x0a, 0x0f, 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, 0x49, - 0x74, 0x65, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x49, 0x6e, 0x61, 0x63, - 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x64, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x41, 0x63, 0x74, - 0x69, 0x76, 0x61, 0x74, 0x65, 0x64, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x72, 0x65, 0x65, - 0x7a, 0x65, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6c, 0x65, 0x65, 0x70, 0x10, 0x03, 0x42, - 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x14, 0x0a, + 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, + 0x61, 0x74, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x22, 0xb7, 0x01, 0x0a, 0x08, 0x44, 0x42, 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, + 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, + 0x12, 0x14, 0x0a, 0x05, 0x62, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x05, 0x62, 0x74, 0x79, 0x70, 0x65, 0x12, 0x2a, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, + 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x44, 0x42, 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, + 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x69, 0x74, 0x65, + 0x6d, 0x73, 0x1a, 0x47, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x23, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x42, 0x75, 0x72, 0x69, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, 0x48, 0x0a, 0x0f, 0x42, + 0x75, 0x72, 0x69, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0f, + 0x0a, 0x0b, 0x49, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x64, 0x10, 0x00, 0x12, + 0x0d, 0x0a, 0x09, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x64, 0x10, 0x01, 0x12, 0x0a, + 0x0a, 0x06, 0x46, 0x72, 0x65, 0x65, 0x7a, 0x65, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6c, + 0x65, 0x65, 0x70, 0x10, 0x03, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var (