RechargeBackLogic.lua 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. --- 打赏返利
  2. local Util = require("common.Util")
  3. local ObjHuman = require("core.ObjHuman")
  4. local RechBackExcel = require("excel.present").rechargeBack
  5. local Msg = require("core.Msg")
  6. local Grid = require("bag.Grid")
  7. local ItemDefine = require("bag.ItemDefine")
  8. local BuyLogic = require("topup.BuyLogic")
  9. local BagLogic = require("bag.BagLogic")
  10. local YunYingLogic = require("yunying.YunYingLogic")
  11. local PanelDefine = require("broadcast.PanelDefine")
  12. local YyHandler = require("yunying.Handler")
  13. local KingWorldLogic = require("present.KingWorldLogic")
  14. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  15. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  16. function query(human)
  17. local msgRet = Msg.gc.GC_RECHARGE_BACK_QUERY
  18. msgRet.recharge = human.db.topupAcount or 0
  19. msgRet.maxCnt = #RechBackExcel
  20. msgRet.isEnd = 0
  21. local len = 0
  22. local getDb = human.db.rechargeBackGet or {}
  23. for k, config in ipairs(RechBackExcel) do
  24. len = len + 1
  25. local net = msgRet.list[len]
  26. net.id = k
  27. net.need = config.need
  28. net.state = getDb[k] and 2 or 0
  29. for j, h in ipairs(config.items) do
  30. Grid.makeItem(net.reward[j], h[1], h[2])
  31. end
  32. net.reward[0] = #config.items
  33. if len >= 10 then
  34. msgRet.isEnd = 0
  35. msgRet.list[0] = len
  36. Msg.send(msgRet, human.fd)
  37. len = 0
  38. end
  39. if k >= 3 and (not human.db.topupAcount or human.db.topupAcount < config.need) then
  40. break
  41. end
  42. end
  43. msgRet.isEnd = 1
  44. msgRet.list[0] = len
  45. Msg.send(msgRet, human.fd)
  46. end
  47. function get(human, id)
  48. local config = RechBackExcel[id]
  49. if not config then return end
  50. local rechargeNum = human.db.topupAcount or 0
  51. if config.need > rechargeNum then
  52. return
  53. end
  54. if human.db.rechargeBackGet and human.db.rechargeBackGet[id] then
  55. return
  56. end
  57. human.db.rechargeBackGet = human.db.rechargeBackGet or {}
  58. human.db.rechargeBackGet[id] = 1
  59. BagLogic.addItemList(human, config.items, "rechargeBack")
  60. query(human)
  61. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_108)
  62. end
  63. function isDot(human)
  64. local getDb = human.db.rechargeBackGet or {}
  65. local rechargeNum = human.db.topupAcount or 0
  66. for k, config in ipairs(RechBackExcel) do
  67. if rechargeNum >= config.need and not getDb[k] then
  68. return true
  69. elseif rechargeNum < config.need then
  70. break
  71. end
  72. end
  73. return false
  74. end
  75. function isRed(human,YYInfo, funcConfig)
  76. local getDb = human.db.rechargeBackGet or {}
  77. local rechargeNum = human.db.topupAcount or 0
  78. for k, config in ipairs(RechBackExcel) do
  79. if rechargeNum >= config.need and not getDb[k] then
  80. return true
  81. elseif rechargeNum < config.need then
  82. break
  83. end
  84. end
  85. return false
  86. end
  87. function isOpen(human, YYInfo, funcConfig)
  88. return true
  89. end