user.lua 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. local code = require("code")
  2. local util_player = require("utils.util_player")
  3. local util_global = require("utils.util_global")
  4. local util_3rd = require("utils.util_3rd")
  5. local serverLogUtil = require("utils.serverLogUtil")
  6. local playerData = require("data.player")
  7. local userData = require("data.user")
  8. local root = class("user", require("base.baseModule"))
  9. function root:ctor(uid)
  10. root.super.ctor(self, uid, "user", "uid", true)
  11. self.uid = uid
  12. end
  13. function root:mysql_get_init_columns()
  14. return {
  15. uid = "int(11) unsigned NOT NULL",
  16. nickname = "varchar(50)",
  17. password = "varchar(45) DEFAULT NULL",
  18. uuid = "varchar(200) DEFAULT NULL",
  19. udid = "varchar(200) DEFAULT NULL",
  20. channel = "int(11) DEFAULT NULL",
  21. device = "varchar(45) DEFAULT NULL",
  22. loginTime = "int(11) DEFAULT 0",
  23. sysVer = "varchar(1024) DEFAULT NULL",
  24. version = "varchar(45) DEFAULT NULL",
  25. appVersion = "varchar(45) DEFAULT NULL",
  26. deviceId = "varchar(200) DEFAULT NULL",
  27. headUrl = "varchar(500) DEFAULT NULL",
  28. sex = "int(11) DEFAULT NULL",
  29. token = "varchar(255)",
  30. lastLoginTime = "int(11) DEFAULT 0",
  31. logoutTime = "int(11) DEFAULT 0",
  32. registerTime = "int(11) DEFAULT 0 COMMENT '注册时间'",
  33. registerVersion = "varchar(45) DEFAULT NULL COMMENT '注册版本'",
  34. ip = "varchar(45) DEFAULT NULL COMMENT 'IP'",
  35. status = "int(11) DEFAULT 0 COMMENT '账号状态 0:正常 1:封号 2:注销'",
  36. phone = "varchar(45) DEFAULT NULL COMMENT '绑定手机号'",
  37. bandShareCode = "varchar(45) DEFAULT NULL COMMENT '绑定推广码'",
  38. shareCode = "varchar(45) DEFAULT NULL COMMENT '我的推广码'",
  39. steamLink = "varchar(45) DEFAULT NULL COMMENT 'steam交易链接'"
  40. }
  41. end
  42. ----------------------------------------
  43. -- 接口
  44. ----------------------------------------
  45. -- 获取自己的信息
  46. function root:itf_get_info(role, msg)
  47. local info = util_player:get_player_info(self.uid)
  48. return code.OK, {playerInfo = info}
  49. end
  50. -- 获取验证码
  51. function root:itf_get_verify_code(role, msg)
  52. local vcode = playerData:update_verify_code(self.uid)
  53. local ret = {}
  54. if IS_TEST then
  55. ret.vcode = vcode
  56. else
  57. -- 发短信
  58. end
  59. return code.OK, ret
  60. end
  61. -- 更新主播邀请码
  62. function root:itf_update_band_share_code(role, msg)
  63. local shareCode = msg.shareCode
  64. if is_empty(shareCode) then
  65. return code.PARAMTER_ERROR
  66. end
  67. if not util_global:is_sharecode_active(shareCode) then
  68. -- 邀请码不存在
  69. return code.SHARE_CODE.NOT_FOUND
  70. end
  71. userData:band_share_code(self.uid, shareCode)
  72. -- 再次输出玩家登录埋点,方便后台捕捉数据
  73. serverLogUtil.logLogin(
  74. self.uid,
  75. shareCode,
  76. self:redis_get_key_info("channel") or "",
  77. self:redis_get_key_info("version") or "",
  78. self:redis_get_key_info("sysVer") or "",
  79. "",
  80. "",
  81. self:redis_get_key_info("uuid") or "",
  82. self:redis_get_key_info("udid") or "",
  83. self:redis_get_key_info("ip") or ""
  84. )
  85. return code.OK
  86. end
  87. -- 更新自己邀请码
  88. function root:itf_update_share_code(role, msg)
  89. local shareCode = msg.shareCode
  90. if is_empty(shareCode) then
  91. shareCode = util_global:gen_share_code()
  92. end
  93. if not util_global:is_sharecode_active(shareCode) then
  94. -- 邀请码已存在
  95. return code.SHARE_CODE.EXIST
  96. end
  97. self:redis_update_key_info("shareCode", shareCode)
  98. return code.OK
  99. end
  100. -- 更新steam交易链接
  101. function root:itf_update_steam_link(role, msg)
  102. local link = msg.link
  103. local vcode = msg.vcode
  104. if is_empty(link) or is_empty(vcode) then
  105. return code.PARAMTER_ERROR
  106. end
  107. local errcode, _vcode = playerData:get_verify_code(self.uid)
  108. if code.is_not_ok(errcode) then
  109. return errcode
  110. end
  111. if vcode ~= _vcode then
  112. return code.VERIFY_CODE.NOT_MATCH
  113. end
  114. self:redis_update_key_info("steamLink", link)
  115. return code.OK
  116. end
  117. -- 更新头像
  118. function root:itf_update_icon(role, msg)
  119. local icon = msg.icon
  120. if is_empty(icon) then
  121. return code.PARAMTER_ERROR
  122. end
  123. self:redis_update_key_info("headUrl", icon)
  124. return code.OK
  125. end
  126. -- 更新昵称
  127. function root:itf_update_nickname(role, msg)
  128. local nickname = msg.nickname
  129. if is_empty(nickname) then
  130. return code.PARAMTER_ERROR
  131. end
  132. -- 检查敏感词
  133. if util_3rd:is_sensitive(nickname) then
  134. return code.USR.INCLUDE_SENSITIVE
  135. end
  136. self:redis_update_key_info("nickname", nickname)
  137. return code.OK
  138. end
  139. -- 更新密码
  140. function root:itf_update_password(role, msg)
  141. local oldPassword = msg.oldPassword
  142. local newPassword = msg.newPassword
  143. if is_empty(oldPassword) or is_empty(newPassword) then
  144. return code.PARAMTER_ERROR
  145. end
  146. local password = self:redis_get_key_info("password")
  147. if oldPassword ~= password then
  148. return code.USR.PASSWORD_NOT_MATCH
  149. end
  150. self:redis_update_key_info("password", newPassword)
  151. return code.OK
  152. end
  153. -- 注销
  154. function root:itf_cancel_account(role, msg)
  155. return code.OK
  156. end
  157. -- 实名认证 - 更新信息
  158. function root:itf_identity(role, msg)
  159. return code.OK
  160. end
  161. return root