维京优化
This commit is contained in:
parent
f9d974a6c3
commit
d5f642d0dc
@ -322,5 +322,11 @@
|
||||
"open": true,
|
||||
"routrules": "~/worker",
|
||||
"describe": "公会活跃度列表"
|
||||
},
|
||||
{
|
||||
"msgid": "viking.ranklist",
|
||||
"open": true,
|
||||
"routrules": "~/worker",
|
||||
"describe": "维京排行榜数据"
|
||||
}
|
||||
]
|
@ -3,7 +3,6 @@ package gourmet
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@ -26,9 +25,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.GourmetGetListRe
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
if _gourmet.Ctime == 0 {
|
||||
_gourmet.Ctime = configure.Now().Unix()
|
||||
}
|
||||
|
||||
// 计算订单信息
|
||||
this.module.modelGourmet.CalculationGourmet(session.GetUserId(), _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
|
||||
}
|
||||
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) // 当前过去的时间
|
||||
if costTime < 0 { // 没有完成 不做处理
|
||||
if costTime < 0 { // 没有完成 不做处理
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -148,7 +148,7 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
|
||||
bCooking = true
|
||||
|
||||
// 记录下订单时间
|
||||
gourmet.Ctime = configure.Now().Unix()
|
||||
gourmet.Ctime = gourmet.CookingFood.ETime
|
||||
mapData["ctime"] = gourmet.Ctime
|
||||
break
|
||||
}
|
||||
|
@ -5,7 +5,9 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/sys/db"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"google.golang.org/protobuf/proto"
|
||||
@ -121,7 +123,9 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
||||
mapRankData["Leadpos"] = Leadpos
|
||||
mapRankData["line"] = szLine
|
||||
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
|
||||
bFind = true
|
||||
break
|
||||
@ -142,7 +146,9 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
||||
CostTime: costTime,
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/redis/pipe"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/db"
|
||||
"strconv"
|
||||
|
||||
"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 {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
|
||||
if !req.Friend {
|
||||
if !this.module.IsCross() {
|
||||
if conn, err := db.Local(); err == nil {
|
||||
var (
|
||||
pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
|
||||
)
|
||||
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 {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
_dataList := rd.Val()
|
||||
for _, v := range _dataList {
|
||||
result := &pb.DBVikingRank{}
|
||||
if err = this.module.modulerank.GetListObj(session.GetUserId(), v, result); err == nil {
|
||||
szRank = append(szRank, result)
|
||||
}
|
||||
}
|
||||
if _, err := pipe.Exec(); err != nil {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
_dataList := rd.Val()
|
||||
for _, v := range _dataList {
|
||||
result := &pb.DBVikingRank{}
|
||||
if err := this.module.modulerank.GetListObj(session.GetUserId(), v, result); err == nil {
|
||||
szRank = append(szRank, result)
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
uids := this.friend.GetFriendList(session.GetUserId())
|
||||
for _, id := range uids {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"go_dreamfactory/lego/sys/redis/pipe"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/db"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
)
|
||||
@ -61,24 +62,28 @@ func (this *ModelRank) getVikingRankListByBossType(uid string, bossType int32) *
|
||||
return nil
|
||||
}
|
||||
|
||||
// 排行数据写跨服
|
||||
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 (
|
||||
pipe *pipe.RedisPipe = this.DBModel.Redis.RedisPipe(context.TODO())
|
||||
menbers *redis.Z
|
||||
)
|
||||
menbers = &redis.Z{Score: float64(score), Member: uid}
|
||||
|
||||
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 {
|
||||
this.moduleViking.Errorln(dock, err1)
|
||||
dock, err1 := cmd.Result()
|
||||
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