mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 18:48:14 -05:00
fix: 修复用户侧流量明细不显示的问题
This commit is contained in:
parent
5f3b95b699
commit
d45113da7e
@ -13,7 +13,7 @@ class StatController extends Controller
|
||||
{
|
||||
public function getTrafficLog(Request $request)
|
||||
{
|
||||
$startDate = now()->startOfMonth();
|
||||
$startDate = strtotime(now()->startOfMonth());
|
||||
$records = StatUser::query()
|
||||
->where('user_id', $request->user['id'])
|
||||
->where('record_at', '>=', $startDate)
|
||||
@ -26,11 +26,11 @@ class StatController extends Controller
|
||||
$statService->setStartAt($recordAt);
|
||||
$todayTraffics = $statService->getStatUserByUserID($request->user['id']);
|
||||
if (count($todayTraffics) > 0) {
|
||||
$todayTraffics = collect($todayTraffics)->map(function ($todayTraffic) {
|
||||
$todayTraffic['server_rate'] = number_format($todayTraffic['server_rate'], 2);
|
||||
return $todayTraffic;
|
||||
$records = collect($todayTraffics)->merge($records);
|
||||
$records = $records->map(function ($record) {
|
||||
$record['server_rate'] = number_format($record['server_rate'], 2);
|
||||
return $record;
|
||||
});
|
||||
$records = $todayTraffics->merge($records);
|
||||
}
|
||||
$data = TrafficLogResource::collection(collect($records));
|
||||
return $this->success($data);
|
||||
|
@ -110,12 +110,11 @@ class StatisticalService
|
||||
*/
|
||||
public function getStatUserByUserID($userId): array
|
||||
{
|
||||
|
||||
$stats = [];
|
||||
$statsUser = $this->redis->zrange($this->statUserKey, 0, -1, true);
|
||||
foreach ($statsUser as $member => $value) {
|
||||
list($rate, $uid, $type) = explode('_', $member);
|
||||
if ($uid !== $userId)
|
||||
if (intval($uid) !== intval($userId))
|
||||
continue;
|
||||
$key = "{$rate}_{$uid}";
|
||||
$stats[$key] = $stats[$key] ?? [
|
||||
|
Loading…
Reference in New Issue
Block a user