local GrowthFund_Controller = {} local private = {} local GROWTHFUND_NEW_KEY = "GrowthFund_New" function GrowthFund_Controller.GetCurrentGrowthFundId() local allFundID = CTL.PayMall.GetAllGrowthFundID() local returnId -- 顺序找到第一个没完成的,如果都完成了就取最后一个 for _, fundID in ipairs(allFundID) do returnId = fundID if not GrowthFund_Controller.IsHasGrowthFundGetOver(fundID) then break -- 有没完成的就跳出 end end if not returnId then returnId = allFundID[1] --一个都没完成,就留在在首层 end --logging.log(LTAG.LOG, "cur fundid:",returnId) return returnId end --成长基金是否领完 function GrowthFund_Controller.IsHasGrowthFundGetOver(fundID) local preferentialOrderCfg = DataSheetManager.PreferentialOrder:GetDataByID(fundID) if preferentialOrderCfg and preferentialOrderCfg.HideTriggerID > 0 then if MDL.Unlock.IsTriggerIdComplete(preferentialOrderCfg.HideTriggerID) then return true end end return false end ---@return 成长基金红点 function GrowthFund_Controller.IsHasGrowthFundToGet() return private.IsHasGrowthFundToGetByFundID() end function private.IsHasGrowthFundToGetByFundID() local allFundID = CTL.PayMall.GetAllGrowthFundID() if allFundID then for _, fundID in ipairs(allFundID) do local fundList = MDL.GrowthFund.GetGrowFundByFundID(fundID) if fundList ~= nil then for _, v in ipairs(fundList.FundSubInfos) do if v.State == MDL.GrowthFund.SubItemStateType.Finished then return true end end end end end return false end ---@return 官职基金红点 function GrowthFund_Controller.IsHasOfficialPositionFundToGet() local fundList = MDL.GrowthFund.GetGrowFundByFundID(CTL.PayMall.ShopChildTabType.OfficialPositionFund) if fundList ~= nil then for k,v in ipairs(fundList.FundSubInfos) do if v.State == MDL.GrowthFund.SubItemStateType.Finished then return true end end end return false end --成长基金首次展示逻辑,参考0元购FreeBuy的逻辑 --首次展示某个礼包的红点,需要存盘,跟随账号. function GrowthFund_Controller.SetFirstShow(fundID) local dataChange = false if not fundID then return dataChange end dataChange = true local t = PersistentData.PlayerData:Get(GROWTHFUND_NEW_KEY) if not t then t = {} end for _, v in ipairs(t) do if v.fundID == fundID then dataChange = false --本来就有这个数据,不用插入了 break end end if dataChange then table.insert(t, { fundID = fundID }) PersistentData.PlayerData:Set(GROWTHFUND_NEW_KEY, t, true) end return dataChange end function GrowthFund_Controller.GetFirstShowRP(fundID) if not fundID or not PersistentData.PlayerData then return false --无数据,不显示红点 end local t = PersistentData.PlayerData:Get(GROWTHFUND_NEW_KEY) if t then for _, v in ipairs(t) do if v.fundID == fundID then return false --能找到数据说明已经展示过了,不再显示红点 end end end return true --找不到数据说明没展示过,可显示红点 end function GrowthFund_Controller.HasFirstShowRP() if not MDL.GrowthFund.FundDataInited() then return false end local id = GrowthFund_Controller.GetCurrentGrowthFundId() local showRp = GrowthFund_Controller.GetFirstShowRP(id) return showRp end return GrowthFund_Controller