master
ELF 5 years ago
parent 8d934c8d88
commit 67dd874ccf

@ -114,13 +114,26 @@ class StatController extends ThinkController
$this->display();
}
}
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);
}
return array_values($records);
}
public function userretention()
{
$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');
$dataOrder = I('data_order', '');
$gameId = I('game_id', 0);
$status = true;
@ -157,6 +170,20 @@ class StatController extends ThinkController
$this->assign('error', '数据请求异常!');
}
$data = $result['data']['records'];
$dayList = [1, 2, 3, 4, 5, 6, 7, 15, 30];
foreach ($data as $key => $item) {
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;
}
if ($dataOrder) {
$data = $this->multisort($data, $dataOrder);
}
} else {
$this->assign('error', $error);
}

@ -74,7 +74,7 @@
<!-- 表头 -->
<thead>
<tr>
<th ><a class="paixu" data-order='time'>日期</a></th>
<th ><a class="paixu" data-order='date'>日期</a></th>
<if condition="$game_name neq ''">
@ -88,23 +88,23 @@
<th ><a class="paixu" data-order='register_count'>新增玩家</a></th>
<th ><a class="paixu" data-order='1'>1日留存</a></th>
<th ><a class="paixu" data-order='retention_day1'>1日留存</a></th>
<th ><a class="paixu" data-order='2'>2日留存</a></th>
<th ><a class="paixu" data-order='retention_day2'>2日留存</a></th>
<th ><a class="paixu" data-order='3'>3日留存</a></th>
<th ><a class="paixu" data-order='retention_day3'>3日留存</a></th>
<th ><a class="paixu" data-order='4'>4日留存</a></th>
<th ><a class="paixu" data-order='retention_day4'>4日留存</a></th>
<th ><a class="paixu" data-order='5'>5日留存</a></th>
<th ><a class="paixu" data-order='retention_day5'>5日留存</a></th>
<th ><a class="paixu" data-order='6'>6日留存</a></th>
<th ><a class="paixu" data-order='retention_day6'>6日留存</a></th>
<th ><a class="paixu" data-order='7'>7日留存</a></th>
<th ><a class="paixu" data-order='retention_day7'>7日留存</a></th>
<th ><a class="paixu" data-order='15'>15日留存</a></th>
<th ><a class="paixu" data-order='retention_day15'>15日留存</a></th>
<th ><a class="paixu" data-order='30'>30日留存</a></th>
<th ><a class="paixu" data-order='retention_day30'>30日留存</a></th>
</tr>
</thead>
<!-- 列表 -->
@ -117,22 +117,34 @@
<volist name="data" id="vo">
<tr>
<td>{$vo.date}</td>
<if condition="$game_name neq ''">
<if condition="$game_name neq ''">
<td>{$game_name}</td>
</if>
<if condition="$promote_name neq ''">
</if>
<if condition="$promote_name neq ''">
<td>{$promote_name}</td>
</if>
</if>
<td>{$vo.register_count}</td>
<td>{:round($vo['retention_day1']/$vo['register_count'],4)*100}%</td>
<td>{:round($vo['retention_day2']/$vo['register_count'],4)*100}%</td>
<td>{:round($vo['retention_day3']/$vo['register_count'],4)*100}%</td>
<td>{:round($vo['retention_day4']/$vo['register_count'],4)*100}%</td>
<td>{:round($vo['retention_day5']/$vo['register_count'],4)*100}%</td>
<td>{:round($vo['retention_day6']/$vo['register_count'],4)*100}%</td>
<td>{:round($vo['retention_day7']/$vo['register_count'],4)*100}%</td>
<td>{:round($vo['retention_day15']/$vo['register_count'],4)*100}%</td>
<td>{:round($vo['retention_day30']/$vo['register_count'],4)*100}%</td>
<?php if ($vo['register_count']>0):?>
<td>{$vo['retention_day1']}%</td>
<td>{$vo['retention_day2']}%</td>
<td>{$vo['retention_day3']}%</td>
<td>{$vo['retention_day4']}%</td>
<td>{$vo['retention_day5']}%</td>
<td>{$vo['retention_day6']}%</td>
<td>{$vo['retention_day7']}%</td>
<td>{$vo['retention_day15']}%</td>
<td>{$vo['retention_day30']}%</td>
<?php else:?>
<td>--</td>
<td>--</td>
<td>--</td>
<td>--</td>
<td>--</td>
<td>--</td>
<td>--</td>
<td>--</td>
<td>--</td>
<?php endif;?>
</tr>
</volist>
</empty>
@ -218,17 +230,9 @@ $(function(){
var that=$(this);
$data_order=that.attr('data-order');
$order_type='{$userarpu_order}';
if($order_type==''||$order_type=='4'){
$(".sortBy").attr('name','data_order');
val='3,'+$data_order;
$(".sortBy").attr('value',val);
$("#search").click();
}else if($order_type=='3'){
$(".sortBy").attr('name','data_order');
val='4,'+$data_order;
$(".sortBy").attr('value',val);
$("#search").click();
}
$(".sortBy").attr('name','data_order');
$(".sortBy").attr('value',$data_order);
$("#search").click();
});
//回车自动提交
$('.jssearch').find('input').keyup(function(event){

@ -1762,7 +1762,7 @@ class QueryController extends BaseController
$sortName = trim(I('sort_name', ''));
$sort = intval(I('sort', 1));
$sortNameData = ['recharge_cost', 'recharge_count', 'recharge_cost_today', 'unlogin_day', 'create_time', 'user_game_login_count'];
$nowTime = date('Y-m-d', time() - 3600 * 24);
$nowTime = date('Y-m-d', time());
$initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime)));
$initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime');
$initEndTime = $nowTime;

Loading…
Cancel
Save