tokumeikoi 3 роки тому
батько
коміт
e6a7c2c11c
32 змінених файлів з 71 додано та 112 видалено
  1. 2 14
      app/Http/Controllers/Admin/CouponController.php
  2. 1 2
      app/Http/Controllers/Admin/Server/GroupController.php
  3. 0 5
      app/Http/Controllers/Admin/Server/ShadowsocksController.php
  4. 0 5
      app/Http/Controllers/Admin/Server/TrojanController.php
  5. 0 5
      app/Http/Controllers/Admin/Server/V2rayController.php
  6. 3 3
      app/Http/Controllers/Client/Protocols/AnXray.php
  7. 3 3
      app/Http/Controllers/Client/Protocols/Clash.php
  8. 3 3
      app/Http/Controllers/Client/Protocols/Passwall.php
  9. 2 2
      app/Http/Controllers/Client/Protocols/QuantumultX.php
  10. 3 3
      app/Http/Controllers/Client/Protocols/SSRPlus.php
  11. 3 3
      app/Http/Controllers/Client/Protocols/Shadowrocket.php
  12. 2 2
      app/Http/Controllers/Client/Protocols/Surfboard.php
  13. 2 2
      app/Http/Controllers/Client/Protocols/Surge.php
  14. 3 3
      app/Http/Controllers/Client/Protocols/V2rayN.php
  15. 3 3
      app/Http/Controllers/Client/Protocols/V2rayNG.php
  16. 1 1
      app/Http/Controllers/Server/DeepbworkController.php
  17. 1 1
      app/Http/Controllers/Server/PoseidonController.php
  18. 1 1
      app/Http/Controllers/Server/ShadowsocksTidalabController.php
  19. 1 1
      app/Http/Controllers/Server/TrojanTidalabController.php
  20. 1 2
      app/Http/Controllers/User/CommController.php
  21. 1 2
      app/Http/Controllers/User/CouponController.php
  22. 2 1
      app/Models/Coupon.php
  23. 2 1
      app/Models/Order.php
  24. 2 1
      app/Models/Payment.php
  25. 7 1
      app/Models/Server.php
  26. 2 1
      app/Models/ServerShadowsocks.php
  27. 2 1
      app/Models/ServerTrojan.php
  28. 1 2
      app/Services/CouponService.php
  29. 3 3
      app/Services/OrderService.php
  30. 1 1
      app/Services/PaymentService.php
  31. 13 34
      app/Services/ServerService.php
  32. 0 0
      public/assets/admin/umi.js

+ 2 - 14
app/Http/Controllers/Admin/CouponController.php

@@ -24,10 +24,6 @@ class CouponController extends Controller
         $total = $builder->count();
         $coupons = $builder->forPage($current, $pageSize)
             ->get();
