|
|
|
@ -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();
|
|
|
|
|
}
|
|
|
|
|
}
|