From 84174b18e9ce42ff3ad7cd93546b8f9832ab0c05 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Thu, 17 Oct 2019 14:02:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Base/Repository/SpendRepository.class.php | 14 +- .../Base/Repository/UserRepository.class.php | 6 +- .../Home/Controller/QueryController.class.php | 33 ++- Application/Home/View/default/Query/arpu.html | 4 +- .../Home/View/default/Query/gameArpu.html | 280 ++++++++++++++++++ 5 files changed, 316 insertions(+), 21 deletions(-) create mode 100644 Application/Home/View/default/Query/gameArpu.html diff --git a/Application/Base/Repository/SpendRepository.class.php b/Application/Base/Repository/SpendRepository.class.php index c7409113e..5b9431ab6 100644 --- a/Application/Base/Repository/SpendRepository.class.php +++ b/Application/Base/Repository/SpendRepository.class.php @@ -71,18 +71,6 @@ class SpendRepository { return $this->assembleRecords($items, $dayList, 'count'); } - /** - * 付费游戏数 - */ - public function getPayGameCountGroupByGame($params) - { - $gameIds = $params['game_ids'] ?? []; - $conditions = $this->getGameGroupConditions($params); - $field = 'game_id, count(*) count'; - $items = M('spend', 'tab_')->field($field)->where($conditions)->group('game_id')->select(); - return $this->assembleRecords($items, $gameIds, 'count', 'game_id'); - } - /** * 按天统计付款总额 */ @@ -124,7 +112,7 @@ class SpendRepository { $conditions = $this->getGameGroupConditions($params); $field = 'game_id, count(distinct user_id) count'; $items = M('spend', 'tab_')->field($field)->where($conditions)->group('game_id')->select(); - return $this->assembleRecords($items, $dayList, 'count', 'game_id'); + return $this->assembleRecords($items, $gameIds, 'count', 'game_id'); } /** diff --git a/Application/Base/Repository/UserRepository.class.php b/Application/Base/Repository/UserRepository.class.php index 696379bb5..0f58c6834 100644 --- a/Application/Base/Repository/UserRepository.class.php +++ b/Application/Base/Repository/UserRepository.class.php @@ -112,11 +112,11 @@ class UserRepository { $params['time_column'] = 'register_time'; $conditions = $this->getGameGroupConditions($params); - $items = M('user', 'tab_')->field('count(*) count, game_id') + $items = M('user', 'tab_')->field('count(*) count, fgame_id') ->where($conditions) - ->group('game_id') + ->group('fgame_id') ->select(); - return $this->assembleRecords($items, $gameIds, 'count', 'game_id'); + return $this->assembleRecords($items, $gameIds, 'count', 'fgame_id'); } /** diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index 933295615..ce7a00127 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -760,6 +760,7 @@ class QueryController extends BaseController $time = I('time', date('Y-m-d')); $applys = M('Apply', 'tab_')->field('game_id, game_name')->where(['promote_id' => $promote['id']])->order('game_id desc')->select(); $gameIds = array_column($applys, 'game_id'); + $applys = index_by_column('game_id', $applys); $params = [ 'begin_time' => strtotime($time . ' 00:00:00'), @@ -768,10 +769,36 @@ class QueryController extends BaseController 'promote_ids' => $ids, ]; + $userRepository = new UserRepository(); $spendRepository = new SpendRepository(); - // $result = $spendRepository->getHistoryPayCountGroupByGame($params); - $result = $spendRepository->getPayGameCountGroupByGame($params); - var_dump($result); + $payUserCountList = $spendRepository->getPayUserCountGroupByGame($params); + $newPayUserCountList = $spendRepository->getNewPayUserCountGroupByGame($params); + $payAmountList = $spendRepository->getPayAmountGroupByGame($params); + $newPayAmountList = $spendRepository->getNewPayAmountGroupByGame($params); + $historyPayCountList = $spendRepository->getHistoryPayCountGroupByGame($params); + $loginCountList = $userRepository->getLoginCountGroupByGame($params); + $registerCountList = $userRepository->getRegisterCountGroupByGame($params); + + foreach ($gameIds as $gameId) { + $records[] = [ + 'gameId' => $gameId, + 'gameName' => $applys[$gameId]['game_name'], + 'payUserCount' => $payUserCountList[$gameId], + 'newPayUserCount' => $newPayUserCountList[$gameId], + 'payAmount' => number_format($payAmountList[$gameId], 2), + 'newPayAmount' => number_format($newPayAmountList[$gameId], 2), + 'historyPayCount' => $historyPayCountList[$gameId], + 'loginCount' => $loginCountList[$gameId], + 'registerCount' => $registerCountList[$gameId], + 'payRate' => $loginCountList[$gameId] == 0 ? '--' : round($payUserCountList[$gameId] / $loginCountList[$gameId] * 100, 2) . '%', + 'ratentionOneDay' => '--', + 'arpu' => $loginCountList[$gameId] == 0 ? '0.00' : number_format(round($payAmountList[$gameId] / $loginCountList[$gameId], 2), 2), + 'arppu' => $payUserCountList[$gameId] == 0 ? '0.00' : number_format(round($payAmountList[$gameId] / $payUserCountList[$gameId], 2), 2), + ]; + } + + $this->assign('records', $records); + $this->display('gameArpu'); } public function arpu_analysis() diff --git a/Application/Home/View/default/Query/arpu.html b/Application/Home/View/default/Query/arpu.html index 0ec23603b..f5d6c5108 100644 --- a/Application/Home/View/default/Query/arpu.html +++ b/Application/Home/View/default/Query/arpu.html @@ -223,7 +223,7 @@
游戏名称 | +新增玩家 | +活跃玩家 | +充值金额 | +付费玩家 | +新增付费用户 | +付费率 | +ARPU | +ARPPU | +||
---|---|---|---|---|---|---|---|---|---|---|
暂无数据 | ||||||||||
{$record.gameName} | +{$record.registerCount} | +{$record.loginCount} | +{$record.payAmount} | +{$record.payUserCount} | +{$record.newPayUserCount} | +{$record.payRate} | +{$record.arpu} | +{$record.arppu} | +