添加竞技馆获奖记录查询接口

This commit is contained in:
sk 2024-09-23 16:43:35 +08:00
parent ef6236e3a8
commit df3c4d353e
12 changed files with 623 additions and 45 deletions

View File

@ -12,6 +12,7 @@ import (
)
func init() {
// 竞技馆对局记录
mq.RegisterSubscriber(mq.DBCustomLog, func(e broker.Event) (err error) {
msg := e.Message()
if msg != nil {
@ -33,4 +34,27 @@ func init() {
}
return nil
}, broker.Queue(mq.DBCustomLog), broker.DisableAutoAck(), rabbitmq.DurableQueue())
// 竞技馆奖励记录
mq.RegisterSubscriber(mq.DBCustomLogAward, func(e broker.Event) (err error) {
msg := e.Message()
if msg != nil {
defer func() {
e.Ack()
}()
var log model.CustomLogAward
err = json.Unmarshal(msg.Body, &log)
if err != nil {
return
}
c := svc.DbCustomLogAwardCollection(log.Platform)
if c != nil {
err = c.Insert(log)
}
return
}
return nil
}, broker.Queue(mq.DBCustomLogAward), broker.DisableAutoAck(), rabbitmq.DurableQueue())
}

View File

@ -0,0 +1,50 @@
package svc
import (
"errors"
"net/rpc"
"github.com/globalsign/mgo"
"go.mongodb.org/mongo-driver/bson"
"mongo.games.com/game/dbproxy/mongo"
"mongo.games.com/game/model"
)
var ErrCustomLogAwardNotFound = errors.New("CustomLogAward not found")
func DbCustomLogAwardCollection(plt string) *mongo.Collection {
s := mongo.MgoSessionMgrSington.GetPltMgoSession(plt, model.DbCustomLogAwardDBName)
if s != nil {
d, first := s.DB().C(model.DbCustomLogAwardCollName)
if first {
d.EnsureIndex(mgo.Index{Key: []string{"cycleid"}, Background: true, Sparse: true})
d.EnsureIndex(mgo.Index{Key: []string{"-startts", "cycleid"}, Background: true, Sparse: true})
d.EnsureIndex(mgo.Index{Key: []string{"startts"}, Background: true, Sparse: true})
d.EnsureIndex(mgo.Index{Key: []string{"endts"}, Background: true, Sparse: true})
d.EnsureIndex(mgo.Index{Key: []string{"-endts"}, Background: true, Sparse: true})
d.EnsureIndex(mgo.Index{Key: []string{"snid"}, Background: true, Sparse: true})
}
return d
}
return nil
}
type DBCustomLogAwardSvc struct {
}
func (this *DBCustomLogAwardSvc) Find(req *model.CustomLogAwardFindReq, res *model.CustomLogAwardFindRes) error {
c := DbCustomLogAwardCollection(req.Platform)
if c == nil {
return ErrCustomLogAwardNotFound
}
if err := c.Find(bson.M{"startts": bson.M{"$gte": req.StartTs, "$lte": req.EndTs}}).Sort("startts").All(&res.List); err != nil {
return err
}
return nil
}
func init() {
rpc.Register(new(DBCustomLogAwardSvc))
}

View File

@ -58,4 +58,5 @@ func init() {
LogChannelSingleton.RegisterLogCName(model.FriendRecordLogCollName, &model.FriendRecord{})
LogChannelSingleton.RegisterLogCName(model.ItemLogCollName, &model.ItemLog{})
LogChannelSingleton.RegisterLogCName(mq.DBCustomLog, &model.CustomLog{})
LogChannelSingleton.RegisterLogCName(mq.DBCustomLogAward, &model.CustomLogAward{})
}

View File

@ -2641,6 +2641,15 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
GameId: int64(sceneEx.GameId),
GameFreeId: int64(sceneEx.GetGameFreeId()),
})
base.LogChannelSingleton.WriteLog(&model.CustomLogAward{
Platform: p.Platform,
CycleId: sceneEx.CycleID,
SnId: p.SnId,
Name: p.GetName(),
Awards: items,
StartTs: sceneEx.GameStartTime.Unix(),
EndTs: time.Now().Unix(),
})
sceneEx.PlayerAward[p.SnId] = &items
}
}

View File

