|
|
|
@ -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);
|
|
|
|
|