WeekDirectPurchase.lua 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. --- 运营直购礼包
  2. WeekDirectPurchase = {}
  3. WeekDirectPurchase.__index = WeekDirectPurchase
  4. local this = {}
  5. local function _rechargeType()
  6. return "20"
  7. end
  8. local function _playerDbKey()
  9. return nil
  10. end
  11. local BUY_TYPE = {
  12. NOE_BUY = 2, -- 一键购买
  13. FREE_BUY = 3 -- 免费购买
  14. }
  15. --- 请求充值档位信息
  16. function WeekDirectPurchase.reqRechargeAction(actor,mainGroup)
  17. -- 判断当前主活动是否开启了子直购活动
  18. local allActivityInfo = {}
  19. -- local operateActivityTable = ConfigDataManager.getList("cfg_OperateActivity_CDM")
  20. -- if table.isNullOrEmpty(operateActivityTable) then
  21. -- return allActivityInfo
  22. -- end
  23. -- for _, config in pairs(operateActivityTable) do
  24. -- if tonumber(mainGroup) == tonumber(config.maingroup) then
  25. -- local directId = config.id
  26. -- local itemCount = config.itemcount
  27. -- local rewardsMap = string.toIntIntMap(itemCount, "#", "|")
  28. -- local rechargeId = ConfigDataManager.getTableValue("cfg_recharge","id","type",config.rechargetype,"parameter",directId)
  29. -- local activityInfo = {
  30. -- directId = directId,
  31. -- itemInfo = rewardsMap,
  32. -- rechargeId = rechargeId
  33. -- }
  34. -- table.insert(allActivityInfo,activityInfo)
  35. -- end
  36. -- end
  37. return allActivityInfo
  38. end
  39. --- 触发充值
  40. function WeekDirectPurchase.rechargeEvent(actor, cfg_recharge, count, amount, ext, outRewards)
  41. -- local directGiftId = cfg_recharge.parameter
  42. -- local config = ConfigDataManager.getById("cfg_OperateActivity_CDM", directGiftId)
  43. -- local mainGroup = WeekActives.getCurrentMainGroup(actor)
  44. -- local cfgMainGroup = config.maingroup
  45. -- if mainGroup ~= tonumber(cfgMainGroup) then
  46. -- return
  47. -- end
  48. -- if tonumber(config.bugtype) == BUY_TYPE.NOE_BUY then
  49. -- -- 一键购买
  50. -- local operateActivity = ConfigDataManager.getTable("cfg_OperateActivity_CDM","mainGroup",mainGroup)
  51. -- if not table.isNullOrEmpty(operateActivity) then
  52. -- for _, config in pairs(operateActivity) do
  53. -- local operateActivityId = config.id
  54. -- local countKey = ConfigDataManager.getTableValue("cfg_recharge","Countkey","parameter",operateActivityId,"type",_rechargeType())
  55. -- local count = CountManager.getCount(actor, tonumber(countKey))
  56. -- if tonumber(operateActivityId) ~= tonumber(directGiftId) then
  57. -- if tonumber(config.bugtype) ~= BUY_TYPE.FREE_BUY and count.count > 0 then
  58. -- return
  59. -- end
  60. -- end
  61. -- end
  62. -- end
  63. -- this.oneBug(actor,outRewards,operateActivity)
  64. -- else
  65. -- gameDebug.assertTrue(table.notEmpty(config), "没有配置直购礼包", directGiftId)
  66. -- local reward_str = config.itemcount
  67. -- if not string.isNullOrEmpty(reward_str) then
  68. -- string.putIntIntMap(outRewards, reward_str, "#", "|")
  69. -- end
  70. -- end
  71. -- -- 发送界面信息数据
  72. -- this.debug("购买直购礼包成功", cfg_recharge, "购买数量", count, ext, outRewards)
  73. -- WeekActives.openSubActive(actor,{
  74. -- subType = ACTIVE_TYPE.DIRECT
  75. -- })
  76. end
  77. -- 一键购买
  78. function this.oneBug(actor,outRewards,operateActivity)
  79. if not table.isNullOrEmpty(operateActivity) then
  80. for _, config in pairs(operateActivity) do
  81. local operateActivityId = config.id
  82. local countKey = ConfigDataManager.getTableValue("cfg_recharge","Countkey","parameter",operateActivityId,"type",_rechargeType())
  83. local total = ConfigDataManager.getTableValue("Count_count","total","id",countKey)
  84. CountManager.count(actor, tonumber(countKey),tonumber(total))
  85. for i = 1, tonumber(total) do
  86. string.putIntIntMap(outRewards, config.itemcount, "#", "|")
  87. end
  88. end
  89. end
  90. end
  91. --- 直购关闭
  92. function WeekDirectPurchase.closeActive(mainGroup)
  93. -- local allRoleInfos = getallrolesummaryinfos()
  94. -- local activeInfo = {}
  95. -- if not table.isNullOrEmpty(allRoleInfos) then
  96. -- local directId = ConfigDataManager.getTableValue("cfg_OperateActivity_CDM","id","mainGroup",mainGroup,"bugType",BUY_TYPE.FREE_BUY)
  97. -- local countKey = ConfigDataManager.getTableValue("cfg_recharge","Countkey","parameter",directId,"type",_rechargeType())
  98. -- local specialCondition = ConfigDataManager.getTableValue("cfg_OperateActivity_subActivity","specialCondition","mainGroup",mainGroup,"subType",ACTIVE_TYPE.DIRECT)
  99. -- for k, roleInfo in pairs(allRoleInfos) do
  100. -- local actor = roleInfo["actor"]
  101. -- -- 判断当前玩家有没有另外免费直购
  102. -- local item = {}
  103. -- local countInfo = CountManager.getCount(actor,countKey)
  104. -- if not table.isNullOrEmpty(countInfo) and countInfo.total > countInfo.count and ConditionManager.Check(actor, specialCondition) then
  105. -- local itemInfo = ConfigDataManager.getTableValue("cfg_OperateActivity_CDM","itemCount","id",directId)
  106. -- local count = countInfo.total - countInfo.count
  107. -- for i = 1, count do
  108. -- string.putIntIntMap(item, itemInfo, "#", "|")
  109. -- end
  110. -- sendconfigmailbyrid(actor,actor:toString(), 900002, item)
  111. -- end
  112. -- end
  113. -- end
  114. end
  115. -- ------------------------------------------------------------- --
  116. this.log_open = false
  117. function this.debug(...)
  118. if not this.log_open then
  119. return
  120. end
  121. gameDebug.print(...)
  122. end
  123. function this.jprint(...)
  124. if not this.log_open then
  125. return
  126. end
  127. if param == nil then
  128. param = "error! 输出内容为空. nil"
  129. end
  130. jprint(...)
  131. end
  132. -- ------------------------------------------------------------- --
  133. EventListerTable.registerType("幸运周末直购礼包", _rechargeType(), _playerDbKey())
  134. RechargeEventListerTable:eventLister(_rechargeType(), "幸运周末直购礼包", WeekDirectPurchase.rechargeEvent)