local PushInterface_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') -- key组合格式 UIViewName 数据前缀 用户acid local SAVE_KEY_FORMAT = "PUSHINTERFACE_%s_%s_%s" local SAVE_KEY_PREFIX_VISITTIME = "VISITTIME" local SAVE_KEY_PREFIX_VISITCOUNT = "VISITCOUNT" local SAVE_KEY_PREFIX_SKIP = "ISSKIP" local SAVE_KEY_PREFIX_CHARGELEVEL = "PUSHINTERFACE_CHARGELEVEL_" local SAVE_KEY_PREFIX_CHARGETIME = "PUSHINTERFACE_CHARGETIME_" local PUSH_INTERFACE_TIME_KEY = "PUSH_INTERFACE_TIME_KEY" --诸葛亮预热打脸图 开始时间id local LiveBroadcastTimeId = 8971 local LiveBroadcastRewardId = 8972 -- 测试用显示登录打脸图不显示原因 ------------------------------------ 系统函数 -------------------------------------- local IsShowLoginReason = true --对应PushInterface 的id PushInterface_Controller.PushInterfaceEnum = { LiveBroadcast1 = 35, --直播预告 LiveBroadcast2 = 36, --直播预告带领奖 DouYin = 22, --抖音关注 FourteenDayReward = 202, --新人14日登录礼 } function PushInterface_Controller.OnStartup() EventSystem.Regist(EventID.FunctionUnlockUpdate, private.OnFunctionUnlockUpdate) private.viewClass2PushInterfaceDict = LuaExt.CreateTable(0, DataSheetManager.PushInterface:GetDataCount()) private.viewClass2SaveProperties = LuaExt.CreateTable(0, DataSheetManager.PushInterface:GetDataCount()) private.id2OperationParams = LuaExt.CreateTable(DataSheetManager.PushInterface:GetDataCount()) private.id2TableParams = LuaExt.CreateTable(DataSheetManager.PushInterface:GetDataCount()) for i, v in DataSheetManager.PushInterface:GetEnumerator() do --todo 这里之前拿ViewClass 做key 但是现在key 可能重复 所以有PrefabPath时 用PrefabPath 做key 但是如果PrefabPath也重复呢 目前暂时没有 --最好按照表id 做key 这就要改所有打脸图 if not string.isNilOrEmpty(v.PrefabPath) then private.viewClass2PushInterfaceDict[v.PrefabPath] = v else private.viewClass2PushInterfaceDict[v.ViewClass] = v end private.id2OperationParams[v.ID] = not string.isNilOrEmpty(v.OpreationParam) and string.split(v.OpreationParam, ",") or nil if v.TableParam_Table and #v.TableParam_Table > 0 then local params = LuaExt.CreateTable(#v.TableParam_Table) for _, v in ipairs (v.TableParam_Table) do table.insert(params, string.split(v.Condition, ",")) end private.id2TableParams[v.ID] = params end end private.curPlayIndexIndex = -1 private.containIDDict = {} private.idList = {} private.isTriggerLogin = false private.hasExcuteLogin = false end function PushInterface_Controller.OnShutdown() private.viewClass2SaveProperties = nil private.viewClass2PushInterfaceDict = nil private.id2OperationParams = nil private.id2TableParams = nil private.containIDDict = nil private.idList = nil end ---------------------------------------------------------------------------------- --===================================================== 对外公有函数 =========================================================-- -- 触发打脸图流程 在主城延迟界面展示完触发 function PushInterface_Controller.TriggerExcutePushInterface() if not private.isTriggerLogin then private.isTriggerLogin = true for _, v in DataSheetManager.PushInterface:GetEnumerator() do local isCanShowLogin, reasonStr = PushInterface_Controller.IsCanShowLogin(v.ID) if isCanShowLogin then private.InsertPushInterfaceID(v.ID) elseif not string.isNilOrEmpty(reasonStr) then -- logging.log(LTAG.ERROR, reasonStr) end end end private.TriggerExcutePushInterface() end -- 判断当前打脸图是否存在于队列 是否已经执行过 function PushInterface_Controller.IsContainAndExcutePushInterfaceID(id) for i, v in ipairs (private.idList) do if v == id then return true, private.curPlayIndexIndex ~= -1 and private.curPlayIndexIndex >= i end end return false, false end -- 当前是否处于打脸图流程中 function PushInterface_Controller.IsInPushInterfaceState() return private.curPlayIndexIndex ~= -1 end -- 是否显示过登录打脸图 function PushInterface_Controller.IsShowLoginPushInterface() return private.hasExcuteLogin end -- 打开打脸系统管理界面 function PushInterface_Controller.OpenPushInterface(id) if CTL.HotFix.CheckAssetIsReady("PushInterface") == false then return end local cfg = DataSheetManager.PushInterface:GetDataByID(id) if cfg then local context local prefabPath if not string.isNilOrEmpty(cfg.OpenParam) then -- 解析传递参数 context = cfg.OpenParam end if cfg.ViewClass == Const_UI_Lua.UIEnum.UIWelfareReservedGift then -- 预约豪礼特殊处理 context = {isPopUpView = true} prefabPath = Const_UI_Lua.UIEnum.UIReservedGiftWindow elseif cfg.ViewClass == Const_UI_Lua.UIEnum.UIPushInterfaceStage1 or cfg.ViewClass == Const_UI_Lua.UIEnum.UIPushInterfaceStage2 or cfg.ViewClass == Const_UI_Lua.UIEnum.UIPushInterfaceStage3 or cfg.ViewClass == Const_UI_Lua.UIEnum.UIPushInterfaceStage4 or cfg.ViewClass == Const_UI_Lua.UIEnum.UIPushInterfaceStage5 then prefabPath = Const_UI_Lua.UIEnum.UIPushInterfaceHegemony elseif not string.isNilOrEmpty(cfg.PrefabPath) then prefabPath = cfg.PrefabPath context = private.GetViewContext(cfg.ID) end if CTL.HotFix.CanAssetLoad(prefabPath or cfg.ViewClass) then UIManager.OpenView(cfg.ViewClass, context, prefabPath or cfg.ViewClass) end else private.ShowNextPushInterface() end end function private.GetViewContext(pushInterfaceEnum) if pushInterfaceEnum == PushInterface_Controller.PushInterfaceEnum.LiveBroadcast1 then return {pushInterfaceEnum = pushInterfaceEnum} elseif pushInterfaceEnum == PushInterface_Controller.PushInterfaceEnum.LiveBroadcast2 then return {pushInterfaceEnum = pushInterfaceEnum} elseif pushInterfaceEnum == PushInterface_Controller.PushInterfaceEnum.DouYin then local liveBroadcastAward = DataSheetManager.ConstData:GetDataByID("FollowTiktokAward").IntListValue return {pushInterfaceEnum = pushInterfaceEnum, rewardList = liveBroadcastAward} elseif pushInterfaceEnum == PushInterface_Controller.PushInterfaceEnum.FourteenDayReward then return {pushInterfaceEnum = pushInterfaceEnum} end end -- 显示打脸系统管理界面 function PushInterface_Controller.ShowPushInterface(classPath, toggle_Skip) local cfg = PushInterface_Controller.GetCfgByViewClass(classPath) if cfg then if PushInterface_Controller.IsInPushInterfaceState() then -- 如果执行打脸图流程 if not PushInterface_Controller.IsShowLoginPushInterface() then -- 只有登录打脸流程显示跳过逻辑 统计跳过次数和访问次数 特殊处理战区打脸图也按登录逻辑处理 local properties = private.GetSaveProperties(classPath) -- 只有登录打脸显示跳过逻辑 if toggle_Skip then toggle_Skip.isOn = properties.isSkip -- 一天只显示一次的打脸图 不显示跳过按钮 UIUtils.SetActive(toggle_Skip, cfg.Times ~= 1) end -- 增加访问次数 private.SaveVisitState(properties, true) else if toggle_Skip then UIUtils.SetActive(toggle_Skip, false) end end else if toggle_Skip then UIUtils.SetActive(toggle_Skip, false) end end end end -- 关闭打脸系统管理界面 function PushInterface_Controller.HidePushInterface(classPath, toggle_Skip) if PushInterface_Controller.GetCfgByViewClass(classPath) then -- 如果执行打脸图流程 if PushInterface_Controller.IsInPushInterfaceState() then if not PushInterface_Controller.IsShowLoginPushInterface() then -- 只有登录打脸流程保存是否跳过选项 local properties = private.GetSaveProperties(classPath) if toggle_Skip then private.SaveSkipState(properties, toggle_Skip.isOn) end end -- 触发下一个打脸图 private.ShowNextPushInterface() end end end function PushInterface_Controller.GetCfgByViewClass(classPath) if classPath then return private.viewClass2PushInterfaceDict[classPath] end return nil end -- 触发打脸图 function PushInterface_Controller.TriggerUnlockPushInterface(viewClass, isUnlock) -- 未完成登录打脸 不能手动触发 if not PushInterface_Controller.IsShowLoginPushInterface() then return false end local cfg = private.viewClass2PushInterfaceDict[viewClass] if not cfg then return false end if isUnlock then private.InsertPushInterfaceID(cfg.ID) private.TriggerExcutePushInterface() else local isContain, isExcute = PushInterface_Controller.IsContainAndExcutePushInterfaceID(cfg.ID) if isContain and not isExcute then private.RemovePushInterfaceID(cfg.ID) end end return true end -- 判断是否登录显示 function PushInterface_Controller.IsCanShowLogin(id) local cfg = DataSheetManager.PushInterface:GetDataByID(id) local reasonStr = not IsShowLoginReason and "" or nil if cfg then if not cfg.IsLoginShow then reasonStr = reasonStr or "打脸ID:" .. id .. "不是登录显示" return false, reasonStr end local properties = nil if not string.isNilOrEmpty(cfg.PrefabPath) then properties = private.GetSaveProperties(cfg.PrefabPath) else properties = private.GetSaveProperties(cfg.ViewClass) end -- 重置时间和访问次数 private.SaveVisitState(properties) -- 是否跳过 if properties.isSkip and properties.visitCount > 0 then reasonStr = reasonStr or "打脸ID:" .. id .. "执行跳过逻辑 访问次数:" .. properties.visitCount return false, reasonStr end -- 关注有礼 if cfg.ViewClass == Const_UI_Lua.UIEnum.UIPushInterfaceAttention then if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Attention) then reasonStr = reasonStr or "打脸ID:" .. id .. " 关注有礼功能尚未开启" return false, reasonStr end if SDKUtil.ChannelID ~= LuaConst.SDKChannelId.Hero_Android and SDKUtil.ChannelID ~= LuaConst.SDKChannelId.Hero_iOS then reasonStr = reasonStr or "【策划注意!!!!】 打脸ID:" .. id .. " 不能在改渠道显示" return false, reasonStr end local state = MDL.Attention.GetAttentionState(CTL.Welfare.WelfareType.AttentionReward) if state ~= nil and state ~= MDL.Attention.AttentionState.Initial then reasonStr = reasonStr or "打脸ID:" .. id .. " 关注有礼奖励已经可领取 or 已经领取完成" return false, reasonStr end end -- 抖音关注福利 if cfg.PrefabPath == Const_UI_Lua.UIEnum.UIPushInterfaceDouYin then if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.FollowDouYin) then reasonStr = reasonStr or "打脸ID:" .. id .. " 抖音号打脸图功能尚未开启" return false, reasonStr end if SDKUtil.ChannelID ~= LuaConst.SDKChannelId.Hero_Android and SDKUtil.ChannelID ~= LuaConst.SDKChannelId.Hero_iOS then reasonStr = reasonStr or "【策划注意!!!!】 打脸ID:" .. id .. " 不能在该渠道显示" return false, reasonStr end local state = MDL.Attention.GetAttentionState(CTL.Welfare.WelfareType.DouYinReward) if state ~= nil and state ~= MDL.Attention.AttentionState.Initial then reasonStr = reasonStr or "打脸ID:" .. id .. " 抖音号打脸图奖励已经可领取 or 已经领取完成" return false, reasonStr end end -- 苹果评分 if cfg.viewClass == Const_UI_Lua.UIEnum.UICommonFakeScore then local show, r = private.CanShowCommonFakeScore(id) if not show then reasonStr = reasonStr or r return false, reasonStr end end -- 功能解锁 if not string.isNilOrEmpty(cfg.UnlockParam) and MDL.Unlock.FunctionType[cfg.UnlockParam] then local unlockFuncType = MDL.Unlock.FunctionType[cfg.UnlockParam] if not MDL.Unlock.IsUnlock(unlockFuncType) then -- 累充信息重置 private.RechargeInfoFunc(properties, -1, -1) reasonStr = reasonStr or "打脸ID:" .. id .. "功能未解锁" return false, reasonStr end if unlockFuncType == MDL.Unlock.FunctionType.ReservedGift and not MDL.ReservedGift.GetIsShowReservedGift() then -- 预约豪礼特殊判断 reasonStr = reasonStr or "打脸ID:" .. id .. "预约豪礼未开启" return false, reasonStr elseif unlockFuncType == MDL.Unlock.FunctionType.DailySignin and not MDL.DailySignin.HaveCanReceiveReward() then -- 月签到特殊判断 reasonStr = reasonStr or "打脸ID:" .. id .. "月签到无可领取奖励" return false, reasonStr elseif unlockFuncType == MDL.Unlock.FunctionType.GoldHeroPreview and not CTL.GoldHeroPreview.CheckShowGoldHeroPreviewEntry() then -- 金将预览特殊判断 reasonStr = reasonStr or "打脸ID:" .. id .. "金奖预览无解锁相关金将" return false, reasonStr end end -- 累充特殊处理 if properties.rechargeParams then local rechargeParams = properties.rechargeParams if not CTL.MultilevelRecharge.IsShowAccumulatingRechargeGJ() then -- 累充信息重置 private.RechargeInfoFunc(properties, -1, -1) reasonStr = reasonStr or "打脸ID:" .. id .. "累充积分到达上限" return false, reasonStr end if private.id2TableParams[id] then local score = MDL.Currency.GetTotalRechargeCredit() local level = 0 local day = 0 for i, v in ipairs (private.id2TableParams[id]) do local startScore = tonumber(v[1]) local endScore = tonumber(v[2]) local durationDay = v[3] if score >= startScore and score <= endScore then level = i day = durationDay break end end if level == 0 then -- 累充信息重置 private.RechargeInfoFunc(properties, -1, -1) reasonStr = reasonStr or "打脸ID:" .. id .. "累充档位未查找到" return false, reasonStr end if rechargeParams.level < level then -- 重置显示时间 以当前天的起始时间为准 private.RechargeInfoFunc(properties, level, UTL.Time.GetDayStartTimestamp()) else local time = UTL.Time.GetServerTimestamp() local startTime = rechargeParams.checkTimeStamp local endTime = rechargeParams.checkTimeStamp + UTL.Time.TotalSecondsOneDay * day if time < startTime or time > endTime then reasonStr = reasonStr or "打脸ID:" .. id .. "累充不在显示时间范围内 起始时间:" .. os.date(UTL.Time.FormatDateEnum.YMDHMS, startTime) .. "结束时间:" .. os.date(UTL.Time.FormatDateEnum.YMDHMS, endTime) .. "持续天数:" .. day return false, reasonStr end end end end -- 活动判断 if private.id2OperationParams[id] then local params = private.id2OperationParams[id] local operationActivityType = MDL.OperationActivity.ActivityType[params[1]] if operationActivityType then local activityIsAvailable = false -- 默认活动第一个详情 local activityInfo local activityInfos = MDL.OperationActivity.GetOperationActivityInfo(operationActivityType) if operationActivityType == MDL.OperationActivity.ActivityType.GoldenHero and MDL.OperationActivity.HotControlInfo then --金将特殊判断开启 if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GoldHeroActivity) then local goldHeroTypeData = MDL.OperationActivity.HotControlInfo:GetDataByActivityType_ActivityID(operationActivityType) if goldHeroTypeData and activityInfos then for i, v in pairs(goldHeroTypeData) do if CTL.OperationActivity.IsOperationActivityUnlock(v) then local activityId = v.ActivityID local heroType = MDL.GoldenHeroMain.GetHeroTypeByActivityId(activityId) if tonumber(params[2]) == DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(heroType).SynergyBossHeroID then activityInfo = activityInfos[activityId] activityIsAvailable = CTL.OperationActivity.IsOperationActivityOpen(activityInfo) and CTL.OperationActivity.IsOperationActivityStillGoing(operationActivityType, activityId) break end end end end end elseif operationActivityType == MDL.OperationActivity.ActivityType.SuperGold and MDL.OperationActivity.HotControlInfo then --彩金特殊判断开启 if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.SuperGoldActivity) then local data = MDL.OperationActivity.HotControlInfo:GetDataByActivityType_ActivityID(operationActivityType) if data and activityInfos then for i, v in pairs(data) do if CTL.OperationActivity.IsOperationActivityUnlock(v) then local activityId = v.ActivityID local heroType = MDL.SuperGoldMain.GetHeroTypeByActivityId(activityId) if tonumber(params[2]) == DataSheetManager.SuperGoldActivityModeData:GetDataByHeroType(heroType).HeroID then activityInfo = activityInfos[activityId] activityIsAvailable = CTL.OperationActivity.IsOperationActivityOpen(activityInfo) and CTL.OperationActivity.IsOperationActivityStillGoing(operationActivityType, activityId) break end end end end end elseif operationActivityType == MDL.OperationActivity.ActivityType.StageSignIn then --十四日特殊判断开启 local hasRewardToCollect, activityId = CTL.SignIn.IsSignInTypeHasRewardToCollect() activityIsAvailable = hasRewardToCollect and MDL.SignIn.IsNeedPushInterFace(activityId) if not activityIsAvailable then reasonStr = reasonStr or "打脸ID:" .. id .. "十四日无可领取奖励" return false, reasonStr end activityInfo = MDL.OperationActivity.GetOperationActivityInfo(operationActivityType, activityId) --号令天下判断开启 elseif operationActivityType == MDL.OperationActivity.ActivityType.BattlefieldMuster then if activityInfos then for _, v in pairs (activityInfos) do activityInfo = v break end end activityIsAvailable = CTL.CommandTheWorld.IsShowActivity() elseif operationActivityType == MDL.OperationActivity.ActivityType.NewYear then local info = MDL.OperationActivity.GetOperationActivityInfo(operationActivityType) if info then for activityId, v in pairs(info) do if CTL.OperationActivity.IsOperationActivityTypeUnlock(operationActivityType) and CTL.OperationActivity.IsOperationActivityOpen(v) and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.NewYear) then local modeData = MDL.OperationActivity.ActivityBaseData[operationActivityType]:GetDataByActivityID(activityId) if modeData.PrefabMode == tonumber(params[2]) then -- 显示次数判断 if cfg.Times > 0 and properties.visitCount >= cfg.Times then reasonStr = reasonStr or "打脸ID:" .. id .. "显示次数超过上限" .. properties.visitCount, cfg.Times return false, reasonStr else return true, reasonStr end end end end end else if activityInfos then for _, v in pairs (activityInfos) do activityInfo = v break end end activityIsAvailable = CTL.OperationActivity.IsOperationActivityTypeOpen(operationActivityType) and CTL.OperationActivity.IsOperationActivityTypeUnlock(operationActivityType) end if not activityInfo or not activityIsAvailable then reasonStr = reasonStr or "打脸ID:" .. id .. "活动未开启" return false, reasonStr end -- 活动持续时间判断 if cfg.Duration > 0 then local startTime = activityInfo.startTime local endTime = startTime + UTL.Time.TotalSecondsOneDay * cfg.Duration local nowTime = UTL.Time.GetServerTimestamp() if nowTime < startTime or nowTime > endTime then reasonStr = reasonStr or "打脸ID:" .. id .. "不在活动显示时间 起始时间:" .. os.date(UTL.Time.FormatDateEnum.YMDHMS, startTime) .. "结束时间:" .. os.date(UTL.Time.FormatDateEnum.YMDHMS, endTime) .. "持续天数:" .. cfg.Duration return false, reasonStr end elseif private.id2TableParams[id] then local isShow = false for _, v in ipairs (private.id2TableParams[id]) do local startDay = v[1] local endDay = v[2] local startTime = activityInfo.startTime + UTL.Time.TotalSecondsOneDay * (startDay - 1) local endTime = activityInfo.startTime + UTL.Time.TotalSecondsOneDay * endDay local nowTime = UTL.Time.GetServerTimestamp() if nowTime >= startTime and nowTime <= endTime then isShow = true break end end if not isShow then for _, v in ipairs (private.id2TableParams[id]) do local startDay = v[1] local endDay = v[2] local startTime = activityInfo.startTime + UTL.Time.TotalSecondsOneDay * (startDay - 1) local endTime = activityInfo.startTime + UTL.Time.TotalSecondsOneDay * endDay local nowTime = UTL.Time.GetServerTimestamp() if nowTime < startTime or nowTime > endTime then reasonStr = reasonStr or "打脸ID:" .. id .. "不在活动 显示时间起始时间:" .. os.date(UTL.Time.FormatDateEnum.YMDHMS, startTime) .. "结束时间:" .. os.date(UTL.Time.FormatDateEnum.YMDHMS, endTime) .. "天数:" .. startDay .. "-" .. endDay break end end return false, reasonStr end end end end -- 天地群雄 if cfg.ViewClass == Const_UI_Lua.UIEnum.UIPushInterfaceHeroMatch1v1 then reasonStr = reasonStr or "打脸ID:" .. id .. "天地群雄体验打脸图,仅在报名阶段显示" if MDL.HeroMatch1v1.GetCurStageID() == MDL.HeroMatch1v1.Stage.Join and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HeroMatch1v1) then return true, reasonStr else return false, reasonStr end end -- 天地群雄 if cfg.ViewClass == Const_UI_Lua.UIEnum.UIPushInterfaceHeroMatch3v3 then reasonStr = reasonStr or "打脸ID:" .. id .. "天地群雄3v3体验打脸图,仅在报名阶段显示" if MDL.HeroMatch3v3.GetCurStageID() == MDL.HeroMatch3v3.Stage.Join and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HeroMatch3v3) then return true, reasonStr else return false, reasonStr end end --天下会武预告 if cfg.ViewClass == Const_UI_Lua.UIEnum.UIPushInterfaceFairSoloTournament then reasonStr = reasonStr or "打脸ID:" .. id .. "天下会武打脸图,仅在报名阶段显示" if MDL.FairSoloTournament.GetCurStageID() == MDL.FairSoloTournament.ConfigStage.Prepare and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.FairSoloTournament) then return true, reasonStr else return false, reasonStr end end --天下会武邀请函 if cfg.ViewClass == Const_UI_Lua.UIEnum.UIFairSoloTournamentInvitation then reasonStr = reasonStr or "打脸ID:" .. id .. "天下会武打脸图,在小组赛前显示" local curStageId = MDL.FairSoloTournament.GetCurStageID() if MDL.FairSoloTournament.GetIfInGroup() and curStageId > MDL.FairSoloTournament.ConfigStage.Prepare and curStageId <= MDL.FairSoloTournament.ConfigStage.Group_2 and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.FairSoloTournament) then return true, reasonStr else return false, reasonStr end end -- 天下会武3v3 if cfg.ViewClass == Const_UI_Lua.UIEnum.UIPushInterfaceTeamFairChampionship then reasonStr = reasonStr or "打脸ID:" .. id .. "天下会武33体验打脸图,仅在报名阶段显示" if MDL.TeamFairChampionship.GetCurStageID() == MDL.TeamFairChampionship.Stage.Join and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.TeamFairChampionship) then return true, reasonStr else return false, reasonStr end end --天下会武3v3邀请函 if cfg.ViewClass == Const_UI_Lua.UIEnum.UITeamFairChampionshipInvitation then reasonStr = reasonStr or "打脸ID:" .. id .. "天下会武打脸图,在小组赛前显示" if MDL.TeamFairChampionship.GetMyFilterGroupId()>0 and CTL.TeamFairChampionship.IsFilterMatchStage() and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.TeamFairChampionship) then return true, reasonStr else return false, reasonStr end end --渠道专属充值返利活动 if cfg.ViewClass == Const_UI_Lua.UIEnum.UIDouYinRechargeReward then if MDL.DouYinRechargeReward.CurActivityIsHasNotVisit() and CTL.DouYinRechargeReward.IsCanShowEntrance() then return true else return false, "打脸ID:" .. id .. "渠道专属充值返利活动打脸图已查看或活动未开启" end end --王者挑战新赛季开启弹窗 if cfg.ViewClass == Const_UI_Lua.UIEnum.UIKingChallengeSeasonOpen then if CTL.KingChallenge.IsShowNewSeasonPopUp() then return true else return false, "打脸ID:" .. id .. "王者挑战新赛季开启弹窗已查看或未开启" end end -- 自定义Condition处理 local paramTable = private.id2TableParams[id] and private.id2TableParams[id][1] or nil if cfg.ViewClass == Const_UI_Lua.UIEnum.UIPushInterfaceGuildWar then if not CTL.GuildWar.IsGuildWarCrossServerPushInterface() then return false, "打脸ID :".. id .. ",势力战跨服不在打脸时间范围之内" end elseif cfg.ViewClass == Const_UI_Lua.UIEnum.UIPushInterfaceLvbu then local serverDay = MDL.Player.GetServerDayCount() if serverDay < tonumber(paramTable[1]) or serverDay > tonumber(paramTable[2]) then return false, "打脸ID : "..id..", 势力拍卖打脸图不在时间范围内 "..serverDay end end if cfg.ID == PushInterface_Controller.PushInterfaceEnum.LiveBroadcast1 then if not private.IsInTime(LiveBroadcastTimeId, cfg.Duration) then return false, "打脸ID : "..id..", 不在时间范围内 " end end if cfg.ID == PushInterface_Controller.PushInterfaceEnum.LiveBroadcast2 then if not private.IsInTime(LiveBroadcastRewardId, cfg.Duration) then return false, "打脸ID : "..id..", 不在时间范围内 " end end -- 显示次数判断 if cfg.Times > 0 and properties.visitCount >= cfg.Times then reasonStr = reasonStr or "打脸ID:" .. id .. "显示次数超过上限" .. properties.visitCount, cfg.Times return false, reasonStr end return true end reasonStr = reasonStr or "打脸ID:" .. id .. "不存在配置" return false, reasonStr end function PushInterface_Controller.GetGoldHeroPushInterfaceClassView(heroID) for id, params in pairs (private.id2OperationParams) do if params then local operationActivityType = MDL.OperationActivity.ActivityType[params[1]] if operationActivityType and operationActivityType == MDL.OperationActivity.ActivityType.GoldenHero then if heroID == tonumber(params[2]) then return DataSheetManager.PushInterface:GetDataByID(id).ViewClass end end end end return nil end function PushInterface_Controller.GetSuperGoldPushInterfaceClassView(heroID) for id, params in pairs (private.id2OperationParams) do if params then local operationActivityType = MDL.OperationActivity.ActivityType[params[1]] if operationActivityType and operationActivityType == MDL.OperationActivity.ActivityType.SuperGold then if heroID == tonumber(params[2]) then return DataSheetManager.PushInterface:GetDataByID(id).ViewClass end end end end return nil end function PushInterface_Controller.RemoveAllGoldHeroUnlockTriggerPushInterface() for id, params in pairs (private.id2OperationParams) do if params then local operationActivityType = MDL.OperationActivity.ActivityType[params[1]] if operationActivityType and operationActivityType == MDL.OperationActivity.ActivityType.GoldenHero then PushInterface_Controller.TriggerUnlockPushInterface(DataSheetManager.PushInterface:GetDataByID(id).ViewClass, false) elseif operationActivityType and operationActivityType == MDL.OperationActivity.ActivityType.SuperGold then PushInterface_Controller.TriggerUnlockPushInterface(DataSheetManager.PushInterface:GetDataByID(id).ViewClass, false) end end end end -- 测试用打印本地序列化数据 function PushInterface_Controller.PrintPushInterfaceSaveProperties(id) local cfg = DataSheetManager.PushInterface:GetDataByID(id) if cfg then local properties = private.GetSaveProperties(cfg.ViewClass) local resultStr = cfg.ViewClass resultStr = resultStr .. " 访问时间:" .. (properties.lastVisitTimeStamp > 0 and os.date(UTL.Time.FormatDateEnum.YMDHMS, properties.lastVisitTimeStamp) or 0) resultStr = resultStr .. " 访问次数:" .. tostring(properties.visitCount) resultStr = resultStr .. " 跳过:" .. tostring(properties.isSkip) if properties.rechargeParams then local rechargeParams = properties.rechargeParams resultStr = resultStr .. " 累充检测时间:" .. (rechargeParams.checkTimeStamp > 0 and os.date(UTL.Time.FormatDateEnum.YMDHMS, rechargeParams.checkTimeStamp) or 0) resultStr = resultStr .. " 累充档位:" .. tostring(rechargeParams.level) end logging.log(LTAG.LOG, resultStr) end end --===================================================== 私有函数 =========================================================-- -- 功能解锁 function private.OnFunctionUnlockUpdate(funcId, isUnlock) -- 累充 if funcId then if funcId == MDL.Unlock.FunctionType.AccumulatingRechargeGJ then PushInterface_Controller.TriggerUnlockPushInterface(Const_UI_Lua.UIEnum.OperationActivity.UIAccumulatingRecharge, isUnlock) elseif funcId == MDL.Unlock.FunctionType.GuildWar then local isShow = CTL.GuildWar.IsGuildWarCrossServerPushInterface(CTL.GuildWar.pushInterfaceID) PushInterface_Controller.TriggerUnlockPushInterface(Const_UI_Lua.UIEnum.UIPushInterfaceGuildWar, isShow and isUnlock) elseif funcId == MDL.Unlock.FunctionType.Attention then if isUnlock then local cfg = PushInterface_Controller.GetCfgByViewClass(Const_UI_Lua.UIEnum.UIPushInterfaceAttention) if PushInterface_Controller.IsCanShowLogin(cfg.ID) then PushInterface_Controller.TriggerUnlockPushInterface(Const_UI_Lua.UIEnum.UIPushInterfaceAttention, true) end else PushInterface_Controller.TriggerUnlockPushInterface(Const_UI_Lua.UIEnum.UIPushInterfaceAttention, false) end elseif funcId == MDL.Unlock.FunctionType.FollowDouYin then if isUnlock then local cfg = PushInterface_Controller.GetCfgByViewClass(Const_UI_Lua.UIEnum.UIPushInterfaceDouYin) if PushInterface_Controller.IsCanShowLogin(cfg.ID) then PushInterface_Controller.TriggerUnlockPushInterface(Const_UI_Lua.UIEnum.UIPushInterfaceDouYin, true) end else PushInterface_Controller.TriggerUnlockPushInterface(Const_UI_Lua.UIEnum.UIPushInterfaceDouYin, false) end elseif funcId == MDL.Unlock.FunctionType.FakeScore then if isUnlock then local cfg = PushInterface_Controller.GetCfgByViewClass(Const_UI_Lua.UIEnum.UICommonFakeScore) local show = private.CanShowCommonFakeScore(cfg.ID) if show then PushInterface_Controller.TriggerUnlockPushInterface(Const_UI_Lua.UIEnum.UICommonFakeScore, true) end else PushInterface_Controller.TriggerUnlockPushInterface(Const_UI_Lua.UIEnum.UICommonFakeScore, false) end end end end function private.CanShowCommonFakeScore(id) if SDKUtil.ChannelID ~= LuaConst.SDKChannelId.Hero_iOS then return false, "【策划注意!!!!】打脸ID:" .. id .. " 不能在改渠道显示" end local fakeScore = PersistentData.PlayerData:Get("OpenFakeScore", false) if fakeScore then return false, "打脸ID:" .. id .. " 已经弹出过一次" end return true, "" end -- 触发显示打脸图流程 function private.TriggerExcutePushInterface() -- 当前界面焦点在主城 且打脸流程未开始 且主城延迟界面队列为空 触发打脸流程 if BattleDataGetter.IsTownLevel() and UIManager.IsFocus(Const_UI_Lua.UIEnum.UIHomeMain) and not PushInterface_Controller.IsInPushInterfaceState() and CTL.HomeMain.DelayListIsEmpty() then if #private.idList > 0 then table.sort(private.idList, private.SortPushInterfaceByWeight) private.curPlayIndexIndex = 0 private.ShowNextPushInterface() else private.PushInterfaceOver() end end end -- 插入打脸图ID function private.InsertPushInterfaceID(id) if not id then return end local pushInterfaceData = DataSheetManager.PushInterface:GetDataByID(id) if not pushInterfaceData then return end -- 判断打脸图 是否可以添加 -- 1、渠道是否满足(为空表示全渠道显示) if not string.isNilOrEmpty(pushInterfaceData.Channel) then local channelList = string.split(pushInterfaceData.Channel, ',') local canShow = false local channelID = SDKUtil.ChannelID for _, v in ipairs(channelList) do if v == channelID then canShow = true break end end if not canShow then return end end -- 2、判断是否显示过 if not private.containIDDict[id] then local curCount = #private.idList -- 如果打脸流程未执行 或者 执行到显示最后一张打脸图 直接插入末尾 if not PushInterface_Controller.IsInPushInterfaceState() or private.curPlayIndexIndex == curCount then table.insert(private.idList, id) else -- 插入排序 插入到未显示打脸图集合的正确位置 while (curCount > private.curPlayIndexIndex) do if not private.SortPushInterfaceByWeight(id, private.idList[curCount]) then if curCount == #private.idList then table.insert(private.idList, id) else table.insert(private.idList, curCount + 1, id) end break end curCount = curCount - 1 end end private.containIDDict[id] = true end end -- 删除打脸图ID function private.RemovePushInterfaceID(id) if id and private.containIDDict[id] then private.containIDDict[id] = false for i, v in ipairs (private.idList) do if v == id then table.remove(private.idList, i) break end end end end -- 显示下一个打脸图 function private.ShowNextPushInterface() if not PushInterface_Controller.IsInPushInterfaceState() then return end if private.idList[private.curPlayIndexIndex + 1] then private.curPlayIndexIndex = private.curPlayIndexIndex + 1 PushInterface_Controller.OpenPushInterface(private.idList[private.curPlayIndexIndex]) else private.PushInterfaceOver() end end -- 打脸图流程结束 function private.PushInterfaceOver() for k, _ in pairs (private.containIDDict) do private.containIDDict[k] = false end table.clearArray(private.idList) private.curPlayIndexIndex = -1 if not private.hasExcuteLogin then private.hasExcuteLogin = true end end function private.SortPushInterfaceByWeight(a, b) local aCfg = DataSheetManager.PushInterface:GetDataByID(a) local bCfg = DataSheetManager.PushInterface:GetDataByID(b) if aCfg.Weight == bCfg.Weight then return a < b end return aCfg.Weight > bCfg.Weight end function private.GetSaveProperties(viewClass) -- 初始化缓存 if not private.viewClass2SaveProperties[viewClass] then local cfg = private.viewClass2PushInterfaceDict[viewClass] private.viewClass2SaveProperties[viewClass] = { id = cfg.ID, timeKey = string.format(SAVE_KEY_FORMAT, viewClass, SAVE_KEY_PREFIX_VISITTIME, BattleDataGetter.GetAcID()), lastVisitTimeStamp = -1, vcKey = string.format(SAVE_KEY_FORMAT, viewClass, SAVE_KEY_PREFIX_VISITCOUNT, BattleDataGetter.GetAcID()), visitCount = -1, skipKey = string.format(SAVE_KEY_FORMAT, viewClass, SAVE_KEY_PREFIX_SKIP, BattleDataGetter.GetAcID()), isSkip = nil } if viewClass == Const_UI_Lua.UIEnum.OperationActivity.UIAccumulatingRecharge then -- 累充特殊处理 private.viewClass2SaveProperties[viewClass].rechargeParams = { levelKey = SAVE_KEY_PREFIX_CHARGELEVEL .. BattleDataGetter.GetAcID(), level = -1, timeKey = SAVE_KEY_PREFIX_CHARGETIME .. BattleDataGetter.GetAcID(), checkTimeStamp = -1 } end end local properties = private.viewClass2SaveProperties[viewClass] properties.lastVisitTimeStamp = private.LastVisitTimeStampFunc(properties) properties.visitCount = private.VisitCountFunc(properties) properties.isSkip = private.SkipStateFunc(properties) if properties.rechargeParams then properties.rechargeParams.level, properties.rechargeParams.checkTimeStamp = private.RechargeInfoFunc(properties) end return properties end function private.SaveSkipState(properties, isSkip) if properties then private.SkipStateFunc(properties, isSkip) end end function private.SaveVisitState(properties, isAddVisitCount) if properties then local key = properties.key if properties.lastVisitTimeStamp == 0 or UTL.Time.IsTimestampCrossDay(properties.lastVisitTimeStamp) then -- 更新时间、访问次数 private.LastVisitTimeStampFunc(properties, UTL.Time.GetServerTimestamp()) private.VisitCountFunc(properties, 0) end if isAddVisitCount then private.VisitCountFunc(properties, private.VisitCountFunc(properties) + 1) end end end -- 打脸图访问次数Get/Set function private.VisitCountFunc(properties, visitCount) if properties and properties.vcKey then if properties.visitCount == -1 then properties.visitCount = PersistentData.PlayerData:Get(properties.vcKey,0) end if visitCount then properties.visitCount = visitCount PersistentData.PlayerData:Set(properties.vcKey, visitCount, true) else return properties.visitCount end end return 0 end -- 打脸图访问时间Get/Set function private.LastVisitTimeStampFunc(properties, lastVisitTimeStamp) if properties and properties.timeKey then if properties.lastVisitTimeStamp == -1 then local tb = PersistentData.PlayerData:Get(PUSH_INTERFACE_TIME_KEY) local timeStamp = tb ~= nil and tb[properties.timeKey] or 0 properties.lastVisitTimeStamp = not string.isNilOrEmpty(timeStamp) and tonumber(timeStamp) or 0 end if lastVisitTimeStamp then properties.lastVisitTimeStamp = lastVisitTimeStamp local tb = PersistentData.PlayerData:Get(PUSH_INTERFACE_TIME_KEY) if tb == nil then tb = {} end tb[properties.timeKey] = tostring(lastVisitTimeStamp) PersistentData.PlayerData:Set(PUSH_INTERFACE_TIME_KEY, tb, true) else return properties.lastVisitTimeStamp end end return 0 end -- 打脸图跳过状态Get/Set function private.SkipStateFunc(properties, skipState) if properties and properties.skipKey then if properties.isSkip == nil then properties.isSkip = PersistentData.PlayerData:Get(properties.skipKey) or false end if skipState ~= nil then properties.isSkip = skipState PersistentData.PlayerData:Set(properties.skipKey, skipState, true) else return properties.isSkip end end return false end -- 累充特殊处理 function private.RechargeInfoFunc(properties, level, checkTimeStamp) if properties and properties.rechargeParams then local rechargeParams = properties.rechargeParams if rechargeParams.level == -1 then rechargeParams.level = PersistentData.PlayerData:Get(rechargeParams.levelKey,0) end if rechargeParams.checkTimeStamp == -1 then local timeStamp = PersistentData.PlayerData:Get(rechargeParams.timeKey) rechargeParams.checkTimeStamp = not string.isNilOrEmpty(timeStamp) and tonumber(timeStamp) or 0 end if level and checkTimeStamp then rechargeParams.level = level PersistentData.PlayerData:Set(rechargeParams.levelKey, level, true) rechargeParams.checkTimeStamp = checkTimeStamp PersistentData.PlayerData:Set(rechargeParams.timeKey, tostring(checkTimeStamp), true) else return rechargeParams.level, rechargeParams.checkTimeStamp end end return 0, 0 end function private.IsInTime(timeId, duration) local timeRefreshCfg = DataSheetManager.TimeRefresh:GetDataByID(timeId) local OSTimeTab = {} OSTimeTab.year = timeRefreshCfg.Year OSTimeTab.month = timeRefreshCfg.Month OSTimeTab.day = timeRefreshCfg.Day OSTimeTab.hour = 0 OSTimeTab.min = 0 OSTimeTab.sec = 0 local startTime = os.time(OSTimeTab) + timeRefreshCfg.HMS + UTL.Time.GetDisplayDiffLocalTimeZone() local nowTime = UTL.Time.GetServerTimestamp() local endTime = startTime + duration * UTL.Time.TotalSecondsOneDay return startTime <= nowTime and endTime >= nowTime end function PushInterface_Controller.InTimeLiveBroadcastReward() if SDKUtil.ChannelID == LuaConst.SDKChannelId.Hero_Android or SDKUtil.ChannelID == LuaConst.SDKChannelId.Hero_iOS then local cfg = DataSheetManager.PushInterface:GetDataByID(PushInterface_Controller.PushInterfaceEnum.LiveBroadcast2) return private.IsInTime(LiveBroadcastRewardId, cfg.Duration) end return false end function PushInterface_Controller.OnViewClose(pushInterfaceEnum, toggle_Skip) local cfg = DataSheetManager.PushInterface:GetDataByID(pushInterfaceEnum) if not string.isNilOrEmpty(cfg.PrefabPath) then PushInterface_Controller.HidePushInterface(cfg.PrefabPath, toggle_Skip) else PushInterface_Controller.HidePushInterface(cfg.ViewClass, toggle_Skip) end end function PushInterface_Controller.SetBtnState(pushInterfaceEnum, btn, lab_Collect, extraComp) if pushInterfaceEnum == PushInterface_Controller.PushInterfaceEnum.DouYin then local state = MDL.Attention.GetAttentionState(CTL.Welfare.WelfareType.DouYinReward) if state and state == MDL.Attention.AttentionState.CanReceive then UIUtils.SetLabelText(lab_Collect, Const_IDS.IDS_NationClimbTower_GetReward) btn:SetRedPoint(true) else UIUtils.SetLabelText(lab_Collect, Const_IDS.IDS_FollowTiktok_1) btn:SetRedPoint(false) end end end function PushInterface_Controller.OnClickBtn(pushInterfaceEnum) if pushInterfaceEnum == PushInterface_Controller.PushInterfaceEnum.LiveBroadcast2 or pushInterfaceEnum == PushInterface_Controller.PushInterfaceEnum.LiveBroadcast1 then local link = DataSheetManager.ConstData:GetDataByID("LiveBroadcastLink").StringValue UnityEngine.Application.OpenURL(link) elseif pushInterfaceEnum == PushInterface_Controller.PushInterfaceEnum.DouYin then local state = MDL.Attention.GetAttentionState(CTL.Welfare.WelfareType.DouYinReward) if state == MDL.Attention.AttentionState.CanReceive then MDL.Attention.PushInterfaceOptReq(CTL.Welfare.WelfareType.DouYinReward, MDL.Attention.OptType.Receive) EventSystem.Dispatch(EventID.PushInterfaceCommon_CloseView, pushInterfaceEnum) else local accountLink = DataSheetManager.ConstData:GetDataByID("FollowTiktokLink").StringValue UnityEngine.Application.OpenURL(accountLink) MDL.Attention.PushInterfaceOptReq(CTL.Welfare.WelfareType.DouYinReward, MDL.Attention.OptType.SetReceive) end elseif pushInterfaceEnum == PushInterface_Controller.PushInterfaceEnum.FourteenDayReward then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIWelfareBasePanel, {welfareId = CTL.Welfare.WelfareType.SignInGift}) end end return PushInterface_Controller