diff --git a/lua/app/module/shop/shop_manager.lua b/lua/app/module/shop/shop_manager.lua index d6a4035b..a24884ef 100644 --- a/lua/app/module/shop/shop_manager.lua +++ b/lua/app/module/shop/shop_manager.lua @@ -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 \ No newline at end of file diff --git a/lua/app/ui/shop/cell/coin_sell_cell.lua b/lua/app/ui/shop/cell/coin_sell_cell.lua index 0cc3513a..f71a6c01 100644 --- a/lua/app/ui/shop/cell/coin_sell_cell.lua +++ b/lua/app/ui/shop/cell/coin_sell_cell.lua @@ -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 diff --git a/lua/app/ui/shop/shop_comp.lua b/lua/app/ui/shop/shop_comp.lua index 8a1d290f..9bc3d06d 100644 --- a/lua/app/ui/shop/shop_comp.lua +++ b/lua/app/ui/shop/shop_comp.lua @@ -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() diff --git a/lua/app/userdata/shop/shop_data.lua b/lua/app/userdata/shop/shop_data.lua index bdf01f7e..f5504626 100644 --- a/lua/app/userdata/shop/shop_data.lua +++ b/lua/app/userdata/shop/shop_data.lua @@ -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