903 lines
30 KiB
Lua
903 lines
30 KiB
Lua
--[[
|
||
* @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")
|
||
|
||
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
|
||
|
||
-- 月卡激活提示内容,也用来标记是否需要拍脸提示
|
||
this.showStr = ""
|
||
--初始化
|
||
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 = ""
|
||
end
|
||
|
||
---------------------------局限性----------------------------
|
||
function this.SetBasicValues(giftGoodsList)
|
||
giftGoodsInfo = giftGoodsList
|
||
for _, v in pairs(GoodsTypeDef) do
|
||
giftGoodsInfoList[v] = {}
|
||
end
|
||
for _, giftGoodsInfo in ipairs(giftGoodsList) do
|
||
if giftGoodsInfo.goodsId and giftGoodsInfo.goodsId ~= 0 then
|
||
local rechargeConfigLocal = ConfigManager.TryGetConfigData(ConfigName.RechargeCommodityConfig, giftGoodsInfo.goodsId)
|
||
if rechargeConfigLocal then
|
||
-- 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
|
||
end
|
||
else
|
||
LogError("服务器发过来一个前端表中不存在的礼包:"..tostring(giftGoodsInfo.goodsId))
|
||
end
|
||
end
|
||
end
|
||
Game.GlobalEvent:DispatchEvent(GameEvent.FindFairy.RefreshBuyOpenState)
|
||
end
|
||
|
||
--判断商品是否可购买(成长礼)
|
||
function this.IsGrowthGiftGoodsAvailable(goodsType)
|
||
for _, v in ipairs(giftGoodsInfo)do
|
||
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
|
||
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 or v.isBought>0 )then
|
||
return true
|
||
end
|
||
end
|
||
return false
|
||
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("此类商品不存在")
|
||
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 {}
|
||
if not giftGoodsInfoList[type] then
|
||
LogError("没有这个类型的礼包:"..tostring(type))
|
||
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
|
||
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("此类基金尚未激活!, 商品ID是 -- " .. 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 not goodsId then
|
||
--LogError("goodid====="..goodsId)
|
||
return v.buyTimes
|
||
end
|
||
if v.goodsId == goodsId then
|
||
if rechargeConfig[goodsId] then
|
||
if rechargeConfig[goodsId].Otype==3 then
|
||
return v.isBought
|
||
else
|
||
return v.buyTimes
|
||
end
|
||
end
|
||
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 not giftGoodsInfo then return false end
|
||
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
|
||
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] and 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 = GetLanguageStrById(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[11383], endTime)
|
||
local startStr = os.date(Language[11383], endTime - duration + 1)
|
||
return startStr, endStr
|
||
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.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
|
||
|
||
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
|
||
|
||
|
||
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
|
||
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(GetLanguageStrById(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(red)
|
||
this.InitDynamicActData()
|
||
if not this.allData then
|
||
return false
|
||
end
|
||
local type
|
||
if red == RedPointType.DynamicActTask_MeiRi then
|
||
type = 1
|
||
elseif red == RedPointType.DynamicActTask_MeiZhou then
|
||
type = 2
|
||
else
|
||
type = 0
|
||
end
|
||
for i=1,#this.allData do
|
||
if this.allData[i].state == 1 and (type == 0 or (this.allData[i].type == type)) then
|
||
return true
|
||
end
|
||
end
|
||
return false
|
||
end
|
||
function this.InitLeiJiChongZhiData(_type)
|
||
local id = 0
|
||
local type = _type
|
||
if type then
|
||
id = ActivityGiftManager.IsActivityTypeOpen(type)
|
||
if (not id) or id == 0 then
|
||
return nil
|
||
end
|
||
else
|
||
id = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.AccumulativeRechargeExper)
|
||
if (not id) or id == 0 then
|
||
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
|
||
local tempConfig = ConfigManager.GetConfigData(ConfigName.GlobalActivity,id)
|
||
if tempConfig and tempConfig.ShowArt == 1 then
|
||
return nil
|
||
end
|
||
end
|
||
end
|
||
|
||
this.LeiJiChongZhiData = {}
|
||
local allListData = ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityRewardConfig, "ActivityId", id)
|
||
local allMissionData = ActivityGiftManager.GetActivityTypeInfo(type)
|
||
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
|
||
|
||
function this.CheckTimeLimitHeroStoreRedPoint()
|
||
local boughtNum = 0
|
||
local limitNum = 0
|
||
local shopData = OperatingManager.GetGiftGoodsInfoList(GoodsTypeDef.DirectPurchaseGift)
|
||
for i = 1, #shopData do
|
||
if rechargeConfig[shopData[i].goodsId].ShowType == DirectBuyType.XIANSHIMIBAO 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
|
||
local red=DynamicActivityManager.CheckMingWangRed()
|
||
if red then
|
||
return true
|
||
end
|
||
return false
|
||
|
||
|
||
end
|
||
|
||
--为限时神装写的(只有一个)
|
||
function this.GetTimeLimitSkinInfoList()
|
||
local giftList={}
|
||
local infoList = OperatingManager.GetGiftGoodsInfoList(GoodsTypeDef.DirectPurchaseGift)--拿取所有类型5礼包信息(包含需要的礼包)
|
||
local infoList2 = ConfigManager.GetConfigDataByKey(ConfigName.RechargeCommodityConfig,"ShowType",29)
|
||
for index, value in pairs(infoList) do
|
||
if infoList2.Id == value.goodsId and value.dynamicBuyTimes > 0 then
|
||
return value
|
||
end
|
||
end
|
||
return nil
|
||
end
|
||
--为限时折扣写的(含有多个)
|
||
function this.GetInfoList(showData)
|
||
local giftList={}
|
||
local infoList = OperatingManager.GetGiftGoodsInfoList(GoodsTypeDef.DirectPurchaseGift)--拿取所有类型5礼包信息(包含需要的礼包)
|
||
if not showData or #showData < 1 then
|
||
return giftList
|
||
end
|
||
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
|
||
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
|
||
|
||
return this |