| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190 |
- <?php
- /**
- * api登录控制器
- */
- namespace app\api\controller\v1;
- use app\api\controller\Api;
- use app\common\library\IpLimit;
- use app\common\logic\Member;
- use app\common\model\Members;
- use app\common\model\Logininfo;
- use app\common\model\Logoutinfo;
- use app\common\model\Channel;
- use app\common\model\Subaccount;
- use app\common\library\JwtToken;
- use app\common\library\Sms;
- use app\common\service\FkStrategiesService;
- use app\service\CommonService;
- use app\service\TiktokService;
- use think\Db;
- use think\Cache;
- use app\common\logic\Member as MemberLogic;
- use app\common\logic\Coin;
- use app\common\model\Setting;
- use app\api\library\MemberDevice;
- use think\Env;
- use think\Exception;
- use think\Request;
- class Login extends Api
- {
- protected $membersModel;
- protected $noNeedLogin = ['index', 'loginsms', 'loginqq', 'loginweibo', 'third'];
- public function _initialize()
- {
- parent::_initialize();
- $this->membersModel = new Members();
- }
- /**
- * 普通用户登录处理
- */
- public function index()
- {
- // if (temporary()) {
- // $this->jsonResult('', 0, '禁止登录');
- // }
- $username = $this->input('username'); //用户名
- $password = $this->input('password'); //密码
- $imeil = trim($this->input('imeil')); //手机imeil码
- $gameid = $this->input('gameid'); //游戏ID
- $device = $this->input('device'); //设备
- $channelId = $this->input('channel_id'); //当前登录的渠道ID
- //海外游戏ip限制
- if (in_array($gameid, config('haiwai_game_ids'))) {
- $res = (new IpLimit())->validateIp(request()->ip(), $username);
- if ($res != 1) {
- $this->jsonResult('', -110, '国内用户禁止登录');
- }
- }
- if (empty($username)) {
- $this->jsonResult('', -100, '用户名不能为空');
- } elseif (empty($password)) {
- $this->jsonResult('', -100, '密码不能为空');
- }
- //游戏ID不能为空
- if (empty($gameid)) {
- $this->jsonResult('', -100, '游戏ID不能为空');
- }
- if (empty($device)) {
- $this->jsonResult('', -100, '没有注册设备来源');
- }
- if (empty($imeil)) {
- $this->jsonResult('', -100, '设备imeil异常');
- }
- if (empty($channelId)) {
- $this->jsonResult('', -100, '渠道不能为空');
- }
- //判断渠道
- $channelInfo = (new Channel)->where(['status' => 1, 'id' => $channelId])->find();
- if (!$channelInfo) {
- $this->jsonResult('', -120, '当前渠道不存在或已禁用!');
- } else if ($channelInfo['level'] <> 3) {
- $this->jsonResult('', -120, '非推广员渠道,不能进行推广,请联系客服');
- }
- if (!$game = model('Common/Game')->where(['id' => $gameid])->find()) {
- $this->jsonResult('', -120, '游戏信息不存在');
- }
- if ($game['cooperation_status'] == 3) {
- $this->jsonResult('', -120, '游戏已下架不存在');
- }
- if ($game['is_login'] == 1) {
- // 游戏登录白名单
- if(Db::name('cy_game_user_white')->where(['game_id' => $gameid, 'username' => $username])->count() == 0){
- $gameInfo = Db::table('cy_gameinfo')->where(['game_id' => $gameid])->field('ban_login_msg')->find();
- $ban_login_msg = '当前游戏禁止登录!';
- if(!empty($gameInfo['ban_login_msg'])){
- $ban_login_msg = $gameInfo['ban_login_msg'];
- }
- $this->jsonResult('', -120, $ban_login_msg);
- }
- }
- // 渠道禁止判断
- if (isFrozenOption($channelId, $gameid, 'member_login')) {
- $this->jsonResult('', -120, '您所在渠道已经被禁止登录此游戏!! ');
- }
- // 封禁仙剑安卓包的主播包登陆
- if (!in_array($username, ['zbgzzdaj', 'zbcobpyl'])) {
- if ($channelId == 100 && $gameid == 266) {
- $this->jsonResult('', -120, '您所在渠道已经被禁止登录此游戏!! ');
- }
- }
-
- //加密后密码
- $password = auth_code($password, "ENCODE", Env::get($this->authKey));
- //用户信息
- $userinfo = $this->membersModel->where(['username' => $username, 'password' => $password])->find();
- if (empty($userinfo)) {
- $this->jsonResult('', -120, '账号不存在或者密码不正确');
- }
- // 账号是否被冻结
- if (1 == $userinfo['flag']) {
- $this->jsonResult('', -120, '您的账号已被冻结,请联系客服QQ:' . CUSTOMER_SERVICE_QQ);
- }
- // 子账号是否被冻结
- $subaccountInfo = model('Subaccount')->where(['member_id' => $userinfo['id'], 'game_id' => $gameid])->find();
- if (1 == $subaccountInfo['flag']) {
- $this->jsonResult('', -120, '您的子账号已被冻结,请联系客服QQ:' . CUSTOMER_SERVICE_QQ);
- }
- //elseif($userinfo['channel_id'] != $channelId){
- // $this->jsonResult("",0,"登录渠道号和注册渠道不一致,无法登录");
- // }
- // $channelId = $userinfo['channel_id'];
- // ## 风控策略
- $fkData = [
- // 'event_type' => 'login', // username
- 'username' => $username, // username
- 'ip' => request()->ip(), // ip
- 'imei' => $imeil, // imei
- 'mobile' => $userinfo['mobile'], // 注册手机号
- ];
- $result = (new FkStrategiesService())->processEvent($fkData); // 登录
- if ($result['status']) {
- $this->jsonResult('', -120, '您的账号已被风控冻结,请联系客服QQ:' . CUSTOMER_SERVICE_QQ);
- }
- //用户登录公共部分处理
- $this->loginProcess($userinfo, $gameid, $imeil, $device, $channelId);
- exit;
- }
- /**
- * 手机验证码登录
- */
- /*
- public function loginSms()
- {
- $username = $this->input('username'); //用户名
- $code = $this->input('sms_code'); //短信验证码
- $imeil = $this->input('imeil'); //手机imeil码
- $gameid = $this->input('gameid'); //游戏ID
- $device = $this->input('device'); //设备
- if (empty($username)) {
- $this->jsonResult('',0,'用户名不能为空');
- }
- //游戏ID不能为空
- if (empty($gameid)) {
- $this->jsonResult('',0,'游戏ID不能为空');
- }
- if (empty($device)) {
- $this->jsonResult('',0,'没有注册设备来源');
- }
- if (empty($imeil)) {
- $this->jsonResult('',0,'设备imeil异常');
- }
- if($code==''){
- $this->jsonResult('',0,'短信验证码不能为空');
- }
- $sms = new Sms;
- $codeResult = $sms->checkCode($username, $code);
- if(!$codeResult['status']) {
- $this->jsonResult('', 0, $codeResult['msg']);
- }
- //用户信息
- $userinfo = $this->membersModel->where(['username'=>$username])->find();
- if(empty($userinfo))
- {
- $this->jsonResult('',0,'账号不存在');
- }
- // 判断一下当前账号是否被冻结
- elseif(1 == $userinfo['flag']) {
- $this->jsonResult('',0,'您的账号已被冻结,请联系客服QQ:'.CUSTOMER_SERVICE_QQ);
- }
- //用户登录公共部分处理
- $this->loginProcess($userinfo, $gameid, $imeil, $device);
- exit;
- }*/
- /**
- * QQ第三方登录
- */
- /*
- public function loginQq()
- {
- $access_token = $this->input('access_token'); //Access Token
- $imeil = $this->input('imeil'); //手机imeil码
- $gameid = $this->input('gameid'); //游戏ID
- $device = $this->input('device'); //设备
- if (empty($access_token)) {
- $this->jsonResult('',0,'access_token码不能空。');
- }
- //游戏ID不能为空
- if (empty($gameid)) {
- $this->jsonResult('',0,'游戏ID不能为空');
- }
- if (empty($device)) {
- $this->jsonResult('',0,'没有注册设备来源');
- }
- $url="https://graph.qq.com/oauth2.0/me?access_token={$access_token}&unionid=1";
- $unioid_content = getCurlContent($url);
- $subStr = substr($unioid_content, strpos($unioid_content, "{"));
- $subStr = strstr($subStr, "}", true) . "}";
- $unioidInfo = json_decode($subStr, true);
- if(!isset($unioidInfo['openid']) || !isset($unioidInfo['unionid'])) {
- $this->jsonResult('',0,'获取QQ的用户信息失败,请检查Access Token是否有效');
- }
- else{
- $request_url="https://graph.qq.com/user/get_user_info?oauth_consumer_key=".QQ_APPID."&access_token={$access_token}&openid={$unioidInfo['openid']}";
- $request_content = http_get($request_url);
- $qqInfo = json_decode($request_content, true);
- if(empty($qqInfo) || $qqInfo['ret']!=0)
- {
- $this->jsonResult('',0,'获取QQ的用户信息失败');
- }
- else{
- $qqInfo['unionid'] = $unioidInfo['unionid'];
- $qqInfo['qq_openid']= $unioidInfo['openid'];
- $qqModel = new MembersQq;
- $membersQqInfo = $qqModel->where(['unionid'=>$qqInfo['unionid']])->find();
- //注册
- if(empty($membersQqInfo))
- {
- }
- //登录
- else{
- //用户信息
- $userinfo = $this->membersModel->where(['id'=>$membersQqInfo['userid']])->find();
- //用户登录公共部分处理
- $this->loginProcess($userinfo, $gameid, $imeil, $device);
- }
- }
- }
- }*/
- /**
- * 判断是否节假日
- */
- public function getHoliday($date)
- {
- try {
- $url = "https://tool.bitefu.net/jiari/?d=$date&back=json";
- $result = file_get_contents($url);
- $result = json_decode($result, true);
- if (isset($result[$date]) && $result[$date] == 2) {
- return true;
- } else {
- return false;
- }
- } catch (\Exception $e) {
- return false;
- }
- }
- /**
- * 用户登录公共部分处理
- *
- * @param $userinfo : array 用户信息数组(member表)
- * @param $gameid : int 游戏ID
- * @param $imeil : string 手机imeil码
- * @param $device : int 注册设备来源
- * @param $channelId : int 当前登录的渠道ID
- *
- */
- private function loginProcess($userinfo, $gameid, $imeil, $device, $channelId)
- {
- //判断游戏是否冻结IP或者IMEI
- $LoginIp = request()->ip();
- $BannedInfo = model('GameBanned')->where(['game_id' => array('in', [0, $gameid]), 'banned_type' => 'ip', 'banned_device' => $LoginIp])->find();
- if (!empty($BannedInfo)) {
- log_message(json_encode([$userinfo, $gameid, $imeil, $device, $channelId, $LoginIp]), 'log', LOG_PATH . 'login/');
- $template = '【封禁提示】IP禁止登录:账号:' . $userinfo['username'] . ' ip:' . $LoginIp;
- curlDD($template, Env::get('dingtalk.notice_weelfar_url'), true);
- $this->jsonResult('', 0, '您的IP已被禁止登录此游戏! ');
- }
- if ($imeil) {
- $BannedInfo = model('GameBanned')->where(['game_id' => array('in', [0, $gameid]), 'banned_type' => 'imeil', 'banned_device' => $imeil])->find();
- if (!empty($BannedInfo)) {
- log_message(json_encode([$userinfo, $gameid, $imeil, $device, $channelId]), 'log', LOG_PATH . 'login/');
- $template = '【封禁提示】设备登录:账号:' .$userinfo['username'].' imeil:'.$imeil;
- curlDD($template, Env::get('dingtalk.notice_weelfar_url'), true);
- $this->jsonResult('', 0, '该设备已被禁止登录此游戏! ');
- }
- }
- // 渠道禁止判断
- if (isFrozenOption($channelId, $gameid, 'member_login')) {
- $this->jsonResult('', 0, '您所在渠道已经被禁止登录此游戏! ');
- }
- //游戏防沉迷限制
- $restrictInfo = model('GameRestrict')->where(['game_id' => $gameid, 'restrict_type' => 'preventhook'])->find();
- if ($restrictInfo) {
- $isPreventHook = intval($restrictInfo['restrict_status']);
- } else {
- $settingModel = new Setting;
- $isPreventHook = intval($settingModel::getSetting('CHILD_LIMIT'));
- }
- $subaccountModel = model('Subaccount');
- $offline_time = null;
- $gameAccountInfo = $subaccountModel->where(['game_id' => $gameid, 'member_id' => $userinfo['id']])->find();
- if ($isPreventHook == 2) {
- // vendor('authSdk.Authentication', '.class.php');
- // $auth = new \Authentication();
- // 已实名认证用户做防沉迷判断
- $membersTwoInfo = model('MembersTwo')->where(['userid' => $userinfo['id']])->find();
- $gameInfo = model('Game')->where(['id' => $gameid])->find();
- if ($gameInfo['game_auth_type'] == 1) { //中宣部实名认证
- // // 判断其他子账户是否已实名,是的话,使用其他账户的实名信息。
- // if(!$gameAccountInfo || !$gameAccountInfo['idcard_num']){
- // $shimingInfo = $subaccountModel->where(['member_id' => $userinfo['id'], 'auth_type' => 1, 'auth_status' => 3])->find();
- // if($shimingInfo){
- // $zxResult = $auth->check(trim($gameInfo['game_bizid']), $gameAccountInfo['member_id'] . '-' . $gameAccountInfo['id'], $shimingInfo['real_name'], $shimingInfo['idcard_num']);
- // if($zxResult['errcode'] == 0 && isset($zxResult['data']['result']['pi'])){
- // if(!$gameAccountInfo){
- // //生成子账号记录
- // $gameAccountInfo = $subaccountModel->create([
- // 'auth_type' => 1,
- // 'real_name' => $shimingInfo['real_name'],
- // 'idcard_num' => $shimingInfo['idcard_num'],
- // 'auth_status' => 3,
- // 'auth_pi' => $zxResult['data']['result']['pi'],
- // 'member_id' => $userinfo['id'],
- // 'game_id' => $gameid,
- // 'createtime' => NOW_TIMESTAMP,
- // ]);
- // }else{
- // $gameAccountInfo->auth_type = 1;
- // $gameAccountInfo->real_name = $shimingInfo['real_name'];
- // $gameAccountInfo->idcard_num = $shimingInfo['idcard_num'];
- // $gameAccountInfo->auth_status = 3;
- // $gameAccountInfo->auth_pi = $zxResult['data']['result']['pi'];
- // $gameAccountInfo->last_auth_time = time();
- // $gameAccountInfo->save();
- // }
- //
- // // 插入玩家历史记录
- // Db::table('cy_member_history')->insert([
- // 'userid' => $userinfo['id'],
- // 'password' => $shimingInfo['real_name'] . ' ' . $shimingInfo['idcard_num'] . ' ' . $shimingInfo['sub_username'],
- // 'mobile' => '',
- // 'ip' => request()->ip(),
- // 'create_time' => time(),
- // ]);
- // }
- // }
- // }
- 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) {
- $membersTwoInfo['realname'] = '';
- $membersTwoInfo['idcard'] = '';
- } else {
- $membersTwoInfo['realname'] = '';
- $membersTwoInfo['idcard'] = '';
- }
- } else {
- $membersTwoInfo['realname'] = '';
- $membersTwoInfo['idcard'] = '';
- }
- }
- if ($membersTwoInfo && !empty($membersTwoInfo['realname']) && !empty($membersTwoInfo['idcard']) && $membersTwoInfo['realname'] <> -1 && $membersTwoInfo['idcard'] <> -1) {
- if (!isMeetAgeByIDCard($membersTwoInfo['idcard'], 18, 120)) {
- // 节假日
- $holiday = $this->getHoliday(date("Ymd"));
- if ($holiday) {
- if (!(date("H:i") > "20:00" && date("H:i") < "21:00")) {
- $this->jsonResult('', 0, '未成年用户,仅可在周五、周六、周日和法定节假日每日20时至21时进行游戏,其他时间均无法进行游戏 ');
- } else {
- $offline_time = strtotime(date("Y-m-d") . " 21:00");
- }
- } else {
- $date = date("w");
- if (in_array($date, [0, 5, 6])) {
- if (!(date("H:i") > "20:00" && date("H:i") < "21:00")) {
- $this->jsonResult('', 0, '未成年用户,仅可在周五、周六、周日和法定节假日每日20时至21时进行游戏,其他时间均无法进行游戏 ');
- } else {
- $offline_time = strtotime(date("Y-m-d") . " 21:00");
- }
- } else {
- $this->jsonResult('', 0, '未成年用户,仅可在周五、周六、周日和法定节假日每日20时至21时进行游戏,其他时间均无法进行游戏 ');
- }
- }
- }
- }
- }
- $logininfoModel = new Logininfo();
- $member_channel_game_rel = model('MemberChannelGame');
- $nowTime = NOW_TIMESTAMP;
- /**
- * 所属渠道:
- * 1. 根据注册的渠道,注册渠道没有则根据客户端传递的;
- */
- $bandChannelId = $channelId; // 默认客户端传递的渠道
- if(!empty($gameAccountInfo['channel_id'])){
- $bandChannelId = $gameAccountInfo['channel_id'];
- }
- /**
- * 注册子账户以及所属渠道绑定
- * 1. 查询对应 安卓/IOS/H5 其他端游戏绑定的渠道号;
- */
- $getBandGameId = getBandGameId($gameid);
- if($getBandGameId){
- $getBandChannelId = Db::table('cy_member_channel_game_rel')->where(['member_id' => $userinfo['id'], 'game_id' => ['in', $getBandGameId]])->order('mcgr_id asc')->value('channel_id');
- if (!empty($getBandChannelId)) {
- $bandChannelId = $getBandChannelId;
- }
- }
- // 启动事务
- Db::startTrans();
- try {
- // 用户&游戏 绑定数据
- $info = $member_channel_game_rel->where(['member_id' => $userinfo['id'], 'game_id' => $gameid])->find();
- $userId = $userinfo['id'];
- $gameId = $gameid;
- // 首次登录-游戏渠道注册
- if (empty($info)) {
- $info = $member_channel_game_rel->create([
- 'member_id' => $userId,
- 'channel_id' => $bandChannelId,
- 'game_id' => $gameId,
- 'mcgr_createtime' => NOW_TIMESTAMP,
- 'update_time' => NOW_TIMESTAMP,
- 'mcgr_imeil' => $imeil,
- 'mcgr_ip' => request()->ip()
- ]);
- // 插入玩家游戏渠道绑定记录
- $channelName = model('Channel')->where(['id' => $bandChannelId])->value('name');
- $gameInfo = model('Common/Game')->where(['id' => $gameId])->field('id,name,type')->find();
- Db::table('cy_member_history')->insert([
- 'userid' => $userId,
- 'channel' => $gameInfo['name'] . "," . $channelName,
- 'ip' => request()->ip(),
- 'create_time' => time()
- ]);
- // 用于首充发放 (用于首次登录)
- // (new Coin())->autoSend($gameId, $bandChannelId, $userId);
- } else {
- // 更新游戏最后登录时间
- $member_channel_game_rel->where(['member_id' => $userId, 'game_id' => $gameId])->update(['update_time' => time()]);
- }
- //为了兼容旧SDK保存memkey,新SDK没有用到这个值,旧SDK关闭后可以删除该代码
- // if (!trim($userinfo['nickname'])) {
- // $userNickName = random(3) . $userinfo['id'];
- // $this->membersModel->where(['id' => $userinfo['id']])->update(['memkey' => md5($userinfo['username'] . $userinfo['password'] . rand(0, 1000)), 'login_time' => $nowTime, 'nickname' => $userNickName]);
- // } else {
- // $this->membersModel->where(['id' => $userinfo['id']])->update(['memkey' => md5($userinfo['username'] . $userinfo['password'] . rand(0, 1000)), 'login_time' => $nowTime]);
- // }
- /**
- * 子账户信息
- * 1. 有则根据查询;无则创建子账户;
- * 2. 关联游戏使用主账户的ID+正式/测试的标识;
- */
- $sub_username = '';
- if(!empty($gameAccountInfo['sub_username'])){
- $sub_username = $gameAccountInfo['sub_username'];
- $subData = ['update_time' => $nowTime, 'last_imeil' => $imeil];
- $subaccountModel->save($subData, ['member_id' => $userinfo['id'], 'game_id' => $gameid ]);
- }else {
- // 指定的几款游戏 不需要注册,账号从cy_members 取
- // $settingModel = new Setting();
- // $accountArr = explode(',', $settingModel->getSetting('ANDROID_IOS_ACCOUNT'));
- //
- // if (in_array($gameid, $accountArr)) {
- // $sub_username = $userinfo['username'];
- // } elseif ($gameid > 220) {
- // $sub_username = $userinfo['id'];
- // } else {
- // //旧SDK的玩家,绑定关系表有记录时
- // if (!empty($info)) {
- // $sub_username = $userinfo['username'];
- // } //旧SDK的channel_id=0或者默认渠道的玩家
- // elseif ($logininfoModel->where(['userid' => $userinfo['id'], 'gameid' => $gameid])->find()) {
- // $sub_username = $userinfo['username'];
- // } else {
- // $sub_username = strtolower(random(20));
- // //保证子账号名唯一性
- // while ($subaccountModel->field('id')->where(['sub_username' => $sub_username])->find()) {
- // $sub_username = strtolower(random(20));
- // }
- // }
- // }
- // $sub_username .= '_'.$gameid.Env::get('sdk_mark_type');
- $sub_username = $userinfo['id'].'_'.APP_STATUS;
- // 正式服指定游戏的userid不能有英文
- if(in_array($gameid, [652, 653, 654, 655])){
- $sub_username = $userinfo['id'];
- }
- //生成子账号记录
- if (isset($gameAccountInfo['id']) && isset($gameAccountInfo['idcard_num'])) {
- $subData = [
- 'sub_username' => $sub_username,
- 'channel_id' => $bandChannelId,
- 'update_time' => $nowTime,
- 'last_imeil' => $imeil,
- ];
- $subaccountModel->save($subData, [
- 'member_id' => $userinfo['id'],
- 'game_id' => $gameid,
- ]);
- } else {
- $gameAccountInfo = $subaccountModel->create([
- 'member_id' => $userinfo['id'],
- 'game_id' => $gameid,
- 'channel_id' => $bandChannelId,
- 'sub_username' => $sub_username,
- 'create_time' => $nowTime,
- 'update_time' => $nowTime,
- 'last_imeil' => $imeil,
- ]);
- }
- }
- // 更新常用设备列表
- try {
- $memberDevice = new MemberDevice();
- $memberDevice->addDevice($userinfo['id'], $gameid, $imeil, $device, false, false);
- } catch (\Exception $e) {
- // 设备记录更新失败不影响登录流程
- trace('设备记录更新失败:' . $e->getMessage(), 'error');
- }
- $logData['sub_id'] = $gameAccountInfo['id'];
- $logData['userid'] = $userinfo['id'];
- $logData['gameid'] = $gameid;
- $logData['imeil'] = $imeil;
- $logData['device'] = $device;
- $logData['reg_time'] = $userinfo['reg_time'];
- $logData['fromflag'] = $userinfo['fromflag'];
- $logData['channel_id'] = $bandChannelId;
- $logData['login_time'] = $nowTime;
- $logData['ip'] = request()->ip();
- //登录日志
- $logininfoModel->limitInsert($logData);
- $platform = ($device == 3 ? 1 : 0);
- //收集设备信息
- $this->saveDevices($gameid, $imeil, $platform);
- $this->membersModel->save(['update_time' => $nowTime, 'login_time' => $nowTime], ['id' => $userinfo['id']]);
- // 提交事务
- Db::commit();
- } catch (\Exception $e) {
- // 回滚事务
- Db::rollback();
- $this->jsonResult('', 0, '登录失败:' . $e->getMessage());
- }
- // 查询出帐号在用户中心的openid,下面使用openid交互
- // $mgMemberInfo = Db::connect('db_config_resource_center')->table('mg_member')->field('mem_openid')->where(['mem_login_name'=>$userinfo['username'],'pl_id'=>2])->find();
- // $signStr = "username=".$mgMemberInfo['mem_openid']."&appkey=".$this->appInfo['appkey']."&logintime=".$nowTime;
- // $returnData['sign'] = md5($signStr);
- // $returnData['memkey'] = md5($mgMemberInfo['mem_openid'].$userinfo['password'].rand(0,1000)); //登录生成用户key
- // $returnData['login_time'] = $nowTime;
- // $returnData['openid'] = $mgMemberInfo['mem_openid'];
- //token的随机码
- $token_random = random(8);
- $token = auth_code($userinfo['id'] . '|' . $userinfo['username'] . '|' . $gameid . '|' . $sub_username . '|' . $token_random . '|sdk|v3', "ENCODE", Env::get($this->authKey));
- // $imeil 做为唯一登录标识
- Cache::store('redis')->set($token, $imeil, 60 * 60 * 24 * 15);
- // redis中玩家登录安全控制的随机码
- Cache::store('redis')->set('token|sdk|' . $userinfo['id'] . '|' . $gameid, $token_random, 60 * 60 * 24 * 15);
- //用户推广信息保存
- // setChannelId($userinfo['id'], $bandChannelId);
- $returnData['token'] = $token;
- $returnData['username'] = $userinfo['username']; //主账号名
- $returnData['sub_username'] = $sub_username; //子账号名
- $returnData['offline_time'] = $offline_time;
- // ## JWT:仅版本号大于 v3.6.6 的客户端返回 ##
- if (!empty($this->version) && version_compare($this->version, '3.6.8', '>')) {
- $jwtKey = trim((string) Env::get('jwt.jwt_key', ''));
- $jwtExpTime = (int) Env::get('jwt.exp_time', 0);
- $returnData['jwt_token'] = '';
- if ($jwtKey === '' || $jwtExpTime <= 0) {
- trace('JWT配置缺失或错误,请检查jwt.jwt_key和jwt.exp_time', 'error');
- } else {
- $jwtIssuedAt = time();
- $jwtUserData = [
- 'member_id' => $userinfo['id'],
- 'username' => $userinfo['username'],
- 'game_id' => $gameid,
- 'sub_id' => $gameAccountInfo['id'],
- 'channel_id' => $bandChannelId,
- 'iat' => $jwtIssuedAt,
- 'exp' => $jwtIssuedAt + $jwtExpTime,
- ];
- $returnData['jwt_token'] = JwtToken::encode($jwtUserData, $jwtKey);
- }
- }
- file_put_contents(RUNTIME_PATH . '/register.txt', var_export($returnData, true) . PHP_EOL, FILE_APPEND);
- if ($isPreventHook == 2) {
- // 已实名认证用户做防沉迷判断
- $membersTwoInfo = model('MembersTwo')->where(['userid' => $userinfo['id']])->find();
- $gameInfo = model('Game')->where(['id' => $gameid])->find();
- if ($gameInfo['game_auth_type'] == 1) { //中宣部实名认证
- $gameAccountInfo = model('Subaccount')->where(['game_id' => $gameid, 'member_id' => $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) {
- $membersTwoInfo['realname'] = '';
- $membersTwoInfo['idcard'] = '';
- } else {
- $membersTwoInfo['realname'] = '';
- $membersTwoInfo['idcard'] = '';
- }
- } else {
- $membersTwoInfo['realname'] = '';
- $membersTwoInfo['idcard'] = '';
- }
- vendor('authSdk.Authentication', '.class.php');
- $auth = new \Authentication();
- if (!$membersTwoInfo['realname'] || !$membersTwoInfo['idcard']) { //未实名
- $result = $auth->loginout(trim($gameInfo['game_bizid']), $token, 1, 2, $imeil);
- if ($result['errcode'] == 0) {}
- } else { //已实名
- $result = $auth->loginout(trim($gameInfo['game_bizid']), $token, 1, 0, $imeil, $gameAccountInfo['auth_pi']);
- if ($result['errcode'] == 0) {}
- }
- }
- }
- //
- // try {
- // //2022-10-13 抖音推送
- // $extend = [
- // 'Oaid' => '',
- // 'Idfa' => '',
- // 'Androidid' => '',
- // 'Imei' => '',
- // 'PayAmount' => 0,
- // 'Ip' => request()->ip()
- // ];
- // $tiktokService = new TiktokService();
- // $tiktokService->push('tiktok.retention_days', $userinfo['id'], $gameid, $bandChannelId, $extend);
- // } catch (Exception $e) {
- // $template = '抖音登录推送异常 userid' . $userinfo['id'] . $e->getMessage();
- // $ddurl = Env::get('warning_url');
- // $result = curlDD($template, $ddurl, true);
- // }
- $this->jsonResultUnescape($returnData, 1, '登录成功');
- }
- /**
- * 退出登录
- *
- */
- public function logout()
- {
- $logoutModel = new Logoutinfo();
- $username = $this->input('username'); //用户名
- $imeil = $this->input('imeil'); //手机imeil码
- $gameid = $this->input('gameid'); //游戏ID
- $device = $this->input('device'); //设备
- if (empty($username)) {
- $this->jsonResult('', 0, '用户名不能为空');
- }
- //游戏ID不能为空
- if (empty($gameid)) {
- $this->jsonResult('', 0, '游戏ID不能为空');
- }
- if (empty($device)) {
- $this->jsonResult('', 0, '没有注册设备来源');
- }
- $data = [
- 'username' => $username,
- 'gameid' => $gameid,
- 'imeil' => $imeil,
- 'device' => $device,
- 'logout_time' => time()
- ];
- $logoutModel->insert($data);
- //用户信息
- $userinfo = $this->membersModel->field('id,reg_time,fromflag,flag,nickname')->where(['id' => $this->input('userid')])->find();
- if (empty($userinfo)) {
- $this->jsonResult('', 0, '账号不存在');
- }
- session(null);
- Cache::store('redis')->rm($this->input('token'));
- Cache::store('redis')->rm('token|sdk|' . $this->input['userid'] . '|' . $gameid);
- //游戏防沉迷限制
- $restrictInfo = model('GameRestrict')->where(['game_id' => $gameid, 'restrict_type' => 'preventhook'])->find();
- if ($restrictInfo) {
- $isPreventHook = intval($restrictInfo['restrict_status']);
- } else {
- $settingModel = new Setting;
- $isPreventHook = intval($settingModel::getSetting('CHILD_LIMIT'));
- }
- if ($isPreventHook == 2) {
- // 已实名认证用户做防沉迷判断
- $membersTwoInfo = model('MembersTwo')->where(['userid' => $userinfo['id']])->find();
- $gameInfo = model('Game')->where(['id' => $gameid])->find();
- if ($gameInfo['game_auth_type'] == 1) { //中宣部实名认证
- $gameAccountInfo = model('Subaccount')->where(['game_id' => $gameid, 'member_id' => $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) {
- $membersTwoInfo['realname'] = '';
- $membersTwoInfo['idcard'] = '';
- } else {
- $membersTwoInfo['realname'] = '';
- $membersTwoInfo['idcard'] = '';
- }
- } else {
- $membersTwoInfo['realname'] = '';
- $membersTwoInfo['idcard'] = '';
- }
- vendor('authSdk.Authentication', '.class.php');
- $auth = new \Authentication();
- if (!$membersTwoInfo['realname'] || !$membersTwoInfo['idcard']) { //未实名
- $result = $auth->loginout(trim($gameInfo['game_bizid']), $this->input('token'), 0, 2, $imeil);
- // var_dump($result);
- if ($result['errcode'] == 0) {
- }
- } else { //已实名
- $result = $auth->loginout(trim($gameInfo['game_bizid']), $this->input('token'), 0, 0, $imeil, $gameAccountInfo['auth_pi']);
- // var_dump($result);
- if ($result['errcode'] == 0) {
- }
- }
- }
- }
- $this->jsonResult('', 1, '退出成功');
- }
- /**
- * 校验是否登录[自动登录]
- */
- public function checkToken()
- {
- if (temporary()) {
- $this->jsonResult('', 0, '禁止登录');
- }
- if (!empty($this->version) && version_compare($this->version, '3.6.8', '>') && $this->input['token_version'] == "") {
- $this->jsonResult('', 0, '登录失效,请重新登录!');
- }
- $channel_id = $this->input('channel_id'); //渠道ID
- $gameid = $this->input('gameid'); //游戏ID
- $device = $this->input('device'); //设备 (v3.0.2 新增参数)
- $imeil = $this->input('imeil');
- //海外游戏ip限制
- if (in_array($gameid, config('haiwai_game_ids'))) {
- $res = (new IpLimit())->validateIp(request()->ip(), $this->input['username']);
- if ($res != 1) {
- $this->jsonResult('', 0, '国内用户禁止登录');
- }
- }
- if (empty($channel_id)) {
- $this->jsonResult('', 0, '渠道ID不能为空');
- }
- if (!$game = model('Common/Game')->where(['id' => $gameid])->find()) {
- $this->jsonResult('', 0, '游戏信息不存在');
- }
- if ($game['cooperation_status'] == 3) {
- $this->jsonResult('', 0, '游戏已下架不存在');
- }
- if ($game['is_login'] == 1) {
- // 游戏登录白名单
- if(Db::name('cy_game_user_white')->where(['game_id' => $gameid, 'username' => $this->input['username']])->count() == 0){
- $gameInfo = Db::table('cy_gameinfo')->where(['game_id' => $gameid])->field('ban_login_msg')->find();
- $ban_login_msg = '当前游戏禁止登录!';
- if(!empty($gameInfo['ban_login_msg'])){
- $ban_login_msg = $gameInfo['ban_login_msg'];
- }
- $this->jsonResult('', 0, $ban_login_msg);
- }
- }
- //用户信息
- $userinfo = $this->membersModel->field('id,reg_time,fromflag,flag,nickname,channel_id,mobile')->where(['id' => $this->input('userid')])->find();
- // 封禁仙剑安卓包的主播包登陆
- if(!in_array($this->input['username'], ['zbgzzdaj', 'zbcobpyl'])){
- if($channel_id == 100 && $gameid == 266){
- $this->jsonResult('', 0, '您所在渠道已经被禁止登录此游戏!! ');
- }
- }
- if (empty($userinfo)) {
- $this->jsonResult('', 0, '账号不存在');
- } // 判断一下当前账号是否被冻结
- elseif (1 == $userinfo['flag']) {
- Cache::store('redis')->rm($this->input('token'));
- $this->jsonResult('', 0, '您的账号已被冻结,请联系客服QQ:' . CUSTOMER_SERVICE_QQ);
- } // 渠道禁止判断
- elseif (isFrozenOption($channel_id, $gameid, 'member_login')) {
- Cache::store('redis')->rm($this->input('token'));
- $this->jsonResult('', 0, '您所在渠道已经被禁止登录此游戏! ');
- }
- // ## 风控策略(与 index 登录保持一致)
- $fkData = [
- 'username' => $this->input['username'], // username
- 'ip' => request()->ip(), // ip
- 'imei' => $imeil, // imei
- 'mobile' => $userinfo['mobile'], // 注册手机号
- ];
- $result = (new FkStrategiesService())->processEvent($fkData); // 登录
- if ($result['status']) {
- $this->jsonResult('', 0, '您的账号已被风控冻结,请联系客服QQ:' . CUSTOMER_SERVICE_QQ);
- }
- //判断游戏是否冻结IP或者IMEI
- $LoginIp = request()->ip();
- $BannedInfo = model('GameBanned')->where(['game_id' => array('in', [0, $gameid]), 'banned_type' => 'ip', 'banned_device' => $LoginIp])->find();
- if (!empty($BannedInfo)) {
- log_message(json_encode([$userinfo, $gameid, $imeil, $device, $LoginIp]), 'log', LOG_PATH . 'login/');
- $template = '【封禁提示】IP禁止登录:账号:' .$userinfo['username'].' ip:'.$LoginIp;
- curlDD($template, Env::get('notice_weelfar_url'), true);
- $this->jsonResult('', 0, '您的IP已被禁止登录此游戏! ');
- }
- if ($imeil) {
- $BannedInfo = model('GameBanned')->where(['game_id' => array('in', [0, $gameid]), 'banned_type' => 'imeil', 'banned_device' => $imeil])->find();
- if (!empty($BannedInfo)) {
- log_message(json_encode([$userinfo, $gameid, $imeil, $device]), 'log', LOG_PATH . 'login/');
- $template = '【封禁提示】设备登录:账号:' .$userinfo['username'].' imeil:'.$imeil;
- curlDD($template, Env::get('notice_weelfar_url'), true);
- $this->jsonResult('', 0, '该设备已被禁止登录此游戏! ');
- }
- }
- //游戏防沉迷限制
- $restrictInfo = model('GameRestrict')->where(['game_id' => $gameid, 'restrict_type' => 'preventhook'])->find();
- if ($restrictInfo) {
- $isPreventHook = intval($restrictInfo['restrict_status']);
- } else {
- $settingModel = new Setting;
- $isPreventHook = intval($settingModel::getSetting('CHILD_LIMIT'));
- }
- $offline_time = null;
- if ($isPreventHook == 2) {
- // 已实名认证用户做防沉迷判断
- $membersTwoInfo = model('MembersTwo')->where(['userid' => $userinfo['id']])->find();
- if ($membersTwoInfo && !empty($membersTwoInfo['realname']) && !empty($membersTwoInfo['idcard']) && $membersTwoInfo['realname'] <> -1 && $membersTwoInfo['idcard'] <> -1) {
- if (!isMeetAgeByIDCard($membersTwoInfo['idcard'], 18, 120)) {
- //if (!(date('H:i') > '08:00' && date('H:i') < '22:00')) {
- // $this->jsonResult('', 0, '您未满18周岁,22:00~8:00无法登录 ');
- // }
- // 节假日
- $holiday = $this->getHoliday(date("Ymd"));
- if ($holiday) {
- if (!(date("H:i") > "20:00" && date("H:i") < "21:00")) {
- $this->jsonResult('', 0, '未成年用户,仅可在周五、周六、周日和法定节假日每日20时至21时进行游戏,其他时间均无法进行游戏 ');
- } else {
- $offline_time = strtotime(date("Y-m-d") . " 21:00");
- }
- } else {
- $date = date("w");
- if (in_array($date, [0, 5, 6])) {
- if (!(date("H:i") > "20:00" && date("H:i") < "21:00")) {
- $this->jsonResult('', 0, '未成年用户,仅可在周五、周六、周日和法定节假日每日20时至21时进行游戏,其他时间均无法进行游戏 ');
- } else {
- $offline_time = strtotime(date("Y-m-d") . " 21:00");
- }
- } else {
- $this->jsonResult('', 0, '未成年用户,仅可在周五、周六、周日和法定节假日每日20时至21时进行游戏,其他时间均无法进行游戏 ');
- }
- }
- }
- }
- }
- $logininfoModel = new Logininfo();
- if (empty($device)) {
- $platform = model('Common/GameInfo')->where(['game_id' => $gameid])->value('platform');
- if ($platform == 1)
- $device = 3; //IOS
- elseif ($platform == 0)
- $device = 2; //安卓
- else
- $device = 1; //PC
- }
- $gameAccountInfo = (new Subaccount())->where(['game_id' => $gameid, 'member_id' => $userinfo['id']])->find();
- if (1 == $gameAccountInfo['flag']) {
- $this->jsonResult('', -120, '您的子账号已被冻结,请联系客服QQ:' . CUSTOMER_SERVICE_QQ);
- }
- $logData['sub_id'] = $gameAccountInfo['id'];
- $logData['userid'] = $userinfo['id'];
- $logData['gameid'] = $gameid;
- $logData['imeil'] = $imeil;
- $logData['device'] = $device;
- $logData['reg_time'] = $userinfo['reg_time'];
- $logData['fromflag'] = $userinfo['fromflag'];
- $logData['channel_id'] = $gameAccountInfo['channel_id'];
- $logData['login_time'] = NOW_TIMESTAMP;
- $logData['ip'] = request()->ip();
- //登录日志
- $logininfoModel->limitInsert($logData);
- // 用户推广信息保存
- // setChannelId($userinfo['id'], $gameAccountInfo['channel_id']);
- //更新最近登录时间
- if (!trim($userinfo['nickname'])) {
- $userNickName = random(3) . $userinfo['id'];
- $this->membersModel->where(['id' => $userinfo['id']])->update(['login_time' => NOW_TIMESTAMP, 'nickname' => $userNickName]);
- } else {
- $this->membersModel->where(['id' => $userinfo['id']])->update(['login_time' => NOW_TIMESTAMP]);
- }
- // 更新子账户时间
- (new Subaccount())->where(['game_id' => $gameid, 'member_id' => $userinfo['id']])->update(['update_time' => NOW_TIMESTAMP]);
- $this->jsonResult(['is_login' => 1, "offline_time" => $offline_time], 1, '有效token');
- }
- /**
- * 普通用户登录处理
- */
- public function third()
- {
- // if (temporary()) {
- // $this->jsonResult('', 0, '禁止登录');
- // }
- $username = $this->input('username'); //用户名
- $imeil = trim($this->input('imeil')); //手机imeil码
- $gameid = $this->input('gameid'); //游戏ID
- $device = $this->input('device'); //设备
- $channelId = $this->input('channel_id'); //当前登录的渠道ID
- $type_id = $this->input('type_id'); // 当前登录的渠道ID:1=微信, 2=qq, 3=抖音
- $oaid = $this->input('oaid', '');
- $dy_channel_id = $this->input('dy_channel_id', 0);
- // log_message(json_encode(input()), 'log', LOG_PATH . 'third/');
- //海外游戏ip限制
- if (in_array($gameid, config('haiwai_game_ids'))) {
- $res = (new IpLimit())->validateIp(request()->ip(), $username);
- if ($res != 1) {
- $this->jsonResult('', 0, '国内用户禁止登录');
- }
- }
- if (empty($username)) {
- $this->jsonResult('', 0, '用户名不能为空');
- }
- //游戏ID不能为空
- if (empty($gameid)) {
- $this->jsonResult('', 0, '游戏ID不能为空');
- }
- if (empty($device)) {
- $this->jsonResult('', 0, '没有注册设备来源');
- }
- if (empty($imeil)) {
- $this->jsonResult('', 0, '设备imeil异常');
- }
- if (empty($channelId)) {
- $this->jsonResult('', 0, '渠道不能为空');
- }
- //判断渠道
- $channelInfo = (new Channel)->where(['status' => 1, 'id' => $channelId])->find();
- if (!$channelInfo) {
- $this->jsonResult('', 0, '渠道信息不存在');
- } else if ($channelInfo['level'] <> 3) {
- $this->jsonResult('', 0, '非推广员渠道,不能进行推广,请联系客服');
- }
- if (!$game = model('Common/Game')->where(['id' => $gameid])->find()) {
- $this->jsonResult('', 0, '游戏信息不存在');
- }
- if ($game['cooperation_status'] == 3) {
- $this->jsonResult('', 0, '游戏已下架不存在');
- }
- // 渠道禁止判断
- if (isFrozenOption($channelId, $gameid, 'member_login')) {
- $this->jsonResult('', 0, '您所在渠道已经被禁止登录此游戏!! ');
- }
- $fromflag = 1;
- if (!in_array($type_id, [1, 2, 3])) {
- $this->jsonResult('', 0, '请求类型有误!');
- }
- if ($type_id == 1) { // 微信
- $userinfo = $this->membersModel->where(['wx_uid' => $username])->find();
- } else if ($type_id == 2) { // qq
- $userinfo = $this->membersModel->where(['wx_uid' => $username])->find();
- } else if ($type_id == 3) { // 抖音
- $userinfo = $this->membersModel->where(['dy_uid' => $username])->find();
- $fromflag = 3;
- }
- if ($userinfo) {
- if (1 == $userinfo['flag']) {
- $this->jsonResult('', 0, '您的账号已被冻结,请联系客服QQ:' . CUSTOMER_SERVICE_QQ);
- }
- $channelId = $userinfo['channel_id'];
- //用户登录公共部分处理
- $this->loginProcess($userinfo, $gameid, $imeil, $device, $channelId);
- } else {
- $username_third = strtolower(random(11));
- while ($this->membersModel->field('id')->where(['username' => $username_third])->find()) {
- $username_third = strtolower(random(11));
- }
- $data = [
- 'username' => $username_third,
- 'password' => auth_code('a12345fewdcv2', "ENCODE", Env::get($this->aesKey)),
- 'device' => $this->input('device'),
- 'gameid' => $gameid,
- 'imeil' => $imeil,
- 'channel_id' => $this->input('channel_id'),
- 'deviceinfo' => $this->input('deviceinfo'),
- 'mobile' => '',
- 'is_local' => 0,
- 'reg_time' => time(),
- 'login_time' => time(),
- 'ip' => request()->ip(),
- 'nickname' => random(8),
- 'fromflag' => $fromflag
- ];
- if ($type_id == 1) { // 微信
- $data['wx_uid'] = $username;
- } else if ($type_id == 2) { // qq
- $data['qq_uid'] = $username;
- } else if ($type_id == 3) { // 微信
- $data['dy_uid'] = $username;
- }
- // 启动事务
- Db::startTrans();
- try {
- $member_id = $this->membersModel->insertGetId($data);
- if ($member_id) {
- // 插入玩家历史记录
- Db::table('cy_member_history')->insert([
- 'userid' => $member_id,
- 'password' => $data['password'],
- 'mobile' => $data['mobile'],
- 'ip' => request()->ip(),
- 'create_time' => time()
- ]);
- $realname = '';
- $idcard = '';
- //插入用户扩展记录
- Db::table('cy_memberstwo')->insert([
- 'userid' => $member_id,
- 'username' => $data['username'],
- 'realname' => $realname,
- 'idcard' => $idcard,
- 'create_time' => time()
- ]);
- //绑定抖音channel 和 平台内的channel
- // $dy_channel_info = Db::table("mw_dy_channel_rel")
- // ->where("channel_id", $data['channel_id'])
- // ->where("dy_channel_id", $dy_channel_id)->find();
- // if (empty($dy_channel_info)) {
- // $dy_channel_rel = [
- // 'channel_id' => $data['channel_id'],
- // 'dy_channel_id' => $dy_channel_id,
- // 'create_time' => NOW_TIMESTAMP,
- // 'update_time' => NOW_TIMESTAMP,
- // ];
- // Db::table("mw_dy_channel_rel")->insert($dy_channel_rel);
- // }
- // 提交事务
- Db::commit();
- // 登录处理
- $this->loginProcess(array_merge($data, ['id' => $member_id, 'gameid' => $gameid, 'oaid' => $oaid]), $gameid, $imeil, $device, $channelId);
- } else {
- throw new Exception("注册失败!");
- }
- } catch (\Exception $e) {
- // 回滚事务
- Db::rollback();
- $this->jsonResult('', 0, '注册失败!' . $e->getMessage());
- }
- }
- exit;
- }
- }
|