diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php
index f18dc1a52..e798f6e3d 100644
--- a/Application/Admin/Controller/CompanyStatementSetController.class.php
+++ b/Application/Admin/Controller/CompanyStatementSetController.class.php
@@ -1702,7 +1702,7 @@ class CompanyStatementSetController extends Controller {
if(empty($rfres)){
return false;
}else{
- $rfres;
+ return $rfres;
}
}
/**
diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php
index 33c4cc40f..3c10092fa 100644
--- a/Application/Admin/Controller/ConsoleController.class.php
+++ b/Application/Admin/Controller/ConsoleController.class.php
@@ -13,6 +13,7 @@ use think\Db;
use Base\Task\Task;
use Base\Service\MarketService;
use Base\Tool\AggregateClient;
+use Base\Repository\GameRepository;
class ConsoleController extends Think {
@@ -600,7 +601,7 @@ class ConsoleController extends Think {
// ARPU (当日充值金额/当日活跃用户数)
// ARRPU (当日充值金额/当日充值用户数)
}
-
+
public function checkAndfreezeTestingUser()
{
$pageCount = 100;
@@ -635,8 +636,34 @@ class ConsoleController extends Think {
} while($hasNext);
}
- public function testIp()
+ public function statUserRetention()
{
- var_dump(\Base\Tool\IPTool::getIpInfo('120.35.40.249'));
+ $begin = I('begin', date('Y-m-d'));
+ $end = I('end', date('Y-m-d'));
+ $baseGameId = I('base_game_id', 0);
+
+ $repository = new GameRepository();
+ $baseGame = M('base_game', 'tab_')->where(['id' => $baseGameId])->find();
+
+ $beginDate = strtotime($begin);
+ $endDate = strtotime($end);
+ $dayTime = 24 * 3600;
+
+ $trs = '';
+ for ($date = $beginDate; $date <= $endDate; $date = $date + $dayTime) {
+ $dateStr = date('Y-m-d', $date);
+ $userRegisterCount = $repository->getUserRegisterCount($baseGame, $dateStr);
+ $userRetentionCount60 = $repository->getUserRetentionCount($baseGame, $dateStr, 60);
+ $userRetentionCount90 = $repository->getUserRetentionCount($baseGame, $dateStr, 90);
+ $trs .= '
' . PHP_EOL;
+ $trs .= '' . $dateStr . ' | ' . PHP_EOL;
+ $trs .= '' . $userRegisterCount . ' | ' . PHP_EOL;
+ $trs .= '' . $userRetentionCount60 . ' | ' . PHP_EOL;
+ $trs .= '' . $userRetentionCount90 . ' | ' . PHP_EOL;
+ $trs .= '' . round($userRetentionCount60 / $userRegisterCount * 100, 2) . '%' . ' | ' . PHP_EOL;
+ $trs .= '' . round($userRetentionCount90 / $userRegisterCount * 100, 2) . '%' . ' | ' . PHP_EOL;
+ $trs .= '
'. PHP_EOL;
+ }
+ echo '';
}
}
diff --git a/Application/Base/Repository/GameRepository.class.php b/Application/Base/Repository/GameRepository.class.php
index 25e3d44e0..3e358037e 100644
--- a/Application/Base/Repository/GameRepository.class.php
+++ b/Application/Base/Repository/GameRepository.class.php
@@ -53,4 +53,57 @@ class GameRepository
->order('server_id asc')
->select();
}
+
+ public function getGameIdsByBaseGame($baseGame, $deviceType = 0)
+ {
+ $gameIds = [];
+ if ($deviceType == 1) {
+ $gameIds[] = $baseGame['android_game_id'];
+ } elseif ($deviceType == 2) {
+ $gameIds[] = $baseGame['ios_game_id'];
+ } else {
+ $gameIds[] = $baseGame['android_game_id'];
+ $gameIds[] = $baseGame['ios_game_id'];
+ }
+ return $gameIds;
+ }
+
+ public function getUserRegisterCount($baseGame, $date, $deviceType = 0)
+ {
+ $gameIds = $this->getGameIdsByBaseGame($baseGame, $deviceType);
+ $timeBegin = strtotime($date . ' 00:00:00');
+ $timeEnd = strtotime($date . ' 23:59:59');
+
+ $subCondition = [
+ 'game_id' => ['in', $gameIds],
+ '_string' => 'tab_user.id=tab_user_play_info.user_id'
+ ];
+
+ $subSql = M('user_play_info', 'tab_')->field('1')->where($subCondition)->select(false);
+ return M('user', 'tab_')->where([
+ 'register_time' => ['between', [$timeBegin, $timeEnd]],
+ '_string' => 'exists (' . $subSql . ')'
+ ])->count();
+ }
+
+ public function getUserRetentionCount($baseGame, $date, $day, $deviceType = 0)
+ {
+ $gameIds = $this->getGameIdsByBaseGame($baseGame, $deviceType);
+
+ $timeBegin = strtotime($date . ' 00:00:00');
+ $timeEnd = strtotime($date . ' 23:59:59');
+ $retentionTime = $timeBegin + ($day * 24 * 3600);
+
+ $subCondition = [
+ 'game_id' => ['in', $gameIds],
+ '_string' => 'tab_user.id=tab_user_play_info.user_id',
+ 'play_time' => ['egt', $retentionTime],
+ ];
+
+ $subSql = M('user_play_info', 'tab_')->field('1')->where($subCondition)->select(false);
+ return M('user', 'tab_')->where([
+ 'register_time' => ['between', [$timeBegin, $timeEnd]],
+ '_string' => 'exists (' . $subSql . ')'
+ ])->count();
+ }
}
\ No newline at end of file