diff --git a/Application/Admin/Model/UserModel.class.php b/Application/Admin/Model/UserModel.class.php index e031fb6a5..f16e12318 100644 --- a/Application/Admin/Model/UserModel.class.php +++ b/Application/Admin/Model/UserModel.class.php @@ -1051,16 +1051,32 @@ class UserModel extends Model{ } } - public function login_sdk($account,$password,$type=1,$game_id,$game_name,$sdk_version){ + public function login_sdk($account,$password,$type=1,$game_id,$game_name,$sdk_version,$unique_code){ $map['account'] = $account; /* 获取用户数据 */ $user = $this->where($map)->find(); if(is_array($user) && $user['lock_status'] && $user['check_status']){ /* 验证用户密码 */ if(think_ucenter_md5($password, UC_AUTH_KEY) === $user['password']||$type==2){ - $token = $this->updateLogin_($user['id'],$account,$password,$user['fgame_id'],$game_id,$game_name); //更新用户登录信息 - $this->user_login_record2($user,$type,$game_id,$game_name,$sdk_version); - return array("user_id"=>$user['id'],"token"=>$token); //登录成功,返回用户ID + $test_resource = M('test_resource','tab_')->where("user_id=%s and apply_status=2",$user['id'])->find();//测试资源(扶持号) + if($test_resource){ //扶持号 + if($user['device_number'] && $unique_code && $user['device_number'] !=$unique_code){ //#当前登录设备信息与历史登录设备信息不一致,触发账户冻结 + $this->sdklogin_device_error($user,$test_resource,$unique_code); + $this->sdklogin_ip_error($user,$test_resource,get_client_ip()); + return -1;//扶持号被禁用 + }else{ + $token = $this->sdklogin_update($user,$account,$password,$user['fgame_id'],$game_id,$game_name,$unique_code); //更新用户登录信息 + $this->user_login_record2($user,$type,$game_id,$game_name,$sdk_version); + $this->sdklogin_ip_error($user,$test_resource,get_client_ip()); + return array("user_id"=>$user['id'],"token"=>$token); //登录成功,返回用户ID + } + }else{ + Log::write('进入SDK_1' , 'INFO'); + $token = $this->sdklogin_update($user,$account,$password,$user['fgame_id'],$game_id,$game_name,$unique_code); //更新用户登录信息 + $this->user_login_record2($user,$type,$game_id,$game_name,$sdk_version); + return array("user_id"=>$user['id'],"token"=>$token); //登录成功,返回用户ID + } + } else { return -2; //密码错误 } @@ -1070,6 +1086,79 @@ class UserModel extends Model{ } + //更新用户登录信息 + protected function sdklogin_update($user,$account,$password,$user_fgame_id,$game_id,$game_name,$unique_code=''){ + $model = M('User','tab_'); + $uid = $user['id']; + $data["id"] = $uid; + $data["login_time"] = NOW_TIME; + $data["login_ip"] = get_client_ip(); + $data["device_number"] = $unique_code; + $data["last_login_ip"] = $user['login_ip']; + $data["last_device_number"] = $user['device_number']; + $data["token"] = $this->generateToken($uid,$account,$password); + if($user_fgame_id){ + $model->save($data); + }else{ + $data['fgame_id']=$game_id; + $data['fgame_name']=$game_name; + $model->save($data); + } + return $data["token"]; + } + + // 扶持号登录设备异常 + protected function sdklogin_device_error($user,$resource,$unique_code){ + $model = M('User','tab_'); + $uid = $user['id']; + $data["id"] = $uid; + $data["device_number"] = $unique_code; + $data["last_device_number"] = $user['device_number']; + $data["lock_status"] = 0 ; + $model->save($data); + $protect_data['user_id']= $uid; + $protect_data['user_account']= $resource['user_account']; + $protect_data['server_id'] = $resource['server_id']; + $protect_data['server_name']= $resource['server_name']; + $protect_data['game_id']=$resource['game_id']; + $protect_data['game_name']=$resource['game_name']; + $protect_data['nickname']=$resource['role_name']; + $protect_data['promote_id']=$resource['promote_id']; + $protect_data['promote_account']=$resource['promote_account']; + $protect_data['type']=2; + $protect_data['detail']="登录设备号异常,本次异常设备号:".$unique_code.",历史登录设备号:".$user['device_number']; + $protect_data['create_time'] = NOW_TIME; + M('protect_log','tab_')->add($protect_data); + } + + // 扶持号登录IP异常 + protected function sdklogin_ip_error($user,$resource,$ip){ + $newloginip_source = file_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=".$ip); + $aldloginip_source = file_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=".$user['login_ip']); + + $newloginip_source = json_decode($newloginip_source,true); + $aldloginip_source = json_decode($aldloginip_source,true); + + if($newloginip_source['data']['city']!=$aldloginip_source['data']['city']){ //登录城市不一致时触发IP异常 + $uid = $user['id']; + $protect_data['user_id']= $uid; + $protect_data['user_account']= $resource['user_account']; + $protect_data['server_id'] = $resource['server_id']; + $protect_data['server_name']= $resource['server_name']; + $protect_data['game_id']=$resource['game_id']; + $protect_data['game_name']=$resource['game_name']; + $protect_data['nickname']=$resource['role_name']; + $protect_data['promote_id']=$resource['promote_id']; + $protect_data['promote_account']=$resource['promote_account']; + $protect_data['type']=1; + $protect_data['detail']="登录IP异常,本次异常IP:".$ip.",历史登录IP:".$user['login_ip']; + $protect_data['create_time'] = NOW_TIME; + M('protect_log','tab_')->add($protect_data); + } + } + + + //判断game_id是否有值 protected function updateLogin_($uid,$account,$password,$user_fgame_id,$game_id,$game_name){ $model = M('User','tab_'); diff --git a/Application/Base/Repository/PromoteRepository.class.php b/Application/Base/Repository/PromoteRepository.class.php index 514f7a734..9f2f55f50 100644 --- a/Application/Base/Repository/PromoteRepository.class.php +++ b/Application/Base/Repository/PromoteRepository.class.php @@ -48,7 +48,15 @@ class PromoteRepository { if (isset($params['lock_status'])) { $lockUserIds = M('user', 'tab_')->where(['lock_status' => 0, 'promote_id' => ['in', $allIds]])->getField('id', 'true'); if (count($lockUserIds) > 0) { - $map['user_id'] = ['not in', $lockUserIds]; + if ($params['lock_status'] == 1) { + $map['user_id'] = ['not in', $lockUserIds]; + } else { + $map['user_id'] = ['in', $lockUserIds]; + } + } else { + if ($params['lock_status'] == 2) { + $map['_string'] = ' 1<>1'; + } } } return $map; @@ -214,7 +222,11 @@ class PromoteRepository { } $subQuery = M('user_play_info', 'tab_')->field('user_id')->group('user_id')->where($subMap)->buildSql(); - $map['_string'] = ' user_id not in (' . $subQuery . ')'; + if (isset($map['_string'])) { + $map['_string'] .= ' and user_id not in (' . $subQuery . ')'; + } else { + $map['_string'] = ' user_id not in (' . $subQuery . ')'; + } $inQuery = M('user_play_info', 'tab_')->field('user_id')->group('user_id')->where($map)->buildSql(); $resultMap = ['_string' => 'user_id in (' . $inQuery . ')']; diff --git a/Application/Home/Controller/PromoteController.class.php b/Application/Home/Controller/PromoteController.class.php index d4774857b..037cb7b5f 100644 --- a/Application/Home/Controller/PromoteController.class.php +++ b/Application/Home/Controller/PromoteController.class.php @@ -37,7 +37,11 @@ class PromoteController extends BaseController { $this->meta_title = "首页"; $loginPromote = $this->getLoginPromote(); - if ($loginPromote['id'] != 1 && $loginPromote['parent_id'] != 1 && $loginPromote['grand_id'] != 1) { + + $whiteList = [1, 8]; + $isOpenQuery = in_array($loginPromote['id'], $whiteList) || in_array($loginPromote['parent_id'], $whiteList) || in_array($loginPromote['grand_id'], $whiteList) ? true : false; + + if (!$isOpenQuery) { $this->display('prepare'); exit(0); } @@ -856,6 +860,15 @@ class PromoteController extends BaseController $this->ajaxReturn(array('status' => -1, 'msg' => '身份证格式错误')); } } + if (mb_strlen($_POST['account']) < 6 || mb_strlen($_POST['account']) > 15) { + $this->error('账号长度为6-15个字符', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 0)))); + return false; + } + + if (mb_strlen($_POST['real_name']) < 2 || mb_strlen($_POST['real_name']) > 4) { + $this->error('姓名长度为2-4个字符', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 0)))); + return false; + } $res = $user->promote_add($_POST); if (is_numeric($res)) { diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index c2913a8d7..30765d46e 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -1155,7 +1155,9 @@ class QueryController extends BaseController $newUserNumData = $userPlayInfoModel ->field('tab_user_play_info.create_time,count(distinct tab_user_play_info.user_id) as num') + ->join($join) ->where($userPlayInfoWhere2) + ->where($map) ->having('tab_user_play_info.create_time between ' . $begTime . ' and ' . ($endTime + 86399)) ->order('tab_user_play_info.id') ->find(); @@ -1163,7 +1165,9 @@ class QueryController extends BaseController $newDeviceData = $userPlayInfoModel ->field('tab_user_play_info.create_time,count(distinct tab_user_play_info.create_device_number) as num') + ->join($join) ->where($userPlayInfoWhere2) + ->where($map) ->having('tab_user_play_info.create_time between ' . $begTime . ' and ' . ($endTime + 86399)) ->order('tab_user_play_info.id') ->find(); @@ -1171,7 +1175,9 @@ class QueryController extends BaseController $newIpNumData = $userPlayInfoModel ->field('tab_user_play_info.create_time,count(distinct tab_user_play_info.create_ip) as num') + ->join($join) ->where($userPlayInfoWhere2) + ->where($map) ->having('tab_user_play_info.create_time between ' . $begTime . ' and ' . ($endTime + 86399)) ->order('tab_user_play_info.id') ->find(); @@ -1671,6 +1677,7 @@ class QueryController extends BaseController $serverData = M('Server', 'tab_') ->field('server_id,server_name') ->where($where) + ->order('server_version,start_time desc') ->select(); $result['status'] = 1; $result['data'] = $serverData; @@ -1990,9 +1997,9 @@ class QueryController extends BaseController if ($costBegin != '' && $costEnd != '') { $having = 'sum(cost) between ' . $costBegin . ' and ' . $costEnd; } elseif ($costBegin != '' && $costEnd == '') { - $having = 'sum(cost) > ' . $costBegin; + $having = 'sum(cost) >= ' . $costBegin; } elseif ($costBegin == '' && $costEnd != '') { - $having = 'sum(cost) < ' . $costEnd; + $having = 'sum(cost) <= ' . $costEnd; } $subMap = $map; $subMap['pay_status'] = 1; @@ -2088,7 +2095,7 @@ class QueryController extends BaseController public function getGameServers() { $gameId = I('game_id', 0); - $servers = M('server', 'tab_')->field(['id', 'server_id', 'server_name'])->where(['game_id' => $gameId])->select(); + $servers = M('server', 'tab_')->field(['id', 'server_id', 'server_name'])->where(['game_id' => $gameId])->order('server_id asc')->select(); $this->ajaxReturn([ 'status' => 1, 'msg' => '成功', diff --git a/Application/Home/View/default/Promote/add_chlid.html b/Application/Home/View/default/Promote/add_chlid.html index e87d01b21..5d9d63c2a 100644 --- a/Application/Home/View/default/Promote/add_chlid.html +++ b/Application/Home/View/default/Promote/add_chlid.html @@ -37,13 +37,13 @@