update: fix statistics

This commit is contained in:
v2board
2023-05-17 11:28:59 +08:00
parent c42097e92f
commit 4ba6edc328
6 changed files with 40 additions and 64 deletions

View File

@ -79,18 +79,11 @@ class TrojanTidalabController extends Controller
Cache::put(CacheKey::get('SERVER_TROJAN_ONLINE_USER', $server->id), count($data), 3600);
Cache::put(CacheKey::get('SERVER_TROJAN_LAST_PUSH_AT', $server->id), time(), 3600);
$userService = new UserService();
$statData = [];
$formatData = [];
foreach ($data as $item) {
$u = $item['u'];
$d = $item['d'];
$userService->trafficFetch($u, $d, $item['user_id'], $server->toArray(), 'trojan');
$statData[$item['user_id']] = [$u, $d];
$formatData[$item['user_id']] = [$item['u'], $item['d']];
}
$statService = new StatisticalService();
$statService->setStartAt(strtotime(date('Y-m-d')));
$statService->setUserStats();
$statService->statUser($server['rate'], $statData);
$userService->trafficFetch($server->toArray(), 'trojan', $formatData);
return response([
'ret' => 1,