源战役客户端
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

513 righe
16 KiB

4 settimane fa
  1. SupremeVipModel = SupremeVipModel or BaseClass(BaseVo, true)
  2. local SupremeVipModel = SupremeVipModel
  3. function SupremeVipModel:__init()
  4. SupremeVipModel.Instance = self
  5. self:Reset()
  6. end
  7. function SupremeVipModel:Reset()
  8. self.sup_vip_type = 0 --是否是永久贵族 0|否 1|体验 2|永久
  9. self.end_time = 0 --体验贵族结束时间戳
  10. self.today_charge = 0 --今日充值
  11. self.continue_day = 0 --体验贵族连续充值天数
  12. self.now_day = 0 --体验贵族当前天数
  13. self.gift_count = 0 --每日礼包领取次数
  14. self.unlock_id = 0 --当前解锁序列
  15. self.star_gold = 0 --今日星钻
  16. self.shop_cfg = {} --排好序的星钻商城配置列表
  17. self.shop_limit_data = {} --商城物品的限购信息
  18. self.shop_limit_data_dic = {} --存一份以限购类型为键的表
  19. self.exchange_rest_count_list = {} --剩余的兑换次数列表
  20. self.is_first_open_train_drug = true --是否第一次打开培养丹兑换界面,第一次打开之后就要清掉红点
  21. self.is_first_open_shop = true --是否第一次打开商城界面
  22. self.supreme_vip_red_dot_info = {} --红点数据
  23. -- self.login_red = true
  24. self.daily_reward_day_state_list = {} --每日奖励前七天领奖状态
  25. self.supreme_vip_login_days = 0 --七日登录当前天数
  26. self:SetSupremeVipShopCfg()
  27. self:InitCfg()
  28. end
  29. function SupremeVipModel:getInstance()
  30. if SupremeVipModel.Instance == nil then
  31. SupremeVipModel.Instance = SupremeVipModel.New()
  32. end
  33. return SupremeVipModel.Instance
  34. end
  35. function SupremeVipModel:InitCfg( )
  36. self.cfg_total_charge = stringtotable(Config.Supvipkv["total_charge"].value)[1][3]
  37. self.trial_sup_vip_active = stringtotable(Config.Supvipkv["trial_sup_vip_active"].value)[1][3]
  38. self.gold_exchange_price_data = stringtotable(Config.Supvipkv["gold_exchange_price"].value)
  39. end
  40. --星钻商城配置信息
  41. function SupremeVipModel:SetSupremeVipShopCfg( )
  42. for k,v in pairs(Config.Supvipstore) do
  43. table.insert(self.shop_cfg,v)
  44. end
  45. local sort_func = function ( a, b )
  46. return a.index < b.index
  47. end
  48. table.sort(self.shop_cfg, sort_func)
  49. end
  50. --获取商城配置信息
  51. function SupremeVipModel:GetSupremeVipShopCfg()
  52. local true_cfg = {} --排除掉已经购买过的终身限购物品
  53. for i,v in ipairs(self.shop_cfg) do
  54. local is_unlocked = self:IsInUnLockList(i-1>=1 and i-1 or 1)
  55. if is_unlocked then
  56. if self.shop_limit_data[v.goods_id] then
  57. if self.shop_limit_data[v.goods_id].count_type == 3 then
  58. if self.shop_limit_data[v.goods_id].count == 0 then
  59. table.insert(true_cfg,v)
  60. end
  61. else
  62. table.insert(true_cfg,v)
  63. end
  64. else
  65. table.insert(true_cfg,v)
  66. end
  67. end
  68. end
  69. return true_cfg
  70. end
  71. --获取贵族图标开放VIP等级
  72. function SupremeVipModel:GetSupremeIconOpenVipLv( )
  73. return Config.Supvipkv["trial_sup_vip_lv_limit"].value
  74. end
  75. --获取每日礼包配置信息
  76. function SupremeVipModel:GetDailyGiftCfg( )
  77. return stringtotable(Config.Supvipkv["daily_sup_vip_gift"].value)
  78. end
  79. --获取彩钻兑换常量配置
  80. function SupremeVipModel:GetDiamondExchageCfg( )
  81. return stringtotable(Config.Supvipkv["gold_exchange"].value)
  82. end
  83. --星钻库存超过时提醒的数值
  84. function SupremeVipModel:GetMoneyLeftCfgNum( )
  85. return Config.Supvipkv["remind_num"].value
  86. end
  87. --获取彩钻兑换比例(红钻数,彩钻数)
  88. function SupremeVipModel:GetDiamondExchangeRatio( )
  89. local data = self.gold_exchange_price_data
  90. return data[1][1],data[1][2]
  91. end
  92. --获取激活一阶贵族的消耗
  93. function SupremeVipModel:GetActivateSupremeVipCost( )
  94. return self.trial_sup_vip_active
  95. end
  96. --获取激活永久贵族的消耗
  97. function SupremeVipModel:GetActivateForeverSupremeVipCost( )
  98. return self.cfg_total_charge
  99. end
  100. --保存贵族信息 45101
  101. function SupremeVipModel:SetSupremeVipData(vo)
  102. self.sup_vip_type = vo.sup_vip_type
  103. self.end_time = vo.end_time
  104. self.today_charge = vo.today_charge
  105. self.total_charge = vo.total_charge
  106. self.continue_day = vo.continue_day
  107. self.now_day = vo.day
  108. self.gift_count = vo.gift_count
  109. RoleManager.Instance.mainRoleInfo:ChangeVar("sup_vip_type", self.sup_vip_type)
  110. end
  111. --获取一阶贵族结束时间戳
  112. function SupremeVipModel:GetEndTime( )
  113. return self.end_time
  114. end
  115. --保存贵族商城信息 45104
  116. function SupremeVipModel:SetSupremeVipShopData(vo)
  117. for k,v in pairs(vo.goods_list) do
  118. self.shop_limit_data_dic[v.count_type] = self.shop_limit_data_dic[v.count_type] or {}
  119. self.shop_limit_data_dic[v.count_type][v.goods_id] = v
  120. self.shop_limit_data[v.goods_id] = v
  121. end
  122. self.unlock_id = vo.unlock_id
  123. end
  124. --更新贵族商城限购信息 45104
  125. function SupremeVipModel:RefreshShopLimitData(vo)
  126. for k,v in pairs(vo.goods_list) do
  127. self.shop_limit_data_dic[v.count_type] = self.shop_limit_data_dic[v.count_type] or {}
  128. self.shop_limit_data_dic[v.count_type][v.goods_id] = v
  129. self.shop_limit_data[v.goods_id] = v
  130. end
  131. self.unlock_id = vo.unlock_id
  132. end
  133. --判断当前index的商品是否解锁能买
  134. function SupremeVipModel:IsInUnLockList(index)
  135. if self.shop_cfg[index] then
  136. if self.shop_cfg[index].type == 1 then
  137. return true
  138. else
  139. return index <= self.unlock_id
  140. end
  141. else
  142. return false
  143. end
  144. end
  145. --获取限购信息列表
  146. function SupremeVipModel:GetLimitShopData(goods_id)
  147. return self.shop_limit_data[goods_id] or nil
  148. end
  149. --保存今日星钻数 45106
  150. function SupremeVipModel:SetStarDiamondData(vo)
  151. self.star_gold = vo.star_gold
  152. end
  153. function SupremeVipModel:GetStarDiamondNum( )
  154. return self.star_gold
  155. end
  156. --保存今日的兑换剩余次数
  157. function SupremeVipModel:SetExchangeRestCounts(vo)
  158. -- 1礼包|2彩钻|3培养丹
  159. self.exchange_rest_count_list[vo.type] = vo.rest_count
  160. end
  161. --获取剩余兑换次数
  162. function SupremeVipModel:GetExchangeRestCount(type)
  163. return self.exchange_rest_count_list[type] or 0
  164. end
  165. --45109 每日礼包七天登录数据
  166. function SupremeVipModel:SetSupremeVipSevenLoginData(vo)
  167. self.daily_reward_day_state_list = vo.day_state
  168. self.supreme_vip_login_days = vo.login_days
  169. end
  170. --七天登录当前天数
  171. function SupremeVipModel:GetSupremeVipSevenLoginDays( )
  172. return self.supreme_vip_login_days
  173. end
  174. --判断当前天对应奖励的领取状态
  175. function SupremeVipModel:GetSupremeVipSevenLoginRewardState(day)
  176. -- 领取状态 0|未领 1|领了一次 2|领了两次
  177. local reward_state = 0
  178. for k,v in pairs(self.daily_reward_day_state_list) do
  179. if v.day_id == day then
  180. reward_state = v.reward_state
  181. break
  182. end
  183. end
  184. return reward_state
  185. end
  186. --获取累计充值的天数
  187. function SupremeVipModel:GetChargeDay( )
  188. return self.continue_day
  189. end
  190. --是否拥有该主界面功能特权
  191. function SupremeVipModel:HaveSupremeVipRight(index)
  192. -- do return true end
  193. if self:IsForeverSupremeVip() then
  194. return true
  195. else
  196. if self:IsMomentSupremeVip() then
  197. return index == 1 or index == 4
  198. else
  199. return false
  200. end
  201. end
  202. end
  203. --自己是否是永久贵族
  204. function SupremeVipModel:IsForeverSupremeVip()
  205. return self.sup_vip_type == 2
  206. end
  207. --自己是否是一阶贵族
  208. function SupremeVipModel:IsMomentSupremeVip()
  209. return self.sup_vip_type == 1
  210. -- if self:IsForeverSupremeVip() then
  211. -- return false
  212. -- else
  213. -- local now_time = TimeUtil:getServerTime()
  214. -- if now_time < self.end_time then
  215. -- return true
  216. -- else
  217. -- return false
  218. -- end
  219. -- end
  220. end
  221. function SupremeVipModel:GetSupVipType( )
  222. return self.sup_vip_type
  223. end
  224. --根据时间戳计算一阶贵族还剩几天
  225. function SupremeVipModel:GetLeftMomentSupremeVipDay()
  226. local day_time = 1
  227. local true_day = 0
  228. local true_hour = 0
  229. local true_time = 0
  230. local hour_time = 0
  231. local minute_time = 0
  232. if self.end_time ~=0 then
  233. local str = TimeUtil:timeConversion(self.end_time, "yy/mm/dd hh:mm")
  234. local real_time = TimeUtil:ConvertFmStringToTime(str, 1)
  235. true_time = real_time-TimeUtil:getServerTime()
  236. true_day = true_time/86400
  237. true_hour = true_time/3600
  238. hour_time = math.ceil(true_time/3600)
  239. minute_time = math.ceil(true_time/60)
  240. day_time = math.ceil(true_day)
  241. end
  242. return day_time,true_day,hour_time,true_hour,minute_time
  243. end
  244. -------------红点
  245. function SupremeVipModel:IsNeedRedAll( )
  246. for k,v in pairs(SupremeVipConst.RED_DOT_TYPE) do
  247. self:IsNeedRed(v)
  248. end
  249. end
  250. function SupremeVipModel:IsNeedRed( tab_id )
  251. local bool = false
  252. if tab_id == SupremeVipConst.RED_DOT_TYPE.DailyGift then
  253. bool = self:CheckDailyGiftRed()
  254. elseif tab_id == SupremeVipConst.RED_DOT_TYPE.DiamondExchange then
  255. bool = self:CheckDiamondExchangeRed()
  256. elseif tab_id == SupremeVipConst.RED_DOT_TYPE.Shop then
  257. bool = self:CheckShopRed()
  258. elseif tab_id == SupremeVipConst.RED_DOT_TYPE.TrainDrugExchange then
  259. bool = self:CheckTrainDrugExchangeRed()
  260. elseif tab_id == SupremeVipConst.RED_DOT_TYPE.MoneyLeft then--特殊红点,用来显示倒计时标志的,与红点是互斥,红点优先
  261. bool = self:CheckMoneyLeftRed()
  262. elseif tab_id == SupremeVipConst.RED_DOT_TYPE.SevenLogin then
  263. bool = self:CheckSevenLoginRed()
  264. end
  265. self.supreme_vip_red_dot_info[tab_id] = bool
  266. self:Fire(SupremeVipConst.ANS_UPDATE_RED_DOT,tab_id)
  267. end
  268. function SupremeVipModel:GetAllRedDot( )
  269. return self.supreme_vip_red_dot_info
  270. end
  271. function SupremeVipModel:GetMainButtonRed( )
  272. local bool = false
  273. for i,v in pairs(self.supreme_vip_red_dot_info) do
  274. if v and i ~= SupremeVipConst.RED_DOT_TYPE.MoneyLeft then--特殊红点,用来显示倒计时标志的,与红点是互斥,红点优先
  275. bool = true
  276. break
  277. end
  278. end
  279. return bool
  280. end
  281. -- 优化5:
  282. -- 检测玩家的星钻货币存量,如果玩家的星钻货币存量是》=X(X值看下可否走配置),且玩家星钻商城存在可兑换物品,则主图标以及页签给与一个倒计时图标
  283. -- 当玩家有操作导致存量<X,或无可兑换物品,倒计时图标消失
  284. -- 请留意倒计时标记和红点互斥,如有外部图标有红点,优先显示红点
  285. -- 优化6:
  286. -- 玩家每次完成充值后,检查如玩家的星钻货币存量》=X(X看下可否走配置,同条目5中的X值一样),且玩家星钻商城存在可兑换物品,则主界面与页签给与一次性红点
  287. -- 玩家进入点击一次星钻商城页签后,红点消失
  288. -- 说明1:如满足条件则每充值一次就会触发一次
  289. -- 说明2:内部页签的倒计时图标和红点也是互斥,有红点优先显示红点
  290. function SupremeVipModel:GetMainButtonTimeCountDownFlag( )
  291. return self.supreme_vip_red_dot_info[SupremeVipConst.RED_DOT_TYPE.MoneyLeft] and self.supreme_vip_red_dot_info[SupremeVipConst.RED_DOT_TYPE.MoneyLeft] or false
  292. end
  293. function SupremeVipModel:CheckDailyGiftRed( )
  294. if not GetModuleIsOpen(451) then return false end
  295. local login_days = self:GetSupremeVipSevenLoginDays()
  296. if login_days <= 7 then
  297. return false
  298. end
  299. local bool = false
  300. bool = self:GetExchangeRestCount(SupremeVipConst.ExchangeType.DailyGift) > 0
  301. return bool
  302. end
  303. function SupremeVipModel:CheckDiamondExchangeRed( )
  304. if not GetModuleIsOpen(451) then return false end
  305. local bool = false
  306. local jinLock_num = RoleManager.Instance.mainRoleInfo.jinLock
  307. local jinLock_ratio,jin_ratio = self:GetDiamondExchangeRatio()--彩钻红钻兑换比例数
  308. local can_exchange = jinLock_num >= jinLock_ratio
  309. bool = self:GetExchangeRestCount(SupremeVipConst.ExchangeType.Diamond) > 0 and can_exchange
  310. return bool
  311. end
  312. function SupremeVipModel:CheckShopRed( )
  313. if not GetModuleIsOpen(451) then return false end
  314. if self.sup_vip_type == 0 then return false end
  315. if not self.is_first_open_shop then return false end --每次登陆上线给次红点,之后不再给红点
  316. local bool = false
  317. local can_buy_cfg = {}--筛选出能购买物品的商品列表
  318. for i,v in ipairs(self.shop_cfg) do
  319. if self.shop_limit_data[v.goods_id] and v.index <= self.unlock_id then
  320. local price_cfg = stringtotable(v.price)
  321. local limit_cfg = stringtotable(v.limit_buy)
  322. if not limit_cfg or #limit_cfg ~= 0 then --把不限购的筛选出去
  323. local can_buy = limit_cfg[1][2]-self.shop_limit_data[v.goods_id].count > 0
  324. if can_buy and price_cfg[1][1] == 11 and self.star_gold >= price_cfg[1][2] then
  325. bool = true
  326. break
  327. end
  328. end
  329. end
  330. end
  331. return bool
  332. end
  333. function SupremeVipModel:CheckTrainDrugExchangeRed( )
  334. return false
  335. -- if not GetModuleIsOpen(451) then return false end
  336. -- if not self.is_first_open_train_drug then return false end --每次登陆上线给次红点,之后不再给红点
  337. -- local bool = false
  338. -- local train_drug_cfg = self:GetTrainDrugExchangeTrueCfg()
  339. -- local is_train_drug_enough = false
  340. -- for k,v in pairs(train_drug_cfg) do
  341. -- local _,goods_num1 = GoodsModel:getInstance():GetTypeGoodsNum(v.goods_id) --拿到限时物品数量
  342. -- if goods_num1 >= 1 then
  343. -- is_train_drug_enough = true
  344. -- break
  345. -- end
  346. -- end
  347. -- bool = self:GetExchangeRestCount(SupremeVipConst.ExchangeType.TrainDrug) > 0 and is_train_drug_enough
  348. -- return bool
  349. end
  350. function SupremeVipModel:CheckMoneyLeftRed( )
  351. if not GetModuleIsOpen(451) then return false end
  352. if self.sup_vip_type == 0 then return false end
  353. local bool = false
  354. local remind_num = self:GetMoneyLeftCfgNum()
  355. local star_gold_num = self:GetStarDiamondNum()
  356. if star_gold_num >= remind_num then
  357. --如果剩余的星钻数超过了配置值,判断是不是有东西可以买
  358. local can_buy_cfg = {}--筛选出能购买物品的商品列表
  359. for i,v in ipairs(self.shop_cfg) do
  360. if self.shop_limit_data[v.goods_id] and v.index <= self.unlock_id then
  361. local price_cfg = stringtotable(v.price)
  362. local limit_cfg = stringtotable(v.limit_buy)
  363. if not limit_cfg or #limit_cfg ~= 0 then --把不限购的筛选出去
  364. local can_buy = limit_cfg[1][2]-self.shop_limit_data[v.goods_id].count > 0
  365. if can_buy and price_cfg[1][1] == 11 and self.star_gold >= price_cfg[1][2] then
  366. bool = true
  367. break
  368. end
  369. end
  370. end
  371. end
  372. end
  373. return bool
  374. end
  375. function SupremeVipModel:CheckSevenLoginRed( )
  376. if not GetModuleIsOpen(451) then return false end
  377. local bool = false
  378. local login_days = self:GetSupremeVipSevenLoginDays()
  379. if login_days > 7 then
  380. bool = false
  381. else
  382. for k,v in pairs(self.daily_reward_day_state_list) do
  383. if self:IsForeverSupremeVip() then
  384. if v.reward_state ~= 2 then
  385. bool = true
  386. end
  387. elseif self:IsMomentSupremeVip() then
  388. if v.reward_state == 0 then
  389. bool = true
  390. end
  391. end
  392. end
  393. end
  394. return bool
  395. end
  396. function SupremeVipModel:GetTrainDrugExchangeTrueCfg( )
  397. -- local mainVo = RoleManager:getInstance():GetMainRoleVo()
  398. local data = {}
  399. local train_drug_cfg = {}
  400. for k,v in pairs(Config.Supvipexchange) do
  401. -- if mainVo.vip_flag >= v.min_vip and mainVo.vip_flag <= v.max_vip then
  402. -- data[v.goods_id] = v
  403. -- end
  404. data[v.goods_id] = v
  405. end
  406. for k,v in pairs(data) do
  407. table.insert(train_drug_cfg,v)
  408. end
  409. for i,v in ipairs(train_drug_cfg) do
  410. v.goods_num = GoodsModel:getInstance():GetTypeGoodsNum(v.goods_id)
  411. end
  412. local sort_func = function ( a, b )
  413. return a.goods_num > b.goods_num
  414. end
  415. table.sort(train_drug_cfg, sort_func)
  416. return train_drug_cfg
  417. end
  418. function SupremeVipModel:GetDailyGiftRed( )
  419. return self.supreme_vip_red_dot_info[SupremeVipConst.RED_DOT_TYPE.DailyGift] or false
  420. end
  421. function SupremeVipModel:GetDiamondExchangeRed( )
  422. return self.supreme_vip_red_dot_info[SupremeVipConst.RED_DOT_TYPE.DiamondExchange] or false
  423. end
  424. function SupremeVipModel:GetShopRed( )
  425. return self.supreme_vip_red_dot_info[SupremeVipConst.RED_DOT_TYPE.Shop] or false
  426. end
  427. function SupremeVipModel:GetTrainDrugExchangeRed( )
  428. return false
  429. -- return self.supreme_vip_red_dot_info[SupremeVipConst.RED_DOT_TYPE.TrainDrugExchange] or false
  430. end
  431. function SupremeVipModel:GetMoneyLeftRed( )
  432. return self.supreme_vip_red_dot_info[SupremeVipConst.RED_DOT_TYPE.MoneyLeft] or false
  433. end
  434. function SupremeVipModel:GetSevenLoginRed( )
  435. return self.supreme_vip_red_dot_info[SupremeVipConst.RED_DOT_TYPE.SevenLogin] or false
  436. end