v卡掉落
This commit is contained in:
parent
bc679f529e
commit
f2c63ce427
|
@ -599,6 +599,8 @@ const (
|
|||
ItemIDPermit = 100011 // 赛季通行证积分
|
||||
ItemIDLong = 50013 // 龙币
|
||||
ItemIDPetSkill = 11001 //宠物技能升级道具
|
||||
ItemIDVCard = 30001 // v卡
|
||||
ItemIDJCard = 30002 // 金券
|
||||
)
|
||||
|
||||
func ToItemId(id int32) int32 {
|
||||
|
|
Binary file not shown.
BIN
data/DB_Task.dat
BIN
data/DB_Task.dat
Binary file not shown.
|
@ -100,6 +100,29 @@ func (svc *DbShopLogSvc) GetDbShopLogsByState(args *model.DbShopLogArgs, dbShops
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetMoneyTotal(platform string, snid int32) int64 {
|
||||
c := DbShopLogCollection(platform)
|
||||
if c == nil {
|
||||
logger.Logger.Error("UpdateDbShopState == nil")
|
||||
return 0
|
||||
}
|
||||
var err error
|
||||
type m struct {
|
||||
Total int64 `bson:"total"`
|
||||
}
|
||||
tc := new(m)
|
||||
err = c.Pipe([]bson.M{
|
||||
{"$match": bson.M{"snid": snid, "state": 1, "consumenum": bson.M{"$gt": 0}}},
|
||||
{"$group": bson.M{"_id": nil, "total": bson.M{"$sum": "$consumenum"}}},
|
||||
}).AllowDiskUse().One(tc)
|
||||
if err != nil {
|
||||
logger.Logger.Error("GetMoneyTotal error:", err)
|
||||
return 0
|
||||
}
|
||||
return tc.Total
|
||||
}
|
||||
|
||||
func init() {
|
||||
rpc.Register(new(DbShopLogSvc))
|
||||
}
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package svc
|
||||
|
||||
import (
|
||||
"net/rpc"
|
||||
|
||||
"github.com/globalsign/mgo"
|
||||
"github.com/globalsign/mgo/bson"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/dbproxy/mongo"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"net/rpc"
|
||||
)
|
||||
|
||||
func ItemLogsCollection(plt string) *mongo.Collection {
|
||||
|
@ -13,7 +17,6 @@ func ItemLogsCollection(plt string) *mongo.Collection {
|
|||
if s != nil {
|
||||
c_itemlog, first := s.DB().C(model.ItemLogCollName)
|
||||
if first {
|
||||
c_itemlog.EnsureIndex(mgo.Index{Key: []string{"snid"}, Background: true, Sparse: true})
|
||||
c_itemlog.EnsureIndex(mgo.Index{Key: []string{"logtype"}, Background: true, Sparse: true})
|
||||
c_itemlog.EnsureIndex(mgo.Index{Key: []string{"itemid"}, Background: true, Sparse: true})
|
||||
c_itemlog.EnsureIndex(mgo.Index{Key: []string{"createts"}, Background: true, Sparse: true})
|
||||
|
@ -21,6 +24,7 @@ func ItemLogsCollection(plt string) *mongo.Collection {
|
|||
c_itemlog.EnsureIndex(mgo.Index{Key: []string{"typeid"}, Background: true, Sparse: true})
|
||||
c_itemlog.EnsureIndex(mgo.Index{Key: []string{"gameid"}, Background: true, Sparse: true})
|
||||
c_itemlog.EnsureIndex(mgo.Index{Key: []string{"gamefreeid"}, Background: true, Sparse: true})
|
||||
c_itemlog.EnsureIndex(mgo.Index{Key: []string{"snid", "logtype", "itemid", "typeid"}, Background: true, Sparse: true})
|
||||
}
|
||||
return c_itemlog
|
||||
}
|
||||
|
@ -44,6 +48,77 @@ func (svc *ItemLogSvc) InsertItemLog(log *model.ItemLog, ret *bool) (err error)
|
|||
return
|
||||
}
|
||||
|
||||
func GetItemCount(platform string, snid, id int32, tp int) (count int64) {
|
||||
c := ItemLogsCollection(platform)
|
||||
if c == nil {
|
||||
return 0
|
||||
}
|
||||
var err error
|
||||
var swapN, matchN int64
|
||||
var costN, gainN int64
|
||||
type m struct {
|
||||
Count int64 `bson:"count"`
|
||||
}
|
||||
tc := new(m)
|
||||
// 兑换返还
|
||||
err = c.Pipe([]bson.M{
|
||||
{"$match": bson.M{"snid": snid, "logtype": 0, "itemid": id, "typeid": common.GainWay_Exchange}},
|
||||
{"$group": bson.M{"_id": nil, "count": bson.M{"$sum": "$count"}}},
|
||||
}).AllowDiskUse().One(tc)
|
||||
if err != nil {
|
||||
logger.Logger.Warn("GetItemCount swapN error:", err)
|
||||
return 0
|
||||
}
|
||||
swapN = tc.Count
|
||||
|
||||
// 比赛返回
|
||||
err = c.Pipe([]bson.M{
|
||||
{"$match": bson.M{"snid": snid, "logtype": 0, "itemid": id, "typeid": common.GainWay_MatchSignup}},
|
||||
{"$group": bson.M{"_id": nil, "count": bson.M{"$sum": "$count"}}},
|
||||
}).AllowDiskUse().One(tc)
|
||||
if err != nil {
|
||||
logger.Logger.Warn("GetItemCount matchN error:", err)
|
||||
return 0
|
||||
}
|
||||
matchN = tc.Count
|
||||
|
||||
// 消耗总数量
|
||||
err = c.Pipe([]bson.M{
|
||||
{"$match": bson.M{"snid": snid, "logtype": 1, "itemid": id}},
|
||||
{"$group": bson.M{"_id": nil, "count": bson.M{"$sum": "$count"}}},
|
||||
}).AllowDiskUse().One(tc)
|
||||
if err != nil {
|
||||
logger.Logger.Warn("GetItemCount costN error:", err)
|
||||
return 0
|
||||
}
|
||||
costN = tc.Count
|
||||
|
||||
// 获得总数量
|
||||
err = c.Pipe([]bson.M{
|
||||
{"$match": bson.M{"snid": snid, "logtype": 0, "itemid": id}},
|
||||
{"$group": bson.M{"_id": nil, "count": bson.M{"$sum": "$count"}}},
|
||||
}).AllowDiskUse().One(tc)
|
||||
if err != nil {
|
||||
logger.Logger.Warn("GetItemCount gainN error:", err)
|
||||
return 0
|
||||
}
|
||||
gainN = tc.Count
|
||||
|
||||
if tp == 0 {
|
||||
// 获得数量 = 获得总数量 - 兑换返还 - 比赛返回
|
||||
count = gainN - swapN - matchN
|
||||
} else {
|
||||
// 消耗数量 = 消耗总数量 - 兑换返还 - 比赛返回
|
||||
count = costN - swapN - matchN
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
func (svc *ItemLogSvc) GetItemCount(req *model.ItemCountParam, count *int64) error {
|
||||
*count = GetItemCount(req.Platform, req.Snid, req.Id, req.Tp)
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
rpc.Register(new(ItemLogSvc))
|
||||
}
|
||||
|
|
|
@ -7,9 +7,11 @@ import (
|
|||
|
||||
"github.com/globalsign/mgo"
|
||||
"github.com/globalsign/mgo/bson"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/dbproxy/mongo"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -95,6 +97,7 @@ func (svc *BagSvc) AddBagItem(args *model.BagInfo, ret *bool) error {
|
|||
if bag.BagId == "" {
|
||||
bag.BagId = bson.NewObjectId()
|
||||
}
|
||||
var vCard int64 // v卡返还
|
||||
for id, v := range args.BagItem {
|
||||
if item, exist := bag.BagItem[id]; !exist {
|
||||
if v.ItemNum <= 0 {
|
||||
|
@ -111,12 +114,25 @@ func (svc *BagSvc) AddBagItem(args *model.BagInfo, ret *bool) error {
|
|||
}
|
||||
item.ItemNum += v.ItemNum
|
||||
}
|
||||
// v卡返还
|
||||
if id == common.ItemIDVCard && args.GainWay == common.GainWay_Exchange && v.ItemNum > 0 {
|
||||
vCard = v.ItemNum
|
||||
}
|
||||
}
|
||||
_, err = cbag.Upsert(bson.M{"_id": bag.BagId}, bag)
|
||||
if err != nil {
|
||||
*ret = false
|
||||
logger.Logger.Info("AddBagItem error ", err)
|
||||
}
|
||||
|
||||
// v卡返还
|
||||
if vCard > 0 {
|
||||
c := PlayerDataCollection(args.Platform)
|
||||
if c != nil {
|
||||
err = c.Update(bson.M{"snid": args.SnId}, bson.M{"$inc": bson.M{"vcardcost": -vCard}})
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -400,6 +400,12 @@ func (svc *PlayerDataSvc) GetPlayerDataBySnId(args *model.GetPlayerDataBySnIdArg
|
|||
ret.Pd.IScoreTs = time.Now()
|
||||
cplayerdata.Update(bson.M{"snid": args.SnId}, bson.M{"$set": bson.M{"icode": code, "iscorets": ret.Pd.IScoreTs}})
|
||||
}
|
||||
if ret.Pd.VCardCost == 0 {
|
||||
ret.Pd.VCardCost = GetItemCount(ret.Pd.Platform, ret.Pd.SnId, common.ItemIDVCard, 1)
|
||||
}
|
||||
if ret.Pd.MoneyTotal == 0 {
|
||||
ret.Pd.MoneyTotal = GetMoneyTotal(ret.Pd.Platform, ret.Pd.SnId)
|
||||
}
|
||||
f(ret.Pd)
|
||||
if args.CorrectData && ret.Pd != nil {
|
||||
CorrectData(ret.Pd)
|
||||
|
|
|
@ -2,6 +2,7 @@ package base
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"time"
|
||||
|
@ -2149,7 +2150,8 @@ func (this *Scene) TryBillExGameDrop(p *Player) {
|
|||
if drop.MaxAmount > drop.MinAmount {
|
||||
num = rand.Int31n(drop.MaxAmount-drop.MinAmount+1) + drop.MinAmount
|
||||
}
|
||||
|
||||
a := math.Max(float64(p.MoneyTotal), 50) * 10.0 / math.Max(float64(p.VCardCost), 500.0)
|
||||
num = int32(float64(num) * math.Min(a, 1.5))
|
||||
p.Items[drop.ItemId] += int64(num)
|
||||
realDrop[drop.ItemId] = num
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ type BagInfo struct {
|
|||
SnId int32 //玩家账号直接在这里生成
|
||||
Platform string //平台
|
||||
BagItem map[int32]*Item //背包数据 key为itemId
|
||||
GainWay int32 `bson:"-"`
|
||||
}
|
||||
|
||||
type Item struct {
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/globalsign/mgo/bson"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -62,3 +64,26 @@ func NewItemLogEx(param ItemParam) *ItemLog {
|
|||
itemLog.Cost = param.Cost
|
||||
return itemLog
|
||||
}
|
||||
|
||||
type ItemCountParam struct {
|
||||
Platform string
|
||||
Snid int32 // 玩家id
|
||||
Id int32 // 道具id
|
||||
Tp int // 类型 0.获取 1.消耗
|
||||
}
|
||||
|
||||
func GetItemCount(param *ItemCountParam) (int64, error) {
|
||||
if rpcCli == nil {
|
||||
logger.Logger.Warnf("rpcCli is nil")
|
||||
return 0, errors.New("rpcCli is nil")
|
||||
}
|
||||
|
||||
var ret int64
|
||||
err := rpcCli.CallWithTimeout("ItemLogSvc.GetItemCount", param, &ret, time.Second*30)
|
||||
if err != nil {
|
||||
logger.Logger.Warnf("GetItemCount err:%v", err)
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return ret, err
|
||||
}
|
||||
|
|
|
@ -479,6 +479,8 @@ type PlayerData struct {
|
|||
Permit time.Time // 赛季通行证领取时间
|
||||
PermitStartTs int64 // 赛季通行证开始时间戳
|
||||
DiamondLotteryScore int64 //钻石抽奖幸运值
|
||||
VCardCost int64 // 消耗v卡数量
|
||||
MoneyTotal int64 // 现金总充值金额,不包含api加币时的现金
|
||||
}
|
||||
|
||||
// 七日签到数据
|
||||
|
@ -489,7 +491,6 @@ type NewSignData struct {
|
|||
TurnplateIdx []int32 //领取转盘下标
|
||||
VideoTicket int64 // 领取视频奖励时间戳
|
||||
Addup2Data map[int32]map[int32]int64 // 进阶奖励key1 - day key2-次数 value-结束领取时间戳(-1代表已领取)
|
||||
|
||||
}
|
||||
|
||||
type TaskData struct {
|
||||
|
|
|
@ -322,6 +322,14 @@ func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int
|
|||
if v.ItemId == common.ItemIDPetSkill && v.ItemNum > 0 {
|
||||
PetMgrSington.CheckShowRed(p)
|
||||
}
|
||||
if v.ItemId == common.ItemIDVCard && (v.ItemNum <= 0 ||
|
||||
gainWay == common.GainWay_MatchSignup || gainWay == common.GainWay_Exchange) {
|
||||
// 比赛报名返还,兑换返还
|
||||
p.VCardCost += -v.ItemNum
|
||||
if p.VCardCost < 0 {
|
||||
p.VCardCost = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(changeItems) > 0 {
|
||||
|
@ -386,6 +394,7 @@ func (this *BagMgr) AddItemsOffline(platform string, snid int32, addItems []*Ite
|
|||
SnId: findPlayer.SnId,
|
||||
Platform: findPlayer.Platform,
|
||||
BagItem: make(map[int32]*model.Item),
|
||||
GainWay: gainWay,
|
||||
}
|
||||
for _, v := range addItems {
|
||||
if v == nil || v.ItemNum == 0 {
|
||||
|
@ -572,7 +581,7 @@ func (this *BagMgr) SyncBagData(snid int32, changeItemIds ...int32) {
|
|||
//Describe: itemInfo.Describe,
|
||||
ObtainTime: itemInfo.ObtainTime,
|
||||
})
|
||||
if itemInfo.ItemId == VCard {
|
||||
if itemInfo.ItemId == common.ItemIDVCard {
|
||||
FriendMgrSington.UpdateInfo(p.Platform, p.SnId)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ func (this *FriendMgr) UpdateInfo(platform string, snid int32) {
|
|||
info.Sex = p.Sex
|
||||
info.Coin = p.Coin
|
||||
info.Diamond = p.Diamond
|
||||
item := BagMgrSingleton.GetItem(p.SnId, VCard)
|
||||
item := BagMgrSingleton.GetItem(p.SnId, common.ItemIDVCard)
|
||||
if item != nil {
|
||||
info.VCard = item.ItemNum
|
||||
}
|
||||
|
|
|
@ -183,6 +183,9 @@ func (this *Player) init() bool {
|
|||
if this.WelfData == nil {
|
||||
this.WelfData = model.NewWelfareData()
|
||||
}
|
||||
if this.VCardCost < 0 {
|
||||
this.VCardCost = 0
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -3021,7 +3024,7 @@ func (this *Player) SendPlayerInfo() {
|
|||
if this.WelfData != nil {
|
||||
scPlayerData.Data.ReliefFundTimes = this.WelfData.ReliefFundTimes
|
||||
}
|
||||
if item := BagMgrSingleton.GetItem(this.SnId, VCard); item != nil {
|
||||
if item := BagMgrSingleton.GetItem(this.SnId, common.ItemIDVCard); item != nil {
|
||||
scPlayerData.Data.VCoin = item.ItemNum //V卡
|
||||
}
|
||||
// 排位积分
|
||||
|
@ -3925,6 +3928,7 @@ func (this *Player) GetPayGoodsInfo() {
|
|||
this.AddDiamond(int64(info.Amount[1]), 0, info.GainWay, "Callback_login", info.Remark)
|
||||
}
|
||||
this.AddMoneyPayTotal(int64(info.ConsumeNum))
|
||||
this.MoneyTotal += int64(info.ConsumeNum)
|
||||
if info.ItemInfo != nil {
|
||||
for _, v := range info.ItemInfo {
|
||||
items = append(items, &Item{ItemId: v.ItemId, ItemNum: v.ItemNum})
|
||||
|
|
|
@ -72,11 +72,6 @@ const (
|
|||
Shop_Status_Revoke // 4为撤单
|
||||
)
|
||||
|
||||
const (
|
||||
VCard int32 = 30001
|
||||
JCard int32 = 30002 //金券
|
||||
)
|
||||
|
||||
/*
|
||||
1.兑换成功:兑换成功,请等待审核
|
||||
2.今日兑换已达上限,请明日再来
|
||||
|
@ -811,7 +806,7 @@ func (this *ShopMgr) Exchange(p *Player, goodsId int32, username, mobile, commen
|
|||
//扣除V卡
|
||||
if info.Price > 0 {
|
||||
item := model.ItemInfo{
|
||||
ItemId: VCard,
|
||||
ItemId: common.ItemIDVCard,
|
||||
ItemNum: int64(info.Price * num),
|
||||
}
|
||||
_, code, _ := BagMgrSingleton.AddItem(p, int64(item.ItemId), -item.ItemNum, 0, common.GainWay_Exchange,
|
||||
|
@ -825,7 +820,7 @@ func (this *ShopMgr) Exchange(p *Player, goodsId int32, username, mobile, commen
|
|||
//扣除金券
|
||||
if info.JPrice > 0 {
|
||||
item := model.ItemInfo{
|
||||
ItemId: JCard,
|
||||
ItemId: common.ItemIDJCard,
|
||||
ItemNum: int64(info.JPrice * num),
|
||||
}
|
||||
_, _, isF := BagMgrSingleton.AddItem(p, int64(item.ItemId), -item.ItemNum, 0, common.GainWay_Exchange,
|
||||
|
|
|
@ -174,613 +174,6 @@ func (this *WebAPIHandlerMgr) GetWebAPIHandler(name string) WebAPIHandler {
|
|||
}
|
||||
|
||||
func init() {
|
||||
//API用户登录
|
||||
//WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Member/APIMemberRegisterOrLogin", WebAPIHandlerWrapper(
|
||||
// func(tNode *transact.TransNode, params []byte) (int, proto.Message) {
|
||||
// logger.Logger.Trace("WebAPIHandler:/api/Member/APIMemberRegisterOrLogin", params)
|
||||
// pack := &webapi.SALogin{}
|
||||
// msg := &webapi.ASLogin{}
|
||||
// err1 := proto.Unmarshal(params, msg)
|
||||
// if err1 != nil {
|
||||
// pack.Tag = webapi.TagCode_FAILED
|
||||
// pack.Msg = "数据序列化失败" + err1.Error()
|
||||
// return common.ResponseTag_ParamError, pack
|
||||
// }
|
||||
//
|
||||
// platformID, channel, _, _, tagkey := PlatformMgrSingleton.GetPlatformByPackageTag(msg.GetPlatformTag())
|
||||
// platform := PlatformMgrSingleton.GetPlatform(strconv.Itoa(int(platformID)))
|
||||
// if platform == nil {
|
||||
// pack.Tag = webapi.TagCode_FAILED
|
||||
// pack.Msg = "没有对应的包标识"
|
||||
// return common.ResponseTag_ParamError, pack
|
||||
// }
|
||||
// merchantkey := platform.MerchantKey
|
||||
//
|
||||
// sign := msg.GetSign()
|
||||
//
|
||||
// raw := fmt.Sprintf("%v%v%v%v%v", msg.GetTelegramId(), msg.GetPlatformTag(), msg.GetUsername(), merchantkey, msg.GetTs())
|
||||
// h := md5.New()
|
||||
// io.WriteString(h, raw)
|
||||
// newsign := hex.EncodeToString(h.Sum(nil))
|
||||
//
|
||||
// if newsign != sign {
|
||||
// pack.Tag = webapi.TagCode_FAILED
|
||||
// pack.Msg = "商户验签失败"
|
||||
// return common.ResponseTag_ParamError, pack
|
||||
// }
|
||||
//
|
||||
// var acc *model.Account
|
||||
// var errcode int
|
||||
//
|
||||
// rawpwd := fmt.Sprintf("%v%v%v", msg.GetSign(), common.GetAppId(), time.Now().Unix())
|
||||
// hpwd := md5.New()
|
||||
// io.WriteString(hpwd, rawpwd)
|
||||
// pwd := hex.EncodeToString(h.Sum(nil))
|
||||
//
|
||||
// task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
// acc, errcode = model.AccountIsExist(msg.GetTelegramId(), msg.GetTelegramId(), "", platform.IdStr, time.Now().Unix(), 5, tagkey, false)
|
||||
// if errcode == 2 {
|
||||
// var err int
|
||||
// acc, err = model.InsertAccount(msg.GetTelegramId(), pwd, platform.IdStr, strconv.Itoa(int(channel)), "", "",
|
||||
// "telegramapi", 0, 0, msg.GetPlatformTag(), "", "", "", tagkey)
|
||||
// if acc != nil { //需要预先创建玩家数据
|
||||
// _, _ = model.GetPlayerData(acc.PackegeTag,acc.AccountId.Hex())
|
||||
// }
|
||||
// if err == 5 {
|
||||
// return 1
|
||||
// } else {
|
||||
// //t.flag = login_proto.OpResultCode_OPRC_Login_CreateAccError
|
||||
// }
|
||||
// }
|
||||
// return errcode
|
||||
// }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
|
||||
// switch data.(int) {
|
||||
// case 1:
|
||||
// {
|
||||
// if err := model.UpdatePlayerTokenPassword(acc.Platform, acc.AccountId.Hex(), pwd); err != nil {
|
||||
// pack.Tag = webapi.TagCode_FAILED
|
||||
// pack.Msg = err.Error()
|
||||
// } else {
|
||||
// tokenuserdata := &common.TokenUserData{
|
||||
// TelegramId: msg.GetTelegramId(),
|
||||
// Password: pwd,
|
||||
// Packagetag: msg.GetPlatformTag(),
|
||||
// Expired: time.Now().Add(time.Minute * 15).Unix(),
|
||||
// }
|
||||
//
|
||||
// token, err := common.CreateTokenAes(tokenuserdata)
|
||||
// if err != nil {
|
||||
// pack.Tag = webapi.TagCode_FAILED
|
||||
// pack.Msg = err.Error()
|
||||
// } else {
|
||||
// pack.Tag = webapi.TagCode_SUCCESS
|
||||
// pack.Msg = ""
|
||||
// pack.Snid = proto.Int32(acc.SnId)
|
||||
// pack.Token = fmt.Sprintf("%v?token=%v&snid=%v", model.GameParamData.CSURL, token, acc.SnId)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// case 2:
|
||||
// {
|
||||
// pack.Tag = webapi.TagCode_FAILED
|
||||
// pack.Msg = "创建帐号失败"
|
||||
// }
|
||||
// case 3:
|
||||
// {
|
||||
// //t.flag = login_proto.OpResultCode_OPRC_LoginPassError
|
||||
// pack.Tag = webapi.TagCode_FAILED
|
||||
// pack.Msg = "账号密码错误"
|
||||
// }
|
||||
// case 4:
|
||||
// {
|
||||
// //t.flag = login_proto.OpResultCode_OPRC_AccountBeFreeze
|
||||
// pack.Tag = webapi.TagCode_FAILED
|
||||
// pack.Msg = "帐号冻结"
|
||||
// }
|
||||
// }
|
||||
// tNode.TransRep.RetFiels = pack
|
||||
// tNode.Resume()
|
||||
// }), "APIMemberRegisterOrLogin").Start()
|
||||
// return common.ResponseTag_TransactYield, pack
|
||||
// }))
|
||||
|
||||
//API用户加减币
|
||||
//WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Game/APIAddSubCoinById", WebAPIHandlerWrapper(
|
||||
// func(tNode *transact.TransNode, params []byte) (int, proto.Message) {
|
||||
// pack := &webapi.SAAddCoinById{}
|
||||
// msg := &webapi.ASAddCoinById{}
|
||||
// err1 := proto.Unmarshal(params, msg)
|
||||
// if err1 != nil {
|
||||
// pack.Tag = webapi.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 = webapi.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)
|
||||
// oldSafeBoxGold := 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 = webapi.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 = webapi.TagCode_FAILED
|
||||
// pack.Msg = "player platform forbit!"
|
||||
// return common.ResponseTag_ParamError, pack
|
||||
// }
|
||||
//
|
||||
// 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 = webapi.TagCode_FAILED
|
||||
// pack.Msg = "coin not enough!"
|
||||
// return common.ResponseTag_ParamError, pack
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //if logType != 0 {
|
||||
// // opcode = logType
|
||||
// //}
|
||||
//
|
||||
// oldGold = player.Coin
|
||||
// oldSafeBoxGold = player.SafeBoxCoin
|
||||
// coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode,
|
||||
// gold_desc, model.PayCoinLogType_Coin, coinEx)
|
||||
// timeStamp = coinLog.TimeStamp
|
||||
// //增加帐变记录
|
||||
// coinlogex := model.NewCoinLogEx(int32(member_snid), coin+coinEx, oldGold+coin+coinEx,
|
||||
// oldSafeBoxGold, 0, opcode, 0, oper, gold_desc, pd.Platform, pd.Channel,
|
||||
// pd.BeUnderAgentCode, 0, pd.PackageID, 0)
|
||||
//
|
||||
// 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 = webapi.TagCode_FAILED
|
||||
// pack.Msg = data.(error).Error()
|
||||
// } else {
|
||||
// //player.Coin += coin + coinEx
|
||||
// player.AddCoinAsync(coin+coinEx, common.GainWay_Api_In, 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 = webapi.TagCode_SUCCESS
|
||||
// pack.Msg = ""
|
||||
// }
|
||||
// tNode.TransRep.RetFiels = pack
|
||||
// tNode.Resume()
|
||||
// if err != nil {
|
||||
// logger.Logger.Error("AddSubCoinById task marshal data error:", err)
|
||||
// }
|
||||
// }), "APIAddCoinById").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
|
||||
// oldSafeBoxGold = pd.SafeBoxCoin
|
||||
//
|
||||
// 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,
|
||||
// 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(int32(member_snid), coin+coinEx, oldGold+coin+coinEx,
|
||||
// oldSafeBoxGold, 0, opcode, 0, oper, gold_desc, pd.Platform,
|
||||
// pd.Channel, pd.BeUnderAgentCode, 0, pd.PackageID, 0)
|
||||
// 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 = webapi.TagCode_FAILED
|
||||
// pack.Msg = data.(error).Error()
|
||||
// } else {
|
||||
// pack.Tag = webapi.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/GetMemberGoldById", WebAPIHandlerWrapper(
|
||||
// func(tNode *transact.TransNode, params []byte) (int, proto.Message) {
|
||||
// pack := &webapi.SAMemberGold{}
|
||||
// msg := &webapi.ASMemberGold{}
|
||||
//
|
||||
// err1 := proto.Unmarshal(params, msg)
|
||||
// if err1 != nil {
|
||||
// pack.Tag = webapi.TagCode_FAILED
|
||||
// pack.Msg = "数据序列化失败" + err1.Error()
|
||||
// return common.ResponseTag_ParamError, pack
|
||||
// }
|
||||
//
|
||||
// platform := PlatformMgrSingleton.GetPlatform(msg.GetPlatform())
|
||||
// if platform == nil {
|
||||
// pack.Tag = webapi.TagCode_FAILED
|
||||
// pack.Msg = "没有对应的包标识"
|
||||
// return common.ResponseTag_ParamError, pack
|
||||
// }
|
||||
// platform_param := msg.GetPlatform()
|
||||
// member_snid := msg.GetSnid()
|
||||
// var err error
|
||||
// gold := int64(0)
|
||||
// bank := int64(0)
|
||||
// p := PlayerMgrSington.GetPlayerBySnId(member_snid)
|
||||
// task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
// if p != nil {
|
||||
// if len(platform_param) > 0 && p.Platform != platform_param {
|
||||
// return errors.New("Platform error.")
|
||||
// }
|
||||
// bank = p.SafeBoxCoin
|
||||
// gold = p.GetCoin()
|
||||
// return nil
|
||||
// } else {
|
||||
// pbi, _ := model.GetPlayerDataBySnId(platform_param, member_snid, true, true)
|
||||
// if pbi == nil {
|
||||
// return errors.New("snid error")
|
||||
// }
|
||||
// if len(platform_param) > 0 && pbi.Platform != platform_param {
|
||||
// return errors.New("Platform error.")
|
||||
// }
|
||||
// bank = pbi.SafeBoxCoin
|
||||
// gold = pbi.Coin
|
||||
// return nil
|
||||
// }
|
||||
// }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
|
||||
// if data != nil {
|
||||
// pack.Tag = webapi.TagCode_FAILED
|
||||
// pack.Msg = data.(error).Error()
|
||||
// } else {
|
||||
//
|
||||
// pd := &webapi.PlayerCoinData{
|
||||
// Id: member_snid,
|
||||
// Gold: gold,
|
||||
// Bank: bank,
|
||||
// }
|
||||
// pack.Tag = webapi.TagCode_SUCCESS
|
||||
// //pack.Msg = data.(error).Error()
|
||||
// pack.Data = pd
|
||||
// }
|
||||
// tNode.TransRep.RetFiels = pack
|
||||
// tNode.Resume()
|
||||
// if err != nil {
|
||||
// logger.Logger.Error("AddSubCoinById task marshal data error:", err)
|
||||
// }
|
||||
// }), "GetMemberGoldById").Start()
|
||||
//
|
||||
// return common.ResponseTag_TransactYield, pack
|
||||
// }))
|
||||
|
||||
//获取用户注单记录游戏记录
|
||||
//WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Member/GetGameHistory", WebAPIHandlerWrapper(
|
||||
// func(tNode *transact.TransNode, params []byte) (int, proto.Message) {
|
||||
// pack := &webapi.SAPlayerHistory{}
|
||||
// msg := &webapi.ASPlayerHistory{}
|
||||
//
|
||||
// err1 := proto.Unmarshal(params, msg)
|
||||
// if err1 != nil {
|
||||
// pack.Tag = webapi.TagCode_FAILED
|
||||
// pack.Msg = "数据序列化失败" + err1.Error()
|
||||
// return common.ResponseTag_ParamError, pack
|
||||
// }
|
||||
//
|
||||
// platform := PlatformMgrSingleton.GetPlatform(msg.GetPlatform())
|
||||
// if platform == nil {
|
||||
// pack.Tag = webapi.TagCode_FAILED
|
||||
// pack.Msg = "没有对应的包标识"
|
||||
// return common.ResponseTag_ParamError, pack
|
||||
// }
|
||||
// platform_param := msg.GetPlatform()
|
||||
// member_snid := msg.GetSnid()
|
||||
//
|
||||
// gameid := int(msg.GetGameId())
|
||||
// historyModel := msg.GetGameHistoryModel()
|
||||
// p := PlayerMgrSington.GetPlayerBySnId(member_snid)
|
||||
// if p == nil{
|
||||
// pi,_:=model.GetPlayerDataBySnId(platform_param, member_snid, true, true)
|
||||
// p = &Player{PlayerData:pi}
|
||||
// }
|
||||
//
|
||||
// if p != nil {
|
||||
// switch historyModel {
|
||||
// case PLAYER_HISTORY_MODEL: // 历史记录
|
||||
// task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
// var genPlayerHistoryInfo = func(spinID string, isFree bool, createdTime, totalBetValue, totalPriceValue, totalBonusValue, multiple int64, player *gamehall.PlayerHistoryInfo) {
|
||||
// player.SpinID = proto.String(spinID)
|
||||
// player.CreatedTime = proto.Int64(createdTime)
|
||||
// player.TotalBetValue = proto.Int64(totalBetValue)
|
||||
// player.TotalPriceValue = proto.Int64(totalPriceValue)
|
||||
// player.IsFree = proto.Bool(isFree)
|
||||
// player.TotalBonusValue = proto.Int64(totalBonusValue)
|
||||
// player.Multiple = proto.Int64(multiple)
|
||||
// }
|
||||
//
|
||||
// var genPlayerHistoryInfoMsg = func(spinid string, v *model.NeedGameRecord, gdl *model.GameDetailedLog, player *gamehall.PlayerHistoryInfo) {
|
||||
// switch gameid {
|
||||
// case common.GameId_Crash:
|
||||
// data, err := model.UnMarshalGameNoteByHUNDRED(gdl.GameDetailedNote)
|
||||
// if err != nil {
|
||||
// logger.Logger.Errorf("World UnMarshalAvengersGameNote error:%v", err)
|
||||
// }
|
||||
// jsonString, _ := json.Marshal(data)
|
||||
//
|
||||
// // convert json to struct
|
||||
// gnd := model.CrashType{}
|
||||
// json.Unmarshal(jsonString, &gnd)
|
||||
//
|
||||
// //gnd := data.(*model.CrashType)
|
||||
// for _, curplayer := range gnd.PlayerData {
|
||||
// if curplayer.UserId == p.SnId {
|
||||
// genPlayerHistoryInfo(spinid, false, int64(v.Ts), int64(curplayer.UserBetTotal), curplayer.ChangeCoin, 0, int64(curplayer.UserMultiple), player)
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// case common.GameId_Avengers:
|
||||
// data, err := model.UnMarshalAvengersGameNote(gdl.GameDetailedNote)
|
||||
// if err != nil {
|
||||
// logger.Logger.Errorf("World UnMarshalAvengersGameNote error:%v", err)
|
||||
// }
|
||||
// gnd := data.(*model.GameResultLog)
|
||||
// genPlayerHistoryInfo(spinid, gnd.BaseResult.IsFree, int64(v.Ts), int64(gnd.BaseResult.TotalBet), gnd.BaseResult.WinTotal, gnd.BaseResult.WinSmallGame, 0, player)
|
||||
// //case common.GameId_EasterIsland:
|
||||
// // data, err := model.UnMarshalEasterIslandGameNote(gdl.GameDetailedNote)
|
||||
// // if err != nil {
|
||||
// // logger.Logger.Errorf("World UnMarshalEasterIslandGameNote error:%v", err)
|
||||
// // }
|
||||
// // gnd := data.(*model.EasterIslandType)
|
||||
// // genPlayerHistoryInfo(spinid, gnd.IsFree, int64(v.Ts), int64(gnd.Score), gnd.TotalPriceValue, gnd.TotalBonusValue, player)
|
||||
// default:
|
||||
// logger.Logger.Errorf("World CSHundredSceneGetGameHistoryInfoHandler receive gameid(%v) error", gameid)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// gameclass := int32(2)
|
||||
// spinid := strconv.FormatInt(int64(p.SnId), 10)
|
||||
// dbGameFrees := srvdata.PBDB_GameFreeMgr.Datas.Arr //.GetData(data.DbGameFree.Id)
|
||||
// roomtype := int32(0)
|
||||
// for _, v := range dbGameFrees {
|
||||
// if int32(gameid) == v.GetGameId() {
|
||||
// gameclass = v.GetGameClass()
|
||||
// roomtype = v.GetSceneType()
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// gpl := model.GetPlayerListByHallEx(p.SnId, p.Platform, 0, 50, 0, 0, roomtype, gameclass, gameid)
|
||||
// pack := &gamehall.SCPlayerHistory{}
|
||||
// for _, v := range gpl.Data {
|
||||
// if v.GameDetailedLogId == "" {
|
||||
// logger.Logger.Error("World PlayerHistory GameDetailedLogId is nil")
|
||||
// break
|
||||
// }
|
||||
// gdl := model.GetPlayerHistory(p.Platform, v.GameDetailedLogId)
|
||||
// player := &gamehall.PlayerHistoryInfo{}
|
||||
// genPlayerHistoryInfoMsg(spinid, v, gdl, player)
|
||||
// pack.PlayerHistory = append(pack.PlayerHistory, player)
|
||||
// }
|
||||
// proto.SetDefaults(pack)
|
||||
// logger.Logger.Infof("World gameid:%v PlayerHistory:%v ", gameid, pack)
|
||||
// return pack
|
||||
// }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
|
||||
// if data == nil {
|
||||
// tNode.TransRep.RetFiels = data
|
||||
// tNode.Resume()
|
||||
// }
|
||||
// }), "CSGetPlayerHistoryHandlerWorld").Start()
|
||||
// case BIGWIN_HISTORY_MODEL: // 爆奖记录
|
||||
// jackpotList := JackpotListMgrSington.GetJackpotList(gameid)
|
||||
// //if len(jackpotList) < 1 {
|
||||
// // JackpotListMgrSington.GenJackpot(gameid) // 初始化爆奖记录
|
||||
// // JackpotListMgrSington.after(gameid) // 开启定时器
|
||||
// // jackpotList = JackpotListMgrSington.GetJackpotList(gameid)
|
||||
// //}
|
||||
// pack := JackpotListMgrSington.GetStoCMsg(jackpotList)
|
||||
// pack.GameId = msg.GetGameId()
|
||||
// logger.Logger.Infof("World BigWinHistory: %v %v", gameid, pack)
|
||||
// p.SendToClient(int(gamehall.HundredScenePacketID_PACKET_SC_GAMEBIGWINHISTORY), pack)
|
||||
// case GAME_HISTORY_MODEL:
|
||||
// task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
// var genGameHistoryInfo = func(gameNumber string, createdTime, multiple int64, hash string, gamehistory *gamehall.GameHistoryInfo) {
|
||||
// gamehistory.GameNumber = proto.String(gameNumber)
|
||||
// gamehistory.CreatedTime = proto.Int64(createdTime)
|
||||
// gamehistory.Hash = proto.String(hash)
|
||||
// gamehistory.Multiple = proto.Int64(multiple)
|
||||
// }
|
||||
//
|
||||
// gls := model.GetAllGameDetailedLogsByGameIdAndTs(p.Platform, gameid, 20)
|
||||
//
|
||||
// pack := &gamehall.SCPlayerHistory{}
|
||||
// for _, v := range gls {
|
||||
//
|
||||
// gamehistory := &gamehall.GameHistoryInfo{}
|
||||
//
|
||||
// data, err := model.UnMarshalGameNoteByHUNDRED(v.GameDetailedNote)
|
||||
// if err != nil {
|
||||
// logger.Logger.Errorf("World UnMarshalAvengersGameNote error:%v", err)
|
||||
// }
|
||||
// jsonString, _ := json.Marshal(data)
|
||||
//
|
||||
// // convert json to struct
|
||||
// gnd := model.CrashType{}
|
||||
// json.Unmarshal(jsonString, &gnd)
|
||||
//
|
||||
// genGameHistoryInfo(v.LogId, int64(v.Ts), int64(gnd.Rate), gnd.Hash, gamehistory)
|
||||
// pack.GameHistory = append(pack.GameHistory, gamehistory)
|
||||
// }
|
||||
// proto.SetDefaults(pack)
|
||||
// logger.Logger.Infof("World gameid:%v History:%v ", gameid, pack)
|
||||
// return pack
|
||||
// }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
|
||||
// if data == nil {
|
||||
// tNode.TransRep.RetFiels = data
|
||||
// tNode.Resume()
|
||||
// }
|
||||
// }), "CSGetGameHistoryHandlerWorld").Start()
|
||||
// default:
|
||||
// logger.Logger.Errorf("World CSHundredSceneGetGameHistoryInfoHandler receive historyModel(%v) error", historyModel)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return common.ResponseTag_TransactYield, pack
|
||||
// }))
|
||||
|
||||
//API用户加减币
|
||||
WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Game/QPAPIAddSubCoinById", WebAPIHandlerWrapper(
|
||||
func(tNode *transact.TransNode, params []byte) (int, proto.Message) {
|
||||
|
@ -2123,42 +1516,6 @@ func init() {
|
|||
return common.ResponseTag_Ok, pack
|
||||
}))
|
||||
|
||||
// 水池开关
|
||||
//WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Game/GamePoolSwitch", WebAPIHandlerWrapper(
|
||||
// func(tNode *transact.TransNode, params []byte) (int, proto.Message) {
|
||||
// pack := &webapi_proto.SAGamePoolSwitch{}
|
||||
// msg := &webapi_proto.ASGamePoolSwitch{}
|
||||
// err := proto.Unmarshal(params, msg)
|
||||
// if err != nil {
|
||||
// pack.Tag = webapi_proto.TagCode_FAILED
|
||||
// pack.Msg = "数据序列化失败" + err.Error()
|
||||
// return common.ResponseTag_ParamError, pack
|
||||
// }
|
||||
// if msg.GameFreeId == 0 {
|
||||
// pack.Tag = webapi_proto.TagCode_FAILED
|
||||
// pack.Msg = "GameFreeId id zero"
|
||||
// return common.ResponseTag_ParamError, pack
|
||||
// }
|
||||
// gs := GameSessMgrSington.GetGameSess(int(msg.ServerId))
|
||||
// if gs != nil {
|
||||
// msg := &server.WGGamePoolSwitch{
|
||||
// Platform: msg.GetPlatform(),
|
||||
// GameFreeId: msg.GetGameFreeId(),
|
||||
// ServerId: msg.GetServerId(),
|
||||
// GroupId: msg.GetGroupId(),
|
||||
// Switch: msg.GetSwitch(),
|
||||
// }
|
||||
// gs.Send(int(server.SSPacketID_PACKET_WG_GAMEPOOLSWITCH), msg)
|
||||
// } else {
|
||||
// pack.Tag = webapi_proto.TagCode_FAILED
|
||||
// pack.Msg = "no find srvId"
|
||||
// return common.ResponseTag_ParamError, pack
|
||||
// }
|
||||
// pack.Tag = webapi_proto.TagCode_SUCCESS
|
||||
// pack.Msg = "switch game pool success"
|
||||
// return common.ResponseTag_Ok, pack
|
||||
// }))
|
||||
|
||||
//更新水池
|
||||
// 修改本地缓存,修改数据库,同步到gamesrv
|
||||
WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Game/UpdateGamePool", WebAPIHandlerWrapper(
|
||||
|
@ -2253,23 +1610,6 @@ func init() {
|
|||
return common.ResponseTag_TransactYield, nil
|
||||
}))
|
||||
|
||||
//查询水池
|
||||
//WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Game/QueryAllGamePool", WebAPIHandlerWrapper(
|
||||
// func(tNode *transact.TransNode, params []byte) (int, proto.Message) {
|
||||
// pack := &webapi_proto.SAQueryAllGamePool{}
|
||||
// msg := &webapi_proto.ASQueryAllGamePool{}
|
||||
// err := proto.Unmarshal(params, msg)
|
||||
// if err != nil {
|
||||
// pack.Tag = webapi_proto.TagCode_FAILED
|
||||
// pack.Msg = "数据序列化失败" + err.Error()
|
||||
// return common.ResponseTag_ParamError, pack
|
||||
// }
|
||||
// pageNo := msg.GetPageNo()
|
||||
// pageSize := msg.GetPageSize()
|
||||
// StartQueryCoinPoolStatesTransact(tNode, int32(pageNo), int32(pageSize))
|
||||
// return common.ResponseTag_TransactYield, nil
|
||||
// }))
|
||||
//////////////////////////房间//////////////////////////
|
||||
WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Cache/GetRoom", WebAPIHandlerWrapper(
|
||||
func(tNode *transact.TransNode, params []byte) (int, proto.Message) {
|
||||
pack := &webapiproto.SAGetRoom{}
|
||||
|
@ -4026,7 +3366,7 @@ func init() {
|
|||
return common.ResponseTag_ParamError, pack
|
||||
}
|
||||
//cdata := ShopMgrSington.GetExchangeData(msg.GoodsId)
|
||||
item := srvdata.GameItemMgr.Get(platform, VCard)
|
||||
item := srvdata.GameItemMgr.Get(platform, common.ItemIDVCard)
|
||||
if item == nil {
|
||||
pack.Tag = webapiproto.TagCode_FAILED
|
||||
pack.Msg = "item is nil"
|
||||
|
@ -4037,11 +3377,11 @@ func init() {
|
|||
var items []*Item
|
||||
//V卡
|
||||
if addvcoin > 0 {
|
||||
items = append(items, &Item{ItemId: VCard, ItemNum: int64(addvcoin)})
|
||||
items = append(items, &Item{ItemId: common.ItemIDVCard, ItemNum: int64(addvcoin)})
|
||||
}
|
||||
//金券
|
||||
if jPrice > 0 {
|
||||
items = append(items, &Item{ItemId: JCard, ItemNum: int64(jPrice)})
|
||||
items = append(items, &Item{ItemId: common.ItemIDJCard, ItemNum: int64(jPrice)})
|
||||
}
|
||||
remark := fmt.Sprintf("兑换撤单 %v-%v", msg.GoodsId, msg.Name)
|
||||
if player != nil {
|
||||
|
@ -4104,6 +3444,7 @@ func init() {
|
|||
player.AddDiamond(int64(info.Amount[1]), 0, info.GainWay, "Callback", info.Remark)
|
||||
}
|
||||
player.AddMoneyPayTotal(int64(info.ConsumeNum))
|
||||
player.MoneyTotal += int64(info.ConsumeNum)
|
||||
player.dirty = true
|
||||
player.SendDiffData()
|
||||
info.Amount[2] = player.GetVIPExpByPay(info.ConsumeNum)
|
||||
|
@ -4423,7 +3764,6 @@ func init() {
|
|||
}
|
||||
tNode.TransRep.RetFiels = pack
|
||||
tNode.Resume()
|
||||
|
||||
})
|
||||
return common.ResponseTag_TransactYield, pack
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue