miduo_client/Assets/ManagedResources/~Lua/Modules/FirstRecharge/FirstRechargeManager.lua

152 lines
4.9 KiB
Lua
Raw Normal View History

2020-05-09 13:31:21 +08:00
--[[
* @ClassName FirstRechargeManager
* @Description
* @Date 2019/7/4 19:11
* @Author MagicianJoker, fengliudianshao@outlook.com
* @Copyright Copyright (c) 2019, MagicianJoker
--]]
FirstRechargeManager = {}
local this = FirstRechargeManager
local activityRewardConfig = ConfigManager.GetConfig(ConfigName.ActivityRewardConfig)
local AccumRechargeValue
--充值
local rechargeTime
function this.Initialize()
end
function this.GetFirstRechargeRedPointStatus()
local redPoint = false
if ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.FirstRecharge) then
if ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.AccumulativeRecharge) then
redPoint = redPoint or this.GetSixMoneyTabRedPointStatus()
redPoint = redPoint or this.GetHundredTabRedPointStatus()
end
end
return redPoint
end
function this.GetSixMoneyTabRedPointStatus()
local redPoint = false
for _, rewardInfo in ConfigPairs(activityRewardConfig) do
if rewardInfo.ActivityId == ActivityTypeDef.AccumulativeRecharge and
rewardInfo.Values[1][1] == IndexValueDef[1] then
redPoint = redPoint or this.GetDayItemRedPoint(rewardInfo)
end
end
return redPoint
end
function this.GetHundredTabRedPointStatus()
local redPoint = false
for _, rewardInfo in ConfigPairs(activityRewardConfig) do
if rewardInfo.ActivityId == ActivityTypeDef.AccumulativeRecharge and
rewardInfo.Values[1][1] == IndexValueDef[2] then
redPoint = redPoint or this.GetDayItemRedPoint(rewardInfo)
end
end
return redPoint
end
function this.GetDayItemRedPoint(context)
local activityInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.AccumulativeRecharge)
local AccumRecharge = 0
for _, missInfo in pairs(activityInfo.mission) do
if missInfo and missInfo.progress then
AccumRecharge = missInfo.progress
end
end
--if this.GetAccumRechargeValue() == 0 then
if AccumRecharge == 0 then
return false
else
--if this.GetAccumRechargeValue() >= context.Values[1][1] then
if AccumRecharge >= context.Values[1][1] then
if this.isFirstRecharge == 0 then
this.SetRechargeTime(math.floor(GetTimeStamp()))
this.isFirstRecharge = 1
end
local day = GetTimePass(this.GetRechargeTime())
--local day = GetTimePass(math.floor(GetTimeStamp()))
if context.Values[1][2] <= day then
local state = ActivityGiftManager.GetActivityInfo(ActivityTypeDef.AccumulativeRecharge, context.Id).state
return state ~= 1
else
return false
end
else
return false
end
end
return false
end
function this.GetReceiveAll()
local condition = true
local activityInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.AccumulativeRecharge)
if activityInfo then
for i = 1, #activityInfo.mission do
local rechargeInfo = activityInfo.mission[i]
condition = condition and rechargeInfo.state == 1
end
end
return condition
end
function this.GetFirstRechargeExist()
if this.GetReceiveAll() or ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.FirstRecharge) == nil then
return false
end
return true
end
-----------首充,累充相关----------------------
this.isFirstRecharge = 0
--刷新累计充值金额
function this.RefreshAccumRechargeValue(goodsId)
--local rechargeConfig = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig, goodsId)
--if rechargeConfig.AccumulativeRecharge == 0 then return end
if this.isFirstRecharge == 0 then
Log("sssssssssss-------------------------ssssssss")
this.SetRechargeTime(math.floor(GetTimeStamp()))
this.isFirstRecharge = 1
end
--this.SetAccumRechargeValue(rechargeConfig.Price, true)
if(LuckyCatManager.isOpenLuckyCat) then
--LuckyCatManager.SetAccumRechargeValue(rechargeConfig.Price)
LuckyCatManager.SetAccumRechargeValue()
end
end
function this.SetAccumRechargeValue(value, flag)
Log("this.SetAccumRechargeValue!!!!!! value:"..value)
--local activityInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.AccumulativeRecharge)
--if activityInfo.mission then
-- for _, treasureInfo in ipairs(activityInfo.mission) do
-- AccumRechargeValue = treasureInfo.progress
-- end
--end
if flag then
AccumRechargeValue = AccumRechargeValue + value
CheckRedPointStatus(RedPointType.FirstRecharge)
else
AccumRechargeValue = value
end
end
function this.GetAccumRechargeValue()
return AccumRechargeValue
end
function this.SetRechargeTime(value)
rechargeTime = value
end
function this.GetRechargeTime()
return rechargeTime
end
return this