--[[@------------------------------------------------------------------ @description:VIP模块 @author:huangcong ----------------------------------------------------------------------]] VipModel = VipModel or BaseClass(BaseModel) local stringtotable = stringtotable VipModel.REQUEST_CCMD_EVENT = "VipModel.REQUEST_CCMD_EVENT" VipModel.UPDATE_VIP_INFO = "VipModel.UPDATE_VIP_INFO" --更新VIP信息 VipModel.UPDATE_VIP_VIEW_RED = "VipModel.UPDATE_VIP_VIEW_RED" --更新vip界面红点 VipModel.UPDATE_MAIN_VIEW_BG_RES = "VipModel.UPDATE_MAIN_VIEW_BG_RES" --更新主界面背景资源 VipModel.UPDATE_RECHARGE_CARD_DATA = "VipModel.UPDATE_RECHARGE_CARD_DATA" --更新充值卡数据 VipModel.UPDATE_RECHARGE_ITEM_DATA = "VipModel.UPDATE_RECHARGE_ITEM_DATA" -- VipModel.OPEN_VIP_RENEW_VIEW = "VipModel.OPEN_VIP_RENEW_VIEW" --打开续费界面 VipModel.OPEN_EXPERIENCE_VIEW = "VipModel.OPEN_EXPERIENCE_VIEW" --打开VIP体验界面 VipModel.SHOW_EXPERIENCE_TASK_TIP = "VipModel.SHOW_EXPERIENCE_TASK_TIP" --展示VIP体验任务栏飞鞋特权信息 VipModel.OPEN_EXPERIENCE_V_THREE_VIEW = "VipModel.OPEN_EXPERIENCE_V_THREE_VIEW"--打开VIP体验贵族V3界面 VipModel.OPEN_EXPERIENCE_V_THREE_EX_VIEW = "VipModel.OPEN_EXPERIENCE_V_THREE_EX_VIEW"--打开VIP体验贵族V3详情界面 VipModel.UPDATE_EXPERIENCE_V_THREE_EX_RED = "VipModel.UPDATE_EXPERIENCE_V_THREE_EX_RED"--更新VIP体验贵族V3图标红点 VipModel.OPEN_CUSTOM_RECHARGE_VIEW = "VipModel.OPEN_CUSTOM_RECHARGE_VIEW" --打开随心充界面 VipModel.UPDATE_TAB_INFO = "VipModel.UPDATE_TAB_INFO" --更新页签信息 VipModel.OPEN_NOBLE_BUY_VIEW = "VipModel.OPEN_NOBLE_BUY_VIEW" --打开vip贵族礼包购买提示界面 VipModel.OPEN_VIP_NOBLE_VIEW = "VipModel.OPEN_VIP_NOBLE_VIEW"--打开VIP特权界面 VipModel.OPEN_VIP_SKILL_EFFECT_VIEW = "VipModel.OPEN_VIP_SKILL_EFFECT_VIEW"--特权技能界面 -- 投资相关 start VipModel.UPDATE_INVESTMENT_DATA = "VipModel.UPDATE_INVESTMENT_DATA" -- 更新投资计划协议信息 -- 投资相关 end -- 幻魔UP卡 start VipModel.UPDATE_VIP_CARD_INFO = "VipModel.UPDATE_VIP_CARD_INFO" -- 幻魔UP卡信息更新 -- 幻魔UP卡 end VipModel.REGISTER_MASK_ID = "VipModel.REGISTER_MASK_ID" --注册mask_id VipModel.BIND_GIFTS_PRODUCT_ID = 20 --红钻礼包商品id VipModel.IOSAlpha_PRODUCT_ID = 999 --iOS审核状态下商品id VipModel.TabType = { Recharge = 1,--充值 Noble = 2,--特权 PurchaseGift = 3,--直购礼包 Investment = 4, -- 投资计划 HopeGift = 5, -- 投资计划 Card = 6, --幻魔UP卡 -- Investment = 4, -- Seven = 5, -- Renew = 6, -- Open_Recharge = 7, -- Every_Recharge = 8, -- SuperInvest = 9, -- GodInvest = 10, -- MergeInvest = 11, } VipModel.Type = {--直购礼包类型Config.Rechargegoods PurchaseGift = 4,--直购礼包 FirstRecharge = 5,--首充 } VipModel.VIP_CARD = { WEEK = 301, --周卡 MONTH = 302, --月卡 SEASON = 303, --季卡 } --尊享卡概率 VipModel.VIP_CARD_RATIO = { Evolotion = 500, --升星概率 Strength = 500, --强化概率 MonthEquipDrop = 500, --月卡橙装掉率 SeasonEquipDrop = 1000, --季卡橙装掉率 } VipModel.PurchaseGiftType = {--直购礼包类型 Day = 1,--天 Week = 2,--周 Month = 3,--月(但是在直购这里代表终身礼包) } VipModel.PurchaseGiftTypeName = {--直购礼包类型名字 [1] = "每日精选礼包",--天 [2] = "每周精选礼包",--周 [3] = "每月精选礼包",--月(但是在直购这里代表终身礼包) } function VipModel:__init() VipModel.Instance = self self.vip_info = nil self.vip_red_dot_info = {} self.product_list = {} self.vip_gift_list = {}--VIP专属礼包信息 self.vip_gift_find_list = {}--vip礼包查询列表 self.is_first_red = true--第一次VIP要有红点 self.vip_max_level = TableSize(Config.Vipgift) self.product_info = {}--15903商品信息 -- 投资相关 self.investment_login_red = true -- 投资计划登录红点 self.investment_type_cfg = {} -- 投资计划类型配置 self.investment_data = {} -- 投资计划已投资信息 self.investment_cfg = {} -- 投资计划配置 self.investment_view_item_data = {} -- 投资计划主界面,节点数据缓存 self.investment_red = {} -- 投资计划红点 格式为 [type] = true / false self._block_update_invsetment_data = false -- 是否拦截投资协议信息的更新 self._cache_invsetment_data = nil -- 当打开界面后,不主动更新42001协议的数据,关闭界面或者手动购买即检测缓存并覆盖协议数据 self.is_active_vip_three = false self.is_open_vip_ex_1 = false--是否第一次打开过 self.can_todo_task = true -- self.service_data = nil self.vipcard_info = {} --幻魔UP卡信息 self:InitVipCfg() self:InitInvestmentPlayCfg() end function VipModel:getInstance() if VipModel.Instance == nil then VipModel.New() end return VipModel.Instance end function VipModel:InitVipCfg( ) self.vip_cfg = {}--vip配置 local cfg_data = DeepCopy(Config.Vipcfg) for k,v in pairs(cfg_data) do v.reward = stringtotable(v.reward) self.vip_cfg[v.lv] = v end self.vip_gift_cfg = {}--vip特权礼包配置 local gift_cfg_data = DeepCopy(Config.Vipgift) for k,v in pairs(gift_cfg_data) do local data = v data.gift_reward = stringtotable(v.gift_reward)--奖励展示 self.vip_gift_cfg[v.vip_lv] = v end self.vip_rechargeGoods_cfg = {}--直购礼包商品配置 self.vip_rechargeGoods_id_cfg = {}--直购礼包商品配置Id索引 local vip_rechargeGoods_cfg = DeepCopy(Config.Rechargegoods) for k,v in pairs(vip_rechargeGoods_cfg) do local data = v data.name = Trim(data.name) data.about = Trim(data.about) data.limit = stringtotable(v.limit)--类型和购买限制次数 data.open_day = stringtotable(v.open_day)--开服天数限制 data.condition = stringtotable(v.condition)--等级vip限制还有折扣 data.award = stringtotable(v.award)--展示奖励 if not self.vip_rechargeGoods_cfg[v.type] then self.vip_rechargeGoods_cfg[v.type] = {} end self.vip_rechargeGoods_cfg[v.type][#self.vip_rechargeGoods_cfg[v.type] + 1] = v self.vip_rechargeGoods_id_cfg[v.id] = v end -- print("huangcong:VipModel [start:96] :", self.vip_rechargeGoods_cfg) -- PrintTable(self.vip_rechargeGoods_cfg[4]) -- print("huangcong:VipModel [end]") end --得到vip通用配置 function VipModel:GetVipCfg( vip_lv ) return self.vip_cfg[vip_lv] end --得到vip礼包配置 function VipModel:GetVipGiftCfg( vip_lv ) return self.vip_gift_cfg[vip_lv] end function VipModel:IsNeedRedAll( )--这样写红点 每次调全局的只要调两次 self.vip_red_dot_info[VipModel.TabType.Noble] = self:CheckVipNobleRedDot() self:CheckVipMainIconRedDot() end function VipModel:IsNeedRed( view_type,is_all,sub_type ) local bool = false if view_type == VipModel.TabType.Noble then--贵族 bool = self:CheckVipNobleRedDot() elseif view_type == VipModel.TabType.PurchaseGift then--直购 bool = self:CheckPurchaseGiftFreeRed() elseif view_type == VipModel.TabType.Investment then--投资计划 bool = self:CheckInvestmentPlanRed() elseif view_type == VipModel.TabType.HopeGift and sub_type then--臻享礼包这里是多开活动ID要不同变化 view_type = sub_type + 3316500 bool = self:CheckHopeGiftRedDot(sub_type) elseif view_type == VipModel.TabType.Card then--幻魔UP卡 bool = self:CheckVipCardRedDot() elseif view_type == VipModel.TabType.Recharge then--充值 bool = KfActivityModel:getInstance():IsMoneyCopyRedByTag( "charge" ) end self.vip_red_dot_info[view_type] = bool self:Fire(VipModel.UPDATE_VIP_VIEW_RED,view_type,bool) if not is_all then -- self:CheckVipMainIconRedDot() end -- print("huangcong:VipModel [62]: ",bool,id) -- PrintTable(self.vip_red_dot_info) end --检查主界面VIP红点 function VipModel:CheckVipMainIconRedDot( ) local show = false for k,v in pairs(self.vip_red_dot_info) do if v == true then show = v break end end -- if not self:GetVipRedCookie() then -- show = true -- end return show end function VipModel:SetFisrtRed( bool ) self.is_first_red = bool end --检查臻享礼包红点 function VipModel:CheckHopeGiftRedDot( sub_type ) if not sub_type then return false end return HopeGiftModel:getInstance():GetHopeGiftRedDot(sub_type) end --检查vip特权红点 function VipModel:CheckVipNobleRedDot( ) local bool = false local vip_flag = RoleManager.Instance.mainRoleInfo.vip_flag if self.vip_info and self.vip_info.vip_endtime and self.vip_info.vip_endtime - TimeUtil:getServerTime( ) <= 0 then if vip_flag >= 1 then for i=1,vip_flag do bool = not self:GetVipGiftFindByVipLv(i) if bool then break end end if not bool and self.vip_info.vip_award_list and #self.vip_info.vip_award_list > 0 then bool = true end end end return bool end --45001 刷新VIP界面信息 function VipModel:UpdateVipInfomation(vo) self.vip_info = vo if vo.vip_lv ~= 0 then self.is_vip = false end if RoleManager.Instance.mainRoleInfo.vip_flag < 3 and self.vip_info.vip_lv == 3 and not self.is_active_vip_three then--说明升级到V3了 self.is_active_vip_three = true self:PlayVipThreeStep()--开始V3激活步骤 end --如果当前时间小于VIP结束时间,需要修改角色的VIP值 local now = TimeUtil:getServerTime() if vo.vip_lv < vo.experience_vip_lv and now < vo.vip_endtime then--体验VIP RoleManager:getInstance():GetMainRoleVo():ChangeVar("vip_flag", vo.experience_vip_lv) else if vo.vip_lv == 4 then--V4的时候要在界面内判断礼包开启~ self:Fire(VipModel.UPDATE_TAB_INFO) end RoleManager:getInstance():GetMainRoleVo():ChangeVar("vip_flag", vo.vip_lv) end -- local vip_type = 1 -- if RoleManager:getInstance():GetMainRoleVo().vip_type ~= vip_type then -- RoleManager:getInstance():GetMainRoleVo():ChangeVar("vip_type", vo.vip_type) -- end self:Fire(VipModel.UPDATE_VIP_INFO, vo) self:Fire(VipModel.REQUEST_CCMD_EVENT,45007) if vo.vip_lv <= 3 then VipModel:getInstance():Fire(VipModel.REQUEST_CCMD_EVENT, 45010) end end --永久VIP function VipModel:IsForeverVip( ) if self.vip_info and self.vip_info.vip_lv > 0 then return true end end --VIP是到期 function VipModel:IsVipExperience( ) if self.vip_info and self.vip_info.vip_endtime then return self.vip_info.vip_endtime - TimeUtil:getServerTime() > 0 end end --获得Vip信息 function VipModel:GetVipInfomation() return self.vip_info end --得到VIP类型 1王权 2皇权 3神权 function VipModel:GetVipType(vip_lv) local vip_type = 1 local vip_type_name = "王权" local vip_type_lv = 0 local cfg = self:GetVipCfg(vip_lv) if cfg then if cfg.type >= 101 and cfg.type <= 200 then vip_type = 1 vip_type_name = "王权" vip_type_lv = cfg.type - 100 elseif cfg.type >= 201 and cfg.type <= 300 then vip_type = 2 vip_type_name = "皇权" vip_type_lv = cfg.type - 200 elseif cfg.type >= 301 then vip_type = 3 vip_type_name = "神权" vip_type_lv = cfg.type - 300 end end return vip_type,vip_type_name,vip_type_lv end --设置充值卡数据 function VipModel:SetRechargeCardData(data) if PlatformMgr:getInstance():IsEyouPlatform() then --eyou平台充值卡处理 data = self:EyouPlatformRecharge(data) end self.recharge_card_data = data self:Fire(VipModel.UPDATE_RECHARGE_CARD_DATA) end --筛选出eyou平台的用的充值配置 function VipModel:EyouPlatformRecharge(data) if RuntimePlatform and data and data.product_list then local remove_index_list = {} if SystemRuntimePlatform.IsIphone() then --苹果手机 if PlatformMgr:getInstance():IsTWAreaCurrency() then --臺灣地區 for i,v in ipairs(data.product_list) do local cfg = self:GetEyouIOSRechargeTwProductCfg(v.product_id) if cfg == nil or cfg.is_show == 0 then table.insert(remove_index_list, i) end end else --非臺灣地區 for i,v in ipairs(data.product_list) do local cfg = self:GetEyouIOSRechargeNotTwProductCfg(v.product_id) if cfg == nil or cfg.is_show == 0 then table.insert(remove_index_list, i) end end end elseif SystemRuntimePlatform.IsAndroid() then --安卓 if PlatformMgr:getInstance():IsTWAreaCurrency() then --台湾地区 for i,v in ipairs(data.product_list) do local cfg = self:GetEyouAndroidRechargeTwProductCfg(v.product_id) if cfg == nil or cfg.is_show == 0 then table.insert(remove_index_list, i) end end else --非台湾地区 for i,v in ipairs(data.product_list) do local cfg = self:GetEyouAndroidRechargeNotTwProductCfg(v.product_id) if cfg == nil or cfg.is_show == 0 then table.insert(remove_index_list, i) end end end end local del_num = 0 for i,v in ipairs(remove_index_list) do local index = v - del_num table.remove(data.product_list, index) del_num = del_num + 1 end end return data end --ios儲值配置,臺灣地區,顯示臺幣 function VipModel:GetEyouIOSRechargeTwProductCfg(product_id) local cfg, money_sign for k,v in pairs(Config.Chargeconfig) do if v.plat_type == 2 and v.usd_money == 0 and v.product_id == product_id then cfg = v cfg.money = cfg.local_money money_sign = Trim(cfg.money_sign) end end return cfg, money_sign end --ios儲值配置,非臺灣地區,顯示美元 function VipModel:GetEyouIOSRechargeNotTwProductCfg(product_id) local cfg, money_sign for k,v in pairs(Config.Chargeconfig) do if v.plat_type == 2 and v.local_money == 0 and v.product_id == product_id then cfg = v cfg.money = cfg.usd_money money_sign = "$" end end return cfg, money_sign end --ios充值配置 function VipModel:GetEyouIOSRechargeProductCfg(product_id) local cfg, money_sign for k,v in pairs(Config.Chargeconfig) do if v.plat_type == 2 and v.product_id == product_id then cfg = v cfg.money = cfg.usd_money money_sign = "$" end end return cfg, money_sign end --台湾地区的安卓充值配置,显示本地货币 function VipModel:GetEyouAndroidRechargeTwProductCfg(product_id) local cfg, money_sign for k,v in pairs(Config.Chargeconfig) do if v.plat_type == 1 and v.usd_money == 0 and v.product_id == product_id then cfg = v cfg.money = cfg.local_money money_sign = Trim(cfg.money_sign) end end return cfg, money_sign end --非台湾地区的安卓充值配置,显示美元 function VipModel:GetEyouAndroidRechargeNotTwProductCfg(product_id) local cfg, money_sign for k,v in pairs(Config.Chargeconfig) do if v.plat_type == 1 and v.local_money == 0 and v.product_id == product_id then cfg = v cfg.money = cfg.usd_money money_sign = "$" end end return cfg, money_sign end --从配置中获得对应权限 function VipModel:GetPrivilegeFromConfig(vip_lv) local list = {} for _, v in pairs(Config.Vipprivilege) do if v.lv <= vip_lv then--插入并且重新排列 if not list[v.class_id] then list[v.class_id] = {} end v.sort_id = v.class_id*100000 + v.subclass_id if not list[v.class_id][v.subclass_id] then list[v.class_id][v.subclass_id] = v else if v.lv > list[v.class_id][v.subclass_id].lv then--取高等级的特权 list[v.class_id][v.subclass_id] = v end end end end local new_list = {} for k,v in pairs(list) do for kk,vv in pairs(v) do new_list[#new_list + 1] = vv end end if #list > 1 then local onSort = function (a, b) return a.sort_id < b.sort_id end table.sort(new_list, onSort) end print("huangcong:VipModel [start:446] :", new_list) PrintTable(new_list) print("huangcong:VipModel [end]") return new_list end --VIP升级经验上限 function VipModel:GetExpFromConfig(vip_lv) local total_exp = 0 for _, v in pairs(Config.Viplevelup) do if v.lv <= vip_lv then total_exp = total_exp + v.exp end end return total_exp end --检查VIP体验卡1(获得的时候检查) function VipModel:CheckVipXpCard(goods_list) if not self.is_open_vip_ex_1 then for _, v in pairs(goods_list) do if v.type_id == GuideModel.VIP_EXPERIENCE_ID and RoleManager.Instance.mainRoleInfo.vip_flag == 0 then setTimeout(function() self.is_open_vip_ex_1 = true self:Fire(VipModel.OPEN_EXPERIENCE_VIEW, 1) self:Fire(VipModel.SHOW_EXPERIENCE_TASK_TIP) end, 0.5) break end end end end --检查VIP体验卡2(使用道具的时候检查) function VipModel:CheckVipXpCardByUse(goods_type_id) if goods_type_id == GuideModel.VIP_EXPERIENCE_ID2 then setTimeout(function() GlobalEventSystem:Fire(EventName.CLOSE_BAG_VIEW) self:Fire(VipModel.OPEN_EXPERIENCE_VIEW, 1) self:Fire(VipModel.SHOW_EXPERIENCE_TASK_TIP) end, 0.5) end end --获得VIP特权数值 function VipModel:GetVipPrivilegeValue(vipLv, module_id, subclass_id) if not self.vip_info.vip_type then return 0 end local str = vipLv .. "@" .. module_id .. "@" .. subclass_id local value = 0 local cfg = Config.Vipprivilege[str] if cfg then if self.vip_info.vip_type == 1 then --白银 if cfg.can_try == 1 then value = tonumber(cfg.value) or 0 end elseif self.vip_info.vip_type == 3 then --至尊 value = ( tonumber(cfg.value) + tonumber(cfg.honor_extra) ) or 0 else value = tonumber(cfg.value) or 0 end end return value end --获得充值配置 function VipModel:GetRechargeProductConfig(product_id) return Config.Rechargeproduct[product_id] end --获得充值返利配置 function VipModel:GetRechargeReturnConfig(product_id, return_type) return Config.Rechargereturn[product_id .. "@" .. return_type] end --根据vip等级 获取特权配置 如果没找到 就会遍历上一个等级的 function VipModel:GetVipPrivilegeValue(class_id, subclass_id, vip_lv ) if class_id and subclass_id and vip_lv then local cfg = Config.Vipprivilege[vip_lv.."@"..class_id.."@"..subclass_id.."@1"] if cfg then return cfg.value else if vip_lv == 0 then return 0 else return self:GetVipPrivilegeValue(class_id, subclass_id, vip_lv-1) end end else return 0 end end --得到VIP等级 function VipModel:GetVipLevel() self.vipLevel = self.vip_info and self.vip_info.vip_lv or nil return self.vipLevel or -1 end --设置超级VIP开启条件数据 function VipModel:SetSuperVipOpenData( info ) if not ClientConfig.super_vip_open then return end -- 是否开启超级客服 --本地储存是否 推送过 推送过就退出不推送 local bool = CookieWrapper.Instance:GetCookie(CookieLevelType.Account, CookieKey.SUPER_VIP_SHOW_STATE) if bool then return end local open_day = ServerTimeModel:getInstance():GetOpenServerDay() local cfg = ClientConfig.super_vip_open_config if cfg ~= "" then local data = StrToTable(cfg) for i,vo in ipairs(data) do if open_day >= tonumber(vo.min_open_day) and open_day <= tonumber(vo.max_open_day) then --开发天数条件满足 判断充值条件 for i,v in ipairs(info.month_recharge_record) do --先遍历月充值条件 如果满足 就触发超级VIP 不再继续判断 if v.gold_num >= tonumber(vo.month_recharge_record) then if SceneManager.Instance:IsMainCityAndFieldScene() then self:Fire(VipModel.OPEN_SUPER_VIP_VIEW) else self.is_super_vip = true end return end end for i,v in ipairs(info.daily_recharge_record) do if v.gold_num >= tonumber(vo.daily_recharge_num) then if SceneManager.Instance:IsMainCityAndFieldScene() then self:Fire(VipModel.OPEN_SUPER_VIP_VIEW) return else self.is_super_vip = true end return end end end end end end --是否满足超级会员条件 但是在因为场景没有推送 function VipModel:IsSuperVipPush( ) return self.is_super_vip end --得到VIP卡类型 function VipModel:GetVipCardType( ) local list = {} local cfg = Config.Vipcardnew if cfg then for i,v in pairs(cfg) do if v.type == 2 then table.insert(list,v) end end end return list end --设置vip礼包信息 function VipModel:SetVipGiftInfo( list ) self.vip_gift_list = {} for i,v in ipairs(list) do self.vip_gift_list[v.vip_lv] = v end self:IsNeedRed(VipModel.TabType.Noble) end --得到vip礼包信息 function VipModel:GetVipGiftInfo( vip_lv ) if not vip_lv then return self.vip_gift_list else return self.vip_gift_list[vip_lv] end end --获得VIP最大等级 function VipModel:GetVipMaxLevel( ) return self.vip_max_level end --设置Vip红点cookie function VipModel:SetVipRedCookie(bool) CookieWrapper.Instance:SaveCookie(CookieLevelType.Account,CookieTimeType.TYPE_ALWAYS,CookieKey.VIP_RED_SHOW,bool) CookieWrapper.Instance:WriteAll() end --获取Vip红点cookie function VipModel:GetVipRedCookie() return CookieWrapper.Instance:GetCookie(CookieLevelType.Account, CookieKey.VIP_RED_SHOW) end --免费小飞鞋使用vip等级 function VipModel:GetFreeShoeVip( ) if not self.free_shoe_vip_lv then for k,v in pairs(Config.Vipprivilege) do if v.class_id == 1 and v.subclass_id == 1 then self.free_shoe_vip_lv = v.lv end end end return self.free_shoe_vip_lv or 3 end function VipModel:CanFreeUseShoe( ) local vip = RoleManager.Instance.mainRoleInfo.vip_flag return vip >= VipModel:getInstance():GetFreeShoeVip( ) or VipModel:getInstance():IsVipExperience() end --获得直购礼包配置 function VipModel:GetPurchaseGiftCfg( ) return self.vip_rechargeGoods_cfg[VipModel.Type.PurchaseGift] end --获得直购礼包商品配置通过商品Id function VipModel:GetPurchaseGiftCfgById( product_id ) return self.vip_rechargeGoods_id_cfg[product_id] end --设置15903商品信息 function VipModel:SetProductInfo( scmd ) local new_vo = {} new_vo.product_type = scmd new_vo.product_list = {} for k,v in pairs(scmd.product_list) do new_vo.product_list[v.product_id] = v end new_vo.time_list = {} for k,v in pairs(scmd.time_list) do new_vo.time_list[v.sub_type] = v end self.product_info[scmd.product_type] = new_vo if scmd.product_type == VipModel.Type.PurchaseGift then self:IsNeedRed(VipModel.TabType.PurchaseGift) end -- print("huangcong:VipModel [start:581] :", new_vo) -- PrintTable(new_vo) -- print("huangcong:VipModel [end]") end function VipModel:GetProductInfo( product_type ) return self.product_info[product_type] end --设置VIP专属礼包查看信息 function VipModel:SetVipGiftFindInfo( vo ) for k,v in pairs(vo.list) do self.vip_gift_find_list[v.vip_lv] = true end end --获得vip专属礼包查询状态通过vip等级 function VipModel:GetVipGiftFindByVipLv( vip_lv ) return self.vip_gift_find_list[vip_lv] or false end -- 投资相关 start -- -- 投资相关 start -- -- 投资相关 start -- -- 初始化投资计划配置 function VipModel:InitInvestmentPlayCfg( ) -- 初始化缓存计划类型配置 self.investment_type_cfg = {} for k, v in pairs(Config.Investmenttypes) do self.investment_type_cfg[v.type] = self.investment_type_cfg[v.type] or {} self.investment_type_cfg[v.type][v.level] = v end -- 初始化缓存投资计划内容配置 self.investment_cfg = {} for k, v in pairs(Config.Investmentrewards) do self.investment_cfg[v.type] = self.investment_cfg[v.type] or {} self.investment_cfg[v.type][v.level] = self.investment_cfg[v.type][v.level] or {} self.investment_cfg[v.type][v.level][v.id] = v end -- 创建一次缓存配置,用于提供首轮红点 -- for k, v in pairs(self.investment_cfg) do -- self:GetInvestmentViewData(v.type) -- end end function VipModel:GetInvestmentTypeData( ) return self.investment_type_cfg end -- 根据需求获取投资配置 function VipModel:GetInvestmentCfg(type, level, id) if type then if level then if id then return self.investment_cfg[type] and self.investment_cfg[type][level] and self.investment_cfg[type][level][id] or nil else return self.investment_cfg[type] and self.investment_cfg[type][level] or nil end else return self.investment_cfg[type] end else return self.investment_cfg end end -- 获取投资计划特定类型节点所需数据 function VipModel:GetInvestmentViewData(type) if not type then return nil end self.investment_view_item_data[type] = self.investment_view_item_data[type] or {} local round, is_finished = self:GetInvestmentCurRound(type) -- 不存在缓存数据的话就生成 if not self.investment_view_item_data[type][round] then self.investment_view_item_data[type][round] = DeepCopy(self:GetInvestmentCfg(type, round)) end if self.investment_view_item_data[type][round] then for k, v in ipairs(self.investment_view_item_data[type][round]) do if is_finished then v.sort_weight = 3 else self:UpdateInvestmentItemDataSortWeight(v) end end self:InvestmentSortFunc(self.investment_view_item_data[type][round]) return self.investment_view_item_data[type][round] end return nil end -- 由于跨天或者升级后要更新投资计划的红点信息 function VipModel:RefreshInvestmentViewDataRed( ) local function refresh_func() local updated = false for k, v in pairs(self.investment_data) do local round, is_finished = self:GetInvestmentCurRound(v.type) if v.is_buy == 1 and not is_finished then -- 已购买才刷新 -- 更新当前类型的投资已经买了几天 v.bought_day = v.buy_time ~= 0 and math.ceil((TimeUtil:getServerTime() - v.buy_time) / 86400) or 0 updated = true end end if updated then self:IsNeedRed(VipModel.TabType.Investment) end end TimeManager.GetInstance():StartTime("VIP_INVESETMENT_RED_1", 0.5, refresh_func) end -- 更新投资计划节点数据的排序权重 function VipModel:UpdateInvestmentItemDataSortWeight(data) local flag = self:GetInvestMentRewardFlag(data.type, data.id) local lv = RoleManager.Instance.mainRoleInfo.level local bought_day = self:GetInvestmentBoughtDay(data.type) -- 设置排序队列,已领取的在后面 if flag then data.sort_weight = 3 else -- 判断是否可领取 local can_reveive = true local condition = stringtotable(data.condition) for _, cond in ipairs(condition) do if cond[1] == "lv" then -- 需要达到等级 can_reveive = can_reveive and lv >= cond[2] elseif cond[1] == "day" then -- 需要达到购买天数 can_reveive = can_reveive and bought_day >= cond[2] end end data.sort_weight = can_reveive and 1 or 2 end end function VipModel:InvestmentSortFunc(list) local sort_func = function ( a, b ) if a.sort_weight == b.sort_weight then return a.id < b.id else return a.sort_weight < b.sort_weight end end table.sort(list, sort_func) end -- 设置投资相关协议信息 42001 function VipModel:SetInvestmentData(vo) if not vo then return end if self._block_update_invsetment_data then self._cache_invsetment_data = vo else self._cache_invsetment_data = nil -- 如果能顺利更新投资数据,则需要清除限制刷新时的缓存 -- 初始化数据 self.investment_data = {} for k, v in ipairs(vo.list) do local rewards_tb = {} for _, v2 in ipairs(v.rewards) do rewards_tb[v2.id] = v2.id end self.investment_data[v.type] = self.investment_data[v.type] or {} self.investment_data[v.type].type = v.type self.investment_data[v.type].round = v.round self.investment_data[v.type].is_buy = v.is_buy self.investment_data[v.type].buy_time = v.buy_time self.investment_data[v.type].rewards = rewards_tb -- 当前类型的投资已经买了几天 self.investment_data[v.type].bought_day = v.buy_time ~= 0 and math.ceil((TimeUtil:getServerTime() - v.buy_time) / 86400) or 0 end -- 更新投资信息的领取情况及排序 for k, v in pairs(self.investment_data) do self:GetInvestmentViewData(v.type) end -- 特殊处理后,在这边更新 self:IsNeedRed(VipModel.TabType.Investment) self:Fire(VipModel.UPDATE_INVESTMENT_DATA) end end -- 关闭界面时,重新更新投资协议数据 function VipModel:ReupdateInvestmentData( ) if self._cache_invsetment_data then self:SetInvestmentData(self._cache_invsetment_data) end self._cache_invsetment_data = nil end function VipModel:GetInvestmentData(type) if type then return self.investment_data[type] else return self.investment_data end end function VipModel:GetInvestmentBoughtDay(type) local bought_day = 0 local data = self:GetInvestmentData(type) if data then bought_day = data.bought_day end return bought_day end -- 根据服务端返回的数据,判断当前是处于当前投资类型的第几轮 function VipModel:GetInvestmentCurRound(type) if not type then return nil end local round = 1 local data = self:GetInvestmentData(type) if data then round = data.round end local total_round = self.investment_type_cfg[type] and #self.investment_type_cfg[type] or 0 -- 是否已经投资完全部阶段 local is_finished = round > total_round round = round <= total_round and round or total_round return round, is_finished end -- 根据投资类型更新领奖rewardid function VipModel:UpdateInvestmentRewardId(vo) if not vo then return end self.investment_data[vo.type] = self.investment_data[vo.type] or {} self.investment_data[vo.type].rewards = self.investment_data[vo.type].rewards or {} self.investment_data[vo.type].rewards[vo.id] = vo.id -- 更新缓存 local round, is_finished = self:GetInvestmentCurRound(vo.type) if self.investment_view_item_data[vo.type] and self.investment_view_item_data[vo.type][round] then for k, v in ipairs(self.investment_view_item_data[vo.type][round]) do if v.id == vo.id then -- 领取了的缓存直接改为3 v.sort_weight = 3 break end end -- 重新排序节点 self:InvestmentSortFunc(self.investment_view_item_data[vo.type][round]) end end -- 获取投资计划的奖励领取情况 function VipModel:GetInvestMentRewardFlag(type, id) if not type then return false end if id then return self.investment_data[type] and self.investment_data[type].rewards and self.investment_data[type].rewards[id] or false else return self.investment_data[type] and self.investment_data[type].rewards or false end end -- 是否已经投资了所有的投资类型 function VipModel:HasBoughtAllInvestmentTypes( ) local bool = true local type_list = self:GetInvestmentTypeData() for k, v in pairs(type_list) do local type_data = self:GetInvestmentData(v.type) or {} for k2, v2 in ipairs(type_data) do bool = bool and (v2.is_buy == 1) end end return bool end -- 投资计划红点 function VipModel:CheckInvestmentPlanRed(type) local bool = false local bought_all = true -- 是否已经买完了投资所有档位 local function check_investment_red_by_type(type) self.investment_red[type] = false local data = self:GetInvestmentData(type) bought_all = bought_all and (data and data.is_buy == 1 or false) if data and data.is_buy == 1 then local view_data = self:GetInvestmentViewData(type) for k, v in ipairs(view_data) do if v.sort_weight == 1 then -- 可领取 self.investment_red[type] = true bool = true end end end end if type then check_investment_red_by_type(type) else for k, v in pairs(self.investment_type_cfg) do check_investment_red_by_type(k) end end -- 如果已经全买了,那就不需要登录红点了 if self.investment_login_red then self.investment_login_red = not bought_all end bool = bool or self.investment_login_red return bool end -- 根据类型获取投资计划红点 function VipModel:GetInvestmentPlanRed(type) if type then return self.investment_red[type] or false else local bool = false for k, v in pairs(self.investment_red) do bool = bool or v end return bool end end -- 投资相关 end -- -- 投资相关 end -- -- 投资相关 end -- ---------------------------- vip 幻魔UP卡 开始 --------------------- -- 获取幻魔UP卡基本信息 function VipModel:GetVipCarBaseInfo(product_id) local info = { product_id = product_id, product_name = "", money = 0, about = "", days = 0, buy_reward = {}, day_reward = {}, } local config_product = Config.Rechargeproduct[product_id] if config_product then info.product_name = config_product.product_name info.money = config_product.money info.about = config_product.about end local config_rechargewelfare = Config.Rechargewelfare[product_id] if config_rechargewelfare then info.days = config_rechargewelfare.days info.buy_reward = stringtotable(Trim(config_rechargewelfare.buy_reward)) info.day_reward = stringtotable(Trim(config_rechargewelfare.reward)) end return info end -- 获取幻魔UP卡信息 function VipModel:RequstVipCarInfo() self:DelayFire(VipModel.REQUEST_CCMD_EVENT, 15901) end -- 购买幻魔UP卡 function VipModel:RequstBuyVipCar(product_id) if not self:IsCurProductCanBuy(product_id) then Message.show("今日续费次数已达到上限哦~") return end self:Fire(VipModel.REQUEST_CCMD_EVENT, 15904, product_id) end -- 领取幻魔UP卡每日奖励 function VipModel:RequstGetVipCarDayReward(product_id) self:Fire(VipModel.REQUEST_CCMD_EVENT, 15902, product_id) end -- 设置幻魔UP卡信息 function VipModel:SetVipCarDayReward(vo) self.vipcard_info = {} self.vipcard_info.product_list = vo.product_list if self.vipcard_info.product_list and #self.vipcard_info.product_list > 1 then table.sort( self.vipcard_info.product_list, function (a, b) return a.product_subtype < b.product_subtype end ) end self:IsNeedRed(VipModel.TabType.Card) self:Fire(VipModel.UPDATE_VIP_CARD_INFO) end -- 是否可以续费尊享卡 function VipModel:IsCurProductCanBuy(product_id) local left_buy_time = 0 local can_buy = true if self.vipcard_info and self.vipcard_info.product_list then for i,v in ipairs(self.vipcard_info.product_list) do if v.product_id == product_id then return v.left_times > 0 end end end return can_buy end -- 尊享卡强化概率 function VipModel:VipCardEquipStrengthRatio(is_perent) local ratio = 0 if self:HaveVipCard(VipModel.VIP_CARD.MONTH) then ratio = VipModel.VIP_CARD_RATIO.Strength if is_perent then ratio = ratio / 100 end end return ratio end -- 尊享卡升星概率 function VipModel:VipCardEquipEvolutionRatio(is_perent) local ratio = 0 if self:HaveVipCard(VipModel.VIP_CARD.WEEK) then ratio = VipModel.VIP_CARD_RATIO.Evolotion if is_perent then ratio = ratio / 100 end end return ratio end -- 尊享卡月卡橙装掉率概率 function VipModel:VipCardMonthEquipDropRatio(is_have, is_perent) local ratio = 0 if is_have or self:HaveVipCard(VipModel.VIP_CARD.MONTH) then ratio = VipModel.VIP_CARD_RATIO.MonthEquipDrop if is_perent then ratio = ratio / 100 end end return ratio end -- 尊享卡季卡橙装掉率概率 function VipModel:VipCardSeasonEquipDropRatio(is_have, is_perent) local ratio = 0 if is_have or self:HaveVipCard(VipModel.VIP_CARD.SEASON) then ratio = VipModel.VIP_CARD_RATIO.SeasonEquipDrop if is_perent then ratio = ratio / 100 end end return ratio end -- 是否还有vip尊享卡 function VipModel:HaveVipCard(product_id) local b = false if self.vipcard_info and self.vipcard_info.product_list then for i,v in ipairs(self.vipcard_info.product_list) do if v.product_id == product_id then return v.state ~= 0 and v.left_count > 0 end end end return b end -- 尊享卡主界面展示 function VipModel:CheckVipCardIcon() local b, str = false,"" if not GetModuleIsOpen(450, 6) or self:GetVipLevel() < 1 then return b, str end local is_active_month_card = self:HaveVipCard(VipModel.VIP_CARD.MONTH) local is_active_season_card = self:HaveVipCard(VipModel.VIP_CARD.SEASON) local month_card_drop_ratio = self:VipCardMonthEquipDropRatio(true, true) local season_card_drop_ratio = self:VipCardSeasonEquipDropRatio(true, true) if not is_active_month_card and not is_active_season_card then str = HtmlColorTxt("未激活", ColorUtil.RED_DARK) elseif is_active_month_card and is_active_season_card then str = string.format("橙装掉率%s", HtmlColorTxt("+".. (month_card_drop_ratio + season_card_drop_ratio) .."%", "#fdffc2")) elseif is_active_season_card then str = string.format("橙装掉率%s", HtmlColorTxt("+".. (season_card_drop_ratio) .."%", "#fdffc2")) elseif is_active_month_card then str = string.format("橙装掉率%s", HtmlColorTxt("+".. (month_card_drop_ratio) .."%", "#fdffc2")) end return true, str end -- 获取续费提示 function VipModel:GetVipCardRechargeTip() local product_id, left_times = 0, 0 local cur_time = TimeUtil:getServerTime() if self.vipcard_info and self.vipcard_info.product_list then for i,v in ipairs(self.vipcard_info.product_list) do if v.end_time and v.end_time > 0 and v.end_time > cur_time then --3天 local offset_time = v.end_time - cur_time if offset_time < 3600 * 24 * 3 and (left_times == 0 or offset_time < left_times) then product_id = v.product_id left_times = offset_time end end end end return product_id,left_times end -- 领取幻魔UP卡每日奖励 function VipModel:CheckVipCardRedDot() if self.vipcard_info and self.vipcard_info.product_list then for i,v in ipairs(self.vipcard_info.product_list) do if v.state == 1 then return true end end end return false end -- 尊享卡主界面展示 function VipModel:IsCanShowVipCardTips() local b = false if not GetModuleIsOpen(450, 6) or self:GetVipLevel() < 1 then return b end local is_active_week_card = self:HaveVipCard(VipModel.VIP_CARD.WEEK) local is_active_month_card = self:HaveVipCard(VipModel.VIP_CARD.MONTH) local is_active_season_card = self:HaveVipCard(VipModel.VIP_CARD.SEASON) return not is_active_week_card and not is_active_month_card and not is_active_season_card end ---------------------------- vip 幻魔UP卡 结束 --------------------- --保存客服信息 function VipModel:SetServiceData(scmd) self.service_data = scmd end function VipModel:GetServiceData( ) return self.service_data end -- 获取VIP副本可以扫荡的VIP等级 function VipModel:GetVipDungeonSweepLV( ) for k,v in pairs(Config.Vipprivilege) do if v.class_id == 5 and v.subclass_id == 1 and v.type == 1 then return v.lv end end end --设置贵族技能播放cookie function VipModel:SetVipNobleSkillPlayCookie( bool ) CookieWrapper.Instance:SaveCookie(CookieLevelType.Account,CookieTimeType.TYPE_ALWAYS,CookieKey.VIP_NOBLE_SKILL_PLAY,bool) CookieWrapper.Instance:WriteAll() end --设置贵族技能播放cookie function VipModel:GetVipNobleSkillPlayCookie( ) local bool = CookieWrapper.Instance:GetCookie(CookieLevelType.Account,CookieKey.VIP_NOBLE_SKILL_PLAY) or false return bool end ----------直购礼包免费红点-start--------- function VipModel:CheckPurchaseGiftFreeRed( ) self.purchase_gift_red_list = {} if self:GetVipLevel() < 3 then return false end local purchaseGift_cfg = self:GetPurchaseGiftCfg() local server_info = self:GetProductInfo(VipModel.Type.PurchaseGift) local is_show, openDay_limit, mergeDay_limt local open_day = ServerTimeModel:getInstance():GetOpenServerDay() local level = RoleManager.Instance.mainRoleInfo.level local vip_flag = RoleManager.Instance.mainRoleInfo.vip_flag for k,v in pairs(purchaseGift_cfg) do local recharge_cfg = Config.Rechargeproduct[v.id] if recharge_cfg.money == 0 and v.limit and v.limit[2] then local have_time = v.limit[2] if server_info and server_info.product_list[v.id] then have_time = have_time - server_info.product_list[v.id].buy_counts end is_show = true openDay_limit = v.open_day[1] if openDay_limit then if open_day < openDay_limit[1] or open_day > openDay_limit[2] then is_show = false end end mergeDay_limt = v.merge_day[1] if mergeDay_limt then if open_day < mergeDay_limt[1] or open_day > mergeDay_limt[2] then is_show = false end end for kk,vv in pairs(v.condition) do if vv[1] == "lv" then if level < tonumber(vv[2]) then is_show = false end limit_lv = tonumber(vv[2]) elseif vv[1] == "vip" then if vip_flag < tonumber(vv[2]) then is_show = false end limit_vip = tonumber(vv[2]) end end if have_time > 0 and is_show then print('=======Msh:VipModel.lua[1261] ===TABLE====') PrintTable(v) self.purchase_gift_red_list[v.sub_type] = true end end end return self:GetPurchaseGiftFreeRed() end function VipModel:GetPurchaseGiftFreeRed( sub_type ) if sub_type then return self.purchase_gift_red_list and self.purchase_gift_red_list[sub_type] else return self.purchase_gift_red_list and TableSize(self.purchase_gift_red_list) > 0 end end ----------直购礼包免费红点-end----------- --开始V3激活步骤 function VipModel:PlayVipThreeStep( ) --先关界面 self:Fire(VipModel.OPEN_EXPERIENCE_V_THREE_VIEW,true) self:Fire(VipModel.OPEN_EXPERIENCE_V_THREE_EX_VIEW,nil,true) --打开引导界面 local show_vos = {{ type = 1, is_out_res=false, saying = "恭喜晋升VIP3,相应特权现已全部激活!", ignore_fly=false, show_time=10,--持续时间 name = "VIP3", winId = 450, subId = 22, }} local view = NewFuncOpenView.New() view:Open(show_vos) end