充值接口修改,sdk和本地走同一套接口

dev_chengFeng
gaoxin 2020-09-09 18:47:17 +08:00 committed by JieLing
parent d440edea11
commit 701db5bb17
21 changed files with 164 additions and 266 deletions

View File

@ -28,12 +28,10 @@ end
--添加事件监听(用于子类重写)
function XianShiShangShi:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.RechargeSuccessFunc)
end
--移除事件监听(用于子类重写)
function XianShiShangShi:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.RechargeSuccessFunc)
end
local sortingOrder = 0
--界面打开时调用(用于子类重写)
@ -150,16 +148,10 @@ function this.SingleDataShow(pre,value)
PopupTipPanel.ShowTip(Language[10540])
else
--直购商品
if AppConst.isSDKLogin then
PayManager.Pay({ Id = value.Id })
else
NetManager.RequestBuyGiftGoods(value.Id, function(msg)
FirstRechargeManager.RefreshAccumRechargeValue(value.Id)
-- OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.DirectPurchaseGift, data.goodsId) -- 改成后端推了
this.OnShowData()
PayManager.Pay(value.Id, function(id)
this.RechargeSuccessFunc(id)
end)
end
end
end)
end
@ -170,7 +162,6 @@ end
function this.RechargeSuccessFunc(id)
FirstRechargeManager.RefreshAccumRechargeValue(id)
--OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.GiftBuy, id)
this.OnShowData()
end

View File

@ -28,12 +28,10 @@ end
--添加事件监听(用于子类重写)
function ZhenQiYiBaoPage:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.RechargeSuccessFunc)
end
--移除事件监听(用于子类重写)
function ZhenQiYiBaoPage:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.RechargeSuccessFunc)
end
local sortingOrder = 0
--界面打开时调用(用于子类重写)
@ -153,17 +151,10 @@ function this.SingleDataShow(pre,value)
PopupTipPanel.ShowTip(Language[10540])
else
--直购商品
if AppConst.isSDKLogin then
PayManager.Pay({ Id = value.Id })
else
NetManager.RequestBuyGiftGoods(value.Id, function(msg)
FirstRechargeManager.RefreshAccumRechargeValue(value.Id)
-- OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.DirectPurchaseGift, data.goodsId) -- 改成后端推了
LogGreen("刷新?")
this.OnShowData()
PayManager.Pay(value.Id, function(id)
this.RechargeSuccessFunc(id)
end)
end
end
end)
end

View File

@ -118,17 +118,12 @@ function DiffMonsterBuy:DiffMonsterBuy()
end
Util.AddOnceClick(this.diffMonsterBuyBtn, function()
if shopItemData.buyTimes <= 0 then
if AppConst.isSDKLogin then
PayManager.Pay({ Id = rechargeCommodityConfig.Id })
else
Log(Language[10527]..rechargeCommodityConfig.Id)
NetManager.RequestBuyGiftGoods(rechargeCommodityConfig.Id, function()
PayManager.Pay(rechargeCommodityConfig.Id, function(id)
FirstRechargeManager.RefreshAccumRechargeValue(rechargeCommodityConfig.Id)
OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.DirectPurchaseGift, rechargeCommodityConfig.Id)
this:DiffMonsterBuy()
end)
end
end
end)
Util.AddOnceClick(this.diffMonsteNameBtn, function()
UIManager.OpenPanel(UIName.PatFaceDiffMonsterInfoPanel,diffMonsterBuyData.Values)

View File

@ -32,12 +32,10 @@ end
--添加事件监听(用于子类重写)
function GiftBuy:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.RechargeSuccessFunc)
end
--移除事件监听(用于子类重写)
function GiftBuy:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.RechargeSuccessFunc)
end
local sortingOrder = 0
--界面打开时调用(用于子类重写)
@ -134,16 +132,10 @@ function this.SingleDataShow(go, data)
PopupTipPanel.ShowTip(Language[10540])
else
--直购商品
if AppConst.isSDKLogin then
PayManager.Pay({ Id = data.Id })
else
NetManager.RequestBuyGiftGoods(data.Id, function(msg)
FirstRechargeManager.RefreshAccumRechargeValue(data.Id)
-- OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.DirectPurchaseGift, data.goodsId) -- 改成后端推了
this.OnShowData()
PayManager.Pay(data.Id, function(id)
this:RechargeSuccessFunc(id)
end)
end
end
end)
end
function this.RechargeSuccessFunc(id)

