local code = require("code") local util_player = require("utils.util_player") local util_global = require("utils.util_global") local util_3rd = require("utils.util_3rd") local serverLogUtil = require("utils.serverLogUtil") local playerData = require("data.player") local userData = require("data.user") local root = class("user", require("base.baseModule")) function root:ctor(uid) root.super.ctor(self, uid, "user", "uid", true) self.uid = uid end function root:mysql_get_init_columns() return { uid = "int(11) unsigned NOT NULL", nickname = "varchar(50)", password = "varchar(45) DEFAULT NULL", uuid = "varchar(200) DEFAULT NULL", udid = "varchar(200) DEFAULT NULL", channel = "int(11) DEFAULT NULL", device = "varchar(45) DEFAULT NULL", loginTime = "int(11) DEFAULT 0", sysVer = "varchar(1024) DEFAULT NULL", version = "varchar(45) DEFAULT NULL", appVersion = "varchar(45) DEFAULT NULL", deviceId = "varchar(200) DEFAULT NULL", headUrl = "varchar(500) DEFAULT NULL", sex = "int(11) DEFAULT NULL", token = "varchar(255)", lastLoginTime = "int(11) DEFAULT 0", logoutTime = "int(11) DEFAULT 0", registerTime = "int(11) DEFAULT 0 COMMENT '注册时间'", registerVersion = "varchar(45) DEFAULT NULL COMMENT '注册版本'", ip = "varchar(45) DEFAULT NULL COMMENT 'IP'", status = "int(11) DEFAULT 0 COMMENT '账号状态 0:正常 1:封号 2:注销'", phone = "varchar(45) DEFAULT NULL COMMENT '绑定手机号'", bandShareCode = "varchar(45) DEFAULT NULL COMMENT '绑定推广码'", shareCode = "varchar(45) DEFAULT NULL COMMENT '我的推广码'", steamLink = "varchar(45) DEFAULT NULL COMMENT 'steam交易链接'" } end ---------------------------------------- -- 接口 ---------------------------------------- -- 获取自己的信息 function root:itf_get_info(role, msg) local info = util_player:get_player_info(self.uid) return code.OK, {playerInfo = info} end -- 获取验证码 function root:itf_get_verify_code(role, msg) local vcode = playerData:update_verify_code(self.uid) local ret = {} if IS_TEST then ret.vcode = vcode else -- 发短信 end return code.OK, ret end -- 更新主播邀请码 function root:itf_update_band_share_code(role, msg) local shareCode = msg.shareCode if is_empty(shareCode) then return code.PARAMTER_ERROR end if not util_global:is_sharecode_active(shareCode) then -- 邀请码不存在 return code.SHARE_CODE.NOT_FOUND end userData:band_share_code(self.uid, shareCode) -- 再次输出玩家登录埋点,方便后台捕捉数据 serverLogUtil.logLogin( self.uid, shareCode, self:redis_get_key_info("channel") or "", self:redis_get_key_info("version") or "", self:redis_get_key_info("sysVer") or "", "", "", self:redis_get_key_info("uuid") or "", self:redis_get_key_info("udid") or "", self:redis_get_key_info("ip") or "" ) return code.OK end -- 更新自己邀请码 function root:itf_update_share_code(role, msg) local shareCode = msg.shareCode if is_empty(shareCode) then shareCode = util_global:gen_share_code() end if not util_global:is_sharecode_active(shareCode) then -- 邀请码已存在 return code.SHARE_CODE.EXIST end self:redis_update_key_info("shareCode", shareCode) return code.OK end -- 更新steam交易链接 function root:itf_update_steam_link(role, msg) local link = msg.link local vcode = msg.vcode if is_empty(link) or is_empty(vcode) then return code.PARAMTER_ERROR end local errcode, _vcode = playerData:get_verify_code(self.uid) if code.is_not_ok(errcode) then return errcode end if vcode ~= _vcode then return code.VERIFY_CODE.NOT_MATCH end self:redis_update_key_info("steamLink", link) return code.OK end -- 更新头像 function root:itf_update_icon(role, msg) local icon = msg.icon if is_empty(icon) then return code.PARAMTER_ERROR end self:redis_update_key_info("headUrl", icon) return code.OK end -- 更新昵称 function root:itf_update_nickname(role, msg) local nickname = msg.nickname if is_empty(nickname) then return code.PARAMTER_ERROR end -- 检查敏感词 if util_3rd:is_sensitive(nickname) then return code.USR.INCLUDE_SENSITIVE end self:redis_update_key_info("nickname", nickname) return code.OK end -- 更新密码 function root:itf_update_password(role, msg) local oldPassword = msg.oldPassword local newPassword = msg.newPassword if is_empty(oldPassword) or is_empty(newPassword) then return code.PARAMTER_ERROR end local password = self:redis_get_key_info("password") if oldPassword ~= password then return code.USR.PASSWORD_NOT_MATCH end self:redis_update_key_info("password", newPassword) return code.OK end -- 注销 function root:itf_cancel_account(role, msg) return code.OK end -- 实名认证 - 更新信息 function root:itf_identity(role, msg) return code.OK end return root