diff --git a/app/Http/Controllers/Client/ClientController.php b/app/Http/Controllers/Client/ClientController.php index 1b5c7302..83a2169c 100644 --- a/app/Http/Controllers/Client/ClientController.php +++ b/app/Http/Controllers/Client/ClientController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Client; use App\Http\Controllers\Client\Protocols\General; use App\Http\Controllers\Controller; use App\Services\ServerService; +use App\Utils\Helper; use Illuminate\Http\Request; use App\Services\UserService; @@ -40,9 +41,9 @@ class ClientController extends Controller { if (!isset($servers[0])) return; if (!(int)config('v2board.show_info_to_server_enable', 0)) return; - $useTraffic = round($user['u'] / (1024*1024*1024), 2) + round($user['d'] / (1024*1024*1024), 2); - $totalTraffic = round($user['transfer_enable'] / (1024*1024*1024), 2); - $remainingTraffic = $totalTraffic - $useTraffic; + $useTraffic = $user['u'] + $user['d']; + $totalTraffic = $user['transfer_enable']; + $remainingTraffic = Helper::trafficConvert($totalTraffic - $useTraffic); $expiredDate = $user['expired_at'] ? date('Y-m-d', $user['expired_at']) : '长期有效'; $userService = new UserService(); $resetDay = $userService->getResetDay($user); @@ -55,7 +56,7 @@ class ClientController extends Controller ])); } array_unshift($servers, array_merge($servers[0], [ - 'name' => "剩余流量:{$remainingTraffic} GB", + 'name' => "剩余流量:{$remainingTraffic}", ])); } }