diff --git a/dbproxy/svc/l_itemlog.go b/dbproxy/svc/l_itemlog.go index 521675a..3606e7e 100644 --- a/dbproxy/svc/l_itemlog.go +++ b/dbproxy/svc/l_itemlog.go @@ -30,6 +30,7 @@ func ItemLogsCollection(plt string) *mongo.Collection { c_itemlog.EnsureIndex(mgo.Index{Key: []string{"typeid", "roomconfigid"}, Background: true, Sparse: true}) c_itemlog.EnsureIndex(mgo.Index{Key: []string{"ts"}, Background: true, Sparse: true}) c_itemlog.EnsureIndex(mgo.Index{Key: []string{"-ts"}, Background: true, Sparse: true}) + c_itemlog.EnsureIndex(mgo.Index{Key: []string{"gamedif"}, Background: true, Sparse: true}) } return c_itemlog } diff --git a/model/itemdatalog.go b/model/itemdatalog.go index 9cf73e7..16415d4 100644 --- a/model/itemdatalog.go +++ b/model/itemdatalog.go @@ -28,6 +28,7 @@ type ItemLog struct { TypeId int32 // 变化类型 GameId int64 // 游戏id,游戏中获得时有值 GameFreeId int64 // 场次id,游戏中获得时有值 + GameDif string // 游戏分组 Cost []*Item // 消耗的道具 Id string // 撤销的id,兑换失败 RoomConfigId int32 // 房间配置id @@ -50,6 +51,7 @@ type ItemParam struct { TypeId int32 // 变化类型 GameId int64 // 游戏id,游戏中获得时有值 GameFreeId int64 // 场次id,游戏中获得时有值 + GameDif string // 游戏分组 Cost []*Item // 消耗的道具 LogId string // 撤销的id,兑换失败 RoomConfigId int32 // 房间配置id @@ -71,6 +73,7 @@ func NewItemLogEx(param ItemParam) *ItemLog { itemLog.TypeId = param.TypeId itemLog.GameId = param.GameId itemLog.GameFreeId = param.GameFreeId + itemLog.GameDif = param.GameDif itemLog.Cost = param.Cost itemLog.Id = param.LogId itemLog.RoomConfigId = param.RoomConfigId @@ -246,7 +249,7 @@ type InsertItemLogReq struct { Logs []*ItemLog } -func InsertItemLog(configItems map[int32]*server.DB_GameItem, param *AddItemParam, isOffline bool) error { +func InsertItemLog(configItems map[int32]*server.DB_GameItem, param *AddItemParam, gamedif string, isOffline bool) error { if rpcCli == nil { logger.Logger.Warnf("rpcCli is nil") return errors.New("rpcCli is nil") @@ -280,6 +283,7 @@ func InsertItemLog(configItems map[int32]*server.DB_GameItem, param *AddItemPara TypeId: param.GainWay, GameId: param.GameId, GameFreeId: param.GameFreeId, + GameDif: gamedif, Cost: param.Cost, LogId: param.LogId, RoomConfigId: param.RoomConfigId, diff --git a/worldsrv/bagmgr.go b/worldsrv/bagmgr.go index cf1aeae..eb2ad7e 100644 --- a/worldsrv/bagmgr.go +++ b/worldsrv/bagmgr.go @@ -690,6 +690,15 @@ func (this *BagMgr) AddItems(param *model.AddItemParam) (*BagInfo, bag.OpResultC logType = ItemConsume num = -v.ItemNum } + gamedif := "" + plt := PlatformMgrSingleton.GetPlatform(p.Platform) + if plt != nil { + gf := plt.GameConfig.GetGameConfig(int32(param.GameFreeId)) + if gf != nil { + gamedif = gf.GetDbGameFree().GetGameDif() + } + } + // 日志 log := model.NewItemLogEx(model.ItemParam{ Platform: p.Platform, @@ -702,6 +711,7 @@ func (this *BagMgr) AddItems(param *model.AddItemParam) (*BagInfo, bag.OpResultC TypeId: param.GainWay, GameId: param.GameId, GameFreeId: param.GameFreeId, + GameDif: gamedif, Cost: param.Cost, LogId: param.LogId, RoomConfigId: param.RoomConfigId, @@ -765,6 +775,15 @@ func (this *BagMgr) AddItemsOffline(param *model.AddItemParam, callback func(err return } + gamedif := "" + plt := PlatformMgrSingleton.GetPlatform(param.Platform) + if plt != nil && param.GameFreeId > 0 { + gf := plt.GameConfig.GetGameConfig(int32(param.GameFreeId)) + if gf != nil { + gamedif = gf.GetDbGameFree().GetGameDif() + } + } + // 玩家离线时 var findPlayer *model.PlayerBaseInfo task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { @@ -793,7 +812,7 @@ func (this *BagMgr) AddItemsOffline(param *model.AddItemParam, callback func(err return err } // 保存日志 - if err := model.InsertItemLog(srvdata.GameItemMgr.GetItems(param.Platform), param, true); err != nil { + if err := model.InsertItemLog(srvdata.GameItemMgr.GetItems(param.Platform), param, gamedif, true); err != nil { logger.Logger.Errorf("离线保存道具变更日志错误 %v", err) return err }