From 67dd874ccff74cdbe85079060ade40bc55cc3009 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Tue, 24 Dec 2019 11:51:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/StatController.class.php | 29 +++++++- .../Admin/View/Stat/userretention.html | 72 ++++++++++--------- .../Home/Controller/QueryController.class.php | 2 +- 3 files changed, 67 insertions(+), 36 deletions(-) diff --git a/Application/Admin/Controller/StatController.class.php b/Application/Admin/Controller/StatController.class.php index 7310b44c5..bc94fcf0b 100644 --- a/Application/Admin/Controller/StatController.class.php +++ b/Application/Admin/Controller/StatController.class.php @@ -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); } diff --git a/Application/Admin/View/Stat/userretention.html b/Application/Admin/View/Stat/userretention.html index b6ab5e513..890749641 100644 --- a/Application/Admin/View/Stat/userretention.html +++ b/Application/Admin/View/Stat/userretention.html @@ -74,7 +74,7 @@ - 日期 + 日期 @@ -88,23 +88,23 @@ 新增玩家 - 1日留存 + 1日留存 - 2日留存 + 2日留存 - 3日留存 + 3日留存 - 4日留存 + 4日留存 - 5日留存 + 5日留存 - 6日留存 + 6日留存 - 7日留存 + 7日留存 - 15日留存 + 15日留存 - 30日留存 + 30日留存 @@ -117,22 +117,34 @@ {$vo.date} - + {$game_name} - - + + {$promote_name} - + {$vo.register_count} - {:round($vo['retention_day1']/$vo['register_count'],4)*100}% - {:round($vo['retention_day2']/$vo['register_count'],4)*100}% - {:round($vo['retention_day3']/$vo['register_count'],4)*100}% - {:round($vo['retention_day4']/$vo['register_count'],4)*100}% - {:round($vo['retention_day5']/$vo['register_count'],4)*100}% - {:round($vo['retention_day6']/$vo['register_count'],4)*100}% - {:round($vo['retention_day7']/$vo['register_count'],4)*100}% - {:round($vo['retention_day15']/$vo['register_count'],4)*100}% - {:round($vo['retention_day30']/$vo['register_count'],4)*100}% + 0):?> + {$vo['retention_day1']}% + {$vo['retention_day2']}% + {$vo['retention_day3']}% + {$vo['retention_day4']}% + {$vo['retention_day5']}% + {$vo['retention_day6']}% + {$vo['retention_day7']}% + {$vo['retention_day15']}% + {$vo['retention_day30']}% + + -- + -- + -- + -- + -- + -- + -- + -- + -- + @@ -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){ diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index 76728d4cf..d5806068c 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -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;