itemrecordSrv.lua 963 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. --[[
  2. Descripttion:明细
  3. version:
  4. Author: Neo,Huang
  5. Date: 2023-11-23 23:22:46
  6. LastEditors: Neo,Huang
  7. LastEditTime: 2023-11-23 23:23:57
  8. --]]
  9. local timer = require("timer")
  10. local baseService = require("baseService")
  11. local lib_game_mysql = require("lib_game_mysql")
  12. local timeUtil = require("utils.timeUtil")
  13. local timerDelExpire = nil
  14. local CMD = {}
  15. -- 清理明细记录
  16. local function l_del_expire_record()
  17. local currTime = skynet_time()
  18. local maxTime = timeUtil.getDayStartTime(currTime, -7)
  19. local sql = string.format("delete from mdl_itemrecord where createTime < %s;", tostring(maxTime))
  20. local ret = lib_game_mysql:query(sql)
  21. log.info("l_del_expire_record sql[%s] ret[%s]", tostring(sql), tostring(ret))
  22. end
  23. function CMD.onStart()
  24. -- 每天1点开始删除
  25. timerDelExpire = timer.timeOfDay(1, 0, 0, l_del_expire_record)
  26. end
  27. function CMD.onStop()
  28. -- 取消定时器
  29. timerDelExpire.func = nil
  30. end
  31. baseService.start(CMD, ".itemrecordCenter", true)