道具修改优化
This commit is contained in:
parent
09202f60d3
commit
5ac106365e
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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{
|
||||
{
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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]
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}))
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue