mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 01:11:46 +08:00 
			
		
		
		
	update: statistical service
This commit is contained in:
		| @@ -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; | ||||
| @@ -81,12 +82,17 @@ class DeepbworkController extends Controller | ||||
|         Cache::put(CacheKey::get('SERVER_VMESS_ONLINE_USER', $server->id), count($data), 3600); | ||||
|         Cache::put(CacheKey::get('SERVER_VMESS_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(), 'vmess'); | ||||
|             $statData[$item['user_id']] = [$u, $d]; | ||||
|         } | ||||
|  | ||||
|         $statService = new StatisticalService(); | ||||
|         $statService->statUser($server['rate'], $statData); | ||||
|  | ||||
|         return response([ | ||||
|             'ret' => 1, | ||||
|             'msg' => 'ok' | ||||
|   | ||||
| @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Server; | ||||
|  | ||||
| use App\Models\ServerShadowsocks; | ||||
| use App\Services\ServerService; | ||||
| use App\Services\StatisticalService; | ||||
| use App\Services\UserService; | ||||
| use App\Utils\CacheKey; | ||||
| use Illuminate\Http\Request; | ||||
| @@ -73,12 +74,17 @@ class ShadowsocksTidalabController extends Controller | ||||
|         Cache::put(CacheKey::get('SERVER_SHADOWSOCKS_ONLINE_USER', $server->id), count($data), 3600); | ||||
|         Cache::put(CacheKey::get('SERVER_SHADOWSOCKS_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(), 'shadowsocks'); | ||||
|             $statData[$item['user_id']] = [$u, $d]; | ||||
|         } | ||||
|  | ||||
|         $statService = new StatisticalService(); | ||||
|         $statService->statUser($server['rate'], $statData); | ||||
|  | ||||
|         return response([ | ||||
|             'ret' => 1, | ||||
|             'msg' => 'ok' | ||||
|   | ||||
| @@ -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' | ||||
|   | ||||
| @@ -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 App\Utils\Helper; | ||||
| @@ -69,6 +70,9 @@ class UniProxyController extends Controller | ||||
|             $userService->trafficFetch($u, $d, $k, $this->nodeInfo->toArray(), $this->nodeType); | ||||
|         } | ||||
|  | ||||
|         $statService = new StatisticalService(); | ||||
|         $statService->statUser($this->nodeInfo->rate, $data); | ||||
|  | ||||
|         return response([ | ||||
|             'data' => true | ||||
|         ]); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user