源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1340 rivejä
40 KiB

1 kuukausi sitten
  1. --[[@------------------------------------------------------------------
  2. @description:VIP模块
  3. @author:huangcong
  4. ----------------------------------------------------------------------]]
  5. VipModel = VipModel or BaseClass(BaseModel)
  6. local stringtotable = stringtotable
  7. VipModel.REQUEST_CCMD_EVENT = "VipModel.REQUEST_CCMD_EVENT"
  8. VipModel.UPDATE_VIP_INFO = "VipModel.UPDATE_VIP_INFO" --更新VIP信息
  9. VipModel.UPDATE_VIP_VIEW_RED = "VipModel.UPDATE_VIP_VIEW_RED" --更新vip界面红点
  10. VipModel.UPDATE_MAIN_VIEW_BG_RES = "VipModel.UPDATE_MAIN_VIEW_BG_RES" --更新主界面背景资源
  11. VipModel.UPDATE_RECHARGE_CARD_DATA = "VipModel.UPDATE_RECHARGE_CARD_DATA" --更新充值卡数据
  12. VipModel.UPDATE_RECHARGE_ITEM_DATA = "VipModel.UPDATE_RECHARGE_ITEM_DATA" --
  13. VipModel.OPEN_VIP_RENEW_VIEW = "VipModel.OPEN_VIP_RENEW_VIEW" --打开续费界面
  14. VipModel.OPEN_EXPERIENCE_VIEW = "VipModel.OPEN_EXPERIENCE_VIEW" --打开VIP体验界面
  15. VipModel.SHOW_EXPERIENCE_TASK_TIP = "VipModel.SHOW_EXPERIENCE_TASK_TIP" --展示VIP体验任务栏飞鞋特权信息
  16. VipModel.OPEN_EXPERIENCE_V_THREE_VIEW = "VipModel.OPEN_EXPERIENCE_V_THREE_VIEW"--打开VIP体验贵族V3界面
  17. VipModel.OPEN_EXPERIENCE_V_THREE_EX_VIEW = "VipModel.OPEN_EXPERIENCE_V_THREE_EX_VIEW"--打开VIP体验贵族V3详情界面
  18. VipModel.UPDATE_EXPERIENCE_V_THREE_EX_RED = "VipModel.UPDATE_EXPERIENCE_V_THREE_EX_RED"--更新VIP体验贵族V3图标红点
  19. VipModel.OPEN_CUSTOM_RECHARGE_VIEW = "VipModel.OPEN_CUSTOM_RECHARGE_VIEW" --打开随心充界面
  20. VipModel.UPDATE_TAB_INFO = "VipModel.UPDATE_TAB_INFO" --更新页签信息
  21. VipModel.OPEN_NOBLE_BUY_VIEW = "VipModel.OPEN_NOBLE_BUY_VIEW" --打开vip贵族礼包购买提示界面
  22. VipModel.OPEN_VIP_NOBLE_VIEW = "VipModel.OPEN_VIP_NOBLE_VIEW"--打开VIP特权界面
  23. VipModel.OPEN_VIP_SKILL_EFFECT_VIEW = "VipModel.OPEN_VIP_SKILL_EFFECT_VIEW"--特权技能界面
  24. -- 投资相关 start
  25. VipModel.UPDATE_INVESTMENT_DATA = "VipModel.UPDATE_INVESTMENT_DATA" -- 更新投资计划协议信息
  26. -- 投资相关 end
  27. -- 幻魔UP卡 start
  28. VipModel.UPDATE_VIP_CARD_INFO = "VipModel.UPDATE_VIP_CARD_INFO" -- 幻魔UP卡信息更新
  29. -- 幻魔UP卡 end
  30. VipModel.REGISTER_MASK_ID = "VipModel.REGISTER_MASK_ID" --注册mask_id
  31. VipModel.BIND_GIFTS_PRODUCT_ID = 20 --红钻礼包商品id
  32. VipModel.IOSAlpha_PRODUCT_ID = 999 --iOS审核状态下商品id
  33. VipModel.TabType = {
  34. Recharge = 1,--充值
  35. Noble = 2,--特权
  36. PurchaseGift = 3,--直购礼包
  37. Investment = 4, -- 投资计划
  38. HopeGift = 5, -- 投资计划
  39. Card = 6, --幻魔UP卡
  40. -- Investment = 4,
  41. -- Seven = 5,
  42. -- Renew = 6,
  43. -- Open_Recharge = 7,
  44. -- Every_Recharge = 8,
  45. -- SuperInvest = 9,
  46. -- GodInvest = 10,
  47. -- MergeInvest = 11,
  48. }
  49. VipModel.Type = {--直购礼包类型Config.Rechargegoods
  50. PurchaseGift = 4,--直购礼包
  51. FirstRecharge = 5,--首充
  52. }
  53. VipModel.VIP_CARD = {
  54. WEEK = 301, --周卡
  55. MONTH = 302, --月卡
  56. SEASON = 303, --季卡
  57. }
  58. --尊享卡概率
  59. VipModel.VIP_CARD_RATIO = {
  60. Evolotion = 500, --升星概率
  61. Strength = 500, --强化概率
  62. MonthEquipDrop = 500, --月卡橙装掉率
  63. SeasonEquipDrop = 1000, --季卡橙装掉率
  64. }
  65. VipModel.PurchaseGiftType = {--直购礼包类型
  66. Day = 1,--天
  67. Week = 2,--周
  68. Month = 3,--月(但是在直购这里代表终身礼包)
  69. }
  70. VipModel.PurchaseGiftTypeName = {--直购礼包类型名字
  71. [1] = "每日精选礼包",--天
  72. [2] = "每周精选礼包",--周
  73. [3] = "每月精选礼包",--月(但是在直购这里代表终身礼包)
  74. }
  75. function VipModel:__init()
  76. VipModel.Instance = self
  77. self.vip_info = nil
  78. self.vip_red_dot_info = {}
  79. self.product_list = {}
  80. self.vip_gift_list = {}--VIP专属礼包信息
  81. self.vip_gift_find_list = {}--vip礼包查询列表
  82. self.is_first_red = true--第一次VIP要有红点
  83. self.vip_max_level = TableSize(Config.Vipgift)
  84. self.product_info = {}--15903商品信息
  85. -- 投资相关
  86. self.investment_login_red = true -- 投资计划登录红点
  87. self.investment_type_cfg = {} -- 投资计划类型配置
  88. self.investment_data = {} -- 投资计划已投资信息
  89. self.investment_cfg = {} -- 投资计划配置
  90. self.investment_view_item_data = {} -- 投资计划主界面,节点数据缓存
  91. self.investment_red = {} -- 投资计划红点 格式为 [type] = true / false
  92. self._block_update_invsetment_data = false -- 是否拦截投资协议信息的更新
  93. self._cache_invsetment_data = nil -- 当打开界面后,不主动更新42001协议的数据,关闭界面或者手动购买即检测缓存并覆盖协议数据
  94. self.is_active_vip_three = false
  95. self.is_open_vip_ex_1 = false--是否第一次打开过
  96. self.can_todo_task = true
  97. --
  98. self.service_data = nil
  99. self.vipcard_info = {} --幻魔UP卡信息
  100. self:InitVipCfg()
  101. self:InitInvestmentPlayCfg()
  102. end
  103. function VipModel:getInstance()
  104. if VipModel.Instance == nil then
  105. VipModel.New()
  106. end
  107. return VipModel.Instance
  108. end
  109. function VipModel:InitVipCfg( )
  110. self.vip_cfg = {}--vip配置
  111. local cfg_data = DeepCopy(Config.Vipcfg)
  112. for k,v in pairs(cfg_data) do
  113. v.reward = stringtotable(v.reward)
  114. self.vip_cfg[v.lv] = v
  115. end
  116. self.vip_gift_cfg = {}--vip特权礼包配置
  117. local gift_cfg_data = DeepCopy(Config.Vipgift)
  118. for k,v in pairs(gift_cfg_data) do
  119. local data = v
  120. data.gift_reward = stringtotable(v.gift_reward)--奖励展示
  121. self.vip_gift_cfg[v.vip_lv] = v
  122. end
  123. self.vip_rechargeGoods_cfg = {}--直购礼包商品配置
  124. self.vip_rechargeGoods_id_cfg = {}--直购礼包商品配置Id索引
  125. local vip_rechargeGoods_cfg = DeepCopy(Config.Rechargegoods)
  126. for k,v in pairs(vip_rechargeGoods_cfg) do
  127. local data = v
  128. data.name = Trim(data.name)
  129. data.about = Trim(data.about)
  130. data.limit = stringtotable(v.limit)--类型和购买限制次数
  131. data.open_day = stringtotable(v.open_day)--开服天数限制
  132. data.condition = stringtotable(v.condition)--等级vip限制还有折扣
  133. data.award = stringtotable(v.award)--展示奖励
  134. if not self.vip_rechargeGoods_cfg[v.type] then
  135. self.vip_rechargeGoods_cfg[v.type] = {}
  136. end
  137. self.vip_rechargeGoods_cfg[v.type][#self.vip_rechargeGoods_cfg[v.type] + 1] = v
  138. self.vip_rechargeGoods_id_cfg[v.id] = v
  139. end
  140. -- print("huangcong:VipModel [start:96] :", self.vip_rechargeGoods_cfg)
  141. -- PrintTable(self.vip_rechargeGoods_cfg[4])
  142. -- print("huangcong:VipModel [end]")
  143. end
  144. --得到vip通用配置
  145. function VipModel:GetVipCfg( vip_lv )
  146. return self.vip_cfg[vip_lv]
  147. end
  148. --得到vip礼包配置
  149. function VipModel:GetVipGiftCfg( vip_lv )
  150. return self.vip_gift_cfg[vip_lv]
  151. end
  152. function VipModel:IsNeedRedAll( )--这样写红点 每次调全局的只要调两次
  153. self.vip_red_dot_info[VipModel.TabType.Noble] = self:CheckVipNobleRedDot()
  154. self:CheckVipMainIconRedDot()
  155. end
  156. function VipModel:IsNeedRed( view_type,is_all,sub_type )
  157. local bool = false
  158. if view_type == VipModel.TabType.Noble then--贵族
  159. bool = self:CheckVipNobleRedDot()
  160. elseif view_type == VipModel.TabType.PurchaseGift then--直购
  161. bool = self:CheckPurchaseGiftFreeRed()
  162. elseif view_type == VipModel.TabType.Investment then--投资计划
  163. bool = self:CheckInvestmentPlanRed()
  164. elseif view_type == VipModel.TabType.HopeGift and sub_type then--臻享礼包这里是多开活动ID要不同变化
  165. view_type = sub_type + 3316500
  166. bool = self:CheckHopeGiftRedDot(sub_type)
  167. elseif view_type == VipModel.TabType.Card then--幻魔UP卡
  168. bool = self:CheckVipCardRedDot()
  169. elseif view_type == VipModel.TabType.Recharge then--充值
  170. bool = KfActivityModel:getInstance():IsMoneyCopyRedByTag( "charge" )
  171. end
  172. self.vip_red_dot_info[view_type] = bool
  173. self:Fire(VipModel.UPDATE_VIP_VIEW_RED,view_type,bool)
  174. if not is_all then
  175. -- self:CheckVipMainIconRedDot()
  176. end
  177. -- print("huangcong:VipModel [62]: ",bool,id)
  178. -- PrintTable(self.vip_red_dot_info)
  179. end
  180. --检查主界面VIP红点
  181. function VipModel:CheckVipMainIconRedDot( )
  182. local show = false
  183. for k,v in pairs(self.vip_red_dot_info) do
  184. if v == true then
  185. show = v
  186. break
  187. end
  188. end
  189. -- if not self:GetVipRedCookie() then
  190. -- show = true
  191. -- end
  192. return show
  193. end
  194. function VipModel:SetFisrtRed( bool )
  195. self.is_first_red = bool
  196. end
  197. --检查臻享礼包红点
  198. function VipModel:CheckHopeGiftRedDot( sub_type )
  199. if not sub_type then return false end
  200. return HopeGiftModel:getInstance():GetHopeGiftRedDot(sub_type)
  201. end
  202. --检查vip特权红点
  203. function VipModel:CheckVipNobleRedDot( )
  204. local bool = false
  205. local vip_flag = RoleManager.Instance.mainRoleInfo.vip_flag
  206. if self.vip_info and self.vip_info.vip_endtime and self.vip_info.vip_endtime - TimeUtil:getServerTime( ) <= 0 then
  207. if vip_flag >= 1 then
  208. for i=1,vip_flag do
  209. bool = not self:GetVipGiftFindByVipLv(i)
  210. if bool then
  211. break
  212. end
  213. end
  214. if not bool and self.vip_info.vip_award_list and #self.vip_info.vip_award_list > 0 then
  215. bool = true
  216. end
  217. end
  218. end
  219. return bool
  220. end
  221. --45001 刷新VIP界面信息
  222. function VipModel:UpdateVipInfomation(vo)
  223. self.vip_info = vo
  224. if vo.vip_lv ~= 0 then
  225. self.is_vip = false
  226. end
  227. if RoleManager.Instance.mainRoleInfo.vip_flag < 3 and self.vip_info.vip_lv == 3 and not self.is_active_vip_three then--说明升级到V3了
  228. self.is_active_vip_three = true
  229. self:PlayVipThreeStep()--开始V3激活步骤
  230. end
  231. --如果当前时间小于VIP结束时间,需要修改角色的VIP值
  232. local now = TimeUtil:getServerTime()
  233. if vo.vip_lv < vo.experience_vip_lv and now < vo.vip_endtime then--体验VIP
  234. RoleManager:getInstance():GetMainRoleVo():ChangeVar("vip_flag", vo.experience_vip_lv)
  235. else
  236. if vo.vip_lv == 4 then--V4的时候要在界面内判断礼包开启~
  237. self:Fire(VipModel.UPDATE_TAB_INFO)
  238. end
  239. RoleManager:getInstance():GetMainRoleVo():ChangeVar("vip_flag", vo.vip_lv)
  240. end
  241. -- local vip_type = 1
  242. -- if RoleManager:getInstance():GetMainRoleVo().vip_type ~= vip_type then
  243. -- RoleManager:getInstance():GetMainRoleVo():ChangeVar("vip_type", vo.vip_type)
  244. -- end
  245. self:Fire(VipModel.UPDATE_VIP_INFO, vo)
  246. self:Fire(VipModel.REQUEST_CCMD_EVENT,45007)
  247. if vo.vip_lv <= 3 then
  248. VipModel:getInstance():Fire(VipModel.REQUEST_CCMD_EVENT, 45010)
  249. end
  250. end
  251. --永久VIP
  252. function VipModel:IsForeverVip( )
  253. if self.vip_info and self.vip_info.vip_lv > 0 then
  254. return true
  255. end
  256. end
  257. --VIP是到期
  258. function VipModel:IsVipExperience( )
  259. if self.vip_info and self.vip_info.vip_endtime then
  260. return self.vip_info.vip_endtime - TimeUtil:getServerTime() > 0
  261. end
  262. end
  263. --获得Vip信息
  264. function VipModel:GetVipInfomation()
  265. return self.vip_info
  266. end
  267. --得到VIP类型 1王权 2皇权 3神权
  268. function VipModel:GetVipType(vip_lv)
  269. local vip_type = 1
  270. local vip_type_name = "王权"
  271. local vip_type_lv = 0
  272. local cfg = self:GetVipCfg(vip_lv)
  273. if cfg then
  274. if cfg.type >= 101 and cfg.type <= 200 then
  275. vip_type = 1
  276. vip_type_name = "王权"
  277. vip_type_lv = cfg.type - 100
  278. elseif cfg.type >= 201 and cfg.type <= 300 then
  279. vip_type = 2
  280. vip_type_name = "皇权"
  281. vip_type_lv = cfg.type - 200
  282. elseif cfg.type >= 301 then
  283. vip_type = 3
  284. vip_type_name = "神权"
  285. vip_type_lv = cfg.type - 300
  286. end
  287. end
  288. return vip_type,vip_type_name,vip_type_lv
  289. end
  290. --设置充值卡数据
  291. function VipModel:SetRechargeCardData(data)
  292. if PlatformMgr:getInstance():IsEyouPlatform() then --eyou平台充值卡处理
  293. data = self:EyouPlatformRecharge(data)
  294. end
  295. self.recharge_card_data = data
  296. self:Fire(VipModel.UPDATE_RECHARGE_CARD_DATA)
  297. end
  298. --筛选出eyou平台的用的充值配置
  299. function VipModel:EyouPlatformRecharge(data)
  300. if RuntimePlatform and data and data.product_list then
  301. local remove_index_list = {}
  302. if SystemRuntimePlatform.IsIphone() then --苹果手机
  303. if PlatformMgr:getInstance():IsTWAreaCurrency() then --臺灣地區
  304. for i,v in ipairs(data.product_list) do
  305. local cfg = self:GetEyouIOSRechargeTwProductCfg(v.product_id)
  306. if cfg == nil or cfg.is_show == 0 then
  307. table.insert(remove_index_list, i)
  308. end
  309. end
  310. else --非臺灣地區
  311. for i,v in ipairs(data.product_list) do
  312. local cfg = self:GetEyouIOSRechargeNotTwProductCfg(v.product_id)
  313. if cfg == nil or cfg.is_show == 0 then
  314. table.insert(remove_index_list, i)
  315. end
  316. end
  317. end
  318. elseif SystemRuntimePlatform.IsAndroid() then --安卓
  319. if PlatformMgr:getInstance():IsTWAreaCurrency() then --台湾地区
  320. for i,v in ipairs(data.product_list) do
  321. local cfg = self:GetEyouAndroidRechargeTwProductCfg(v.product_id)
  322. if cfg == nil or cfg.is_show == 0 then
  323. table.insert(remove_index_list, i)
  324. end
  325. end
  326. else --非台湾地区
  327. for i,v in ipairs(data.product_list) do
  328. local cfg = self:GetEyouAndroidRechargeNotTwProductCfg(v.product_id)
  329. if cfg == nil or cfg.is_show == 0 then
  330. table.insert(remove_index_list, i)
  331. end
  332. end
  333. end
  334. end
  335. local del_num = 0
  336. for i,v in ipairs(remove_index_list) do
  337. local index = v - del_num
  338. table.remove(data.product_list, index)
  339. del_num = del_num + 1
  340. end
  341. end
  342. return data
  343. end
  344. --ios儲值配置,臺灣地區,顯示臺幣
  345. function VipModel:GetEyouIOSRechargeTwProductCfg(product_id)
  346. local cfg, money_sign
  347. for k,v in pairs(Config.Chargeconfig) do
  348. if v.plat_type == 2 and v.usd_money == 0 and v.product_id == product_id then
  349. cfg = v
  350. cfg.money = cfg.local_money
  351. money_sign = Trim(cfg.money_sign)
  352. end
  353. end
  354. return cfg, money_sign
  355. end
  356. --ios儲值配置,非臺灣地區,顯示美元
  357. function VipModel:GetEyouIOSRechargeNotTwProductCfg(product_id)
  358. local cfg, money_sign
  359. for k,v in pairs(Config.Chargeconfig) do
  360. if v.plat_type == 2 and v.local_money == 0 and v.product_id == product_id then
  361. cfg = v
  362. cfg.money = cfg.usd_money
  363. money_sign = "$"
  364. end
  365. end
  366. return cfg, money_sign
  367. end
  368. --ios充值配置
  369. function VipModel:GetEyouIOSRechargeProductCfg(product_id)
  370. local cfg, money_sign
  371. for k,v in pairs(Config.Chargeconfig) do
  372. if v.plat_type == 2 and v.product_id == product_id then
  373. cfg = v
  374. cfg.money = cfg.usd_money
  375. money_sign = "$"
  376. end
  377. end
  378. return cfg, money_sign
  379. end
  380. --台湾地区的安卓充值配置,显示本地货币
  381. function VipModel:GetEyouAndroidRechargeTwProductCfg(product_id)
  382. local cfg, money_sign
  383. for k,v in pairs(Config.Chargeconfig) do
  384. if v.plat_type == 1 and v.usd_money == 0 and v.product_id == product_id then
  385. cfg = v
  386. cfg.money = cfg.local_money
  387. money_sign = Trim(cfg.money_sign)
  388. end
  389. end
  390. return cfg, money_sign
  391. end
  392. --非台湾地区的安卓充值配置,显示美元
  393. function VipModel:GetEyouAndroidRechargeNotTwProductCfg(product_id)
  394. local cfg, money_sign
  395. for k,v in pairs(Config.Chargeconfig) do
  396. if v.plat_type == 1 and v.local_money == 0 and v.product_id == product_id then
  397. cfg = v
  398. cfg.money = cfg.usd_money
  399. money_sign = "$"
  400. end
  401. end
  402. return cfg, money_sign
  403. end
  404. --从配置中获得对应权限
  405. function VipModel:GetPrivilegeFromConfig(vip_lv)
  406. local list = {}
  407. for _, v in pairs(Config.Vipprivilege) do
  408. if v.lv <= vip_lv then--插入并且重新排列
  409. if not list[v.class_id] then
  410. list[v.class_id] = {}
  411. end
  412. v.sort_id = v.class_id*100000 + v.subclass_id
  413. if not list[v.class_id][v.subclass_id] then
  414. list[v.class_id][v.subclass_id] = v
  415. else
  416. if v.lv > list[v.class_id][v.subclass_id].lv then--取高等级的特权
  417. list[v.class_id][v.subclass_id] = v
  418. end
  419. end
  420. end
  421. end
  422. local new_list = {}
  423. for k,v in pairs(list) do
  424. for kk,vv in pairs(v) do
  425. new_list[#new_list + 1] = vv
  426. end
  427. end
  428. if #list > 1 then
  429. local onSort = function (a, b)
  430. return a.sort_id < b.sort_id
  431. end
  432. table.sort(new_list, onSort)
  433. end
  434. print("huangcong:VipModel [start:446] :", new_list)
  435. PrintTable(new_list)
  436. print("huangcong:VipModel [end]")
  437. return new_list
  438. end
  439. --VIP升级经验上限
  440. function VipModel:GetExpFromConfig(vip_lv)
  441. local total_exp = 0
  442. for _, v in pairs(Config.Viplevelup) do
  443. if v.lv <= vip_lv then
  444. total_exp = total_exp + v.exp
  445. end
  446. end
  447. return total_exp
  448. end
  449. --检查VIP体验卡1(获得的时候检查)
  450. function VipModel:CheckVipXpCard(goods_list)
  451. if not self.is_open_vip_ex_1 then
  452. for _, v in pairs(goods_list) do
  453. if v.type_id == GuideModel.VIP_EXPERIENCE_ID and RoleManager.Instance.mainRoleInfo.vip_flag == 0 then
  454. setTimeout(function()
  455. self.is_open_vip_ex_1 = true
  456. self:Fire(VipModel.OPEN_EXPERIENCE_VIEW, 1)
  457. self:Fire(VipModel.SHOW_EXPERIENCE_TASK_TIP)
  458. end, 0.5)
  459. break
  460. end
  461. end
  462. end
  463. end
  464. --检查VIP体验卡2(使用道具的时候检查)
  465. function VipModel:CheckVipXpCardByUse(goods_type_id)
  466. if goods_type_id == GuideModel.VIP_EXPERIENCE_ID2 then
  467. setTimeout(function()
  468. GlobalEventSystem:Fire(EventName.CLOSE_BAG_VIEW)
  469. self:Fire(VipModel.OPEN_EXPERIENCE_VIEW, 1)
  470. self:Fire(VipModel.SHOW_EXPERIENCE_TASK_TIP)
  471. end, 0.5)
  472. end
  473. end
  474. --获得VIP特权数值
  475. function VipModel:GetVipPrivilegeValue(vipLv, module_id, subclass_id)
  476. if not self.vip_info.vip_type then return 0 end
  477. local str = vipLv .. "@" .. module_id .. "@" .. subclass_id
  478. local value = 0
  479. local cfg = Config.Vipprivilege[str]
  480. if cfg then
  481. if self.vip_info.vip_type == 1 then --白银
  482. if cfg.can_try == 1 then
  483. value = tonumber(cfg.value) or 0
  484. end
  485. elseif self.vip_info.vip_type == 3 then --至尊
  486. value = ( tonumber(cfg.value) + tonumber(cfg.honor_extra) ) or 0
  487. else
  488. value = tonumber(cfg.value) or 0
  489. end
  490. end
  491. return value
  492. end
  493. --获得充值配置
  494. function VipModel:GetRechargeProductConfig(product_id)
  495. return Config.Rechargeproduct[product_id]
  496. end
  497. --获得充值返利配置
  498. function VipModel:GetRechargeReturnConfig(product_id, return_type)
  499. return Config.Rechargereturn[product_id .. "@" .. return_type]
  500. end
  501. --根据vip等级 获取特权配置 如果没找到 就会遍历上一个等级的
  502. function VipModel:GetVipPrivilegeValue(class_id, subclass_id, vip_lv )
  503. if class_id and subclass_id and vip_lv then
  504. local cfg = Config.Vipprivilege[vip_lv.."@"..class_id.."@"..subclass_id.."@1"]
  505. if cfg then
  506. return cfg.value
  507. else
  508. if vip_lv == 0 then
  509. return 0
  510. else
  511. return self:GetVipPrivilegeValue(class_id, subclass_id, vip_lv-1)
  512. end
  513. end
  514. else
  515. return 0
  516. end
  517. end
  518. --得到VIP等级
  519. function VipModel:GetVipLevel()
  520. self.vipLevel = self.vip_info and self.vip_info.vip_lv or nil
  521. return self.vipLevel or -1
  522. end
  523. --设置超级VIP开启条件数据
  524. function VipModel:SetSuperVipOpenData( info )
  525. if not ClientConfig.super_vip_open then return end -- 是否开启超级客服
  526. --本地储存是否 推送过 推送过就退出不推送
  527. local bool = CookieWrapper.Instance:GetCookie(CookieLevelType.Account, CookieKey.SUPER_VIP_SHOW_STATE)
  528. if bool then return end
  529. local open_day = ServerTimeModel:getInstance():GetOpenServerDay()
  530. local cfg = ClientConfig.super_vip_open_config
  531. if cfg ~= "" then
  532. local data = StrToTable(cfg)
  533. for i,vo in ipairs(data) do
  534. if open_day >= tonumber(vo.min_open_day) and open_day <= tonumber(vo.max_open_day) then --开发天数条件满足 判断充值条件
  535. for i,v in ipairs(info.month_recharge_record) do --先遍历月充值条件 如果满足 就触发超级VIP 不再继续判断
  536. if v.gold_num >= tonumber(vo.month_recharge_record) then
  537. if SceneManager.Instance:IsMainCityAndFieldScene() then
  538. self:Fire(VipModel.OPEN_SUPER_VIP_VIEW)
  539. else
  540. self.is_super_vip = true
  541. end
  542. return
  543. end
  544. end
  545. for i,v in ipairs(info.daily_recharge_record) do
  546. if v.gold_num >= tonumber(vo.daily_recharge_num) then
  547. if SceneManager.Instance:IsMainCityAndFieldScene() then
  548. self:Fire(VipModel.OPEN_SUPER_VIP_VIEW)
  549. return
  550. else
  551. self.is_super_vip = true
  552. end
  553. return
  554. end
  555. end
  556. end
  557. end
  558. end
  559. end
  560. --是否满足超级会员条件 但是在因为场景没有推送
  561. function VipModel:IsSuperVipPush( )
  562. return self.is_super_vip
  563. end
  564. --得到VIP卡类型
  565. function VipModel:GetVipCardType( )
  566. local list = {}
  567. local cfg = Config.Vipcardnew
  568. if cfg then
  569. for i,v in pairs(cfg) do
  570. if v.type == 2 then
  571. table.insert(list,v)
  572. end
  573. end
  574. end
  575. return list
  576. end
  577. --设置vip礼包信息
  578. function VipModel:SetVipGiftInfo( list )
  579. self.vip_gift_list = {}
  580. for i,v in ipairs(list) do
  581. self.vip_gift_list[v.vip_lv] = v
  582. end
  583. self:IsNeedRed(VipModel.TabType.Noble)
  584. end
  585. --得到vip礼包信息
  586. function VipModel:GetVipGiftInfo( vip_lv )
  587. if not vip_lv then
  588. return self.vip_gift_list
  589. else
  590. return self.vip_gift_list[vip_lv]
  591. end
  592. end
  593. --获得VIP最大等级
  594. function VipModel:GetVipMaxLevel( )
  595. return self.vip_max_level
  596. end
  597. --设置Vip红点cookie
  598. function VipModel:SetVipRedCookie(bool)
  599. CookieWrapper.Instance:SaveCookie(CookieLevelType.Account,CookieTimeType.TYPE_ALWAYS,CookieKey.VIP_RED_SHOW,bool)
  600. CookieWrapper.Instance:WriteAll()
  601. end
  602. --获取Vip红点cookie
  603. function VipModel:GetVipRedCookie()
  604. return CookieWrapper.Instance:GetCookie(CookieLevelType.Account, CookieKey.VIP_RED_SHOW)
  605. end
  606. --免费小飞鞋使用vip等级
  607. function VipModel:GetFreeShoeVip( )
  608. if not self.free_shoe_vip_lv then
  609. for k,v in pairs(Config.Vipprivilege) do
  610. if v.class_id == 1 and v.subclass_id == 1 then
  611. self.free_shoe_vip_lv = v.lv
  612. end
  613. end
  614. end
  615. return self.free_shoe_vip_lv or 3
  616. end
  617. function VipModel:CanFreeUseShoe( )
  618. local vip = RoleManager.Instance.mainRoleInfo.vip_flag
  619. return vip >= VipModel:getInstance():GetFreeShoeVip( ) or VipModel:getInstance():IsVipExperience()
  620. end
  621. --获得直购礼包配置
  622. function VipModel:GetPurchaseGiftCfg( )
  623. return self.vip_rechargeGoods_cfg[VipModel.Type.PurchaseGift]
  624. end
  625. --获得直购礼包商品配置通过商品Id
  626. function VipModel:GetPurchaseGiftCfgById( product_id )
  627. return self.vip_rechargeGoods_id_cfg[product_id]
  628. end
  629. --设置15903商品信息
  630. function VipModel:SetProductInfo( scmd )
  631. local new_vo = {}
  632. new_vo.product_type = scmd
  633. new_vo.product_list = {}
  634. for k,v in pairs(scmd.product_list) do
  635. new_vo.product_list[v.product_id] = v
  636. end
  637. new_vo.time_list = {}
  638. for k,v in pairs(scmd.time_list) do
  639. new_vo.time_list[v.sub_type] = v
  640. end
  641. self.product_info[scmd.product_type] = new_vo
  642. if scmd.product_type == VipModel.Type.PurchaseGift then
  643. self:IsNeedRed(VipModel.TabType.PurchaseGift)
  644. end
  645. -- print("huangcong:VipModel [start:581] :", new_vo)
  646. -- PrintTable(new_vo)
  647. -- print("huangcong:VipModel [end]")
  648. end
  649. function VipModel:GetProductInfo( product_type )
  650. return self.product_info[product_type]
  651. end
  652. --设置VIP专属礼包查看信息
  653. function VipModel:SetVipGiftFindInfo( vo )
  654. for k,v in pairs(vo.list) do
  655. self.vip_gift_find_list[v.vip_lv] = true
  656. end
  657. end
  658. --获得vip专属礼包查询状态通过vip等级
  659. function VipModel:GetVipGiftFindByVipLv( vip_lv )
  660. return self.vip_gift_find_list[vip_lv] or false
  661. end
  662. -- 投资相关 start --
  663. -- 投资相关 start --
  664. -- 投资相关 start --
  665. -- 初始化投资计划配置
  666. function VipModel:InitInvestmentPlayCfg( )
  667. -- 初始化缓存计划类型配置
  668. self.investment_type_cfg = {}
  669. for k, v in pairs(Config.Investmenttypes) do
  670. self.investment_type_cfg[v.type] = self.investment_type_cfg[v.type] or {}
  671. self.investment_type_cfg[v.type][v.level] = v
  672. end
  673. -- 初始化缓存投资计划内容配置
  674. self.investment_cfg = {}
  675. for k, v in pairs(Config.Investmentrewards) do
  676. self.investment_cfg[v.type] = self.investment_cfg[v.type] or {}
  677. self.investment_cfg[v.type][v.level] = self.investment_cfg[v.type][v.level] or {}
  678. self.investment_cfg[v.type][v.level][v.id] = v
  679. end
  680. -- 创建一次缓存配置,用于提供首轮红点
  681. -- for k, v in pairs(self.investment_cfg) do
  682. -- self:GetInvestmentViewData(v.type)
  683. -- end
  684. end
  685. function VipModel:GetInvestmentTypeData( )
  686. return self.investment_type_cfg
  687. end
  688. -- 根据需求获取投资配置
  689. function VipModel:GetInvestmentCfg(type, level, id)
  690. if type then
  691. if level then
  692. if id then
  693. return self.investment_cfg[type] and self.investment_cfg[type][level] and self.investment_cfg[type][level][id] or nil
  694. else
  695. return self.investment_cfg[type] and self.investment_cfg[type][level] or nil
  696. end
  697. else
  698. return self.investment_cfg[type]
  699. end
  700. else
  701. return self.investment_cfg
  702. end
  703. end
  704. -- 获取投资计划特定类型节点所需数据
  705. function VipModel:GetInvestmentViewData(type)
  706. if not type then return nil end
  707. self.investment_view_item_data[type] = self.investment_view_item_data[type] or {}
  708. local round, is_finished = self:GetInvestmentCurRound(type)
  709. -- 不存在缓存数据的话就生成
  710. if not self.investment_view_item_data[type][round] then
  711. self.investment_view_item_data[type][round] = DeepCopy(self:GetInvestmentCfg(type, round))
  712. end
  713. if self.investment_view_item_data[type][round] then
  714. for k, v in ipairs(self.investment_view_item_data[type][round]) do
  715. if is_finished then
  716. v.sort_weight = 3
  717. else
  718. self:UpdateInvestmentItemDataSortWeight(v)
  719. end
  720. end
  721. self:InvestmentSortFunc(self.investment_view_item_data[type][round])
  722. return self.investment_view_item_data[type][round]
  723. end
  724. return nil
  725. end
  726. -- 由于跨天或者升级后要更新投资计划的红点信息
  727. function VipModel:RefreshInvestmentViewDataRed( )
  728. local function refresh_func()
  729. local updated = false
  730. for k, v in pairs(self.investment_data) do
  731. local round, is_finished = self:GetInvestmentCurRound(v.type)
  732. if v.is_buy == 1 and not is_finished then -- 已购买才刷新
  733. -- 更新当前类型的投资已经买了几天
  734. v.bought_day = v.buy_time ~= 0 and math.ceil((TimeUtil:getServerTime() - v.buy_time) / 86400) or 0
  735. updated = true
  736. end
  737. end
  738. if updated then
  739. self:IsNeedRed(VipModel.TabType.Investment)
  740. end
  741. end
  742. TimeManager.GetInstance():StartTime("VIP_INVESETMENT_RED_1", 0.5, refresh_func)
  743. end
  744. -- 更新投资计划节点数据的排序权重
  745. function VipModel:UpdateInvestmentItemDataSortWeight(data)
  746. local flag = self:GetInvestMentRewardFlag(data.type, data.id)
  747. local lv = RoleManager.Instance.mainRoleInfo.level
  748. local bought_day = self:GetInvestmentBoughtDay(data.type)
  749. -- 设置排序队列,已领取的在后面
  750. if flag then
  751. data.sort_weight = 3
  752. else
  753. -- 判断是否可领取
  754. local can_reveive = true
  755. local condition = stringtotable(data.condition)
  756. for _, cond in ipairs(condition) do
  757. if cond[1] == "lv" then -- 需要达到等级
  758. can_reveive = can_reveive and lv >= cond[2]
  759. elseif cond[1] == "day" then -- 需要达到购买天数
  760. can_reveive = can_reveive and bought_day >= cond[2]
  761. end
  762. end
  763. data.sort_weight = can_reveive and 1 or 2
  764. end
  765. end
  766. function VipModel:InvestmentSortFunc(list)
  767. local sort_func = function ( a, b )
  768. if a.sort_weight == b.sort_weight then
  769. return a.id < b.id
  770. else
  771. return a.sort_weight < b.sort_weight
  772. end
  773. end
  774. table.sort(list, sort_func)
  775. end
  776. -- 设置投资相关协议信息 42001
  777. function VipModel:SetInvestmentData(vo)
  778. if not vo then return end
  779. if self._block_update_invsetment_data then
  780. self._cache_invsetment_data = vo
  781. else
  782. self._cache_invsetment_data = nil -- 如果能顺利更新投资数据,则需要清除限制刷新时的缓存
  783. -- 初始化数据
  784. self.investment_data = {}
  785. for k, v in ipairs(vo.list) do
  786. local rewards_tb = {}
  787. for _, v2 in ipairs(v.rewards) do
  788. rewards_tb[v2.id] = v2.id
  789. end
  790. self.investment_data[v.type] = self.investment_data[v.type] or {}
  791. self.investment_data[v.type].type = v.type
  792. self.investment_data[v.type].round = v.round
  793. self.investment_data[v.type].is_buy = v.is_buy
  794. self.investment_data[v.type].buy_time = v.buy_time
  795. self.investment_data[v.type].rewards = rewards_tb
  796. -- 当前类型的投资已经买了几天
  797. self.investment_data[v.type].bought_day = v.buy_time ~= 0 and math.ceil((TimeUtil:getServerTime() - v.buy_time) / 86400) or 0
  798. end
  799. -- 更新投资信息的领取情况及排序
  800. for k, v in pairs(self.investment_data) do
  801. self:GetInvestmentViewData(v.type)
  802. end
  803. -- 特殊处理后,在这边更新
  804. self:IsNeedRed(VipModel.TabType.Investment)
  805. self:Fire(VipModel.UPDATE_INVESTMENT_DATA)
  806. end
  807. end
  808. -- 关闭界面时,重新更新投资协议数据
  809. function VipModel:ReupdateInvestmentData( )
  810. if self._cache_invsetment_data then
  811. self:SetInvestmentData(self._cache_invsetment_data)
  812. end
  813. self._cache_invsetment_data = nil
  814. end
  815. function VipModel:GetInvestmentData(type)
  816. if type then
  817. return self.investment_data[type]
  818. else
  819. return self.investment_data
  820. end
  821. end
  822. function VipModel:GetInvestmentBoughtDay(type)
  823. local bought_day = 0
  824. local data = self:GetInvestmentData(type)
  825. if data then
  826. bought_day = data.bought_day
  827. end
  828. return bought_day
  829. end
  830. -- 根据服务端返回的数据,判断当前是处于当前投资类型的第几轮
  831. function VipModel:GetInvestmentCurRound(type)
  832. if not type then return nil end
  833. local round = 1
  834. local data = self:GetInvestmentData(type)
  835. if data then
  836. round = data.round
  837. end
  838. local total_round = self.investment_type_cfg[type] and #self.investment_type_cfg[type] or 0
  839. -- 是否已经投资完全部阶段
  840. local is_finished = round > total_round
  841. round = round <= total_round and round or total_round
  842. return round, is_finished
  843. end
  844. -- 根据投资类型更新领奖rewardid
  845. function VipModel:UpdateInvestmentRewardId(vo)
  846. if not vo then return end
  847. self.investment_data[vo.type] = self.investment_data[vo.type] or {}
  848. self.investment_data[vo.type].rewards = self.investment_data[vo.type].rewards or {}
  849. self.investment_data[vo.type].rewards[vo.id] = vo.id
  850. -- 更新缓存
  851. local round, is_finished = self:GetInvestmentCurRound(vo.type)
  852. if self.investment_view_item_data[vo.type] and self.investment_view_item_data[vo.type][round] then
  853. for k, v in ipairs(self.investment_view_item_data[vo.type][round]) do
  854. if v.id == vo.id then
  855. -- 领取了的缓存直接改为3
  856. v.sort_weight = 3
  857. break
  858. end
  859. end
  860. -- 重新排序节点
  861. self:InvestmentSortFunc(self.investment_view_item_data[vo.type][round])
  862. end
  863. end
  864. -- 获取投资计划的奖励领取情况
  865. function VipModel:GetInvestMentRewardFlag(type, id)
  866. if not type then return false end
  867. if id then
  868. return self.investment_data[type] and self.investment_data[type].rewards and self.investment_data[type].rewards[id] or false
  869. else
  870. return self.investment_data[type] and self.investment_data[type].rewards or false
  871. end
  872. end
  873. -- 是否已经投资了所有的投资类型
  874. function VipModel:HasBoughtAllInvestmentTypes( )
  875. local bool = true
  876. local type_list = self:GetInvestmentTypeData()
  877. for k, v in pairs(type_list) do
  878. local type_data = self:GetInvestmentData(v.type) or {}
  879. for k2, v2 in ipairs(type_data) do
  880. bool = bool and (v2.is_buy == 1)
  881. end
  882. end
  883. return bool
  884. end
  885. -- 投资计划红点
  886. function VipModel:CheckInvestmentPlanRed(type)
  887. local bool = false
  888. local bought_all = true -- 是否已经买完了投资所有档位
  889. local function check_investment_red_by_type(type)
  890. self.investment_red[type] = false
  891. local data = self:GetInvestmentData(type)
  892. bought_all = bought_all and (data and data.is_buy == 1 or false)
  893. if data and data.is_buy == 1 then
  894. local view_data = self:GetInvestmentViewData(type)
  895. for k, v in ipairs(view_data) do
  896. if v.sort_weight == 1 then -- 可领取
  897. self.investment_red[type] = true
  898. bool = true
  899. end
  900. end
  901. end
  902. end
  903. if type then
  904. check_investment_red_by_type(type)
  905. else
  906. for k, v in pairs(self.investment_type_cfg) do
  907. check_investment_red_by_type(k)
  908. end
  909. end
  910. -- 如果已经全买了,那就不需要登录红点了
  911. if self.investment_login_red then
  912. self.investment_login_red = not bought_all
  913. end
  914. bool = bool or self.investment_login_red
  915. return bool
  916. end
  917. -- 根据类型获取投资计划红点
  918. function VipModel:GetInvestmentPlanRed(type)
  919. if type then
  920. return self.investment_red[type] or false
  921. else
  922. local bool = false
  923. for k, v in pairs(self.investment_red) do
  924. bool = bool or v
  925. end
  926. return bool
  927. end
  928. end
  929. -- 投资相关 end --
  930. -- 投资相关 end --
  931. -- 投资相关 end --
  932. ---------------------------- vip 幻魔UP卡 开始 ---------------------
  933. -- 获取幻魔UP卡基本信息
  934. function VipModel:GetVipCarBaseInfo(product_id)
  935. local info =
  936. {
  937. product_id = product_id,
  938. product_name = "",
  939. money = 0,
  940. about = "",
  941. days = 0,
  942. buy_reward = {},
  943. day_reward = {},
  944. }
  945. local config_product = Config.Rechargeproduct[product_id]
  946. if config_product then
  947. info.product_name = config_product.product_name
  948. info.money = config_product.money
  949. info.about = config_product.about
  950. end
  951. local config_rechargewelfare = Config.Rechargewelfare[product_id]
  952. if config_rechargewelfare then
  953. info.days = config_rechargewelfare.days
  954. info.buy_reward = stringtotable(Trim(config_rechargewelfare.buy_reward))
  955. info.day_reward = stringtotable(Trim(config_rechargewelfare.reward))
  956. end
  957. return info
  958. end
  959. -- 获取幻魔UP卡信息
  960. function VipModel:RequstVipCarInfo()
  961. self:DelayFire(VipModel.REQUEST_CCMD_EVENT, 15901)
  962. end
  963. -- 购买幻魔UP卡
  964. function VipModel:RequstBuyVipCar(product_id)
  965. if not self:IsCurProductCanBuy(product_id) then
  966. Message.show("今日续费次数已达到上限哦~")
  967. return
  968. end
  969. self:Fire(VipModel.REQUEST_CCMD_EVENT, 15904, product_id)
  970. end
  971. -- 领取幻魔UP卡每日奖励
  972. function VipModel:RequstGetVipCarDayReward(product_id)
  973. self:Fire(VipModel.REQUEST_CCMD_EVENT, 15902, product_id)
  974. end
  975. -- 设置幻魔UP卡信息
  976. function VipModel:SetVipCarDayReward(vo)
  977. self.vipcard_info = {}
  978. self.vipcard_info.product_list = vo.product_list
  979. if self.vipcard_info.product_list and #self.vipcard_info.product_list > 1 then
  980. table.sort( self.vipcard_info.product_list, function (a, b)
  981. return a.product_subtype < b.product_subtype
  982. end )
  983. end
  984. self:IsNeedRed(VipModel.TabType.Card)
  985. self:Fire(VipModel.UPDATE_VIP_CARD_INFO)
  986. end
  987. -- 是否可以续费尊享卡
  988. function VipModel:IsCurProductCanBuy(product_id)
  989. local left_buy_time = 0
  990. local can_buy = true
  991. if self.vipcard_info and self.vipcard_info.product_list then
  992. for i,v in ipairs(self.vipcard_info.product_list) do
  993. if v.product_id == product_id then
  994. return v.left_times > 0
  995. end
  996. end
  997. end
  998. return can_buy
  999. end
  1000. -- 尊享卡强化概率
  1001. function VipModel:VipCardEquipStrengthRatio(is_perent)
  1002. local ratio = 0
  1003. if self:HaveVipCard(VipModel.VIP_CARD.MONTH) then
  1004. ratio = VipModel.VIP_CARD_RATIO.Strength
  1005. if is_perent then
  1006. ratio = ratio / 100
  1007. end
  1008. end
  1009. return ratio
  1010. end
  1011. -- 尊享卡升星概率
  1012. function VipModel:VipCardEquipEvolutionRatio(is_perent)
  1013. local ratio = 0
  1014. if self:HaveVipCard(VipModel.VIP_CARD.WEEK) then
  1015. ratio = VipModel.VIP_CARD_RATIO.Evolotion
  1016. if is_perent then
  1017. ratio = ratio / 100
  1018. end
  1019. end
  1020. return ratio
  1021. end
  1022. -- 尊享卡月卡橙装掉率概率
  1023. function VipModel:VipCardMonthEquipDropRatio(is_have, is_perent)
  1024. local ratio = 0
  1025. if is_have or self:HaveVipCard(VipModel.VIP_CARD.MONTH) then
  1026. ratio = VipModel.VIP_CARD_RATIO.MonthEquipDrop
  1027. if is_perent then
  1028. ratio = ratio / 100
  1029. end
  1030. end
  1031. return ratio
  1032. end
  1033. -- 尊享卡季卡橙装掉率概率
  1034. function VipModel:VipCardSeasonEquipDropRatio(is_have, is_perent)
  1035. local ratio = 0
  1036. if is_have or self:HaveVipCard(VipModel.VIP_CARD.SEASON) then
  1037. ratio = VipModel.VIP_CARD_RATIO.SeasonEquipDrop
  1038. if is_perent then
  1039. ratio = ratio / 100
  1040. end
  1041. end
  1042. return ratio
  1043. end
  1044. -- 是否还有vip尊享卡
  1045. function VipModel:HaveVipCard(product_id)
  1046. local b = false
  1047. if self.vipcard_info and self.vipcard_info.product_list then
  1048. for i,v in ipairs(self.vipcard_info.product_list) do
  1049. if v.product_id == product_id then
  1050. return v.state ~= 0 and v.left_count > 0
  1051. end
  1052. end
  1053. end
  1054. return b
  1055. end
  1056. -- 尊享卡主界面展示
  1057. function VipModel:CheckVipCardIcon()
  1058. local b, str = false,""
  1059. if not GetModuleIsOpen(450, 6) or self:GetVipLevel() < 1 then
  1060. return b, str
  1061. end
  1062. local is_active_month_card = self:HaveVipCard(VipModel.VIP_CARD.MONTH)
  1063. local is_active_season_card = self:HaveVipCard(VipModel.VIP_CARD.SEASON)
  1064. local month_card_drop_ratio = self:VipCardMonthEquipDropRatio(true, true)
  1065. local season_card_drop_ratio = self:VipCardSeasonEquipDropRatio(true, true)
  1066. if not is_active_month_card and not is_active_season_card then
  1067. str = HtmlColorTxt("未激活", ColorUtil.RED_DARK)
  1068. elseif is_active_month_card and is_active_season_card then
  1069. str = string.format("橙装掉率%s", HtmlColorTxt("+".. (month_card_drop_ratio + season_card_drop_ratio) .."%", "#fdffc2"))
  1070. elseif is_active_season_card then
  1071. str = string.format("橙装掉率%s", HtmlColorTxt("+".. (season_card_drop_ratio) .."%", "#fdffc2"))
  1072. elseif is_active_month_card then
  1073. str = string.format("橙装掉率%s", HtmlColorTxt("+".. (month_card_drop_ratio) .."%", "#fdffc2"))
  1074. end
  1075. return true, str
  1076. end
  1077. -- 获取续费提示
  1078. function VipModel:GetVipCardRechargeTip()
  1079. local product_id, left_times = 0, 0
  1080. local cur_time = TimeUtil:getServerTime()
  1081. if self.vipcard_info and self.vipcard_info.product_list then
  1082. for i,v in ipairs(self.vipcard_info.product_list) do
  1083. if v.end_time and v.end_time > 0 and v.end_time > cur_time then
  1084. --3天
  1085. local offset_time = v.end_time - cur_time
  1086. if offset_time < 3600 * 24 * 3 and (left_times == 0 or offset_time < left_times) then
  1087. product_id = v.product_id
  1088. left_times = offset_time
  1089. end
  1090. end
  1091. end
  1092. end
  1093. return product_id,left_times
  1094. end
  1095. -- 领取幻魔UP卡每日奖励
  1096. function VipModel:CheckVipCardRedDot()
  1097. if self.vipcard_info and self.vipcard_info.product_list then
  1098. for i,v in ipairs(self.vipcard_info.product_list) do
  1099. if v.state == 1 then
  1100. return true
  1101. end
  1102. end
  1103. end
  1104. return false
  1105. end
  1106. -- 尊享卡主界面展示
  1107. function VipModel:IsCanShowVipCardTips()
  1108. local b = false
  1109. if not GetModuleIsOpen(450, 6) or self:GetVipLevel() < 1 then
  1110. return b
  1111. end
  1112. local is_active_week_card = self:HaveVipCard(VipModel.VIP_CARD.WEEK)
  1113. local is_active_month_card = self:HaveVipCard(VipModel.VIP_CARD.MONTH)
  1114. local is_active_season_card = self:HaveVipCard(VipModel.VIP_CARD.SEASON)
  1115. return not is_active_week_card and not is_active_month_card and not is_active_season_card
  1116. end
  1117. ---------------------------- vip 幻魔UP卡 结束 ---------------------
  1118. --保存客服信息
  1119. function VipModel:SetServiceData(scmd)
  1120. self.service_data = scmd
  1121. end
  1122. function VipModel:GetServiceData( )
  1123. return self.service_data
  1124. end
  1125. -- 获取VIP副本可以扫荡的VIP等级
  1126. function VipModel:GetVipDungeonSweepLV( )
  1127. for k,v in pairs(Config.Vipprivilege) do
  1128. if v.class_id == 5 and v.subclass_id == 1 and v.type == 1 then
  1129. return v.lv
  1130. end
  1131. end
  1132. end
  1133. --设置贵族技能播放cookie
  1134. function VipModel:SetVipNobleSkillPlayCookie( bool )
  1135. CookieWrapper.Instance:SaveCookie(CookieLevelType.Account,CookieTimeType.TYPE_ALWAYS,CookieKey.VIP_NOBLE_SKILL_PLAY,bool)
  1136. CookieWrapper.Instance:WriteAll()
  1137. end
  1138. --设置贵族技能播放cookie
  1139. function VipModel:GetVipNobleSkillPlayCookie( )
  1140. local bool = CookieWrapper.Instance:GetCookie(CookieLevelType.Account,CookieKey.VIP_NOBLE_SKILL_PLAY) or false
  1141. return bool
  1142. end
  1143. ----------直购礼包免费红点-start---------
  1144. function VipModel:CheckPurchaseGiftFreeRed( )
  1145. self.purchase_gift_red_list = {}
  1146. if self:GetVipLevel() < 3 then
  1147. return false
  1148. end
  1149. local purchaseGift_cfg = self:GetPurchaseGiftCfg()
  1150. local server_info = self:GetProductInfo(VipModel.Type.PurchaseGift)
  1151. local is_show, openDay_limit, mergeDay_limt
  1152. local open_day = ServerTimeModel:getInstance():GetOpenServerDay()
  1153. local level = RoleManager.Instance.mainRoleInfo.level
  1154. local vip_flag = RoleManager.Instance.mainRoleInfo.vip_flag
  1155. for k,v in pairs(purchaseGift_cfg) do
  1156. local recharge_cfg = Config.Rechargeproduct[v.id]
  1157. if recharge_cfg.money == 0 and v.limit and v.limit[2] then
  1158. local have_time = v.limit[2]
  1159. if server_info and server_info.product_list[v.id] then
  1160. have_time = have_time - server_info.product_list[v.id].buy_counts
  1161. end
  1162. is_show = true
  1163. openDay_limit = v.open_day[1]
  1164. if openDay_limit then
  1165. if open_day < openDay_limit[1] or open_day > openDay_limit[2] then
  1166. is_show = false
  1167. end
  1168. end
  1169. mergeDay_limt = v.merge_day[1]
  1170. if mergeDay_limt then
  1171. if open_day < mergeDay_limt[1] or open_day > mergeDay_limt[2] then
  1172. is_show = false
  1173. end
  1174. end
  1175. for kk,vv in pairs(v.condition) do
  1176. if vv[1] == "lv" then
  1177. if level < tonumber(vv[2]) then
  1178. is_show = false
  1179. end
  1180. limit_lv = tonumber(vv[2])
  1181. elseif vv[1] == "vip" then
  1182. if vip_flag < tonumber(vv[2]) then
  1183. is_show = false
  1184. end
  1185. limit_vip = tonumber(vv[2])
  1186. end
  1187. end
  1188. if have_time > 0 and is_show then
  1189. print('=======Msh:VipModel.lua[1261] ===TABLE====')
  1190. PrintTable(v)
  1191. self.purchase_gift_red_list[v.sub_type] = true
  1192. end
  1193. end
  1194. end
  1195. return self:GetPurchaseGiftFreeRed()
  1196. end
  1197. function VipModel:GetPurchaseGiftFreeRed( sub_type )
  1198. if sub_type then
  1199. return self.purchase_gift_red_list and self.purchase_gift_red_list[sub_type]
  1200. else
  1201. return self.purchase_gift_red_list and TableSize(self.purchase_gift_red_list) > 0
  1202. end
  1203. end
  1204. ----------直购礼包免费红点-end-----------
  1205. --开始V3激活步骤
  1206. function VipModel:PlayVipThreeStep( )
  1207. --先关界面
  1208. self:Fire(VipModel.OPEN_EXPERIENCE_V_THREE_VIEW,true)
  1209. self:Fire(VipModel.OPEN_EXPERIENCE_V_THREE_EX_VIEW,nil,true)
  1210. --打开引导界面
  1211. local show_vos = {{
  1212. type = 1,
  1213. is_out_res=false,
  1214. saying = "恭喜晋升VIP3,相应特权现已全部激活!",
  1215. ignore_fly=false,
  1216. show_time=10,--持续时间
  1217. name = "VIP3",
  1218. winId = 450,
  1219. subId = 22,
  1220. }}
  1221. local view = NewFuncOpenView.New()
  1222. view:Open(show_vos)
  1223. end