diff --git a/app/Console/Commands/CheckCommission.php b/app/Console/Commands/CheckCommission.php index e58797e8..30869a7e 100644 --- a/app/Console/Commands/CheckCommission.php +++ b/app/Console/Commands/CheckCommission.php @@ -5,6 +5,7 @@ namespace App\Console\Commands; use Illuminate\Console\Command; use App\Models\Order; use App\Models\User; +use Illuminate\Support\Facades\DB; class CheckCommission extends Command { @@ -62,13 +63,20 @@ class CheckCommission extends Command ->where('invite_user_id', '!=', NULL) ->get(); foreach ($order as $item) { + DB::beginTransaction(); $inviter = User::find($item->invite_user_id); if (!$inviter) continue; $inviter->commission_balance = $inviter->commission_balance + $item->commission_balance; - if ($inviter->save()) { - $item->commission_status = 2; - $item->save(); + if (!$inviter->save()) { + DB::rollBack(); + continue; } + $item->commission_status = 2; + if (!$item->save()){ + DB::rollBack(); + continue; + } + DB::commit(); } } diff --git a/app/Http/Controllers/Admin/Server/V2rayController.php b/app/Http/Controllers/Admin/Server/V2rayController.php index dfd94324..820debca 100644 --- a/app/Http/Controllers/Admin/Server/V2rayController.php +++ b/app/Http/Controllers/Admin/Server/V2rayController.php @@ -125,7 +125,7 @@ class V2rayController extends Controller public function viewConfig(Request $request) { $serverService = new ServerService(); - $config = $serverService->getVmessConfig($request->input('node_id'), 23333); + $config = $serverService->getV2RayConfig($request->input('node_id'), 23333); return response([ 'data' => $config ]); diff --git a/app/Http/Controllers/Server/DeepbworkController.php b/app/Http/Controllers/Server/DeepbworkController.php index 43f8c3ab..421937df 100644 --- a/app/Http/Controllers/Server/DeepbworkController.php +++ b/app/Http/Controllers/Server/DeepbworkController.php @@ -109,7 +109,7 @@ class DeepbworkController extends Controller } $serverService = new ServerService(); try { - $json = $serverService->getVmessConfig($nodeId, $localPort); + $json = $serverService->getV2RayConfig($nodeId, $localPort); } catch (\Exception $e) { abort(500, $e->getMessage()); } diff --git a/app/Http/Controllers/Server/PoseidonController.php b/app/Http/Controllers/Server/PoseidonController.php index d926cab3..3d8aaffd 100644 --- a/app/Http/Controllers/Server/PoseidonController.php +++ b/app/Http/Controllers/Server/PoseidonController.php @@ -92,7 +92,7 @@ class PoseidonController extends Controller $serverService = new ServerService(); try { - $json = $serverService->getVmessConfig($nodeId, $localPort); + $json = $serverService->getV2RayConfig($nodeId, $localPort); $json->poseidon = [ 'license_key' => (string)config('v2board.server_license'), ]; diff --git a/app/Services/ServerService.php b/app/Services/ServerService.php index 50cd51ed..689e9369 100644 --- a/app/Services/ServerService.php +++ b/app/Services/ServerService.php @@ -126,7 +126,7 @@ class ServerService ->get(); } - public function getVmessConfig(int $nodeId, int $localPort) + public function getV2RayConfig(int $nodeId, int $localPort) { $server = Server::find($nodeId); if (!$server) {