diff --git a/lua/app/common/bi_report.lua b/lua/app/common/bi_report.lua index f0f9011b..867c4168 100644 --- a/lua/app/common/bi_report.lua +++ b/lua/app/common/bi_report.lua @@ -76,7 +76,9 @@ BIReport.ITEM_GET_TYPE = { MALL_DAILY = "MallDaily", -- 每日特惠 MALL_DAILY_RESET = "MallDailyReset", FIRST_RECHARGE = "FirstRecharge", + COIN_GIFT = "CoinGift", BEGINNER_GIFT = "BeginnerGift", + LEVEL_UP_GIFT = "LevelUpGift", ACT_CHAPTER_STORE = "ActChapterStore", -- 章节礼包 SUMMON = "Summon", PLAYER_LV_UP = "PlayerLvUp", @@ -124,7 +126,9 @@ BIReport.BATTLE_TYPE = { BIReport.GIFT_TYPE = { FIRST_RECHARGE = "FirstRecharge", + COIN_GIFT = "CoinGift", BEGINNER_GIFT = "BeginnerGift", + LEVEL_UP_GIFT = "LevelUpGift", BOUNTY = "Bounty", GOLD_PIG = "GoldPig", MALL_TREASURE = "MallTreasure", diff --git a/lua/app/common/pay_manager.lua b/lua/app/common/pay_manager.lua index 45a7d674..0cc28857 100644 --- a/lua/app/common/pay_manager.lua +++ b/lua/app/common/pay_manager.lua @@ -12,7 +12,9 @@ PayManager.PURCHARSE_TYPE = { PayManager.PURCHARSE_ACT_TYPE = { FIRST_RECHARGE = 1, + COIN_GIFT = 2, BEGINNER_GIFT = 4, + LEVEL_UP_GIFT = 5, BOUNTY = 7, } @@ -26,7 +28,9 @@ PayManager.PURCHARSE_TYPE_CONFIG = { PayManager.BI_ITEM_GET_TYPE = { [PayManager.PURCHARSE_TYPE.ACT_GIFT] = { [PayManager.PURCHARSE_ACT_TYPE.FIRST_RECHARGE] = BIReport.ITEM_GET_TYPE.FIRST_RECHARGE, + [PayManager.PURCHARSE_ACT_TYPE.COIN_GIFT] = BIReport.ITEM_GET_TYPE.COIN_GIFT, [PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT] = BIReport.ITEM_GET_TYPE.BEGINNER_GIFT, + [PayManager.PURCHARSE_ACT_TYPE.LEVEL_UP_GIFT] = BIReport.ITEM_GET_TYPE.LEVEL_UP_GIFT, [PayManager.PURCHARSE_ACT_TYPE.BOUNTY] = BIReport.ITEM_GET_TYPE.BOUNTY, }, [PayManager.PURCHARSE_TYPE.ACT_GOLD_PIG] = BIReport.ITEM_GET_TYPE.GOLD_PIG, @@ -37,7 +41,9 @@ PayManager.BI_ITEM_GET_TYPE = { PayManager.BI_GIFT_TYPE = { [PayManager.PURCHARSE_TYPE.ACT_GIFT] = { [PayManager.PURCHARSE_ACT_TYPE.FIRST_RECHARGE] = BIReport.GIFT_TYPE.FIRST_RECHARGE, + [PayManager.PURCHARSE_ACT_TYPE.COIN_GIFT] = BIReport.GIFT_TYPE.COIN_GIFT, [PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT] = BIReport.GIFT_TYPE.BEGINNER_GIFT, + [PayManager.PURCHARSE_ACT_TYPE.LEVEL_UP_GIFT] = BIReport.GIFT_TYPE.LEVEL_UP_GIFT, [PayManager.PURCHARSE_ACT_TYPE.BOUNTY] = BIReport.GIFT_TYPE.BOUNTY, }, [PayManager.PURCHARSE_TYPE.ACT_GOLD_PIG] = BIReport.GIFT_TYPE.GOLD_PIG, diff --git a/lua/app/common/server_push_manager.lua b/lua/app/common/server_push_manager.lua index 37c20b8b..0b2b0fb5 100644 --- a/lua/app/common/server_push_manager.lua +++ b/lua/app/common/server_push_manager.lua @@ -16,7 +16,8 @@ function ServerPushManager:initWhenLogin() self:addServerPushListener(ProtoMsgType.FromMsgEnum.BountyBoughtNtf, ModuleManager.BountyManager, ModuleManager.BountyManager.onBoughtBountyFinish) self:addServerPushListener(ProtoMsgType.FromMsgEnum.NewMailNtf, ModuleManager.MailManager, ModuleManager.MailManager.needUpdateMail) self:addServerPushListener(ProtoMsgType.FromMsgEnum.PigLevelUpNtf, ModuleManager.ActivityManager, ModuleManager.ActivityManager.onBoughtGoldPigFinish) - self:addServerPushListener(ProtoMsgType.FromMsgEnum.MallDailyResetNtf, ModuleManager.ShopManager, ModuleManager.MailManager.onMallDailyReset) + self:addServerPushListener(ProtoMsgType.FromMsgEnum.TriggerLevelUpGiftNtf, ModuleManager.ShopManager, ModuleManager.ShopManager.triggerLevelUpGift) + self:addServerPushListener(ProtoMsgType.FromMsgEnum.MallDailyResetNtf, ModuleManager.ShopManager, ModuleManager.ShopManager.onMallDailyReset) end ---- 移除全局推送监听 diff --git a/lua/app/module/shop/shop_manager.lua b/lua/app/module/shop/shop_manager.lua index ee6cf98c..ddfde8a9 100644 --- a/lua/app/module/shop/shop_manager.lua +++ b/lua/app/module/shop/shop_manager.lua @@ -129,4 +129,9 @@ function ShopManager:buyMallIdleCoinFinish(result) end end +-- 推送助力礼包 +function ShopManager:triggerLevelUpGift(result) + DataManager.ShopData:triggerLevelUpGift(result.current_level_up_gift) +end + return ShopManager \ No newline at end of file diff --git a/lua/app/ui/shop/cell/level_sell_cell.lua b/lua/app/ui/shop/cell/level_sell_cell.lua index 1725c6fa..20835a41 100644 --- a/lua/app/ui/shop/cell/level_sell_cell.lua +++ b/lua/app/ui/shop/cell/level_sell_cell.lua @@ -23,13 +23,12 @@ function LevelSellCell:init() end function LevelSellCell:refresh() - -- 暂无数据部分 测试用 TODOJ - local tmpIds = {50102, 50402} + local actIds = #DataManager.ShopData:getLevelUpGiftActIds() self.actGiftCfg = {} local actGiftCfg = ConfigManager:getConfig("act_gift") - for i = 1, #tmpIds do - local cfgInfo = clone(actGiftCfg[tmpIds[i]]) - cfgInfo.id = tmpIds[i] + for i = 1, #actIds do + local cfgInfo = clone(actGiftCfg[actIds[i]]) + cfgInfo.id = actIds[i] table.insert(self.actGiftCfg, cfgInfo) end self.scrollRect:refillCells(#self.actGiftCfg) @@ -44,7 +43,7 @@ function LevelSellCell:getCellHeight() end function LevelSellCell:getIsOpen() - return true -- TOODJ + return #DataManager.ShopData:getLevelUpGiftActIds() > 0 end function LevelSellCell:setVisible(visible) diff --git a/lua/app/userdata/shop/shop_data.lua b/lua/app/userdata/shop/shop_data.lua index bb109f3c..7c541740 100644 --- a/lua/app/userdata/shop/shop_data.lua +++ b/lua/app/userdata/shop/shop_data.lua @@ -53,6 +53,10 @@ function ShopData:initActGift(act) self:setDirty() end +function ShopData:getActGiftConfig() + return ConfigManager:getConfig("act_gift") +end + -- 已购买的礼包 function ShopData:getActGiftMap() return self.giftMap @@ -124,6 +128,41 @@ function ShopData:getPopUpGift() return self.needPopUpGift end +-- 获取下一个需要弹出的礼包数据 +function ShopData:getNextPopGiftData() + local popUpGift = self:getPopUpGift() + if popUpGift then + for actType, actIdList in pairs(popUpGift) do + -- 弹窗顺序待处理 TODOJ + for _, actId in ipairs(actIdList) do + return actType, actId + end + end + end +end + +-- 上次支付的时间 +function ShopData:getLastPayTime() + -- TODOJ +end + +-- 包含了降档规则的支付总额(目前影响助力和金币礼包) +function ShopData:getTotalPayAmountWithTime() + local total = DataManager.PlayerData:getTotalPayAmount() + local lastPayTime = self:getLastPayTime() + if lastPayTime then + diffTime = Time:getServerTime() - lastPayTime // 1000 + local dTime = GFunc.getConstIntValue("act_gift_downshift_time") or 72 -- 每X小时 + local dValue = GFunc.getConstIntValue("act_gift_downshift_number") or 15 -- 降低X金额 + local dCount = diffTime // (dTime * 3600) + total = total - dCount * dValue + if total < 0 then + total = 0 + end + end + return total +end + -- 通用礼包结束 ---------------------------------------------------------------------------------------------- -- 每日特惠部分 ********************************************************************************************** @@ -330,19 +369,6 @@ function ShopData:markPopUpGiftForActChapterStore(chapterId) self:markPopUpGift(PayManager.PURCHARSE_TYPE.CHAPTER_GIFT, actId) end --- 获取下一个需要弹出的礼包数据 -function ShopData:getNextPopGiftData() - local popUpGift = self:getPopUpGift() - if popUpGift then - for actType, actIdList in pairs(popUpGift) do - -- 弹窗顺序待处理 TODOJ - for _, actId in ipairs(actIdList) do - return actType, actId - end - end - end -end - -- 章节礼包结束 ---------------------------------------------------------------------------------------------- -- 新手礼包 ********************************************************************************************** @@ -360,12 +386,52 @@ end -- 新手礼包结束 ---------------------------------------------------------------------------------------------- +-- 助力礼包(等级 act_gift) ********************************************************************************************** + +-- 初始化助力礼包 +function ShopData:initLevelUpGift(levelUpGift) + self.levelUpGifts = levelUpGift or {} -- [{trigger_level,current_level_up_gift,trigger_at}] + + self:setDirty() +end + +function ShopData:getLevelUpGift() + return self.levelUpGifts +end + +function ShopData:triggerLevelUpGift(gift) + table.insert(self.levelUpGifts, gift) + -- 标记弹窗 + self:markPopUpGift(PayManager.PURCHARSE_TYPE.ACT_GIFT, gift.current_level_up_gift) +end + +function ShopData:removeLevelUpGift(actId) + for index, gift in ipairs(self.levelUpGifts) do + if gift.current_level_up_gift == actId then + table.remove(self.levelUpGifts, index) + break + end + end +end + +-- 获得可购买的助力礼包Ids +function ShopData:getLevelUpGiftActIds() + local list = {} + for index, gift in ipairs(self.levelUpGifts) do + table.insert(list, gift.current_level_up_gift) + end + table.sort(list) + return list +end + +-- 助力礼包结束 ---------------------------------------------------------------------------------------------- + +-- 成长礼包 ********************************************************************************************** + -- 初始化成长礼包 function ShopData:initGrowUpGift(growUpGift) end --- 初始化助力礼包 -function ShopData:initLevelUpGift(levelUpGift) -end +-- 成长礼包结束 ---------------------------------------------------------------------------------------------- return ShopData \ No newline at end of file