优化curl

master
ELF 5 years ago
parent 0af6a53ba7
commit 486b5e1f83

@ -145,7 +145,8 @@ class StatController extends ThinkController
$start = I('start', date('Y-m-d',strtotime('-7 day'))); $start = I('start', date('Y-m-d',strtotime('-7 day')));
$end = empty(I('end')) ? time_format(time(),'Y-m-d') : I('end'); $end = empty(I('end')) ? time_format(time(),'Y-m-d') : I('end');
$dataOrder = I('data_order', ''); $dataOrder = I('data_order', '');
$gameId = I('game_id', 0); $baseGameId = I('game_id', 0);
$deviceType = I('device_type', '');
$promoteId = I('promote_id', 0); $promoteId = I('promote_id', 0);
$orderType = 'asc'; $orderType = 'asc';
@ -160,10 +161,14 @@ class StatController extends ThinkController
$status = true; $status = true;
$data = false; $data = false;
$error = ''; $error = '';
if ($gameId == 0) { if ($baseGameId == 0) {
$error = '请选择游戏!'; $error = '请选择游戏!';
$status = false; $status = false;
} }
if ($deviceType == '') {
$error = '请选择设备类型!';
$status = false;
}
$startTime = strtotime($start . ' 00:00:00'); $startTime = strtotime($start . ' 00:00:00');
$endTime = strtotime($end . ' 23:59:59') + 1; $endTime = strtotime($end . ' 23:59:59') + 1;
if ((($endTime - $startTime)/(24*3600)) > 31) { if ((($endTime - $startTime)/(24*3600)) > 31) {
@ -171,6 +176,10 @@ class StatController extends ThinkController
$status = false; $status = false;
} }
if ($status) { if ($status) {
$baseGame = M('base_game', 'tab_')->where(['id' => $baseGameId])->find();
$gameId = $deviceType == 'android' ? $baseGame['android_game_id'] : $baseGame['ios_game_id'];
$client = new Client([ $client = new Client([
'base_uri' => C('TASK_URL'), 'base_uri' => C('TASK_URL'),
'timeout' => 10.0, 'timeout' => 10.0,
@ -216,7 +225,9 @@ class StatController extends ThinkController
$this->assign('error', $error); $this->assign('error', $error);
} }
$this->assign('data', $data); $baseGames = M('base_game', 'tab_')->select();
$this->assign('baseGames', $baseGames);
$this->assign('order_type', $orderType); $this->assign('order_type', $orderType);
$this->assign('order_column', $orderColumn); $this->assign('order_column', $orderColumn);
$this->assign('data', $data); $this->assign('data', $data);
@ -675,9 +686,10 @@ AND UNIX_TIMESTAMP(
{ {
$start = I('start', date('Y-m-d')); $start = I('start', date('Y-m-d'));
$end = I('end', date('Y-m-d')); $end = I('end', date('Y-m-d'));
$gameIds = I('game_ids', ''); $baseGameIds = I('game_ids', '');
$promoteId = I('promote_id', 0); $promoteId = I('promote_id', 0);
$dataOrder = I('data_order', ''); $dataOrder = I('data_order', '');
$deviceType = I('device_type', '');
$containBindCoins = I('contain_bind_coins', 0); $containBindCoins = I('contain_bind_coins', 0);
$orderType = ''; $orderType = '';
@ -697,15 +709,42 @@ AND UNIX_TIMESTAMP(
$startTime = strtotime($start . ' 00:00:00'); $startTime = strtotime($start . ' 00:00:00');
$endTime = strtotime($end . ' 23:59:59'); $endTime = strtotime($end . ' 23:59:59');
$gameIdRows = $gameIds ? explode(',', $gameIds) : []; $baseGameIdRows = $baseGameIds ? explode(',', $baseGameIds) : [];
$baseGames = M('base_game', 'tab_')->select();
$gameIds = null;
$conditions = []; $conditions = [];
if (count($gameIdRows)) { if (count($baseGameIdRows)) {
$conditions['game_id'] = ['in', $gameIdRows]; $tmpBaseGames = M('base_game', 'tab_')->where(['id' => ['in', $baseGameIdRows]])->select();
$gameIds = array_merge(array_column($tmpBaseGames, 'android_game_id'), array_column($tmpBaseGames, 'ios_game_id'));
} }
if (count($promoteIds)) { if (count($promoteIds)) {
$conditions['promote_id'] = ['in', $promoteIds]; $conditions['promote_id'] = ['in', $promoteIds];
} }
if ($deviceType != '') {
if ($gameIds) {
$gameIds = (
$deviceType == 'android' ?
array_intersect($gameIds, array_column($baseGames, 'android_game_id')) :
array_intersect($gameIds, array_column($baseGames, 'ios_game_id'))
);
} else {
$gameIds = (
$deviceType == 'android' ?
array_column($baseGames, 'android_game_id') :
array_column($baseGames, 'ios_game_id')
);
}
}
if ($gameIds && count($gameIds)) {
if (count($gameIds)) {
$conditions['game_id'] = ['in', $gameIds];
} else {
$conditions['game_id'] = ['in', 0];
}
}
// 新增用户 // 新增用户
/* M('user', 'tab_') /* M('user', 'tab_')
@ -795,6 +834,7 @@ AND UNIX_TIMESTAMP(
} }
$this->meta_title = 'ARPU统计'; $this->meta_title = 'ARPU统计';
$this->assign('baseGames', $baseGames);
$this->assign('records', $rows); $this->assign('records', $rows);
$this->assign('order', $order); $this->assign('order', $order);
$this->assign('orderType', $orderType); $this->assign('orderType', $orderType);

@ -105,9 +105,16 @@
<div class="input-list input-list-game search_label_rehab"> <div class="input-list input-list-game search_label_rehab">
<select id="game_ids" name="game_ids" class="select_gallery"> <select id="game_ids" name="game_ids" class="select_gallery">
<option value="">请选择游戏</option> <option value="">请选择游戏</option>
<volist name=":get_game_list()" id="vo"> <?php foreach($baseGames as $baseGame):?>
<option game-id="{$vo.game_name}" value="{$vo.id}">{$vo.game_name}</option> <option game-id="<?= $baseGame['id'] ?>" value="<?= $baseGame['id'] ?>"><?= $baseGame['name'] ?></option>
</volist> <?php endforeach;?>
</select>
</div>
<div class="input-list input-list-game search_label_rehab">
<select id="device_type" name="device_type" class="select_gallery">
<option value="">请选择设备类型</option>
<option value="android" <?php if(I('device_type', '') == 'android'):?>selected<?php endif;?>>安卓</option>
<option value="ios" <?php if(I('device_type', '') == 'ios'):?>selected<?php endif;?>>IOS</option>
</select> </select>
</div> </div>
<div class="input-list input-list-promote search_label_rehab"> <div class="input-list input-list-promote search_label_rehab">
@ -173,6 +180,7 @@
'end'=>$_GET['end'], 'end'=>$_GET['end'],
'game_ids'=>$_GET['game_ids'], 'game_ids'=>$_GET['game_ids'],
'promote_id'=>$_GET['promote_id'], 'promote_id'=>$_GET['promote_id'],
'device_type'=>$_GET['device_type'],
'export'=>1, 'export'=>1,
),false)}">导出</a> ),false)}">导出</a>
{$_page|default=''} {$_page|default=''}
@ -187,6 +195,7 @@ Think.setValue('start',"{$Think.get.start|default=''}");
Think.setValue('end',"{$Think.get.end|default=''}"); Think.setValue('end',"{$Think.get.end|default=''}");
Think.setValue('promote_id',{$Think.get.promote_id|default='""'}); Think.setValue('promote_id',{$Think.get.promote_id|default='""'});
Think.setValue('game_ids',{$Think.get.game_ids|default='""'}); Think.setValue('game_ids',{$Think.get.game_ids|default='""'});
Think.setValue('device_type',{$Think.get.device_type|default='""'});
Think.setValue('row',{$Think.get.row|default=10}); Think.setValue('row',{$Think.get.row|default=10});
$(".select_gallery").select2(); $(".select_gallery").select2();
</script> </script>

@ -47,10 +47,17 @@
<div class="input-list search_label_rehab"> <div class="input-list search_label_rehab">
<select id="game_id" name="game_id" class="select_gallery"> <select id="game_id" name="game_id" class="select_gallery">
<option value="">请选择游戏</option> <option value="">请选择游戏</option>
<volist name=":get_game_list()" id="vo"> <?php foreach($baseGames as $baseGame):?>
<option game-id="{$vo.id}" value="{$vo.id}">{$vo.game_name}</option> <option game-id="<?= $baseGame['id'] ?>" value="<?= $baseGame['id'] ?>"><?= $baseGame['name'] ?></option>
</volist> <?php endforeach;?>
</select> </select>
</div>
<div class="input-list search_label_rehab">
<select id="device_type" name="device_type" class="select_gallery">
<option value="">请选择设备类型</option>
<option value="android" <?php if(I('device_type', '') == 'android'):?>selected<?php endif;?>>安卓</option>
<option value="ios" <?php if(I('device_type', '') == 'ios'):?>selected<?php endif;?>>IOS</option>
</select>
</div> </div>
<div class="input-list input-list-promote search_label_rehab"> <div class="input-list input-list-promote search_label_rehab">
<select id="promote_id" name="promote_id" class="select_gallery" > <select id="promote_id" name="promote_id" class="select_gallery" >

Loading…
Cancel
Save