View File

@ -49,10 +49,24 @@ function HeroStarFeedPage:BindEvent()
end)
Util.AddClick(self.btnBuy,function()
if AppConst.isSDKLogin then
PayManager.Pay({ Id = curGiftId })
else
NetManager.RequestBuyGiftGoods(curGiftId, function()
--直购商品
PayManager.Pay(curGiftId, function(id)
this:RechargeSuccessFunc(id)
end)
end)
Util.AddClick(self.arrowsLeft,function()
self:FreshRewardShow(curIndex-1)
end)
Util.AddClick(self.arrowsRight,function()
self:FreshRewardShow(curIndex+1)
end)
end
-- 充值成功回调
function HeroStarFeedPage:RechargeSuccessFunc(id)
FirstRechargeManager.RefreshAccumRechargeValue(curGiftId)
CheckRedPointStatus(RedPointType.GrowthPackage)--成长礼包的红点检测
curGiftList[curIndex].dynamicBuyTimes = curGiftList[curIndex].dynamicBuyTimes - 1
@ -87,25 +101,6 @@ function HeroStarFeedPage:BindEvent()
end
end
end
end)
end
end)
Util.AddClick(self.arrowsLeft,function()
self:FreshRewardShow(curIndex-1)
end)
Util.AddClick(self.arrowsRight,function()
self:FreshRewardShow(curIndex+1)
end)
end
-- 充值成功回调
function HeroStarFeedPage:RechargeSuccessFunc(id)
FirstRechargeManager.RefreshAccumRechargeValue(id)
-- OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.DemonCrystal, id)--后端推了
self:FreshRewardShow()
end

View File

@ -27,16 +27,13 @@ end
function WeekCard:BindEvent()
Util.AddClick(self.weekCardBuyBtn, function()
if AppConst.isSDKLogin then
PayManager.Pay({ Id = 12 })
else
NetManager.RequestBuyGiftGoods(12, function()
--直购商品
PayManager.Pay(12, function(id)
PopupTipPanel.ShowTip(Language[10553])
FirstRechargeManager.RefreshAccumRechargeValue(12)
OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.WeekCard, 12)
this:WeekCardShow()
end)
end
end)
end

View File

@ -31,11 +31,9 @@ function this:BindEvent()
end
function this:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.RechargeSuccessFunc)
end
function this:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.RechargeSuccessFunc)
end
function this:OnShow(_sortingOrder)
@ -88,15 +86,10 @@ function this.SetShow(root,data)
stateBtnText.text=Language[10638]
end
Util.AddOnceClick(stateBtn,function()
if AppConst.isSDKLogin then
PayManager.Pay({ Id = data.native.Id })
else
NetManager.RequestBuyGiftGoods(data.native.Id, function()
FirstRechargeManager.RefreshAccumRechargeValue(data.native.Id)
OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.DirectPurchaseGift, data.native.Id)
this.OnShowPanelData()
--直购商品
PayManager.Pay(data.native.Id, function(id)
this.RechargeSuccessFunc(id)
end)
end
end)
if data.native.Limit-data.server.buyTimes==0 then

View File

@ -27,11 +27,9 @@ function this:BindEvent()
end
function this:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.RechargeSuccessFunc)
end
function this:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.RechargeSuccessFunc)
end
function this:OnShow(_sortingOrder)
@ -76,17 +74,9 @@ function this.OnShowPanelData()
itemRewardGrid[i]:OnOpen(false,conFigData.BaseReward[i],1.1,false,false,false,sortingOrder)
end
Util.AddOnceClick(this.buyBtn, function()
if shopItemData.buyTimes <= 0 then
if AppConst.isSDKLogin then
PayManager.Pay({ Id = conFigData.Id })
else
NetManager.RequestBuyGiftGoods(conFigData.Id, function()
FirstRechargeManager.RefreshAccumRechargeValue(conFigData.Id)
OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.DirectPurchaseGift, conFigData.Id)
this.OnShowPanelData()
PayManager.Pay(conFigData.Id, function(id)
this.RechargeSuccessFunc(id)
end)
end
end
end)
this.RemainTimeDown(this.timeGo,this.time,shopItemData.endTime - GetTimeStamp())
end

