TopupLogic.lua 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. -------------------------------------------------
  2. -- 充值
  3. -------------------------------------------------
  4. local BuyExcel = require("excel.buy")
  5. local Msg = require("core.Msg")
  6. local ObjHuman = require("core.ObjHuman")
  7. local BuyLogic = require("topup.BuyLogic")
  8. local SceneHandler = require("scene.Handler")
  9. local YunYingLogic = require("yunying.YunYingLogic")
  10. local LeichongHaoli = require("present.LeichongHaoli")
  11. local LeijiChongzhi = require("present.LeijiChongzhi")
  12. local DailyLeichong = require("present.DailyLeichong")
  13. local LoginSignLogic = require("loginSign.LoginSignLogic")
  14. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  15. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  16. local MailExcel = require("excel.mail")
  17. local MailManager = require("mail.MailManager")
  18. local CommonDB = require("common.CommonDB")
  19. local Msg = require("core.Msg")
  20. -- 专属客服充值额度
  21. EXCLUSIVE_SERVER_9937 = 1000
  22. TOPUP_LIBAO_ID1 = 1 --盲盒礼包
  23. TOPUP_LIBAO_ID2 = 2 --铂金周卡
  24. TOPUP_LIBAO_ID3 = 3 --365王卡
  25. local MAX_FIREWORKS_DURATION = 43200
  26. local YANHUA_EMAIL = 7012 --烟花邮箱
  27. local ITEMID=1022 --烟花道具ID
  28. --封装直购基本信息
  29. local function wrapTopupItem(net, config, human)
  30. net.id = config.id
  31. BuyLogic.fontBuyItem(human, net.buyItem, config.buyID)
  32. end
  33. -- 充值列表
  34. function query(human)
  35. if SceneHandler.canCharge(human) ~= true then
  36. return
  37. end
  38. local msgRet = Msg.gc.GC_TOPUP_QUERY
  39. msgRet.list[0] = #BuyExcel.topup
  40. for i, config in ipairs(BuyExcel.topup) do
  41. local net = msgRet.list[i]
  42. wrapTopupItem(net, config, human)
  43. end
  44. Msg.send(msgRet,human.fd)
  45. end
  46. -- 直购回调
  47. function clacTopupAcount(human, price, buyID)
  48. if price < 0 then return end
  49. ObjHuman.updateDaily(human)
  50. human.db.topupAcountDaily = (human.db.topupAcountDaily or 0) + price
  51. human.db.topupAccountMonth = (human.db.topupAccountMonth or 0) + price
  52. human.db.topupAcount = (human.db.topupAcount or 0) + price
  53. checkKf(human)
  54. YunYingLogic.onCharge(human, price, buyID)
  55. DailyLeichong.charge(human, price)
  56. LeichongHaoli.onAddMoney(human, price)
  57. LeijiChongzhi.onAddMoney(human, price)
  58. LoginSignLogic.chargeAfter(human)
  59. sendFireworksMail(human,price)
  60. end
  61. -- 发送烟花邮件
  62. function sendFireworksMail(human, price)
  63. if price < 100 then return end -- 如果充值金额小于100,不发送邮件
  64. -- 计算烟花数量
  65. local nFireWorksCount = math.floor(price / 100)
  66. if 0 >= nFireWorksCount then
  67. return
  68. end
  69. local mailCfg = MailExcel.mail[YANHUA_EMAIL]
  70. local title = mailCfg.title
  71. local content = mailCfg.content
  72. local senderName = mailCfg.senderName
  73. local items = {
  74. {ITEMID,nFireWorksCount} -- 1022是烟花的道具ID
  75. }
  76. -- 调用邮件管理器发送邮件
  77. MailManager.add(MailManager.SYSTEM, human.db._id, title, content, items, senderName)
  78. end
  79. function checkKf(human)
  80. -- 激活专属客服
  81. if human.db.topupAcount ~= nil and human.db.topupAcount >= EXCLUSIVE_SERVER_9937 then
  82. Msg.send(Msg.gc.GC_EXCLUSIVE_SERVER,human.fd)
  83. end
  84. end
  85. --给客户端下发结束时间//定义的协议时间 //当客户端有点击请求的时候
  86. function DurationofBonus(human)
  87. local tMsgData = Msg.gc.GC_FIREWORKS_QUERY
  88. local nowBufferDuration = CommonDB.getFireWorksBonusTime()-os.time()
  89. tMsgData.buffDuration = math.max(0,nowBufferDuration)
  90. Msg.send(tMsgData, human.fd)
  91. end
  92. function Addtime(human, fireworksCount)
  93. local nNowTime = os.time()
  94. if not human or fireworksCount <= 0 then
  95. return
  96. end
  97. local currentEndTime = CommonDB.getFireWorksBonusTime()
  98. local baseTime = nNowTime
  99. if currentEndTime > nNowTime then
  100. baseTime = currentEndTime
  101. end
  102. local addedTime = math.max(fireworksCount * 60,60)
  103. local newEndTime = math.min(
  104. baseTime + addedTime,
  105. nNowTime + MAX_FIREWORKS_DURATION
  106. )
  107. local totalDuration = newEndTime-nNowTime
  108. if totalDuration <=0 or totalDuration> MAX_FIREWORKS_DURATION then
  109. return
  110. end
  111. CommonDB.setFireWorkBonusTime(newEndTime)
  112. local tMsgData = Msg.gc.GC_FIREWORKS_SHOW
  113. local nowBuffDuration = CommonDB.getFireWorksBonusTime()-os.time()
  114. tMsgData.buffDuration = math.max(0,nowBuffDuration)
  115. tMsgData.playerName = human.db.name
  116. -- 下发时间和玩家名称
  117. for _, human in pairs(ObjHuman.onlineUuid) do
  118. if human and human.fd then
  119. Msg.send(tMsgData, human.fd)
  120. end
  121. end
  122. end