diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 11020033b..8205764a9 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -2,6 +2,7 @@ namespace Admin\Controller; use Think\Controller; +use GuzzleHttp\Client; class ExportController extends Controller { @@ -3029,7 +3030,91 @@ class ExportController extends Controller return $total; } - public function userretention_export($p = 0) + public function userretention_export() + { + $this->meta_title = '留存统计'; + $start = I('start', date('Y-m-d',strtotime('-7 day'))); + $end = empty(I('end')) ? time_format(time(),'Y-m-d') : I('end'); + $gameId = I('game_id', 0); + $promoteId = I('promote_id', 0); + + $status = true; + $data = false; + $error = ''; + if ($gameId == 0) { + $error = '请选择游戏!'; + $status = false; + } + $startTime = strtotime($start . ' 00:00:00'); + $endTime = strtotime($end . ' 23:59:59') + 1; + if ((($endTime - $startTime)/(24*3600)) > 31) { + $error = '时间间隔不能超过31天'; + $status = false; + } + if ($status) { + $client = new Client([ + 'base_uri' => C('PACKAGE_SERVER_URL'), + 'timeout' => 10.0, + ]); + $response = $client->post('/statistics/player-retention', [ + 'verify' => false, + 'form_params' => [ + 'start_time' => $start, + 'end_time' => $end, + 'promote_id' => I('promote_id', 0), + 'game_id' => $gameId, + ] + ]); + + $result = (string)$response->getBody(); + $result = json_decode($result, true); + if (!$result) { + $this->error('数据请求异常!'); + } + $gameName = get_game_name($gameId); + $promoteName = '全部'; + if ($promoteId) { + $promoteName = get_promote_account($promoteId); + } + $data = $result['data']['records']; + $dayList = [1, 2, 3, 4, 5, 6, 7, 15, 30]; + foreach ($data as $key => $item) { + $item['game_name'] = $gameName; + $item['promote_name'] = $promoteName; + foreach ($dayList as $day) { + if ($item['register_count'] > 0) { + $item['retention_day'. $day] = (round($item['retention_day'. $day]/$item['register_count'], 4)*100) . '%'; + } else { + $item['retention_day'. $day] = '--'; + } + } + $data[$key] = $item; + } + } else { + $this->error($error); + } + + $xlsCell = [ + ['date', "日期"], + ['game_name', "游戏名称"], + ['promote_name', "推广员账号"], + ['register_count', '新增玩家', 'time_format', '*'], + ['retention_day1', '1日留存', 'time_format', '*'], + ['retention_day2', '2日留存'], + ['retention_day3', "3日留存"], + ['retention_day4', '4日留存'], + ['retention_day5', '5日留存'], + ['retention_day6', '6日留存'], + ['retention_day7', '7日留存'], + ['retention_day15', '15日留存'], + ['retention_day30', '30日留存'], + ]; + $xlsData = $data; + $xlsName = $_REQUEST['xlsname']?$_REQUEST['xlsname']:'留存分析'; + $this->exportExcel($xlsName, $xlsCell, $xlsData); + } + + public function userretention($p = 0) { $request=$_REQUEST; $page = intval($p); diff --git a/Application/Admin/Controller/GameController.class.php b/Application/Admin/Controller/GameController.class.php index 0f5e8e217..842b87773 100644 --- a/Application/Admin/Controller/GameController.class.php +++ b/Application/Admin/Controller/GameController.class.php @@ -298,8 +298,8 @@ class GameController extends ThinkController $this->error('一句话简介不能超过30个字!'); exit; } - if (!preg_match("/^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+/i", $_POST['beta_url'])) { - return $this->error("请填写正确的Bata链接"); + if (!empty($_POST['beta_url']) && !preg_match("/^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+/i", $_POST['beta_url'])) { + return $this->error("请填写正确的Beta链接"); } /*if($_POST['apply_status']==0&&$_POST['game_status']==1){ $this->error('游戏未审核不允许显示');//游戏添加完成 diff --git a/Application/Admin/Controller/StatController.class.php b/Application/Admin/Controller/StatController.class.php index f5d287b7b..d1c7bc370 100644 --- a/Application/Admin/Controller/StatController.class.php +++ b/Application/Admin/Controller/StatController.class.php @@ -118,14 +118,25 @@ class StatController extends ThinkController public function multisort($records, $column, $type = 'asc') { - $records = index_by_column($column, $records); - // var_dump($records);die(); - if ($type == 'asc') { - ksort($records); - } else { - krsort($records); + $length = count($records); + for ($i = 0; $i < $length; $i ++) { + for ($j = $i + 1; $j < $length; $j ++) { + if ($type == 'asc') { + if ($records[$i][$column] > $records[$j][$column]) { + $temp = $records[$i]; + $records[$i] = $records[$j]; + $records[$j] = $temp; + } + } else if ($type == 'desc') { + if ($records[$i][$column] < $records[$j][$column]) { + $temp = $records[$i]; + $records[$i] = $records[$j]; + $records[$j] = $temp; + } + } + } } - return array_values($records); + return $records; } public function userretention() @@ -135,6 +146,16 @@ class StatController extends ThinkController $end = empty(I('end')) ? time_format(time(),'Y-m-d') : I('end'); $dataOrder = I('data_order', ''); $gameId = I('game_id', 0); + $promoteId = I('promote_id', 0); + + $orderType = 'asc'; + $orderColumn = 'date'; + if ($dataOrder != '') + { + $dataOrder = explode(',', $dataOrder); + $orderType = $dataOrder[1]; + $orderColumn = $dataOrder[0]; + } $status = true; $data = false; @@ -171,7 +192,14 @@ class StatController extends ThinkController } $data = $result['data']['records']; $dayList = [1, 2, 3, 4, 5, 6, 7, 15, 30]; + $gameName = get_game_name($gameId); + $promoteName = '全部'; + if ($promoteId) { + $promoteName = get_promote_account($promoteId); + } foreach ($data as $key => $item) { + $item['promote_name'] = $promoteName; + $item['game_name'] = $gameName; foreach ($dayList as $day) { if ($item['register_count'] > 0) { $item['retention_day'. $day] = round($item['retention_day'. $day]/$item['register_count'], 4)*100; @@ -182,12 +210,15 @@ class StatController extends ThinkController $data[$key] = $item; } if ($dataOrder) { - $data = $this->multisort($data, $dataOrder); + $data = $this->multisort($data, $orderColumn, $orderType); } } else { $this->assign('error', $error); } + $this->assign('data', $data); + $this->assign('order_type', $orderType); + $this->assign('order_column', $orderColumn); $this->assign('data', $data); $this->meta_title = '留存统计'; $this->display(); diff --git a/Application/Admin/View/FinancePromote/gameCoinDetail.html b/Application/Admin/View/FinancePromote/gameCoinDetail.html index 4bafe9375..9995cfcc9 100644 --- a/Application/Admin/View/FinancePromote/gameCoinDetail.html +++ b/Application/Admin/View/FinancePromote/gameCoinDetail.html @@ -11,6 +11,8 @@ + +
@@ -134,6 +156,7 @@