miduo_client/Assets/ManagedResources/~Lua/Modules/Operating/OperatingManager.lua

882 lines
29 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

--[[
* @ClassName OperatingManager
* @Description 运营活动管理
* @Date 2019/6/6 10:29
* @Author MagicianJoker, fengliudianshao@outlook.com
* @Copyright Copyright (c) 2019, MagicianJoker
--]]
OperatingManager = {}
local this = OperatingManager
--后端数据 以RechargeCommodityConfig表Type为键
local giftGoodsInfoList = {}
--- 新的数据列表按照ID存取
local newGoodsList = {}
local hadBuyGoodsList = {}
local rechargeConfig = ConfigManager.GetConfig(ConfigName.RechargeCommodityConfig)
local luxuryConfig = ConfigManager.GetConfig(ConfigName.LuxuryFundConfig)
--后端数据 goodsId;//商品id buyTimes; //购买次数 startTime;//开始时间 endTime; //结束时间 dynamicBuyTimes; //可购买次数
local giftGoodsInfo
this.upGradePackagePanelType = 0
this.upGradePackagePanelIndex = 0
this.IsShowFiveStarPatch = true
--初始化
function this.Initialize()
Game.GlobalEvent:AddEvent(GameEvent.Player.OnLevelChange, function()
RedpotManager.CheckRedPointStatus(RedPointType.GrowthGift)
end)
Game.GlobalEvent:AddEvent(GameEvent.PatFace.PatFaceHaveGrowGift, this.NewHeroGift)
end
---------------------------局限性----------------------------
function this.SetBasicValues(giftGoodsList)
giftGoodsInfo = giftGoodsList
for _, v in pairs(GoodsTypeDef) do
giftGoodsInfoList[v] = {}
end
for _, giftGoodsInfo in ipairs(giftGoodsList) do
local rechargeConfig = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig, giftGoodsInfo.goodsId)
-- LogGreen("------充值活动-----------礼包类型:".. rechargeConfig.Type .." 礼包ID".. giftGoodsInfo.goodsId .." 已购:"
-- ..giftGoodsInfo.buyTimes.." 开始:"..giftGoodsInfo.startTime.." 结束:"
-- ..giftGoodsInfo.endTime .. " 可购(没卵用)" .. giftGoodsInfo.dynamicBuyTimes)
if giftGoodsInfoList[rechargeConfig.Type] then
table.insert(giftGoodsInfoList[rechargeConfig.Type], giftGoodsInfo)
end
end
Game.GlobalEvent:DispatchEvent(GameEvent.FindFairy.RefreshBuyOpenState)
end
--判断商品是否可购买(成长礼)
function this.IsGrowthGiftGoodsAvailable(goodsType)
for _, v in ipairs(giftGoodsInfo)do
local rechargeConfig = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig, v.goodsId)
if(rechargeConfig.Type == goodsType and v.dynamicBuyTimes == 1 and v.buyTimes ~= v.dynamicBuyTimes)then
return v
end
end
return nil
end
-- 判断商品数据是否在可用时间范围内
local function _IsGiftGoodsAvailable(gift)
-- body
if not gift then return false end
if gift.startTime == 0 and gift.endTime == 0 then return true end
local curTime = GetTimeStamp()
local isAvailable = curTime > gift.startTime and curTime <= gift.endTime
return isAvailable
end
function this.RemoveGiftInfoList(goodsType)
giftGoodsInfoList[goodsType] = nil
end
--- 删除某一类型的某一条商品数据
function this.RemoveItemInfoByType(type, goodsId)
if not giftGoodsInfoList[type] then
Log(Language[11482])
return
end
for k,v in pairs(giftGoodsInfoList[type]) do
if v then
if v.goodsId == goodsId then
table.remove(giftGoodsInfoList[type], k)
end
end
end
Game.GlobalEvent:DispatchEvent(GameEvent.FindFairy.RefreshBuyOpenState)
end
function this.IsRechargeable(goodsType)
return giftGoodsInfoList[goodsType]
end
-- 判断相应显示类型的礼包是否存在用于判断是否开启了相应的充值活动
function this.HasGoodsByShowType(showType)
local list = ConfigManager.GetAllConfigsDataByKey(ConfigName.RechargeCommodityConfig, "ShowType", showType)
if not list then return false end
for _, goods in ipairs(list) do
if this.GetGiftGoodsInfo(goods.Type, goods.Id) then
return true
end
end
return false
end
--- 获取激活后的商品数据
function this.GetGiftGoodsInfo(goodsType, Id)
if not giftGoodsInfoList[goodsType] then
return nil
end
for _, giftGoodsInfo in pairs(giftGoodsInfoList[goodsType]) do
if Id then
if giftGoodsInfo.goodsId == Id then
return giftGoodsInfo
end
else
-- 判断是否可用
if _IsGiftGoodsAvailable(giftGoodsInfo) then
return giftGoodsInfo
end
end
end
return nil
end
function this.GetGiftGoodsInfoList(type)
return giftGoodsInfoList[type] and giftGoodsInfoList[type] or {}
end
function this.RefreshGiftGoodsBuyTimes(goodsType, goodsId, buyTimes)
-- if not giftGoodsInfoList[goodsType] then
-- return
-- end
-- for _, giftGoodsInfo in ipairs(giftGoodsInfoList[goodsType]) do
-- if giftGoodsInfo.goodsId == goodsId then
-- giftGoodsInfo.buyTimes = giftGoodsInfo.buyTimes + (buyTimes and buyTimes or 1)
-- end
-- end
end
--- 获取商品的剩余购买次数
--- 0 不可买 1: 剩余1次-1不限次数
function this.GetLeftBuyTime(type, goodsId)
if not giftGoodsInfoList[type] then
Log(Language[11483] .. goodsId)
return
end
--- 此类商品的购买次数限制
local limitTime = rechargeConfig[goodsId].Limit
if limitTime == 0 then --- 不限购
return -1
else
local boughtTime = this.GetGoodsBuyTime(type, goodsId)
return limitTime - boughtTime
end
end
--- 获取商品已经购买次数
function this.GetGoodsBuyTime(type, goodsId)
if not giftGoodsInfoList[type] then
--王振兴添加 防止没有查询到数据报错
return 0
end
for k,v in pairs(giftGoodsInfoList[type]) do
if v.goodsId == goodsId then
return v.buyTimes
end
end
--王振兴添加 防止没有查询到数据报错
return 0
end
--------------------------------------------------------------
function this.SetHadBuyGoodsId(BuyGoodsList)
for i = 1, #BuyGoodsList do
table.insert(hadBuyGoodsList, BuyGoodsList[i])
end
end
function this.GetHadBuyGoodsTypeId(type)
local Id
for _, goodsId in ipairs(hadBuyGoodsList) do
if rechargeConfig[goodsId].Type == type then
Id = goodsId
end
end
return Id
end
function this.GetGrowthRedPointState()
local redPoint = false
local hasGift = OperatingManager.HasGoodsByShowType(4)
if not hasGift then return false end
local giftGoodsInfo = OperatingManager.IsGrowthGiftGoodsAvailable(GoodsTypeDef.GrowthReward)
if giftGoodsInfo then return false end
local openId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.GrowthReward)
if openId then
local actRewardConfig = ConfigManager.GetConfig(ConfigName.ActivityRewardConfig)
for _, configInfo in ConfigPairs(actRewardConfig) do
if configInfo.ActivityId == openId then
local activityInfo = ActivityGiftManager.GetActivityInfo(openId, configInfo.Id)
if activityInfo and activityInfo.state == 0 and PlayerManager.level >= configInfo.Values[1][2] then
redPoint = true
end
end
end
end
return redPoint
end
-- 商品时间数据
local _GoodsDurationData = {}
function this.SetGoodsDurationData(dataList)
if not dataList then
return
end
for _, data in ipairs(dataList) do
-- 这里协议字段为goodsType其实数据为ID
_GoodsDurationData[data.goodsType] = data.endTime
--Log("商品类型 = "..data.goodsType..", 剩余时间 = "..data.endTime)
end
end
-- 根据类型判断相应的物品是否开启并返回相应的ID
function this.GetActiveGoodsIDByType(goodsType)
for goodsId, endTime in pairs(_GoodsDurationData) do
if rechargeConfig[goodsId].Type == goodsType and endTime > GetTimeStamp() then
return goodsId, endTime
end
end
end
function this.GetGoodsEndTime(goodsType)
local goodsId, endTime = this.GetActiveGoodsIDByType(goodsType)
return endTime
end
function this.RemoveEndTime(goodsId)
_GoodsDurationData[goodsId] = nil
end
function this.SetGoodsEndTime(goodsId, endTime)
_GoodsDurationData[goodsId] = endTime
end
-- 直购活动是否还在
function this.IsGoodsExit(type, id)
local isOpen = false
local data = this.GetGiftGoodsInfo(type, id)
if data then
-- 有数据,但是活动结束
local time = data.endTime - PlayerManager.serverTime
isOpen = time > 0
else
isOpen = false
end
return isOpen
end
-- 五星成长礼红点
function this.GetRedState()
local isRed = false
local redValue = PlayerPrefs.GetInt(PlayerManager.uid .. "BlaBlaBla")
local openState = this.IsGoodsExit(GoodsTypeDef.DirectPurchaseGift, 21)
if openState and redValue == 0 then
isRed = true
else
isRed = false
end
return isRed
end
---------------------------------------累计签到--------------------------------
local _SignInData
function this.SetSignInData(signIn)
_SignInData = signIn
CheckRedPointStatus(RedPointType.CumulativeSignIn)
end
function this.GetSignInData()
return _SignInData
end
--红点检测方法
function this.GetSignInRedPointStatus()
local receiveNum=PrivilegeManager.GetPrivilegeRemainValue(PRIVILEGE_TYPE.DAY_SIGN_IN)--本地标记可领取次数
local rechargeNum=PrivilegeManager.GetPrivilegeNumber(PRIVILEGE_TYPE.DAY_SIGN_IN)--充值标记 1未充值 2已充值
return _SignInData.state == 0 or receiveNum>0--(_SignInData.state==1 and ((receiveNum==0 and rechargeNum==1) or (receiveNum==1 and rechargeNum==2)))
end
---------------------------------- 什么什么什么新鸡成长礼包 ------------------------------------------
--- 新增一个礼包
function this.NewHeroGift()
this.SetHeroRedState(1)
CheckRedPointStatus(RedPointType.HERO_STAR_GIFT)
end
--- 获取那个的显示数据
function this.GetStarGiftData()
local data = {}
for k, v in ConfigPairs(rechargeConfig) do
if v.ShowType == 8 then
local t = {}
t.data = v -- 数据结构
t.Id = v.Id -- 商品ID
data[#data + 1] = t
end
end
return data
end
function this.IsHeroGiftActive()
-- 关闭星级成长礼显示
local activeNum = 0
if not giftGoodsInfoList[GoodsTypeDef.DirectPurchaseGift] then
return false
else
for i = 1, #giftGoodsInfoList[GoodsTypeDef.DirectPurchaseGift] do
local data =giftGoodsInfoList[GoodsTypeDef.DirectPurchaseGift][i]
if data then
local id = data.goodsId
if rechargeConfig[id].ShowType == 8 then --- 只有前端显示的商品类型
activeNum = activeNum + 1
end
end
end
end
return activeNum > 0
end
--- 获取礼包的显示数据
function this.GetGiftShowData()
local staticData = this.GetStarGiftData()
local newData = {}
for i = 1, #staticData do
local goodsId = staticData[i].Id
local data = {}
data.rewardData = staticData[i].data.RewardShow
data.price = MoneyUtil.GetMoney(staticData[i].data.Price)
data.id = goodsId
data.name = staticData[i].data.Name
local serData = this.GetGiftGoodsInfo(GoodsTypeDef.DirectPurchaseGift, goodsId)
if serData and serData.endTime > 0 then --- 商品激活可购买
data.endTime = serData.endTime
data.startTime = serData.startTime
data.leftBuyTime = serData.dynamicBuyTimes
data.isActive = 1
else --- 未激活只是显示而已
data.endTime = 0
data.startTime = 0
data.leftBuyTime = 0
data.isActive = 0
end
newData[#newData + 1] = data
end
---排序
if #newData > 1 then
table.sort(newData, function(a, b)
if a.isActive == b.isActive then
return a.id > b.id
else
return a.isActive > b.isActive
end
end)
end
return newData
end
--- 礼包红点
function this.IsHeroStarGiftActive()
local clickedState = this.GetHeroRedState()
local isActive = this.IsHeroGiftActive()
local hasRed = clickedState == 1 and isActive
return hasRed
end
function this.SetHeroRedState(value)
PlayerPrefs.SetInt(PlayerManager.uid .. "hero_star_gift", value)
end
function this.GetHeroRedState()
return PlayerPrefs.GetInt(PlayerManager.uid .. "hero_star_gift")
end
----------------------------------------------------------------------------------------------
--- 获取鸡精面版的显示信息
--- 传进来的参数值是 33或者是34基金类型
function this.GetPanelShowReward(type, isAll,isOverlay)
local data = {}
for k, v in ConfigPairs(luxuryConfig) do
if not isAll then
if v.Type == type and v.ShowReward == 1 then
data[#data + 1] = v
end
else
if v.Type == type then
data[#data + 1] = v
end
end
end
if isOverlay then
local endData = {}
for i = 1, #data do
if endData[data[i].reward[1][1]] then
endData[data[i].reward[1][1]] = endData[data[i].reward[1][1]] + data[i].reward[1][2]
else
endData[data[i].reward[1][1]] = data[i].reward[1][2]
end
end
local endData2 = {}
for i, v in pairs(endData) do
table.insert(endData2,{i,v})
end
return endData2
else
return data
end
end
--- 某一个鸡精活动是否开启
function this.IsBaseOpen(type, id)
local isOpen = false
local data = this.GetGiftGoodsInfo(type, id)
if data then
--- 常驻
if tonumber(data.endTime) == 0 then
isOpen = true
else
local time = data.endTime - PlayerManager.serverTime
local isBuy = this.IsBaseBuy(type)
isOpen = time > 0
-- 如果购买了结束也没有用
if isBuy then
isOpen = true
end
end
else
isOpen = false
-- 如果购买了结束也没有用
if this.IsBaseBuy(type) then
isOpen = true
end
end
return isOpen
end
--- 判断某一个鸡精是否购买
function this.IsBaseBuy(type)
local leftTime = this.GetGoodsEndTime(type)
local isBuy = false
if not leftTime then
isBuy = false
else
if leftTime <= 0 then
isBuy = false
else
isBuy = true
end
end
return isBuy
end
---- 界面打开时设置一下服务器数据
function this.SetSerData(goodsType)
local endTime = this.GetGoodsEndTime(goodsType)
if not endTime then return end
local startTime = endTime - 24 * 30 * 60 * 60
local passSecond = GetTimeStamp() - startTime
-- Log("结束时间" .. os.date("%Y年%m月%d", endTime))
-- Log("起点时间" .. os.date("%Y年%m月%d", startTime))
-- Log("服务器时间".. os.date("%Y年%m月%d", GetTimeStamp()))
-- Log("经历时间 --- " .. PlayerManager.serverTime)
this.SetSignRewarDay(goodsType, passSecond)
end
local getDay = {}
local oneDaySeconds = 24 * 60 * 60
-- 累计领取天数
function this.GetRewardDay(goodType)
-- Log("天数 " .. getDay[goodType])
-- 未激活时没有天数
if not this.IsBaseBuy(goodType) then return 0 end
return getDay[goodType]
end
--- 设置累计天数
function this.SetSignRewarDay(goodType, second)
if not getDay[goodType] then getDay[goodType] = {} end
-- 小于24小时按一天
if second <= oneDaySeconds * 1 then
getDay[goodType] = 1
elseif second >= oneDaySeconds * 30 then
getDay[goodType] = 30
else
local hour = math.ceil(math.ceil(second / 60) / 60)
getDay[goodType] = math.ceil(hour / 24)
-- Log("累计" .. hour .. "小时")
getDay[goodType] = getDay[goodType] >= 30 and 30 or getDay[goodType]
end
end
-- 显示数据
function this.GetShowTime(endTime)
local duration = 30 * 24 * 60 * 60
local endStr = os.date(Language[11484], endTime)
local startStr = os.date(Language[11484], endTime - duration + 1)
return startStr, endStr
end
--月卡开始
--初始化月卡数据
local monthSaveAmt = 0--月卡累计总额
local smonthSaveAmt = 0--豪华月卡累计总额
local monthCardData = {}
function this.InitMonthCardData(data)
monthCardData = {}
--LogError("月卡信息初始化 "..#data)
for i = 1, #data do
--LogError("月卡信息初始化 "..data[i].id.." "..data[i].endingTime.." "..data[i].state)
local singleMonthCard = {}
singleMonthCard.id = data[i].id
singleMonthCard.endingTime = data[i].endingTime
singleMonthCard.state = data[i].state
if i == MONTH_CARD_TYPE.MONTHCARD then
--LogError("月卡信息初始化 月卡累计充值 "..data[i].totleAmt)
monthSaveAmt = data[i].totleAmt
elseif i == MONTH_CARD_TYPE.LUXURYMONTHCARD then
--LogError("月卡信息初始化 豪华月卡累计充值 "..data[i].totleAmt)
smonthSaveAmt = data[i].totleAmt
end
table.insert(monthCardData,singleMonthCard)
end
CheckRedPointStatus(RedPointType.MonthCard)
end
--推送更新月卡数据
function this.UpdateMonthCardData(msg)
--LogError("月卡信息推送 "..#msg.monthinfos)
--当我数据没有 后端推过来的有数据 此时需要弹窗
local showStr = ""
for i = 1, #msg.monthinfos do
if monthCardData[i].endingTime <= 0 then
showStr = Language[11485]
end
end
monthCardData = {}
local curActiveMONTHCARD = false
local curActiveLUXURYMONTHCARD = false
for i = 1, #msg.monthinfos do
--LogError("月卡信息推送 "..msg.monthinfos[i].id.." "..msg.monthinfos[i].endingTime.." "..msg.monthinfos[i].state)
local singleMonthCard = {}
singleMonthCard.id = msg.monthinfos[i].id
singleMonthCard.endingTime = msg.monthinfos[i].endingTime
singleMonthCard.state = msg.monthinfos[i].state--0 未领取 1 已领取
if i == MONTH_CARD_TYPE.MONTHCARD then
monthSaveAmt = msg.monthinfos[i].totleAmt
curActiveMONTHCARD = true
elseif i == MONTH_CARD_TYPE.LUXURYMONTHCARD then
smonthSaveAmt = msg.monthinfos[i].totleAmt
curActiveLUXURYMONTHCARD = true
end
table.insert(monthCardData,singleMonthCard)
end
CheckRedPointStatus(RedPointType.MonthCard)
if showStr ~= "" then
if ActTimeCtrlManager.SingleFuncState(JumpType.Welfare) then
if curActiveMONTHCARD then
--发送埋点数据
CustomEventManager.SendCustomEvents(FBSDKCustomEventType.FirstBuyMonthCard,0)
end
if curActiveLUXURYMONTHCARD then
--发送埋点数据
CustomEventManager.SendCustomEvents(FBSDKCustomEventType.FirstBuyHeightMonthCard,0)
end
MsgPanel.ShowTwo(showStr, function()
JumpManager.GoJump(36004)
end,
function()
UIManager.ClosePanel()
end,Language[10549],Language[11486])
end
end
end
function this.RefreshMonthCardChargeMoney(msg)
--LogError("月卡金额信息推送 "..msg.monthSaveAmt.." "..msg.smonthSaveAmt)
monthSaveAmt = msg.monthSaveAmt--月卡累计总额
smonthSaveAmt = msg.smonthSaveAmt--豪华月卡累计总额
end
-- 月卡累计总额
function this.GetmonthSaveAmt()
return monthSaveAmt
end
-- 豪华月卡累计总额
function this.GetsmonthSaveAmt()
return smonthSaveAmt
end
--前端设置月卡领取状态数据
function this.SetMonthCardGetStateData(type,state)
if monthCardData[type] then
monthCardData[type].state = state--0 未领取 1 已领取
end
CheckRedPointStatus(RedPointType.MonthCard)
end
--后端设置月卡领取状态数据 datas已领取的月卡id 五点刷新
function this.BackSetMonthCardGetStateData(datas)
for i = 1, #monthCardData do
if monthCardData[i] then--0 未领取 1 已领取
if datas[i] then
monthCardData[i].state = 1
else
monthCardData[i].state = 0
end
end
end
--事件
CheckRedPointStatus(RedPointType.MonthCard)
Game.GlobalEvent:DispatchEvent(GameEvent.MonthCard.OnMonthCardUpdate)
end
--获取月卡数据
function this.GetMonthCardData()
if monthCardData then
return monthCardData
else
return nil
end
end
--月卡到期
local addTimeNum = 30 * 24 * 60 * 60
function this.RefreshMonthCardEnd()
for i = 1, #monthCardData do
if monthCardData[i] and monthCardData[i].endingTime > 0 then--0 未领取 1 已领取
local dayLuxuryNum = math.floor((monthCardData[i].endingTime + addTimeNum - GetTimeStamp()) / (24 * 3600))
if dayLuxuryNum < 0 then
monthCardData[i].endingTime = 0
monthCardData[i].state = 0--0 未领取 1 已领取
if i == MONTH_CARD_TYPE.MONTHCARD then
monthSaveAmt = 0--月卡累计总额
else
smonthSaveAmt = 0--豪华月卡累计总额
end
end
end
end
CheckRedPointStatus(RedPointType.MonthCard)
end
--单种月卡红点检测
function this.RefreshMonthCardRedPoint(type)
if monthCardData[type] then
if monthCardData[type].endingTime ~= 0 and monthCardData[type].state == 0 then
return true
end
end
return false
end
--所有月卡红点检测
function this.AllRefreshMonthCardRedPoint()
for i = 1, #monthCardData do
if monthCardData[i].endingTime ~= 0 and monthCardData[i].state == 0 then
return true
end
end
return false
end
--所有月卡激活状态
function this.GetMonthCardIsOpen(type)
if monthCardData[type] then
if monthCardData[type].endingTime ~= 0 then
return true
end
end
return false
end
--月卡结束
--礼包抢购是否开启
function this.IsGiftBuyActive()
local activeNum = 0
local GiftBuyData = ConfigManager.GetAllConfigsDataByDoubleKey(ConfigName.RechargeCommodityConfig, "ShowType", 20, "Type", GoodsTypeDef.DirectPurchaseGift)
if GiftBuyData then
for i = 1, #GiftBuyData do
local curgoodData = OperatingManager.GetGiftGoodsInfo(GoodsTypeDef.DirectPurchaseGift, GiftBuyData[i].Id)
if curgoodData then
if curgoodData.endTime - GetTimeStamp() > 0 then
activeNum = activeNum + 1
end
end
end
end
return activeNum > 0
end
function this.GetTimeLimitRedPointStatus()
local lotterySetting=ConfigManager.GetConfig(ConfigName.LotterySetting)
local activityId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.FindFairy)
if not activityId then
return false
end
local array = ConfigManager.GetConfigDataByDoubleKey(ConfigName.LotterySetting,"ActivityId",activityId,"PerCount",1)
local freeTimesId=lotterySetting[array.Id].FreeTimes
local freeTime= 0
if freeTimesId>0 then
freeTime= PrivilegeManager.GetPrivilegeRemainValue(freeTimesId)
RecruitManager.freeUseTimeList[freeTimesId]=freeTime
return freeTime and freeTime >= 1
end
end
function this.GetQiankunBoxRedPointStatus()
local lotterySetting=ConfigManager.GetConfig(ConfigName.LotterySetting)
local activityId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.QianKunBox)
if not activityId then
return false
end
local array = ConfigManager.GetConfigDataByDoubleKey(ConfigName.LotterySetting,"ActivityId",activityId,"PerCount",1)
local freeTimesId=lotterySetting[array.Id].FreeTimes
local freeTime= 0
if freeTimesId>0 then
freeTime= PrivilegeManager.GetPrivilegeRemainValue(freeTimesId)
RecruitManager.freeUseTimeList[freeTimesId]=freeTime
return freeTime and freeTime >= 1
end
end
this.TimeLimitedTimes = 0
this.allData = {}
function this.InitDynamicActData()
local id = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.DynamicAct)
if (not id) or id < 1 then
return nil
end
-- LogGreen("ActivityId:"..id)
this.allData = {}
local allListData = ConfigManager.GetAllConfigsDataByKey(ConfigName.ThemeActivityTaskConfig, "ActivityId", id)
local allMissionData = TaskManager.GetTypeTaskList(TaskTypeDef.DynamicActTask)
-- LogGreen("allMissionData:"..#allMissionData)
for i=1,#allListData do
for j=1,#allMissionData do
if allListData[i].Id == allMissionData[j].missionId then
local data = {}
data.id = allMissionData[j].missionId
data.progress = allMissionData[j].progress
local strs = string.split(allListData[i].Show,"#")
data.title = strs[1]
data.content = strs[2]
data.value = allListData[i].TaskValue[2][1]
data.state = allMissionData[j].state
-- if allMissionData[j].state == 2 then
-- data.state = allMissionData[j].state
-- else
-- if data.progress >= data.value then
-- data.state = 1
-- else
-- data.state = 0
-- end
-- end
data.type = allListData[i].Type
data.reward = {allListData[i].Integral[1][1],allListData[i].Integral[1][2]}
data.jump = allListData[i].Jump[1]
table.insert(this.allData,data)
end
end
end
return this.allData
end
function this.CheckDynamicActTaskRed()
this.InitDynamicActData()
if not this.allData then
return false
end
for i=1,#this.allData do
if this.allData[i].state == 1 then
return true
end
end
return false
end
function this.InitLeiJiChongZhiData()
local id = ActivityGiftManager.GetActivityIdByType(ActivityTypeDef.DynamicAct_recharge)
if (not id) or id == 0 then
return nil
end
this.LeiJiChongZhiData = {}
local allListData = ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityRewardConfig, "ActivityId", id)
local allMissionData = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.DynamicAct_recharge)
for i=1,#allListData do
for j=1,#allMissionData.mission do
if allListData[i].Id == allMissionData.mission[j].missionId then
local data = {}
data.id = allMissionData.mission[j].missionId
data.progress = allMissionData.value
data.value = allListData[i].Values[1][1]
data.state = allMissionData.mission[j].state == 1 and allMissionData.mission[j].state or (data.progress>= data.value and 2 or 0) -- 0 前往 1已领奖 2领奖
data.reward = allListData[i].Reward
data.jump = allListData[i].Jump[1]
table.insert(this.LeiJiChongZhiData,data)
end
end
end
return this.LeiJiChongZhiData
end
function this.CheckLeiJiChongZhiRedData()
local mission = this.InitLeiJiChongZhiData()
if not mission or #mission < 1 then
return false
end
for j = 1,#mission do
-- LogGreen(mission[j].id..":"..mission[j].state)
if mission[j].state == 2 then
return true
end
end
return false
end
function this.CheckWeekGiftPageRedPoint()
local boughtNum = 0
local limitNum = 0
local shopData = OperatingManager.GetGiftGoodsInfoList(GoodsTypeDef.DirectPurchaseGift)
for i = 1, #shopData do
if rechargeConfig[shopData[i].goodsId].ShowType == DirectBuyType.WEEK_GIFT then
boughtNum = OperatingManager.GetGoodsBuyTime(GoodsTypeDef.DirectPurchaseGift, shopData[i].goodsId)
limitNum = rechargeConfig[shopData[i].goodsId].Limit
local isCanBuy = limitNum - boughtNum >0
if isCanBuy and rechargeConfig[shopData[i].goodsId].Price <= 0 then
return true
end
end
end
return false
end
function this.CheckMonthGiftPageRedPoint()
local boughtNum = 0
local limitNum = 0
local shopData = OperatingManager.GetGiftGoodsInfoList(GoodsTypeDef.DirectPurchaseGift)
for i = 1, #shopData do
if rechargeConfig[shopData[i].goodsId].ShowType == DirectBuyType.MONTH_GIFT then
boughtNum = OperatingManager.GetGoodsBuyTime(GoodsTypeDef.DirectPurchaseGift, shopData[i].goodsId)
limitNum = rechargeConfig[shopData[i].goodsId].Limit
local isCanBuy = limitNum - boughtNum >0
if isCanBuy and rechargeConfig[shopData[i].goodsId].Price <= 0 then
return true
end
end
end
return false
end
return this