Merge remote-tracking branch 'upstream/dev' into feature/v2rayng-hysteria2

This commit is contained in:
George 2024-10-10 11:18:20 +08:00
commit 8737e0a6eb

View File

@ -108,14 +108,14 @@ class StatisticalService
/** /**
* 获取指定用户的流量使用情况 * 获取指定用户的流量使用情况
*/ */
public function getStatUserByUserID($userId): array public function getStatUserByUserID(int|string $userId): array
{ {
$stats = []; $stats = [];
$statsUser = $this->redis->zrange($this->statUserKey, 0, -1, true); $statsUser = $this->redis->zrange($this->statUserKey, 0, -1, true);
foreach ($statsUser as $member => $value) { foreach ($statsUser as $member => $value) {
list($rate, $uid, $type) = explode('_', $member); list($rate, $uid, $type) = explode('_', $member);
if ($uid !== $userId) if (intval($uid) !== intval($userId))
continue; continue;
$key = "{$rate}_{$uid}"; $key = "{$rate}_{$uid}";
$stats[$key] = $stats[$key] ?? [ $stats[$key] = $stats[$key] ?? [