源战役
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
3.9 KiB

  1. %% ---------------------------------------------------------
  2. %% Author: xyao
  3. %% Email: jiexiaowen@gmail.com
  4. %% Created: 2012-5-4
  5. %% Description: 日 ,周,目标 ets
  6. %% --------------------------------------------------------
  7. -define(DAILY_KEY(Clock), lists:concat(["mod_daily_", Clock])).
  8. -define(TWELVE,24). %% 日常次数(凌晨12点)
  9. -define(FOUR, 4). %% 日常次数(凌晨4点)
  10. -define(DEFAULT_SUB_MODULE, 0). %% 默认模块子id设为0
  11. -define(DEFAULT_OTHER, []). %% 默认other扩展数据
  12. %% 每天记录
  13. -record(ets_daily, {
  14. id = {0,0,0}, %% {模块id, 模块子id, 类型}
  15. count = 0, %% 数量
  16. other = [], %% 扩展数据
  17. refresh_time = 0 %% 最后修改时间
  18. }).
  19. -define(DAILY_KEY_DICT(RoleId), lists:concat(["mod_daily_dict_", RoleId])).
  20. -record(ets_daily_dict, {
  21. id = {0,0,0,0}, %% {玩家id, 模块id, 模块子id, 类型}
  22. count = 0, %% 数量
  23. other = [], %% 扩展数据
  24. refresh_time = 0 %% 最后修改时间
  25. }).
  26. -record(base_daily, {
  27. module = 0, %% 模块id
  28. sub_module = 0, %% 模块子id
  29. id = 0, %% 次数id
  30. limit = 0, %% 上限
  31. clock = 0, %% 清理时间
  32. write_db = 1, %% 是否入库:1持久版,2缓存版(缓存版日清时间统一为凌晨4点)
  33. about="" %% 描述
  34. }).
  35. %% 每天次数记录(凌晨12点)
  36. -define(sql_daily_role_sel_all, <<"SELECT `module`, `sub_module`, `type`, `count`, `other`, `refresh_time` FROM `counter_daily_twelve` WHERE role_id=~p">>).
  37. -define(sql_daily_role_upd, <<"REPLACE INTO `counter_daily_twelve` (`role_id`,`module`,`sub_module`,`type`,`count`,`other`,`refresh_time`) VALUES (~p, ~p, ~p, ~p, ~p, '~s', ~p)">>).
  38. -define(sql_daily_role_upd_batch, <<"REPLACE INTO `counter_daily_twelve` (`role_id`,`module`,`sub_module`,`type`,`count`,`other`,`refresh_time`) VALUES ~s">>).
  39. -define(sql_daily_role_clear, <<"delete from `counter_daily_twelve` where `role_id` = ~p">>).
  40. -define(sql_daily_clear, <<"truncate table `counter_daily_twelve`">>).
  41. -define(sql_daily_role_sel, <<"SELECT `count`, `refresh_time`, `other` FROM `counter_daily_twelve` WHERE role_id = ~p AND `module` = ~p AND `sub_module` = ~p AND `type` = ~p">>).
  42. -define(sql_daily_four_role_sel_all, <<"SELECT `module`, `sub_module`, `type`, `count`, `other`, `refresh_time` FROM `counter_daily_four` WHERE role_id=~p">>).
  43. -define(sql_daily_four_role_upd, <<"REPLACE INTO `counter_daily_four` (`role_id`,`module`,`sub_module`,`type`,`count`,`other`,`refresh_time`) VALUES (~p,~p,~p,~p,~p, '~s', ~p)">>).
  44. -define(sql_daily_four_role_upd_batch, <<"REPLACE INTO `counter_daily_four` (`role_id`,`module`,`sub_module`,`type`,`count`,`other`,`refresh_time`) VALUES ~s">>).
  45. -define(sql_daily_four_role_clear, <<"delete from `counter_daily_four` where `role_id` = ~p">>).
  46. -define(sql_daily_four_clear, <<"truncate table `counter_daily_four`">>).
  47. -define(sql_daily_four_role_sel, <<"SELECT `count`, `refresh_time`, `other` FROM `counter_daily_four` WHERE role_id = ~p AND `module` = ~p AND `sub_module` = ~p AND `type` = ~p">>).
  48. -define(sql_daily_count_by_module_type, <<"select sum(`count`) from `counter_daily_twelve` where `module` = ~p AND `sub_module` = ~p AND `type` = ~p">>).
  49. -define(sql_daily_four_count_by_module_type, <<"select sum(`count`) from `counter_daily_four` where `module` = ~p AND `sub_module` = ~p AND `type` = ~p">>).
  50. -define(sql_daily_clear_by_time, <<"delete from `counter_daily_twelve` where `refresh_time` < ~p">>).
  51. -define(sql_daily_four_clear_by_time, <<"delete from `counter_daily_four` where `refresh_time` < ~p">>).