SevenDayLogic.lua 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. --[[
  2. absAct[id] = {
  3. }
  4. ]]
  5. local AbsActLogic = require("absAct.AbsActLogic")
  6. local AbsActExcel = require("excel.absAct")
  7. local BuyExcel = require("excel.buy")
  8. local Util = require("common.Util")
  9. local Msg = require("core.Msg")
  10. local Grid = require("bag.Grid")
  11. local BagLogic = require("bag.BagLogic")
  12. local BuyLogic = require("topup.BuyLogic")
  13. local YunYingLogic = require("yunying.YunYingLogic")
  14. function isOpen(human, YYInfo, funcConfig)
  15. local state, endTime, startTime = AbsActLogic.isStarted(human, funcConfig.funcID)
  16. if not state then return end
  17. local absAct = human.db.absAct[funcConfig.funcID]
  18. if absAct and absAct.dayCnt and absAct.dayCnt <= 0 and #absAct.item <= 0 then
  19. return false
  20. end
  21. return true, endTime, startTime
  22. end
  23. function isActive(human, YYInfo, funcConfig)
  24. return not isOpen(human, YYInfo, funcConfig)
  25. end
  26. -- 发送数据
  27. function getAndSendMsg(human,id,actID)
  28. -- 判断活动是否开起
  29. local state, endTime, starTime = AbsActLogic.isStarted(human, id)
  30. if not state then return end
  31. local absConfig = AbsActExcel.absActivity[id]
  32. if not absConfig then return end
  33. local absAct = human.db.absAct[id]
  34. if not absAct then
  35. return
  36. end
  37. -- 构造数据
  38. local nowDay = Util.diffDay(starTime) + 1
  39. absAct.get = absAct.get or {}
  40. config = AbsActExcel.sevenDay
  41. local len = #config
  42. local count = 0
  43. local msgRet = Msg.gc.GC_ABS_ND_SEVEN_DAY_QUERY
  44. msgRet.day = nowDay
  45. for i = 1,len do
  46. local v = config[i]
  47. if v.actId == absConfig.actId then
  48. count = count + 1
  49. local net = msgRet.sevenDayList[count]
  50. net.day = v.day
  51. local itemLen = #v.item
  52. for j = 1,itemLen do
  53. Grid.makeItem(net.item[j],v.item[j][1],v.item[j][2])
  54. end
  55. net.item[0] = itemLen
  56. net.state = absAct.get[v.day] and absAct.get[v.day] or 0
  57. if nowDay >= v.day and net.state == 0 then
  58. net.state = 1
  59. end
  60. end
  61. end
  62. msgRet.sevenDayList[0] = count
  63. Msg.send(msgRet,human.fd)
  64. end
  65. -- 获取对应天数奖励
  66. function getItem(human,day,id)
  67. -- 判断活动是否开启
  68. local state, endTime, starTime = AbsActLogic.isStarted(human, id)
  69. if not state then return end
  70. local absConfig = AbsActExcel.absActivity[id]
  71. if not absConfig then return end
  72. local absAct = human.db.absAct[id]
  73. if not absAct then
  74. return
  75. end
  76. absAct.get = absAct.get or {}
  77. local nowDay = Util.diffDay(starTime) + 1
  78. local config = AbsActExcel.sevenDay
  79. -- 指定天已被领取
  80. if absAct.get[day] == 2 then
  81. return
  82. end
  83. -- 指定天未到
  84. if day > nowDay then
  85. return
  86. end
  87. -- 改变状态
  88. absAct.get[day] = 2
  89. -- 发放道具
  90. local len = #config
  91. for i = 1,len do
  92. local v = config[i]
  93. if v.actId == absConfig.actId and v.day == day then
  94. BagLogic.addItemList(human, v.item, "abs_seven_day")
  95. end
  96. end
  97. getAndSendMsg(human,id,absConfig.actID)
  98. YunYingLogic.updateIcon(YYInfo[id], human)
  99. YunYingLogic.sendBanner(human)
  100. YunYingLogic.sendGroupUpdate(YYInfo[id], human, absConfig.panelID)
  101. end
  102. function isRed(human, YYInfo, funcConfig)
  103. local state,endTime,starTime = AbsActLogic.isStarted(human, funcConfig.funcID)
  104. if not state then return end
  105. local absConfig = AbsActExcel.absActivity[funcConfig.funcID]
  106. local absAct = human.db.absAct[funcConfig.funcID]
  107. if not absAct then return true end
  108. local nowDay = Util.diffDay(starTime) + 1
  109. absAct.get = absAct.get or {}
  110. for i = 1,nowDay do
  111. local v = absAct.get[i]
  112. if v == 1 or v == nil then
  113. return true
  114. end
  115. end
  116. return false
  117. end
  118. function getLeftTime(human, YInfo, funcConfig)
  119. local ret, endTime, startTime = AbsActLogic.isStarted(human, funcConfig.funcID)
  120. if ret == true then
  121. return endTime - os.time()
  122. else
  123. return 0
  124. end
  125. end