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

870 lines
29 KiB
Lua
Raw Normal View History

2021-04-20 13:58:00 +08:00
--[[
2020-05-09 13:31:21 +08:00
* @ClassName OperatingManager
* @Description
* @Date 2019/6/6 10:29
* @Author MagicianJoker, fengliudianshao@outlook.com
* @Copyright Copyright (c) 2019, MagicianJoker
--]]
require("Modules.Operating.MonthCardManager")
require("Modules.Operating.WeekCardManager")
2020-05-09 13:31:21 +08:00
OperatingManager = {}
local this = OperatingManager
2020-08-14 13:01:12 +08:00
--后端数据 以RechargeCommodityConfig表Type为键
2020-05-09 13:31:21 +08:00
local giftGoodsInfoList = {}
--- 新的数据列表按照ID存取
local newGoodsList = {}
local hadBuyGoodsList = {}
local rechargeConfig = ConfigManager.GetConfig(ConfigName.RechargeCommodityConfig)
local luxuryConfig = ConfigManager.GetConfig(ConfigName.LuxuryFundConfig)
2020-08-14 13:01:12 +08:00
--后端数据 goodsId;//商品id buyTimes; //购买次数 startTime;//开始时间 endTime; //结束时间 dynamicBuyTimes; //可购买次数
local giftGoodsInfo
2020-05-09 13:31:21 +08:00
this.upGradePackagePanelType = 0
this.upGradePackagePanelIndex = 0
2020-08-22 19:40:14 +08:00
this.IsShowFiveStarPatch = true
-- 月卡激活提示内容,也用来标记是否需要拍脸提示
this.showStr = ""
2020-05-09 13:31:21 +08:00
--初始化
function this.Initialize()
Game.GlobalEvent:AddEvent(GameEvent.Player.OnLevelChange, function()
RedpotManager.CheckRedPointStatus(RedPointType.GrowthGift)
end)
Game.GlobalEvent:AddEvent(GameEvent.PatFace.PatFaceHaveGrowGift, this.NewHeroGift)
this.showStr = ""
2020-05-09 13:31:21 +08:00
end
---------------------------局限性----------------------------
2020-08-14 13:01:12 +08:00
function this.SetBasicValues(giftGoodsList)
2020-05-25 19:16:23 +08:00
giftGoodsInfo = giftGoodsList
2020-05-09 13:31:21 +08:00
for _, v in pairs(GoodsTypeDef) do
giftGoodsInfoList[v] = {}
end
for _, giftGoodsInfo in ipairs(giftGoodsList) do
2021-04-15 10:28:09 +08:00
if giftGoodsInfo.goodsId and giftGoodsInfo.goodsId ~= 0 then
local rechargeConfigLocal = ConfigManager.TryGetConfigData(ConfigName.RechargeCommodityConfig, giftGoodsInfo.goodsId)
if rechargeConfigLocal then
2021-11-15 15:44:02 +08:00
-- LogBlue("礼包类型:"..tostring(rechargeConfigLocal.Type).." 礼包ID"..tostring(giftGoodsInfo.goodsId).." 已购:"..tostring(giftGoodsInfo.buyTimes)
-- .."次 开始时间:"..tostring(giftGoodsInfo.startTime).." 结束时间:"..tostring(giftGoodsInfo.endTime).. " 可购:" ..tostring(giftGoodsInfo.dynamicBuyTimes).." 是否已买:"..tostring(giftGoodsInfo.isBought))
if giftGoodsInfo.endTime == 0 and giftGoodsInfo.startTime == 0 and (rechargeConfigLocal.ShowType == 25 or rechargeConfigLocal.ShowType == 26 or rechargeConfigLocal.ShowType == 8) then
else
if giftGoodsInfoList[rechargeConfigLocal.Type] then
table.insert(giftGoodsInfoList[rechargeConfigLocal.Type], giftGoodsInfo)
end
2021-04-15 10:28:09 +08:00
end
else
2021-11-15 15:44:02 +08:00
LogError("服务器发过来一个前端表中不存在的礼包:"..tostring(giftGoodsInfo.goodsId))
2020-11-13 16:35:25 +08:00
end
2020-05-09 13:31:21 +08:00
end
end
Game.GlobalEvent:DispatchEvent(GameEvent.FindFairy.RefreshBuyOpenState)
end
2020-05-25 19:16:23 +08:00
--判断商品是否可购买(成长礼)
function this.IsGrowthGiftGoodsAvailable(goodsType)
for _, v in ipairs(giftGoodsInfo)do
2020-11-04 00:15:26 +08:00
if v and v.goodsId and v.goodsId ~= 0 then
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
2020-05-25 19:16:23 +08:00
end
end
return nil
end
--判断商品是否购买过
function this.IsBuyGift(goodsId)
if not goodsId then
return false
end
for _, v in ipairs(giftGoodsInfo)do
if v.goodsId == goodsId and v.buyTimes > 0 then
return true
end
end
return false
end
2020-05-09 13:31:21 +08:00
-- 判断商品数据是否在可用时间范围内
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("此类商品不存在")
2020-05-09 13:31:21 +08:00
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
2020-06-18 20:39:29 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.FindFairy.RefreshBuyOpenState)
2020-05-09 13:31:21 +08:00
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
2020-05-09 13:31:21 +08:00
--- 获取激活后的商品数据
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 {}
if not giftGoodsInfoList[type] then
return {}
end
local newGiftGoodsInfoList = {}
for k,v in pairs(giftGoodsInfoList[type]) do
--and PlayerManager.level >= rechargeConfig[v.goodsId].LevelLinit[1] and PlayerManager.level <= rechargeConfig[v.goodsId].LevelLinit[2]
if rechargeConfig[v.goodsId] then
table.insert(newGiftGoodsInfoList,v)
end
end
return newGiftGoodsInfoList
2020-05-09 13:31:21 +08:00
end
function this.RefreshGiftGoodsBuyTimes(goodsType, goodsId, buyTimes)
2020-05-25 19:16:23 +08:00
-- 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
2020-05-09 13:31:21 +08:00
end
--- 获取商品的剩余购买次数
--- 0 不可买 1: 剩余1次-1不限次数
function this.GetLeftBuyTime(type, goodsId)
if not giftGoodsInfoList[type] then
Log("此类基金尚未激活!, 商品ID是 -- " .. goodsId)
2020-05-09 13:31:21 +08:00
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
2020-08-13 15:38:20 +08:00
--王振兴添加 防止没有查询到数据报错
return 0
2020-05-09 13:31:21 +08:00
end
for k,v in pairs(giftGoodsInfoList[type]) do
if not goodsId then
return v.buyTimes
end
2020-05-09 13:31:21 +08:00
if v.goodsId == goodsId then
return v.buyTimes
end
end
2020-08-13 15:38:20 +08:00
--王振兴添加 防止没有查询到数据报错
return 0
2020-05-09 13:31:21 +08:00
end
--------------------------------------------------------------
function this.SetHadBuyGoodsId(BuyGoodsList)
for i = 1, #BuyGoodsList do
table.insert(hadBuyGoodsList, BuyGoodsList[i])
end
end
function this.GetHadBuyGoodsTypeId(type)
2020-05-25 19:16:23 +08:00
local Id
2020-05-09 13:31:21 +08:00
for _, goodsId in ipairs(hadBuyGoodsList) do
if rechargeConfig[goodsId].Type == type then
2020-05-25 19:16:23 +08:00
Id = goodsId
2020-05-09 13:31:21 +08:00
end
end
2020-05-25 19:16:23 +08:00
return Id
2020-05-09 13:31:21 +08:00
end
function this.GetGrowthRedPointState()
local redPoint = false
local hasGift = OperatingManager.HasGoodsByShowType(4)
if not hasGift then return false end
2020-05-25 19:16:23 +08:00
local giftGoodsInfo = OperatingManager.IsGrowthGiftGoodsAvailable(GoodsTypeDef.GrowthReward)
if not giftGoodsInfo then return false end
2020-05-25 19:16:23 +08:00
local openId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.GrowthReward)
if openId then
-- 判断对应礼包是否购买
local globalActConfigs = ConfigManager.TryGetConfigData(ConfigName.GlobalActivity, openId)
if not globalActConfigs or globalActConfigs.CanBuyRechargeId[1] == 0 then
return false
end
if not this.IsBuyGift(globalActConfigs.CanBuyRechargeId[1]) then
return false
end
2020-05-09 13:31:21 +08:00
local actRewardConfig = ConfigManager.GetConfig(ConfigName.ActivityRewardConfig)
for _, configInfo in ConfigPairs(actRewardConfig) do
2020-05-25 19:16:23 +08:00
if configInfo.ActivityId == openId then
local activityInfo = ActivityGiftManager.GetActivityInfo(openId, configInfo.Id)
2020-06-03 19:09:01 +08:00
if activityInfo and activityInfo.state == 0 and PlayerManager.level >= configInfo.Values[1][2] then
2020-05-25 19:16:23 +08:00
redPoint = true
2020-05-09 13:31:21 +08:00
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] and rechargeConfig[goodsId].Type == goodsType and endTime > GetTimeStamp() then
2020-05-09 13:31:21 +08:00
return goodsId, endTime
end
end
end
2021-07-13 17:25:21 +08:00
2020-05-09 13:31:21 +08:00
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()
2020-07-26 16:44:31 +08:00
-- 关闭星级成长礼显示
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
2020-05-09 13:31:21 +08:00
return activeNum > 0
2020-05-09 13:31:21 +08:00
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)
2020-05-09 13:31:21 +08:00
data.id = goodsId
2021-01-26 17:08:39 +08:00
data.name = GetLanguageStrById(staticData[i].data.Name)
2020-05-09 13:31:21 +08:00
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基金类型
2020-05-25 19:16:23 +08:00
function this.GetPanelShowReward(type, isAll,isOverlay)
2020-05-09 13:31:21 +08:00
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
2020-05-25 19:16:23 +08:00
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
2020-05-09 13:31:21 +08:00
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
2021-04-09 12:26:35 +08:00
local endStr = os.date(Language[11383], endTime)
local startStr = os.date(Language[11383], endTime - duration + 1)
2020-05-09 13:31:21 +08:00
return startStr, endStr
end
2020-06-03 19:09:01 +08:00
--礼包抢购是否开启
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
2020-06-28 17:52:29 +08:00
2021-11-25 17:27:02 +08:00
-- 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
2020-07-17 18:20:31 +08:00
2021-06-03 12:04:04 +08:00
--检测心愿抽卡活动红点
function this.GetWishDrawRedPointStatus()
local activityId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.LimitUpHero)
if not activityId then
return false
end
local wish=ConfigManager.TryGetConfigData(ConfigName.WishActivitySetting,1)
if not wish then
return false
end
local freeTimesId=wish.FreeTimes
local freeTime= 0
if freeTimesId>0 then
freeTime= PrivilegeManager.GetPrivilegeRemainValue(freeTimesId)
RecruitManager.freeUseTimeList[freeTimesId]=freeTime
return freeTime and freeTime >= 1
end
end
2021-11-26 17:54:35 +08:00
function this.GetTianDiHongLuRedPointStatus()
local lotterySetting=ConfigManager.GetConfig(ConfigName.LotterySetting)
local activityId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.tiandihonglu)
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
2021-06-03 12:04:04 +08:00
2020-07-17 18:20:31 +08:00
function this.GetQiankunBoxRedPointStatus()
local lotterySetting=ConfigManager.GetConfig(ConfigName.LotterySetting)
2020-09-25 14:11:05 +08:00
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
2020-07-17 18:20:31 +08:00
local freeTime= 0
if freeTimesId>0 then
freeTime= PrivilegeManager.GetPrivilegeRemainValue(freeTimesId)
RecruitManager.freeUseTimeList[freeTimesId]=freeTime
return freeTime and freeTime >= 1
end
end
2020-07-09 10:04:20 +08:00
this.TimeLimitedTimes = 0
2020-08-20 17:36:19 +08:00
this.allData = {}
2020-09-25 14:11:05 +08:00
function this.InitDynamicActData()
local id = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.DynamicAct)
if (not id) or id < 1 then
2020-08-20 17:36:19 +08:00
return nil
end
this.allData = {}
local allListData = ConfigManager.GetAllConfigsDataByKey(ConfigName.ThemeActivityTaskConfig, "ActivityId", id)
2020-09-25 14:11:05 +08:00
local allMissionData = TaskManager.GetTypeTaskList(TaskTypeDef.DynamicActTask)
-- --LogGreen("allMissionData:"..#allMissionData)
2020-08-20 17:36:19 +08:00
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
2021-01-26 17:08:39 +08:00
local strs = string.split(GetLanguageStrById(allListData[i].Show),"#")
2020-08-20 17:36:19 +08:00
data.title = strs[1]
data.content = strs[2]
data.value = allListData[i].TaskValue[2][1]
2020-09-25 14:11:05 +08:00
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
2020-08-20 17:36:19 +08:00
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
2021-07-23 11:45:13 +08:00
function this.CheckDynamicActTaskRed(red)
2020-09-25 14:11:05 +08:00
this.InitDynamicActData()
2020-08-20 17:36:19 +08:00
if not this.allData then
return false
end
2021-07-23 11:45:13 +08:00
local type
if red == RedPointType.DynamicActTask_MeiRi then
type = 1
elseif red == RedPointType.DynamicActTask_MeiZhou then
type = 2
else
type = 0
end
2020-08-20 17:36:19 +08:00
for i=1,#this.allData do
2021-07-23 11:45:13 +08:00
if this.allData[i].state == 1 and (type == 0 or (this.allData[i].type == type)) then
2020-08-20 17:36:19 +08:00
return true
end
end
return false
end
2020-11-04 03:51:04 +08:00
function this.InitLeiJiChongZhiData(_type)
local id = 0
local type = _type
2020-10-29 09:50:47 +08:00
if type then
id = ActivityGiftManager.IsActivityTypeOpen(type)
2020-11-04 03:51:04 +08:00
if (not id) or id == 0 then
return nil
end
2020-10-29 09:50:47 +08:00
else
id = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.AccumulativeRechargeExper)
2020-11-04 03:51:04 +08:00
if (not id) or id == 0 then
2020-10-29 10:12:47 +08:00
id = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.DynamicAct_recharge)
if (not id) or id == 0 then
return nil
else
type = ActivityTypeDef.DynamicAct_recharge
end
else
type = ActivityTypeDef.AccumulativeRechargeExper
2020-10-29 09:50:47 +08:00
local tempConfig = ConfigManager.GetConfigData(ConfigName.GlobalActivity,id)
if tempConfig and tempConfig.ShowArt == 1 then
return nil
end
2020-11-04 03:51:04 +08:00
end
2020-08-21 16:39:30 +08:00
end
2020-10-29 09:50:47 +08:00
2020-08-21 18:30:44 +08:00
this.LeiJiChongZhiData = {}
2020-08-21 16:39:30 +08:00
local allListData = ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityRewardConfig, "ActivityId", id)
2020-11-04 03:51:04 +08:00
local allMissionData = ActivityGiftManager.GetActivityTypeInfo(type)
2020-08-21 16:39:30 +08:00
for i=1,#allListData do
2020-08-21 18:30:44 +08:00
for j=1,#allMissionData.mission do
if allListData[i].Id == allMissionData.mission[j].missionId then
2020-08-21 16:39:30 +08:00
local data = {}
2020-08-21 18:30:44 +08:00
data.id = allMissionData.mission[j].missionId
2020-08-26 11:11:14 +08:00
data.progress = allMissionData.value
2020-08-21 16:39:30 +08:00
data.value = allListData[i].Values[1][1]
2020-08-21 18:30:44 +08:00
data.state = allMissionData.mission[j].state == 1 and allMissionData.mission[j].state or (data.progress>= data.value and 2 or 0) -- 0 前往 1已领奖 2领奖
2020-08-21 16:39:30 +08:00
data.reward = allListData[i].Reward
data.jump = allListData[i].Jump[1]
2020-08-21 18:30:44 +08:00
table.insert(this.LeiJiChongZhiData,data)
2020-08-21 16:39:30 +08:00
end
end
end
2020-08-21 18:30:44 +08:00
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)
2020-09-25 14:11:05 +08:00
if mission[j].state == 2 then
2020-08-21 18:30:44 +08:00
return true
end
end
return false
2020-08-21 16:39:30 +08:00
end
2020-09-25 14:11:05 +08:00
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
2021-03-12 14:31:53 +08:00
end
2020-09-25 14:11:05 +08:00
end
end
return false
end
--为限时神装写的(只有一个)
function this.GetTimeLimitSkinInfoList()
2021-03-12 14:31:53 +08:00
local giftList={}
local infoList = OperatingManager.GetGiftGoodsInfoList(GoodsTypeDef.DirectPurchaseGift)--拿取所有类型5礼包信息(包含需要的礼包)
local infoList2 = ConfigManager.GetConfigDataByKey(ConfigName.RechargeCommodityConfig,"ShowType",29)
for index, value in pairs(infoList) do
2021-03-13 15:09:34 +08:00
if infoList2.Id == value.goodsId and value.dynamicBuyTimes > 0 then
return value
end
end
2021-03-13 15:09:34 +08:00
return nil
end
--为限时折扣写的(含有多个)
2021-06-17 15:05:44 +08:00
function this.GetInfoList(showData)
local giftList={}
local infoList = OperatingManager.GetGiftGoodsInfoList(GoodsTypeDef.DirectPurchaseGift)--拿取所有类型5礼包信息(包含需要的礼包)
2021-06-17 15:05:44 +08:00
if not showData or #showData < 1 then
return giftList
end
2021-06-17 15:05:44 +08:00
local giftList2 = {}
for i = 1,#showData[1] do
local infoList2 = ConfigManager.GetAllConfigsDataByKey(ConfigName.RechargeCommodityConfig,"ShowType",showData[1][i])
for i = 1, #infoList2 do
table.insert(giftList2,infoList2[i])
end
end
for index, value in pairs(infoList) do
2021-06-17 15:05:44 +08:00
for i = 1, #giftList2 do
if giftList2[i].Id == value.goodsId and value.dynamicBuyTimes > 0 then
table.insert(giftList,value)
end
end
end
return giftList
end
2020-06-23 18:36:24 +08:00
return this