@ -1,8 +1,17 @@
package model
import (
"time"
"mongo.games.com/goserver/core/logger"
)
var (
DbCustomLogDBName = "log"
DbCustomLogCollName = "log_custom"
DbCustomLogAwardDBName = "log"
DbCustomLogAwardCollName = "log_customaward"
)
type PlayerInfo struct {
@ -34,3 +43,42 @@ type CustomLog struct {
StartTs, EndTs int64 // 开始,结束时间
State int32 // 0正常结束 1后台中途解散
}
// CustomLogAward 竞技馆玩家奖励记录
type CustomLogAward struct {
Platform string `bson:"-"`
CycleId string // 本轮id多局游戏属于同一轮
SnId int32
Name string
Awards []*Item
StartTs, EndTs int64 // 开始,结束时间
}
type CustomLogAwardFindReq struct {
Platform string
StartTs int64
EndTs int64
}
type CustomLogAwardFindRes struct {
List []*CustomLogAward
}
func CustomLogAwardFind(plt string, startTs, endTs int64) ([]*CustomLogAward, error) {
if rpcCli == nil {
logger.Logger.Error("model.CustomLogAwardFind rpcCli == nil")
return nil, nil
}
req := &CustomLogAwardFindReq{
Platform: plt,
StartTs: startTs,
EndTs: endTs,
}
res := &CustomLogAwardFindRes{}
if err := rpcCli.CallWithTimeout("DBCustomLogAwardSvc.Find", req, &res, time.Second*30); err != nil {
logger.Logger.Warn("DBCustomLogAwardSvc.Find error:", err)
return nil, err
}
return res.List, nil
}

View File

@ -84,6 +84,7 @@ type GameParam struct {
PermitInitScore int64 // 赛季通行证初始积分
GuideStepMaxNum int32 // 新手引导步骤最大值
GuideTs int64 // 新手引导时间戳,小于这个时间的玩家不显示新手引导
CustomAwardUpdateTime int // 竞技馆奖励更新时间
}
var GameParamPath = "../data/gameparam.json"
@ -217,4 +218,7 @@ func InitGameParam() {
if GameParamData.GuideTs == 0 {
GameParamData.GuideTs = 1724623200
}
if GameParamData.CustomAwardUpdateTime == 0 {
GameParamData.CustomAwardUpdateTime = 60
}
}

View File

@ -23,5 +23,6 @@ const (
const (
DBVipGiftLog = "db_vipgift"
DBCustomLog = "db_customlog" // 房卡场对局记录
DBCustomLog = "db_customlog" // 房卡场对局记录
DBCustomLogAward = "db_customlog_award" // 房卡场对局奖励
)

View File

@ -45,6 +45,9 @@ const (
//赛季通行证排行榜
Rank_PACKET_RANK_CSPermit Rank = 10012
Rank_PACKET_RANK_SCPermit Rank = 10013
// 竞技馆获奖记录
Rank_PACKET_CSRoomAward Rank = 10014
Rank_PACKET_SCRoomAward Rank = 10015
)
// Enum value maps for Rank.
@ -65,6 +68,8 @@ var (
10011: "PACKET_RANK_SCLevel",
10012: "PACKET_RANK_CSPermit",
10013: "PACKET_RANK_SCPermit",
10014: "PACKET_CSRoomAward",
10015: "PACKET_SCRoomAward",
}
Rank_value = map[string]int32{
"PACKET_RANK_ZERO": 0,
@ -82,6 +87,8 @@ var (
"PACKET_RANK_SCLevel": 10011,
"PACKET_RANK_CSPermit": 10012,
"PACKET_RANK_SCPermit": 10013,
"PACKET_CSRoomAward": 10014,
"PACKET_SCRoomAward": 10015,
}
)
@ -1789,6 +1796,260 @@ func (x *SCPermit) GetRankMaxNum() int32 {
return 0
}
//PACKET_CSRoomAward
type CSRoomAward struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Skip int32 `protobuf:"varint,1,opt,name=Skip,proto3" json:"Skip,omitempty"` // 偏移量
Limit int32 `protobuf:"varint,2,opt,name=Limit,proto3" json:"Limit,omitempty"` // 请求数量
}
func (x *CSRoomAward) Reset() {
*x = CSRoomAward{}
if protoimpl.UnsafeEnabled {
mi := &file_rank_proto_msgTypes[22]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CSRoomAward) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CSRoomAward) ProtoMessage() {}
func (x *CSRoomAward) ProtoReflect() protoreflect.Message {
mi := &file_rank_proto_msgTypes[22]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CSRoomAward.ProtoReflect.Descriptor instead.
func (*CSRoomAward) Descriptor() ([]byte, []int) {
return file_rank_proto_rawDescGZIP(), []int{22}
}
func (x *CSRoomAward) GetSkip() int32 {
if x != nil {
return x.Skip
}
return 0
}
func (x *CSRoomAward) GetLimit() int32 {
if x != nil {
return x.Limit
}
return 0
}
type Item struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` // 道具id
N int64 `protobuf:"varint,2,opt,name=N,proto3" json:"N,omitempty"` // 道具数量
}
func (x *Item) Reset() {
*x = Item{}
if protoimpl.UnsafeEnabled {
mi := &file_rank_proto_msgTypes[23]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Item) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Item) ProtoMessage() {}
func (x *Item) ProtoReflect() protoreflect.Message {
mi := &file_rank_proto_msgTypes[23]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Item.ProtoReflect.Descriptor instead.
func (*Item) Descriptor() ([]byte, []int) {
return file_rank_proto_rawDescGZIP(), []int{23}
}
func (x *Item) GetId() int32 {
if x != nil {
return x.Id
}
return 0
}
func (x *Item) GetN() int64 {
if x != nil {
return x.N
}
return 0
}
type UserAward struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Snid int32 `protobuf:"varint,1,opt,name=Snid,proto3" json:"Snid,omitempty"` // 玩家id
Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` // 昵称
Awards []*Item `protobuf:"bytes,3,rep,name=Awards,proto3" json:"Awards,omitempty"` // 奖品
Ts int64 `protobuf:"varint,4,opt,name=Ts,proto3" json:"Ts,omitempty"` // 获得时间
}
func (x *UserAward) Reset() {
*x = UserAward{}
if protoimpl.UnsafeEnabled {
mi := &file_rank_proto_msgTypes[24]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UserAward) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UserAward) ProtoMessage() {}
func (x *UserAward) ProtoReflect() protoreflect.Message {
mi := &file_rank_proto_msgTypes[24]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UserAward.ProtoReflect.Descriptor instead.
func (*UserAward) Descriptor() ([]byte, []int) {
return file_rank_proto_rawDescGZIP(), []int{24}
}
func (x *UserAward) GetSnid() int32 {
if x != nil {
return x.Snid
}
return 0
}
func (x *UserAward) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *UserAward) GetAwards() []*Item {
if x != nil {
return x.Awards
}
return nil
}
func (x *UserAward) GetTs() int64 {
if x != nil {
return x.Ts
}
return 0
}
//PACKET_SCRoomAward
type SCRoomAward struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
List []*UserAward `protobuf:"bytes,1,rep,name=List,proto3" json:"List,omitempty"`
Skip int32 `protobuf:"varint,2,opt,name=Skip,proto3" json:"Skip,omitempty"` // 偏移量
Limit int32 `protobuf:"varint,3,opt,name=Limit,proto3" json:"Limit,omitempty"` // 每页数量
Total int32 `protobuf:"varint,4,opt,name=Total,proto3" json:"Total,omitempty"` // 总数量
}
func (x *SCRoomAward) Reset() {
*x = SCRoomAward{}
if protoimpl.UnsafeEnabled {
mi := &file_rank_proto_msgTypes[25]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SCRoomAward) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SCRoomAward) ProtoMessage() {}
func (x *SCRoomAward) ProtoReflect() protoreflect.Message {
mi := &file_rank_proto_msgTypes[25]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SCRoomAward.ProtoReflect.Descriptor instead.
func (*SCRoomAward) Descriptor() ([]byte, []int) {
return file_rank_proto_rawDescGZIP(), []int{25}
}
func (x *SCRoomAward) GetList() []*UserAward {
if x != nil {
return x.List
}
return nil
}
func (x *SCRoomAward) GetSkip() int32 {
if x != nil {
return x.Skip
}
return 0
}
func (x *SCRoomAward) GetLimit() int32 {
if x != nil {
return x.Limit
}
return 0
}
func (x *SCRoomAward) GetTotal() int32 {
if x != nil {
return x.Total
}
return 0
}
var File_rank_proto protoreflect.FileDescriptor
var file_rank_proto_rawDesc = []byte{
@ -1954,44 +2215,67 @@ var file_rank_proto_rawDesc = []byte{
0x4e, 0x75, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x49, 0x73, 0x45, 0x6e, 0x64,
0x4e, 0x75, 0x6d, 0x12, 0x1e, 0x0a, 0x0a, 0x52, 0x61, 0x6e, 0x6b, 0x4d, 0x61, 0x78, 0x4e, 0x75,
0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x52, 0x61, 0x6e, 0x6b, 0x4d, 0x61, 0x78,
0x4e, 0x75, 0x6d, 0x2a, 0x94, 0x03, 0x0a, 0x04, 0x52, 0x61, 0x6e, 0x6b, 0x12, 0x14, 0x0a, 0x10,
0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x5a, 0x45, 0x52, 0x4f,
0x10, 0x00, 0x12, 0x1c, 0x0a, 0x17, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e,
0x4b, 0x5f, 0x43, 0x53, 0x52, 0x61, 0x6e, 0x6b, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x10, 0x90, 0x4e,
0x12, 0x1c, 0x0a, 0x17, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f,
0x53, 0x43, 0x52, 0x61, 0x6e, 0x6b, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x10, 0x91, 0x4e, 0x12, 0x17,
0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x43, 0x53,
0x43, 0x6f, 0x69, 0x6e, 0x10, 0x92, 0x4e, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45,
0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x53, 0x43, 0x43, 0x6f, 0x69, 0x6e, 0x10, 0x93, 0x4e,
0x4e, 0x75, 0x6d, 0x22, 0x37, 0x0a, 0x0b, 0x43, 0x53, 0x52, 0x6f, 0x6f, 0x6d, 0x41, 0x77, 0x61,
0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x53, 0x6b, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
0x52, 0x04, 0x53, 0x6b, 0x69, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x18,
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x24, 0x0a, 0x04,
0x49, 0x74, 0x65, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
0x52, 0x02, 0x49, 0x64, 0x12, 0x0c, 0x0a, 0x01, 0x4e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
0x01, 0x4e, 0x22, 0x67, 0x0a, 0x09, 0x55, 0x73, 0x65, 0x72, 0x41, 0x77, 0x61, 0x72, 0x64, 0x12,
0x12, 0x0a, 0x04, 0x53, 0x6e, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53,
0x6e, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x06, 0x41, 0x77, 0x61, 0x72, 0x64,
0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x72, 0x61, 0x6e, 0x6b, 0x2e, 0x49,
0x74, 0x65, 0x6d, 0x52, 0x06, 0x41, 0x77, 0x61, 0x72, 0x64, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x54,
0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x54, 0x73, 0x22, 0x72, 0x0a, 0x0b, 0x53,
0x43, 0x52, 0x6f, 0x6f, 0x6d, 0x41, 0x77, 0x61, 0x72, 0x64, 0x12, 0x23, 0x0a, 0x04, 0x4c, 0x69,
0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x61, 0x6e, 0x6b, 0x2e,
0x55, 0x73, 0x65, 0x72, 0x41, 0x77, 0x61, 0x72, 0x64, 0x52, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12,
0x12, 0x0a, 0x04, 0x53, 0x6b, 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53,
0x6b, 0x69, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01,
0x28, 0x05, 0x52, 0x05, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f, 0x74,
0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x2a,
0xc6, 0x03, 0x0a, 0x04, 0x52, 0x61, 0x6e, 0x6b, 0x12, 0x14, 0x0a, 0x10, 0x50, 0x41, 0x43, 0x4b,
0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x5a, 0x45, 0x52, 0x4f, 0x10, 0x00, 0x12, 0x1c,
0x0a, 0x17, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x43, 0x53,
0x52, 0x61, 0x6e, 0x6b, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x10, 0x90, 0x4e, 0x12, 0x1c, 0x0a, 0x17,
0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x53, 0x43, 0x52, 0x61,
0x6e, 0x6b, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x10, 0x91, 0x4e, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x41,
0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x43, 0x53, 0x43, 0x6f, 0x69, 0x6e,
0x10, 0x92, 0x4e, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41,
0x4e, 0x4b, 0x5f, 0x53, 0x43, 0x43, 0x6f, 0x69, 0x6e, 0x10, 0x93, 0x4e, 0x12, 0x19, 0x0a, 0x14,
0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x43, 0x53, 0x49, 0x6e,
0x76, 0x69, 0x74, 0x65, 0x10, 0x94, 0x4e, 0x12, 0x19, 0x0a, 0x14, 0x50, 0x41, 0x43, 0x4b, 0x45,
0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x53, 0x43, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x10,
0x95, 0x4e, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x43, 0x53, 0x49,
0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x6f, 0x67, 0x10, 0x96, 0x4e, 0x12, 0x17, 0x0a, 0x12, 0x50,
0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x6f,
0x67, 0x10, 0x97, 0x4e, 0x12, 0x1a, 0x0a, 0x15, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52,
0x41, 0x4e, 0x4b, 0x5f, 0x43, 0x53, 0x57, 0x69, 0x6e, 0x43, 0x6f, 0x69, 0x6e, 0x10, 0x98, 0x4e,
0x12, 0x1a, 0x0a, 0x15, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f,
0x53, 0x43, 0x57, 0x69, 0x6e, 0x43, 0x6f, 0x69, 0x6e, 0x10, 0x99, 0x4e, 0x12, 0x18, 0x0a, 0x13,
0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x43, 0x53, 0x4c, 0x65,
0x76, 0x65, 0x6c, 0x10, 0x9a, 0x4e, 0x12, 0x18, 0x0a, 0x13, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54,
0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x53, 0x43, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x10, 0x9b, 0x4e,
0x12, 0x19, 0x0a, 0x14, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f,
0x43, 0x53, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x10, 0x94, 0x4e, 0x12, 0x19, 0x0a, 0x14, 0x50,
0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x53, 0x43, 0x49, 0x6e, 0x76,
0x69, 0x74, 0x65, 0x10, 0x95, 0x4e, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54,
0x5f, 0x43, 0x53, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x6f, 0x67, 0x10, 0x96, 0x4e, 0x12,
0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x49, 0x6e, 0x76, 0x69,
0x74, 0x65, 0x4c, 0x6f, 0x67, 0x10, 0x97, 0x4e, 0x12, 0x1a, 0x0a, 0x15, 0x50, 0x41, 0x43, 0x4b,
0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x43, 0x53, 0x57, 0x69, 0x6e, 0x43, 0x6f, 0x69,
0x6e, 0x10, 0x98, 0x4e, 0x12, 0x1a, 0x0a, 0x15, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52,
0x41, 0x4e, 0x4b, 0x5f, 0x53, 0x43, 0x57, 0x69, 0x6e, 0x43, 0x6f, 0x69, 0x6e, 0x10, 0x99, 0x4e,
0x12, 0x18, 0x0a, 0x13, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f,
0x43, 0x53, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x10, 0x9a, 0x4e, 0x12, 0x18, 0x0a, 0x13, 0x50, 0x41,
0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x53, 0x43, 0x4c, 0x65, 0x76, 0x65,
0x6c, 0x10, 0x9b, 0x4e, 0x12, 0x19, 0x0a, 0x14, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52,
0x41, 0x4e, 0x4b, 0x5f, 0x43, 0x53, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x74, 0x10, 0x9c, 0x4e, 0x12,
0x19, 0x0a, 0x14, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x53,
0x43, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x74, 0x10, 0x9d, 0x4e, 0x2a, 0x8d, 0x01, 0x0a, 0x0a, 0x52,
0x61, 0x6e, 0x6b, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x12, 0x13, 0x0a, 0x0f, 0x49, 0x6e, 0x76,
0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x14,
0x0a, 0x10, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x54, 0x6f, 0x74,
0x61, 0x6c, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79,
0x70, 0x65, 0x5f, 0x57, 0x65, 0x65, 0x6b, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x49, 0x6e, 0x76,
0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4d, 0x6f, 0x6e, 0x74, 0x68, 0x10, 0x03, 0x12,
0x15, 0x0a, 0x11, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x55, 0x70,
0x57, 0x65, 0x65, 0x6b, 0x10, 0x04, 0x12, 0x12, 0x0a, 0x0e, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65,
0x54, 0x79, 0x70, 0x65, 0x5f, 0x4d, 0x61, 0x78, 0x10, 0x05, 0x42, 0x24, 0x5a, 0x22, 0x6d, 0x6f,
0x6e, 0x67, 0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61,
0x6d, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x72, 0x61, 0x6e, 0x6b,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x43, 0x53, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x74, 0x10, 0x9c, 0x4e, 0x12, 0x19, 0x0a, 0x14, 0x50,
0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x53, 0x43, 0x50, 0x65, 0x72,
0x6d, 0x69, 0x74, 0x10, 0x9d, 0x4e, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54,
0x5f, 0x43, 0x53, 0x52, 0x6f, 0x6f, 0x6d, 0x41, 0x77, 0x61, 0x72, 0x64, 0x10, 0x9e, 0x4e, 0x12,
0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x52, 0x6f, 0x6f, 0x6d,
0x41, 0x77, 0x61, 0x72, 0x64, 0x10, 0x9f, 0x4e, 0x2a, 0x8d, 0x01, 0x0a, 0x0a, 0x52, 0x61, 0x6e,
0x6b, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x12, 0x13, 0x0a, 0x0f, 0x49, 0x6e, 0x76, 0x69, 0x74,
0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10,
0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x54, 0x6f, 0x74, 0x61, 0x6c,
0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65,
0x5f, 0x57, 0x65, 0x65, 0x6b, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x49, 0x6e, 0x76, 0x69, 0x74,
0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4d, 0x6f, 0x6e, 0x74, 0x68, 0x10, 0x03, 0x12, 0x15, 0x0a,
0x11, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x55, 0x70, 0x57, 0x65,
0x65, 0x6b, 0x10, 0x04, 0x12, 0x12, 0x0a, 0x0e, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79,
0x70, 0x65, 0x5f, 0x4d, 0x61, 0x78, 0x10, 0x05, 0x42, 0x24, 0x5a, 0x22, 0x6d, 0x6f, 0x6e, 0x67,
0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65,
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x72, 0x61, 0x6e, 0x6b, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -2007,7 +2291,7 @@ func file_rank_proto_rawDescGZIP() []byte {
}
var file_rank_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
var file_rank_proto_msgTypes = make([]protoimpl.MessageInfo, 22)
var file_rank_proto_msgTypes = make([]protoimpl.MessageInfo, 26)
var file_rank_proto_goTypes = []interface{}{
(Rank)(0), // 0: rank.Rank
(RankInvite)(0), // 1: rank.RankInvite
@ -2033,6 +2317,10 @@ var file_rank_proto_goTypes = []interface{}{
(*CSPermit)(nil), // 21: rank.CSPermit
(*PermitRank)(nil), // 22: rank.PermitRank
(*SCPermit)(nil), // 23: rank.SCPermit
(*CSRoomAward)(nil), // 24: rank.CSRoomAward
(*Item)(nil), // 25: rank.Item
(*UserAward)(nil), // 26: rank.UserAward
(*SCRoomAward)(nil), // 27: rank.SCRoomAward
}
var file_rank_proto_depIdxs = []int32{
3, // 0: rank.SCRankMatch.Ranks:type_name -> rank.SeasonRank
@ -2048,11 +2336,13 @@ var file_rank_proto_depIdxs = []int32{
19, // 10: rank.SCPlayerLevelRank.Me:type_name -> rank.PlayerLevelRankInfo
22, // 11: rank.SCPermit.Ranks:type_name -> rank.PermitRank
22, // 12: rank.SCPermit.Me:type_name -> rank.PermitRank
13, // [13:13] is the sub-list for method output_type
13, // [13:13] is the sub-list for method input_type
13, // [13:13] is the sub-list for extension type_name
13, // [13:13] is the sub-list for extension extendee
0, // [0:13] is the sub-list for field type_name
25, // 13: rank.UserAward.Awards:type_name -> rank.Item
26, // 14: rank.SCRoomAward.List:type_name -> rank.UserAward
15, // [15:15] is the sub-list for method output_type
15, // [15:15] is the sub-list for method input_type
15, // [15:15] is the sub-list for extension type_name
15, // [15:15] is the sub-list for extension extendee
0, // [0:15] is the sub-list for field type_name
}
func init() { file_rank_proto_init() }
@ -2325,6 +2615,54 @@ func file_rank_proto_init() {
return nil
}
}
file_rank_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CSRoomAward); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_rank_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Item); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_rank_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UserAward); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_rank_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SCRoomAward); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -2332,7 +2670,7 @@ func file_rank_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_rank_proto_rawDesc,
NumEnums: 2,
NumMessages: 22,
NumMessages: 26,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -25,6 +25,9 @@ enum Rank{
//
PACKET_RANK_CSPermit = 10012;
PACKET_RANK_SCPermit = 10013;
//
PACKET_CSRoomAward = 10014;
PACKET_SCRoomAward = 10015;
}
//
@ -207,4 +210,30 @@ message SCPermit{
int32 Skip = 3; //
bool IsEndNum = 4;
int32 RankMaxNum = 5; //
}
//PACKET_CSRoomAward
message CSRoomAward{
int32 Skip = 1; //
int32 Limit = 2; //
}
message Item{
int32 Id = 1; // id
int64 N = 2; //
}
message UserAward{
int32 Snid = 1; // id
string Name = 2; //
repeated Item Awards = 3; //
int64 Ts = 4; //
}
//PACKET_SCRoomAward
message SCRoomAward{
repeated UserAward List = 1;
int32 Skip = 2; //
int32 Limit = 3; //
int32 Total = 4; //
}

