源战役
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.

153 lines
5.9 KiB

  1. %%% @author root <root@localhost.localdomain>
  2. %%% @copyright (C) 2018, root
  3. %%% @doc
  4. %%%
  5. %%% @end
  6. %%% Created : 3 Feb 2018 by root <root@localhost.localdomain>
  7. %% 称号操作
  8. -define(OP_ACTIVE, 1). %% 系统激活
  9. -define(OP_REMOVE, 2). %% 移除
  10. -define(OP_REPLACE, 3). %% 顶替
  11. -define(OP_PROP, 4). %% 道具激活
  12. %% 称号状态
  13. -define(STATUS_UNUSED, 0). %% 没有佩戴
  14. -define(STATUS_USED, 1). %% 佩戴中
  15. %% 结果
  16. -define(CODE_FAIL, 0). %% 失败
  17. -define(CODE_OK, 1). %% 成功
  18. -record(base_designation, {
  19. id = 0, %% 称号id
  20. name = "", %% 称号名称
  21. main_type = 0, %% 1-名人称号,2-成就称号,3情缘称号,4-活动称号
  22. description = "", %% 描述
  23. type = 1, %% 默认1,1图片称号,2文字称号
  24. is_trial = 0, %% 是否可体验 默认是0
  25. goods_id = 0, %% 道具激活的称号对应的物品ID,默认0
  26. attr_list = [], %% 属性奖励,格式:[{属性1,数值},{属性2,数值}……]
  27. resource_id = 0, %% 称号对应的资源ID,文字称号填0
  28. is_global = 0, %% 全局称号数量,0表示无限制
  29. color = 0, %% 称号名称显示的颜色,前端使用
  30. power = 0, %% 战力显示
  31. access_way = "", %% 获取途径
  32. access_id = [], %% 获取途径id
  33. index = 0 %% 排序字段
  34. ,force_cancel %% 是否可以强制取消
  35. }).
  36. %% 限时称号体验配置
  37. -record(base_dsgt_trial, {
  38. goods_id = 0, %% 物品id
  39. dsgt_id = 0, %% 称号id
  40. trial_time = 0, %% 体验时间
  41. is_overlay = 0 %% 是否可叠加 0|1
  42. }).
  43. -record(dsgt_status, {
  44. player_id = 0, %% 玩家id
  45. %% current_id = 0, %% 玩家当前佩戴的称号id
  46. dsgt_map = #{}, %% 当前玩家激活的称号列表 id => #designation
  47. attr = [], %% 当前所有激活称号的属性状态 []
  48. power = 0 %% 战力
  49. }).
  50. -record(designation, {
  51. id = 0, %% 称号id
  52. status = 0, %% 称号当前状态
  53. active_time = 0, %% 激活时间戳
  54. end_time = 0, %% 过期时间
  55. time = 0, %% 操作时间
  56. dress_time = 0, %% 穿戴时间
  57. is_replace = 1 %% 0被顶替 1为顶替 %% 非全局称号默认1,全局称号只有穿戴时是1,被替换时为0
  58. }).
  59. -record(active_para, {
  60. id = 0, %% 称号id
  61. goods_id = 0, %% 物品id
  62. expire_time = 0, %% 称号持续时长
  63. is_overlay = 0 %% 是否可叠加
  64. }).
  65. %% 获取正在佩戴的称号id
  66. -define(SQL_DSGT_SEL_USED_ID,
  67. <<"select id from `designation` where player_id=~p and status=1 limit 1">>).
  68. %% 获取玩家所有的称号id
  69. -define(SQL_DSGT_SEL_ID,
  70. <<"select id from `designation` where player_id=~p">>).
  71. %% 获取一个称号的佩戴状态和时效时间
  72. -define(SQL_DSGT_SEL_STATUS,
  73. <<"select status, endtime from `designation` where player_id=~p and id=~p and is_replace =1">>).
  74. %% Rep更新玩家称号
  75. -define(SQL_DSGT_REPLACE,
  76. <<"replace into `designation` set player_id=~p, id=~p, status=~p, active_time=~p, endtime=~p, time=~p,dress_time = ~p,is_replace =~p">>).
  77. %% Up更新玩家称号
  78. -define(SQL_DSGT_UP,
  79. <<"update designation set status=~p, active_time=~p, endtime=~p, time = ~p ,dress_time = ~p, is_replace = ~p where player_id = ~p and id=~p ">>).
  80. -define(SQL_DSGT_UP_DRESSTIME,
  81. <<"update designation set status=~p, active_time=~p, endtime=~p, time = ~p ,dress_time = ~p where player_id = ~p and id=~p ">>).
  82. -define(SQL_DSGT_UPDATE_STATUS,
  83. <<"update designation set status=~p where player_id = ~p and id=~p">>).
  84. -define(SQL_DSGT_UPDATE_ACTIVE_AND_END_TIME,
  85. <<"update designation set active_time=~p, endtime=~p, is_replace=~p where player_id=~p and id=~p">>).
  86. %% 删除
  87. -define(SQL_DSGT_AUTOID_BATCH_DELETE,
  88. <<"delete from `designation` where player_id=~p and id in (~s) ">>).
  89. %% 获取玩家所有的称号
  90. -define(SQL_All_DSGT_SELECT,
  91. <<"select id, status, active_time, endtime, time, dress_time, is_replace from `designation` where player_id=~p ">>).
  92. %获取玩家某条称号
  93. -define(SQL_ONE_DSGT_SELECT,
  94. <<"select id, status, active_time, endtime, time,dress_time,is_replace from `designation` where player_id=~p and id =~p">>).
  95. %% 获取所有获得同一个称号的玩家
  96. -define(SQL_DSGT_PLAYER_SELECT,
  97. <<"select player_id, active_time, is_replace from `designation` where id=~p">>).
  98. %% 删除玩家的称号
  99. -define(SQL_DSGT_DELETE,
  100. <<"delete from `designation` where player_id=~p and id = ~p">>).
  101. %% 只更新使用状态
  102. -define(SQL_DSGT_STATE_UP,
  103. << "update designation set status=~p, time = ~p ,dress_time = ~p where player_id = ~p and id=~p">>).
  104. %% 只更新顶替和使用状态
  105. -define(SQL_DSGT_STATE_ISREPLACE_UP,
  106. << "update designation set status=~p, time = ~p ,is_replace = ~p where player_id = ~p and id=~p">>).
  107. %% 更新称号结束时间
  108. -define(SQL_DSGT_UPDATE_ETIME,
  109. << "update designation set endtime = ~p, time = ~p where id = ~p and player_id in (~s)">>).
  110. %%获取穿戴记录
  111. -define(SQL_SELECT_LASTDRESS,
  112. <<"select id from `designation` where player_id=~p and dress_time > 0 and status=1">>).
  113. %获取穿戴历史记录
  114. -define(SQL_SELECT_DRESS_HISTORY,
  115. <<"select id,dress_time from `designation` where player_id=~p and id = ~p and dress_time > 0">>).