From cae5536ed35b130de95133a529307da18c34bc3c Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Wed, 28 Aug 2024 09:12:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E5=8D=A1=E6=B6=88=E8=80=97=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbproxy/svc/l_itemlog.go | 2 ++ model/baginfo.go | 1 + model/itemdatalog.go | 55 +++++++++++++++++++------------------ worldsrv/bagmgr.go | 37 ++++++++++++++----------- worldsrv/scenepolicydata.go | 15 +++++----- 5 files changed, 61 insertions(+), 49 deletions(-) diff --git a/dbproxy/svc/l_itemlog.go b/dbproxy/svc/l_itemlog.go index 4fda8b7..49811bb 100644 --- a/dbproxy/svc/l_itemlog.go +++ b/dbproxy/svc/l_itemlog.go @@ -26,6 +26,8 @@ func ItemLogsCollection(plt string) *mongo.Collection { c_itemlog.EnsureIndex(mgo.Index{Key: []string{"gameid"}, Background: true, Sparse: true}) c_itemlog.EnsureIndex(mgo.Index{Key: []string{"gamefreeid"}, Background: true, Sparse: true}) c_itemlog.EnsureIndex(mgo.Index{Key: []string{"snid", "logtype", "itemid", "typeid"}, Background: true, Sparse: true}) + c_itemlog.EnsureIndex(mgo.Index{Key: []string{"roomconfigid"}, Background: true, Sparse: true}) + c_itemlog.EnsureIndex(mgo.Index{Key: []string{"typeid", "roomconfigid"}, Background: true, Sparse: true}) } return c_itemlog } diff --git a/model/baginfo.go b/model/baginfo.go index 00a1698..86a325c 100644 --- a/model/baginfo.go +++ b/model/baginfo.go @@ -95,4 +95,5 @@ type AddItemParam struct { GameId, GameFreeId int64 // 游戏id,场次id NoLog bool // 是否不记录日志 LogId string // 撤销的id,道具兑换失败 + RoomConfigId int32 // 房间配置id } diff --git a/model/itemdatalog.go b/model/itemdatalog.go index a6cd9ab..b4a96b4 100644 --- a/model/itemdatalog.go +++ b/model/itemdatalog.go @@ -14,20 +14,21 @@ var ( ) type ItemLog struct { - LogId bson.ObjectId `bson:"_id"` - Platform string //平台 - SnId int32 //玩家id - LogType int32 //记录类型 0.获取 1.消耗 - ItemId int32 //道具id - ItemName string //道具名称 - Count int64 //个数 - CreateTs int64 //记录时间 - Remark string //备注 - TypeId int32 // 变化类型 - GameId int32 // 游戏id,游戏中获得时有值 - GameFreeId int32 // 场次id,游戏中获得时有值 - Cost []*Item // 消耗的道具 - Id string // 撤销的id,兑换失败 + LogId bson.ObjectId `bson:"_id"` + Platform string //平台 + SnId int32 //玩家id + LogType int32 //记录类型 0.获取 1.消耗 + ItemId int32 //道具id + ItemName string //道具名称 + Count int64 //个数 + CreateTs int64 //记录时间 + Remark string //备注 + TypeId int32 // 变化类型 + GameId int32 // 游戏id,游戏中获得时有值 + GameFreeId int32 // 场次id,游戏中获得时有值 + Cost []*Item // 消耗的道具 + Id string // 撤销的id,兑换失败 + RoomConfigId int32 // 房间配置id } func NewItemLog() *ItemLog { @@ -36,18 +37,19 @@ func NewItemLog() *ItemLog { } type ItemParam struct { - Platform string // 平台 - SnId int32 // 玩家id - LogType int32 // 记录类型 0.获取 1.消耗 - ItemId int32 // 道具id - ItemName string // 道具名称 - Count int64 // 个数 - Remark string // 备注 - TypeId int32 // 变化类型 - GameId int64 // 游戏id,游戏中获得时有值 - GameFreeId int64 // 场次id,游戏中获得时有值 - Cost []*Item // 消耗的道具 - LogId string // 撤销的id,兑换失败 + Platform string // 平台 + SnId int32 // 玩家id + LogType int32 // 记录类型 0.获取 1.消耗 + ItemId int32 // 道具id + ItemName string // 道具名称 + Count int64 // 个数 + Remark string // 备注 + TypeId int32 // 变化类型 + GameId int64 // 游戏id,游戏中获得时有值 + GameFreeId int64 // 场次id,游戏中获得时有值 + Cost []*Item // 消耗的道具 + LogId string // 撤销的id,兑换失败 + RoomConfigId int32 // 房间配置id } func NewItemLogEx(param ItemParam) *ItemLog { @@ -65,6 +67,7 @@ func NewItemLogEx(param ItemParam) *ItemLog { itemLog.GameFreeId = int32(param.GameFreeId) itemLog.Cost = param.Cost itemLog.Id = param.LogId + itemLog.RoomConfigId = param.RoomConfigId return itemLog } diff --git a/worldsrv/bagmgr.go b/worldsrv/bagmgr.go index e770f5f..20c0f48 100644 --- a/worldsrv/bagmgr.go +++ b/worldsrv/bagmgr.go @@ -155,8 +155,9 @@ type ItemParam struct { } type AddItemParam struct { - Cost []*model.Item // 获得道具时消耗的道具数量 - LogId string + Cost []*model.Item // 获得道具时消耗的道具数量 + LogId string + RoomConfigId int32 } func (this *BagMgr) AddItemsV2(args *model.AddItemParam) (*BagInfo, bag.OpResultCode, bool) { @@ -176,8 +177,9 @@ func (this *BagMgr) AddItemsV2(args *model.AddItemParam) (*BagInfo, bag.OpResult }) } return this.AddItems(p, items, args.Add, args.GainWay, args.Operator, args.Remark, args.GameId, args.GameFreeId, args.NoLog, AddItemParam{ - Cost: costs, - LogId: args.LogId, + Cost: costs, + LogId: args.LogId, + RoomConfigId: args.RoomConfigId, }) } @@ -194,9 +196,11 @@ func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int gameId, gameFreeId int64, noLog bool, params ...AddItemParam) (*BagInfo, bag.OpResultCode, bool) { var cost []*model.Item var id string + var roomConfigId int32 if len(params) > 0 { cost = params[0].Cost id = params[0].LogId + roomConfigId = params[0].RoomConfigId } var items []*Item @@ -325,18 +329,19 @@ func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int num = -v.ItemNum } log := model.NewItemLogEx(model.ItemParam{ - Platform: p.Platform, - SnId: p.SnId, - LogType: int32(logType), - ItemId: v.ItemId, - ItemName: item.Name, - Count: num, - Remark: remark, - TypeId: gainWay, - GameId: gameId, - GameFreeId: gameFreeId, - Cost: cost, - LogId: id, + Platform: p.Platform, + SnId: p.SnId, + LogType: int32(logType), + ItemId: v.ItemId, + ItemName: item.Name, + Count: num, + Remark: remark, + TypeId: gainWay, + GameId: gameId, + GameFreeId: gameFreeId, + Cost: cost, + LogId: id, + RoomConfigId: roomConfigId, }) if log != nil { LogChannelSingleton.WriteLog(log) diff --git a/worldsrv/scenepolicydata.go b/worldsrv/scenepolicydata.go index bfe8748..130ab55 100644 --- a/worldsrv/scenepolicydata.go +++ b/worldsrv/scenepolicydata.go @@ -123,13 +123,14 @@ func (spd *ScenePolicyData) CostEnough(costType, playerNum int, roomConfig *weba func (spd *ScenePolicyData) CostPayment(s *Scene, p *Player) bool { return spd.costEnough(s.RoomCostType, s.playerNum, s.RoomConfig, p, func(items []*model.Item) { BagMgrSingleton.AddItemsV2(&model.AddItemParam{ - P: p.PlayerData, - Change: items, - GainWay: common.GainWayRoomCost, - Operator: "system", - Remark: "竞技馆进房费用", - GameId: int64(s.gameId), - GameFreeId: int64(s.dbGameFree.GetId()), + P: p.PlayerData, + Change: items, + GainWay: common.GainWayRoomCost, + Operator: "system", + Remark: "竞技馆进房费用", + GameId: int64(s.gameId), + GameFreeId: int64(s.dbGameFree.GetId()), + RoomConfigId: s.RoomConfig.GetId(), }) }) }