金币礼包逻辑调整
This commit is contained in:
parent
cc674c3204
commit
b784b7aeda
@ -152,7 +152,9 @@ function ShopManager:tryTriggerCoinGift()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ShopManager:tryTriggerCoinGiftFinish(result)
|
function ShopManager:tryTriggerCoinGiftFinish(result)
|
||||||
DataManager.ShopData:onTriggerCoinGift(result.reqData.gold_gift_id)
|
if result.status == 0 then
|
||||||
|
DataManager.ShopData:onTriggerCoinGift(result.reqData.gold_gift_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return ShopManager
|
return ShopManager
|
||||||
@ -72,7 +72,7 @@ function CoinSellCell:refresh()
|
|||||||
self.priceText2:setText(GFunc.getFormatPrice(cfgInfo.recharge_id))
|
self.priceText2:setText(GFunc.getFormatPrice(cfgInfo.recharge_id))
|
||||||
-- 限时
|
-- 限时
|
||||||
self.timeImg:setVisible(true)
|
self.timeImg:setVisible(true)
|
||||||
self:updateTime()
|
self:refreshTime()
|
||||||
|
|
||||||
self:addClickListener(function()
|
self:addClickListener(function()
|
||||||
self:onClickGift(actGiftId)
|
self:onClickGift(actGiftId)
|
||||||
@ -96,12 +96,12 @@ function CoinSellCell:onClickGift(id)
|
|||||||
PayManager:purchasePackage(id, PayManager.PURCHARSE_TYPE.ACT_GIFT)
|
PayManager:purchasePackage(id, PayManager.PURCHARSE_TYPE.ACT_GIFT)
|
||||||
end
|
end
|
||||||
|
|
||||||
function CoinSellCell:updateTime()
|
function CoinSellCell:refreshTime()
|
||||||
local remainTime = 0
|
local remainTime = 0
|
||||||
local actId = DataManager.ShopData:getValidCoinGiftId()
|
local actId = DataManager.ShopData:getValidCoinGiftId()
|
||||||
if actId then
|
if actId > 0 then
|
||||||
local cfgInfo = self:getActGiftConfig()[actId]
|
local cfgInfo = DataManager.ShopData:getActGiftConfig()[actId]
|
||||||
local triggerTime = self:getCoinGiftTriggerTime()
|
local triggerTime = DataManager.ShopData:getCoinGiftTriggerTime()
|
||||||
remainTime = triggerTime + (cfgInfo.limit_time or 0) * 3600 - Time:getServerTime()
|
remainTime = triggerTime + (cfgInfo.limit_time or 0) * 3600 - Time:getServerTime()
|
||||||
if remainTime <= 0 then
|
if remainTime <= 0 then
|
||||||
remainTime = 0
|
remainTime = 0
|
||||||
|
|||||||
@ -138,6 +138,9 @@ function ShopComp:refreshTime()
|
|||||||
if self.hotSellCell and self.hotSellCell:getIsOpen() then
|
if self.hotSellCell and self.hotSellCell:getIsOpen() then
|
||||||
self.hotSellCell:refreshTime()
|
self.hotSellCell:refreshTime()
|
||||||
end
|
end
|
||||||
|
if self.coinSellCell and self.coinSellCell:getIsOpen() then
|
||||||
|
self.coinSellCell:refreshTime()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ShopComp:refreshDiscountPage()
|
function ShopComp:refreshDiscountPage()
|
||||||
|
|||||||
@ -384,8 +384,14 @@ function ShopData:initLevelUpGift(levelUpGift)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ShopData:initCoinGift(id, triggerTime)
|
function ShopData:initCoinGift(id, triggerTime)
|
||||||
|
if EDITOR_MODE then
|
||||||
|
Logger.logHighlight("初始化 金币礼包 -- id:%s time:%s", id, triggerTime)
|
||||||
|
end
|
||||||
|
|
||||||
self.coinGiftId = id or 0 -- 金币礼包触发id
|
self.coinGiftId = id or 0 -- 金币礼包触发id
|
||||||
self.coinGiftTriggerTime = triggerTime or 0 -- 金币礼包触发时间
|
self.coinGiftTriggerTime = triggerTime or 0 -- 金币礼包触发时间
|
||||||
|
|
||||||
|
self:setDirty()
|
||||||
end
|
end
|
||||||
|
|
||||||
function ShopData:getPayAmount()
|
function ShopData:getPayAmount()
|
||||||
@ -436,7 +442,7 @@ function ShopData:getCoinGiftTriggerTime()
|
|||||||
return self.coinGiftTriggerTime // 1000
|
return self.coinGiftTriggerTime // 1000
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 获得当前时间还处于有效的金币礼包id
|
-- 获得当前可购买的金币礼包id,需要未购买且时间满足
|
||||||
function ShopData:getValidCoinGiftId()
|
function ShopData:getValidCoinGiftId()
|
||||||
local actId = self:getCoinGiftId()
|
local actId = self:getCoinGiftId()
|
||||||
if actId > 0 then
|
if actId > 0 then
|
||||||
@ -444,9 +450,26 @@ function ShopData:getValidCoinGiftId()
|
|||||||
local triggerTime = self:getCoinGiftTriggerTime()
|
local triggerTime = self:getCoinGiftTriggerTime()
|
||||||
local remainTime = triggerTime + (cfgInfo.limit_time or 0) * 3600 - Time:getServerTime()
|
local remainTime = triggerTime + (cfgInfo.limit_time or 0) * 3600 - Time:getServerTime()
|
||||||
if remainTime > 0 then
|
if remainTime > 0 then
|
||||||
return actId
|
-- 查看最近一次购买时间
|
||||||
|
local actGiftDetailData = self:getActGiftDetailData(PayManager.PURCHARSE_TYPE.ACT_GIFT, actId)
|
||||||
|
if actGiftDetailData then
|
||||||
|
local latestBuyTime = actGiftDetailData.latest_buy_at // 1000
|
||||||
|
if latestBuyTime <= 0 then
|
||||||
|
return actId
|
||||||
|
else
|
||||||
|
-- 目前规则上有CD 所以如果购买时间在CD范围内则该礼包无效
|
||||||
|
local limitTime = (self:getActGiftConfig()[actId].limit_time or 0) * 3600
|
||||||
|
if Time:getServerTime() > latestBuyTime + limitTime then
|
||||||
|
return actId
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
else -- 没有买过,这个肯定可以购买
|
||||||
|
return actId
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 获取金币礼包付款条件cfgInfo数组 从小到大
|
-- 获取金币礼包付款条件cfgInfo数组 从小到大
|
||||||
@ -457,7 +480,10 @@ function ShopData:_getCoinGiftPayConditionList()
|
|||||||
if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.COIN_GIFT then
|
if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.COIN_GIFT then
|
||||||
local tmpCfgInfo = clone(cfgInfo)
|
local tmpCfgInfo = clone(cfgInfo)
|
||||||
tmpCfgInfo.id = id
|
tmpCfgInfo.id = id
|
||||||
table.insert(self.coinGiftPayConditionList, cfgInfo)
|
|
||||||
|
Logger.logHighlight("set id:%s", id)
|
||||||
|
|
||||||
|
table.insert(self.coinGiftPayConditionList, tmpCfgInfo)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.sort(self.coinGiftPayConditionList, function (a, b)
|
table.sort(self.coinGiftPayConditionList, function (a, b)
|
||||||
@ -503,7 +529,7 @@ function ShopData:checkAndGetCoinGiftTriggerId()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ShopData:onTriggerCoinGift(actId)
|
function ShopData:onTriggerCoinGift(actId)
|
||||||
self:initCoinGift(actId, Time:getServerTime())
|
self:initCoinGift(actId, Time:getServerTime() * 1000)
|
||||||
-- 标记弹窗
|
-- 标记弹窗
|
||||||
self:markPopUpGift(PayManager.PURCHARSE_TYPE.ACT_GIFT, actId)
|
self:markPopUpGift(PayManager.PURCHARSE_TYPE.ACT_GIFT, actId)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user