From 98e903573e5e6d958cfb52c96df2f9b87ec8ec80 Mon Sep 17 00:00:00 2001 From: liwei <2211068034@qq.com> Date: Thu, 3 Aug 2023 10:39:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BA=A2=E7=82=B9=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/arena/modelarena.go | 32 ++++++++++- modules/arena/module.go | 10 +++- modules/dailytask/module.go | 2 +- modules/modulebase.go | 4 +- modules/parkour/model_parkour.go | 2 +- modules/practice/modelPandata.go | 99 ++++++++++++++++++++++++++++++++ modules/practice/module.go | 12 +++- modules/wtask/api_finish.go | 24 ++++---- modules/wtask/module.go | 20 +++---- 9 files changed, 174 insertions(+), 31 deletions(-) diff --git a/modules/arena/modelarena.go b/modules/arena/modelarena.go index 143315413..7c2e2340b 100644 --- a/modules/arena/modelarena.go +++ b/modules/arena/modelarena.go @@ -446,7 +446,37 @@ func (this *modelArena) recoverTicket(session comm.IUserSession, info *pb.DBAren } } -func (this *modelArena) reddot(session comm.IUserSession) (info *pb.DBArenaUser, ticket int32, activated bool) { +// 更新埋点数据到db中 +func (this *modelArena) getpandataModel() (model *arenaModel, err error) { + var m *db.DBModel + if !db.IsCross() { + if m, err = this.module.GetCrossDBModel(this.TableName); err != nil { + return + } + model = &arenaModel{module: this.module, model: m} + } else { + model = &arenaModel{module: this.module, model: this.DBModel} + } + return +} + +// 埋点专属模型 会封装特殊的数据转换接口 +type arenaModel struct { + module *Arena + model *db.DBModel +} + +// 查询用户装备数据 +func (this *arenaModel) queryPlayerInfo(uId string) (result *pb.DBArenaUser, err error) { + result = &pb.DBArenaUser{} + if err = this.model.Get(uId, result); err != nil && err != mgo.MongodbNil { + this.module.Errorln(err) + return + } + return +} + +func (this *arenaModel) reddot(session comm.IUserSession) (info *pb.DBArenaUser, ticket int32, activated bool) { var ( ticketitem *cfg.Gameatn err error diff --git a/modules/arena/module.go b/modules/arena/module.go index 1d9a1cb2b..5eab9fc07 100644 --- a/modules/arena/module.go +++ b/modules/arena/module.go @@ -98,11 +98,19 @@ func (this *Arena) Rpc_ModuleArenaModifyIntegral(ctx context.Context, args *pb.R // 红点需求 func (this *Arena) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (result map[comm.ReddotType]*pb.ReddotItem) { var ( + model *arenaModel info *pb.DBArenaUser = &pb.DBArenaUser{} activated bool ticket int32 + err error ) - if info, ticket, activated = this.modelArena.reddot(session); info == nil { + + if model, err = this.modelArena.getpandataModel(); err != nil { + this.Errorln(err) + return + } + + if info, ticket, activated = model.reddot(session); info == nil { return } result = make(map[comm.ReddotType]*pb.ReddotItem) diff --git a/modules/dailytask/module.go b/modules/dailytask/module.go index aa8163421..0f5dd2b6f 100644 --- a/modules/dailytask/module.go +++ b/modules/dailytask/module.go @@ -149,7 +149,7 @@ func (this *Dailytask) Reddot(session comm.IUserSession, rid ...comm.ReddotType) switch v { case comm.Reddot25101: for _, v := range dtask.Groups { - if !v.Complete { + if v.Complete { progress++ } } diff --git a/modules/modulebase.go b/modules/modulebase.go index e8831ca7b..3f30d9a38 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -529,7 +529,7 @@ func (this *ModuleBase) GetDBNodule(session comm.IUserSession, tableName string, } // 跨服对象获取数据操作对象 -func (this *ModuleBase) GetCrossDBModel(tableName string, expired time.Duration) (model *db.DBModel, err error) { +func (this *ModuleBase) GetCrossDBModel(tableName string) (model *db.DBModel, err error) { var ( conn *db.DBConn ) @@ -542,7 +542,7 @@ func (this *ModuleBase) GetCrossDBModel(tableName string, expired time.Duration) return } } - model = db.NewDBModel(tableName, expired, conn) + model = db.NewDBModel(tableName, time.Hour, conn) return } diff --git a/modules/parkour/model_parkour.go b/modules/parkour/model_parkour.go index 2f8be086a..4d4277696 100644 --- a/modules/parkour/model_parkour.go +++ b/modules/parkour/model_parkour.go @@ -212,7 +212,7 @@ func (this *ModelParkourComp) addUserMounts(uid string, mounts map[string]int32) model *db.DBModel ) if !this.module.IsCross() { //非跨服 - if model, err = this.module.GetCrossDBModel(this.TableName, this.Expired); err != nil { + if model, err = this.module.GetCrossDBModel(this.TableName); err != nil { this.module.Errorln(err) } else { result = &pb.DBParkour{} diff --git a/modules/practice/modelPandata.go b/modules/practice/modelPandata.go index 5b3152d7f..47a7f5a09 100644 --- a/modules/practice/modelPandata.go +++ b/modules/practice/modelPandata.go @@ -9,6 +9,7 @@ import ( "go_dreamfactory/pb" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" + "go_dreamfactory/sys/db" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" @@ -142,3 +143,101 @@ func (this *modelPandata) refreshnpc(room *pb.DBPracticeRoom) (err error) { } return } + +// 更新埋点数据到db中 +func (this *modelPandata) getpandataModel() (model *pandataModel, err error) { + var m *db.DBModel + if !db.IsCross() { + if m, err = this.module.GetCrossDBModel(this.TableName); err != nil { + return + } + model = &pandataModel{module: this.module, model: m} + } else { + model = &pandataModel{module: this.module, model: this.DBModel} + } + return +} + +// 埋点专属模型 会封装特殊的数据转换接口 +type pandataModel struct { + module *Practice + model *db.DBModel +} + +// /询用户的练功房信息 +func (this *pandataModel) queryUserMartialhall(uid string) (result *pb.DBPracticeRoom, err error) { + result = &pb.DBPracticeRoom{} + if err = this.model.Get(uid, result); err != nil && err != mgo.MongodbNil { + this.module.Errorln(err) + return + } + if err == mgo.MongodbNil { + result = &pb.DBPracticeRoom{ + Id: primitive.NewObjectID().Hex(), + Uid: uid, + Full: make(map[int32]int32), + Knapsack: make(map[string]*pb.DBPracticeRes), + Gymaction: 0, + Gymrefresh: 0, + Pillar1: &pb.DBPracticePillar{Index: 1, Isunlock: 0, Lv: 1}, + Pillar2: &pb.DBPracticePillar{Index: 2, Lv: 1}, + Pillar3: &pb.DBPracticePillar{Index: 3, Lv: 1}, + Pillarf: &pb.DBPracticePillar{Index: 4, Isunlock: 0, Lv: 1}, + Statuers: make([]*pb.DBPracticeStatuer, 0), + Npcstate: -1, + Refresh: configure.Now().Unix(), + } + // if err = this.refreshnpc(result); err != nil { + // this.module.Errorln(err) + // return + // } + if err = this.model.Add(uid, result); err != nil { + this.module.Errorln(err) + return + } + if err = this.module.atlas.CheckActivatePandaAtlasCollect(uid, "100001"); err != nil { + this.module.Errorln(err) + return + } + } + err = nil + return +} +func (this *pandataModel) queryrooms(uids []string) (results []*pb.DBPracticeRoom, err error) { + results = make([]*pb.DBPracticeRoom, 0) + var ( + onfound []string + newdata map[string]interface{} = make(map[string]interface{}) + ) + if onfound, err = this.model.Gets(uids, &results); err != nil { + this.module.Errorln(err) + return + } + if len(onfound) > 0 { + for _, v := range onfound { + temp := &pb.DBPracticeRoom{ + Id: primitive.NewObjectID().Hex(), + Uid: v, + Full: make(map[int32]int32), + Knapsack: make(map[string]*pb.DBPracticeRes), + Gymaction: 0, + Gymrefresh: 0, + Pillar1: &pb.DBPracticePillar{Index: 1, Isunlock: 2, Lv: 1}, + Pillar2: &pb.DBPracticePillar{Index: 2, Lv: 1}, + Pillar3: &pb.DBPracticePillar{Index: 3, Lv: 1}, + Pillarf: &pb.DBPracticePillar{Index: 4, Isunlock: 2, Lv: 1}, + Statuers: make([]*pb.DBPracticeStatuer, 0), + Npcstate: 3, + Refresh: configure.Now().Unix(), + } + go this.module.atlas.CheckActivatePandaAtlasCollect(v, "100001") + newdata[v] = temp + results = append(results, temp) + } + if err = this.model.Adds(newdata); err != nil { + this.module.Errorln(err) + return + } + } + return +} diff --git a/modules/practice/module.go b/modules/practice/module.go index 78febeed5..b3c821af4 100644 --- a/modules/practice/module.go +++ b/modules/practice/module.go @@ -412,6 +412,7 @@ func (this *Practice) GetAllJxRes() (res []string, err error) { // 红点 func (this *Practice) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) { var ( + model *pandataModel room *pb.DBPracticeRoom pconf *cfg.GamePandamasMzData usenum int32 @@ -419,7 +420,12 @@ func (this *Practice) Reddot(session comm.IUserSession, rid ...comm.ReddotType) err error ) reddot = make(map[comm.ReddotType]*pb.ReddotItem) - if room, err = this.modelPandata.queryUserMartialhall(session.GetUserId()); err != nil { + if model, err = this.modelPandata.getpandataModel(); err != nil { + this.Errorln(err) + return + } + + if room, err = model.queryUserMartialhall(session.GetUserId()); err != nil { this.Errorln(err) return } @@ -452,8 +458,8 @@ func (this *Practice) Reddot(session comm.IUserSession, rid ...comm.ReddotType) } break case comm.Reddot26201: - reddot[comm.Reddot26101] = &pb.ReddotItem{ - Rid: int32(comm.Reddot26101), + reddot[comm.Reddot26201] = &pb.ReddotItem{ + Rid: int32(comm.Reddot26201), Activated: true, Progress: usenum, Total: totalusenum, diff --git a/modules/wtask/api_finish.go b/modules/wtask/api_finish.go index 008b6a6f4..4d93af516 100644 --- a/modules/wtask/api_finish.go +++ b/modules/wtask/api_finish.go @@ -141,18 +141,18 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WTaskFinishReq) ( } return } - if err = this.module.ModuleBuried.ActiveCondition(session.GetUserId(), afterconf.Completetask...); err != nil { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_ExternalModule, - Title: pb.ErrorCode_ExternalModule.ToString(), - Message: fmt.Sprintf("ModuleBuried.ActiveCondition uid:%s condiIds:%v", session.GetUserId(), conf.Completetask), - } - return - } - wtask.Accepts = append(wtask.Accepts, afterconf.Key) - if _, errdata = this.module.pushtaskprogress(session, wtask, true); errdata != nil { - return - } + // if err = this.module.ModuleBuried.ActiveCondition(session.GetUserId(), afterconf.Completetask...); err != nil { + // errdata = &pb.ErrorData{ + // Code: pb.ErrorCode_ExternalModule, + // Title: pb.ErrorCode_ExternalModule.ToString(), + // Message: fmt.Sprintf("ModuleBuried.ActiveCondition uid:%s condiIds:%v", session.GetUserId(), conf.Completetask), + // } + // return + // } + wtask.Activations = append(wtask.Activations, afterconf.Key) + // if _, errdata = this.module.pushtaskprogress(session, wtask, true); errdata != nil { + // return + // } } this.module.checkgroupState(session, wtask, conf.Group) diff --git a/modules/wtask/module.go b/modules/wtask/module.go index 95d7d76d5..9a329afb9 100644 --- a/modules/wtask/module.go +++ b/modules/wtask/module.go @@ -322,7 +322,7 @@ func (this *WTask) ResetDailytaskTask(session comm.IUserSession, dailytaskid int for _, task := range tasks { if task.Ontxe == 0 { condiIds = append(condiIds, task.Completetask...) - accepts = append(accepts, task.Key) + activations = append(activations, task.Key) if _, ok = results[v]; !ok { results[v] = make([]int32, 0) } @@ -351,14 +351,14 @@ func (this *WTask) ResetDailytaskTask(session comm.IUserSession, dailytaskid int wtask.Exchange = make(map[int32]int32) wtask.Events = make(map[int32]int32) if len(condiIds) > 0 { - if err = this.ModuleBuried.ActiveCondition(session.GetUserId(), condiIds...); err != nil { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_ExternalModule, - Title: pb.ErrorCode_ExternalModule.ToString(), - Message: fmt.Sprintf("ModuleBuried.ActiveCondition uid:%s condiIds:%v", session.GetUserId(), condiIds), - } - return - } + // if err = this.ModuleBuried.ActiveCondition(session.GetUserId(), condiIds...); err != nil { + // errdata = &pb.ErrorData{ + // Code: pb.ErrorCode_ExternalModule, + // Title: pb.ErrorCode_ExternalModule.ToString(), + // Message: fmt.Sprintf("ModuleBuried.ActiveCondition uid:%s condiIds:%v", session.GetUserId(), condiIds), + // } + // return + // } } //有新任务接取 @@ -749,7 +749,7 @@ func (this *WTask) inquireActivations(session comm.IUserSession, wtask *pb.DBWTa if _, ok = completeMap[v.Ontxe]; v.Ontxe != 0 && !ok { //前置任务判断 continue } - if v.Des == 5 || v.Des == 1 { //商队任务不主动触发 日常任务直接接取不进入可接取列表中 + if v.Des == 5 { //商队任务不主动触发 日常任务直接接取不进入可接取列表中 continue } wtask.Activations = append(wtask.Activations, v.Key)