View File

@ -25,11 +25,9 @@ function this:BindEvent()
end
function this:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.RechargeSuccessFunc)
end
function this:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.RechargeSuccessFunc)
end
function this:OnShow(_sortingOrder)
@ -90,16 +88,10 @@ function this.OnShowPanelData(i)
Util.AddOnceClick(buyBtn, function()
if shopItemData.buyTimes <= 0 then
if AppConst.isSDKLogin then
PayManager.Pay({ Id = conFigData.Id })
else
NetManager.RequestBuyGiftGoods(conFigData.Id, function()
FirstRechargeManager.RefreshAccumRechargeValue(conFigData.Id)
OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.DirectPurchaseGift, conFigData.Id)
this.OnShowPanel()
PayManager.Pay(conFigData.Id, function(id)
this.RechargeSuccessFunc(id)
end)
end
end
end)
end
this.timer = Timer.New()

View File

@ -108,12 +108,10 @@ function this:BindEvent()
end
function this:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.RechargeSuccessFunc)
Game.GlobalEvent:AddEvent(GameEvent.FiveAMRefresh.ServerNotifyRefresh, this.InitView)
end
function this:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.RechargeSuccessFunc)
Game.GlobalEvent:RemoveEvent(GameEvent.FiveAMRefresh.ServerNotifyRefresh, this.InitView)
end
@ -178,17 +176,9 @@ function this.SetInfo(id)
Util.AddOnceClick(this.sendBtn,function()
if surplusNum<1 then return end
local recharge=ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig,index[id])
if AppConst.isSDKLogin then
PayManager.Pay({ Id = recharge.Id})
else
NetManager.RequestBuyGiftGoods(recharge.Id, function()
FirstRechargeManager.RefreshAccumRechargeValue(recharge.Id)
OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.GuildRedPacket, recharge.Id)
this.SetInfo(curIndex)
PopupTipPanel.ShowTip(string.format( Language[11078],redpack.Name))
ChatManager.RequestSendRedPacket(curIndex)
PayManager.Pay(recharge.Id, function(id)
this.RechargeSuccessFunc(id)
end)
end
end)
end

View File

@ -487,10 +487,7 @@ function GiftPackPage:RefreshShowData(item, data, type, DataTypeIndex)
self:BuyAction(costId, finalNum, SHOP_TYPE.FINDTREASURE_GIFT, data.id, type)
else
--直购商品
if AppConst.isSDKLogin then
PayManager.Pay({ Id = data.goodsId })
else
NetManager.RequestBuyGiftGoods(data.goodsId, function()
PayManager.Pay(data.goodsId, function(id)
FirstRechargeManager.RefreshAccumRechargeValue(data.goodsId)
OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.DirectPurchaseGift, data.goodsId)
self:RefreshGiftData(type)
@ -498,7 +495,6 @@ function GiftPackPage:RefreshShowData(item, data, type, DataTypeIndex)
end)
end
end
end
end)
end

View File

@ -251,17 +251,10 @@ function GrowthGiftPage:OnBtnInvestClicked()
end
function GrowthGiftPage:RequestBuy()
local giftGoodsInfo = OperatingManager.GetGiftGoodsInfo(GoodsTypeDef.GrowthReward, curGiftsId)
if AppConst.isSDKLogin then
PayManager.Pay({Id = giftGoodsInfo.goodsId})
else
NetManager.RequestBuyGiftGoods(giftGoodsInfo.goodsId,function(respond)
-- PopupTipPanel.ShowTip("奖励已发送到邮件,请前往领取")
-- FirstRechargeManager.RefreshAccumRechargeValue( giftGoodsInfo.goodsId)
lastGiftId = curGiftsId
PayManager.Pay(giftGoodsInfo.goodsId, function(id)
self:RefreshStatus()
end)
end
end
function GrowthGiftPage:RefreshStatus()
local giftGoodsInfo = OperatingManager.GetGiftGoodsInfo(GoodsTypeDef.GrowthReward, curGiftsId)

View File

@ -89,29 +89,18 @@ function UpperMonthCard:BindEvent()
JumpManager.GoJump(36004)
end, Language[10719], Language[10023],nil, false)
else
if AppConst.isSDKLogin then
PayManager.Pay({ Id = self.baseType })
else
Log(Language[11489] .. self.baseType)
NetManager.RequestBuyGiftGoods(self.baseType, function()
self:RechargeSuccessFunc(self.baseType)
Log(Language[10545])
PayManager.Pay(self.baseType, function(id)
self:RechargeSuccessFunc(id)
end)
end
end
end)
end
function UpperMonthCard:AddEvent()
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, self.RechargeSuccessFunc, self)
end
function UpperMonthCard:RemoveEvent()
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess, self.RechargeSuccessFunc, self)
end
function UpperMonthCard:OnShow(parentSorting, arg, pageIndex)

View File

@ -165,16 +165,12 @@ function WeekMonthGiftPackPage:RefreshShowData(item, data)
PopupTipPanel.ShowTip(Language[10540])
else
--直购商品
if AppConst.isSDKLogin then
PayManager.Pay({ Id = data.goodsId })
else
NetManager.RequestBuyGiftGoods(data.goodsId, function()
PayManager.Pay(data.goodsId, function(id)
FirstRechargeManager.RefreshAccumRechargeValue(data.goodsId)
self:RefreshGiftData()
CheckRedPointStatus(RedPointType.DailyGift)
end)
end
end
end)
end

View File

@ -10,7 +10,7 @@ local this = PayManager
--初始化
function this.Initialize()
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.onSdkPayResult)
end
----- 请求支付
----- @param context
@ -18,7 +18,38 @@ end
---- Id, -- required, 商品ID
---- BuyNum, -- optional, 购买个数(默认1
---- }
function this.Pay(context)
----
----
this.EventTrigger = {}
function this.onSdkPayResult(id)
if this.EventTrigger[id] then
this.EventTrigger[id](id)
this.EventTrigger[id] = nil
end
end
function this.Pay(id, func)
if not func then
func = function()end
end
if this.EventTrigger[id] then
PopupTipPanel.ShowTip("您有一个相同的订单正在处理,请稍后再试")
return
end
this.EventTrigger[id] = func
--直购商品
if AppConst.isSDKLogin then
PayManager.SdkPay({ Id = id })
else
NetManager.RequestBuyGiftGoods(id, function(msg)
this.onSdkPayResult(id)
end)
end
end
function this.SdkPay(context)
local rechargeConfig = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig, context.Id)
local payData = table.clone(context)
payData.Name = rechargeConfig.Name

View File

