Merge branch 'develop' into release
This commit is contained in:
commit
b6b7ff4035
|
@ -11,7 +11,7 @@
|
|||
|
||||
è<>¶å¥³ç¢Žç‰‡ ¢œ(0Þ
|
||||
钻石 ¢<>(0Þ
|
||||
!5å…ƒè¯<C3A8>费直兑券 ºê(0
|
||||
!5å…ƒè¯<C3A8>费直兑券 ºê(0
|
||||
钻石 ¢<>(0¸
|
||||
积分 ¬<>(È0¸
|
||||
1å…ƒè¯<C3A8>费直兑券 ¸ê(
|
|
@ -92,7 +92,7 @@
|
|||
"Type": 1,
|
||||
"Name": "5元话费直兑券",
|
||||
"Item_Id": 30010,
|
||||
"Grade": 5,
|
||||
"Grade": 1,
|
||||
"Oddrate": 17
|
||||
},
|
||||
{
|
||||
|
|
Binary file not shown.
Binary file not shown.
BIN
data/DB_Task.dat
BIN
data/DB_Task.dat
Binary file not shown.
|
@ -102,6 +102,15 @@ func (svc *ItemLogSvc) GetItemCount(req *model.ItemCountParam, count *int64) err
|
|||
return nil
|
||||
}
|
||||
|
||||
func (svc *ItemLogSvc) UpdateState(req *model.UpdateParam, res *model.UpdateRes) error {
|
||||
c := ItemLogsCollection(req.Platform)
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
err := c.UpdateId(req.LogId, bson.M{"$set": bson.M{"status": req.State}})
|
||||
return err
|
||||
}
|
||||
|
||||
func init() {
|
||||
rpc.Register(new(ItemLogSvc))
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ type ItemLog struct {
|
|||
GameId int32 // 游戏id,游戏中获得时有值
|
||||
GameFreeId int32 // 场次id,游戏中获得时有值
|
||||
Cost []*ItemInfo // 消耗的道具
|
||||
Id string // 撤销的id,兑换失败
|
||||
}
|
||||
|
||||
func NewItemLog() *ItemLog {
|
||||
|
@ -46,6 +47,7 @@ type ItemParam struct {
|
|||
GameId int64 // 游戏id,游戏中获得时有值
|
||||
GameFreeId int64 // 场次id,游戏中获得时有值
|
||||
Cost []*ItemInfo // 消耗的道具
|
||||
LogId string // 撤销的id,兑换失败
|
||||
}
|
||||
|
||||
func NewItemLogEx(param ItemParam) *ItemLog {
|
||||
|
@ -62,6 +64,7 @@ func NewItemLogEx(param ItemParam) *ItemLog {
|
|||
itemLog.GameId = int32(param.GameId)
|
||||
itemLog.GameFreeId = int32(param.GameFreeId)
|
||||
itemLog.Cost = param.Cost
|
||||
itemLog.Id = param.LogId
|
||||
return itemLog
|
||||
}
|
||||
|
||||
|
@ -87,3 +90,28 @@ func GetItemCount(param *ItemCountParam) (int64, error) {
|
|||
|
||||
return ret, err
|
||||
}
|
||||
|
||||
type UpdateParam struct {
|
||||
Platform string
|
||||
LogId bson.ObjectId
|
||||
State int
|
||||
}
|
||||
|
||||
type UpdateRes struct {
|
||||
}
|
||||
|
||||
func UpdateItemState(param *UpdateParam) error {
|
||||
if rpcCli == nil {
|
||||
logger.Logger.Warnf("rpcCli is nil")
|
||||
return errors.New("rpcCli is nil")
|
||||
}
|
||||
|
||||
var ret UpdateRes
|
||||
err := rpcCli.CallWithTimeout("ItemLogSvc.UpdateState", param, &ret, time.Second*30)
|
||||
if err != nil {
|
||||
logger.Logger.Warnf("UpdateItemState err:%v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -361,26 +361,6 @@ message DB_CreateroomArray {
|
|||
repeated DB_Createroom Arr = 1;
|
||||
}
|
||||
|
||||
message DB_DiamondLottery {
|
||||
|
||||
int32 Id = 1;
|
||||
|
||||
int32 Type = 2;
|
||||
|
||||
string Name = 3;
|
||||
|
||||
int32 Item_Id = 4;
|
||||
|
||||
int32 Grade = 5;
|
||||
|
||||
int32 Oddrate = 6;
|
||||
|
||||
}
|
||||
|
||||
message DB_DiamondLotteryArray {
|
||||
repeated DB_DiamondLottery Arr = 1;
|
||||
}
|
||||
|
||||
message DB_Fish {
|
||||
|
||||
int32 Id = 1;
|
||||
|
|
2
public
2
public
|
@ -1 +1 @@
|
|||
Subproject commit 3d5fc5c6e4eeb3b8008ff098751c1bd6b211793c
|
||||
Subproject commit ddda8276651cda84843a64458a7a3edd6835d6e6
|
|
@ -1,77 +0,0 @@
|
|||
|
||||
// Code generated by xlsx2proto.
|
||||
// DO NOT EDIT!
|
||||
|
||||
package srvdata
|
||||
|
||||
import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"mongo.games.com/game/protocol/server"
|
||||
)
|
||||
|
||||
var PBDB_DiamondLotteryMgr = &DB_DiamondLotteryMgr{
|
||||
Datas: &server.DB_DiamondLotteryArray{},
|
||||
pool: make(map[int32]*server.DB_DiamondLottery),
|
||||
|
||||
}
|
||||
|
||||
type DB_DiamondLotteryMgr struct {
|
||||
Datas *server.DB_DiamondLotteryArray
|
||||
pool map[int32]*server.DB_DiamondLottery
|
||||
|
||||
}
|
||||
|
||||
func (this *DB_DiamondLotteryMgr) unmarshal(data []byte) error {
|
||||
err := proto.Unmarshal(data, this.Datas)
|
||||
if err == nil {
|
||||
this.arrangeData()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *DB_DiamondLotteryMgr) reunmarshal(data []byte) error {
|
||||
newDatas := &server.DB_DiamondLotteryArray{}
|
||||
err := proto.Unmarshal(data, newDatas)
|
||||
if err == nil {
|
||||
for _, item := range newDatas.Arr {
|
||||
existItem := this.GetData(item.GetId())
|
||||
if existItem == nil {
|
||||
this.pool[item.GetId()] = item
|
||||
this.Datas.Arr = append(this.Datas.Arr, item)
|
||||
|
||||
} else {
|
||||
*existItem = *item
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *DB_DiamondLotteryMgr) arrangeData() {
|
||||
if this.Datas == nil {
|
||||
return
|
||||
}
|
||||
|
||||
dataArr := this.Datas.GetArr()
|
||||
if dataArr == nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, data := range dataArr {
|
||||
this.pool[data.GetId()] = data
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func (this *DB_DiamondLotteryMgr) GetData(id int32) *server.DB_DiamondLottery {
|
||||
if data, ok := this.pool[id]; ok {
|
||||
return data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
func init() {
|
||||
DataMgr.register("DB_DiamondLottery.dat", &ProtobufDataLoader{dh: PBDB_DiamondLotteryMgr})
|
||||
}
|
|
@ -306,13 +306,25 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e
|
|||
send()
|
||||
return nil
|
||||
}
|
||||
_, _, isF := BagMgrSingleton.AddItem(p, int64(msg.ItemId), int64(-1), 0, common.GainWayItemChange, "sys", "背包内使用兑换", 0, 0, false)
|
||||
bagInfo, _, isF := BagMgrSingleton.AddItemsV2(&ItemParam{
|
||||
P: p,
|
||||
Change: []*Item{
|
||||
{
|
||||
ItemId: msg.GetItemId(),
|
||||
ItemNum: -1,
|
||||
},
|
||||
},
|
||||
GainWay: common.GainWayItemChange,
|
||||
Operator: "system",
|
||||
Remark: "背包内使用兑换",
|
||||
noLog: false,
|
||||
})
|
||||
if isF {
|
||||
pack.RetCode = bag.OpResultCode_OPRC_Sucess
|
||||
pack.NowItemId = item.ItemId
|
||||
pack.NowItemNum = item.ItemNum
|
||||
//获取兑换码
|
||||
BagMgrSingleton.ItemExchangeCard(p, msg.ItemId, int32(itemInfo.Num), msg.CardType)
|
||||
BagMgrSingleton.ItemExchangeCard(p, msg.ItemId, int32(itemInfo.Num), msg.CardType, bagInfo.LogId)
|
||||
}
|
||||
}
|
||||
send()
|
||||
|
|
|
@ -4,12 +4,10 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
webapiproto "mongo.games.com/game/protocol/webapi"
|
||||
"mongo.games.com/game/webapi"
|
||||
"mongo.games.com/game/worldsrv/internal"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/globalsign/mgo/bson"
|
||||
"mongo.games.com/goserver/core/basic"
|
||||
"mongo.games.com/goserver/core/i18n"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
|
@ -21,7 +19,10 @@ import (
|
|||
"mongo.games.com/game/proto"
|
||||
"mongo.games.com/game/protocol/bag"
|
||||
playerproto "mongo.games.com/game/protocol/player"
|
||||
webapiproto "mongo.games.com/game/protocol/webapi"
|
||||
"mongo.games.com/game/srvdata"
|
||||
"mongo.games.com/game/webapi"
|
||||
"mongo.games.com/game/worldsrv/internal"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -63,6 +64,7 @@ type BagInfo struct {
|
|||
Platform string //平台
|
||||
BagItem map[int32]*Item //背包数据 key为itemId
|
||||
dirty bool
|
||||
LogId string `bson:"-"`
|
||||
}
|
||||
|
||||
// BagMgrSingleton 背包管理器
|
||||
|
@ -148,15 +150,18 @@ type ItemParam struct {
|
|||
Operator, Remark string // 操作人,备注
|
||||
gameId, gameFreeId int64 // 游戏id,场次id
|
||||
noLog bool // 是否不记录日志
|
||||
LogId string // 撤销的id,道具兑换失败
|
||||
}
|
||||
|
||||
type AddItemParam struct {
|
||||
Cost []*model.ItemInfo // 获得道具时消耗的道具数量
|
||||
Cost []*model.ItemInfo // 获得道具时消耗的道具数量
|
||||
LogId string
|
||||
}
|
||||
|
||||
func (this *BagMgr) AddItemsV2(args *ItemParam) (*BagInfo, bag.OpResultCode, bool) {
|
||||
return this.AddItems(args.P, args.Change, args.Add, args.GainWay, args.Operator, args.Remark, args.gameId, args.gameFreeId, args.noLog, AddItemParam{
|
||||
Cost: args.Cost,
|
||||
Cost: args.Cost,
|
||||
LogId: args.LogId,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -172,8 +177,10 @@ func (this *BagMgr) AddItemsV2(args *ItemParam) (*BagInfo, bag.OpResultCode, boo
|
|||
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.ItemInfo
|
||||
var id string
|
||||
if len(params) > 0 {
|
||||
cost = params[0].Cost
|
||||
id = params[0].LogId
|
||||
}
|
||||
|
||||
var items []*Item
|
||||
|
@ -223,6 +230,7 @@ func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int
|
|||
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,
|
||||
|
@ -309,9 +317,11 @@ func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int
|
|||
GameId: gameId,
|
||||
GameFreeId: gameFreeId,
|
||||
Cost: cost,
|
||||
LogId: id,
|
||||
})
|
||||
if log != nil {
|
||||
LogChannelSingleton.WriteLog(log)
|
||||
logId = log.LogId.Hex()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -342,6 +352,7 @@ func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int
|
|||
|
||||
if len(changeItems) > 0 {
|
||||
newBagInfo.dirty = true
|
||||
newBagInfo.LogId = logId
|
||||
p.dirty = true
|
||||
this.PlayerBag[p.SnId] = newBagInfo
|
||||
this.SyncBagData(p.SnId, changeItems...)
|
||||
|
@ -606,7 +617,7 @@ func (this *BagMgr) SyncBagData(snid int32, changeItemIds ...int32) {
|
|||
}
|
||||
|
||||
// 兑换话费卡
|
||||
func (this *BagMgr) ItemExchangeCard(p *Player, itemId int32, money, cardType int32) bool {
|
||||
func (this *BagMgr) ItemExchangeCard(p *Player, itemId int32, money, cardType int32, logId string) bool {
|
||||
// 兑换码奖品
|
||||
var err error
|
||||
var newMsg *model.Message
|
||||
|
@ -661,10 +672,30 @@ func (this *BagMgr) ItemExchangeCard(p *Player, itemId int32, money, cardType in
|
|||
ItemNum: 1, // 数量
|
||||
ObtainTime: time.Now().Unix(),
|
||||
})
|
||||
this.AddItems(p, items, 0, common.GainWayItemChange, "system", "背包内使用兑换失败", 0, 0, false)
|
||||
this.AddItemsV2(&ItemParam{
|
||||
P: p,
|
||||
Change: items,
|
||||
Add: 0,
|
||||
GainWay: common.GainWayItemChange,
|
||||
Operator: "system",
|
||||
Remark: "背包内使用兑换失败",
|
||||
gameId: 0,
|
||||
gameFreeId: 0,
|
||||
noLog: false,
|
||||
LogId: logId,
|
||||
})
|
||||
logger.Logger.Errorf("获取兑换码失败 snid:%v itemID:%v res:%v err:%v", p.SnId, itemId, res, err)
|
||||
pack.RetCode = bag.OpResultCode_OPRC_Error
|
||||
p.SendToClient(int(bag.SPacketID_PACKET_SC_ITEM_EXCHANGE_RES), pack)
|
||||
// 标记兑换失败
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
model.UpdateItemState(&model.UpdateParam{
|
||||
Platform: p.Platform,
|
||||
LogId: bson.ObjectIdHex(logId),
|
||||
State: 1,
|
||||
})
|
||||
return nil
|
||||
}), nil).Start()
|
||||
return
|
||||
}
|
||||
p := PlayerMgrSington.GetPlayerBySnId(p.SnId)
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue