180 lines
		
	
	
		
			5.9 KiB
		
	
	
	
		
			Lua
		
	
			
		
		
	
	
			180 lines
		
	
	
		
			5.9 KiB
		
	
	
	
		
			Lua
		
	
--[[
 | 
						|
 * @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.FirstRecharge) 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.FirstRecharge and
 | 
						|
                rewardInfo.Values[1][1] == IndexValueDef[MoneyUtil.MT][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.FirstRecharge and
 | 
						|
                rewardInfo.Values[1][1] == IndexValueDef[MoneyUtil.MT][2] then
 | 
						|
            redPoint = redPoint or this.GetDayItemRedPoint(rewardInfo)
 | 
						|
        end
 | 
						|
    end
 | 
						|
    return redPoint
 | 
						|
end
 | 
						|
 | 
						|
function this.GetDayItemRedPoint(context)
 | 
						|
    local activityInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.FirstRecharge)
 | 
						|
    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.FirstRecharge, 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.FirstRecharge)
 | 
						|
    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)
 | 
						|
    -- 价格是0元的礼包不再算做充值
 | 
						|
    local rechargeConfig = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig, goodsId)
 | 
						|
    if rechargeConfig.Price == 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
 | 
						|
    CheckRedPointStatus(RedPointType.Expert_AccumulativeRecharge)
 | 
						|
    CheckRedPointStatus(RedPointType.DynamicActRecharge)
 | 
						|
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
 | 
						|
--设置红点存储本地
 | 
						|
function this.PlayerPrefsSetStrItemId(val)
 | 
						|
    PlayerPrefs.SetInt(PlayerManager.uid.."FirstRechatgePace", val)
 | 
						|
end
 | 
						|
--获得红点信息
 | 
						|
function this.PlayerPrefsGetStrItemId()
 | 
						|
    return PlayerPrefs.GetInt(PlayerManager.uid.."FirstRechatgePace", 0)--1 已经查看过不需要显示新红点  0 显示红点
 | 
						|
end
 | 
						|
 | 
						|
function this.IsShowFirstChatge()
 | 
						|
    if FirstRechargeManager.isFirstRecharge == 1 and FirstRechargeManager.PlayerPrefsGetStrItemId() == 0 and ActTimeCtrlManager.IsQualifiled(38) and FirstRechargeManager.GetFirstRechargeExist() then
 | 
						|
        return true
 | 
						|
    else
 | 
						|
        return false
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
-- 
 | 
						|
function this.GetAnimFlag(key)
 | 
						|
    local lt = PlayerPrefs.GetInt(PlayerManager.uid..key)
 | 
						|
    return Util_Check_insameday(lt, GetTimeStamp())
 | 
						|
end
 | 
						|
function this.SetAnimFlag(key)
 | 
						|
    PlayerPrefs.SetInt(PlayerManager.uid..key, GetTimeStamp())
 | 
						|
end
 | 
						|
 | 
						|
return this |