维京优化

This commit is contained in:
meixiongfeng 2022-11-15 20:06:32 +08:00
parent f9d974a6c3
commit d5f642d0dc
6 changed files with 52 additions and 42 deletions

View File

@ -322,5 +322,11 @@
"open": true, "open": true,
"routrules": "~/worker", "routrules": "~/worker",
"describe": "公会活跃度列表" "describe": "公会活跃度列表"
},
{
"msgid": "viking.ranklist",
"open": true,
"routrules": "~/worker",
"describe": "维京排行榜数据"
} }
] ]

View File

@ -3,7 +3,6 @@ package gourmet
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@ -26,9 +25,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.GourmetGetListRe
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
if _gourmet.Ctime == 0 {
_gourmet.Ctime = configure.Now().Unix()
}
// 计算订单信息 // 计算订单信息
this.module.modelGourmet.CalculationGourmet(session.GetUserId(), _gourmet) this.module.modelGourmet.CalculationGourmet(session.GetUserId(), _gourmet)
session.SendMsg(string(this.module.GetType()), GourmetGetListResp, &pb.GourmetGetListResp{Data: _gourmet}) session.SendMsg(string(this.module.GetType()), GourmetGetListResp, &pb.GourmetGetListResp{Data: _gourmet})

View File

@ -148,7 +148,7 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
bCooking = true bCooking = true
// 记录下订单时间 // 记录下订单时间
gourmet.Ctime = configure.Now().Unix() gourmet.Ctime = gourmet.CookingFood.ETime
mapData["ctime"] = gourmet.Ctime mapData["ctime"] = gourmet.Ctime
break break
} }

View File

@ -5,7 +5,9 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure" "go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/sys/db"
"strconv" "strconv"
"time"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
@ -121,7 +123,9 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
mapRankData["Leadpos"] = Leadpos mapRankData["Leadpos"] = Leadpos
mapRankData["line"] = szLine mapRankData["line"] = szLine
mapRankData["costTime"] = costTime mapRankData["costTime"] = costTime
this.module.modulerank.ChangeUserRank(session.GetUserId(), v.Id, mapRankData) conn_, _ := db.Cross()
dbModel := db.NewDBModel(comm.TableVikingRank, time.Hour, conn_)
dbModel.ChangeList(session.GetUserId(), v.Id, mapRankData)
objID = v.Id objID = v.Id
bFind = true bFind = true
break break
@ -142,7 +146,9 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
CostTime: costTime, CostTime: costTime,
} }
objID = new.Id objID = new.Id
this.module.modulerank.AddRankList(session.GetUserId(), new.Id, new) conn_, _ := db.Cross()
dbModel := db.NewDBModel(comm.TableVikingRank, time.Hour, conn_)
dbModel.AddList(session.GetUserId(), new.Id, new)
} }
this.module.modulerank.SetRankListData("vikingRank"+strconv.Itoa(int(req.BossId)), req.Difficulty<<16+costTime, objID) this.module.modulerank.SetRankListData("vikingRank"+strconv.Itoa(int(req.BossId)), req.Difficulty<<16+costTime, objID)
} }

View File

@ -5,7 +5,6 @@ import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/sys/redis/pipe" "go_dreamfactory/lego/sys/redis/pipe"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/db"
"strconv" "strconv"
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
@ -29,28 +28,25 @@ func (this *apiComp) RankList(session comm.IUserSession, req *pb.VikingRankListR
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
return // 参数校验失败直接返回 return // 参数校验失败直接返回
} }
if !req.Friend {
if !this.module.IsCross() {
if conn, err := db.Local(); err == nil {
var (
pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
)
if !req.Friend {
var (
pipe *pipe.RedisPipe = this.module.modelViking.Redis.RedisPipe(context.TODO())
)
rd = pipe.ZRange("vikingRank"+strconv.Itoa(int(req.BoosType)), 0, -1) rd = pipe.ZRange("vikingRank"+strconv.Itoa(int(req.BoosType)), 0, -1)
if _, err = pipe.Exec(); err != nil { if _, err := pipe.Exec(); err != nil {
this.module.Errorln(err) this.module.Errorln(err)
return return
} }
_dataList := rd.Val() _dataList := rd.Val()
for _, v := range _dataList { for _, v := range _dataList {
result := &pb.DBVikingRank{} result := &pb.DBVikingRank{}
if err = this.module.modulerank.GetListObj(session.GetUserId(), v, result); err == nil { if err := this.module.modulerank.GetListObj(session.GetUserId(), v, result); err == nil {
szRank = append(szRank, result) szRank = append(szRank, result)
} }
} }
}
}
} else { } else {
uids := this.friend.GetFriendList(session.GetUserId()) uids := this.friend.GetFriendList(session.GetUserId())
for _, id := range uids { for _, id := range uids {

View File

@ -7,6 +7,7 @@ import (
"go_dreamfactory/lego/sys/redis/pipe" "go_dreamfactory/lego/sys/redis/pipe"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/db"
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
) )
@ -61,10 +62,12 @@ func (this *ModelRank) getVikingRankListByBossType(uid string, bossType int32) *
return nil return nil
} }
// 排行数据写跨服
func (this *ModelRank) SetRankListData(tableName string, score int32, uid string) { func (this *ModelRank) SetRankListData(tableName string, score int32, uid string) {
if !db.IsCross() {
if conn, err := db.Cross(); err == nil {
var ( var (
pipe *pipe.RedisPipe = this.DBModel.Redis.RedisPipe(context.TODO()) pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
menbers *redis.Z menbers *redis.Z
) )
@ -81,4 +84,6 @@ func (this *ModelRank) SetRankListData(tableName string, score int32, uid string
this.moduleViking.Errorln(err) this.moduleViking.Errorln(err)
return return
} }
}
}
} }