From 1e8735f17379d96b9981936f999eef357443b270 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Wed, 18 Dec 2019 15:26:43 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Data/update.sql | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Data/update.sql b/Data/update.sql index 292053b26..3b2695945 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -714,4 +714,22 @@ INSERT INTO `sys_menu`(`title`, `pid`, `sort`, `url`, `hide`, `tip`, `group`, `i --2019-12-13 --游戏添加落地页视频封面 ALTER TABLE `tab_game` -ADD COLUMN `flooring_page_video_cover` int(11) NOT NULL DEFAULT 0 COMMENT '落地页视频封面'; \ No newline at end of file +ADD COLUMN `flooring_page_video_cover` int(11) NOT NULL DEFAULT 0 COMMENT '落地页视频封面'; + +CREATE TABLE `tab_user_retention` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) not null COMMENT '用户ID', + `game_id` int(11) NOT NULL COMMENT '游戏ID', + `day1` tinyint(1) NOT NULL default 0 COMMENT '是否1日留存', + `day2` tinyint(1) NOT NULL default 0 COMMENT '是否2日留存', + `day3` tinyint(1) NOT NULL default 0 COMMENT '是否3日留存', + `day4` tinyint(1) NOT NULL default 0 COMMENT '是否4日留存', + `day5` tinyint(1) NOT NULL default 0 COMMENT '是否5日留存', + `day6` tinyint(1) NOT NULL default 0 COMMENT '是否6日留存', + `day7` tinyint(1) NOT NULL default 0 COMMENT '是否7日留存', + `day15` tinyint(1) NOT NULL default 0 COMMENT '是否15日留存', + `day30` tinyint(1) NOT NULL default 0 COMMENT '是否30日留存', + PRIMARY KEY (`id`), + KEY `game_id` (`game_id`), + KEY `user_id` (`user_id`), +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户留存率'; \ No newline at end of file From 12fd7ac4e9ac0126e4b3fed6103b49e63c55ceba Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Fri, 20 Dec 2019 18:20:35 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Data/update.sql | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Data/update.sql b/Data/update.sql index 3b2695945..4e720663a 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -716,10 +716,11 @@ INSERT INTO `sys_menu`(`title`, `pid`, `sort`, `url`, `hide`, `tip`, `group`, `i ALTER TABLE `tab_game` ADD COLUMN `flooring_page_video_cover` int(11) NOT NULL DEFAULT 0 COMMENT '落地页视频封面'; -CREATE TABLE `tab_user_retention` ( +CREATE TABLE `tab_player_retention` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) not null COMMENT '用户ID', `game_id` int(11) NOT NULL COMMENT '游戏ID', + `player_id` int(11) NOT NULL COMMENT '玩家ID', `day1` tinyint(1) NOT NULL default 0 COMMENT '是否1日留存', `day2` tinyint(1) NOT NULL default 0 COMMENT '是否2日留存', `day3` tinyint(1) NOT NULL default 0 COMMENT '是否3日留存', @@ -730,6 +731,12 @@ CREATE TABLE `tab_user_retention` ( `day15` tinyint(1) NOT NULL default 0 COMMENT '是否15日留存', `day30` tinyint(1) NOT NULL default 0 COMMENT '是否30日留存', PRIMARY KEY (`id`), - KEY `game_id` (`game_id`), - KEY `user_id` (`user_id`), -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户留存率'; \ No newline at end of file + KEY `index_game_id` (`game_id`), + KEY `index_user_id` (`user_id`), + KEY `index_player_id` (`player_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户留存率'; +-- 玩家注册时间 +ALTER TABLE `tab_user_play` +ADD COLUMN `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '玩家注册时间'; + +update tab_user_play a left join tab_user b on a.user_id= b.id set a.create_time = b.register_time where a.user_id=b.id; \ No newline at end of file From 8d934c8d881fa033028b7149a819c93d027e47a4 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 23 Dec 2019 16:35:45 +0800 Subject: [PATCH 3/4] =?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 | 54 ++- .../Admin/View/Stat/userretention.html | 45 ++- .../Admin/View/Stat/userretention1.html | 338 ++++++++++++++++++ Data/update.sql | 4 +- 4 files changed, 416 insertions(+), 25 deletions(-) create mode 100644 Application/Admin/View/Stat/userretention1.html diff --git a/Application/Admin/Controller/StatController.class.php b/Application/Admin/Controller/StatController.class.php index 163fe452a..7310b44c5 100644 --- a/Application/Admin/Controller/StatController.class.php +++ b/Application/Admin/Controller/StatController.class.php @@ -5,6 +5,7 @@ use Admin\Model\SpendModel; use Open\Model\UserLoginRecordModel; use Admin\Model\UserPlayModel; use User\Api\UserApi as UserApi; +use GuzzleHttp\Client; /** * 后台首页控制器 @@ -115,13 +116,64 @@ class StatController extends ThinkController } + 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'); + $gameId = I('game_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->assign('error', '数据请求异常!'); + } + $data = $result['data']['records']; + } else { + $this->assign('error', $error); + } + + $this->assign('data', $data); + $this->meta_title = '留存统计'; + $this->display(); + } + + /** * 留存统计 * @param int $p * 06.12.3 * xmy */ - public function userretention($p = 0) + public function playerRetention($p = 0) { echo "暂不开放"; die(); diff --git a/Application/Admin/View/Stat/userretention.html b/Application/Admin/View/Stat/userretention.html index 2a4cdc821..b6ab5e513 100644 --- a/Application/Admin/View/Stat/userretention.html +++ b/Application/Admin/View/Stat/userretention.html @@ -86,7 +86,7 @@ 渠道名称 - 新增玩家 + 新增玩家 1日留存 @@ -111,28 +111,28 @@ - aOh! 暂时还没有内容! + ' . $error . '': 'aOh! 暂时还没有内容!' ?> - {$vo.time} + {$vo.date} {$game_name} {$promote_name} - {$vo.register_num} - {:round($vo['1']/$vo['register_num'],4)*100}% - {:round($vo['2']/$vo['register_num'],4)*100}% - {:round($vo['3']/$vo['register_num'],4)*100}% - {:round($vo['4']/$vo['register_num'],4)*100}% - {:round($vo['5']/$vo['register_num'],4)*100}% - {:round($vo['6']/$vo['register_num'],4)*100}% - {:round($vo['7']/$vo['register_num'],4)*100}% - {:round($vo['15']/$vo['register_num'],4)*100}% - {:round($vo['30']/$vo['register_num'],4)*100}% + {$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}% @@ -141,15 +141,14 @@
- 导出 - {$_page|default=''} + 导出
@@ -169,7 +168,7 @@ $(".select_gallery").select2(); + + + + + + +
+ +
+
+ +
+
+ +  -  + +
+
+ +
+
+ +
+ +
+ 搜索 +
+
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
日期游戏名称渠道名称新增玩家1日留存2日留存3日留存4日留存5日留存6日留存7日留存15日留存30日留存
aOh! 暂时还没有内容!
{$vo.time}{$game_name}{$promote_name}{$vo.register_num}{:round($vo['1']/$vo['register_num'],4)*100}%{:round($vo['2']/$vo['register_num'],4)*100}%{:round($vo['3']/$vo['register_num'],4)*100}%{:round($vo['4']/$vo['register_num'],4)*100}%{:round($vo['5']/$vo['register_num'],4)*100}%{:round($vo['6']/$vo['register_num'],4)*100}%{:round($vo['7']/$vo['register_num'],4)*100}%{:round($vo['15']/$vo['register_num'],4)*100}%{:round($vo['30']/$vo['register_num'],4)*100}%
+
+
+
+ 导出 + {$_page|default=''} +
+ + + + + + +if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + + diff --git a/Data/update.sql b/Data/update.sql index 4e720663a..3075a87c6 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -739,4 +739,6 @@ CREATE TABLE `tab_player_retention` ( ALTER TABLE `tab_user_play` ADD COLUMN `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '玩家注册时间'; -update tab_user_play a left join tab_user b on a.user_id= b.id set a.create_time = b.register_time where a.user_id=b.id; \ No newline at end of file +update tab_user_play a left join tab_user b on a.user_id= b.id set a.create_time = b.register_time where a.user_id=b.id; +ALTER TABLE `tab_spend` +ADD COLUMN `event_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '事件是否通知''; 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 4/4] =?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;