FanliLogic.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. local ObjHuman = require("core.ObjHuman")
  2. local FanliExcel = require("excel.fanli").fanli
  3. local Config = require("Config")
  4. local ObjHuman = require("core.ObjHuman")
  5. local VipLogic = require("vip.VipLogic")
  6. local MailManager = require("mail.MailManager")
  7. local MailExcel = require("excel.mail")
  8. local PfLogic = require("platform.PfLogic")
  9. local Define = require("platform.Define")
  10. local Json = require("common.Json")
  11. local Log = require("common.Log")
  12. FANLI_LIST = FANLI_LIST or {}
  13. function initAfterHot()
  14. for k,v in pairs(FANLI_LIST) do
  15. FANLI_LIST[k] = nil
  16. end
  17. for k,v in ipairs(FanliExcel) do
  18. --是属于这个服务器的
  19. if PfLogic.inServerIndex(v.svrInd) then
  20. FANLI_LIST[Config.SVR_INDEX.."-"..v.account] = k
  21. end
  22. end
  23. end
  24. -- 读取返利
  25. function setFanLi(human)
  26. -- 有无返利
  27. local id = FANLI_LIST[human.db.account]
  28. if not id then
  29. return
  30. end
  31. if human.db.fanliVer == 1 then
  32. return
  33. end
  34. local api_param = {}
  35. api_param.fanLi = 1
  36. api_param.account = human.db.account
  37. _G.thread_http.send(Define.REPORT_FANLI_REPORT_PHP,Json.Encode(api_param))
  38. end
  39. -- 返利回调
  40. function onFanLi(human)
  41. local id = FANLI_LIST[human.db.account]
  42. if not id then
  43. return
  44. end
  45. local conf = FanliExcel[id]
  46. if not conf then
  47. return
  48. end
  49. if human.db.fanliVer == 1 then
  50. return
  51. end
  52. human.db.fanliVer = 1
  53. local items = { }
  54. items[1] = { 102, conf.yuanbao }
  55. local title = MailExcel.mail[2000].title
  56. local content = MailExcel.mail[2000].content
  57. local senderName = MailExcel.mail[2000].senderName
  58. MailManager.add(MailManager.SYSTEM, human.db._id, title, content, items, senderName)
  59. VipLogic.addExp(human, conf.vipExp)
  60. return true
  61. end