-
-        foreach ($coupons as $k => $v) {
-            if ($coupons[$k]['limit_plan_ids']) $coupons[$k]['limit_plan_ids'] = json_decode($coupons[$k]['limit_plan_ids']);
-        }
         return response([
             'data' => $coupons,
             'total' => $total
@@ -37,9 +33,6 @@ class CouponController extends Controller
     public function save(CouponSave $request)
     {
         $params = $request->validated();
-        if (isset($params['limit_plan_ids'])) {
-            $params['limit_plan_ids'] = json_encode($params['limit_plan_ids']);
-        }
         if (!$request->input('id')) {
             if (!isset($params['code'])) {
                 $params['code'] = Helper::randomChar(8);
@@ -68,9 +61,6 @@ class CouponController extends Controller
         }
 
         $params = $request->validated();
-        if (isset($params['limit_plan_ids'])) {
-            $params['limit_plan_ids'] = json_encode($params['limit_plan_ids']);
-        }
         if (!$request->input('id')) {
             if (!isset($params['code'])) {
                 $params['code'] = Helper::randomChar(8);
@@ -95,10 +85,8 @@ class CouponController extends Controller
     {
         $coupons = [];
         $coupon = $request->validated();
-        if (isset($coupon['limit_plan_ids'])) {
-            $coupon['limit_plan_ids'] = json_encode($coupon['limit_plan_ids']);
-        }
         $coupon['created_at'] = $coupon['updated_at'] = time();
+        $coupon['limit_plan_ids'] = json_encode($coupon['limit_plan_ids']);
         unset($coupon['generate_count']);
         for ($i = 0;$i < $request->input('generate_count');$i++) {
             $coupon['code'] = Helper::randomChar(8);
@@ -118,7 +106,7 @@ class CouponController extends Controller
             $endTime = date('Y-m-d H:i:s', $coupon['ended_at']);
             $limitUse = $coupon['limit_use'] ?? '不限制';
             $createTime = date('Y-m-d H:i:s', $coupon['created_at']);
-            $limitPlanIds = $coupon['limit_plan_ids'] ?? '不限制';
+            $limitPlanIds = implode("/", json_decode($coupon['limit_plan_ids'], true)) ?? '不限制';
             $data .= "{$coupon['name']},{$type},{$value},{$startTime},{$endTime},{$limitUse},{$limitPlanIds},{$coupon['code']},{$createTime}\r\n";
         }
         echo $data;

+ 1 - 2
app/Http/Controllers/Admin/Server/GroupController.php

@@ -52,8 +52,7 @@ class GroupController extends Controller
 
         $servers = Server::all();
         foreach ($servers as $server) {
-            $groupId = json_decode($server->group_id);
-            if (in_array($request->input('id'), $groupId)) {
+            if (in_array($request->input('id'), $server->group_id)) {
                 abort(500, '该组已被节点所使用,无法删除');
             }
         }

+ 0 - 5
app/Http/Controllers/Admin/Server/ShadowsocksController.php

@@ -14,11 +14,6 @@ class ShadowsocksController extends Controller
     public function save(ServerShadowsocksSave $request)
     {
         $params = $request->validated();
-        $params['group_id'] = json_encode($params['group_id']);
-        if (isset($params['tags'])) {
-            $params['tags'] = json_encode($params['tags']);
-        }
-
         if ($request->input('id')) {
             $server = ServerShadowsocks::find($request->input('id'));
             if (!$server) {

+ 0 - 5
app/Http/Controllers/Admin/Server/TrojanController.php

@@ -14,11 +14,6 @@ class TrojanController extends Controller
     public function save(ServerTrojanSave $request)
     {
         $params = $request->validated();
-        $params['group_id'] = json_encode($params['group_id']);
-        if (isset($params['tags'])) {
-            $params['tags'] = json_encode($params['tags']);
-        }
-
         if ($request->input('id')) {
             $server = ServerTrojan::find($request->input('id'));
             if (!$server) {

+ 0 - 5
app/Http/Controllers/Admin/Server/V2rayController.php

@@ -14,11 +14,6 @@ class V2rayController extends Controller
     public function save(ServerV2raySave $request)
     {
         $params = $request->validated();
-        $params['group_id'] = json_encode($params['group_id']);
-        if (isset($params['tags'])) {
-            $params['tags'] = json_encode($params['tags']);
-        }
-
         if (isset($params['dnsSettings'])) {
             if (!is_object(json_decode($params['dnsSettings']))) {
                 abort(500, 'DNS规则配置格式不正确');

+ 3 - 3
app/Http/Controllers/Client/Protocols/AnXray.php

@@ -67,18 +67,18 @@ class AnXray
         ];
         if ($server['tls']) {
             if ($server['tlsSettings']) {
-                $tlsSettings = json_decode($server['tlsSettings'], true);
+                $tlsSettings = $server['tlsSettings'];
                 if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName']))
                     $config['sni'] = urlencode($tlsSettings['serverName']);
             }
         }
         if ((string)$server['network'] === 'ws') {
-            $wsSettings = json_decode($server['networkSettings'], true);
+            $wsSettings = $server['networkSettings'];
             if (isset($wsSettings['path'])) $config['path'] = urlencode($wsSettings['path']);
             if (isset($wsSettings['headers']['Host'])) $config['host'] = urlencode($wsSettings['headers']['Host']);
         }
         if ((string)$server['network'] === 'grpc') {
-            $grpcSettings = json_decode($server['networkSettings'], true);
+            $grpcSettings = $server['networkSettings'];
             if (isset($grpcSettings['serviceName'])) $config['serviceName'] = urlencode($grpcSettings['serviceName']);
         }
         return "vmess://" . $uuid . "@" . $server['host'] . ":" . $server['port'] . "?" . http_build_query($config) . "#" . urlencode($server['name']) . "\r\n";

+ 3 - 3
app/Http/Controllers/Client/Protocols/Clash.php

@@ -84,7 +84,7 @@ class Clash
         if ($server['tls']) {
             $array['tls'] = true;
             if ($server['tlsSettings']) {
-                $tlsSettings = json_decode($server['tlsSettings'], true);
+                $tlsSettings = $server['tlsSettings'];
                 if (isset($tlsSettings['allowInsecure']) && !empty($tlsSettings['allowInsecure']))
                     $array['skip-cert-verify'] = ($tlsSettings['allowInsecure'] ? true : false);
                 if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName']))
@@ -94,7 +94,7 @@ class Clash
         if ($server['network'] === 'ws') {
             $array['network'] = 'ws';
             if ($server['networkSettings']) {
-                $wsSettings = json_decode($server['networkSettings'], true);
+                $wsSettings = $server['networkSettings'];
                 if (isset($wsSettings['path']) && !empty($wsSettings['path']))
                     $array['ws-path'] = $wsSettings['path'];
                 if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host']))
@@ -104,7 +104,7 @@ class Clash
         if ($server['network'] === 'grpc') {
             $array['network'] = 'grpc';
             if ($server['networkSettings']) {
-                $grpcObject = json_decode($server['networkSettings'], true);
+                $grpcObject = $server['networkSettings'];
                 $array['grpc-opts'] = [];
                 $array['grpc-opts']['grpc-service-name'] = $grpcObject['serviceName'];
             }

+ 3 - 3
app/Http/Controllers/Client/Protocols/Passwall.php

@@ -63,18 +63,18 @@ class Passwall
         ];
         if ($server['tls']) {
             if ($server['tlsSettings']) {
-                $tlsSettings = json_decode($server['tlsSettings'], true);
+                $tlsSettings = $server['tlsSettings'];
                 if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName']))
                     $config['sni'] = $tlsSettings['serverName'];
             }
         }
         if ((string)$server['network'] === 'ws') {
-            $wsSettings = json_decode($server['networkSettings'], true);
+            $wsSettings = $server['networkSettings'];
             if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path'];
             if (isset($wsSettings['headers']['Host'])) $config['host'] = $wsSettings['headers']['Host'];
         }
         if ((string)$server['network'] === 'grpc') {
-            $grpcSettings = json_decode($server['networkSettings'], true);
+            $grpcSettings = $server['networkSettings'];
             if (isset($grpcSettings['serviceName'])) $config['path'] = $grpcSettings['serviceName'];
         }
         return "vmess://" . base64_encode(json_encode($config)) . "\r\n";

+ 2 - 2
app/Http/Controllers/Client/Protocols/QuantumultX.php

@@ -66,7 +66,7 @@ class QuantumultX
             if ($server['network'] === 'tcp')
                 array_push($config, 'obfs=over-tls');
             if ($server['tlsSettings']) {
-                $tlsSettings = json_decode($server['tlsSettings'], true);
+                $tlsSettings = $server['tlsSettings'];
                 if (isset($tlsSettings['allowInsecure']) && !empty($tlsSettings['allowInsecure']))
                     array_push($config, 'tls-verification=' . ($tlsSettings['allowInsecure'] ? 'false' : 'true'));
                 if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName']))
@@ -79,7 +79,7 @@ class QuantumultX
             else
                 array_push($config, 'obfs=ws');
             if ($server['networkSettings']) {
-                $wsSettings = json_decode($server['networkSettings'], true);
+                $wsSettings = $server['networkSettings'];
                 if (isset($wsSettings['path']) && !empty($wsSettings['path']))
                     array_push($config, "obfs-uri={$wsSettings['path']}");
                 if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host']) && !isset($host))

+ 3 - 3
app/Http/Controllers/Client/Protocols/SSRPlus.php

@@ -63,18 +63,18 @@ class SSRPlus
         ];
         if ($server['tls']) {
             if ($server['tlsSettings']) {
-                $tlsSettings = json_decode($server['tlsSettings'], true);
+                $tlsSettings = $server['tlsSettings'];
                 if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName']))
                     $config['sni'] = $tlsSettings['serverName'];
             }
         }
         if ((string)$server['network'] === 'ws') {
-            $wsSettings = json_decode($server['networkSettings'], true);
+            $wsSettings = $server['networkSettings'];
             if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path'];
             if (isset($wsSettings['headers']['Host'])) $config['host'] = $wsSettings['headers']['Host'];
         }
         if ((string)$server['network'] === 'grpc') {
-            $grpcSettings = json_decode($server['networkSettings'], true);
+            $grpcSettings = $server['networkSettings'];
             if (isset($grpcSettings['serviceName'])) $config['path'] = $grpcSettings['serviceName'];
         }
         return "vmess://" . base64_encode(json_encode($config)) . "\r\n";

+ 3 - 3
app/Http/Controllers/Client/Protocols/Shadowrocket.php

@@ -63,7 +63,7 @@ class Shadowrocket
         if ($server['tls']) {
             $config['tls'] = 1;
             if ($server['tlsSettings']) {
-                $tlsSettings = json_decode($server['tlsSettings'], true);
+                $tlsSettings = $server['tlsSettings'];
                 if (isset($tlsSettings['allowInsecure']) && !empty($tlsSettings['allowInsecure']))
                     $config['allowInsecure'] = (int)$tlsSettings['allowInsecure'];
                 if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName']))
@@ -73,7 +73,7 @@ class Shadowrocket
         if ($server['network'] === 'ws') {
             $config['obfs'] = "websocket";
             if ($server['networkSettings']) {
-                $wsSettings = json_decode($server['networkSettings'], true);
+                $wsSettings = $server['networkSettings'];
                 if (isset($wsSettings['path']) && !empty($wsSettings['path']))
                     $config['path'] = $wsSettings['path'];
                 if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host']))
@@ -83,7 +83,7 @@ class Shadowrocket
         if ($server['network'] === 'grpc') {
             $config['obfs'] = "grpc";
             if ($server['networkSettings']) {
-                $grpcSettings = json_decode($server['networkSettings'], true);
+                $grpcSettings = $server['networkSettings'];
                 if (isset($grpcSettings['serviceName']) && !empty($grpcSettings['serviceName']))
                     $config['path'] = $grpcSettings['serviceName'];
             }

+ 2 - 2
app/Http/Controllers/Client/Protocols/Surfboard.php

@@ -88,7 +88,7 @@ class Surfboard
         if ($server['tls']) {
             array_push($config, 'tls=true');
             if ($server['tlsSettings']) {
-                $tlsSettings = json_decode($server['tlsSettings'], true);
+                $tlsSettings = $server['tlsSettings'];
                 if (isset($tlsSettings['allowInsecure']) && !empty($tlsSettings['allowInsecure']))
                     array_push($config, 'skip-cert-verify=' . ($tlsSettings['allowInsecure'] ? 'true' : 'false'));
                 if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName']))
@@ -98,7 +98,7 @@ class Surfboard
         if ($server['network'] === 'ws') {
             array_push($config, 'ws=true');
             if ($server['networkSettings']) {
-                $wsSettings = json_decode($server['networkSettings'], true);
+                $wsSettings = $server['networkSettings'];
                 if (isset($wsSettings['path']) && !empty($wsSettings['path']))
                     array_push($config, "ws-path={$wsSettings['path']}");
                 if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host']))

+ 2 - 2
app/Http/Controllers/Client/Protocols/Surge.php

@@ -92,7 +92,7 @@ class Surge
         if ($server['tls']) {
             array_push($config, 'tls=true');
             if ($server['tlsSettings']) {
-                $tlsSettings = json_decode($server['tlsSettings'], true);
+                $tlsSettings = $server['tlsSettings'];
                 if (isset($tlsSettings['allowInsecure']) && !empty($tlsSettings['allowInsecure']))
                     array_push($config, 'skip-cert-verify=' . ($tlsSettings['allowInsecure'] ? 'true' : 'false'));
                 if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName']))
@@ -102,7 +102,7 @@ class Surge
         if ($server['network'] === 'ws') {
             array_push($config, 'ws=true');
             if ($server['networkSettings']) {
-                $wsSettings = json_decode($server['networkSettings'], true);
+                $wsSettings = $server['networkSettings'];
                 if (isset($wsSettings['path']) && !empty($wsSettings['path']))
                     array_push($config, "ws-path={$wsSettings['path']}");
                 if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host']))

+ 3 - 3
app/Http/Controllers/Client/Protocols/V2rayN.php

@@ -63,18 +63,18 @@ class V2rayN
         ];
         if ($server['tls']) {
             if ($server['tlsSettings']) {
-                $tlsSettings = json_decode($server['tlsSettings'], true);
+                $tlsSettings = $server['tlsSettings'];
                 if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName']))
                     $config['sni'] = $tlsSettings['serverName'];
             }
         }
         if ((string)$server['network'] === 'ws') {
-            $wsSettings = json_decode($server['networkSettings'], true);
+            $wsSettings = $server['networkSettings'];
             if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path'];
             if (isset($wsSettings['headers']['Host'])) $config['host'] = $wsSettings['headers']['Host'];
         }
         if ((string)$server['network'] === 'grpc') {
-            $grpcSettings = json_decode($server['networkSettings'], true);
+            $grpcSettings = $server['networkSettings'];
             if (isset($grpcSettings['serviceName'])) $config['path'] = $grpcSettings['serviceName'];
         }
         return "vmess://" . base64_encode(json_encode($config)) . "\r\n";

+ 3 - 3
app/Http/Controllers/Client/Protocols/V2rayNG.php

@@ -63,18 +63,18 @@ class V2rayNG
         ];
         if ($server['tls']) {
             if ($server['tlsSettings']) {
-                $tlsSettings = json_decode($server['tlsSettings'], true);
+                $tlsSettings = $server['tlsSettings'];
                 if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName']))
                     $config['sni'] = $tlsSettings['serverName'];
             }
         }
         if ((string)$server['network'] === 'ws') {
-            $wsSettings = json_decode($server['networkSettings'], true);
+            $wsSettings = $server['networkSettings'];
             if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path'];
             if (isset($wsSettings['headers']['Host'])) $config['host'] = $wsSettings['headers']['Host'];
         }
         if ((string)$server['network'] === 'grpc') {
-            $grpcSettings = json_decode($server['networkSettings'], true);
+            $grpcSettings = $server['networkSettings'];
             if (isset($grpcSettings['serviceName'])) $config['path'] = $grpcSettings['serviceName'];
         }
         return "vmess://" . base64_encode(json_encode($config)) . "\r\n";

+ 1 - 1
app/Http/Controllers/Server/DeepbworkController.php

@@ -41,7 +41,7 @@ class DeepbworkController extends Controller
         }
         Cache::put(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $server->id), time(), 3600);
         $serverService = new ServerService();
-        $users = $serverService->getAvailableUsers(json_decode($server->group_id));
+        $users = $serverService->getAvailableUsers($server->group_id);
         $result = [];
         foreach ($users as $user) {
             $user->v2ray_user = [

+ 1 - 1
app/Http/Controllers/Server/PoseidonController.php

@@ -39,7 +39,7 @@ class PoseidonController extends Controller
         }
         Cache::put(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $server->id), time(), 3600);
         $serverService = new ServerService();
-        $users = $serverService->getAvailableUsers(json_decode($server->group_id));
+        $users = $serverService->getAvailableUsers($server->group_id);
         $result = [];
         foreach ($users as $user) {
             $user->v2ray_user = [

+ 1 - 1
app/Http/Controllers/Server/ShadowsocksTidalabController.php

@@ -41,7 +41,7 @@ class ShadowsocksTidalabController extends Controller
         }
         Cache::put(CacheKey::get('SERVER_SHADOWSOCKS_LAST_CHECK_AT', $server->id), time(), 3600);
         $serverService = new ServerService();
-        $users = $serverService->getAvailableUsers(json_decode($server->group_id));
+        $users = $serverService->getAvailableUsers($server->group_id);
         $result = [];
         foreach ($users as $user) {
             array_push($result, [

+ 1 - 1
app/Http/Controllers/Server/TrojanTidalabController.php

@@ -41,7 +41,7 @@ class TrojanTidalabController extends Controller
         }
         Cache::put(CacheKey::get('SERVER_TROJAN_LAST_CHECK_AT', $server->id), time(), 3600);
         $serverService = new ServerService();
-        $users = $serverService->getAvailableUsers(json_decode($server->group_id));
+        $users = $serverService->getAvailableUsers($server->group_id);
         $result = [];
         foreach ($users as $user) {
             $user->trojan_user = [

+ 1 - 2
app/Http/Controllers/User/CommController.php

@@ -27,9 +27,8 @@ class CommController extends Controller
             ->where('payment', 'StripeCredit')
             ->first();
         if (!$payment) abort(500, 'payment is not found');
-        $config = json_decode($payment->config, true);
         return response([
-            'data' => $config['stripe_pk_live']
+            'data' => $payment->config['stripe_pk_live']
         ]);
     }
 }

+ 1 - 2
app/Http/Controllers/User/CouponController.php

@@ -27,8 +27,7 @@ class CouponController extends Controller
             abort(500, __('This coupon has expired'));
         }
         if ($coupon->limit_plan_ids) {
-            $limitPlanIds = json_decode($coupon->limit_plan_ids);
-            if (!in_array($request->input('plan_id'), $limitPlanIds)) {
+            if (!in_array($request->input('plan_id'), $coupon->limit_plan_ids)) {
                 abort(500, __('The coupon code cannot be used for this subscription'));
             }
         }

+ 2 - 1
app/Models/Coupon.php

@@ -11,6 +11,7 @@ class Coupon extends Model
     protected $guarded = ['id'];
     protected $casts = [
         'created_at' => 'timestamp',
-        'updated_at' => 'timestamp'
+        'updated_at' => 'timestamp',
+        'limit_plan_ids' => 'array'
     ];
 }

+ 2 - 1
app/Models/Order.php

@@ -11,6 +11,7 @@ class Order extends Model
     protected $guarded = ['id'];
     protected $casts = [
         'created_at' => 'timestamp',
-        'updated_at' => 'timestamp'
+        'updated_at' => 'timestamp',
+        'surplus_order_ids' => 'array'
     ];
 }

+ 2 - 1
app/Models/Payment.php

@@ -11,6 +11,7 @@ class Payment extends Model
     protected $guarded = ['id'];
     protected $casts = [
         'created_at' => 'timestamp',
-        'updated_at' => 'timestamp'
+        'updated_at' => 'timestamp',
+        'config' => 'array'
     ];
 }

+ 7 - 1
app/Models/Server.php

@@ -11,6 +11,12 @@ class Server extends Model
     protected $guarded = ['id'];
     protected $casts = [
         'created_at' => 'timestamp',
-        'updated_at' => 'timestamp'
+        'updated_at' => 'timestamp',
+        'group_id' => 'array',
+        'tlsSettings' => 'array',
+        'networkSettings' => 'array',
+        'dnsSettings' => 'array',
+        'ruleSettings' => 'array',
+        'tag' => 'array'
     ];
 }

+ 2 - 1
app/Models/ServerShadowsocks.php

@@ -11,6 +11,7 @@ class ServerShadowsocks extends Model
     protected $guarded = ['id'];
     protected $casts = [
         'created_at' => 'timestamp',
-        'updated_at' => 'timestamp'
+        'updated_at' => 'timestamp',
+        'tag' => 'array'
     ];
 }

+ 2 - 1
app/Models/ServerTrojan.php

@@ -11,6 +11,7 @@ class ServerTrojan extends Model
     protected $guarded = ['id'];
     protected $casts = [
         'created_at' => 'timestamp',
-        'updated_at' => 'timestamp'
+        'updated_at' => 'timestamp',
+        'tag' => 'array'
     ];
 }

+ 1 - 2
app/Services/CouponService.php

@@ -44,8 +44,7 @@ class CouponService
             }
         }
         if ($this->coupon->limit_plan_ids) {
-            $limitPlanIds = json_decode($this->coupon->limit_plan_ids);
-            if (!in_array($order->plan_id, $limitPlanIds)) {
+            if (!in_array($order->plan_id, $this->coupon->limit_plan_ids)) {
                 return false;
             }
         }

+ 3 - 3
app/Services/OrderService.php

@@ -37,7 +37,7 @@ class OrderService
         DB::beginTransaction();
         if ($order->surplus_order_ids) {
             try {
-                Order::whereIn('id', json_decode($order->surplus_order_ids))->update([
+                Order::whereIn('id', $order->surplus_order_ids)->update([
                     'status' => 4
                 ]);
             } catch (\Exception $e) {
@@ -190,7 +190,7 @@ class OrderService
         $result = $trafficUnitPrice * $notUsedTraffic;
         $orderModel = Order::where('user_id', $user->id)->where('cycle', '!=', 'reset_price')->where('status', 3);
         $order->surplus_amount = $result > 0 ? $result : 0;
-        $order->surplus_order_ids = json_encode(array_column($orderModel->get()->toArray(), 'id'));
+        $order->surplus_order_ids = array_column($orderModel->get()->toArray(), 'id');
     }
 
     private function orderIsUsed(Order $order):bool
@@ -229,7 +229,7 @@ class OrderService
             return;
         }
         $order->surplus_amount = $orderSurplusAmount > 0 ? $orderSurplusAmount : 0;
-        $order->surplus_order_ids = json_encode(array_column($orders->toArray(), 'id'));
+        $order->surplus_order_ids = array_column($orders->toArray(), 'id');
     }
 
     public function success(string $callbackNo)

+ 1 - 1
app/Services/PaymentService.php

@@ -22,7 +22,7 @@ class PaymentService
         if ($uuid) $payment = Payment::where('uuid', $uuid)->first()->toArray();
         $this->config = [];
         if (isset($payment)) {
-            $this->config = json_decode($payment['config'], true);
+            $this->config = $payment['config'];
             $this->config['enable'] = $payment['enable'];
             $this->config['id'] = $payment['id'];
             $this->config['uuid'] = $payment['uuid'];

+ 13 - 34
app/Services/ServerService.php

@@ -25,7 +25,7 @@ class ServerService
         $v2ray = $model->get();
         for ($i = 0; $i < count($v2ray); $i++) {
             $v2ray[$i]['type'] = 'v2ray';
-            $groupId = json_decode($v2ray[$i]['group_id']);
+            $groupId = $v2ray[$i]['group_id'];
             if (in_array($user->group_id, $groupId)) {
                 if ($v2ray[$i]['parent_id']) {
                     $v2ray[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $v2ray[$i]['parent_id']));
@@ -50,7 +50,7 @@ class ServerService
         $trojan = $model->get();
         for ($i = 0; $i < count($trojan); $i++) {
             $trojan[$i]['type'] = 'trojan';
-            $groupId = json_decode($trojan[$i]['group_id']);
+            $groupId = $trojan[$i]['group_id'];
             if (in_array($user->group_id, $groupId)) {
                 if ($trojan[$i]['parent_id']) {
                     $trojan[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_TROJAN_LAST_CHECK_AT', $trojan[$i]['parent_id']));
@@ -73,7 +73,7 @@ class ServerService
         $shadowsocks = $model->get();
         for ($i = 0; $i < count($shadowsocks); $i++) {
             $shadowsocks[$i]['type'] = 'shadowsocks';
-            $groupId = json_decode($shadowsocks[$i]['group_id']);
+            $groupId = $shadowsocks[$i]['group_id'];
             if (in_array($user->group_id, $groupId)) {
                 if ($shadowsocks[$i]['parent_id']) {
                     $shadowsocks[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_SHADOWSOCKS_LAST_CHECK_AT', $shadowsocks[$i]['parent_id']));
@@ -159,7 +159,7 @@ class ServerService
     private function setDns(Server $server, object $json)
     {
         if ($server->dnsSettings) {
-            $dns = json_decode($server->dnsSettings);
+            $dns = $server->dnsSettings;
             if (isset($dns->servers)) {
                 array_push($dns->servers, '1.1.1.1');
                 array_push($dns->servers, 'localhost');
@@ -174,25 +174,25 @@ class ServerService
         if ($server->networkSettings) {
             switch ($server->network) {
                 case 'tcp':
-                    $json->inbound->streamSettings->tcpSettings = json_decode($server->networkSettings);
+                    $json->inbound->streamSettings->tcpSettings = $server->networkSettings;
                     break;
                 case 'kcp':
-                    $json->inbound->streamSettings->kcpSettings = json_decode($server->networkSettings);
+                    $json->inbound->streamSettings->kcpSettings = $server->networkSettings;
                     break;
                 case 'ws':
-                    $json->inbound->streamSettings->wsSettings = json_decode($server->networkSettings);
+                    $json->inbound->streamSettings->wsSettings = $server->networkSettings;
                     break;
                 case 'http':
-                    $json->inbound->streamSettings->httpSettings = json_decode($server->networkSettings);
+                    $json->inbound->streamSettings->httpSettings = $server->networkSettings;
                     break;
                 case 'domainsocket':
-                    $json->inbound->streamSettings->dsSettings = json_decode($server->networkSettings);
+                    $json->inbound->streamSettings->dsSettings = $server->networkSettings;
                     break;
                 case 'quic':
-                    $json->inbound->streamSettings->quicSettings = json_decode($server->networkSettings);
+                    $json->inbound->streamSettings->quicSettings = $server->networkSettings;
                     break;
                 case 'grpc':
-                    $json->inbound->streamSettings->grpcSettings = json_decode($server->networkSettings);
+                    $json->inbound->streamSettings->grpcSettings = $server->networkSettings;
                     break;
             }
         }
@@ -203,7 +203,7 @@ class ServerService
         $domainRules = array_filter(explode(PHP_EOL, config('v2board.server_v2ray_domain')));
         $protocolRules = array_filter(explode(PHP_EOL, config('v2board.server_v2ray_protocol')));
         if ($server->ruleSettings) {
-            $ruleSettings = json_decode($server->ruleSettings);
+            $ruleSettings = $server->ruleSettings;
             // domain
             if (isset($ruleSettings->domain)) {
                 $ruleSettings->domain = array_filter($ruleSettings->domain);
@@ -241,7 +241,7 @@ class ServerService
     private function setTls(Server $server, object $json)
     {
         if ((int)$server->tls) {
-            $tlsSettings = json_decode($server->tlsSettings);
+            $tlsSettings = $server->tlsSettings;
             $json->inbound->streamSettings->security = 'tls';
             $tls = (object)[
                 'certificateFile' => '/root/.cert/server.crt',
@@ -292,10 +292,6 @@ class ServerService
         $server = ServerShadowsocks::orderBy('sort', 'ASC')->get();
         for ($i = 0; $i < count($server); $i++) {
             $server[$i]['type'] = 'shadowsocks';
-            if (!empty($server[$i]['tags'])) {
-                $server[$i]['tags'] = json_decode($server[$i]['tags']);
-            }
-            $server[$i]['group_id'] = json_decode($server[$i]['group_id']);
         }
         return $server->toArray();
     }
@@ -305,19 +301,6 @@ class ServerService
         $server = Server::orderBy('sort', 'ASC')->get();
         for ($i = 0; $i < count($server); $i++) {
             $server[$i]['type'] = 'v2ray';
-            if (!empty($server[$i]['tags'])) {
-                $server[$i]['tags'] = json_decode($server[$i]['tags']);
-            }
-            if (!empty($server[$i]['dnsSettings'])) {
-                $server[$i]['dnsSettings'] = json_decode($server[$i]['dnsSettings']);
-            }
-            if (!empty($server[$i]['tlsSettings'])) {
-                $server[$i]['tlsSettings'] = json_decode($server[$i]['tlsSettings']);
-            }
-            if (!empty($server[$i]['ruleSettings'])) {
-                $server[$i]['ruleSettings'] = json_decode($server[$i]['ruleSettings']);
-            }
-            $server[$i]['group_id'] = json_decode($server[$i]['group_id']);
         }
         return $server->toArray();
     }
@@ -327,10 +310,6 @@ class ServerService
         $server = ServerTrojan::orderBy('sort', 'ASC')->get();
         for ($i = 0; $i < count($server); $i++) {
             $server[$i]['type'] = 'trojan';
-            if (!empty($server[$i]['tags'])) {
-                $server[$i]['tags'] = json_decode($server[$i]['tags']);
-            }
-            $server[$i]['group_id'] = json_decode($server[$i]['group_id']);
         }
         return $server->toArray();
     }

Різницю між файлами не показано, бо вона завелика
+ 0 - 0
public/assets/admin/umi.js


Деякі файли не було показано, через те що забагато файлів було змінено