@ -33,13 +33,9 @@ function this:BindEvent()
parent:ClosePanel()
end)
Util.AddOnceClick(this.dealBtn,function()
if AppConst.isSDKLogin then
PayManager.Pay({Id = type[curType].id})
else
NetManager.RequestBuyGiftGoods(type[curType].id,function()
PayManager.Pay(type[curType].id, function(id)
this.RechargeSuccessFunc()
end)
end
end)
end

View File

@ -70,10 +70,7 @@ end
function GiftView:BindEvent()
Util.AddClick(self.buyAllBtn,function ()
if AppConst.isSDKLogin then
PayManager.Pay({ Id = 1004 })
else
NetManager.RequestBuyGiftGoods(1004, function()
PayManager.Pay(1004, function(id)
FirstRechargeManager.RefreshAccumRechargeValue(1004)
PlayerPrefs.SetInt(PlayerManager.uid.."czlb", 0)
CheckRedPointStatus(RedPointType.DailyGift)
@ -81,7 +78,6 @@ function GiftView:BindEvent()
timerList={}
self:RefreshGiftData()
end)
end
end)
end
@ -544,10 +540,7 @@ function GiftView:RefreshShowData(item, data, buyType, DataTypeIndex)
CheckRedPointStatus(RedPointType.GrowthPackage)
else
--直购商品
if AppConst.isSDKLogin then
PayManager.Pay({ Id = data.goodsId })
else
NetManager.RequestBuyGiftGoods(data.goodsId, function()
PayManager.Pay( data.goodsId, function(id)
FirstRechargeManager.RefreshAccumRechargeValue(data.goodsId)
PlayerPrefs.SetInt(PlayerManager.uid.."czlb", 0)
CheckRedPointStatus(RedPointType.DailyGift)
@ -557,7 +550,6 @@ function GiftView:RefreshShowData(item, data, buyType, DataTypeIndex)
end)
end
end
end
end)
end

View File

@ -32,13 +32,9 @@ function HeavenUnlockExtraRewardPanel:BindEvent()
this:ClosePanel()
end)
Util.AddOnceClick(this.dealBtn,function()
if AppConst.isSDKLogin then
PayManager.Pay({Id = type[curType].id})
else
NetManager.RequestBuyGiftGoods(type[curType].id,function()
PayManager.Pay(type[curType].id, function(id)
this.RechargeSuccessFunc()
end)
end
end)
end

View File

@ -24,7 +24,6 @@ end
function UnlockExtraRewardPanel:BindEvent()
Util.AddClick(self.closeBtn, function()
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess, self.RechargeSuccessFunc, self)
self:ClosePanel()
end)
Util.AddClick(self.dealBtn, function()
@ -42,7 +41,6 @@ function UnlockExtraRewardPanel:OnOpen(goodsId,context)
end
function UnlockExtraRewardPanel:OnShow()
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, self.RechargeSuccessFunc, self)
self:SetCostValues()
end
@ -66,14 +64,10 @@ function UnlockExtraRewardPanel:OnDealBtnClicked()
-- self:ClosePanel()
-- end)
-- end)
if AppConst.isSDKLogin then
PayManager.Pay({ Id = self.goodsId })
else
NetManager.RequestBuyGiftGoods(self.goodsId, function()
self:RechargeSuccessFunc(self.goodsId)
PayManager.Pay(self.goodsId, function(id)
self:RechargeSuccessFunc(id)
end)
end
end
--充值成功的回调
function UnlockExtraRewardPanel:RechargeSuccessFunc(id)

View File

@ -40,11 +40,7 @@ function this:BindEvent()
end)
Util.AddClick(this.btnBuy,function()
if AppConst.isSDKLogin then
PayManager.Pay({ Id = curGiftId })
else
LogBlue("curGiftId:"..curGiftId)
NetManager.RequestBuyGiftGoods(curGiftId, function()
PayManager.Pay(curGiftId, function(id)
FirstRechargeManager.RefreshAccumRechargeValue(curGiftId)
CheckRedPointStatus(RedPointType.GrowthPackage)--成长礼包的红点检测
rechargeData.dynamicBuyTimes = rechargeData.dynamicBuyTimes - 1
@ -57,7 +53,6 @@ function this:BindEvent()
-- end
this:Refresh()
end)
end
end)
Util.AddClick(this.arrowsLeft,function()

View File

@ -118,12 +118,10 @@ end
--添加事件监听(用于子类重写)
function this:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Shop.OnShopInfoChange, self.RefreshShopInfo, self)
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, self.RechargeSuccessFunc, self)
end
--移除事件监听(用于子类重写)
function this:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Shop.OnShopInfoChange, self.RefreshShopInfo, self)
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess, self.RechargeSuccessFunc, self)
end
--界面打开时调用(用于子类重写)
function this:OnOpen(...)
@ -545,15 +543,9 @@ function this:RechargeShopItemAdapter(shopItem, itemData)
-- 购买事件
Util.AddOnceClick(shopItem, function()
if AppConst.isSDKLogin then
PayManager.Pay({ Id = itemData.goodsId })
else
NetManager.RequestBuyGiftGoods(itemData.goodsId, function()
PayManager.Pay(itemData.goodsId, function(id)
self:RechargeSuccessFunc(itemData.goodsId)
PlayerPrefs.SetInt(PlayerManager.uid.."czlb", 0)
CheckRedPointStatus(RedPointType.GrowthPackage)--成长礼包红点检测
end)
end
end)
end
@ -563,6 +555,8 @@ function this:RechargeSuccessFunc(id)
OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.DemonCrystal, id)
self:RefreshShopInfo(false, false)
--PopupTipPanel.ShowTip("购买成功,请到邮箱中领取!")
PlayerPrefs.SetInt(PlayerManager.uid.."czlb", 0)
CheckRedPointStatus(RedPointType.GrowthPackage)--成长礼包红点检测
end
---=====================================对外接口=============================----