View File

@ -28,6 +28,8 @@ func init() {
com.Register(int(rankproto.Rank_PACKET_RANK_CSLevel), rankproto.CSPlayerLevelRank{}, CSPlayerLevelRank)
// 赛季通行证积分排行
com.Register(int(rankproto.Rank_PACKET_RANK_CSPermit), rankproto.CSPermit{}, CSPermit)
// 竞技馆获奖记录
com.Register(int(rankproto.Rank_PACKET_CSRoomAward), rankproto.CSRoomAward{}, CSRoomAward)
}
func CSRankMatch(s *netlib.Session, d *rankproto.GateTransmit, packetId int, data interface{}, sid int64) error {
@ -545,3 +547,48 @@ func CSPermit(s *netlib.Session, d *rankproto.GateTransmit, packetId int, data i
})
return nil
}
func CSRoomAward(s *netlib.Session, d *rankproto.GateTransmit, packetId int, data interface{}, sid int64) error {
logger.Logger.Trace("CSRoomAward data:", data)
msg, ok := data.(*rankproto.CSRoomAward)
if !ok {
return nil
}
rank.CustomAwardMgrInstance.Take(d.Platform, 0, func(list []*model.CustomLogAward, err error) {
if err != nil {
logger.Logger.Errorf("CSRoomAward error: %v", err)
return
}
start, end := com.SkipLimitToStartEnd(msg.GetSkip(), msg.GetLimit(), len(list))
var ranks []*rankproto.UserAward
if end > start && int(start) < len(list) {
for _, v := range list[start:end] {
r := &rankproto.UserAward{
Snid: v.SnId,
Name: v.Name,
Ts: v.EndTs,
}
for _, vv := range v.Awards {
r.Awards = append(r.Awards, &rankproto.Item{
Id: vv.ItemId,
N: vv.ItemNum,
})
}
ranks = append(ranks, r)
}
}
pack := &rankproto.SCRoomAward{
List: ranks,
Skip: start,
Limit: msg.GetLimit(),
Total: int32(len(list)),
}
common.SendToGate(sid, int(rankproto.Rank_PACKET_SCRoomAward), pack, s)
logger.Logger.Tracef("SCRoomAward: %v", pack)
})
return nil
}

View File

@ -8,6 +8,9 @@ import (
"mongo.games.com/goserver/core/task"
)
// NewListMgr 创建一个列表管理器
// cacheTime 缓存时间,单位秒
// loadFunc 加载函数
func NewListMgr[T any](cacheTime func() int64, loadFunc func(platform string, index int32) ([]T, error)) *ListMgr[T] {
return &ListMgr[T]{
platform: make(map[string]map[int32]*DataItem[T]),

View File

@ -0,0 +1,24 @@
package rank
import (
"time"
"github.com/jinzhu/now"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/game/model"
"mongo.games.com/game/ranksrv/com"
)
var CustomAwardMgrInstance = com.NewListMgr[*model.CustomLogAward](
func() int64 {
return int64(model.GameParamData.CustomAwardUpdateTime)
},
func(platform string, index int32) ([]*model.CustomLogAward, error) {
// 当天数据
startTs := now.BeginningOfDay().Unix()
endTs := startTs + 24*int64(time.Hour.Seconds())
logger.Logger.Tracef("load custom award platform:%s startTs:%v endTs:%v", platform, startTs, endTs)
ret, err := model.CustomLogAwardFind(platform, startTs, endTs)
return ret, err
})