From 5ac106365e9741bceca1527e7744651713fc77dc Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Thu, 12 Sep 2024 15:03:59 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=81=93=E5=85=B7=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbproxy/svc/l_itemlog.go | 13 + model/baginfo.go | 14 +- model/itemdatalog.go | 38 +- worldsrv/action_bag.go | 117 ++++- worldsrv/action_pets.go | 92 +++- worldsrv/action_phonelottery.go | 26 +- worldsrv/action_player.go | 2 +- worldsrv/action_rankmatch.go | 20 +- worldsrv/action_server.go | 2 +- worldsrv/action_task.go | 15 +- worldsrv/action_welfare.go | 36 +- worldsrv/bagmgr.go | 888 +++++++++++++++++--------------- worldsrv/player.go | 265 ++-------- worldsrv/playercache.go | 4 +- worldsrv/scenepolicydata.go | 21 +- worldsrv/shopmgr.go | 115 +++-- worldsrv/tournament.go | 51 +- worldsrv/trascate_webapi.go | 72 +-- worldsrv/welfmgr.go | 20 +- 19 files changed, 1019 insertions(+), 792 deletions(-) diff --git a/dbproxy/svc/l_itemlog.go b/dbproxy/svc/l_itemlog.go index 49811bb..d338787 100644 --- a/dbproxy/svc/l_itemlog.go +++ b/dbproxy/svc/l_itemlog.go @@ -113,6 +113,19 @@ func (svc *ItemLogSvc) UpdateState(req *model.UpdateParam, res *model.UpdateRes) return err } +func (svc *ItemLogSvc) GetItemLog(req *model.GetItemLogParam, res *model.GetItemLogRes) error { + c := ItemLogsCollection(req.Plt) + if c == nil { + return nil + } + + err := c.Find(bson.M{"snid": req.SnId, "createts": bson.M{"$gt": req.Ts}}).Sort("createts").All(&res.Logs) + if err != nil && !errors.Is(err, mgo.ErrNotFound) { + return err + } + return nil +} + func init() { rpc.Register(new(ItemLogSvc)) } diff --git a/model/baginfo.go b/model/baginfo.go index 86a325c..cc16aff 100644 --- a/model/baginfo.go +++ b/model/baginfo.go @@ -13,7 +13,8 @@ type BagInfo struct { SnId int32 //玩家账号直接在这里生成 Platform string //平台 BagItem map[int32]*Item //背包数据 key为itemId - GainWay int32 `bson:"-"` + Ts int64 + GainWay int32 `bson:"-"` } type Item struct { @@ -97,3 +98,14 @@ type AddItemParam struct { LogId string // 撤销的id,道具兑换失败 RoomConfigId int32 // 房间配置id } + +type ChangeItemParam struct { + SnId int32 + ItemId int32 + ItemNum int64 + GainWay int32 + RoomConfigId int32 + GameId int64 + GameFreeId int64 + Cost []*Item +} diff --git a/model/itemdatalog.go b/model/itemdatalog.go index b4a96b4..14cc378 100644 --- a/model/itemdatalog.go +++ b/model/itemdatalog.go @@ -24,8 +24,8 @@ type ItemLog struct { CreateTs int64 //记录时间 Remark string //备注 TypeId int32 // 变化类型 - GameId int32 // 游戏id,游戏中获得时有值 - GameFreeId int32 // 场次id,游戏中获得时有值 + GameId int64 // 游戏id,游戏中获得时有值 + GameFreeId int64 // 场次id,游戏中获得时有值 Cost []*Item // 消耗的道具 Id string // 撤销的id,兑换失败 RoomConfigId int32 // 房间配置id @@ -63,8 +63,8 @@ func NewItemLogEx(param ItemParam) *ItemLog { itemLog.CreateTs = time.Now().Unix() itemLog.Remark = param.Remark itemLog.TypeId = param.TypeId - itemLog.GameId = int32(param.GameId) - itemLog.GameFreeId = int32(param.GameFreeId) + itemLog.GameId = param.GameId + itemLog.GameFreeId = param.GameFreeId itemLog.Cost = param.Cost itemLog.Id = param.LogId itemLog.RoomConfigId = param.RoomConfigId @@ -118,3 +118,33 @@ func UpdateItemState(param *UpdateParam) error { return err } + +type GetItemLogParam struct { + Plt string + SnId int32 + Ts int64 +} + +type GetItemLogRes struct { + Logs []*ItemLog +} + +func GetItemLog(plt string, snid int32, ts int64) ([]*ItemLog, error) { + if rpcCli == nil { + logger.Logger.Warnf("rpcCli is nil") + return nil, errors.New("rpcCli is nil") + } + + var ret GetItemLogRes + err := rpcCli.CallWithTimeout("ItemLogSvc.GetItemLog", &GetItemLogParam{ + Plt: plt, + SnId: snid, + Ts: ts, + }, &ret, time.Second*30) + if err != nil { + logger.Logger.Errorf("GetItemLog err:%v", err) + return nil, err + } + + return ret.Logs, nil +} diff --git a/worldsrv/action_bag.go b/worldsrv/action_bag.go index 1975421..e5bdb7d 100644 --- a/worldsrv/action_bag.go +++ b/worldsrv/action_bag.go @@ -70,11 +70,17 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e if common.Config.IsDevMode { if msg.GetOpt() == -1 { - items := []*Item{{ + items := []*model.Item{{ ItemId: msg.ItemId, ItemNum: int64(msg.ItemNum), }} - BagMgrSingleton.AddItems(p, items, 0, common.GainWay_ItemUse, "system", "测试", 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: items, + GainWay: common.GainWay_ItemUse, + Operator: "system", + Remark: "测试", + }) return nil } } @@ -110,7 +116,7 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e case ItemCanUse: logger.Logger.Trace("道具使用", msg.ItemId) - items := map[int32]*Item{} + items := map[int32]*model.Item{} var useFunc func() saleFunc := func(gainWay int32, oper, remark string) { if gainWay == 0 { @@ -123,7 +129,18 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e remark = "道具使用" } // 使用道具,减少道具 - BagMgrSingleton.AddItem(p, int64(item.ItemId), int64(-msg.ItemNum), 0, gainWay, oper, remark, 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: item.ItemId, + ItemNum: int64(-msg.ItemNum), + }, + }, + GainWay: gainWay, + Operator: oper, + Remark: remark, + }) pack.RetCode = bag.OpResultCode_OPRC_Sucess pack.NowItemId = item.ItemId pack.NowItemNum = item.ItemNum @@ -142,11 +159,17 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e remark = "道具使用" } if len(items) > 0 { - var itemArr []*Item + var itemArr []*model.Item for _, v := range items { itemArr = append(itemArr, v) } - BagMgrSingleton.AddItems(p, itemArr, 0, gainWay, oper, remark, 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: itemArr, + GainWay: gainWay, + Operator: oper, + Remark: remark, + }) for _, v := range itemArr { pack.Infos = append(pack.Infos, &bag.ItemInfo{ ItemId: v.ItemId, @@ -189,7 +212,7 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e if vv > 0 { item, ok := items[int32(k)] if !ok { - items[int32(k)] = &Item{ + items[int32(k)] = &model.Item{ ItemId: int32(k), ItemNum: vv, ObtainTime: ts, @@ -223,7 +246,7 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e if vv > 0 { item, ok := items[int32(k)] if !ok { - items[int32(k)] = &Item{ + items[int32(k)] = &model.Item{ ItemId: int32(k), ItemNum: vv, ObtainTime: ts, @@ -251,8 +274,18 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e logger.Logger.Trace("道具赠送成功", msg.ItemId) remark := fmt.Sprintf("赠送给玩家(%v)", msg.AcceptSnId) BagMgrSingleton.AddMailByItem(p.Platform, p.SnId, p.Name, msg.AcceptSnId, msg.ShowId, []int32{msg.ItemId, msg.ItemNum}) - BagMgrSingleton.AddItem(p, int64(item.ItemId), int64(-msg.ItemNum), 0, common.GainWay_ItemMove, - "player", remark, 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: item.ItemId, + ItemNum: int64(-msg.ItemNum), + }, + }, + GainWay: common.GainWay_ItemMove, + Operator: "player", + Remark: remark, + }) pack.RetCode = bag.OpResultCode_OPRC_Sucess pack.NowItemId = msg.ItemId pack.NowItemNum = item.ItemNum @@ -265,8 +298,18 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e logger.Logger.Trace("道具赠送成功", msg.ItemId) remark := fmt.Sprintf("赠送给玩家(%v)", msg.AcceptSnId) BagMgrSingleton.AddMailByItem(p.Platform, p.SnId, p.Name, msg.AcceptSnId, msg.ShowId, []int32{msg.ItemId, msg.ItemNum}) - BagMgrSingleton.AddItem(p, int64(item.ItemId), int64(-msg.ItemNum), 0, common.GainWay_ItemMove, - "player", remark, 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: item.ItemId, + ItemNum: int64(-msg.ItemNum), + }, + }, + GainWay: common.GainWay_ItemMove, + Operator: "player", + Remark: remark, + }) pack.RetCode = bag.OpResultCode_OPRC_Sucess pack.NowItemId = msg.ItemId pack.NowItemNum = item.ItemNum @@ -282,7 +325,18 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e logger.Logger.Trace("道具出售", msg.ItemId) if msg.ItemNum > 0 { remark := "道具出售" + fmt.Sprintf("%v-%v", msg.ItemId, msg.ItemNum) - _, _, isF := BagMgrSingleton.AddItem(p, int64(msg.ItemId), int64(-msg.ItemNum), 0, common.GainWay_Item_Sale, "sys", remark, 0, 0, false) + _, _, isF := BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: item.ItemId, + ItemNum: int64(-msg.ItemNum), + }, + }, + GainWay: common.GainWay_Item_Sale, + Operator: "player", + Remark: remark, + }) if isF { pack.RetCode = bag.OpResultCode_OPRC_Sucess if item.SaleGold > 0 { @@ -308,7 +362,7 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e send() return nil } - bagInfo, _, isF := BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + bagInfo, _, isF := BagMgrSingleton.AddItems(&model.AddItemParam{ P: p.PlayerData, Change: []*model.Item{ { @@ -333,7 +387,7 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e logger.Logger.Trace("道具分解", msg.ItemId) itemInfo := srvdata.GameItemMgr.Get(p.Platform, msg.ItemId) if msg.ItemNum > 0 && itemInfo != nil { - _, _, isF := BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + _, _, isF := BagMgrSingleton.AddItems(&model.AddItemParam{ P: p.PlayerData, Change: []*model.Item{ { @@ -357,7 +411,7 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e }) } } - BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + BagMgrSingleton.AddItems(&model.AddItemParam{ P: p.PlayerData, Change: changeItems, Cost: []*model.Item{ @@ -451,8 +505,8 @@ func CSPropExchange(s *netlib.Session, packetid int, data interface{}, sid int64 return nil } // 检查背包是否足够 - var items []*Item - var costItems []*Item + var items []*model.Item + var costItems []*model.Item for k, v := range info.GetCost() { item := BagMgrSingleton.GetItem(p.SnId, int32(k)) if item == nil || item.ItemNum < v { @@ -461,29 +515,44 @@ func CSPropExchange(s *netlib.Session, packetid int, data interface{}, sid int64 } info := srvdata.GameItemMgr.Get(p.Platform, int32(k)) if info != nil { - costItems = append(costItems, &Item{ + costItems = append(costItems, &model.Item{ ItemId: int32(k), ItemNum: v, - Name: info.Name, }) } } for k, v := range info.GetGain() { info := srvdata.GameItemMgr.Get(p.Platform, int32(k)) if info != nil { - items = append(items, &Item{ + items = append(items, &model.Item{ ItemId: int32(k), ItemNum: v, - Name: info.Name, }) } } // 扣除背包物品 for _, item := range costItems { - BagMgrSingleton.AddItem(p, int64(item.ItemId), -item.ItemNum, 0, common.GainWayItemCollectExchange, "system", "集卡活动兑换", 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: item.ItemId, + ItemNum: -item.ItemNum, + }, + }, + GainWay: common.GainWayItemCollectExchange, + Operator: "system", + Remark: "集卡活动兑换", + }) } // 增加背包物品 - BagMgrSingleton.AddItems(p, items, 0, common.GainWayItemCollectExchange, "system", "集卡活动兑换", 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: items, + GainWay: common.GainWayItemCollectExchange, + Operator: "system", + Remark: "集卡活动兑换", + }) for _, v := range items { pack.Items = append(pack.Items, &bag.PropInfo{ ItemId: v.ItemId, diff --git a/worldsrv/action_pets.go b/worldsrv/action_pets.go index 40af61f..6749458 100644 --- a/worldsrv/action_pets.go +++ b/worldsrv/action_pets.go @@ -143,14 +143,27 @@ func (this *CSRisingStarHandler) Process(s *netlib.Session, packetid int, data i return nil } } + if role == nil { + logger.Logger.Tracef("人物不存在") + return nil + } //背包数据处理 item := BagMgrSingleton.GetItem(p.SnId, role.Fragment) - if item != nil { - // item.ItemNum -= role.Amount + if item != nil && item.ItemNum >= int64(role.Amount) { role.HaveAmount -= role.Amount remark := role.Name + "升星" - BagMgrSingleton.AddItem(p, int64(item.ItemId), int64(-role.Amount), 0, common.GainWay_RoleUpgrade, - "player", remark, 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: item.ItemId, + ItemNum: int64(-role.Amount), + }, + }, + GainWay: common.GainWay_RoleUpgrade, + Operator: "player", + Remark: remark, + }) //人物模型状态处理 p.Roles.ModUnlock[msg.RisingModId]++ FriendMgrSington.UpdateInfo(p.Platform, p.SnId) @@ -177,15 +190,27 @@ func (this *CSRisingStarHandler) Process(s *netlib.Session, packetid int, data i return nil } } + if pet == nil { + logger.Logger.Tracef("宠物不存在") + return nil + } //背包数据处理 item := BagMgrSingleton.GetItem(p.SnId, pet.Fragment) - if item != nil { - // item.ItemNum -= pet.Amount + if item != nil && item.ItemNum >= int64(pet.Amount) { pet.HaveAmount -= pet.Amount remark := pet.Name + "升星" - BagMgrSingleton.AddItem(p, int64(item.ItemId), int64(-pet.Amount), 0, common.GainWay_PetUpgrade, - "player", remark, 0, 0, false) - + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: item.ItemId, + ItemNum: int64(-pet.Amount), + }, + }, + GainWay: common.GainWay_PetUpgrade, + Operator: "player", + Remark: remark, + }) p.Pets.ModUnlock[msg.RisingModId]++ FriendMgrSington.UpdateInfo(p.Platform, p.SnId) p.dirty = true @@ -193,7 +218,6 @@ func (this *CSRisingStarHandler) Process(s *netlib.Session, packetid int, data i SendInfoPet(pets.OpResultCode_OPRC_Sucess, PetMgrSington.GetPetInfo(p, msg.RisingModId)) } } - } return nil } @@ -301,9 +325,18 @@ func (this *CSRolePetUnlockHandler) Process(s *netlib.Session, packetid int, dat item := BagMgrSingleton.GetItem(p.SnId, roleInfo.Fragment) if item != nil && item.ItemNum >= int64(roleInfo.Amount) { remark := roleInfo.Name + "解锁" - BagMgrSingleton.AddItem(p, int64(item.ItemId), int64(-roleInfo.Amount), 0, common.GainWay_RoleUpgrade, - "player", remark, 0, 0, false) - + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: item.ItemId, + ItemNum: int64(-roleInfo.Amount), + }, + }, + GainWay: common.GainWay_RoleUpgrade, + Operator: "player", + Remark: remark, + }) p.Roles.ModUnlock[msg.UseModId] = 1 if p.Roles.Mod[msg.UseModId] == nil { p.Roles.Mod[msg.UseModId] = &model.ModEx{} @@ -326,9 +359,18 @@ func (this *CSRolePetUnlockHandler) Process(s *netlib.Session, packetid int, dat item := BagMgrSingleton.GetItem(p.SnId, petInfo.Fragment) if item != nil && item.ItemNum >= int64(petInfo.Amount) { remark := petInfo.Name + "解锁" - BagMgrSingleton.AddItem(p, int64(item.ItemId), int64(-petInfo.Amount), 0, common.GainWay_PetUpgrade, - "player", remark, 0, 0, false) - + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: item.ItemId, + ItemNum: int64(-petInfo.Amount), + }, + }, + GainWay: common.GainWay_PetUpgrade, + Operator: "player", + Remark: remark, + }) p.Pets.ModUnlock[msg.UseModId] = 1 if p.Pets.Mod[msg.UseModId] == nil { p.Pets.Mod[msg.UseModId] = &model.ModEx{} @@ -395,17 +437,23 @@ func (this *CSPetSkillLevelUpHandler) Process(s *netlib.Session, packetid int, d } //消耗道具 itemCon := SkillInfo.ItemConsum - var items []*Item + var items []*model.Item for itemId, itemNum := range itemCon { - if itemNum == 0 { + if itemNum <= 0 { return nil } - items = append(items, &Item{ + items = append(items, &model.Item{ ItemId: int32(itemId), ItemNum: -itemNum, }) } - _, _, isF := BagMgrSingleton.AddItems(p, items, 0, common.GainWayPetSkillLevelUp, "system", "宠物技能升级消耗", 0, 0, false) + _, _, isF := BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: items, + GainWay: common.GainWayPetSkillLevelUp, + Operator: "system", + Remark: "宠物技能升级消耗", + }) if isF { p.Pets.SkillInfo[petId][skillId] = level + 1 if level == 0 { @@ -543,7 +591,7 @@ func CSSkinUpgrade(s *netlib.Session, packetid int, data interface{}, sid int64) ItemNum: -v.GetN(), }) } - _, _, ok = BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + _, _, ok = BagMgrSingleton.AddItems(&model.AddItemParam{ P: p.PlayerData, Change: change, Add: 0, @@ -597,7 +645,7 @@ func SkinUnLock(p *Player, id int32) (*pets.SkinInfo, pets.OpResultCode) { ItemNum: -v.GetN(), }) } - _, _, ok := BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + _, _, ok := BagMgrSingleton.AddItems(&model.AddItemParam{ P: p.PlayerData, Change: change, Add: 0, diff --git a/worldsrv/action_phonelottery.go b/worldsrv/action_phonelottery.go index f8f39e1..70d8f0d 100644 --- a/worldsrv/action_phonelottery.go +++ b/worldsrv/action_phonelottery.go @@ -99,7 +99,7 @@ func (this *CSPhoneLotteryHandler) Process(s *netlib.Session, packetid int, data p.addLotteryCount(-count) pool := srvdata.PBDB_PhoneLotteryMgr.Datas.GetArr() pack := &player_proto.SCPhoneLottery{} - items := make([]*Item, 0) + items := make([]*model.Item, 0) for i := 1; i <= int(count); i++ { //抽奖 rate := 0 @@ -167,7 +167,7 @@ func (this *CSPhoneLotteryHandler) Process(s *netlib.Session, packetid int, data itemArr.ItemId = lottery.Item_Id itemArr.ItemNum = int64(lottery.Grade) itemArr.Id = lottery.Id - items = append(items, &Item{ + items = append(items, &model.Item{ ItemId: lottery.Item_Id, // 物品id ItemNum: int64(lottery.Grade), // 数量 }) @@ -178,7 +178,13 @@ func (this *CSPhoneLotteryHandler) Process(s *netlib.Session, packetid int, data } } //增加到玩家背包 - BagMgrSingleton.AddItems(p, items, 0, common.GainWay_PhoneScore, "system", "玩游戏积分", 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: items, + GainWay: common.GainWay_PhoneScore, + Operator: "system", + Remark: "玩游戏积分", + }) pack.Count = p.LotteryCount pack.PhoneScore = p.PhoneScore logger.Logger.Tracef("获取玩家抽奖权重 score = %d,抽奖获得的物品:%v", p.PhoneScore, pack) @@ -389,7 +395,7 @@ func (this *CSDiamondLotteryHandler) Process(s *netlib.Session, packetid int, da } } } - BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + BagMgrSingleton.AddItems(&model.AddItemParam{ P: p.PlayerData, Change: items, Cost: []*model.Item{ @@ -462,8 +468,8 @@ func (this *CSDiamondLotteryLuckyAwardHandler) Process(s *netlib.Session, packet //获取奖励 for _, lotteryInfo := range config.Info { if lotteryInfo.Type == 2 { - var items []*Item - items = append(items, &Item{ + var items []*model.Item + items = append(items, &model.Item{ ItemId: lotteryInfo.ItemId, // 物品id ItemNum: int64(lotteryInfo.Grade), // 数量 }) @@ -472,7 +478,13 @@ func (this *CSDiamondLotteryLuckyAwardHandler) Process(s *netlib.Session, packet ItemId: lotteryInfo.ItemId, ItemNum: int64(lotteryInfo.Grade), } - BagMgrSingleton.AddItems(p, items, 0, common.GainWayDiamondLottery, "system", "钻石抽奖保底奖励", 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: items, + GainWay: common.GainWayDiamondLottery, + Operator: "system", + Remark: "钻石抽奖保底奖励", + }) pack.Item = append(pack.Item, itemData) break } diff --git a/worldsrv/action_player.go b/worldsrv/action_player.go index f429b88..c64484d 100644 --- a/worldsrv/action_player.go +++ b/worldsrv/action_player.go @@ -3118,7 +3118,7 @@ func CSUpdateAttribute(s *netlib.Session, packetId int, data interface{}, sid in send() // 获得10v卡 if p.GuideStep == 2 { - BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + BagMgrSingleton.AddItems(&model.AddItemParam{ P: p.PlayerData, Change: []*model.Item{ { diff --git a/worldsrv/action_rankmatch.go b/worldsrv/action_rankmatch.go index d29c0ea..034d469 100644 --- a/worldsrv/action_rankmatch.go +++ b/worldsrv/action_rankmatch.go @@ -251,11 +251,21 @@ func CSRMAward(s *netlib.Session, packetId int, data interface{}, sid int64) err } default: //道具 - item := &Item{ - ItemId: v.Id, - ItemNum: int64(v.Num), - } - BagMgrSingleton.AddItems(p, []*Item{item}, 0, common.GainWay_RankMatch, "system", "段位奖励", 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: v.Id, + ItemNum: int64(v.Num), + }, + }, + Add: 0, + GainWay: common.GainWay_RankMatch, + Operator: "system", + Remark: "段位奖励", + GameId: 0, + GameFreeId: 0, + }) } } } diff --git a/worldsrv/action_server.go b/worldsrv/action_server.go index b7e9e7c..8aec90d 100644 --- a/worldsrv/action_server.go +++ b/worldsrv/action_server.go @@ -631,7 +631,7 @@ func HandlePlayerChangeItems(session *netlib.Session, packetId int, data interfa ItemNum: v.GetNum(), }) } - _, _, ok = BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + _, _, ok = BagMgrSingleton.AddItems(&model.AddItemParam{ P: p.PlayerData, Change: items, NoLog: true, diff --git a/worldsrv/action_task.go b/worldsrv/action_task.go index 2671743..f095ff3 100644 --- a/worldsrv/action_task.go +++ b/worldsrv/action_task.go @@ -82,7 +82,7 @@ func IsTaskReward(p *Player, id int32) bool { func SendReward(p *Player, m map[int64]int64, tp int32) { isPermit := p.GetIsPermit() add := p.GetSkillAdd(common.SkillIdTask) - var items []*Item + var items []*model.Item for k, v := range m { if k == common.ItemIDPermit && isPermit { v += int64(float64(v) * common.PermitAdd) @@ -91,7 +91,7 @@ func SendReward(p *Player, m map[int64]int64, tp int32) { if tp == common.TaskActivityTypeEveryDay && add > 0 && k == common.ItemIDCoin { v += int64((float64(v) * float64(add)) / 100.0) } - items = append(items, &Item{ + items = append(items, &model.Item{ ItemId: int32(k), ItemNum: v, }) @@ -118,7 +118,16 @@ func SendReward(p *Player, m map[int64]int64, tp int32) { gain = common.GainWayItemTaskPermit giveType = model.SystemFreeGive_GiveType_TaskPermit } - BagMgrSingleton.AddItems(p, items, 0, gain, "system", "任务奖励", 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: items, + Add: 0, + GainWay: gain, + Operator: "system", + Remark: "任务奖励", + GameId: 0, + GameFreeId: 0, + }) for _, v := range items { tp := int32(-1) if v.ItemId == common.ItemIDCoin { diff --git a/worldsrv/action_welfare.go b/worldsrv/action_welfare.go index bc800d9..130f4ba 100644 --- a/worldsrv/action_welfare.go +++ b/worldsrv/action_welfare.go @@ -531,9 +531,9 @@ func IsPermitCanReward(p *Player, id int32) bool { // SendPermitReward 发赛季通行证奖励 // tp 1普通,2典藏 func SendPermitReward(p *Player, m map[int64]int64, tp int32) { - var items []*Item + var items []*model.Item for k, v := range m { - items = append(items, &Item{ + items = append(items, &model.Item{ ItemId: int32(k), ItemNum: v, }) @@ -548,7 +548,16 @@ func SendPermitReward(p *Player, m map[int64]int64, tp int32) { gain = common.GainWayPermitAward giveType = model.SystemFreeGive_GiveType_PermitAward } - BagMgrSingleton.AddItems(p, items, 0, gain, "system", "通行证奖励", 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: items, + Add: 0, + GainWay: gain, + Operator: "system", + Remark: "通行证奖励", + GameId: 0, + GameFreeId: 0, + }) for _, v := range items { tp1 := int32(-1) if v.ItemId == common.ItemIDCoin { @@ -1040,9 +1049,8 @@ func CSPermitExchange(s *netlib.Session, packetid int, data interface{}, sid int if exchangeConfig != nil { // 检查背包是否足够 var items []*model.Item - var costItems []*Item + var costItems, cost1 []*model.Item var cost, gain []model.AwardItem - var cost1 []*model.Item for _, v := range exchangeConfig.GetCost() { item := BagMgrSingleton.GetItem(p.SnId, v.GetItemId()) if item == nil || item.ItemNum < v.GetItemNum() { @@ -1051,10 +1059,9 @@ func CSPermitExchange(s *netlib.Session, packetid int, data interface{}, sid int } info := srvdata.GameItemMgr.Get(p.Platform, v.GetItemId()) if info != nil { - costItems = append(costItems, &Item{ + costItems = append(costItems, &model.Item{ ItemId: v.GetItemId(), - ItemNum: v.GetItemNum(), - Name: info.Name, + ItemNum: -v.GetItemNum(), }) cost = append(cost, model.AwardItem{ Id: v.GetItemId(), @@ -1080,12 +1087,15 @@ func CSPermitExchange(s *netlib.Session, packetid int, data interface{}, sid int } } // 扣除背包物品 - for _, item := range costItems { - BagMgrSingleton.AddItem(p, int64(item.ItemId), -item.ItemNum, 0, - common.GainWayPermitExchangeCost, "system", "赛季通行证兑换消耗", 0, 0, false) - } + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: costItems, + GainWay: common.GainWayPermitExchangeCost, + Operator: "system", + Remark: "赛季通行证兑换消耗", + }) // 增加背包物品 - BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + BagMgrSingleton.AddItems(&model.AddItemParam{ P: p.PlayerData, Change: items, Cost: cost1, diff --git a/worldsrv/bagmgr.go b/worldsrv/bagmgr.go index acb0556..05f56a8 100644 --- a/worldsrv/bagmgr.go +++ b/worldsrv/bagmgr.go @@ -3,8 +3,6 @@ package main import ( "errors" "fmt" - "math" - "strconv" "time" "github.com/globalsign/mgo/bson" @@ -25,6 +23,120 @@ import ( "mongo.games.com/game/worldsrv/internal" ) +func init() { + module.RegisteModule(BagMgrSingleton, time.Second, 0) + internal.RegisterPlayerLoad(BagMgrSingleton) + + BagMgrSingleton.AddOnChangeFuncs(func(param *model.ChangeItemParam) { + p := PlayerMgrSington.GetPlayerBySnId(param.SnId) + if p == nil { + return + } + itemData := srvdata.GameItemMgr.Get(p.Platform, param.ItemId) + if itemData == nil { + return + } + + logType := ItemObtain + if param.ItemNum < 0 { + logType = ItemConsume + } + //获奖记录log + if logType == ItemObtain && param.ItemNum > 0 { + awardLogType := 0 + if itemData.Type == common.ItemTypeChange { + //话费 + awardLogType = 1 + } else if itemData.Type == common.ItemTypeObjective { + //实物 + awardLogType = 2 + AwardLogMgr.UpdateAwardLog(p.Platform, itemData.Id, param.ItemNum) + } + if awardLogType != 0 { + data := model.AnnouncerLog{ + Platform: p.Platform, + Snid: p.SnId, + Name: p.Name, + Phone: p.Tel, + ItemId: param.ItemId, //获得物品ID + TypeId: int32(awardLogType), + } + AwardLogMgr.UpdateAnnouncerLog(data) + } + } + + // 皮肤自动解锁 + if p != nil && itemData.GetType() == 21 && param.ItemNum > 0 { + p.AutoSkinUnlock() + } + + if param.ItemNum > 0 { + switch param.ItemId { + case common.ItemIDWeekScore: + TaskSubjectSingleton.Touch(common.TaskTypeActivityScore, &TaskData{ + SnId: p.SnId, + Num: param.ItemNum, + }) + case common.ItemIDPetSkill: + PetMgrSington.CheckShowRed(p) + + case common.ItemIDPermit, common.ItemIDLong: + var permitScore, long int64 + if param.ItemId == common.ItemIDLong { + long = param.ItemNum + } else { + permitScore = param.ItemNum + } + LogChannelSingleton.WriteLog(&model.BackendPermitJoin{ + Platform: p.Platform, + StartTs: PlatformMgrSingleton.GetConfig(p.Platform).PermitStartTs, + SnId: p.SnId, + Score: permitScore, + Long: long, + Ts: time.Now().Unix(), + }) + + } + + switch itemData.GetType() { + case common.ItemTypeSkinChip: + PetMgrSington.CheckSkinRed(p) + } + } + + // 统计 v卡兑换消耗数量 + if p != nil && param.ItemId == common.ItemIDVCard && param.GainWay == common.GainWay_Exchange { + p.VCardCost += -param.ItemNum + if p.VCardCost < 0 { + p.VCardCost = 0 + } + } + + // 更新通行证赛季积分排行榜 + if param.ItemId == common.ItemIDPermit { + item := BagMgrSingleton.GetItem(p.SnId, param.ItemId) + startTs := PlatformMgrSingleton.GetConfig(p.Platform).PermitStartTs + if item != nil && item.ItemNum > 0 && startTs > 0 { + // 赛季积分排行榜 + LogChannelSingleton.WriteLog(&model.PermitScore{ + Platform: p.Platform, + SnId: p.SnId, + Name: p.Name, + Exp: item.ItemNum, + ModId: p.Roles.ModId, + StartTs: startTs, + Ts: time.Now().Unix(), + }) + } + } + + // 更新好友信息 + if param.ItemId == common.ItemIDVCard { + FriendMgrSington.UpdateInfo(p.Platform, p.SnId) + } + }) +} + const ( BagItemMax int32 = 200 ) @@ -35,37 +147,42 @@ const ( ItemCanGive //可以赠送 ItemCanSell //可以出售 ItemCanExchange //可以兑换 - ItemCanFen // 可以分解 + ItemCanFen //可以分解 ItemMax ) type Item struct { - ItemId int32 // 物品ID - ItemNum int64 // 物品数量 - ////数据表数据 - Name string // 名称 - //ShowLocation []int32 // 显示位置 - //Classify []int32 // 分页类型 1,道具类 2,资源类 3,兑换类 - //Type int32 // 道具种类 1,宠物碎片 2,角色碎片 - Effect0 []int32 // 竖版道具功能 1,使用 2,赠送 3,出售 - Effect []int32 // 横版道具功能 1,使用 2,赠送 3,出售 + ItemId int32 // 物品ID + ItemNum int64 // 物品数量 + ObtainTime int64 //获取的时间 + //数据表数据 + Name string // 名称 + Effect0 []int32 // 竖版道具功能 ItemCanUse ... + Effect []int32 // 横版道具功能 ItemCanUse ... SaleType int32 // 出售类型 SaleGold int32 // 出售金额 - //Composition int32 // 能否叠加 1,能 2,不能 - //CompositionMax int32 // 叠加上限 - //Time int32 // 道具时效 0为永久 - //Location string // 跳转页面 - //Describe string // 道具描述 - //数据库数据 - ObtainTime int64 //获取的时间 } type BagInfo struct { - SnId int32 //玩家账号直接在这里生成 - Platform string //平台 + SnId int32 //玩家id + Platform string //平台id BagItem map[int32]*Item //背包数据 key为itemId - dirty bool - LogId string `bson:"-"` + Ts int64 //更新时间戳 + + // 临时携带参数 + dirty bool `bson:"-"` //是否需要更新数据库 + LogId string `bson:"-"` //最后一次保存的日志id +} + +func NewBagInfo(platform string, snid int32) *BagInfo { + return &BagInfo{ + SnId: snid, + Platform: platform, + BagItem: make(map[int32]*Item), + Ts: time.Now().Unix(), + dirty: true, + LogId: "", + } } // BagMgrSingleton 背包管理器 @@ -75,6 +192,9 @@ var BagMgrSingleton = &BagMgr{ type BagMgr struct { PlayerBag map[int32]*BagInfo // snid:背包 + + // 道具变更监听,玩家离线时道具变更会在登录时根据道具日志执行一遍 + OnChangeFuncs []func(param *model.ChangeItemParam) } func (this *BagMgr) ModuleName() string { @@ -84,11 +204,15 @@ func (this *BagMgr) ModuleName() string { func (this *BagMgr) Init() { } -func (this *BagMgr) GetBagInfo(snid int32) *BagInfo { - if v, exist := this.PlayerBag[snid]; exist { - return v - } - return nil +func (this *BagMgr) Update() { +} + +func (this *BagMgr) Shutdown() { + module.UnregisteModule(this) +} + +func (this *BagMgr) AddOnChangeFuncs(f ...func(param *model.ChangeItemParam)) { + this.OnChangeFuncs = append(this.OnChangeFuncs, f...) } // GetItem 获取个人的指定道具信息 @@ -105,18 +229,10 @@ func (this *BagMgr) GetItem(snid, itemId int32) *Item { itemX := srvdata.GameItemMgr.Get(p.Platform, itemId) if itemX != nil { item.Name = itemX.Name - //item.ShowLocation = itemX.ShowLocation - //item.Classify = itemX.Classify - //item.Type = itemX.Type item.Effect0 = itemX.Effect item.Effect = itemX.Effect item.SaleType = itemX.SaleType item.SaleGold = itemX.SaleGold - //item.Composition = itemX.Composition - //item.CompositionMax = itemX.CompositionMax - //item.Time = itemX.Time - //item.Location = itemX.Location - //item.Describe = itemX.Describe } } @@ -142,57 +258,122 @@ func (this *BagMgr) GetItem(snid, itemId int32) *Item { return item } -type AddItemParam struct { - Cost []*model.Item // 获得道具时消耗的道具数量 - LogId string - RoomConfigId int32 +// Range 遍历背包 +func (this *BagMgr) Range(snid int32, fn func(item *Item) bool) { + if v, exist := this.PlayerBag[snid]; exist { + for k := range v.BagItem { + e := this.GetItem(snid, k) + if e == nil { + continue + } + if !fn(e) { + return + } + } + } } -func (this *BagMgr) AddItemsV2(args *model.AddItemParam) (*BagInfo, bag.OpResultCode, bool) { - p := PlayerMgrSington.GetPlayerBySnId(args.P.SnId) - var items []*Item - var costs []*model.Item - for _, v := range args.Change { - items = append(items, &Item{ - ItemId: v.ItemId, - ItemNum: v.ItemNum, - }) +// GetBagInfo 获取背包信息 +// 是复制的一份数据 +func (this *BagMgr) GetBagInfo(snid int32) *BagInfo { + p := PlayerMgrSington.GetPlayerBySnId(snid) + if p == nil { + return nil } - for _, v := range args.Cost { - costs = append(costs, &model.Item{ - ItemId: v.ItemId, - ItemNum: v.ItemNum, - }) + ret := NewBagInfo(p.Platform, p.SnId) + if v, exist := this.PlayerBag[snid]; exist { + ret.Ts = v.Ts + ret.dirty = v.dirty + ret.LogId = v.LogId + for k := range v.BagItem { + ret.BagItem[k] = this.GetItem(snid, k) + } + } else { + this.PlayerBag[snid] = NewBagInfo(p.Platform, p.SnId) } - 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, - RoomConfigId: args.RoomConfigId, - }) + return ret } -// AddItems 给玩家背包添加道具 -// add 加成数量 -// gainWay 记录类型 -// oper 操作人 -// remark 备注 -// gameId 游戏id -// gameFreeId 场次id -// NoLog 是否不记录日志 -// Deprecated: use [ AddItemsV2 ] instead -func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int32, operator, remark string, - 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 +// SyncBagData 通知玩家背包数据变化 +func (this *BagMgr) SyncBagData(snid int32, changeItemIds ...int32) { + p := PlayerMgrSington.GetPlayerBySnId(snid) + if p == nil || p.IsRob { + return } - var items []*Item - for _, v := range addItems { + var itemInfos []*bag.ItemInfo + for _, itemId := range changeItemIds { + itemInfo := this.GetItem(snid, itemId) + if itemInfo != nil { + itemInfos = append(itemInfos, &bag.ItemInfo{ + ItemId: itemInfo.ItemId, + ItemNum: itemInfo.ItemNum, + ObtainTime: itemInfo.ObtainTime, + }) + } + } + pack := &bag.SCSyncBagData{ + Infos: itemInfos, + } + p.SendToClient(int(bag.SPacketID_PACKET_SC_SYNCBAGDATA), pack) + logger.Logger.Tracef("背包数据变更(%v): %v", p.SnId, pack) +} + +// AddItemCheck 校验道具是否充足 +// 返回道具变化,操作结果,是否成功 +func (this *BagMgr) AddItemCheck(param *model.AddItemParam) ([]*model.Item, bag.OpResultCode, bool) { + var items []*model.Item // 道具变化 + p := PlayerMgrSington.GetPlayerBySnId(param.P.SnId) + if p == nil { + return items, bag.OpResultCode_OPRC_NotPlayer, false + } + + // 获取背包 + var newBagInfo *BagInfo + if _, exist := this.PlayerBag[p.SnId]; !exist { + newBagInfo = NewBagInfo(p.Platform, p.SnId) + this.PlayerBag[p.SnId] = newBagInfo + } else { + newBagInfo = this.PlayerBag[p.SnId] + } + + // 参数校验 + for _, v := range param.Change { + if v == nil || v.ItemNum == 0 { + continue + } + item := srvdata.GameItemMgr.Get(p.Platform, v.ItemId) + if item == nil { + return items, bag.OpResultCode_OPRC_IdErr, false + } + if itm, exist := newBagInfo.BagItem[v.ItemId]; exist { + if v.ItemNum < 0 && itm.ItemNum < -v.ItemNum { + return items, bag.OpResultCode_OPRC_UseUp, false + } + } else { + if v.ItemNum < 0 { + return items, bag.OpResultCode_OPRC_UseUp, false + } + } + items = append(items, &model.Item{ + ItemId: v.ItemId, + ItemNum: v.ItemNum, + ObtainTime: v.ObtainTime, + }) + } + return items, bag.OpResultCode_OPRC_Sucess, true +} + +// AddItems 修改道具,玩家在线 +func (this *BagMgr) AddItems(param *model.AddItemParam) (*BagInfo, bag.OpResultCode, bool) { + p := PlayerMgrSington.GetPlayerBySnId(param.P.SnId) + if p == nil { + return nil, bag.OpResultCode_OPRC_NotPlayer, false + } + + // 非道具 + var realItems []*model.Item + for _, v := range param.Change { if v == nil || v.ItemNum == 0 { continue } @@ -204,12 +385,12 @@ func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int case common.ItemTypeCoin: //增加金币 if item.Id == common.ItemIDCoin { - p.AddCoin(v.ItemNum, add, gainWay, operator, remark) + p.AddCoin(v.ItemNum, param.Add, param.GainWay, param.Operator, param.Remark) } case common.ItemTypeDiamond: //增加钻石 if item.Id == common.ItemIDDiamond { - p.AddDiamond(v.ItemNum, add, gainWay, operator, remark) + p.AddDiamond(v.ItemNum, param.Add, param.GainWay, param.Operator, param.Remark) } case common.ItemTypeFishPower: //增加炮台 @@ -226,90 +407,56 @@ func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int } case common.ItemTypeShopScore: if v.ItemId == common.ItemIDPhoneScore { - p.AddPhoneScore(v.ItemNum, 0, gainWay, operator, remark) + p.AddPhoneScore(v.ItemNum, 0, param.GainWay, param.Operator, param.Remark) } case common.ItemTypeExpireTime: - p.AddItemRecExpireTime(v.ItemId, v.ItemNum, 0, gainWay, operator, remark) + p.AddItemRecExpireTime(v.ItemId, v.ItemNum, 0, param.GainWay, param.Operator, param.Remark) default: // 道具变化 - items = append(items, v) + realItems = append(realItems, v) } } + param.Change = realItems + if len(realItems) == 0 { + return nil, bag.OpResultCode_OPRC_Sucess, true + } + // 非道具 + + items, code, ok := this.AddItemCheck(param) + if !ok { + return nil, code, ok + } - // 添加道具到背包 - var isSkin bool - var permitScore, long int64 - var changeItems []int32 - var newBagInfo *BagInfo - var logId string - if _, exist := this.PlayerBag[p.SnId]; !exist { - newBagInfo = &BagInfo{ - SnId: p.SnId, - Platform: p.Platform, - BagItem: make(map[int32]*Item), - } - } else { - newBagInfo = this.PlayerBag[p.SnId] - } if len(items) == 0 { - return newBagInfo, bag.OpResultCode_OPRC_Sucess, true + return nil, bag.OpResultCode_OPRC_Sucess, true } - var code = bag.OpResultCode_OPRC_Sucess - //检查道具数量 - for _, v := range items { - if v == nil || v.ItemNum == 0 { - continue - } - - item := srvdata.GameItemMgr.Get(p.Platform, v.ItemId) - if item == nil { - code = bag.OpResultCode_OPRC_IdErr - return newBagInfo, code, false - } - if itm, exist := newBagInfo.BagItem[v.ItemId]; exist { - if v.ItemNum < 0 && itm.ItemNum < int64(math.Abs(float64(v.ItemNum))) { - code = bag.OpResultCode_OPRC_UseUp - return newBagInfo, code, false - } - } + newBagInfo, ok := this.PlayerBag[param.P.SnId] + if !ok { + newBagInfo = NewBagInfo(p.Platform, p.SnId) + this.PlayerBag[param.P.SnId] = newBagInfo } + // 更新背包 + var ts int64 // 最新日志时间戳 + var itemInfos []int32 for _, v := range items { - if v == nil || v.ItemNum == 0 { + itemData := srvdata.GameItemMgr.Get(p.Platform, v.ItemId) + if itemData == nil { continue } - - item := srvdata.GameItemMgr.Get(p.Platform, v.ItemId) - if item == nil { - code = bag.OpResultCode_OPRC_IdErr - continue - } - if !isSkin { - isSkin = item.GetType() == 21 && v.ItemNum > 0 - } if itm, exist := newBagInfo.BagItem[v.ItemId]; exist { - if itm.ItemNum+v.ItemNum < 0 { - code = bag.OpResultCode_OPRC_IdErr - continue - } itm.ItemNum += v.ItemNum } else { - if v.ItemNum < 0 { - code = bag.OpResultCode_OPRC_IdErr - continue - } newBagInfo.BagItem[v.ItemId] = &Item{ - ItemId: item.Id, // 物品id + ItemId: v.ItemId, // 物品id ItemNum: v.ItemNum, // 数量 ObtainTime: time.Now().Unix(), } } - changeItems = append(changeItems, v.ItemId) - - // 道具日志 - if !noLog { + // 日志 + if !param.NoLog { num := v.ItemNum logType := ItemObtain if v.ItemNum < 0 { @@ -321,137 +468,52 @@ func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int SnId: p.SnId, LogType: int32(logType), ItemId: v.ItemId, - ItemName: item.Name, + ItemName: itemData.Name, Count: num, - Remark: remark, - TypeId: gainWay, - GameId: gameId, - GameFreeId: gameFreeId, - Cost: cost, - LogId: id, - RoomConfigId: roomConfigId, + Remark: param.Remark, + TypeId: param.GainWay, + GameId: param.GameId, + GameFreeId: param.GameFreeId, + Cost: param.Cost, + LogId: param.LogId, + RoomConfigId: param.RoomConfigId, }) if log != nil { LogChannelSingleton.WriteLog(log) - logId = log.LogId.Hex() + ts = log.CreateTs + newBagInfo.LogId = log.LogId.Hex() } - //获奖记录log - if logType == ItemObtain && v.ItemNum > 0 { - awardLogType := 0 - if item.Type == common.ItemTypeChange { - //话费 - awardLogType = 1 - } else if item.Type == common.ItemTypeObjective { - //实物 - awardLogType = 2 - AwardLogMgr.UpdateAwardLog(p.Platform, item.Id, v.ItemNum) - } - if awardLogType != 0 { - data := model.AnnouncerLog{ - Platform: p.Platform, - Snid: p.SnId, - Name: p.Name, - Phone: p.Tel, - ItemId: item.Id, //获得物品ID - TypeId: int32(awardLogType), - } - AwardLogMgr.UpdateAnnouncerLog(data) - } - } - } - - if v.ItemId == common.ItemIDWeekScore && v.ItemNum > 0 { - TaskSubjectSingleton.Touch(common.TaskTypeActivityScore, &TaskData{ - SnId: p.SnId, - Num: v.ItemNum, - }) - } - - if v.ItemId == common.ItemIDPetSkill && v.ItemNum > 0 { - PetMgrSington.CheckShowRed(p) - } - - // 皮肤红点 - if v.ItemNum > 0 && item.GetType() == common.ItemTypeSkinChip { - PetMgrSington.CheckSkinRed(p) - } - - // 统计 v卡兑换消耗数量 - if v.ItemId == common.ItemIDVCard && gainWay == common.GainWay_Exchange { - p.VCardCost += -v.ItemNum - if p.VCardCost < 0 { - p.VCardCost = 0 - } - } - if v.ItemId == common.ItemIDPermit && v.ItemNum > 0 { - permitScore += v.ItemNum - } - if v.ItemId == common.ItemIDLong && v.ItemNum > 0 { - long += v.ItemNum - } - } - - if len(changeItems) > 0 { - newBagInfo.dirty = true - newBagInfo.LogId = logId - p.dirty = true - this.PlayerBag[p.SnId] = newBagInfo - this.SyncBagData(p.SnId, changeItems...) - } - - for _, v := range changeItems { - if v == common.ItemIDPermit { - item := this.GetItem(p.SnId, v) - startTs := PlatformMgrSingleton.GetConfig(p.Platform).PermitStartTs - if item != nil && item.ItemNum > 0 && startTs > 0 { - // 赛季积分排行榜 - LogChannelSingleton.WriteLog(&model.PermitScore{ - Platform: p.Platform, - SnId: p.SnId, - Name: p.Name, - Exp: item.ItemNum, - ModId: p.Roles.ModId, - StartTs: startTs, - Ts: time.Now().Unix(), + for _, f := range this.OnChangeFuncs { + f(&model.ChangeItemParam{ + SnId: p.SnId, + ItemId: v.ItemId, + ItemNum: num, + GainWay: param.GainWay, + RoomConfigId: param.RoomConfigId, + GameId: param.GameId, + GameFreeId: param.GameFreeId, + Cost: param.Cost, }) } } - if v == common.ItemIDLong { - p.SendDiffData() + + itemInfo := this.GetItem(p.SnId, v.ItemId) + if itemInfo != nil { + itemInfos = append(itemInfos, v.ItemId) } } - - if permitScore > 0 || long > 0 { - LogChannelSingleton.WriteLog(&model.BackendPermitJoin{ - Platform: p.Platform, - StartTs: PlatformMgrSingleton.GetConfig(p.Platform).PermitStartTs, - SnId: p.SnId, - Score: permitScore, - Long: long, - Ts: time.Now().Unix(), - }) + newBagInfo.dirty = true + if ts > newBagInfo.Ts { + newBagInfo.Ts = ts } - - // 自动解锁皮肤 - if isSkin { - p.AutoSkinUnlock() - } - - if code != bag.OpResultCode_OPRC_Sucess { - return newBagInfo, code, false - } - return newBagInfo, code, true - + this.PlayerBag[p.SnId] = newBagInfo + p.SendDiffData() + this.SyncBagData(p.SnId, itemInfos...) + return newBagInfo, bag.OpResultCode_OPRC_Sucess, true } -// Deprecated: use [ AddItemsV2 ] instead -func (this *BagMgr) AddItem(p *Player, itemId, itemNum int64, add int64, gainWay int32, operator, remark string, - gameId, gameFreeId int64, noLog bool, params ...AddItemParam) (*BagInfo, bag.OpResultCode, bool) { - return this.AddItems(p, []*Item{{ItemId: int32(itemId), ItemNum: itemNum}}, add, gainWay, operator, remark, gameId, gameFreeId, noLog, params...) -} - -func (this *BagMgr) AddItemsOffline(platform string, snid int32, addItems []*model.Item, gainWay int32, operator, remark string, - gameId, gameFreeId int64, noLog bool, callback func(err error)) { +// AddItemsOffline 修改道具,玩家离线 +func (this *BagMgr) AddItemsOffline(platform string, snid int32, param *model.AddItemParam, callback func(err error)) { var findPlayer *model.PlayerBaseInfo task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { findPlayer = model.GetPlayerBaseInfo(platform, snid) @@ -462,78 +524,70 @@ func (this *BagMgr) AddItemsOffline(platform string, snid int32, addItems []*mod SnId: findPlayer.SnId, Platform: findPlayer.Platform, BagItem: make(map[int32]*model.Item), - GainWay: gainWay, + GainWay: param.GainWay, } - for _, v := range addItems { + for _, v := range param.Change { if v == nil || v.ItemNum == 0 { continue } newBagInfo.BagItem[v.ItemId] = &model.Item{ItemId: v.ItemId, ItemNum: v.ItemNum} } - return model.SaveDBBagItem(newBagInfo) }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { - logger.Logger.Tracef("AddItemsOffline failed: %v %+v", data, *findPlayer) - if data == nil && findPlayer != nil { - callback(nil) - if noLog { + logger.Logger.Tracef("AddItemsOffline error(%v) Player:%+v", data, *findPlayer) + p := PlayerMgrSington.GetPlayerBySnId(snid) + if p != nil { + // 在线仍然走在线流程 + param.P = p.PlayerData + _, code, ok := this.AddItems(param) + if !ok { + logger.Logger.Errorf("AddItemsOffline failed Code:%v Player:%+v", code, *findPlayer) + callback(errors.New("AddItemsOffline failed")) return } - for _, v := range addItems { - itemData := srvdata.GameItemMgr.Get(platform, v.ItemId) - if itemData == nil { - continue - } - num := v.ItemNum - logType := ItemObtain - if v.ItemNum < 0 { - logType = ItemConsume - num = -v.ItemNum - } - log := model.NewItemLogEx(model.ItemParam{ - Platform: findPlayer.Platform, - SnId: findPlayer.SnId, - LogType: int32(logType), - ItemId: v.ItemId, - ItemName: itemData.Name, - Count: num, - Remark: remark, - TypeId: gainWay, - GameId: gameId, - GameFreeId: gameFreeId, - }) - if log != nil { - LogChannelSingleton.WriteLog(log) - } - - //获奖记录log - if logType == ItemObtain && v.ItemNum > 0 { - awardLogType := 0 - if itemData.Type == common.ItemTypeChange { - //话费 - awardLogType = 1 - } else if itemData.Type == common.ItemTypeObjective { - //实物 - awardLogType = 2 - AwardLogMgr.UpdateAwardLog(findPlayer.Platform, itemData.Id, v.ItemNum) - } - if awardLogType > 0 { - logData := model.AnnouncerLog{ - Platform: findPlayer.Platform, - Snid: findPlayer.SnId, - Name: findPlayer.Name, - Phone: findPlayer.Tel, - ItemId: itemData.Id, //获得物品ID - TypeId: int32(awardLogType), - } - AwardLogMgr.UpdateAnnouncerLog(logData) - } - } - } - } else { - callback(errors.New("AddItemsOffline failed")) + callback(nil) + return } - }), "AddItemsOffline").Start() + + if data != nil || findPlayer == nil { + logger.Logger.Errorf("AddItemsOffline Error error(%v) Player:%+v", data, *findPlayer) + callback(errors.New("AddItemsOffline failed")) + return + } + + callback(nil) + if param.NoLog { + return + } + + for _, v := range param.Change { + itemData := srvdata.GameItemMgr.Get(platform, v.ItemId) + if itemData == nil { + continue + } + num := v.ItemNum + logType := ItemObtain + if v.ItemNum < 0 { + logType = ItemConsume + num = -v.ItemNum + } + log := model.NewItemLogEx(model.ItemParam{ + Platform: findPlayer.Platform, + SnId: findPlayer.SnId, + LogType: int32(logType), + ItemId: v.ItemId, + ItemName: itemData.Name, + Count: num, + Remark: param.Remark, + TypeId: param.GainWay, + GameId: param.GameId, + GameFreeId: param.GameFreeId, + }) + if log != nil { + LogChannelSingleton.WriteLog(log) + } + } + })).StartByExecutor(fmt.Sprintf("Player%v", snid)) } // AddMailByItem 赠送道具到邮件 @@ -583,20 +637,21 @@ func (this *BagMgr) VerifyUpJybInfo(p *Player, args *model.VerifyUpJybInfoArgs) pack.GainItem = &playerproto.JybInfoAward{} if jyb.Award.Item != nil { if len(jyb.Award.Item) > 0 { - items := make([]*Item, 0) + items := make([]*model.Item, 0) for _, v := range jyb.Award.Item { - items = append(items, &Item{ + items = append(items, &model.Item{ ItemId: v.ItemId, // 物品id ItemNum: v.ItemNum, // 数量 ObtainTime: time.Now().Unix(), }) } - if _, code, _ := this.AddItems(p, items, 0, common.GainWay_ActJybAward, "system", "礼包码兑换", 0, 0, false); code != bag.OpResultCode_OPRC_Sucess { //TODO 添加失败 要回退礼包 - logger.Logger.Errorf("CSPlayerSettingHandler AddItems err", code) - pack.OpRetCode = playerproto.OpResultCode_OPRC_Error - proto.SetDefaults(pack) - p.SendToClient(int(playerproto.PlayerPacketID_PACKET_ALL_SETTING), pack) - } + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: items, + GainWay: common.GainWay_ActJybAward, + Operator: "system", + Remark: "礼包码兑换", + }) p.dirty = true } } @@ -663,44 +718,6 @@ func (this *BagMgr) VerifyUpJybInfo(p *Player, args *model.VerifyUpJybInfoArgs) proto.SetDefaults(pack) p.SendToClient(int(playerproto.PlayerPacketID_PACKET_ALL_SETTING), pack) }), "VerifyUpJybInfo").Start() - // 先检查玩家背包是否足够 - -} - -// SyncBagData 通知玩家背包数据变化 -func (this *BagMgr) SyncBagData(snid int32, changeItemIds ...int32) { - p := PlayerMgrSington.GetPlayerBySnId(snid) - if p == nil || p.IsRob { - return - } - - var itemInfos []*bag.ItemInfo - for _, itemId := range changeItemIds { - itemInfo := this.GetItem(snid, itemId) - if itemInfo != nil { - itemInfos = append(itemInfos, &bag.ItemInfo{ - ItemId: itemInfo.ItemId, - ItemNum: itemInfo.ItemNum, - //Name: itemInfo.Name, - //Classify: itemInfo.Classify, - //Type: itemInfo.Type, - //Effect0: itemInfo.Effect0, - //Effect: itemInfo.Effect, - //SaleType: itemInfo.SaleType, - //SaleGold: itemInfo.SaleGold, - //Composition: itemInfo.Composition, - //CompositionMax: itemInfo.CompositionMax, - //Time: itemInfo.Time, - //Location: itemInfo.Location, - //Describe: itemInfo.Describe, - ObtainTime: itemInfo.ObtainTime, - }) - if itemInfo.ItemId == common.ItemIDVCard { - FriendMgrSington.UpdateInfo(p.Platform, p.SnId) - } - } - } - p.SyncBagData(itemInfos) } // 兑换话费卡 @@ -759,7 +776,7 @@ func (this *BagMgr) ItemExchangeCard(p *Player, itemId int32, money, cardType in ItemNum: 1, // 数量 ObtainTime: time.Now().Unix(), }) - this.AddItemsV2(&model.AddItemParam{ + this.AddItems(&model.AddItemParam{ P: p.PlayerData, Change: items, Add: 0, @@ -797,22 +814,30 @@ func (this *BagMgr) ItemExchangeCard(p *Player, itemId int32, money, cardType in return true } -func (this *BagMgr) Update() { +// ========================implement IPlayerLoad ============================== +type LoadData struct { + BagInfo *model.BagInfo } -func (this *BagMgr) Shutdown() { - module.UnregisteModule(this) -} - -//========================implement IPlayerLoad ============================== - func (this *BagMgr) Load(platform string, snid int32, player any) *internal.PlayerLoadReplay { - data, err := model.GetBagInfo(snid, platform) + // 加载道具 + bagInfo, err := model.GetBagInfo(snid, platform) + if err != nil { + return &internal.PlayerLoadReplay{ + Platform: platform, + Snid: snid, + Err: err, + Data: nil, + } + } + return &internal.PlayerLoadReplay{ Platform: platform, Snid: snid, Err: err, - Data: data, + Data: &LoadData{ + BagInfo: bagInfo, + }, } } @@ -821,18 +846,15 @@ func (this *BagMgr) Callback(player any, ret *internal.PlayerLoadReplay) { return } - bagInfo, ok := ret.Data.(*model.BagInfo) - if !ok || bagInfo == nil { + data, ok := ret.Data.(*LoadData) + if !ok || data == nil || data.BagInfo == nil { return } - //数据表 数据库数据相结合 - newBagInfo := &BagInfo{ - SnId: ret.Snid, - Platform: ret.Platform, - BagItem: make(map[int32]*Item), - } - for k, bi := range bagInfo.BagItem { + // 背包数据 + newBagInfo := NewBagInfo(ret.Platform, ret.Snid) + newBagInfo.Ts = data.BagInfo.Ts + for k, bi := range data.BagInfo.BagItem { item := srvdata.GameItemMgr.Get(ret.Platform, bi.ItemId) if item != nil { if bi.ItemNum > 0 { @@ -849,14 +871,37 @@ func (this *BagMgr) Callback(player any, ret *internal.PlayerLoadReplay) { this.PlayerBag[ret.Snid] = newBagInfo } +type LoadAfterData struct { + GameID []int32 + ItemLogs []*model.ItemLog +} + func (this *BagMgr) LoadAfter(platform string, snid int32) *internal.PlayerLoadReplay { + var err error // 查询最近游戏 gameID := model.GetRecentGame(platform, snid) + + // 道具变更记录 + var itemLogs []*model.ItemLog + itemLogs, err = model.GetItemLog(platform, snid, this.PlayerBag[snid].Ts) + if err != nil { + logger.Logger.Errorf("LoadAfter GetItemLog err: %v", err) + return &internal.PlayerLoadReplay{ + Platform: platform, + Snid: snid, + Err: err, + Data: nil, + } + } + return &internal.PlayerLoadReplay{ Platform: platform, Snid: snid, Err: nil, - Data: gameID, + Data: &LoadAfterData{ + GameID: gameID, + ItemLogs: itemLogs, + }, } } @@ -870,49 +915,65 @@ func (this *BagMgr) CallbackAfter(ret *internal.PlayerLoadReplay) { } p := PlayerMgrSington.GetPlayerBySnId(ret.Snid) if p != nil { - p.GameID = ret.Data.([]int32) - p.AutoSkinUnlock() + // 最近游戏 + p.GameID = ret.Data.(*LoadAfterData).GameID + + // 道具变更记录 + bagInfo := this.PlayerBag[p.SnId] + if bagInfo != nil { + for _, v := range ret.Data.(*LoadAfterData).ItemLogs { + bagInfo.Ts = v.CreateTs + bagInfo.dirty = true + + num := v.Count + if v.LogType == 1 { + num = -num + } + + for _, f := range this.OnChangeFuncs { + f(&model.ChangeItemParam{ + SnId: p.SnId, + ItemId: v.ItemId, + ItemNum: num, + GainWay: v.TypeId, + RoomConfigId: v.RoomConfigId, + GameId: v.GameId, + GameFreeId: v.GameFreeId, + Cost: v.Cost, + }) + } + } + } } } func (this *BagMgr) Save(platform string, snid int32, isSync, force bool) { - bagInfo := this.PlayerBag[snid] - logger.Logger.Trace("SaveBagData:", bagInfo) - - if bagInfo == nil || (!bagInfo.dirty && !force) { + bagInfo := this.GetBagInfo(snid) + if bagInfo == nil { return } - - type BagInfoMap struct { - SnId int32 //玩家账号直接在这里生成 - Platform string //平台 - BagItem []*Item //背包数据 key为itemId - } - // biMap 数据拷贝 - var biMap = BagInfoMap{ - SnId: bagInfo.SnId, - Platform: bagInfo.Platform, - } - for _, v := range bagInfo.BagItem { - biMap.BagItem = append(biMap.BagItem, &Item{ItemId: v.ItemId, ItemNum: v.ItemNum, ObtainTime: v.ObtainTime}) + if !bagInfo.dirty && !force { + return } + logger.Logger.Tracef("SaveBagData: %+v", *bagInfo) var err error f := func() { newBagInfo := &model.BagInfo{ - SnId: biMap.SnId, - Platform: biMap.Platform, + SnId: bagInfo.SnId, + Platform: bagInfo.Platform, + Ts: bagInfo.Ts, BagItem: make(map[int32]*model.Item), } - for _, v := range biMap.BagItem { + for _, v := range bagInfo.BagItem { newBagInfo.BagItem[v.ItemId] = &model.Item{ItemId: v.ItemId, ItemNum: v.ItemNum, ObtainTime: v.ObtainTime} } err = model.UpBagItem(newBagInfo) } cf := func() { - if err == nil { - bagInfo.dirty = false + if err == nil && this.PlayerBag[snid] != nil { + this.PlayerBag[snid].dirty = false } } @@ -927,14 +988,9 @@ func (this *BagMgr) Save(platform string, snid int32, isSync, force bool) { return nil }), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) { cf() - }), "SaveBagData").StartByFixExecutor("SnId:" + strconv.Itoa(int(snid))) + })).StartByExecutor(fmt.Sprintf("Player%v", snid)) } func (this *BagMgr) Release(platform string, snid int32) { delete(this.PlayerBag, snid) } - -func init() { - module.RegisteModule(BagMgrSingleton, time.Second, 0) - internal.RegisterPlayerLoad(BagMgrSingleton) -} diff --git a/worldsrv/player.go b/worldsrv/player.go index 39e4967..ace497e 100644 --- a/worldsrv/player.go +++ b/worldsrv/player.go @@ -264,7 +264,7 @@ func (this *Player) LoadAfter() { } v.CallbackAfter(replays[k]) } - })).StartByFixExecutor(fmt.Sprintf("Player%v", this.SnId)) + })).StartByExecutor(fmt.Sprintf("Player%v", this.SnId)) } func (this *Player) OnLogined() { @@ -1125,10 +1125,10 @@ func (this *Player) GetMessageAttach(id string) { // 领取道具 addItem := func() { - items := make([]*Item, 0) + items := make([]*model.Item, 0) if num := len(msg.Params); num > 0 && num%2 == 0 { for i := 0; i < num; i += 2 { - items = append(items, &Item{ + items = append(items, &model.Item{ ItemId: msg.Params[i], // 物品id ItemNum: int64(msg.Params[i+1]), // 数量 ObtainTime: time.Now().Unix(), @@ -1147,14 +1147,13 @@ func (this *Player) GetMessageAttach(id string) { } } } - if _, code, _ := BagMgrSingleton.AddItems(this, items, 0, gainWay, "mail", remark, 0, 0, false); code != bag.OpResultCode_OPRC_Sucess { // 领取失败 - logger.Logger.Errorf("CSPlayerSettingHandler AddItems err", code) - pack := &msgproto.SCGetMessageAttach{ - Id: proto.String(""), - } - proto.SetDefaults(pack) - this.SendToClient(int(msgproto.MSGPacketID_PACKET_SC_GETMESSAGEATTACH), pack) - } + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: this.PlayerData, + Change: items, + GainWay: gainWay, + Operator: "mail", + Remark: remark, + }) this.dirty = true } } @@ -1277,182 +1276,6 @@ func (this *Player) GetMessageAttach(id string) { } } -// 一键领取 -func (this *Player) GetMessageAttachs(ids []string) { - var msgs []*model.Message - var Ids []string // 可以领取的邮件 - var platform string - for _, id := range ids { - if msg, exist := this.msgs[id]; exist { - if msg.AttachState == model.MSGATTACHSTATE_DEFAULT && (msg.Coin > 0 || msg.Ticket > 0 || - msg.Grade > 0 || len(msg.Params) > 0 || msg.Diamond > 0) { - Ids = append(Ids, id) - platform = msg.Platform - } - } - } - - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - - magids, err := model.GetMessageAttachs(Ids, platform) - if err != nil { - logger.Logger.Trace("GetMessageAttachs err ", err) - } - return magids - }), task.CompleteNotifyWrapper(func(data interface{}, tt task.Task) { - magids, ok := data.(*[]string) - - if ok && magids != nil { - for _, id := range *magids { - if msg, exist := this.msgs[id]; exist { - if msg.AttachState == model.MSGATTACHSTATE_DEFAULT && (msg.Coin > 0 || msg.Ticket > 0 || - msg.Grade > 0 || len(msg.Params) > 0 || msg.Diamond > 0) { - msgs = append(msgs, msg) - platform = msg.Platform - } - } - } - - pack := &msgproto.SCGetMessageAttach{ - // Id: proto.String(id), - } - - for _, msg := range msgs { - pack.Ids = append(pack.Ids, msg.Id.Hex()) - dirtyCoin := int64(0) - msg.AttachState = model.MSGATTACHSTATE_GOT - notifyClient := true - var remark string - var gainWay int32 = common.GainWay_MessageAttach - switch msg.MType { - case model.MSGTYPE_ITEM: - remark = "领取道具" - gainWay = common.GainWay_MAIL_MTEM - dirtyCoin = msg.Coin - items := make([]*Item, 0) - if num := len(msg.Params); num > 0 && num%2 == 0 { - for i := 0; i < num; i += 2 { - items = append(items, &Item{ - ItemId: msg.Params[i], // 物品id - ItemNum: int64(msg.Params[i+1]), // 数量 - ObtainTime: time.Now().Unix(), - }) - } - if _, code, _ := BagMgrSingleton.AddItems(this, items, 0, gainWay, "mail", remark, 0, 0, false); code != bag.OpResultCode_OPRC_Sucess { // 领取失败 - logger.Logger.Errorf("CSPlayerSettingHandler AddItems err", code) - /* - pack := &msg_proto.SCGetMessageAttach{ - Id: proto.String(""), - } - proto.SetDefaults(pack) - this.SendToClient(int(msg_proto.MSGPacketID_PACKET_SC_GETMESSAGEATTACH), pack) - */ - } - this.dirty = true - } - case model.MSGTYPE_IOSINSTALLSTABLE: - remark = "IOS下载稳定版本" - gainWay = common.GainWay_IOSINSTALLSTABLE - dirtyCoin = msg.Coin - case model.MSGTYPE_GIFT: - remark = "礼物" - case model.MSGTYPE_GOLDCOMERANK: - remark = "财神降临奖励" - gainWay = common.GainWay_GoldCome - notifyClient = false - dirtyCoin = msg.Coin - case model.MSGTYPE_RANDCOIN: - remark = "红包雨" - gainWay = common.GainWay_OnlineRandCoin - notifyClient = false - dirtyCoin = msg.Coin - case model.MSGTYPE_REBATE: - remark = "流水返利" - gainWay = common.GainWay_RebateTask - notifyClient = false - dirtyCoin = msg.Coin - //邮件领取 添加日志 - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - return model.InsertRebateLog(this.Platform, &model.Rebate{ - SnId: this.SnId, - RebateCoin: msg.Coin, - ReceiveType: 1, - CodeCoin: 0, - }) - }), nil, "InsertRebateLog").StartByFixExecutor("ReceiveCodeCoin") - case model.MSGTYPE_ClubGet: - //if len(msg.Params) != 0 { - // //如果俱乐部解散 就存msg.Params[0] - // remark = fmt.Sprintf("%v", msg.Params[0]) - //} - //gainWay = common.GainWay_ClubGetCoin - //dirtyCoin = msg.Coin - case model.MSGTYPE_ClubPump: - //if len(msg.Params) != 0 { - // remark = fmt.Sprintf("%v", msg.Params[0]) - //} - //gainWay = common.GainWay_ClubPumpCoin - //notifyClient = false - //dirtyCoin = msg.Coin - case model.MSGTYPE_MATCH_SIGNUPFEE: - gainWay = common.GainWay_MatchBreakBack - notifyClient = false - case model.MSGTYPE_MATCH_TICKETREWARD: - gainWay = common.GainWay_MatchSystemSupply - notifyClient = false - this.TicketTotal += msg.Ticket - case model.MSGTYPE_MATCH_SHOPEXCHANGE: - remark = "积分商城兑换" - gainWay = common.GainWay_Exchange - case model.MSGTYPE_MATCH_SHOPERETURN: - remark = "撤单返还" - gainWay = common.GainWay_GradeShopReturn - } - if msg.Coin > 0 { - this.AddCoin(msg.Coin, 0, gainWay, msg.Id.Hex(), remark) - //增加泥码 - this.AddDirtyCoin(0, dirtyCoin) - //俱乐部获取不算系统赠送 - if msg.MType != model.MSGTYPE_ClubGet { - this.ReportSystemGiveEvent(int32(msg.Coin), gainWay, notifyClient) //邮件附件算是系统赠送 - } else { //俱乐部获取算充值 - this.AddCoinGiveLog(msg.Coin, 0, 0, gainWay, model.COINGIVETYPE_PAY, "club", "club") - } - this.AddPayCoinLog(msg.Coin, model.PayCoinLogType_Coin, "mail") - if msg.Oper == 0 { //系统赠送 - if !this.IsRob { - LogChannelSingleton.WriteMQData(model.GenerateSystemFreeGive(this.SnId, this.Name, this.Platform, this.Channel, model.SystemFreeGive_GiveType_MailSystemGive, - model.SystemFreeGive_CoinType_Coin, int64(msg.Coin))) - } - } - } - if msg.Ticket > 0 { - //增加报名券 - this.AddTicket(msg.Ticket, gainWay, msg.Id.Hex(), remark) - } - if msg.Grade > 0 { - //增加积分 - this.AddGrade(msg.Grade, gainWay, msg.Id.Hex(), remark) - } - if msg.Diamond > 0 { - this.AddDiamond(msg.Diamond, 0, gainWay, msg.Id.Hex(), remark) - if msg.Oper == 0 { //系统赠送 - if !this.IsRob { - LogChannelSingleton.WriteMQData(model.GenerateSystemFreeGive(this.SnId, this.Name, this.Platform, this.Channel, model.SystemFreeGive_GiveType_MailSystemGive, - model.SystemFreeGive_CoinType_Diamond, int64(msg.Diamond))) - } - } - } - - } - - proto.SetDefaults(pack) - this.SendToClient(int(msgproto.MSGPacketID_PACKET_SC_GETMESSAGEATTACH), pack) - } - }), "GetMessageAttach").StartByFixExecutor("logic_message") - -} - func (this *Player) GetMessageByGiftId(id string) *model.Message { for _, msg := range this.msgs { if msg.GiftId == id && msg.State != model.MSGSTATE_REMOVEED { @@ -1853,7 +1676,7 @@ func (this *Player) Save(force bool) { } } }), "SavePlayerTask") - if b := t.StartByExecutor(strconv.Itoa(int(this.SnId))); b { + if b := t.StartByExecutor(fmt.Sprintf("Player%v", this.SnId)); b { this.lastSaved = time.Now() } } @@ -3860,7 +3683,7 @@ func (this *Player) VIPDraw(id, vip int32) { this.AddMoneyPayTotal(addVipExp) pack.Award[common.ItemIDVipExp] = addVipExp default: - BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + BagMgrSingleton.AddItems(&model.AddItemParam{ P: this.PlayerData, Change: []*model.Item{ { @@ -3893,7 +3716,7 @@ func (this *Player) VIPDraw(id, vip int32) { itemInfo = append(itemInfo, model.ItemInfo{ItemId: int32(k), ItemNum: v}) pack.Award[k] = v } - BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + BagMgrSingleton.AddItems(&model.AddItemParam{ P: this.PlayerData, Change: items, GainWay: common.GainWayVipGift9, @@ -4021,7 +3844,7 @@ func (this *Player) GetPayGoodsInfo() { logger.Logger.Tracef("GetPayGoodsInfo ShopPageBackend %+v", *info) default: var itemInfo []*playerproto.PayItem - var items []*Item + var items []*model.Item if len(info.Amount) > 0 { this.AddCoin(int64(info.Amount[0]), 0, info.GainWay, "Callback_login", info.Remark) this.AddDiamond(int64(info.Amount[1]), 0, info.GainWay, "Callback_login", info.Remark) @@ -4030,7 +3853,7 @@ func (this *Player) GetPayGoodsInfo() { this.MoneyTotal += int64(info.ConsumeTypeNum) if info.ItemInfo != nil { for _, v := range info.ItemInfo { - items = append(items, &Item{ItemId: v.ItemId, ItemNum: v.ItemNum}) + items = append(items, &model.Item{ItemId: v.ItemId, ItemNum: v.ItemNum}) itemInfo = append(itemInfo, &playerproto.PayItem{ ItemId: v.ItemId, ItemNum: v.ItemNum, @@ -4086,7 +3909,13 @@ func (this *Player) GetPayGoodsInfo() { info.Amount[2] = int32(this.GetVIPExpByPay(int64(info.ConsumeNum))) - BagMgrSingleton.AddItems(this, items, 0, info.GainWay, info.Operator, info.Remark, 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: this.PlayerData, + Change: items, + GainWay: info.GainWay, + Operator: info.Operator, + Remark: info.Remark, + }) PayGoodsInfo := &playerproto.SCPayGoodsInfo{ Gold: info.Amount, @@ -4453,27 +4282,36 @@ func (this *Player) BindTelReward() { // 发送奖励 plt := PlatformMgrSingleton.GetPlatform(this.Platform) if plt != nil { - var items []*Item + var items []*model.Item for k, v := range plt.BindTelReward { switch k { case 1: - items = append(items, &Item{ + items = append(items, &model.Item{ ItemId: common.ItemIDCoin, ItemNum: v, }) case 2: - items = append(items, &Item{ + items = append(items, &model.Item{ ItemId: common.ItemIDDiamond, ItemNum: v, }) default: - items = append(items, &Item{ + items = append(items, &model.Item{ ItemId: k, ItemNum: v, }) } } - BagMgrSingleton.AddItems(this, items, 0, common.GainWay_BindTel, "system", "绑定手机号", 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: this.PlayerData, + Change: items, + Add: 0, + GainWay: common.GainWay_BindTel, + Operator: "system", + Remark: "绑定手机号奖励", + GameId: 0, + GameFreeId: 0, + }) } } @@ -4654,14 +4492,19 @@ func (this *Player) CollectTask(taskId int32, num int64) { // 每日转盘抽奖赠送一个 switch taskId { case common.TaskTypeTurnplate, common.TaskTypeFirstLogin: - oper := fmt.Sprintf("集卡活动%v", taskId) - var items []*Item - items = append(items, &Item{ - ItemId: common.ItemIDCollectBox, - ItemNum: num, - ObtainTime: time.Now().Unix(), + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: this.PlayerData, + Change: []*model.Item{ + { + ItemId: common.ItemIDCollectBox, + ItemNum: num, + ObtainTime: time.Now().Unix(), + }, + }, + GainWay: common.GainWayItemCollectLogin, + Operator: "system", + Remark: fmt.Sprintf("集卡活动%v", taskId), }) - BagMgrSingleton.AddItems(this, items, 0, common.GainWayItemCollectLogin, "system", oper, 0, 0, false) default: } } @@ -4750,16 +4593,22 @@ func (this *Player) GetWeekCardAwary(id int32) { if !this.WeekCardAward[id] { //获取周卡奖励 items := data.GetDayRewards() - addItem := []*Item{} + var addItem []*model.Item for itemId, itemNum := range items { - item := &Item{ItemId: int32(itemId), ItemNum: itemNum, ObtainTime: time.Now().Unix()} + item := &model.Item{ItemId: int32(itemId), ItemNum: itemNum, ObtainTime: time.Now().Unix()} addItem = append(addItem, item) itemInfo := &playerproto.PayItem{} itemInfo.ItemId = int32(itemId) itemInfo.ItemNum = itemNum ret.Items = append(ret.Items, itemInfo) } - BagMgrSingleton.AddItems(this, addItem, 0, common.GainWay_WeekCardAward, "system", "周卡每日奖励", 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: this.PlayerData, + Change: addItem, + GainWay: common.GainWay_WeekCardAward, + Operator: "system", + Remark: "周卡每日奖励", + }) //返回消息 this.WeekCardAward[id] = true ret.WeekCardAward = this.WeekCardAward[id] diff --git a/worldsrv/playercache.go b/worldsrv/playercache.go index 94b7334..aeb2057 100644 --- a/worldsrv/playercache.go +++ b/worldsrv/playercache.go @@ -1,7 +1,7 @@ package main import ( - "strconv" + "fmt" "time" "mongo.games.com/goserver/core" @@ -153,7 +153,7 @@ func (c *PlayerCacheMgr) Get(plt string, snid int32, cb func(*PlayerCacheItem, b } } - }), "PlayerCacheMgr.Get").StartByExecutor(strconv.Itoa(int(snid))) + })).StartByExecutor(fmt.Sprintf("Player%v", snid)) } func (c *PlayerCacheMgr) GetMore(plt string, snid []int32, cb func([]*PlayerCacheItem, bool)) { diff --git a/worldsrv/scenepolicydata.go b/worldsrv/scenepolicydata.go index da9f6f3..eaf3a7e 100644 --- a/worldsrv/scenepolicydata.go +++ b/worldsrv/scenepolicydata.go @@ -146,7 +146,7 @@ func (spd *ScenePolicyData) CostPayment(s *Scene, p *Player) bool { for _, v := range items { v.ItemNum = -v.ItemNum } - BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + BagMgrSingleton.AddItems(&model.AddItemParam{ P: p.PlayerData, Change: items, GainWay: common.GainWayRoomCost, @@ -180,7 +180,7 @@ func (spd *ScenePolicyData) GiveCostPayment(s *Scene, snid int32) bool { p := PlayerMgrSington.GetPlayerBySnId(snid) if p != nil { - BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + BagMgrSingleton.AddItems(&model.AddItemParam{ P: p.PlayerData, Change: items, GainWay: common.GainWayRoomCost, @@ -192,10 +192,19 @@ func (spd *ScenePolicyData) GiveCostPayment(s *Scene, snid int32) bool { RoomConfigId: roomConfig.GetId(), }) } else { - BagMgrSingleton.AddItemsOffline(s.limitPlatform.IdStr, snid, items, common.GainWayRoomCost, "system", - "竞技场费用返还", int64(s.gameId), int64(s.dbGameFree.GetId()), false, func(err error) { - logger.Logger.Errorf("竞技场房间费用返还失败, err: %v", err) - }) + BagMgrSingleton.AddItemsOffline(s.limitPlatform.IdStr, snid, &model.AddItemParam{ + P: nil, + Change: items, + GainWay: common.GainWayRoomCost, + Operator: "system", + Remark: "竞技场房间费用返还", + GameId: int64(s.gameId), + GameFreeId: int64(s.dbGameFree.GetId()), + NoLog: false, + RoomConfigId: roomConfig.GetId(), + }, func(err error) { + logger.Logger.Errorf("竞技场房间费用返还失败, err: %v", err) + }) } return false } diff --git a/worldsrv/shopmgr.go b/worldsrv/shopmgr.go index 22551fe..e6f9059 100644 --- a/worldsrv/shopmgr.go +++ b/worldsrv/shopmgr.go @@ -4,8 +4,6 @@ import ( "encoding/json" "fmt" "math/rand" - "mongo.games.com/game/protocol/bag" - "mongo.games.com/game/srvdata" "slices" "time" @@ -21,6 +19,7 @@ import ( hall_proto "mongo.games.com/game/protocol/gamehall" "mongo.games.com/game/protocol/shop" webapi_proto "mongo.games.com/game/protocol/webapi" + "mongo.games.com/game/srvdata" "mongo.games.com/game/webapi" ) @@ -541,8 +540,18 @@ func (this *ShopMgr) shopAddItem(p *Player, shopInfo *model.ShopInfo, vipShopId } for _, info := range shopInfo.GetItems() { - item := &Item{ItemId: info.ItemId, ItemNum: info.ItemNum, ObtainTime: time.Now().Unix()} - BagMgrSingleton.AddItems(p, []*Item{item}, 0, int32(gainWay), "system", name, 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: info.ItemId, + ItemNum: info.ItemNum, + }, + }, + GainWay: int32(gainWay), + Operator: "system", + Remark: name, + }) } } @@ -692,12 +701,18 @@ func (this *ShopMgr) GainShop(shopInfo *model.ShopInfo, p *Player, vipShopId, po case ShopConsumePhoneScore: p.AddPhoneScore(-costNum, 0, gainWay, "sys", shopName) case ShopConsumeDiamondScore: - var items []*Item - items = append(items, &Item{ - ItemId: common.ItemDiamondScore, // 物品id - ItemNum: int64(-costNum), // 数量 + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: common.ItemDiamondScore, + ItemNum: -costNum, + }, + }, + GainWay: common.GainWayBuyItem, + Operator: "system", + Remark: "商城购买消耗钻石积分", }) - BagMgrSingleton.AddItems(p, items, 0, common.GainWayBuyItem, "system", "商城购买消耗钻石积分", 0, 0, false) default: logger.Logger.Errorf("GainShop ConstType[%v] err", shopInfo.ConstType) return shop.OpResultCode_OPRC_Error @@ -849,37 +864,61 @@ func (this *ShopMgr) Exchange(p *Player, goodsId int32, username, mobile, commen return false } - var itemInfo []model.ItemInfo + var itemInfo []*model.Item // TODO 服务器处理 减劵 成功后调后台生成订单 // 判断p.VCoin是否足够 不足返回错误 足够扣掉 另外需从后台操作回执成功生成扣除V卡的订单 回执失败 //扣除V卡 if info.Price > 0 { - item := model.ItemInfo{ - ItemId: common.ItemIDVCard, - ItemNum: int64(info.Price * num), - } - _, code, _ := BagMgrSingleton.AddItem(p, int64(item.ItemId), -item.ItemNum, 0, common.GainWay_Exchange, - "sys", fmt.Sprintf("兑换扣除%v", item.ItemId), 0, 0, false) - if code != bag.OpResultCode_OPRC_Sucess { // 扣掉V卡 + item := BagMgrSingleton.GetItem(p.SnId, common.ItemIDVCard) + n := int64(info.Price * num) + if item != nil && item.ItemNum >= n { + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: item.ItemId, + ItemNum: -n, + }, + }, + GainWay: common.GainWay_Exchange, + Operator: "system", + Remark: fmt.Sprintf("兑换扣除%v", item.ItemId), + }) + } else { p.SendToClient(int(shop.SPacketID_PACKET_SC_SHOP_EXCHANGE), pack) return false } - itemInfo = append(itemInfo, item) + itemInfo = append(itemInfo, &model.Item{ + ItemId: item.ItemId, + ItemNum: n, + }) } //扣除金券 if info.JPrice > 0 { - item := model.ItemInfo{ - ItemId: common.ItemIDJCard, - ItemNum: int64(info.JPrice * num), - } - _, _, isF := BagMgrSingleton.AddItem(p, int64(item.ItemId), -item.ItemNum, 0, common.GainWay_Exchange, - "sys", fmt.Sprintf("兑换扣除%v", item.ItemId), 0, 0, false) - if !isF { // 扣掉金券 + item := BagMgrSingleton.GetItem(p.SnId, common.ItemIDJCard) + n := int64(info.JPrice * num) + if item != nil && item.ItemNum >= n { + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: item.ItemId, + ItemNum: -n, + }, + }, + GainWay: common.GainWay_Exchange, + Operator: "system", + Remark: fmt.Sprintf("兑换扣除%v", item.ItemId), + }) + } else { pack.RetCode = shop.OpResultCode_OPRC_JCoinNotEnough p.SendToClient(int(shop.SPacketID_PACKET_SC_SHOP_EXCHANGE), pack) return false } - itemInfo = append(itemInfo, item) + itemInfo = append(itemInfo, &model.Item{ + ItemId: item.ItemId, + ItemNum: n, + }) } task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { pack := &webapi_proto.ASCreateExchangeOrder{ @@ -912,8 +951,15 @@ func (this *ShopMgr) Exchange(p *Player, goodsId int32, username, mobile, commen } var amount [ShopParamMax]int32 //保存db + var items []model.ItemInfo + for _, v := range itemInfo { + items = append(items, model.ItemInfo{ + ItemId: v.ItemId, + ItemNum: v.ItemNum, + }) + } dbShop := this.NewDbShop(p, 0, amount[:], ExchangeConsumeCash, info.Cash*num, - common.GainWay_ShopBuy, itemInfo, cdata.Id, cdata.Name, 0, "", []int32{}) + common.GainWay_ShopBuy, items, cdata.Id, cdata.Name, 0, "", []int32{}) err = model.InsertDbShopLog(dbShop) if err != nil { logger.Logger.Errorf("model.InsertDbShopLog err:", err) @@ -980,16 +1026,15 @@ func (this *ShopMgr) Exchange(p *Player, goodsId int32, username, mobile, commen } } logger.Logger.Trace("API_CreateExchange: ", as.Tag, as.GetReturnCPO()) - var items []*Item - for _, v := range itemInfo { - items = append(items, &Item{ - ItemId: v.ItemId, - ItemNum: v.ItemNum, + if len(itemInfo) > 0 { + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: itemInfo, + GainWay: common.GainWay_Exchange, + Operator: "system", + Remark: "兑换返还", }) } - if len(items) > 0 { - BagMgrSingleton.AddItems(p, items, 0, common.GainWay_Exchange, "system", "返还物品", 0, 0, false) // 后台订单创建失败 返回物品 - } } p.SendToClient(int(shop.SPacketID_PACKET_SC_SHOP_EXCHANGE), pack) diff --git a/worldsrv/tournament.go b/worldsrv/tournament.go index ad3eee2..741b826 100644 --- a/worldsrv/tournament.go +++ b/worldsrv/tournament.go @@ -600,12 +600,36 @@ func (this *Tournament) signUpCost(p *Player, tmId int32, cost bool) (bool, int3 logger.Logger.Trace("道具不足") return false, int32(tournament.SignRaceCode_OPRC_NoItem) } else { - BagMgrSingleton.AddItem(p, int64(item.ItemId), -gmd.SignupCostItem.ItemNum, 0, common.GainWay_MatchSignup, - "player", gmd.MatchName+"-报名消耗", gameId, int64(gmd.GameFreeId), false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: item.ItemId, + ItemNum: -gmd.SignupCostItem.ItemNum, + }, + }, + GainWay: common.GainWay_MatchSignup, + Operator: "player", + Remark: gmd.MatchName + "-报名消耗", + GameId: gameId, + GameFreeId: int64(gmd.GameFreeId), + }) } } else { - BagMgrSingleton.AddItem(p, int64(item.ItemId), gmd.SignupCostItem.ItemNum, 0, common.GainWay_MatchSignup, - "player", gmd.MatchName+"-报名退还", gameId, int64(gmd.GameFreeId), false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: item.ItemId, + ItemNum: gmd.SignupCostItem.ItemNum, + }, + }, + GainWay: common.GainWay_MatchSignup, + Operator: "player", + Remark: gmd.MatchName + "-报名退还", + GameId: gameId, + GameFreeId: int64(gmd.GameFreeId), + }) } } else { logger.Logger.Trace("道具不足") @@ -1384,11 +1408,20 @@ func (this *Tournament) sendPromotionInfo(mc *PlayerMatchContext, sortId int64, if info.ItemNum <= 0 { continue } - item := &Item{ - ItemId: info.ItemId, - ItemNum: int64(info.ItemNum), - } - BagMgrSingleton.AddItems(mc.p, []*Item{item}, 0, common.GainWay_MatchSystemSupply, "system", mc.tm.gmd.MatchName+"排名奖励", 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: mc.p.PlayerData, + Change: []*model.Item{ + { + ItemId: info.ItemId, + ItemNum: int64(info.ItemNum), + }, + }, + GainWay: common.GainWay_MatchSystemSupply, + Operator: "system", + Remark: mc.tm.gmd.MatchName + "排名奖励", + GameId: int64(mc.tm.dbGameFree.GetGameId()), + GameFreeId: int64(mc.tm.dbGameFree.GetId()), + }) } } } diff --git a/worldsrv/trascate_webapi.go b/worldsrv/trascate_webapi.go index bb2e4e6..2cf5e48 100644 --- a/worldsrv/trascate_webapi.go +++ b/worldsrv/trascate_webapi.go @@ -3387,7 +3387,7 @@ func init() { remark := fmt.Sprintf("兑换撤单 %v-%v", msg.GoodsId, msg.Name) if player != nil { // 在线 - if _, code, _ := BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + if _, code, _ := BagMgrSingleton.AddItems(&model.AddItemParam{ P: player.PlayerData, Change: items, GainWay: common.GainWay_Exchange, @@ -3402,18 +3402,22 @@ func init() { pack.Msg = "UpExchange success" return common.ResponseTag_Ok, pack } else { - BagMgrSingleton.AddItemsOffline(platform, snid, items, common.GainWay_Exchange, - "system", remark, 0, 0, false, func(err error) { - if err != nil { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "UpExchange failed:" + err.Error() - } else { - pack.Tag = webapiproto.TagCode_SUCCESS - pack.Msg = "UpExchange success" - } - tNode.TransRep.RetFiels = pack - tNode.Resume() - }) + BagMgrSingleton.AddItemsOffline(platform, snid, &model.AddItemParam{ + Change: items, + GainWay: common.GainWay_Exchange, + Operator: "system", + Remark: remark, + }, func(err error) { + if err != nil { + pack.Tag = webapiproto.TagCode_FAILED + pack.Msg = "UpExchange failed:" + err.Error() + } else { + pack.Tag = webapiproto.TagCode_SUCCESS + pack.Msg = "UpExchange success" + } + tNode.TransRep.RetFiels = pack + tNode.Resume() + }) return common.ResponseTag_TransactYield, pack } })) @@ -3457,17 +3461,23 @@ func init() { info.Amount[2] = int32(player.GetVIPExpByPay(int64(info.ConsumeNum))) var itemInfo []*playerproto.PayItem - var items []*Item + var items []*model.Item if info.ItemInfo != nil { for _, v := range info.ItemInfo { - items = append(items, &Item{ItemId: v.ItemId, ItemNum: v.ItemNum}) + items = append(items, &model.Item{ItemId: v.ItemId, ItemNum: v.ItemNum}) itemInfo = append(itemInfo, &playerproto.PayItem{ ItemId: v.ItemId, ItemNum: v.ItemNum, }) } } - BagMgrSingleton.AddItems(player, items, 0, info.GainWay, "Callback", info.Remark, 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: player.PlayerData, + Change: items, + GainWay: info.GainWay, + Operator: "Callback", + Remark: info.Remark, + }) //钻石存储罐 if info.PageId == ShopPageDiamondBank { WelfareMgrSington.DiamondBankTakeCoin(player) @@ -3761,7 +3771,7 @@ func init() { p := PlayerMgrSington.GetPlayerBySnId(msg.GetSnid()) if p != nil { //获取道具Id - _, _, ok := BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + _, _, ok := BagMgrSingleton.AddItems(&model.AddItemParam{ P: p.PlayerData, Change: items, GainWay: msg.GetTypeId(), @@ -3778,18 +3788,22 @@ func init() { pack.Msg = "修改道具成功" return common.ResponseTag_Ok, pack } else { - BagMgrSingleton.AddItemsOffline(msg.Platform, msg.Snid, items, msg.GetTypeId(), - "system", msg.GetRemark(), 0, 0, false, func(err error) { - if err != nil { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "AddItem failed:" + err.Error() - } else { - pack.Tag = webapiproto.TagCode_SUCCESS - pack.Msg = "AddItem success" - } - tNode.TransRep.RetFiels = pack - tNode.Resume() - }) + BagMgrSingleton.AddItemsOffline(msg.Platform, msg.Snid, &model.AddItemParam{ + Change: items, + GainWay: msg.GetTypeId(), + Operator: "system", + Remark: msg.GetRemark(), + }, func(err error) { + if err != nil { + pack.Tag = webapiproto.TagCode_FAILED + pack.Msg = "AddItem failed:" + err.Error() + } else { + pack.Tag = webapiproto.TagCode_SUCCESS + pack.Msg = "AddItem success" + } + tNode.TransRep.RetFiels = pack + tNode.Resume() + }) return common.ResponseTag_TransactYield, pack } })) diff --git a/worldsrv/welfmgr.go b/worldsrv/welfmgr.go index ae526d8..e28bd73 100644 --- a/worldsrv/welfmgr.go +++ b/worldsrv/welfmgr.go @@ -568,11 +568,19 @@ func DrawWelfareDate(dates []*webapi_proto.WelfareDate, p *Player, gainWay int32 } case 3: //道具 if v.Grade > 0 { - item := &Item{ - ItemId: v.Item_Id, - ItemNum: int64(v.Grade), - } - BagMgrSingleton.AddItems(p, []*Item{item}, 0, gainWay, oper, remark, 0, 0, false) + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: v.Item_Id, + ItemNum: int64(v.Grade), + }, + }, + Add: 0, + GainWay: gainWay, + Operator: oper, + Remark: remark, + }) } } } @@ -887,7 +895,7 @@ func (this *WelfareMgr) GetAddUp2Award(p *Player, day int32) { items = append(items, item) } } - BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + BagMgrSingleton.AddItems(&model.AddItemParam{ P: p.PlayerData, Change: items, Cost: cost, From ba27fa4b3a2bcfa8618155eb11fbb6bc47543303 Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Thu, 19 Sep 2024 11:37:25 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=87=91=E5=B8=81=E9=81=93=E5=85=B7?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/baginfo.go | 20 ++-- worldsrv/action_player.go | 1 + worldsrv/bagmgr.go | 8 +- worldsrv/player.go | 194 ++++++++++++++++---------------------- worldsrv/shopmgr.go | 28 ++++-- 5 files changed, 116 insertions(+), 135 deletions(-) diff --git a/model/baginfo.go b/model/baginfo.go index cc16aff..ecbafae 100644 --- a/model/baginfo.go +++ b/model/baginfo.go @@ -87,16 +87,16 @@ func SaveToDelBackupBagItem(args *BagInfo) error { } type AddItemParam struct { - P *PlayerData - Change []*Item // 道具变化数量 - Cost []*Item // 获得道具时消耗的道具数量 - Add int64 // 加成数量 - GainWay int32 // 记录类型 - Operator, Remark string // 操作人,备注 - GameId, GameFreeId int64 // 游戏id,场次id - NoLog bool // 是否不记录日志 - LogId string // 撤销的id,道具兑换失败 - RoomConfigId int32 // 房间配置id + P *PlayerData // 玩家信息,玩家离线时不传 + Change []*Item // 道具变化数量 + Cost []*Item // 获得道具时消耗的道具数量 + Add int64 // 加成数量 + GainWay int32 // 记录类型 + Operator, Remark string // 操作人,备注 + GameId, GameFreeId int64 // 游戏id,场次id + NoLog bool // 是否不记录日志 + LogId string // 撤销的id,道具兑换失败 + RoomConfigId int32 // 房间配置id } type ChangeItemParam struct { diff --git a/worldsrv/action_player.go b/worldsrv/action_player.go index c64484d..c4506a2 100644 --- a/worldsrv/action_player.go +++ b/worldsrv/action_player.go @@ -1722,6 +1722,7 @@ func (this *CSPlayerVIPInfoHandler) Process(s *netlib.Session, packetid int, dat logger.Logger.Warn("CSPlayerVIPInfoHandler p == nil") return nil } + p.GetVIPLevel() p.SCVIPInfo() } return nil diff --git a/worldsrv/bagmgr.go b/worldsrv/bagmgr.go index 05f56a8..6ba0902 100644 --- a/worldsrv/bagmgr.go +++ b/worldsrv/bagmgr.go @@ -394,12 +394,12 @@ func (this *BagMgr) AddItems(param *model.AddItemParam) (*BagInfo, bag.OpResultC } case common.ItemTypeFishPower: //增加炮台 - p.ItemUnPlayerPowerListEx(v.ItemId) + //p.ItemUnPlayerPowerListEx(v.ItemId) case common.ItemTypeMoneyPond: //增加个人金币池 - if v.ItemId == common.ItemIDMoneyPond { - p.MoneyPond += v.ItemNum - } + //if v.ItemId == common.ItemIDMoneyPond { + // p.MoneyPond += v.ItemNum + //} case common.ItemTypeVipExp: //增加玩家VIP经验 if v.ItemId == common.ItemIDVipExp { diff --git a/worldsrv/player.go b/worldsrv/player.go index ace497e..1aba70e 100644 --- a/worldsrv/player.go +++ b/worldsrv/player.go @@ -310,13 +310,7 @@ func (this *Player) OnLogined() { this.SetOnline() //测试用 - if !this.IsRob { - old := this.VIP - this.VIP = this.GetVIPLevel() - if old != this.VIP { - this.dirty = true - } - } else { + if this.IsRob { this.VIP = rand.Int31n(6) + 1 //机器人随机vip和头像 this.RobRandVip() @@ -1720,55 +1714,46 @@ func (this *Player) AddDiamond(num, add int64, gainWay int32, oper, remark strin return } logger.Logger.Tracef("snid(%v) AddDiamond(%v)", this.SnId, num) - //async := false - //if num > 0 && this.scene != nil && !this.scene.IsTestScene() && this.scene.sceneMode != common.SceneMode_Thr { //游戏场中加币,需要同步到gamesrv上 - // if StartAsyncAddCoinTransact(this, num, gainWay, oper, remark, true, 0, true) { - // async = true - // } - //} - - if num != 0 /*&& !async*/ { - this.dirty = true - if num > 0 { - this.Diamond += num + this.dirty = true + if num > 0 { + this.Diamond += num + } else { + if -num > this.Diamond { + logger.Logger.Errorf("Player.AddCoin exception!!! num(%v) oper(%v)", num, oper) + num = -this.Diamond + this.Diamond = 0 } else { - if -num > this.Diamond { - logger.Logger.Errorf("Player.AddCoin exception!!! num(%v) oper(%v)", num, oper) - num = -this.Diamond - this.Diamond = 0 - } else { - this.Diamond += num - } - switch gainWay { - case common.GainWay_MatchSignup: // 排除的 - default: - TaskSubjectSingleton.Touch(common.TaskTypeCostDiamond, &TaskData{ - SnId: this.SnId, - Num: -num, - }) - } + this.Diamond += num } - - this.SendDiffData() - if !this.IsRob { - log := model.NewCoinLogEx(&model.CoinLogParam{ - Platform: this.Platform, - SnID: this.SnId, - Channel: this.Channel, - ChangeType: common.BillTypeDiamond, - ChangeNum: num, - RemainNum: this.Diamond, - Add: add, - LogType: gainWay, - GameID: 0, - GameFreeID: 0, - BaseCoin: 0, - Operator: oper, - Remark: remark, + switch gainWay { + case common.GainWay_MatchSignup: // 排除的 + default: + TaskSubjectSingleton.Touch(common.TaskTypeCostDiamond, &TaskData{ + SnId: this.SnId, + Num: -num, }) - if log != nil { - LogChannelSingleton.WriteLog(log) - } + } + } + + this.SendDiffData() + if !this.IsRob { + log := model.NewCoinLogEx(&model.CoinLogParam{ + Platform: this.Platform, + SnID: this.SnId, + Channel: this.Channel, + ChangeType: common.BillTypeDiamond, + ChangeNum: num, + RemainNum: this.Diamond, + Add: add, + LogType: gainWay, + GameID: 0, + GameFreeID: 0, + BaseCoin: 0, + Operator: oper, + Remark: remark, + }) + if log != nil { + LogChannelSingleton.WriteLog(log) } } } @@ -2265,23 +2250,14 @@ func (this *Player) BackDiffData() { this.diffData.SafeBoxCoin = this.SafeBoxCoin } -func (this *Player) UpdateVip() { - if this.IsRob { - return - } - this.VIP = this.GetVIPLevel() - //clubManager.UpdateVip(this) -} - func (this *Player) AddMoneyPayTotal(amount int64) { if amount > 0 { this.MoneyPayTotal += amount - this.SendDiffData() //更新vip + this.GetVIPLevel() } } func (this *Player) SendDiffData() { - this.UpdateVip() var dirty bool pack := &playerproto.SCPlayerDataUpdate{} pack.UpdateField = 0 @@ -2767,7 +2743,6 @@ func (this *Player) GetPromoterKey() (string, error) { //} func (this *Player) SendPlayerInfo() { - this.UpdateVip() scPlayerData := &playerproto.SCPlayerData{ OpRetCode: playerproto.OpResultCode_OPRC_Sucess, Data: &playerproto.PlayerData{ @@ -2878,6 +2853,8 @@ func (this *Player) SendPlayerInfo() { this.SendGameConfig(int32(this.scene.gameId), this.Platform, this.Channel) } //this.SendJackpotInfo() + // 更新vip + this.GetVIPLevel() // 后台道具配置 this.SCItems() // 引导配置 @@ -3606,8 +3583,6 @@ func (this *Player) SCVIPInfo() { pack.TolVipExp, pack.Money = this.GetCurrentVIPExp(vips) pack.Vip = this.VIP pack.OpRetCode = playerproto.OpResultCode_OPRC_Sucess - //WelfareMgrSington.MonitorWelfData(this) - //pack.VipId = append(pack.VipId, this.WelfData.VIPGift...) } this.SendToClient(int(playerproto.PlayerPacketID_PACKET_SC_VIPINFO), pack) logger.Logger.Tracef("send vipinfo to client:%v", pack) @@ -3732,6 +3707,8 @@ func (this *Player) VIPDraw(id, vip int32) { send() } +// GetCurrentVIPExp 更新vip等级 +// 返回当前经验和升级需要经验 func (this *Player) GetCurrentVIPExp(vipcfg ...*webapiproto.VIPcfgDataList) (exp int64, money int64) { var vips *webapiproto.VIPcfgDataList if len(vipcfg) == 0 { @@ -3767,6 +3744,7 @@ func (this *Player) GetCurrentVIPExp(vipcfg ...*webapiproto.VIPcfgDataList) (exp return // 默认 } +// GetVIPLevel 更新vip等级,返回vip等级 func (this *Player) GetVIPLevel() int32 { if this.IsRob { return 0 @@ -3786,6 +3764,7 @@ func (this *Player) GetVIPLevel() int32 { } var b bool if vip != this.VIP { + this.dirty = true b = true //玩家VIP升级 this.SCVIPInfo() @@ -4344,7 +4323,7 @@ func (this *Player) addLotteryCount(count int32) { } -// 增加手机积分 +// AddPhoneScore 增加手机积分 func (this *Player) AddPhoneScore(num, add int64, gainWay int32, oper, remark string) { if num == 0 { return @@ -4353,22 +4332,20 @@ func (this *Player) AddPhoneScore(num, add int64, gainWay int32, oper, remark st return } logger.Logger.Tracef("snid(%v) AddPhoneScore(%v)", this.SnId, num) - if num != 0 /*&& !async*/ { - this.dirty = true - if num > 0 { - this.PhoneScore += num - } else { - if -num > this.PhoneScore { - logger.Logger.Errorf("Player.AddPhoneScore exception!!! num(%v) oper(%v)", num, oper) - num = -this.PhoneScore - this.PhoneScore = 0 - } else { - this.PhoneScore += num - } - } - this.SendDiffData() + this.dirty = true + if num > 0 { + this.PhoneScore += num + } else { + if -num > this.PhoneScore { + logger.Logger.Errorf("Player.AddPhoneScore exception!!! num(%v) oper(%v)", num, oper) + num = -this.PhoneScore + this.PhoneScore = 0 + } else { + this.PhoneScore += num + } } + this.SendDiffData() } // 抽奖任务 @@ -4644,43 +4621,34 @@ func (this *Player) GetWeekCardPrivilege(typeId int32) bool { // 增加记牌器道具时限 func (this *Player) AddItemRecExpireTime(itemId int32, num, add int64, gainWay int32, oper, remark string) { - if num == 0 { + if num <= 0 { + return + } + logger.Logger.Tracef("snid(%v) AddItemRecExpireTime, itemId:(%v), num:(%v)", this.SnId, itemId, num) + + this.dirty = true + itemData := srvdata.GameItemMgr.Get(this.Platform, itemId) + if itemData == nil { return } - logger.Logger.Tracef("snid(%v) AddItemRecExpireTime, itemId:(%v), num:(%v)", this.SnId, itemId, num) - - if num != 0 /*&& !async*/ { - this.dirty = true - if num > 0 { - itemData := srvdata.GameItemMgr.Get(this.Platform, itemId) - if itemData == nil { - return - } - - if this.ItemRecExpireTime == 0 { - this.ItemRecExpireTime = time.Now().Unix() + int64(itemData.Time)*3600*num - } else { - if this.ItemRecExpireTime >= time.Now().Unix() { - this.ItemRecExpireTime += int64(itemData.Time) * 3600 * num - } else { - this.ItemRecExpireTime = time.Now().Unix() + int64(itemData.Time)*3600*num - } - } - - if this.scene != nil && this.scene.gameSess != nil { - msg := &serverproto.WGBuyRecTimeItem{ - SnId: this.SnId, - ExpireTime: this.ItemRecExpireTime, - Diamond: this.Diamond, - } - - proto.SetDefaults(msg) - this.SendToGame(int(serverproto.SSPacketID_PACKET_WG_BUYRECTIMEITEM), msg) - } + if this.ItemRecExpireTime == 0 { + this.ItemRecExpireTime = time.Now().Unix() + int64(itemData.Time)*3600*num + } else { + if this.ItemRecExpireTime >= time.Now().Unix() { + this.ItemRecExpireTime += int64(itemData.Time) * 3600 * num + } else { + this.ItemRecExpireTime = time.Now().Unix() + int64(itemData.Time)*3600*num } + } - this.SendDiffData() + if this.scene != nil && this.scene.gameSess != nil { + msg := &serverproto.WGBuyRecTimeItem{ + SnId: this.SnId, + ExpireTime: this.ItemRecExpireTime, + Diamond: this.Diamond, + } + this.SendToGame(int(serverproto.SSPacketID_PACKET_WG_BUYRECTIMEITEM), msg) } } diff --git a/worldsrv/shopmgr.go b/worldsrv/shopmgr.go index e645d0d..594f085 100644 --- a/worldsrv/shopmgr.go +++ b/worldsrv/shopmgr.go @@ -921,18 +921,30 @@ func (this *ShopMgr) Exchange(p *Player, goodsId int32, username, mobile, commen }) } if info.DPrice > 0 { - item := model.ItemInfo{ - ItemId: common.ItemDollCard, - ItemNum: int64(info.JPrice * num), - } - _, _, isF := BagMgrSingleton.AddItem(p, int64(item.ItemId), -item.ItemNum, 0, common.GainWayItemChangeDoll, - "sys", fmt.Sprintf("兑换娃娃扣除%v", item.ItemId), 0, 0, false) - if !isF { // 扣掉金券 + n := int64(info.DPrice * num) + item := BagMgrSingleton.GetItem(p.SnId, common.ItemIDJCard) + if item != nil && item.ItemNum >= n { + BagMgrSingleton.AddItems(&model.AddItemParam{ + P: p.PlayerData, + Change: []*model.Item{ + { + ItemId: item.ItemId, + ItemNum: -n, + }, + }, + GainWay: common.GainWayItemChangeDoll, + Operator: "system", + Remark: fmt.Sprintf("兑换娃娃扣除%v", item.ItemId), + }) + } else { pack.RetCode = shop.OpResultCode_OPRC_DCoinNotEnough p.SendToClient(int(shop.SPacketID_PACKET_SC_SHOP_EXCHANGE), pack) return false } - itemInfo = append(itemInfo, item) + itemInfo = append(itemInfo, &model.Item{ + ItemId: common.ItemDollCard, + ItemNum: n, + }) } task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { pack := &webapi_proto.ASCreateExchangeOrder{ From ecb9c17920e541fe67d3feb846173775a332b855 Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Thu, 19 Sep 2024 14:13:22 +0800 Subject: [PATCH 3/3] no message --- common/transtype.go | 1 + worldsrv/action_player.go | 19 +- worldsrv/player.go | 97 +-- worldsrv/trascate_webapi.go | 1173 +++++++++++++++++------------------ 4 files changed, 617 insertions(+), 673 deletions(-) diff --git a/common/transtype.go b/common/transtype.go index a9f849c..8746e88 100644 --- a/common/transtype.go +++ b/common/transtype.go @@ -22,6 +22,7 @@ const ( TransType_MatchSceneChange = 1013 TransType_MiniGameAddCoin = 1014 TransType_ServerCtrl = 1015 + TranType_AddItem = 1016 // 道具修改 ) type M2GWebTrascate struct { diff --git a/worldsrv/action_player.go b/worldsrv/action_player.go index 6d45f9a..dfa25ad 100644 --- a/worldsrv/action_player.go +++ b/worldsrv/action_player.go @@ -1691,15 +1691,15 @@ func (this *CSPlayerVIPBuyPacketFactory) CreatePacket() interface{} { func (this *CSPlayerVIPBuyHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error { logger.Logger.Trace("CSVIPBuy Process recv ", data) - if msg, ok := data.(*player_proto.CSVIPBuy); ok { - p := PlayerMgrSington.GetPlayer(sid) - if p == nil { - logger.Logger.Warn("CSPlayerVIPBuyHandler p == nil") - return nil - } - - p.SCVIPBuy(int64(msg.GetMoney())) - } + //if msg, ok := data.(*player_proto.CSVIPBuy); ok { + // p := PlayerMgrSington.GetPlayer(sid) + // if p == nil { + // logger.Logger.Warn("CSPlayerVIPBuyHandler p == nil") + // return nil + // } + // + // p.SCVIPBuy(int64(msg.GetMoney())) + //} return nil } @@ -1723,7 +1723,6 @@ func (this *CSPlayerVIPInfoHandler) Process(s *netlib.Session, packetid int, dat return nil } p.GetVIPLevel() - p.SCVIPInfo() } return nil } diff --git a/worldsrv/player.go b/worldsrv/player.go index 3b612ee..4363cad 100644 --- a/worldsrv/player.go +++ b/worldsrv/player.go @@ -34,7 +34,6 @@ import ( "mongo.games.com/game/protocol/rankmatch" serverproto "mongo.games.com/game/protocol/server" shopproto "mongo.games.com/game/protocol/shop" - webapiproto "mongo.games.com/game/protocol/webapi" "mongo.games.com/game/srvdata" "mongo.games.com/game/worldsrv/internal" ) @@ -1110,9 +1109,8 @@ func (this *Player) GetMessageAttach(id string) { } return gift }), task.CompleteNotifyWrapper(func(data interface{}, tt task.Task) { - attach_msg, ok := data.(*model.Message) - dirtyCoin := int64(0) - if ok && attach_msg != nil { + attachMsg, ok := data.(*model.Message) + if ok && attachMsg != nil { msg.AttachState = model.MSGATTACHSTATE_GOT notifyClient := true var remark string @@ -1157,29 +1155,24 @@ func (this *Player) GetMessageAttach(id string) { case model.MSGTYPE_ITEM: remark = "领取道具" gainWay = common.GainWay_MAIL_MTEM - dirtyCoin = msg.Coin addItem() case model.MSGTYPE_IOSINSTALLSTABLE: remark = "IOS下载稳定版本" gainWay = common.GainWay_IOSINSTALLSTABLE - dirtyCoin = msg.Coin case model.MSGTYPE_GIFT: remark = "礼物" case model.MSGTYPE_GOLDCOMERANK: remark = "财神降临奖励" gainWay = common.GainWay_GoldCome notifyClient = false - dirtyCoin = msg.Coin case model.MSGTYPE_RANDCOIN: remark = "红包雨" gainWay = common.GainWay_OnlineRandCoin notifyClient = false - dirtyCoin = msg.Coin case model.MSGTYPE_REBATE: remark = "流水返利" gainWay = common.GainWay_RebateTask notifyClient = false - dirtyCoin = msg.Coin //邮件领取 添加日志 task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { return model.InsertRebateLog(this.Platform, &model.Rebate{ @@ -1227,8 +1220,6 @@ func (this *Player) GetMessageAttach(id string) { } if msg.Coin > 0 { this.AddCoin(msg.Coin, 0, gainWay, msg.Id.Hex(), remark) - //增加泥码 - this.AddDirtyCoin(0, dirtyCoin) //俱乐部获取不算系统赠送 if msg.MType != model.MSGTYPE_ClubGet { this.ReportSystemGiveEvent(int32(msg.Coin), gainWay, notifyClient) //邮件附件算是系统赠送 @@ -1891,45 +1882,6 @@ func (this *Player) AddCoinAsync(num, add int64, gainWay int32, oper, remark str // } //} -// 增加泥码 -func (this *Player) AddDirtyCoin(paycoin, givecoin int64) { - if this.IsRob { - return - } - - //if cfg, ok := ProfitControlMgrSington.GetCfg(this.Platform); ok && cfg != nil && paycoin >= 0 { - // //洗码折算率=(玩家剩余泥码*洗码折算率+期望营收)/(充值额+赠送额+泥码余额) - // this.RecalcuWashingCoinConvRate(cfg.Rate, paycoin, givecoin) - //} - // - //this.DirtyCoin += paycoin + givecoin - //if this.DirtyCoin < 0 { - // this.DirtyCoin = 0 - //} - this.dirty = true -} - -// 洗码 -func (this *Player) WashingCoin(coin int64) int64 { - if this.IsRob { - return 0 - } - if coin <= 0 { - return 0 - } - - //if this.DirtyCoin > coin { - // this.DirtyCoin -= coin - // this.dirty = true - // return coin - //} - // - ////剩余多少泥码,清洗多少 - //coin = this.DirtyCoin - //this.DirtyCoin = 0 - return coin -} - func (this *Player) AddTicket(num int64, gainWay int32, oper, remark string) { if num == 0 { return @@ -3497,17 +3449,17 @@ func (this *Player) SendShowRed(showType hallproto.ShowRedCode, showChild, isSho this.SendToClient(int(hallproto.HallPacketID_PACKET_SC_SHOWRED), pack) } -func (this *Player) SCVIPBuy(buy int64) { - //buy *= 10000 - //this.AddMoneyPayTotal(buy) - //this.GetVIPLevel(0) // 更新下vip等级 - pack := &playerproto.SCVIPBuy{ - OpRetCode: playerproto.OpResultCode_OPRC_Sucess, - } - pack.TolVipExp, pack.Money = this.GetCurrentVIPExp() // 获取经验会更新vip等级 - pack.Vip = this.VIP - this.SendToClient(int(playerproto.PlayerPacketID_PACKET_SC_VIPBUY), pack) -} +//func (this *Player) SCVIPBuy(buy int64) { +// //buy *= 10000 +// //this.AddMoneyPayTotal(buy) +// //this.GetVIPLevel(0) // 更新下vip等级 +// pack := &playerproto.SCVIPBuy{ +// OpRetCode: playerproto.OpResultCode_OPRC_Sucess, +// } +// pack.TolVipExp, pack.Money = this.GetCurrentVIPExp() // 获取经验会更新vip等级 +// pack.Vip = this.VIP +// this.SendToClient(int(playerproto.PlayerPacketID_PACKET_SC_VIPBUY), pack) +//} func (this *Player) SCVIPInfo() { if this.IsRob { @@ -3581,7 +3533,7 @@ func (this *Player) SCVIPInfo() { pack.List = append(pack.List, data) } - pack.TolVipExp, pack.Money = this.GetCurrentVIPExp(vips) + pack.TolVipExp, pack.Money = this.GetCurrentVIPExp() pack.Vip = this.VIP pack.OpRetCode = playerproto.OpResultCode_OPRC_Sucess } @@ -3710,17 +3662,12 @@ func (this *Player) VIPDraw(id, vip int32) { // GetCurrentVIPExp 更新vip等级 // 返回当前经验和升级需要经验 -func (this *Player) GetCurrentVIPExp(vipcfg ...*webapiproto.VIPcfgDataList) (exp int64, money int64) { - var vips *webapiproto.VIPcfgDataList - if len(vipcfg) == 0 { - vips = VipMgrSington.GetVIPcfg(this.Platform) - } else { - vips = vipcfg[0] - } +func (this *Player) GetCurrentVIPExp() (exp int64, money int64) { + vips := VipMgrSington.GetVIPcfg(this.Platform) exp = int64(float64(this.MoneyPayTotal) * vips.MoneyRatio) tolexp := int32(0) oldVipLevel := this.VIP - if vips != nil && this.MoneyPayTotal != 0 { + if this.MoneyPayTotal != 0 { allExp := int64(float64(this.MoneyPayTotal) * vips.MoneyRatio) for _, v := range vips.List { tolexp = v.VipEx @@ -3737,10 +3684,7 @@ func (this *Player) GetCurrentVIPExp(vipcfg ...*webapiproto.VIPcfgDataList) (exp money = 0 } if oldVipLevel != this.VIP { - //玩家VIP升级 - this.SCVIPInfo() - PetMgrSington.CheckSkinRed(this) - logger.Logger.Trace("VIP升级!") + this.GetVIPLevel() } return // 默认 } @@ -3763,15 +3707,16 @@ func (this *Player) GetVIPLevel() int32 { } } } + var b bool if vip != this.VIP { this.dirty = true b = true - //玩家VIP升级 - this.SCVIPInfo() logger.Logger.Trace("VIP升级!") } this.VIP = vip + //玩家VIP升级 + this.SCVIPInfo() if b { PetMgrSington.CheckSkinRed(this) } diff --git a/worldsrv/trascate_webapi.go b/worldsrv/trascate_webapi.go index 2cf5e48..73a2dc5 100644 --- a/worldsrv/trascate_webapi.go +++ b/worldsrv/trascate_webapi.go @@ -175,322 +175,322 @@ func (this *WebAPIHandlerMgr) GetWebAPIHandler(name string) WebAPIHandler { func init() { //API用户加减币 - WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Game/QPAPIAddSubCoinById", WebAPIHandlerWrapper( - func(tNode *transact.TransNode, params []byte) (int, proto.Message) { - pack := &qpapi.SAAddCoinById{} - msg := &qpapi.ASAddCoinById{} - err1 := proto.Unmarshal(params, msg) - if err1 != nil { - pack.Tag = qpapi.TagCode_FAILED - pack.Msg = "数据序列化失败" + err1.Error() - return common.ResponseTag_ParamError, pack - } - - username := msg.GetUsername() - coin := msg.GetGold() - billNo := int(msg.GetBillNo()) - platform := msg.GetMerchantTag() - curplatform := PlatformMgrSingleton.GetPlatform(platform) - - if curplatform == nil { - pack.Tag = qpapi.TagCode_FAILED - pack.Msg = "没有对应的平台" - return common.ResponseTag_ParamError, pack - } - merchantkey := curplatform.MerchantKey - - sign := msg.GetSign() - - raw := fmt.Sprintf("%v%v%v%v%v%v", username, coin, billNo, platform, merchantkey, msg.GetTs()) - h := md5.New() - io.WriteString(h, raw) - newsign := hex.EncodeToString(h.Sum(nil)) - - if newsign != sign { - pack.Tag = qpapi.TagCode_FAILED - pack.Msg = "商户验签失败" - return common.ResponseTag_ParamError, pack - } - - if CacheDataMgr.CacheBillCheck(billNo, platform) { - pack.Tag = qpapi.TagCode_FAILED - pack.Msg = "Bill number repeated!" - return common.ResponseTag_ParamError, pack - } - CacheDataMgr.CacheBillNumber(billNo, platform) //防止手抖点两下 - - var err error - var pd *model.PlayerData - oldGold := int64(0) - var timeStamp = time.Now().UnixNano() - acc, accerr := model.GetAccountByName(platform, username) - if accerr != nil { - CacheDataMgr.ClearCacheBill(billNo, platform) - pack.Tag = qpapi.TagCode_FAILED - pack.Msg = accerr.Error() - return common.ResponseTag_ParamError, pack - } - member_snid := acc.SnId - player := PlayerMgrSington.GetPlayerBySnId(int32(member_snid)) - if player != nil { //在线玩家处理 - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - if player.scene != nil && coin < 0 { - //player.Kickout(common.KickReason_CheckCodeErr) - - leavemsg := &server.WGPlayerLeave{ - SnId: proto.Int32(player.SnId), - } - proto.SetDefaults(leavemsg) - player.SendToGame(int(server.SSPacketID_PACKET_WG_PlayerLEAVE), leavemsg) - - select { - case <-player.leavechan: - case <-time.After(time.Second * 1): - } - - } - //player = PlayerMgrSington.GetPlayerBySnId(int32(member_snid)) - if player.scene != nil { - CacheDataMgr.ClearCacheBill(billNo, platform) - //pack.Tag = qpapi.TagCode_FAILED - //pack.Msg = "Unsupported!!! because player in scene!" - //return common.ResponseTag_ParamError, pack - return errors.New("Unsupported!!! because player in scene!") - } - pd = player.PlayerData - if len(platform) > 0 && player.Platform != platform { - CacheDataMgr.ClearCacheBill(billNo, platform) - //pack.Tag = qpapi.TagCode_FAILED - //pack.Msg = "player platform forbit!" - //return common.ResponseTag_ParamError, pack - return errors.New("player platform forbit!") - } - - opcode := int32(common.GainWay_Api_In) - - if coin < 0 { - opcode = int32(common.GainWay_Api_Out) - if player.Coin+coin < 0 { - CacheDataMgr.ClearCacheBill(billNo, platform) - //pack.Tag = qpapi.TagCode_FAILED - //pack.Msg = "coin not enough!" - //return common.ResponseTag_ParamError, pack - return errors.New("coin not enough!") - } - } - - //if logType != 0 { - // opcode = logType - //} - - oldGold = player.Coin - coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode, - "qpsystem", model.PayCoinLogType_Coin, 0) - timeStamp = coinLog.TimeStamp - //增加帐变记录 - coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ - Platform: pd.Platform, - SnID: member_snid, - Channel: pd.Channel, - ChangeType: common.BillTypeCoin, - ChangeNum: coin, - RemainNum: oldGold + coin, - Add: 0, - LogType: opcode, - GameID: 0, - GameFreeID: 0, - BaseCoin: 0, - Operator: "oper", - Remark: "online", - }) - - err = model.InsertPayCoinLogs(platform, coinLog) - if err != nil { - logger.Logger.Errorf("model.InsertPayCoinLogs err:%v log:%v", err, coinLog) - return err - } - err = model.InsertCoinLog(coinlogex) - if err != nil { - //回滚到对账日志 - model.RemovePayCoinLog(platform, coinLog.LogId) - logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) - return err - } - return err - }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { - CacheDataMgr.ClearCacheBill(billNo, platform) - if data != nil { - pack.Tag = qpapi.TagCode_FAILED - pack.Msg = data.(error).Error() - } else { - //player.Coin += coin + coinEx - player.AddCoinAsync(coin, 0, common.GainWay_Api_In, "oper", "Async", true, 0, false) - //增加相应的泥码量 - player.AddDirtyCoin(coin, 0) - player.SetPayTs(timeStamp) - - if player.TodayGameData == nil { - player.TodayGameData = model.NewPlayerGameCtrlData() - } - //actRandCoinMgr.OnPlayerRecharge(player, coin) - /* - if isAccTodayRecharge { - - player.AddCoinPayTotal(coin) - player.TodayGameData.RechargeCoin += coin //累加当天充值金额 - if coin >= 0 { - plt := PlatformMgrSingleton.GetPlatform(pd.Platform) - curVer := int32(0) - if plt != nil { - curVer = plt.ExchangeVer - } - log := model.NewCoinGiveLogEx(pd.SnId, pd.Name, coin, 0, 0, opcode, pd.PromoterTree, - model.COINGIVETYPE_PAY, curVer, pd.Platform, pd.Channel, pd.BeUnderAgentCode, - "", "system", pd.PackageID, int32(needFlowRate), int32(needGiveFlowRate)) - if log != nil { - err := model.InsertGiveCoinLog(log) - if err == nil { - if pd.LastExchangeOrder != "" && pd.TotalConvertibleFlow > 0 { - err = model.UpdateGiveCoinLastFlow(platform, pd.LastExchangeOrder, pd.TotalConvertibleFlow) - } - } - //清空流水,更新id - pd.TotalConvertibleFlow = 0 - pd.LastExchangeOrder = log.LogId.Hex() - if player == nil { - //需要回写数据库 - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - model.UpdatePlayerExchageFlowAndOrder(platform, member_snid, 0, pd.LastExchangeOrder) - return nil - }), nil, "UpdateGiveCoinLogs").StartByExecutor(pd.AccountId) - } - } - } - } - */ - player.dirty = true - player.Time2Save() - if player.scene == nil { //如果在大厅,那么同步下金币 - player.SendDiffData() - } - player.SendPlayerRechargeAnswer(coin) - pack.Tag = qpapi.TagCode_SUCCESS - pack.Msg = "" - } - tNode.TransRep.RetFiels = pack - tNode.Resume() - if err != nil { - logger.Logger.Error("AddSubCoinById task marshal data error:", err) - } - }), "APIAddSubCoinById").Start() - return common.ResponseTag_TransactYield, pack - } else { - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - pd, _ = model.GetPlayerDataBySnId(platform, int32(member_snid), false, true) - if pd == nil { - return errors.New("Player not find.") - } - if len(platform) > 0 && pd.Platform != platform { - return errors.New("player platform forbit.") - } - oldGold = pd.Coin - opcode := int32(common.GainWay_Api_In) - if coin < 0 { - opcode = int32(common.GainWay_Api_Out) - if pd.Coin+coin < 0 { - return errors.New("coin not enough!") - } - } - - //if logType != 0 { - // opcode = logType - //} - coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode, - "not online", model.PayCoinLogType_Coin, 0) - timeStamp = coinLog.TimeStamp - err = model.InsertPayCoinLogs(platform, coinLog) - if err != nil { - logger.Logger.Errorf("model.InsertPayCoinLogs err:%v log:%v", err, coinLog) - return err - } - //增加帐变记录 - coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ - Platform: pd.Platform, - SnID: member_snid, - Channel: pd.Channel, - ChangeType: common.BillTypeCoin, - ChangeNum: coin, - RemainNum: oldGold + coin, - Add: 0, - LogType: opcode, - GameID: 0, - GameFreeID: 0, - BaseCoin: 0, - Operator: "oper", - Remark: "not online", - }) - err = model.InsertCoinLog(coinlogex) - if err != nil { - //回滚到对账日志 - model.RemovePayCoinLog(platform, coinLog.LogId) - logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) - return err - } - return err - }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { - CacheDataMgr.ClearCacheBill(billNo, platform) - if data != nil { - pack.Tag = qpapi.TagCode_FAILED - pack.Msg = data.(error).Error() - } else { - pack.Tag = qpapi.TagCode_SUCCESS - pack.Msg = "" - /* - if isAccTodayRecharge && coin >= 0 { - OnPlayerPay(pd, coin) - } - if isAccTodayRecharge && coin >= 0 && coinEx >= 0 { - - plt := PlatformMgrSingleton.GetPlatform(pd.Platform) - curVer := int32(0) - if plt != nil { - curVer = plt.ExchangeVer - } - log := model.NewCoinGiveLogEx(pd.SnId, pd.Name, coin, coinEx, 0, common.GainWay_Api_In, pd.PromoterTree, - model.COINGIVETYPE_PAY, curVer, pd.Platform, pd.Channel, pd.BeUnderAgentCode, - "", "system", pd.PackageID, int32(needFlowRate), int32(needGiveFlowRate)) - if log != nil { - err := model.InsertGiveCoinLog(log) - if err == nil { - if pd.LastExchangeOrder != "" && pd.TotalConvertibleFlow > 0 { - err = model.UpdateGiveCoinLastFlow(platform, pd.LastExchangeOrder, pd.TotalConvertibleFlow) - } - } - //清空流水,更新id - pd.TotalConvertibleFlow = 0 - pd.LastExchangeOrder = log.LogId.Hex() - if player == nil { - //需要回写数据库 - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - model.UpdatePlayerExchageFlowAndOrder(platform, int32(member_snid), 0, pd.LastExchangeOrder) - return nil - }), nil, "UpdateGiveCoinLogs").StartByExecutor(pd.AccountId) - } - } - - } - */ - } - - tNode.TransRep.RetFiels = pack - tNode.Resume() - if err != nil { - logger.Logger.Error("AddSubCoinById task marshal data error:", err) - } - }), "APIAddSubCoinById").Start() - return common.ResponseTag_TransactYield, pack - } - })) + //WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Game/QPAPIAddSubCoinById", WebAPIHandlerWrapper( + // func(tNode *transact.TransNode, params []byte) (int, proto.Message) { + // pack := &qpapi.SAAddCoinById{} + // msg := &qpapi.ASAddCoinById{} + // err1 := proto.Unmarshal(params, msg) + // if err1 != nil { + // pack.Tag = qpapi.TagCode_FAILED + // pack.Msg = "数据序列化失败" + err1.Error() + // return common.ResponseTag_ParamError, pack + // } + // + // username := msg.GetUsername() + // coin := msg.GetGold() + // billNo := int(msg.GetBillNo()) + // platform := msg.GetMerchantTag() + // curplatform := PlatformMgrSingleton.GetPlatform(platform) + // + // if curplatform == nil { + // pack.Tag = qpapi.TagCode_FAILED + // pack.Msg = "没有对应的平台" + // return common.ResponseTag_ParamError, pack + // } + // merchantkey := curplatform.MerchantKey + // + // sign := msg.GetSign() + // + // raw := fmt.Sprintf("%v%v%v%v%v%v", username, coin, billNo, platform, merchantkey, msg.GetTs()) + // h := md5.New() + // io.WriteString(h, raw) + // newsign := hex.EncodeToString(h.Sum(nil)) + // + // if newsign != sign { + // pack.Tag = qpapi.TagCode_FAILED + // pack.Msg = "商户验签失败" + // return common.ResponseTag_ParamError, pack + // } + // + // if CacheDataMgr.CacheBillCheck(billNo, platform) { + // pack.Tag = qpapi.TagCode_FAILED + // pack.Msg = "Bill number repeated!" + // return common.ResponseTag_ParamError, pack + // } + // CacheDataMgr.CacheBillNumber(billNo, platform) //防止手抖点两下 + // + // var err error + // var pd *model.PlayerData + // oldGold := int64(0) + // var timeStamp = time.Now().UnixNano() + // acc, accerr := model.GetAccountByName(platform, username) + // if accerr != nil { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // pack.Tag = qpapi.TagCode_FAILED + // pack.Msg = accerr.Error() + // return common.ResponseTag_ParamError, pack + // } + // member_snid := acc.SnId + // player := PlayerMgrSington.GetPlayerBySnId(int32(member_snid)) + // if player != nil { //在线玩家处理 + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // if player.scene != nil && coin < 0 { + // //player.Kickout(common.KickReason_CheckCodeErr) + // + // leavemsg := &server.WGPlayerLeave{ + // SnId: proto.Int32(player.SnId), + // } + // proto.SetDefaults(leavemsg) + // player.SendToGame(int(server.SSPacketID_PACKET_WG_PlayerLEAVE), leavemsg) + // + // select { + // case <-player.leavechan: + // case <-time.After(time.Second * 1): + // } + // + // } + // //player = PlayerMgrSington.GetPlayerBySnId(int32(member_snid)) + // if player.scene != nil { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // //pack.Tag = qpapi.TagCode_FAILED + // //pack.Msg = "Unsupported!!! because player in scene!" + // //return common.ResponseTag_ParamError, pack + // return errors.New("Unsupported!!! because player in scene!") + // } + // pd = player.PlayerData + // if len(platform) > 0 && player.Platform != platform { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // //pack.Tag = qpapi.TagCode_FAILED + // //pack.Msg = "player platform forbit!" + // //return common.ResponseTag_ParamError, pack + // return errors.New("player platform forbit!") + // } + // + // opcode := int32(common.GainWay_Api_In) + // + // if coin < 0 { + // opcode = int32(common.GainWay_Api_Out) + // if player.Coin+coin < 0 { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // //pack.Tag = qpapi.TagCode_FAILED + // //pack.Msg = "coin not enough!" + // //return common.ResponseTag_ParamError, pack + // return errors.New("coin not enough!") + // } + // } + // + // //if logType != 0 { + // // opcode = logType + // //} + // + // oldGold = player.Coin + // coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode, + // "qpsystem", model.PayCoinLogType_Coin, 0) + // timeStamp = coinLog.TimeStamp + // //增加帐变记录 + // coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ + // Platform: pd.Platform, + // SnID: member_snid, + // Channel: pd.Channel, + // ChangeType: common.BillTypeCoin, + // ChangeNum: coin, + // RemainNum: oldGold + coin, + // Add: 0, + // LogType: opcode, + // GameID: 0, + // GameFreeID: 0, + // BaseCoin: 0, + // Operator: "oper", + // Remark: "online", + // }) + // + // err = model.InsertPayCoinLogs(platform, coinLog) + // if err != nil { + // logger.Logger.Errorf("model.InsertPayCoinLogs err:%v log:%v", err, coinLog) + // return err + // } + // err = model.InsertCoinLog(coinlogex) + // if err != nil { + // //回滚到对账日志 + // model.RemovePayCoinLog(platform, coinLog.LogId) + // logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) + // return err + // } + // return err + // }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // if data != nil { + // pack.Tag = qpapi.TagCode_FAILED + // pack.Msg = data.(error).Error() + // } else { + // //player.Coin += coin + coinEx + // player.AddCoinAsync(coin, 0, common.GainWay_Api_In, "oper", "Async", true, 0, false) + // //增加相应的泥码量 + // player.AddDirtyCoin(coin, 0) + // player.SetPayTs(timeStamp) + // + // if player.TodayGameData == nil { + // player.TodayGameData = model.NewPlayerGameCtrlData() + // } + // //actRandCoinMgr.OnPlayerRecharge(player, coin) + // /* + // if isAccTodayRecharge { + // + // player.AddCoinPayTotal(coin) + // player.TodayGameData.RechargeCoin += coin //累加当天充值金额 + // if coin >= 0 { + // plt := PlatformMgrSingleton.GetPlatform(pd.Platform) + // curVer := int32(0) + // if plt != nil { + // curVer = plt.ExchangeVer + // } + // log := model.NewCoinGiveLogEx(pd.SnId, pd.Name, coin, 0, 0, opcode, pd.PromoterTree, + // model.COINGIVETYPE_PAY, curVer, pd.Platform, pd.Channel, pd.BeUnderAgentCode, + // "", "system", pd.PackageID, int32(needFlowRate), int32(needGiveFlowRate)) + // if log != nil { + // err := model.InsertGiveCoinLog(log) + // if err == nil { + // if pd.LastExchangeOrder != "" && pd.TotalConvertibleFlow > 0 { + // err = model.UpdateGiveCoinLastFlow(platform, pd.LastExchangeOrder, pd.TotalConvertibleFlow) + // } + // } + // //清空流水,更新id + // pd.TotalConvertibleFlow = 0 + // pd.LastExchangeOrder = log.LogId.Hex() + // if player == nil { + // //需要回写数据库 + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // model.UpdatePlayerExchageFlowAndOrder(platform, member_snid, 0, pd.LastExchangeOrder) + // return nil + // }), nil, "UpdateGiveCoinLogs").StartByExecutor(pd.AccountId) + // } + // } + // } + // } + // */ + // player.dirty = true + // player.Time2Save() + // if player.scene == nil { //如果在大厅,那么同步下金币 + // player.SendDiffData() + // } + // player.SendPlayerRechargeAnswer(coin) + // pack.Tag = qpapi.TagCode_SUCCESS + // pack.Msg = "" + // } + // tNode.TransRep.RetFiels = pack + // tNode.Resume() + // if err != nil { + // logger.Logger.Error("AddSubCoinById task marshal data error:", err) + // } + // }), "APIAddSubCoinById").Start() + // return common.ResponseTag_TransactYield, pack + // } else { + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // pd, _ = model.GetPlayerDataBySnId(platform, int32(member_snid), false, true) + // if pd == nil { + // return errors.New("Player not find.") + // } + // if len(platform) > 0 && pd.Platform != platform { + // return errors.New("player platform forbit.") + // } + // oldGold = pd.Coin + // opcode := int32(common.GainWay_Api_In) + // if coin < 0 { + // opcode = int32(common.GainWay_Api_Out) + // if pd.Coin+coin < 0 { + // return errors.New("coin not enough!") + // } + // } + // + // //if logType != 0 { + // // opcode = logType + // //} + // coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode, + // "not online", model.PayCoinLogType_Coin, 0) + // timeStamp = coinLog.TimeStamp + // err = model.InsertPayCoinLogs(platform, coinLog) + // if err != nil { + // logger.Logger.Errorf("model.InsertPayCoinLogs err:%v log:%v", err, coinLog) + // return err + // } + // //增加帐变记录 + // coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ + // Platform: pd.Platform, + // SnID: member_snid, + // Channel: pd.Channel, + // ChangeType: common.BillTypeCoin, + // ChangeNum: coin, + // RemainNum: oldGold + coin, + // Add: 0, + // LogType: opcode, + // GameID: 0, + // GameFreeID: 0, + // BaseCoin: 0, + // Operator: "oper", + // Remark: "not online", + // }) + // err = model.InsertCoinLog(coinlogex) + // if err != nil { + // //回滚到对账日志 + // model.RemovePayCoinLog(platform, coinLog.LogId) + // logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) + // return err + // } + // return err + // }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // if data != nil { + // pack.Tag = qpapi.TagCode_FAILED + // pack.Msg = data.(error).Error() + // } else { + // pack.Tag = qpapi.TagCode_SUCCESS + // pack.Msg = "" + // /* + // if isAccTodayRecharge && coin >= 0 { + // OnPlayerPay(pd, coin) + // } + // if isAccTodayRecharge && coin >= 0 && coinEx >= 0 { + // + // plt := PlatformMgrSingleton.GetPlatform(pd.Platform) + // curVer := int32(0) + // if plt != nil { + // curVer = plt.ExchangeVer + // } + // log := model.NewCoinGiveLogEx(pd.SnId, pd.Name, coin, coinEx, 0, common.GainWay_Api_In, pd.PromoterTree, + // model.COINGIVETYPE_PAY, curVer, pd.Platform, pd.Channel, pd.BeUnderAgentCode, + // "", "system", pd.PackageID, int32(needFlowRate), int32(needGiveFlowRate)) + // if log != nil { + // err := model.InsertGiveCoinLog(log) + // if err == nil { + // if pd.LastExchangeOrder != "" && pd.TotalConvertibleFlow > 0 { + // err = model.UpdateGiveCoinLastFlow(platform, pd.LastExchangeOrder, pd.TotalConvertibleFlow) + // } + // } + // //清空流水,更新id + // pd.TotalConvertibleFlow = 0 + // pd.LastExchangeOrder = log.LogId.Hex() + // if player == nil { + // //需要回写数据库 + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // model.UpdatePlayerExchageFlowAndOrder(platform, int32(member_snid), 0, pd.LastExchangeOrder) + // return nil + // }), nil, "UpdateGiveCoinLogs").StartByExecutor(pd.AccountId) + // } + // } + // + // } + // */ + // } + // + // tNode.TransRep.RetFiels = pack + // tNode.Resume() + // if err != nil { + // logger.Logger.Error("AddSubCoinById task marshal data error:", err) + // } + // }), "APIAddSubCoinById").Start() + // return common.ResponseTag_TransactYield, pack + // } + // })) //获取用户金币数量 WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Member/QPGetMemberGoldById", WebAPIHandlerWrapper( @@ -1095,8 +1095,7 @@ func init() { player.UpdateShopID(msg.GetShopId()) } if money > 0 { - player.MoneyPayTotal += money - player.SCVIPInfo() + player.AddMoneyPayTotal(money) TaskSubjectSingleton.Touch(common.TaskTypePay, &TaskData{ SnId: player.SnId, Num: money, @@ -1209,275 +1208,275 @@ func init() { // //------------------------------------------------------------------------------------------------------- // //钱包操作接口 - WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Game/AddCoinById", WebAPIHandlerWrapper( - func(tNode *transact.TransNode, params []byte) (int, proto.Message) { - pack := &webapiproto.SAAddCoinById{} - msg := &webapiproto.ASAddCoinById{} - err1 := proto.Unmarshal(params, msg) - if err1 != nil { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "数据序列化失败" + err1.Error() - return common.ResponseTag_ParamError, pack - } - - member_snid := msg.GetID() - coin := msg.GetGold() - coinEx := msg.GetGoldEx() - oper := msg.GetOper() - gold_desc := msg.GetDesc() - billNo := int(msg.GetBillNo()) - platform := msg.GetPlatform() - logType := msg.GetLogType() - isAccTodayRecharge := msg.GetIsAccTodayRecharge() - needFlowRate := msg.GetNeedFlowRate() - needGiveFlowRate := msg.GetNeedGiveFlowRate() - - if CacheDataMgr.CacheBillCheck(billNo, platform) { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "Bill number repeated!" - return common.ResponseTag_ParamError, pack - } - CacheDataMgr.CacheBillNumber(billNo, platform) //防止手抖点两下 - - var err error - var pd *model.PlayerData - oldGold := int64(0) - var timeStamp = time.Now().UnixNano() - player := PlayerMgrSington.GetPlayerBySnId(int32(member_snid)) - if player != nil { //在线玩家处理 - if player.scene != nil { - CacheDataMgr.ClearCacheBill(billNo, platform) - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "Unsupported!!! because player in scene!" - return common.ResponseTag_ParamError, pack - } - pd = player.PlayerData - if len(platform) > 0 && player.Platform != platform { - CacheDataMgr.ClearCacheBill(billNo, platform) - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "player platform forbit!" - return common.ResponseTag_ParamError, pack - } - - if coin < 0 { - if player.Coin+coin < 0 { - CacheDataMgr.ClearCacheBill(billNo, platform) - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "coin not enough!" - return common.ResponseTag_ParamError, pack - } - } - - opcode := int32(common.GainWay_API_AddCoin) - if logType != 0 { - opcode = logType - } - - oldGold = player.Coin - coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode, - gold_desc, model.PayCoinLogType_Coin, coinEx) - timeStamp = coinLog.TimeStamp - //增加帐变记录 - coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ - Platform: pd.Platform, - SnID: member_snid, - Channel: pd.Channel, - ChangeType: common.BillTypeCoin, - ChangeNum: coin + coinEx, - RemainNum: oldGold + coin + coinEx, - Add: 0, - LogType: opcode, - GameID: 0, - GameFreeID: 0, - BaseCoin: 0, - Operator: oper, - Remark: gold_desc, - }) - - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - err = model.InsertPayCoinLogs(platform, coinLog) - if err != nil { - logger.Logger.Errorf("model.InsertPayCoinLogs err:%v log:%v", err, coinLog) - return err - } - err = model.InsertCoinLog(coinlogex) - if err != nil { - //回滚到对账日志 - model.RemovePayCoinLog(platform, coinLog.LogId) - logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) - return err - } - return err - }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { - CacheDataMgr.ClearCacheBill(billNo, platform) - if data != nil { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = data.(error).Error() - } else { - //player.Coin += coin + coinEx - player.AddCoinAsync(coin+coinEx, 0, common.GainWay_API_AddCoin, oper, gold_desc, true, 0, false) - //增加相应的泥码量 - player.AddDirtyCoin(coin, coinEx) - player.SetPayTs(timeStamp) - - if player.TodayGameData == nil { - player.TodayGameData = model.NewPlayerGameCtrlData() - } - //actRandCoinMgr.OnPlayerRecharge(player, coin) - if isAccTodayRecharge { - - player.AddCoinPayTotal(coin) - player.TodayGameData.RechargeCoin += coin //累加当天充值金额 - if coin >= 0 && coinEx >= 0 { - plt := PlatformMgrSingleton.GetPlatform(pd.Platform) - curVer := int32(0) - if plt != nil { - curVer = plt.ExchangeVer - } - log := model.NewCoinGiveLogEx(pd.SnId, pd.Name, coin, coinEx, 0, opcode, pd.PromoterTree, - model.COINGIVETYPE_PAY, curVer, pd.Platform, pd.Channel, pd.BeUnderAgentCode, - "", "system", pd.PackageID, int32(needFlowRate), int32(needGiveFlowRate)) - if log != nil { - err := model.InsertGiveCoinLog(log) - if err == nil { - if pd.LastExchangeOrder != "" && pd.TotalConvertibleFlow > 0 { - err = model.UpdateGiveCoinLastFlow(platform, pd.LastExchangeOrder, pd.TotalConvertibleFlow) - } - } - //清空流水,更新id - pd.TotalConvertibleFlow = 0 - pd.LastExchangeOrder = log.LogId.Hex() - if player == nil { - //需要回写数据库 - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - model.UpdatePlayerExchageFlowAndOrder(platform, member_snid, 0, pd.LastExchangeOrder) - return nil - }), nil, "UpdateGiveCoinLogs").StartByExecutor(pd.AccountId) - } - } - } - } - - player.dirty = true - player.Time2Save() - if player.scene == nil { //如果在大厅,那么同步下金币 - player.SendDiffData() - } - player.SendPlayerRechargeAnswer(coin) - pack.Tag = webapiproto.TagCode_SUCCESS - pack.Msg = "" - } - tNode.TransRep.RetFiels = pack - tNode.Resume() - if err != nil { - logger.Logger.Error("AddCoinById task marshal data error:", err) - } - }), "AddCoinById").Start() - return common.ResponseTag_TransactYield, pack - } else { - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - pd, _ = model.GetPlayerDataBySnId(platform, int32(member_snid), false, true) - if pd == nil { - return errors.New("Player not find.") - } - if len(platform) > 0 && pd.Platform != platform { - return errors.New("player platform forbit.") - } - oldGold = pd.Coin - if coin < 0 { - if pd.Coin+coin < 0 { - return errors.New("coin not enough!") - } - } - - opcode := int32(common.GainWay_API_AddCoin) - if logType != 0 { - opcode = logType - } - coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode, - gold_desc, model.PayCoinLogType_Coin, coinEx) - timeStamp = coinLog.TimeStamp - err = model.InsertPayCoinLogs(platform, coinLog) - if err != nil { - logger.Logger.Errorf("model.InsertPayCoinLogs err:%v log:%v", err, coinLog) - return err - } - //增加帐变记录 - coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ - Platform: pd.Platform, - SnID: member_snid, - Channel: pd.Channel, - ChangeType: common.BillTypeCoin, - ChangeNum: coin + coinEx, - RemainNum: oldGold + coin + coinEx, - Add: 0, - LogType: opcode, - GameID: 0, - GameFreeID: 0, - BaseCoin: 0, - Operator: oper, - Remark: gold_desc, - }) - err = model.InsertCoinLog(coinlogex) - if err != nil { - //回滚到对账日志 - model.RemovePayCoinLog(platform, coinLog.LogId) - logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) - return err - } - return err - }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { - CacheDataMgr.ClearCacheBill(billNo, platform) - if data != nil { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = data.(error).Error() - } else { - pack.Tag = webapiproto.TagCode_SUCCESS - pack.Msg = "" - if isAccTodayRecharge && coin >= 0 { - OnPlayerPay(pd, coin) - } - if isAccTodayRecharge && coin >= 0 && coinEx >= 0 { - - plt := PlatformMgrSingleton.GetPlatform(pd.Platform) - curVer := int32(0) - if plt != nil { - curVer = plt.ExchangeVer - } - log := model.NewCoinGiveLogEx(pd.SnId, pd.Name, coin, coinEx, 0, common.GainWay_API_AddCoin, pd.PromoterTree, - model.COINGIVETYPE_PAY, curVer, pd.Platform, pd.Channel, pd.BeUnderAgentCode, - "", "system", pd.PackageID, int32(needFlowRate), int32(needGiveFlowRate)) - if log != nil { - err := model.InsertGiveCoinLog(log) - if err == nil { - if pd.LastExchangeOrder != "" && pd.TotalConvertibleFlow > 0 { - err = model.UpdateGiveCoinLastFlow(platform, pd.LastExchangeOrder, pd.TotalConvertibleFlow) - } - } - //清空流水,更新id - pd.TotalConvertibleFlow = 0 - pd.LastExchangeOrder = log.LogId.Hex() - if player == nil { - //需要回写数据库 - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - model.UpdatePlayerExchageFlowAndOrder(platform, int32(member_snid), 0, pd.LastExchangeOrder) - return nil - }), nil, "UpdateGiveCoinLogs").StartByExecutor(pd.AccountId) - } - } - - } - } - - tNode.TransRep.RetFiels = pack - tNode.Resume() - if err != nil { - logger.Logger.Error("AddCoinById task marshal data error:", err) - } - }), "AddCoinById").Start() - return common.ResponseTag_TransactYield, pack - } - })) + //WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Game/AddCoinById", WebAPIHandlerWrapper( + // func(tNode *transact.TransNode, params []byte) (int, proto.Message) { + // pack := &webapiproto.SAAddCoinById{} + // msg := &webapiproto.ASAddCoinById{} + // err1 := proto.Unmarshal(params, msg) + // if err1 != nil { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "数据序列化失败" + err1.Error() + // return common.ResponseTag_ParamError, pack + // } + // + // member_snid := msg.GetID() + // coin := msg.GetGold() + // coinEx := msg.GetGoldEx() + // oper := msg.GetOper() + // gold_desc := msg.GetDesc() + // billNo := int(msg.GetBillNo()) + // platform := msg.GetPlatform() + // logType := msg.GetLogType() + // isAccTodayRecharge := msg.GetIsAccTodayRecharge() + // needFlowRate := msg.GetNeedFlowRate() + // needGiveFlowRate := msg.GetNeedGiveFlowRate() + // + // if CacheDataMgr.CacheBillCheck(billNo, platform) { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "Bill number repeated!" + // return common.ResponseTag_ParamError, pack + // } + // CacheDataMgr.CacheBillNumber(billNo, platform) //防止手抖点两下 + // + // var err error + // var pd *model.PlayerData + // oldGold := int64(0) + // var timeStamp = time.Now().UnixNano() + // player := PlayerMgrSington.GetPlayerBySnId(int32(member_snid)) + // if player != nil { //在线玩家处理 + // if player.scene != nil { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "Unsupported!!! because player in scene!" + // return common.ResponseTag_ParamError, pack + // } + // pd = player.PlayerData + // if len(platform) > 0 && player.Platform != platform { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "player platform forbit!" + // return common.ResponseTag_ParamError, pack + // } + // + // if coin < 0 { + // if player.Coin+coin < 0 { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "coin not enough!" + // return common.ResponseTag_ParamError, pack + // } + // } + // + // opcode := int32(common.GainWay_API_AddCoin) + // if logType != 0 { + // opcode = logType + // } + // + // oldGold = player.Coin + // coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode, + // gold_desc, model.PayCoinLogType_Coin, coinEx) + // timeStamp = coinLog.TimeStamp + // //增加帐变记录 + // coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ + // Platform: pd.Platform, + // SnID: member_snid, + // Channel: pd.Channel, + // ChangeType: common.BillTypeCoin, + // ChangeNum: coin + coinEx, + // RemainNum: oldGold + coin + coinEx, + // Add: 0, + // LogType: opcode, + // GameID: 0, + // GameFreeID: 0, + // BaseCoin: 0, + // Operator: oper, + // Remark: gold_desc, + // }) + // + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // err = model.InsertPayCoinLogs(platform, coinLog) + // if err != nil { + // logger.Logger.Errorf("model.InsertPayCoinLogs err:%v log:%v", err, coinLog) + // return err + // } + // err = model.InsertCoinLog(coinlogex) + // if err != nil { + // //回滚到对账日志 + // model.RemovePayCoinLog(platform, coinLog.LogId) + // logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) + // return err + // } + // return err + // }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // if data != nil { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = data.(error).Error() + // } else { + // //player.Coin += coin + coinEx + // player.AddCoinAsync(coin+coinEx, 0, common.GainWay_API_AddCoin, oper, gold_desc, true, 0, false) + // //增加相应的泥码量 + // player.AddDirtyCoin(coin, coinEx) + // player.SetPayTs(timeStamp) + // + // if player.TodayGameData == nil { + // player.TodayGameData = model.NewPlayerGameCtrlData() + // } + // //actRandCoinMgr.OnPlayerRecharge(player, coin) + // if isAccTodayRecharge { + // + // player.AddCoinPayTotal(coin) + // player.TodayGameData.RechargeCoin += coin //累加当天充值金额 + // if coin >= 0 && coinEx >= 0 { + // plt := PlatformMgrSingleton.GetPlatform(pd.Platform) + // curVer := int32(0) + // if plt != nil { + // curVer = plt.ExchangeVer + // } + // log := model.NewCoinGiveLogEx(pd.SnId, pd.Name, coin, coinEx, 0, opcode, pd.PromoterTree, + // model.COINGIVETYPE_PAY, curVer, pd.Platform, pd.Channel, pd.BeUnderAgentCode, + // "", "system", pd.PackageID, int32(needFlowRate), int32(needGiveFlowRate)) + // if log != nil { + // err := model.InsertGiveCoinLog(log) + // if err == nil { + // if pd.LastExchangeOrder != "" && pd.TotalConvertibleFlow > 0 { + // err = model.UpdateGiveCoinLastFlow(platform, pd.LastExchangeOrder, pd.TotalConvertibleFlow) + // } + // } + // //清空流水,更新id + // pd.TotalConvertibleFlow = 0 + // pd.LastExchangeOrder = log.LogId.Hex() + // if player == nil { + // //需要回写数据库 + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // model.UpdatePlayerExchageFlowAndOrder(platform, member_snid, 0, pd.LastExchangeOrder) + // return nil + // }), nil, "UpdateGiveCoinLogs").StartByExecutor(pd.AccountId) + // } + // } + // } + // } + // + // player.dirty = true + // player.Time2Save() + // if player.scene == nil { //如果在大厅,那么同步下金币 + // player.SendDiffData() + // } + // player.SendPlayerRechargeAnswer(coin) + // pack.Tag = webapiproto.TagCode_SUCCESS + // pack.Msg = "" + // } + // tNode.TransRep.RetFiels = pack + // tNode.Resume() + // if err != nil { + // logger.Logger.Error("AddCoinById task marshal data error:", err) + // } + // }), "AddCoinById").Start() + // return common.ResponseTag_TransactYield, pack + // } else { + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // pd, _ = model.GetPlayerDataBySnId(platform, int32(member_snid), false, true) + // if pd == nil { + // return errors.New("Player not find.") + // } + // if len(platform) > 0 && pd.Platform != platform { + // return errors.New("player platform forbit.") + // } + // oldGold = pd.Coin + // if coin < 0 { + // if pd.Coin+coin < 0 { + // return errors.New("coin not enough!") + // } + // } + // + // opcode := int32(common.GainWay_API_AddCoin) + // if logType != 0 { + // opcode = logType + // } + // coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode, + // gold_desc, model.PayCoinLogType_Coin, coinEx) + // timeStamp = coinLog.TimeStamp + // err = model.InsertPayCoinLogs(platform, coinLog) + // if err != nil { + // logger.Logger.Errorf("model.InsertPayCoinLogs err:%v log:%v", err, coinLog) + // return err + // } + // //增加帐变记录 + // coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ + // Platform: pd.Platform, + // SnID: member_snid, + // Channel: pd.Channel, + // ChangeType: common.BillTypeCoin, + // ChangeNum: coin + coinEx, + // RemainNum: oldGold + coin + coinEx, + // Add: 0, + // LogType: opcode, + // GameID: 0, + // GameFreeID: 0, + // BaseCoin: 0, + // Operator: oper, + // Remark: gold_desc, + // }) + // err = model.InsertCoinLog(coinlogex) + // if err != nil { + // //回滚到对账日志 + // model.RemovePayCoinLog(platform, coinLog.LogId) + // logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) + // return err + // } + // return err + // }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // if data != nil { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = data.(error).Error() + // } else { + // pack.Tag = webapiproto.TagCode_SUCCESS + // pack.Msg = "" + // if isAccTodayRecharge && coin >= 0 { + // OnPlayerPay(pd, coin) + // } + // if isAccTodayRecharge && coin >= 0 && coinEx >= 0 { + // + // plt := PlatformMgrSingleton.GetPlatform(pd.Platform) + // curVer := int32(0) + // if plt != nil { + // curVer = plt.ExchangeVer + // } + // log := model.NewCoinGiveLogEx(pd.SnId, pd.Name, coin, coinEx, 0, common.GainWay_API_AddCoin, pd.PromoterTree, + // model.COINGIVETYPE_PAY, curVer, pd.Platform, pd.Channel, pd.BeUnderAgentCode, + // "", "system", pd.PackageID, int32(needFlowRate), int32(needGiveFlowRate)) + // if log != nil { + // err := model.InsertGiveCoinLog(log) + // if err == nil { + // if pd.LastExchangeOrder != "" && pd.TotalConvertibleFlow > 0 { + // err = model.UpdateGiveCoinLastFlow(platform, pd.LastExchangeOrder, pd.TotalConvertibleFlow) + // } + // } + // //清空流水,更新id + // pd.TotalConvertibleFlow = 0 + // pd.LastExchangeOrder = log.LogId.Hex() + // if player == nil { + // //需要回写数据库 + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // model.UpdatePlayerExchageFlowAndOrder(platform, int32(member_snid), 0, pd.LastExchangeOrder) + // return nil + // }), nil, "UpdateGiveCoinLogs").StartByExecutor(pd.AccountId) + // } + // } + // + // } + // } + // + // tNode.TransRep.RetFiels = pack + // tNode.Resume() + // if err != nil { + // logger.Logger.Error("AddCoinById task marshal data error:", err) + // } + // }), "AddCoinById").Start() + // return common.ResponseTag_TransactYield, pack + // } + // })) //重置水池 WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Game/ResetGamePool", WebAPIHandlerWrapper( func(tNode *transact.TransNode, params []byte) (int, proto.Message) {