diff --git a/common/transtype.go b/common/transtype.go index a9f849c..8746e88 100644 --- a/common/transtype.go +++ b/common/transtype.go @@ -22,6 +22,7 @@ const ( TransType_MatchSceneChange = 1013 TransType_MiniGameAddCoin = 1014 TransType_ServerCtrl = 1015 + TranType_AddItem = 1016 // 道具修改 ) type M2GWebTrascate struct { diff --git a/worldsrv/action_player.go b/worldsrv/action_player.go index 6d45f9a..dfa25ad 100644 --- a/worldsrv/action_player.go +++ b/worldsrv/action_player.go @@ -1691,15 +1691,15 @@ func (this *CSPlayerVIPBuyPacketFactory) CreatePacket() interface{} { func (this *CSPlayerVIPBuyHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error { logger.Logger.Trace("CSVIPBuy Process recv ", data) - if msg, ok := data.(*player_proto.CSVIPBuy); ok { - p := PlayerMgrSington.GetPlayer(sid) - if p == nil { - logger.Logger.Warn("CSPlayerVIPBuyHandler p == nil") - return nil - } - - p.SCVIPBuy(int64(msg.GetMoney())) - } + //if msg, ok := data.(*player_proto.CSVIPBuy); ok { + // p := PlayerMgrSington.GetPlayer(sid) + // if p == nil { + // logger.Logger.Warn("CSPlayerVIPBuyHandler p == nil") + // return nil + // } + // + // p.SCVIPBuy(int64(msg.GetMoney())) + //} return nil } @@ -1723,7 +1723,6 @@ func (this *CSPlayerVIPInfoHandler) Process(s *netlib.Session, packetid int, dat return nil } p.GetVIPLevel() - p.SCVIPInfo() } return nil } diff --git a/worldsrv/player.go b/worldsrv/player.go index 3b612ee..4363cad 100644 --- a/worldsrv/player.go +++ b/worldsrv/player.go @@ -34,7 +34,6 @@ import ( "mongo.games.com/game/protocol/rankmatch" serverproto "mongo.games.com/game/protocol/server" shopproto "mongo.games.com/game/protocol/shop" - webapiproto "mongo.games.com/game/protocol/webapi" "mongo.games.com/game/srvdata" "mongo.games.com/game/worldsrv/internal" ) @@ -1110,9 +1109,8 @@ func (this *Player) GetMessageAttach(id string) { } return gift }), task.CompleteNotifyWrapper(func(data interface{}, tt task.Task) { - attach_msg, ok := data.(*model.Message) - dirtyCoin := int64(0) - if ok && attach_msg != nil { + attachMsg, ok := data.(*model.Message) + if ok && attachMsg != nil { msg.AttachState = model.MSGATTACHSTATE_GOT notifyClient := true var remark string @@ -1157,29 +1155,24 @@ func (this *Player) GetMessageAttach(id string) { case model.MSGTYPE_ITEM: remark = "领取道具" gainWay = common.GainWay_MAIL_MTEM - dirtyCoin = msg.Coin addItem() case model.MSGTYPE_IOSINSTALLSTABLE: remark = "IOS下载稳定版本" gainWay = common.GainWay_IOSINSTALLSTABLE - dirtyCoin = msg.Coin case model.MSGTYPE_GIFT: remark = "礼物" case model.MSGTYPE_GOLDCOMERANK: remark = "财神降临奖励" gainWay = common.GainWay_GoldCome notifyClient = false - dirtyCoin = msg.Coin case model.MSGTYPE_RANDCOIN: remark = "红包雨" gainWay = common.GainWay_OnlineRandCoin notifyClient = false - dirtyCoin = msg.Coin case model.MSGTYPE_REBATE: remark = "流水返利" gainWay = common.GainWay_RebateTask notifyClient = false - dirtyCoin = msg.Coin //邮件领取 添加日志 task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { return model.InsertRebateLog(this.Platform, &model.Rebate{ @@ -1227,8 +1220,6 @@ func (this *Player) GetMessageAttach(id string) { } if msg.Coin > 0 { this.AddCoin(msg.Coin, 0, gainWay, msg.Id.Hex(), remark) - //增加泥码 - this.AddDirtyCoin(0, dirtyCoin) //俱乐部获取不算系统赠送 if msg.MType != model.MSGTYPE_ClubGet { this.ReportSystemGiveEvent(int32(msg.Coin), gainWay, notifyClient) //邮件附件算是系统赠送 @@ -1891,45 +1882,6 @@ func (this *Player) AddCoinAsync(num, add int64, gainWay int32, oper, remark str // } //} -// 增加泥码 -func (this *Player) AddDirtyCoin(paycoin, givecoin int64) { - if this.IsRob { - return - } - - //if cfg, ok := ProfitControlMgrSington.GetCfg(this.Platform); ok && cfg != nil && paycoin >= 0 { - // //洗码折算率=(玩家剩余泥码*洗码折算率+期望营收)/(充值额+赠送额+泥码余额) - // this.RecalcuWashingCoinConvRate(cfg.Rate, paycoin, givecoin) - //} - // - //this.DirtyCoin += paycoin + givecoin - //if this.DirtyCoin < 0 { - // this.DirtyCoin = 0 - //} - this.dirty = true -} - -// 洗码 -func (this *Player) WashingCoin(coin int64) int64 { - if this.IsRob { - return 0 - } - if coin <= 0 { - return 0 - } - - //if this.DirtyCoin > coin { - // this.DirtyCoin -= coin - // this.dirty = true - // return coin - //} - // - ////剩余多少泥码,清洗多少 - //coin = this.DirtyCoin - //this.DirtyCoin = 0 - return coin -} - func (this *Player) AddTicket(num int64, gainWay int32, oper, remark string) { if num == 0 { return @@ -3497,17 +3449,17 @@ func (this *Player) SendShowRed(showType hallproto.ShowRedCode, showChild, isSho this.SendToClient(int(hallproto.HallPacketID_PACKET_SC_SHOWRED), pack) } -func (this *Player) SCVIPBuy(buy int64) { - //buy *= 10000 - //this.AddMoneyPayTotal(buy) - //this.GetVIPLevel(0) // 更新下vip等级 - pack := &playerproto.SCVIPBuy{ - OpRetCode: playerproto.OpResultCode_OPRC_Sucess, - } - pack.TolVipExp, pack.Money = this.GetCurrentVIPExp() // 获取经验会更新vip等级 - pack.Vip = this.VIP - this.SendToClient(int(playerproto.PlayerPacketID_PACKET_SC_VIPBUY), pack) -} +//func (this *Player) SCVIPBuy(buy int64) { +// //buy *= 10000 +// //this.AddMoneyPayTotal(buy) +// //this.GetVIPLevel(0) // 更新下vip等级 +// pack := &playerproto.SCVIPBuy{ +// OpRetCode: playerproto.OpResultCode_OPRC_Sucess, +// } +// pack.TolVipExp, pack.Money = this.GetCurrentVIPExp() // 获取经验会更新vip等级 +// pack.Vip = this.VIP +// this.SendToClient(int(playerproto.PlayerPacketID_PACKET_SC_VIPBUY), pack) +//} func (this *Player) SCVIPInfo() { if this.IsRob { @@ -3581,7 +3533,7 @@ func (this *Player) SCVIPInfo() { pack.List = append(pack.List, data) } - pack.TolVipExp, pack.Money = this.GetCurrentVIPExp(vips) + pack.TolVipExp, pack.Money = this.GetCurrentVIPExp() pack.Vip = this.VIP pack.OpRetCode = playerproto.OpResultCode_OPRC_Sucess } @@ -3710,17 +3662,12 @@ func (this *Player) VIPDraw(id, vip int32) { // GetCurrentVIPExp 更新vip等级 // 返回当前经验和升级需要经验 -func (this *Player) GetCurrentVIPExp(vipcfg ...*webapiproto.VIPcfgDataList) (exp int64, money int64) { - var vips *webapiproto.VIPcfgDataList - if len(vipcfg) == 0 { - vips = VipMgrSington.GetVIPcfg(this.Platform) - } else { - vips = vipcfg[0] - } +func (this *Player) GetCurrentVIPExp() (exp int64, money int64) { + vips := VipMgrSington.GetVIPcfg(this.Platform) exp = int64(float64(this.MoneyPayTotal) * vips.MoneyRatio) tolexp := int32(0) oldVipLevel := this.VIP - if vips != nil && this.MoneyPayTotal != 0 { + if this.MoneyPayTotal != 0 { allExp := int64(float64(this.MoneyPayTotal) * vips.MoneyRatio) for _, v := range vips.List { tolexp = v.VipEx @@ -3737,10 +3684,7 @@ func (this *Player) GetCurrentVIPExp(vipcfg ...*webapiproto.VIPcfgDataList) (exp money = 0 } if oldVipLevel != this.VIP { - //玩家VIP升级 - this.SCVIPInfo() - PetMgrSington.CheckSkinRed(this) - logger.Logger.Trace("VIP升级!") + this.GetVIPLevel() } return // 默认 } @@ -3763,15 +3707,16 @@ func (this *Player) GetVIPLevel() int32 { } } } + var b bool if vip != this.VIP { this.dirty = true b = true - //玩家VIP升级 - this.SCVIPInfo() logger.Logger.Trace("VIP升级!") } this.VIP = vip + //玩家VIP升级 + this.SCVIPInfo() if b { PetMgrSington.CheckSkinRed(this) } diff --git a/worldsrv/trascate_webapi.go b/worldsrv/trascate_webapi.go index 2cf5e48..73a2dc5 100644 --- a/worldsrv/trascate_webapi.go +++ b/worldsrv/trascate_webapi.go @@ -175,322 +175,322 @@ func (this *WebAPIHandlerMgr) GetWebAPIHandler(name string) WebAPIHandler { func init() { //API用户加减币 - WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Game/QPAPIAddSubCoinById", WebAPIHandlerWrapper( - func(tNode *transact.TransNode, params []byte) (int, proto.Message) { - pack := &qpapi.SAAddCoinById{} - msg := &qpapi.ASAddCoinById{} - err1 := proto.Unmarshal(params, msg) - if err1 != nil { - pack.Tag = qpapi.TagCode_FAILED - pack.Msg = "数据序列化失败" + err1.Error() - return common.ResponseTag_ParamError, pack - } - - username := msg.GetUsername() - coin := msg.GetGold() - billNo := int(msg.GetBillNo()) - platform := msg.GetMerchantTag() - curplatform := PlatformMgrSingleton.GetPlatform(platform) - - if curplatform == nil { - pack.Tag = qpapi.TagCode_FAILED - pack.Msg = "没有对应的平台" - return common.ResponseTag_ParamError, pack - } - merchantkey := curplatform.MerchantKey - - sign := msg.GetSign() - - raw := fmt.Sprintf("%v%v%v%v%v%v", username, coin, billNo, platform, merchantkey, msg.GetTs()) - h := md5.New() - io.WriteString(h, raw) - newsign := hex.EncodeToString(h.Sum(nil)) - - if newsign != sign { - pack.Tag = qpapi.TagCode_FAILED - pack.Msg = "商户验签失败" - return common.ResponseTag_ParamError, pack - } - - if CacheDataMgr.CacheBillCheck(billNo, platform) { - pack.Tag = qpapi.TagCode_FAILED - pack.Msg = "Bill number repeated!" - return common.ResponseTag_ParamError, pack - } - CacheDataMgr.CacheBillNumber(billNo, platform) //防止手抖点两下 - - var err error - var pd *model.PlayerData - oldGold := int64(0) - var timeStamp = time.Now().UnixNano() - acc, accerr := model.GetAccountByName(platform, username) - if accerr != nil { - CacheDataMgr.ClearCacheBill(billNo, platform) - pack.Tag = qpapi.TagCode_FAILED - pack.Msg = accerr.Error() - return common.ResponseTag_ParamError, pack - } - member_snid := acc.SnId - player := PlayerMgrSington.GetPlayerBySnId(int32(member_snid)) - if player != nil { //在线玩家处理 - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - if player.scene != nil && coin < 0 { - //player.Kickout(common.KickReason_CheckCodeErr) - - leavemsg := &server.WGPlayerLeave{ - SnId: proto.Int32(player.SnId), - } - proto.SetDefaults(leavemsg) - player.SendToGame(int(server.SSPacketID_PACKET_WG_PlayerLEAVE), leavemsg) - - select { - case <-player.leavechan: - case <-time.After(time.Second * 1): - } - - } - //player = PlayerMgrSington.GetPlayerBySnId(int32(member_snid)) - if player.scene != nil { - CacheDataMgr.ClearCacheBill(billNo, platform) - //pack.Tag = qpapi.TagCode_FAILED - //pack.Msg = "Unsupported!!! because player in scene!" - //return common.ResponseTag_ParamError, pack - return errors.New("Unsupported!!! because player in scene!") - } - pd = player.PlayerData - if len(platform) > 0 && player.Platform != platform { - CacheDataMgr.ClearCacheBill(billNo, platform) - //pack.Tag = qpapi.TagCode_FAILED - //pack.Msg = "player platform forbit!" - //return common.ResponseTag_ParamError, pack - return errors.New("player platform forbit!") - } - - opcode := int32(common.GainWay_Api_In) - - if coin < 0 { - opcode = int32(common.GainWay_Api_Out) - if player.Coin+coin < 0 { - CacheDataMgr.ClearCacheBill(billNo, platform) - //pack.Tag = qpapi.TagCode_FAILED - //pack.Msg = "coin not enough!" - //return common.ResponseTag_ParamError, pack - return errors.New("coin not enough!") - } - } - - //if logType != 0 { - // opcode = logType - //} - - oldGold = player.Coin - coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode, - "qpsystem", model.PayCoinLogType_Coin, 0) - timeStamp = coinLog.TimeStamp - //增加帐变记录 - coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ - Platform: pd.Platform, - SnID: member_snid, - Channel: pd.Channel, - ChangeType: common.BillTypeCoin, - ChangeNum: coin, - RemainNum: oldGold + coin, - Add: 0, - LogType: opcode, - GameID: 0, - GameFreeID: 0, - BaseCoin: 0, - Operator: "oper", - Remark: "online", - }) - - err = model.InsertPayCoinLogs(platform, coinLog) - if err != nil { - logger.Logger.Errorf("model.InsertPayCoinLogs err:%v log:%v", err, coinLog) - return err - } - err = model.InsertCoinLog(coinlogex) - if err != nil { - //回滚到对账日志 - model.RemovePayCoinLog(platform, coinLog.LogId) - logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) - return err - } - return err - }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { - CacheDataMgr.ClearCacheBill(billNo, platform) - if data != nil { - pack.Tag = qpapi.TagCode_FAILED - pack.Msg = data.(error).Error() - } else { - //player.Coin += coin + coinEx - player.AddCoinAsync(coin, 0, common.GainWay_Api_In, "oper", "Async", true, 0, false) - //增加相应的泥码量 - player.AddDirtyCoin(coin, 0) - player.SetPayTs(timeStamp) - - if player.TodayGameData == nil { - player.TodayGameData = model.NewPlayerGameCtrlData() - } - //actRandCoinMgr.OnPlayerRecharge(player, coin) - /* - if isAccTodayRecharge { - - player.AddCoinPayTotal(coin) - player.TodayGameData.RechargeCoin += coin //累加当天充值金额 - if coin >= 0 { - plt := PlatformMgrSingleton.GetPlatform(pd.Platform) - curVer := int32(0) - if plt != nil { - curVer = plt.ExchangeVer - } - log := model.NewCoinGiveLogEx(pd.SnId, pd.Name, coin, 0, 0, opcode, pd.PromoterTree, - model.COINGIVETYPE_PAY, curVer, pd.Platform, pd.Channel, pd.BeUnderAgentCode, - "", "system", pd.PackageID, int32(needFlowRate), int32(needGiveFlowRate)) - if log != nil { - err := model.InsertGiveCoinLog(log) - if err == nil { - if pd.LastExchangeOrder != "" && pd.TotalConvertibleFlow > 0 { - err = model.UpdateGiveCoinLastFlow(platform, pd.LastExchangeOrder, pd.TotalConvertibleFlow) - } - } - //清空流水,更新id - pd.TotalConvertibleFlow = 0 - pd.LastExchangeOrder = log.LogId.Hex() - if player == nil { - //需要回写数据库 - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - model.UpdatePlayerExchageFlowAndOrder(platform, member_snid, 0, pd.LastExchangeOrder) - return nil - }), nil, "UpdateGiveCoinLogs").StartByExecutor(pd.AccountId) - } - } - } - } - */ - player.dirty = true - player.Time2Save() - if player.scene == nil { //如果在大厅,那么同步下金币 - player.SendDiffData() - } - player.SendPlayerRechargeAnswer(coin) - pack.Tag = qpapi.TagCode_SUCCESS - pack.Msg = "" - } - tNode.TransRep.RetFiels = pack - tNode.Resume() - if err != nil { - logger.Logger.Error("AddSubCoinById task marshal data error:", err) - } - }), "APIAddSubCoinById").Start() - return common.ResponseTag_TransactYield, pack - } else { - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - pd, _ = model.GetPlayerDataBySnId(platform, int32(member_snid), false, true) - if pd == nil { - return errors.New("Player not find.") - } - if len(platform) > 0 && pd.Platform != platform { - return errors.New("player platform forbit.") - } - oldGold = pd.Coin - opcode := int32(common.GainWay_Api_In) - if coin < 0 { - opcode = int32(common.GainWay_Api_Out) - if pd.Coin+coin < 0 { - return errors.New("coin not enough!") - } - } - - //if logType != 0 { - // opcode = logType - //} - coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode, - "not online", model.PayCoinLogType_Coin, 0) - timeStamp = coinLog.TimeStamp - err = model.InsertPayCoinLogs(platform, coinLog) - if err != nil { - logger.Logger.Errorf("model.InsertPayCoinLogs err:%v log:%v", err, coinLog) - return err - } - //增加帐变记录 - coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ - Platform: pd.Platform, - SnID: member_snid, - Channel: pd.Channel, - ChangeType: common.BillTypeCoin, - ChangeNum: coin, - RemainNum: oldGold + coin, - Add: 0, - LogType: opcode, - GameID: 0, - GameFreeID: 0, - BaseCoin: 0, - Operator: "oper", - Remark: "not online", - }) - err = model.InsertCoinLog(coinlogex) - if err != nil { - //回滚到对账日志 - model.RemovePayCoinLog(platform, coinLog.LogId) - logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) - return err - } - return err - }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { - CacheDataMgr.ClearCacheBill(billNo, platform) - if data != nil { - pack.Tag = qpapi.TagCode_FAILED - pack.Msg = data.(error).Error() - } else { - pack.Tag = qpapi.TagCode_SUCCESS - pack.Msg = "" - /* - if isAccTodayRecharge && coin >= 0 { - OnPlayerPay(pd, coin) - } - if isAccTodayRecharge && coin >= 0 && coinEx >= 0 { - - plt := PlatformMgrSingleton.GetPlatform(pd.Platform) - curVer := int32(0) - if plt != nil { - curVer = plt.ExchangeVer - } - log := model.NewCoinGiveLogEx(pd.SnId, pd.Name, coin, coinEx, 0, common.GainWay_Api_In, pd.PromoterTree, - model.COINGIVETYPE_PAY, curVer, pd.Platform, pd.Channel, pd.BeUnderAgentCode, - "", "system", pd.PackageID, int32(needFlowRate), int32(needGiveFlowRate)) - if log != nil { - err := model.InsertGiveCoinLog(log) - if err == nil { - if pd.LastExchangeOrder != "" && pd.TotalConvertibleFlow > 0 { - err = model.UpdateGiveCoinLastFlow(platform, pd.LastExchangeOrder, pd.TotalConvertibleFlow) - } - } - //清空流水,更新id - pd.TotalConvertibleFlow = 0 - pd.LastExchangeOrder = log.LogId.Hex() - if player == nil { - //需要回写数据库 - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - model.UpdatePlayerExchageFlowAndOrder(platform, int32(member_snid), 0, pd.LastExchangeOrder) - return nil - }), nil, "UpdateGiveCoinLogs").StartByExecutor(pd.AccountId) - } - } - - } - */ - } - - tNode.TransRep.RetFiels = pack - tNode.Resume() - if err != nil { - logger.Logger.Error("AddSubCoinById task marshal data error:", err) - } - }), "APIAddSubCoinById").Start() - return common.ResponseTag_TransactYield, pack - } - })) + //WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Game/QPAPIAddSubCoinById", WebAPIHandlerWrapper( + // func(tNode *transact.TransNode, params []byte) (int, proto.Message) { + // pack := &qpapi.SAAddCoinById{} + // msg := &qpapi.ASAddCoinById{} + // err1 := proto.Unmarshal(params, msg) + // if err1 != nil { + // pack.Tag = qpapi.TagCode_FAILED + // pack.Msg = "数据序列化失败" + err1.Error() + // return common.ResponseTag_ParamError, pack + // } + // + // username := msg.GetUsername() + // coin := msg.GetGold() + // billNo := int(msg.GetBillNo()) + // platform := msg.GetMerchantTag() + // curplatform := PlatformMgrSingleton.GetPlatform(platform) + // + // if curplatform == nil { + // pack.Tag = qpapi.TagCode_FAILED + // pack.Msg = "没有对应的平台" + // return common.ResponseTag_ParamError, pack + // } + // merchantkey := curplatform.MerchantKey + // + // sign := msg.GetSign() + // + // raw := fmt.Sprintf("%v%v%v%v%v%v", username, coin, billNo, platform, merchantkey, msg.GetTs()) + // h := md5.New() + // io.WriteString(h, raw) + // newsign := hex.EncodeToString(h.Sum(nil)) + // + // if newsign != sign { + // pack.Tag = qpapi.TagCode_FAILED + // pack.Msg = "商户验签失败" + // return common.ResponseTag_ParamError, pack + // } + // + // if CacheDataMgr.CacheBillCheck(billNo, platform) { + // pack.Tag = qpapi.TagCode_FAILED + // pack.Msg = "Bill number repeated!" + // return common.ResponseTag_ParamError, pack + // } + // CacheDataMgr.CacheBillNumber(billNo, platform) //防止手抖点两下 + // + // var err error + // var pd *model.PlayerData + // oldGold := int64(0) + // var timeStamp = time.Now().UnixNano() + // acc, accerr := model.GetAccountByName(platform, username) + // if accerr != nil { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // pack.Tag = qpapi.TagCode_FAILED + // pack.Msg = accerr.Error() + // return common.ResponseTag_ParamError, pack + // } + // member_snid := acc.SnId + // player := PlayerMgrSington.GetPlayerBySnId(int32(member_snid)) + // if player != nil { //在线玩家处理 + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // if player.scene != nil && coin < 0 { + // //player.Kickout(common.KickReason_CheckCodeErr) + // + // leavemsg := &server.WGPlayerLeave{ + // SnId: proto.Int32(player.SnId), + // } + // proto.SetDefaults(leavemsg) + // player.SendToGame(int(server.SSPacketID_PACKET_WG_PlayerLEAVE), leavemsg) + // + // select { + // case <-player.leavechan: + // case <-time.After(time.Second * 1): + // } + // + // } + // //player = PlayerMgrSington.GetPlayerBySnId(int32(member_snid)) + // if player.scene != nil { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // //pack.Tag = qpapi.TagCode_FAILED + // //pack.Msg = "Unsupported!!! because player in scene!" + // //return common.ResponseTag_ParamError, pack + // return errors.New("Unsupported!!! because player in scene!") + // } + // pd = player.PlayerData + // if len(platform) > 0 && player.Platform != platform { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // //pack.Tag = qpapi.TagCode_FAILED + // //pack.Msg = "player platform forbit!" + // //return common.ResponseTag_ParamError, pack + // return errors.New("player platform forbit!") + // } + // + // opcode := int32(common.GainWay_Api_In) + // + // if coin < 0 { + // opcode = int32(common.GainWay_Api_Out) + // if player.Coin+coin < 0 { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // //pack.Tag = qpapi.TagCode_FAILED + // //pack.Msg = "coin not enough!" + // //return common.ResponseTag_ParamError, pack + // return errors.New("coin not enough!") + // } + // } + // + // //if logType != 0 { + // // opcode = logType + // //} + // + // oldGold = player.Coin + // coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode, + // "qpsystem", model.PayCoinLogType_Coin, 0) + // timeStamp = coinLog.TimeStamp + // //增加帐变记录 + // coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ + // Platform: pd.Platform, + // SnID: member_snid, + // Channel: pd.Channel, + // ChangeType: common.BillTypeCoin, + // ChangeNum: coin, + // RemainNum: oldGold + coin, + // Add: 0, + // LogType: opcode, + // GameID: 0, + // GameFreeID: 0, + // BaseCoin: 0, + // Operator: "oper", + // Remark: "online", + // }) + // + // err = model.InsertPayCoinLogs(platform, coinLog) + // if err != nil { + // logger.Logger.Errorf("model.InsertPayCoinLogs err:%v log:%v", err, coinLog) + // return err + // } + // err = model.InsertCoinLog(coinlogex) + // if err != nil { + // //回滚到对账日志 + // model.RemovePayCoinLog(platform, coinLog.LogId) + // logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) + // return err + // } + // return err + // }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // if data != nil { + // pack.Tag = qpapi.TagCode_FAILED + // pack.Msg = data.(error).Error() + // } else { + // //player.Coin += coin + coinEx + // player.AddCoinAsync(coin, 0, common.GainWay_Api_In, "oper", "Async", true, 0, false) + // //增加相应的泥码量 + // player.AddDirtyCoin(coin, 0) + // player.SetPayTs(timeStamp) + // + // if player.TodayGameData == nil { + // player.TodayGameData = model.NewPlayerGameCtrlData() + // } + // //actRandCoinMgr.OnPlayerRecharge(player, coin) + // /* + // if isAccTodayRecharge { + // + // player.AddCoinPayTotal(coin) + // player.TodayGameData.RechargeCoin += coin //累加当天充值金额 + // if coin >= 0 { + // plt := PlatformMgrSingleton.GetPlatform(pd.Platform) + // curVer := int32(0) + // if plt != nil { + // curVer = plt.ExchangeVer + // } + // log := model.NewCoinGiveLogEx(pd.SnId, pd.Name, coin, 0, 0, opcode, pd.PromoterTree, + // model.COINGIVETYPE_PAY, curVer, pd.Platform, pd.Channel, pd.BeUnderAgentCode, + // "", "system", pd.PackageID, int32(needFlowRate), int32(needGiveFlowRate)) + // if log != nil { + // err := model.InsertGiveCoinLog(log) + // if err == nil { + // if pd.LastExchangeOrder != "" && pd.TotalConvertibleFlow > 0 { + // err = model.UpdateGiveCoinLastFlow(platform, pd.LastExchangeOrder, pd.TotalConvertibleFlow) + // } + // } + // //清空流水,更新id + // pd.TotalConvertibleFlow = 0 + // pd.LastExchangeOrder = log.LogId.Hex() + // if player == nil { + // //需要回写数据库 + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // model.UpdatePlayerExchageFlowAndOrder(platform, member_snid, 0, pd.LastExchangeOrder) + // return nil + // }), nil, "UpdateGiveCoinLogs").StartByExecutor(pd.AccountId) + // } + // } + // } + // } + // */ + // player.dirty = true + // player.Time2Save() + // if player.scene == nil { //如果在大厅,那么同步下金币 + // player.SendDiffData() + // } + // player.SendPlayerRechargeAnswer(coin) + // pack.Tag = qpapi.TagCode_SUCCESS + // pack.Msg = "" + // } + // tNode.TransRep.RetFiels = pack + // tNode.Resume() + // if err != nil { + // logger.Logger.Error("AddSubCoinById task marshal data error:", err) + // } + // }), "APIAddSubCoinById").Start() + // return common.ResponseTag_TransactYield, pack + // } else { + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // pd, _ = model.GetPlayerDataBySnId(platform, int32(member_snid), false, true) + // if pd == nil { + // return errors.New("Player not find.") + // } + // if len(platform) > 0 && pd.Platform != platform { + // return errors.New("player platform forbit.") + // } + // oldGold = pd.Coin + // opcode := int32(common.GainWay_Api_In) + // if coin < 0 { + // opcode = int32(common.GainWay_Api_Out) + // if pd.Coin+coin < 0 { + // return errors.New("coin not enough!") + // } + // } + // + // //if logType != 0 { + // // opcode = logType + // //} + // coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode, + // "not online", model.PayCoinLogType_Coin, 0) + // timeStamp = coinLog.TimeStamp + // err = model.InsertPayCoinLogs(platform, coinLog) + // if err != nil { + // logger.Logger.Errorf("model.InsertPayCoinLogs err:%v log:%v", err, coinLog) + // return err + // } + // //增加帐变记录 + // coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ + // Platform: pd.Platform, + // SnID: member_snid, + // Channel: pd.Channel, + // ChangeType: common.BillTypeCoin, + // ChangeNum: coin, + // RemainNum: oldGold + coin, + // Add: 0, + // LogType: opcode, + // GameID: 0, + // GameFreeID: 0, + // BaseCoin: 0, + // Operator: "oper", + // Remark: "not online", + // }) + // err = model.InsertCoinLog(coinlogex) + // if err != nil { + // //回滚到对账日志 + // model.RemovePayCoinLog(platform, coinLog.LogId) + // logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) + // return err + // } + // return err + // }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // if data != nil { + // pack.Tag = qpapi.TagCode_FAILED + // pack.Msg = data.(error).Error() + // } else { + // pack.Tag = qpapi.TagCode_SUCCESS + // pack.Msg = "" + // /* + // if isAccTodayRecharge && coin >= 0 { + // OnPlayerPay(pd, coin) + // } + // if isAccTodayRecharge && coin >= 0 && coinEx >= 0 { + // + // plt := PlatformMgrSingleton.GetPlatform(pd.Platform) + // curVer := int32(0) + // if plt != nil { + // curVer = plt.ExchangeVer + // } + // log := model.NewCoinGiveLogEx(pd.SnId, pd.Name, coin, coinEx, 0, common.GainWay_Api_In, pd.PromoterTree, + // model.COINGIVETYPE_PAY, curVer, pd.Platform, pd.Channel, pd.BeUnderAgentCode, + // "", "system", pd.PackageID, int32(needFlowRate), int32(needGiveFlowRate)) + // if log != nil { + // err := model.InsertGiveCoinLog(log) + // if err == nil { + // if pd.LastExchangeOrder != "" && pd.TotalConvertibleFlow > 0 { + // err = model.UpdateGiveCoinLastFlow(platform, pd.LastExchangeOrder, pd.TotalConvertibleFlow) + // } + // } + // //清空流水,更新id + // pd.TotalConvertibleFlow = 0 + // pd.LastExchangeOrder = log.LogId.Hex() + // if player == nil { + // //需要回写数据库 + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // model.UpdatePlayerExchageFlowAndOrder(platform, int32(member_snid), 0, pd.LastExchangeOrder) + // return nil + // }), nil, "UpdateGiveCoinLogs").StartByExecutor(pd.AccountId) + // } + // } + // + // } + // */ + // } + // + // tNode.TransRep.RetFiels = pack + // tNode.Resume() + // if err != nil { + // logger.Logger.Error("AddSubCoinById task marshal data error:", err) + // } + // }), "APIAddSubCoinById").Start() + // return common.ResponseTag_TransactYield, pack + // } + // })) //获取用户金币数量 WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Member/QPGetMemberGoldById", WebAPIHandlerWrapper( @@ -1095,8 +1095,7 @@ func init() { player.UpdateShopID(msg.GetShopId()) } if money > 0 { - player.MoneyPayTotal += money - player.SCVIPInfo() + player.AddMoneyPayTotal(money) TaskSubjectSingleton.Touch(common.TaskTypePay, &TaskData{ SnId: player.SnId, Num: money, @@ -1209,275 +1208,275 @@ func init() { // //------------------------------------------------------------------------------------------------------- // //钱包操作接口 - WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Game/AddCoinById", WebAPIHandlerWrapper( - func(tNode *transact.TransNode, params []byte) (int, proto.Message) { - pack := &webapiproto.SAAddCoinById{} - msg := &webapiproto.ASAddCoinById{} - err1 := proto.Unmarshal(params, msg) - if err1 != nil { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "数据序列化失败" + err1.Error() - return common.ResponseTag_ParamError, pack - } - - member_snid := msg.GetID() - coin := msg.GetGold() - coinEx := msg.GetGoldEx() - oper := msg.GetOper() - gold_desc := msg.GetDesc() - billNo := int(msg.GetBillNo()) - platform := msg.GetPlatform() - logType := msg.GetLogType() - isAccTodayRecharge := msg.GetIsAccTodayRecharge() - needFlowRate := msg.GetNeedFlowRate() - needGiveFlowRate := msg.GetNeedGiveFlowRate() - - if CacheDataMgr.CacheBillCheck(billNo, platform) { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "Bill number repeated!" - return common.ResponseTag_ParamError, pack - } - CacheDataMgr.CacheBillNumber(billNo, platform) //防止手抖点两下 - - var err error - var pd *model.PlayerData - oldGold := int64(0) - var timeStamp = time.Now().UnixNano() - player := PlayerMgrSington.GetPlayerBySnId(int32(member_snid)) - if player != nil { //在线玩家处理 - if player.scene != nil { - CacheDataMgr.ClearCacheBill(billNo, platform) - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "Unsupported!!! because player in scene!" - return common.ResponseTag_ParamError, pack - } - pd = player.PlayerData - if len(platform) > 0 && player.Platform != platform { - CacheDataMgr.ClearCacheBill(billNo, platform) - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "player platform forbit!" - return common.ResponseTag_ParamError, pack - } - - if coin < 0 { - if player.Coin+coin < 0 { - CacheDataMgr.ClearCacheBill(billNo, platform) - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = "coin not enough!" - return common.ResponseTag_ParamError, pack - } - } - - opcode := int32(common.GainWay_API_AddCoin) - if logType != 0 { - opcode = logType - } - - oldGold = player.Coin - coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode, - gold_desc, model.PayCoinLogType_Coin, coinEx) - timeStamp = coinLog.TimeStamp - //增加帐变记录 - coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ - Platform: pd.Platform, - SnID: member_snid, - Channel: pd.Channel, - ChangeType: common.BillTypeCoin, - ChangeNum: coin + coinEx, - RemainNum: oldGold + coin + coinEx, - Add: 0, - LogType: opcode, - GameID: 0, - GameFreeID: 0, - BaseCoin: 0, - Operator: oper, - Remark: gold_desc, - }) - - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - err = model.InsertPayCoinLogs(platform, coinLog) - if err != nil { - logger.Logger.Errorf("model.InsertPayCoinLogs err:%v log:%v", err, coinLog) - return err - } - err = model.InsertCoinLog(coinlogex) - if err != nil { - //回滚到对账日志 - model.RemovePayCoinLog(platform, coinLog.LogId) - logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) - return err - } - return err - }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { - CacheDataMgr.ClearCacheBill(billNo, platform) - if data != nil { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = data.(error).Error() - } else { - //player.Coin += coin + coinEx - player.AddCoinAsync(coin+coinEx, 0, common.GainWay_API_AddCoin, oper, gold_desc, true, 0, false) - //增加相应的泥码量 - player.AddDirtyCoin(coin, coinEx) - player.SetPayTs(timeStamp) - - if player.TodayGameData == nil { - player.TodayGameData = model.NewPlayerGameCtrlData() - } - //actRandCoinMgr.OnPlayerRecharge(player, coin) - if isAccTodayRecharge { - - player.AddCoinPayTotal(coin) - player.TodayGameData.RechargeCoin += coin //累加当天充值金额 - if coin >= 0 && coinEx >= 0 { - plt := PlatformMgrSingleton.GetPlatform(pd.Platform) - curVer := int32(0) - if plt != nil { - curVer = plt.ExchangeVer - } - log := model.NewCoinGiveLogEx(pd.SnId, pd.Name, coin, coinEx, 0, opcode, pd.PromoterTree, - model.COINGIVETYPE_PAY, curVer, pd.Platform, pd.Channel, pd.BeUnderAgentCode, - "", "system", pd.PackageID, int32(needFlowRate), int32(needGiveFlowRate)) - if log != nil { - err := model.InsertGiveCoinLog(log) - if err == nil { - if pd.LastExchangeOrder != "" && pd.TotalConvertibleFlow > 0 { - err = model.UpdateGiveCoinLastFlow(platform, pd.LastExchangeOrder, pd.TotalConvertibleFlow) - } - } - //清空流水,更新id - pd.TotalConvertibleFlow = 0 - pd.LastExchangeOrder = log.LogId.Hex() - if player == nil { - //需要回写数据库 - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - model.UpdatePlayerExchageFlowAndOrder(platform, member_snid, 0, pd.LastExchangeOrder) - return nil - }), nil, "UpdateGiveCoinLogs").StartByExecutor(pd.AccountId) - } - } - } - } - - player.dirty = true - player.Time2Save() - if player.scene == nil { //如果在大厅,那么同步下金币 - player.SendDiffData() - } - player.SendPlayerRechargeAnswer(coin) - pack.Tag = webapiproto.TagCode_SUCCESS - pack.Msg = "" - } - tNode.TransRep.RetFiels = pack - tNode.Resume() - if err != nil { - logger.Logger.Error("AddCoinById task marshal data error:", err) - } - }), "AddCoinById").Start() - return common.ResponseTag_TransactYield, pack - } else { - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - pd, _ = model.GetPlayerDataBySnId(platform, int32(member_snid), false, true) - if pd == nil { - return errors.New("Player not find.") - } - if len(platform) > 0 && pd.Platform != platform { - return errors.New("player platform forbit.") - } - oldGold = pd.Coin - if coin < 0 { - if pd.Coin+coin < 0 { - return errors.New("coin not enough!") - } - } - - opcode := int32(common.GainWay_API_AddCoin) - if logType != 0 { - opcode = logType - } - coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode, - gold_desc, model.PayCoinLogType_Coin, coinEx) - timeStamp = coinLog.TimeStamp - err = model.InsertPayCoinLogs(platform, coinLog) - if err != nil { - logger.Logger.Errorf("model.InsertPayCoinLogs err:%v log:%v", err, coinLog) - return err - } - //增加帐变记录 - coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ - Platform: pd.Platform, - SnID: member_snid, - Channel: pd.Channel, - ChangeType: common.BillTypeCoin, - ChangeNum: coin + coinEx, - RemainNum: oldGold + coin + coinEx, - Add: 0, - LogType: opcode, - GameID: 0, - GameFreeID: 0, - BaseCoin: 0, - Operator: oper, - Remark: gold_desc, - }) - err = model.InsertCoinLog(coinlogex) - if err != nil { - //回滚到对账日志 - model.RemovePayCoinLog(platform, coinLog.LogId) - logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) - return err - } - return err - }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { - CacheDataMgr.ClearCacheBill(billNo, platform) - if data != nil { - pack.Tag = webapiproto.TagCode_FAILED - pack.Msg = data.(error).Error() - } else { - pack.Tag = webapiproto.TagCode_SUCCESS - pack.Msg = "" - if isAccTodayRecharge && coin >= 0 { - OnPlayerPay(pd, coin) - } - if isAccTodayRecharge && coin >= 0 && coinEx >= 0 { - - plt := PlatformMgrSingleton.GetPlatform(pd.Platform) - curVer := int32(0) - if plt != nil { - curVer = plt.ExchangeVer - } - log := model.NewCoinGiveLogEx(pd.SnId, pd.Name, coin, coinEx, 0, common.GainWay_API_AddCoin, pd.PromoterTree, - model.COINGIVETYPE_PAY, curVer, pd.Platform, pd.Channel, pd.BeUnderAgentCode, - "", "system", pd.PackageID, int32(needFlowRate), int32(needGiveFlowRate)) - if log != nil { - err := model.InsertGiveCoinLog(log) - if err == nil { - if pd.LastExchangeOrder != "" && pd.TotalConvertibleFlow > 0 { - err = model.UpdateGiveCoinLastFlow(platform, pd.LastExchangeOrder, pd.TotalConvertibleFlow) - } - } - //清空流水,更新id - pd.TotalConvertibleFlow = 0 - pd.LastExchangeOrder = log.LogId.Hex() - if player == nil { - //需要回写数据库 - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - model.UpdatePlayerExchageFlowAndOrder(platform, int32(member_snid), 0, pd.LastExchangeOrder) - return nil - }), nil, "UpdateGiveCoinLogs").StartByExecutor(pd.AccountId) - } - } - - } - } - - tNode.TransRep.RetFiels = pack - tNode.Resume() - if err != nil { - logger.Logger.Error("AddCoinById task marshal data error:", err) - } - }), "AddCoinById").Start() - return common.ResponseTag_TransactYield, pack - } - })) + //WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Game/AddCoinById", WebAPIHandlerWrapper( + // func(tNode *transact.TransNode, params []byte) (int, proto.Message) { + // pack := &webapiproto.SAAddCoinById{} + // msg := &webapiproto.ASAddCoinById{} + // err1 := proto.Unmarshal(params, msg) + // if err1 != nil { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "数据序列化失败" + err1.Error() + // return common.ResponseTag_ParamError, pack + // } + // + // member_snid := msg.GetID() + // coin := msg.GetGold() + // coinEx := msg.GetGoldEx() + // oper := msg.GetOper() + // gold_desc := msg.GetDesc() + // billNo := int(msg.GetBillNo()) + // platform := msg.GetPlatform() + // logType := msg.GetLogType() + // isAccTodayRecharge := msg.GetIsAccTodayRecharge() + // needFlowRate := msg.GetNeedFlowRate() + // needGiveFlowRate := msg.GetNeedGiveFlowRate() + // + // if CacheDataMgr.CacheBillCheck(billNo, platform) { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "Bill number repeated!" + // return common.ResponseTag_ParamError, pack + // } + // CacheDataMgr.CacheBillNumber(billNo, platform) //防止手抖点两下 + // + // var err error + // var pd *model.PlayerData + // oldGold := int64(0) + // var timeStamp = time.Now().UnixNano() + // player := PlayerMgrSington.GetPlayerBySnId(int32(member_snid)) + // if player != nil { //在线玩家处理 + // if player.scene != nil { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "Unsupported!!! because player in scene!" + // return common.ResponseTag_ParamError, pack + // } + // pd = player.PlayerData + // if len(platform) > 0 && player.Platform != platform { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "player platform forbit!" + // return common.ResponseTag_ParamError, pack + // } + // + // if coin < 0 { + // if player.Coin+coin < 0 { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = "coin not enough!" + // return common.ResponseTag_ParamError, pack + // } + // } + // + // opcode := int32(common.GainWay_API_AddCoin) + // if logType != 0 { + // opcode = logType + // } + // + // oldGold = player.Coin + // coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode, + // gold_desc, model.PayCoinLogType_Coin, coinEx) + // timeStamp = coinLog.TimeStamp + // //增加帐变记录 + // coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ + // Platform: pd.Platform, + // SnID: member_snid, + // Channel: pd.Channel, + // ChangeType: common.BillTypeCoin, + // ChangeNum: coin + coinEx, + // RemainNum: oldGold + coin + coinEx, + // Add: 0, + // LogType: opcode, + // GameID: 0, + // GameFreeID: 0, + // BaseCoin: 0, + // Operator: oper, + // Remark: gold_desc, + // }) + // + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // err = model.InsertPayCoinLogs(platform, coinLog) + // if err != nil { + // logger.Logger.Errorf("model.InsertPayCoinLogs err:%v log:%v", err, coinLog) + // return err + // } + // err = model.InsertCoinLog(coinlogex) + // if err != nil { + // //回滚到对账日志 + // model.RemovePayCoinLog(platform, coinLog.LogId) + // logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) + // return err + // } + // return err + // }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // if data != nil { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = data.(error).Error() + // } else { + // //player.Coin += coin + coinEx + // player.AddCoinAsync(coin+coinEx, 0, common.GainWay_API_AddCoin, oper, gold_desc, true, 0, false) + // //增加相应的泥码量 + // player.AddDirtyCoin(coin, coinEx) + // player.SetPayTs(timeStamp) + // + // if player.TodayGameData == nil { + // player.TodayGameData = model.NewPlayerGameCtrlData() + // } + // //actRandCoinMgr.OnPlayerRecharge(player, coin) + // if isAccTodayRecharge { + // + // player.AddCoinPayTotal(coin) + // player.TodayGameData.RechargeCoin += coin //累加当天充值金额 + // if coin >= 0 && coinEx >= 0 { + // plt := PlatformMgrSingleton.GetPlatform(pd.Platform) + // curVer := int32(0) + // if plt != nil { + // curVer = plt.ExchangeVer + // } + // log := model.NewCoinGiveLogEx(pd.SnId, pd.Name, coin, coinEx, 0, opcode, pd.PromoterTree, + // model.COINGIVETYPE_PAY, curVer, pd.Platform, pd.Channel, pd.BeUnderAgentCode, + // "", "system", pd.PackageID, int32(needFlowRate), int32(needGiveFlowRate)) + // if log != nil { + // err := model.InsertGiveCoinLog(log) + // if err == nil { + // if pd.LastExchangeOrder != "" && pd.TotalConvertibleFlow > 0 { + // err = model.UpdateGiveCoinLastFlow(platform, pd.LastExchangeOrder, pd.TotalConvertibleFlow) + // } + // } + // //清空流水,更新id + // pd.TotalConvertibleFlow = 0 + // pd.LastExchangeOrder = log.LogId.Hex() + // if player == nil { + // //需要回写数据库 + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // model.UpdatePlayerExchageFlowAndOrder(platform, member_snid, 0, pd.LastExchangeOrder) + // return nil + // }), nil, "UpdateGiveCoinLogs").StartByExecutor(pd.AccountId) + // } + // } + // } + // } + // + // player.dirty = true + // player.Time2Save() + // if player.scene == nil { //如果在大厅,那么同步下金币 + // player.SendDiffData() + // } + // player.SendPlayerRechargeAnswer(coin) + // pack.Tag = webapiproto.TagCode_SUCCESS + // pack.Msg = "" + // } + // tNode.TransRep.RetFiels = pack + // tNode.Resume() + // if err != nil { + // logger.Logger.Error("AddCoinById task marshal data error:", err) + // } + // }), "AddCoinById").Start() + // return common.ResponseTag_TransactYield, pack + // } else { + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // pd, _ = model.GetPlayerDataBySnId(platform, int32(member_snid), false, true) + // if pd == nil { + // return errors.New("Player not find.") + // } + // if len(platform) > 0 && pd.Platform != platform { + // return errors.New("player platform forbit.") + // } + // oldGold = pd.Coin + // if coin < 0 { + // if pd.Coin+coin < 0 { + // return errors.New("coin not enough!") + // } + // } + // + // opcode := int32(common.GainWay_API_AddCoin) + // if logType != 0 { + // opcode = logType + // } + // coinLog := model.NewPayCoinLog(int64(billNo), int32(member_snid), coin, opcode, + // gold_desc, model.PayCoinLogType_Coin, coinEx) + // timeStamp = coinLog.TimeStamp + // err = model.InsertPayCoinLogs(platform, coinLog) + // if err != nil { + // logger.Logger.Errorf("model.InsertPayCoinLogs err:%v log:%v", err, coinLog) + // return err + // } + // //增加帐变记录 + // coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ + // Platform: pd.Platform, + // SnID: member_snid, + // Channel: pd.Channel, + // ChangeType: common.BillTypeCoin, + // ChangeNum: coin + coinEx, + // RemainNum: oldGold + coin + coinEx, + // Add: 0, + // LogType: opcode, + // GameID: 0, + // GameFreeID: 0, + // BaseCoin: 0, + // Operator: oper, + // Remark: gold_desc, + // }) + // err = model.InsertCoinLog(coinlogex) + // if err != nil { + // //回滚到对账日志 + // model.RemovePayCoinLog(platform, coinLog.LogId) + // logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) + // return err + // } + // return err + // }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { + // CacheDataMgr.ClearCacheBill(billNo, platform) + // if data != nil { + // pack.Tag = webapiproto.TagCode_FAILED + // pack.Msg = data.(error).Error() + // } else { + // pack.Tag = webapiproto.TagCode_SUCCESS + // pack.Msg = "" + // if isAccTodayRecharge && coin >= 0 { + // OnPlayerPay(pd, coin) + // } + // if isAccTodayRecharge && coin >= 0 && coinEx >= 0 { + // + // plt := PlatformMgrSingleton.GetPlatform(pd.Platform) + // curVer := int32(0) + // if plt != nil { + // curVer = plt.ExchangeVer + // } + // log := model.NewCoinGiveLogEx(pd.SnId, pd.Name, coin, coinEx, 0, common.GainWay_API_AddCoin, pd.PromoterTree, + // model.COINGIVETYPE_PAY, curVer, pd.Platform, pd.Channel, pd.BeUnderAgentCode, + // "", "system", pd.PackageID, int32(needFlowRate), int32(needGiveFlowRate)) + // if log != nil { + // err := model.InsertGiveCoinLog(log) + // if err == nil { + // if pd.LastExchangeOrder != "" && pd.TotalConvertibleFlow > 0 { + // err = model.UpdateGiveCoinLastFlow(platform, pd.LastExchangeOrder, pd.TotalConvertibleFlow) + // } + // } + // //清空流水,更新id + // pd.TotalConvertibleFlow = 0 + // pd.LastExchangeOrder = log.LogId.Hex() + // if player == nil { + // //需要回写数据库 + // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + // model.UpdatePlayerExchageFlowAndOrder(platform, int32(member_snid), 0, pd.LastExchangeOrder) + // return nil + // }), nil, "UpdateGiveCoinLogs").StartByExecutor(pd.AccountId) + // } + // } + // + // } + // } + // + // tNode.TransRep.RetFiels = pack + // tNode.Resume() + // if err != nil { + // logger.Logger.Error("AddCoinById task marshal data error:", err) + // } + // }), "AddCoinById").Start() + // return common.ResponseTag_TransactYield, pack + // } + // })) //重置水池 WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/Game/ResetGamePool", WebAPIHandlerWrapper( func(tNode *transact.TransNode, params []byte) (int, proto.Message) {