上传红点任务

This commit is contained in:
liwei 2023-08-03 10:39:40 +08:00
parent 5dbabf4432
commit 98e903573e
9 changed files with 174 additions and 31 deletions

View File

@ -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

View File

@ -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)

View File

@ -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++
}
}

View File

@ -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
}

View File

@ -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{}

View File

@ -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
}

View File

@ -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,

View File

@ -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)

View File

@ -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)