update: statistical service

This commit is contained in:
v2board
2023-04-15 19:34:54 +08:00
parent 6dd509d73e
commit 7be6553396
10 changed files with 112 additions and 5 deletions

View File

@ -3,6 +3,7 @@
namespace App\Http\Controllers\Server;
use App\Services\ServerService;
use App\Services\StatisticalService;
use App\Services\UserService;
use App\Utils\CacheKey;
use Illuminate\Http\Request;
@ -78,12 +79,17 @@ 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 = [];
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];
}
$statService = new StatisticalService();
$statService->statUser($server['rate'], $statData);
return response([
'ret' => 1,
'msg' => 'ok'