房卡消耗记录

This commit is contained in:
sk 2024-08-28 09:12:01 +08:00
parent 17c0817dab
commit cae5536ed3
5 changed files with 61 additions and 49 deletions

View File

@ -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
}

View File

@ -95,4 +95,5 @@ type AddItemParam struct {
GameId, GameFreeId int64 // 游戏id,场次id
NoLog bool // 是否不记录日志
LogId string // 撤销的id,道具兑换失败
RoomConfigId int32 // 房间配置id
}

View File

@ -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
}

View File

@ -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)

View File

@ -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(),
})
})
}