From 81f2b568ef9e21d5270f13cd4a32a4852b33f1ed Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 14 Jul 2023 19:55:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AA=E7=8E=AF=E5=A1=94=E6=8E=92=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/pagoda/api_crossrank.go | 16 ++++++++++----- modules/pagoda/api_racechallengeover.go | 4 ++-- modules/pagoda/module.go | 27 +++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/modules/pagoda/api_crossrank.go b/modules/pagoda/api_crossrank.go index a41748559..754ad0595 100644 --- a/modules/pagoda/api_crossrank.go +++ b/modules/pagoda/api_crossrank.go @@ -5,6 +5,7 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/sys/redis/pipe" "go_dreamfactory/pb" + "go_dreamfactory/sys/db" "strconv" "github.com/go-redis/redis/v8" @@ -27,16 +28,20 @@ func (this *apiComp) CrossRaceRankList(session comm.IUserSession, req *pb.Pagoda szRank []*pb.DBRacePagodaRecord rd *redis.StringSliceCmd ) + var ( + pipe *pipe.RedisPipe + ) if errdata = this.CrossRaceRankListCheck(session, req); errdata != nil { return } if this.module.IsCross() { - var ( - pipe *pipe.RedisPipe = this.module.modelPagoda.Redis.RedisPipe(context.TODO()) - ) + conn, _ := db.Local() + dbModel := db.NewDBModel(comm.TableRaceRecord, 0, conn) - rd = pipe.ZRange("race"+strconv.Itoa(int(req.Raceid)), 0, comm.MaxRankList) + pipe = conn.Redis.RedisPipe(context.TODO()) + tablename := "race" + strconv.Itoa(int(req.Raceid)) + rd = pipe.ZRevRange(tablename, 0, comm.MaxRankList) if _, err := pipe.Exec(); err != nil { this.module.Errorln(err) @@ -45,10 +50,11 @@ func (this *apiComp) CrossRaceRankList(session comm.IUserSession, req *pb.Pagoda _dataList := rd.Val() for _, v := range _dataList { result := &pb.DBRacePagodaRecord{} - if err := this.module.modulerank.GetListObj(session.GetUserId(), v, result); err == nil { + if err := dbModel.Redis.HGetAll(v, result); err == nil { szRank = append(szRank, result) } } + } session.SendMsg(string(this.module.GetType()), PagodaCrossRaceRankListReq, &pb.PagodaCrossRaceRankListResp{Ranks: szRank}) diff --git a/modules/pagoda/api_racechallengeover.go b/modules/pagoda/api_racechallengeover.go index fc526e595..40b09b455 100644 --- a/modules/pagoda/api_racechallengeover.go +++ b/modules/pagoda/api_racechallengeover.go @@ -136,7 +136,7 @@ func (this *apiComp) ChallengeRaceOver(session comm.IUserSession, req *pb.Pagoda Floor: race.Race[conf.Restriction].Curfloor, Type: conf.Restriction, Nickname: userinfo.Name, - Icon: "", + Icon: userinfo.CurSkin, // 皮肤 Lv: userinfo.Lv, Overtime: configure.Now().Unix(), } @@ -165,7 +165,7 @@ func (this *apiComp) ChallengeRaceOver(session comm.IUserSession, req *pb.Pagoda } else { this.module.Errorf("db crosserr :%v", err) } - this.module.SetPagodaRankList("race"+strconv.Itoa(int(conf.Restriction)), race.Race[conf.Restriction].Curfloor, newData.Id) + this.module.SetRacePagodaRankList("race"+strconv.Itoa(int(conf.Restriction)), race.Race[conf.Restriction].Curfloor, session.GetUserId(), newData.Id) } // 任务相关 //go this.module.ModuleBuried.TriggerBuried(session.Clone(), comm.GetBuriedParam(comm.Rtype168, pagoda.Data[conf.Tab], conf.Tab)) diff --git a/modules/pagoda/module.go b/modules/pagoda/module.go index 2c22397a6..3e139df1f 100644 --- a/modules/pagoda/module.go +++ b/modules/pagoda/module.go @@ -199,3 +199,30 @@ func (this *Pagoda) CheckCompletePagoda(uid string) (bComplete bool) { return false } +func (this *Pagoda) SetRacePagodaRankList(tableName string, score int32, uid string, objID string) { + if !this.IsCross() { + if conn, err := db.Cross(); err == nil { + + var ( + pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO()) + menbers *redis.Z + ) + + strKey := "pagodarace:" + uid + "-" + objID // 自定义key + menbers = &redis.Z{Score: float64(score), Member: strKey} + + if cmd := pipe.ZAdd(tableName, menbers); cmd != nil { + + dock, err1 := cmd.Result() + if err1 != nil { + this.Errorln(dock, err1) + } + } + if _, err := pipe.Exec(); err != nil { + this.Errorln(err) + return + } + + } + } +}