diff --git a/Application/Admin/Controller/AutoPackController.class.php b/Application/Admin/Controller/AutoPackController.class.php index 713f67a4f..622619e61 100644 --- a/Application/Admin/Controller/AutoPackController.class.php +++ b/Application/Admin/Controller/AutoPackController.class.php @@ -301,7 +301,7 @@ class AutoPackController extends Think $applys = M('apply', 'tab_')->field('id,game_id,game_name,promote_id,promote_account,sdk_version') ->where($map) ->order('bale_sort desc,id desc') - ->limit(12) + ->limit(15) ->select(); if (count($applys) == 0) { diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index dc9e97c15..80f10074a 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -49,10 +49,9 @@ class ExportController extends Controller //导出Excel function expUser($id) { - $xlsName = $_REQUEST['xlsname']; + $xlsName = $_REQUEST['xlsname']; switch ($id) { case 1: - $xlsCell = array( array('user_account', "玩家账号"), array('game_name', "游戏名称"), @@ -866,6 +865,11 @@ class ExportController extends Controller unset($_REQUEST['time-start']); unset($_REQUEST['time-end']); } + if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) { + $map['pay_time'] = array('BETWEEN', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 24 * 60 * 60 - 1)); + unset($_REQUEST['timestart']); + unset($_REQUEST['timeend']); + } if (isset($_REQUEST['start']) && isset($_REQUEST['end'])) { $map['pay_time'] = array('BETWEEN', array(strtotime($_REQUEST['start']), strtotime($_REQUEST['end']) + 24 * 60 * 60 - 1)); unset($_REQUEST['start']); @@ -1004,7 +1008,7 @@ class ExportController extends Controller array('pay_amount', "充值平台币"), array('pay_way', "充值方式", 'get_pay_way', '*'), array('pay_ip', "充值ip"), - array('create_time', "充值时间", 'time_format'), + array('create_time', "充值时间"), array('pay_status', L('Order_status'), 'get_info_status', '*', '9'), array('', "共计充值{$total}"), ); @@ -1012,6 +1016,10 @@ class ExportController extends Controller ->where($map) ->order('id DESC') ->select(); + foreach ($xlsData as $key => $value) { + $xlsData[$key]['create_time'] = date('Y-m-d H:i:s', $value['create_time']); + } +// dd($xlsData); break; case 9: $xlsName = $xlsName?$xlsName:"平台币发放"; @@ -1542,6 +1550,7 @@ class ExportController extends Controller $xlsName = $xlsCell = $xlsData = []; } + //数据处理 foreach ($xlsData as $key => $val) { foreach ($xlsCell as $k => $v) { @@ -3419,80 +3428,131 @@ if ($key == 'model'){ * 登录记录 * @author 鹿文学 */ - public function login_record() { + public function login_record() { - $xlsName = $_REQUEST['xlsname']; + $xlsName = $_REQUEST['xlsname']; - $xlsCell = array( - array('user_account','玩家账号'), - array('game_name','游戏名称'), - array('server_name','游戏区服'), - array('user_nickname','角色名'), - array('login_time','登录时间'), - array('login_ip','最后登录ip'), - ); +// $xlsCell = array( +// array('user_account','玩家账号'), +// array('game_name','游戏名称'), +// array('server_name','游戏区服'), +// array('user_nickname','角色名'), +// array('login_time','登录时间'), +// array('login_ip','最后登录ip'), +// ); + $xlsCell = array( + '玩家账号', + '游戏名称', + '游戏区服', + '角色名', + '登录时间', + '最后登录ip', + ); - if (isset($_REQUEST['login_ip'])) { - $map['login_ip'] = $_REQUEST['login_ip']; - } - if (isset($_REQUEST['game_id'])) { - $map['game_id'] = $_REQUEST['game_id']; - } - if (isset($_REQUEST['game_name'])) { - $map['game_name'] = ['like', $_REQUEST['game_name']."%"]; - unset($_REQUEST['game_name']); - } - if (isset($_REQUEST['game_type'])) { - $map['sdk_version'] = $_REQUEST['game_type']; - unset($_REQUEST['game_type']); - } - if (isset($_REQUEST['server_name'])) { - $map['server_name'] = $_REQUEST['server_name']; - unset($_REQUEST['server_name']); - } - if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) { - $map['login_time'] = array('BETWEEN', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 24 * 60 * 60 - 1)); - }elseif(isset($_REQUEST['timestart'])){ - $map['login_time'] = array('GT',strtotime($_REQUEST['timestart'])); - }elseif(isset($_REQUEST['timeend'])){ - $map['login_time'] = array('lt',(strtotime($_REQUEST['timeend'])+ 24 * 60 * 60 - 1)); - } - if (isset($_REQUEST['account'])) { - $map['user_account'] = array('like', '%' . trim($_REQUEST['account']) . '%'); - } - - $map['login_time'] = array('neq', 0); - $page = intval($_REQUEST['p']); + if (isset($_REQUEST['login_ip'])) { + $map['login_ip'] = $_REQUEST['login_ip']; + } + if (isset($_REQUEST['game_id'])) { + $map['game_id'] = $_REQUEST['game_id']; + } + if (isset($_REQUEST['game_name'])) { + $map['game_name'] = ['like', $_REQUEST['game_name']."%"]; + unset($_REQUEST['game_name']); + } + if (isset($_REQUEST['game_type'])) { + $map['sdk_version'] = $_REQUEST['game_type']; + unset($_REQUEST['game_type']); + } + if (isset($_REQUEST['server_name'])) { + $map['server_name'] = $_REQUEST['server_name']; + unset($_REQUEST['server_name']); + } + if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) { + $map['login_time'] = array('BETWEEN', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 24 * 60 * 60 - 1)); + }elseif(isset($_REQUEST['timestart'])){ + $map['login_time'] = array('GT',strtotime($_REQUEST['timestart'])); + }elseif(isset($_REQUEST['timeend'])){ + $map['login_time'] = array('lt',(strtotime($_REQUEST['timeend'])+ 24 * 60 * 60 - 1)); + } + if (isset($_REQUEST['account'])) { + $map['user_account'] = array('like', '%' . trim($_REQUEST['account']) . '%'); + } - $page = $page?$page:1; + if (isset($_REQUEST['promote_id'])) { + $map['promote_id'] = $_REQUEST['promote_id']; + } - $row = $_REQUEST['row']?$_REQUEST['row']:10; +// $map['login_time'] = array('neq', 0); - $data = M('UserLoginRecord','tab_') - ->where($map)->order('id desc')->select(); + $page = intval($_REQUEST['p']); - $xlsData = []; + $page = $page?$page:1; - foreach($data as $k => $v) { + $row = $_REQUEST['row']?$_REQUEST['row']:10; - $v['login_time'] = date('Y-m-d H:i:s',$v['login_time']); - $v['server_name'] = empty($v['server_name'])?'空':$v['server_name']; - $gamename=trim(get_game_name($v['game_id'],'id')); + //查询数量 + $accessNum = M('UserLoginRecord','tab_') + ->where($map)->order('id desc')->count(); - $v['game_name'] = empty($gamename)?($v['type']==2?'APP登录':'平台登录'):$gamename; + if ($accessNum > 1000000) { + echo "数据量过大,大于100万";die(); + } - $xlsData[] = $v; + $csvFileName = $xlsName.'.csv'; + //设置好告诉浏览器要下载excel文件的headers + header('Content-Description: File Transfer'); + header('Content-Type: application/vnd.ms-excel'); + header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + $fp = fopen('php://output', 'a');//打开output流 + mb_convert_variables('GBK', 'UTF-8', $xlsCell); + fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 - } + $perSize = 50000;//每次查询的条数 + $pages = ceil($accessNum / $perSize); + for($i = 1; $i <= $pages; $i++) { + $data = M('UserLoginRecord','tab_') + ->field("user_account,game_name,server_name,user_nickname,login_time,login_ip") + ->where($map) + ->limit(($i-1)*$perSize ,$perSize) + ->order('id desc') + ->select(); - $this->exportExcel($xlsName, $xlsCell, $xlsData); + foreach($data as $k => $v) { - } + $v['login_time'] = date('Y-m-d H:i:s',$v['login_time']); + $v['server_name'] = empty($v['server_name'])?'空':$v['server_name']; + +// $gamename=trim(get_game_name($v['game_id'],'id')); + +// $v['game_name'] = empty($gamename)?($v['type']==2?'APP登录':'平台登录'):$gamename; + + $xlsData[] = $v; + + mb_convert_variables('GBK', 'UTF-8', $v); + fputcsv($fp, $v); + } + + unset($xlsData);//释放变量的内存 + //刷新输出缓冲到浏览器 + ob_flush(); + flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。 + } +// $xlsData = []; + + exit(); + + +// $this->exportExcel($xlsName, $xlsCell, $xlsData); + + } /** diff --git a/Application/Admin/Controller/FileController.class.php b/Application/Admin/Controller/FileController.class.php index 864003999..0e1304463 100644 --- a/Application/Admin/Controller/FileController.class.php +++ b/Application/Admin/Controller/FileController.class.php @@ -209,9 +209,9 @@ class FileController extends AdminController ); //TODO:上传到远程服务器 // 添加水印 - if ($_REQUEST['flag']) { - $this->addWatermarkOnPic($info['download']); - } +// if ($_REQUEST['flag']) { +// $this->addWatermarkOnPic($info['download']); +// } /* 记录图片信息 */ if ($info) { @@ -249,8 +249,6 @@ class FileController extends AdminController C("UPLOAD_{$file_driver}_CONFIG"), $_REQUEST['flag'] ); //TODO:上传到远程服务器 - - /* 记录图片信息 */ if ($info) { $return['status'] = 1; diff --git a/Application/Admin/Controller/MemberController.class.php b/Application/Admin/Controller/MemberController.class.php index afde5599c..b24903687 100644 --- a/Application/Admin/Controller/MemberController.class.php +++ b/Application/Admin/Controller/MemberController.class.php @@ -788,13 +788,20 @@ class MemberController extends ThinkController $map['server_name'] = $_REQUEST['server_name']; unset($_REQUEST['server_name']); } + if (isset($_REQUEST['promote_id'])) { + $map['promote_id'] = $_REQUEST['promote_id']; + unset($_REQUEST['promote_id']); + } // $map['type'] = 1; // $map['login_time'] = ['exp', 'login_time<>0']; $extend = array(); $extend['map'] = $map; - + $count = M('UserLoginRecord','tab_')->field('user_id')->where($extend['map'])->group('user_id')->select(false); + $sql = "select count(user_id) as count from ({$count})t"; + $count = M('UserLoginRecord','tab_')->query($sql); $this->m_title = '登录记录'; + $this->assign('user_count',$count[0]['count']); $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Member/login_record', 'status' => 1])->find()); parent::lists("UserLoginRecord", $p, $extend['map']); @@ -1231,6 +1238,24 @@ class MemberController extends ThinkController } $list = M('device_bans', 'tab_')->where($map)->page($p, $row)->select(); $count = M('device_bans', 'tab_')->where($map)->count(); + if (!empty($list)) { + foreach ($list as &$item) { + switch ($item['type']) { + case '1': + $item['type_name'] = '设备号'; + break; + case '2': + $item['type_name'] = 'IP'; + break; + case '3': + $item['type_name'] = '落地页链接'; + break; + case '4': + $item['type_name'] = '下载链接'; + break; + } + } + } $page = set_pagination($count, $row); if ($page) { $this->assign('_page', $page); @@ -1249,9 +1274,15 @@ class MemberController extends ThinkController if (empty($type) || empty($tag)) { return $this->error("请填写完整信息"); } + if (\in_array($type, [3,4]) && !preg_match("/^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+/i", $tag)) { + return $this->error("请填写正确的url地址"); + } if ($type == 2 && !preg_match("/(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/i", $tag)) { return $this->error("请填写正确的ip信息,如127.0.0.1"); } + if ($type == 1 && (preg_match("/(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/i", $tag) || preg_match("/^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+/i", $tag))) { + return $this->error("请填写正确的设备信息"); + } $map['type'] = $type; $map['tag'] = $tag; $item = M('device_bans', 'tab_')->where($map)->find(); diff --git a/Application/Admin/Controller/MendController.class.php b/Application/Admin/Controller/MendController.class.php index a1d9bc50f..b4a22e062 100644 --- a/Application/Admin/Controller/MendController.class.php +++ b/Application/Admin/Controller/MendController.class.php @@ -81,6 +81,8 @@ class MendController extends ThinkController { "order_time"=>$create['order_time'], "type"=>2, "shift_ids"=>[$create['user_id']], + "creator_type"=>0, + "creator_id"=>$_SESSION["onethink_admin"]["user_auth"]["uid"] ); if(!empty($create['remark'])){ $params['remark'] = $create['remark']; @@ -111,13 +113,16 @@ class MendController extends ThinkController { { $id = I('id'); $info = M("shift_task")->where("id = {$id} and status = 0")->find(); + if(empty($info)){ $this->error("补链不存在或已处理"); } $info['user_id'] = json_decode($info['shift_ids'])[0]; - $info['order_time'] = date("Y-m-d",$info['order_time']); + $info['order_time'] = date("Y-m-d",$info['order_time']); + $userid = $info['user_id']; + $info['account'] = M("User","tab_")->field("account")->where("id = '{$userid}'")->find()['account']; $this->assign('data',$info); $this->display(); } @@ -127,9 +132,9 @@ class MendController extends ThinkController { $id = I('id'); $status = M('ShiftTask')->where(['id' => $id,'status' => 0])->save(['status' => 2]); if ($status) { - $this->success('取消补链成功', U('lists'), 2); + $this->ajaxReturn(array("status"=>1,"url"=> U('lists'))); } else { - $this->error("取消失败,或补链已生效",U('lists')); + $this->ajaxReturn(array("status"=>0,"url"=> U('lists'))); } } } diff --git a/Application/Admin/Controller/StatController.class.php b/Application/Admin/Controller/StatController.class.php index 3f3ee2da9..325a530f8 100644 --- a/Application/Admin/Controller/StatController.class.php +++ b/Application/Admin/Controller/StatController.class.php @@ -604,7 +604,11 @@ class StatController extends ThinkController ->where($map) ->group('user_id') ->find(); - $data[$key]['keep_num'] = round($num['num']/$data[$key]['register_num'],4)*100; + if (!empty($data[$key]['register_num'])) { + $data[$key]['keep_num'] = round($num['num']/$data[$key]['register_num'],4)*100; + } else { + $data[$key]['keep_num'] = 0; + } //充值 $map = $map_list; empty($game_name ) || $map['game_name'] = array('like','%'.$game_name.'%'); @@ -638,12 +642,24 @@ class StatController extends ThinkController $data[$key]['new_pop'] = $query[0]['num']; //付费率 - $data[$key]['spend_rate'] = round($data[$key]['spend_people']/$data[$key]['act_user'],4)*100; + if (!empty($data[$key]['act_user'])) { + $data[$key]['spend_rate'] = round($data[$key]['spend_people']/$data[$key]['act_user'],4)*100; + } else { + $data[$key]['spend_rate'] = 0; + } //ARPU - $data[$key]['ARPU'] = round($data[$key]['spend']/$data[$key]['act_user'],2); - //ARPPU - $data[$key]['ARPPU'] = round($data[$key]['spend']/$data[$key]['spend_people'],2); + if (!empty($data[$key]['act_user'])) { + $data[$key]['ARPU'] = round($data[$key]['spend']/$data[$key]['act_user'],2); + } else { + $data[$key]['ARPU'] = 0; + } + //ARPPU + if (!empty($data[$key]['spend_people'])) { + $data[$key]['ARPPU'] = round($data[$key]['spend']/$data[$key]['spend_people'],2); + } else { + $data[$key]['ARPPU'] = 0; + } //累计付费玩家 $map = $map_list; empty($hasbindcoins) || $map['pay_way'] = $hasbindcoins['pay_way']; @@ -1144,7 +1160,11 @@ class StatController extends ThinkController ->join("right join tab_user_login_record as ur on ur.user_id = tab_user.id and FROM_UNIXTIME(ur.login_time,'%Y-%m-%d') = '{$login_time}'") ->where($mapl) ->find(); - $data[$key]['keep_num'] = round($num['num']/$data[$key]['register_num'],4)*100; + if (!empty($data[$key]['register_num'])) { + $data[$key]['keep_num'] = round($num['num']/$data[$key]['register_num'],4)*100; + } else { + $data[$key]['keep_num'] = 0; + } //充值 $mapl = $map_list; empty($game_name ) || $mapl['game_name'] = array('like','%'.$game_name.'%'); @@ -1157,15 +1177,26 @@ class StatController extends ThinkController //付费玩家数 $data[$key]['spend_people'] = $spend['people']; //付费率 - $data[$key]['spend_rate'] = round($data[$key]['spend_people']/$data[$key]['act_user'],4)*100; + if (!empty($data[$key]['act_user'])) { + $data[$key]['spend_rate'] = round($data[$key]['spend_people']/$data[$key]['act_user'],4)*100; + } else { + $data[$key]['spend_rate'] = 0; + } //ARPU - $data[$key]['ARPU'] = round($data[$key]['spend']/$data[$key]['act_user'],2); + if (!empty($data[$key]['act_user'])) { + $data[$key]['ARPU'] = round($data[$key]['spend']/$data[$key]['act_user'],2); + } else { + $data[$key]['ARPU'] = 0; + } //ARPPU - $data[$key]['ARPPU'] = round($data[$key]['spend']/$data[$key]['spend_people'],2); - if($data[$key]['register_num']==0&&$data[$key]['act_user']==0&&$data[$key]['keep_num']==0&&$data[$key]['spend']==0&&$data[$key]['spend_people']==0){ - unset($data[$key]); + if (!empty($data[$key]['spend_people'])) { + $data[$key]['ARPPU'] = round($data[$key]['spend']/$data[$key]['spend_people'],2); + } else { + $data[$key]['ARPPU'] = 0; } - +// if($data[$key]['register_num']==0&&$data[$key]['act_user']==0&&$data[$key]['keep_num']==0&&$data[$key]['spend']==0&&$data[$key]['spend_people']==0){ +// unset($data[$key]); +// } } $count=count($data); if($count > $row){ @@ -1180,6 +1211,7 @@ class StatController extends ThinkController $this->assign('list_data',$data); $this->display(); } + function game_analysis(){ if($_REQUEST['time-start']!=''&&$_REQUEST['time-end']!=''){ $start=$_REQUEST['time-start']; @@ -1375,7 +1407,7 @@ class StatController extends ThinkController $model = M('device_statistics','tab_'); if ($type == 0) { - $return = $model->sum('new_device'); + $return = $model->where(['time'=>['neq',0]])->sum('new_device'); // $return = $device->all_device(); } else if($type == 1) { $return = $model->where(['time'=>array('between',[$todaystart,$todaystart+86399])])->sum('new_device'); diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php index 5cd2b799a..2a089ff0e 100644 --- a/Application/Admin/Controller/TimingController.class.php +++ b/Application/Admin/Controller/TimingController.class.php @@ -141,9 +141,15 @@ class TimingController extends AdminController { //当日新增设备 $newSql = M('device_record','tab_')->field('min(create_time) as create_time,model,unique_code,id')->where(['version'=>1])->group('unique_code')->select(false); $data['new_device'] = M('device_record','tab_')->table('(' . $newSql . ') as a')->where(['create_time'=>array('between',[$startTime,$startTime+86399])])->order('create_time')->count(); + $data['time'] = $startTime; echo $data['new_device'].' '; + $duration = $this->duration(['create_time'=>array('between',[$startTime-86400*7,$startTime-1])]); + $newSqls = M('device_record','tab_')->field('min(create_time) as create_time,model,unique_code,id')->group('unique_code')->select(false); + $data['duration7'] = ($duration/M('device_record','tab_')->table('(' . $newSqls . ') as a')->where(['create_time'=>array('between',[$startTime-86400*7,$startTime-1])])->order('create_time')->count())/7; + $data['version'] = 1; + $getStatistics = M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>1])->find(); echo "\n"; if (!$getStatistics) { @@ -151,13 +157,14 @@ class TimingController extends AdminController { } else { M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>1])->save($data); } - + $data['duration7'] = 0; echo date("Y-m-d",$startTime).' 苹果 '; //当日新增设备 $newSql = M('device_record','tab_')->field('min(create_time) as create_time,model,unique_code,id')->where(['version'=>2])->group('unique_code')->select(false); $data['new_device'] = M('device_record','tab_')->table('(' . $newSql . ') as a')->where(['create_time'=>array('between',[$startTime,$startTime+86399])])->order('create_time')->count(); echo $data['new_device'].' '; + $data['version'] = 2; $getStatistics = M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>2])->find(); echo "\n"; diff --git a/Application/Admin/View/Member/device_bans_edit.html b/Application/Admin/View/Member/device_bans_edit.html index 275ac0adc..5d1ba903d 100644 --- a/Application/Admin/View/Member/device_bans_edit.html +++ b/Application/Admin/View/Member/device_bans_edit.html @@ -11,10 +11,13 @@