金币礼包逻辑调整

This commit is contained in:
CloudJ 2023-05-25 16:30:10 +08:00
parent cc674c3204
commit b784b7aeda
4 changed files with 41 additions and 10 deletions

View File

@ -152,7 +152,9 @@ function ShopManager:tryTriggerCoinGift()
end
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
return ShopManager

View File

@ -72,7 +72,7 @@ function CoinSellCell:refresh()
self.priceText2:setText(GFunc.getFormatPrice(cfgInfo.recharge_id))
-- 限时
self.timeImg:setVisible(true)
self:updateTime()
self:refreshTime()
self:addClickListener(function()
self:onClickGift(actGiftId)
@ -96,12 +96,12 @@ function CoinSellCell:onClickGift(id)
PayManager:purchasePackage(id, PayManager.PURCHARSE_TYPE.ACT_GIFT)
end
function CoinSellCell:updateTime()
function CoinSellCell:refreshTime()
local remainTime = 0
local actId = DataManager.ShopData:getValidCoinGiftId()
if actId then
local cfgInfo = self:getActGiftConfig()[actId]
local triggerTime = self:getCoinGiftTriggerTime()
if actId > 0 then
local cfgInfo = DataManager.ShopData:getActGiftConfig()[actId]
local triggerTime = DataManager.ShopData:getCoinGiftTriggerTime()
remainTime = triggerTime + (cfgInfo.limit_time or 0) * 3600 - Time:getServerTime()
if remainTime <= 0 then
remainTime = 0

View File

@ -138,6 +138,9 @@ function ShopComp:refreshTime()
if self.hotSellCell and self.hotSellCell:getIsOpen() then
self.hotSellCell:refreshTime()
end
if self.coinSellCell and self.coinSellCell:getIsOpen() then
self.coinSellCell:refreshTime()
end
end
function ShopComp:refreshDiscountPage()

View File

@ -384,8 +384,14 @@ function ShopData:initLevelUpGift(levelUpGift)
end
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.coinGiftTriggerTime = triggerTime or 0 -- 金币礼包触发时间
self:setDirty()
end
function ShopData:getPayAmount()
@ -436,7 +442,7 @@ function ShopData:getCoinGiftTriggerTime()
return self.coinGiftTriggerTime // 1000
end
-- 获得当前时间还处于有效的金币礼包id
-- 获得当前可购买的金币礼包id,需要未购买且时间满足
function ShopData:getValidCoinGiftId()
local actId = self:getCoinGiftId()
if actId > 0 then
@ -444,9 +450,26 @@ function ShopData:getValidCoinGiftId()
local triggerTime = self:getCoinGiftTriggerTime()
local remainTime = triggerTime + (cfgInfo.limit_time or 0) * 3600 - Time:getServerTime()
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
return nil
end
-- 获取金币礼包付款条件cfgInfo数组 从小到大
@ -457,7 +480,10 @@ function ShopData:_getCoinGiftPayConditionList()
if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.COIN_GIFT then
local tmpCfgInfo = clone(cfgInfo)
tmpCfgInfo.id = id
table.insert(self.coinGiftPayConditionList, cfgInfo)
Logger.logHighlight("set id:%s", id)
table.insert(self.coinGiftPayConditionList, tmpCfgInfo)
end
end
table.sort(self.coinGiftPayConditionList, function (a, b)
@ -503,7 +529,7 @@ function ShopData:checkAndGetCoinGiftTriggerId()
end
function ShopData:onTriggerCoinGift(actId)
self:initCoinGift(actId, Time:getServerTime())
self:initCoinGift(actId, Time:getServerTime() * 1000)
-- 标记弹窗
self:markPopUpGift(PayManager.PURCHARSE_TYPE.ACT_GIFT, actId)
end