维京优化
This commit is contained in:
parent
f9d974a6c3
commit
d5f642d0dc
@ -322,5 +322,11 @@
|
|||||||
"open": true,
|
"open": true,
|
||||||
"routrules": "~/worker",
|
"routrules": "~/worker",
|
||||||
"describe": "公会活跃度列表"
|
"describe": "公会活跃度列表"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "viking.ranklist",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "维京排行榜数据"
|
||||||
}
|
}
|
||||||
]
|
]
|
@ -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})
|
||||||
|
@ -93,9 +93,9 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
|
|||||||
szTime[k] = _time
|
szTime[k] = _time
|
||||||
}
|
}
|
||||||
if gourmet.CookingFood != nil && gourmet.CookingFood.ETime > 0 {
|
if gourmet.CookingFood != nil && gourmet.CookingFood.ETime > 0 {
|
||||||
zeroTime = utils.GetZeroTime(gourmet.CookingFood.STime) // 获取订单开始时间当天的0点
|
zeroTime = utils.GetZeroTime(gourmet.CookingFood.STime) // 获取订单开始时间当天的0点
|
||||||
costTime = int32(configure.Now().Unix() - gourmet.CookingFood.ETime) // 当前过去的时间
|
costTime = int32(configure.Now().Unix() - gourmet.CookingFood.ETime) // 当前过去的时间
|
||||||
if costTime < 0 { // 没有完成 不做处理
|
if costTime < 0 { // 没有完成 不做处理
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -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 !req.Friend {
|
||||||
if !this.module.IsCross() {
|
var (
|
||||||
if conn, err := db.Local(); err == nil {
|
pipe *pipe.RedisPipe = this.module.modelViking.Redis.RedisPipe(context.TODO())
|
||||||
var (
|
)
|
||||||
pipe *pipe.RedisPipe = conn.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 {
|
||||||
|
this.module.Errorln(err)
|
||||||
if _, err = pipe.Exec(); err != nil {
|
return
|
||||||
this.module.Errorln(err)
|
}
|
||||||
return
|
_dataList := rd.Val()
|
||||||
}
|
for _, v := range _dataList {
|
||||||
_dataList := rd.Val()
|
result := &pb.DBVikingRank{}
|
||||||
for _, v := range _dataList {
|
if err := this.module.modulerank.GetListObj(session.GetUserId(), v, result); err == nil {
|
||||||
result := &pb.DBVikingRank{}
|
szRank = append(szRank, result)
|
||||||
if err = this.module.modulerank.GetListObj(session.GetUserId(), v, result); err == nil {
|
|
||||||
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 {
|
||||||
|
@ -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,24 +62,28 @@ 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 (
|
||||||
|
pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
|
||||||
|
menbers *redis.Z
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
menbers = &redis.Z{Score: float64(score), Member: uid}
|
||||||
pipe *pipe.RedisPipe = this.DBModel.Redis.RedisPipe(context.TODO())
|
|
||||||
menbers *redis.Z
|
|
||||||
)
|
|
||||||
|
|
||||||
menbers = &redis.Z{Score: float64(score), Member: uid}
|
if cmd := pipe.ZAdd(tableName, menbers); cmd != nil {
|
||||||
|
|
||||||
if cmd := pipe.ZAdd(tableName, menbers); cmd != nil {
|
dock, err1 := cmd.Result()
|
||||||
|
if err1 != nil {
|
||||||
dock, err1 := cmd.Result()
|
this.moduleViking.Errorln(dock, err1)
|
||||||
if err1 != nil {
|
}
|
||||||
this.moduleViking.Errorln(dock, err1)
|
}
|
||||||
|
if _, err := pipe.Exec(); err != nil {
|
||||||
|
this.moduleViking.Errorln(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, err := pipe.Exec(); err != nil {
|
|
||||||
this.moduleViking.Errorln(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user