203 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			Lua
		
	
			
		
		
	
	
			203 lines
		
	
	
		
			6.4 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
 | 
						|
        redPoint = redPoint or this.GetRedPointStatus(1)
 | 
						|
        redPoint = redPoint or this.GetRedPointStatus(2)
 | 
						|
    end
 | 
						|
    return redPoint
 | 
						|
end
 | 
						|
 | 
						|
function this.GetRedPointStatus(index)
 | 
						|
    local redPoint = false
 | 
						|
    local money = FirstRechargeManager.GetFirstRechargeMoneyByIndex(index)
 | 
						|
    local activityInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.FirstRecharge)
 | 
						|
    for _, missionInfo in ipairs(activityInfo.mission) do
 | 
						|
        local rewardInfo = activityRewardConfig[missionInfo.missionId]
 | 
						|
        if rewardInfo and rewardInfo.Values[1][1] == money then
 | 
						|
            redPoint = redPoint or this.GetDayItemRedPoint(missionInfo, rewardInfo)
 | 
						|
        end
 | 
						|
    end
 | 
						|
    return redPoint
 | 
						|
end
 | 
						|
 | 
						|
 | 
						|
function this.GetDayItemRedPoint(missionInfo, context)
 | 
						|
    local AccumRecharge = missionInfo.progress
 | 
						|
    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 = missionInfo.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
 | 
						|
        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("充值金额:"..value)
 | 
						|
    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
 | 
						|
 | 
						|
-- 获取充值配置数据
 | 
						|
function this.GetFirstRechargeConfig()
 | 
						|
    if not this.IndexToMoney then
 | 
						|
        -- 获取首充配置数据
 | 
						|
        local firstRechargeConfig = ConfigManager.GetConfigData(ConfigName.SpecialConfig, 129)
 | 
						|
        if firstRechargeConfig then
 | 
						|
            local ml = string.split(firstRechargeConfig.Value, "|")
 | 
						|
            if not ml or not ml[MoneyUtil.MT] then
 | 
						|
                LogError("未找到对应币种的首充配置数据: "..tostring(MoneyUtil.MT))
 | 
						|
                return 
 | 
						|
            end
 | 
						|
            local itm = string.split(ml[MoneyUtil.MT], "#")
 | 
						|
            if itm and #itm > 0 then
 | 
						|
                this.IndexToMoney = {}
 | 
						|
                for _, v in ipairs(itm) do
 | 
						|
                    table.insert(this.IndexToMoney, tonumber(v))
 | 
						|
                end
 | 
						|
            end
 | 
						|
        else
 | 
						|
            LogError("未找到首充配置数据")
 | 
						|
            return
 | 
						|
        end
 | 
						|
    end
 | 
						|
    return this.IndexToMoney
 | 
						|
end
 | 
						|
-- 通过首充裆位获取该裆位所需的充值金额
 | 
						|
function this.GetFirstRechargeMoneyByIndex(index)
 | 
						|
    local config = this.GetFirstRechargeConfig()
 | 
						|
    if not config then
 | 
						|
        LogError("未找到首充配置数据")
 | 
						|
        return
 | 
						|
    end
 | 
						|
    return config[index]
 | 
						|
end
 | 
						|
-- 根据裆位金额获取裆位
 | 
						|
function this.GetFirstRechargeIndexByMoney(money)
 | 
						|
    local config = this.GetFirstRechargeConfig()
 | 
						|
    if not config then
 | 
						|
        LogError("未找到首充配置数据")
 | 
						|
        return
 | 
						|
    end
 | 
						|
    for i, m in ipairs(config) do
 | 
						|
        if m == money then
 | 
						|
            return i
 | 
						|
        end
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
return this |