user.lua 4.7 KB

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