error('请先登录'); } //检查用户是否冻结 $userInfo = model('Members')->field('id,mobile,email')->where([ 'username' => Session::get('username'), 'flag' => 0, ])->find(); if (empty($userInfo)) { $this->error("用户冻结"); } $this->userInfo = $userInfo; $this->username = Session::get('username'); $this->game_id = Session::get('game_id'); $this->sub_username = Session::get('sub_username'); } public function index() { //todo 获取用户平台币 $isVisitor = ''; $membersTwoModel = new MembersTwo(); $membersTwoInfo = $membersTwoModel->where(['userid' => $this->userInfo['id']])->find(); $userInfo = (new Members())->where(['id' => $this->userInfo['id']])->field('mobile,email,channel_id')->find(); $gameInfo = (new Game())->where(['id' => $this->game_id])->find(); // echo $gameInfo['game_auth_type']."---game_auth_type----".$gameInfo['game_bizid']."---game_bizid----
"; if ($gameInfo['game_auth_type'] == 1 || $gameInfo['game_auth_type'] == 2) { //中宣部实名认证 $gameAccountInfo = model('Subaccount')->where(['game_id' => $this->game_id, 'member_id' => $this->userInfo['id']])->find(); if ($gameAccountInfo) { if ($gameAccountInfo['auth_status'] == 3) { $membersTwoInfo['realname'] = trim($gameAccountInfo['real_name']); $membersTwoInfo['idcard'] = trim($gameAccountInfo['idcard_num']); } else if ($gameAccountInfo['auth_status'] == 1) { vendor('authSdk.Authentication', '.class.php'); $auth = new \Authentication(); $result = $auth->query(trim($gameInfo['game_bizid']), $gameAccountInfo['member_id'] . '-' . $gameAccountInfo['id']); if ($result['errcode'] == 0) { $resultData = $result['data']['result']; if ($resultData['status'] == 0 && isset($resultData['pi']) && trim($resultData['pi']) <> '') { $updAccountData = array(); $updAccountData['auth_type'] = 1; $updAccountData['auth_status'] = 3; $updAccountData['auth_pi'] = $resultData['pi']; $updAccountData['last_query_time'] = time(); $updResult = model('Subaccount')->where(['id' => $gameAccountInfo['id']])->update($updAccountData); if ($updResult) { $membersTwoInfo['realname'] = trim($gameAccountInfo['real_name']); $membersTwoInfo['idcard'] = trim($gameAccountInfo['idcard_num']); } else { $isVisitor = '(认证中)'; } } else if ($resultData['status'] == 1) { $updAccountData = array(); $updAccountData['auth_type'] = 1; $updAccountData['last_query_time'] = time(); $updResult = model('Subaccount')->where(['id' => $gameAccountInfo['id']])->update($updAccountData); $membersTwoInfo['realname'] = trim($gameAccountInfo['real_name']); $membersTwoInfo['idcard'] = trim($gameAccountInfo['idcard_num']); $isVisitor = '(认证中)'; } else if ($resultData['status'] == 2) { $updAccountData = array(); $updAccountData['auth_type'] = 1; $updAccountData['auth_status'] = 2; $updAccountData['last_query_time'] = time(); $updResult = model('Subaccount')->where(['id' => $gameAccountInfo['id']])->update($updAccountData); $isVisitor = '(游客)'; } } } else { if (empty($userInfo['mobile']) && empty($userInfo['email'])) { $isVisitor = '(游客)'; } } } else { if (empty($userInfo['mobile']) && empty($userInfo['email'])) { $isVisitor = '(游客)'; } } } else { //平台实名认证 if ((-1 == $membersTwoInfo['realname']) && (-1 == $membersTwoInfo['idcard'])) { if (empty($userInfo['mobile']) && empty($userInfo['email'])) { $isVisitor = '(游客)'; } } } $this->assign('username', $this->username); $this->assign('isVisitor', $isVisitor); $this->assign('gameInfo', $gameInfo); return $this->fetch(); } public function logout() { Session::clear(); } /** * 绑定中心 * @return mixed * @throws \app\api\controller\HttpResponseException */ public function account() { $userInfo = (new Members())->where(['id' => $this->userInfo['id']])->field('mobile,email,channel_id')->find(); $gameInfo = (new Game())->where(['id' => $this->game_id])->find(); $share_url = ''; if (in_array($this->game_id, [223,224])) { $short_link = db('nw_promotion_short_link')->where(['game_id' => $this->game_id, 'channel_id' => $userInfo['channel_id'], 'package_type' => 0])->value('short_link'); if (!empty($short_link)) { $share_url = API_DOMAIN . '/' . $short_link; } } $this->assign('gameInfo', $gameInfo); $this->assign('share_url', $share_url); $this->assign('mobile', mobileObfuscation($this->userInfo['mobile'])); $this->assign('email', mailObfuscation($this->userInfo['email'])); $this->assign('username', $this->username); return $this->fetch(); } /** * 返回json数据到H5 * @param array $data * @param int $code * @param string $msg * @return \think\response\Json */ public function json($data = [], $code = 0, $msg = '') { return json(['data' => $data, 'code' => $code, 'msg' => $msg]); } /** * todo 解绑避免手机邮箱都解绑的判断防止无法找回密码 */ public function checkBind() { } /** * 修改密码 */ public function editPassword() { if ($this->request->isPost()) { $data = $this->request->post(); //1.验证数据合法性 todo 密码格式加以验证 if (true !== ($res = $this->validate($data, [ 'old_password|旧密码' => 'require|isEmpty', 'new_password|新密码' => 'require|isEmpty|length:6,15', 're_password|重复新密码' => 'require|isEmpty|length:6,15|confirm:re_password', ]))) { return $this->json('', 0, $res); } $this->memberModel = new Members(); //2.验证旧密码是否匹配 $memberInfo = $this->memberModel->field('id,password,username,mobile')->where([ 'username' => $this->username, 'flag' => 0, ])->find(); $old_password = auth_code($data['old_password'], 'ENCODE', Env::get('auth_key')); if ($old_password !== $memberInfo['password']) { return $this->json([], 0, '旧密码错误'); } //3.更新新密码 $password = auth_code($data['new_password'], 'ENCODE', Env::get('auth_key')); if ($this->memberModel->update(['password' => $password], ['id' => $memberInfo['id']])) { // 插入玩家历史记录 Db::table('cy_member_history')->insert([ 'userid' => $memberInfo['id'], 'password' => $password, 'mobile' => $memberInfo['mobile'], 'ip' => request()->ip(), 'create_time' => time(), ]); // $memberLogic = new MemberLogic; // //同步用户信息到账户中心 // $openid = $memberLogic->syncMember($memberInfo['username'], $data['password'], $memberInfo['mobile'], time()); return $this->json('', 1, '密码重置成功'); } } return $this->fetch('edit_password'); } }