Browse Source

Simplify array merge & time format

BrettonYe 3 months ago
parent
commit
4032724480

+ 5 - 5
app/Console/Commands/NodeDailyMaintenance.php

@@ -75,9 +75,9 @@ class NodeDailyMaintenance extends Command
         $now = Carbon::now();
         $now = Carbon::now();
 
 
         $notificationDates = [ // 通知日期 分别是 前1天,3天和7天
         $notificationDates = [ // 通知日期 分别是 前1天,3天和7天
-            $now->addDays(1)->format('Y-m-d'),
-            $now->addDays(2)->format('Y-m-d'),
-            $now->addDays(4)->format('Y-m-d'),
+            $now->addDays(1)->toDateString(),
+            $now->addDays(2)->toDateString(),
+            $now->addDays(4)->toDateString(),
         ];
         ];
 
 
         $nodes = Node::whereNotNull('details')->whereIn('details->next_renewal_date', $notificationDates)->pluck('name', 'id')->toArray();
         $nodes = Node::whereNotNull('details')->whereIn('details->next_renewal_date', $notificationDates)->pluck('name', 'id')->toArray();
@@ -93,14 +93,14 @@ class NodeDailyMaintenance extends Command
         $nodes = Node::whereNotNull('details')
         $nodes = Node::whereNotNull('details')
             ->where(function (Builder $query) {
             ->where(function (Builder $query) {
                 $query->where('details->subscription_term', '<>', null)
                 $query->where('details->subscription_term', '<>', null)
-                    ->where('details->next_renewal_date', '<=', Carbon::now()->format('Y-m-d'));
+                    ->where('details->next_renewal_date', '<=', Carbon::now()->toDateString());
             })
             })
             ->get();
             ->get();
 
 
         // 更新每个节点的 next_renewal_date
         // 更新每个节点的 next_renewal_date
         foreach ($nodes as $node) {
         foreach ($nodes as $node) {
             $details = $node->details;
             $details = $node->details;
-            $details['next_renewal_date'] = Carbon::createFromFormat('Y-m-d', $details['next_renewal_date'])->add($details['subscription_term'])->format('Y-m-d');
+            $details['next_renewal_date'] = Carbon::createFromFormat('Y-m-d', $details['next_renewal_date'])->add($details['subscription_term'])->toDateString();
             $node->details = $details;
             $node->details = $details;
 
 
             $node->save();
             $node->save();

+ 1 - 1
app/Console/Commands/NodeStatusDetection.php

@@ -119,7 +119,7 @@ class NodeStatusDetection extends Command
             }
             }
         }
         }
 
 
-        if (! empty($data)) { //只有在出现阻断线路时,才会发出警报
+        if (! empty($data)) { // 只有在出现阻断线路时,才会发出警报
             Notification::send(User::find(1), new NodeBlocked($data));
             Notification::send(User::find(1), new NodeBlocked($data));
 
 
             Log::notice(trans('notification.node_block').": \r\n".var_export($data, true));
             Log::notice(trans('notification.node_block').": \r\n".var_export($data, true));

+ 3 - 3
app/Helpers/ClientApiResponse.php

@@ -7,7 +7,7 @@ use Illuminate\Http\Request;
 
 
 trait ClientApiResponse
 trait ClientApiResponse
 {
 {
-    private static string $client;
+    private static string $client = 'clash';
 
 
     public function __construct(Request $request)
     public function __construct(Request $request)
     {
     {
@@ -34,11 +34,11 @@ trait ClientApiResponse
             $result = ['ret' => $status, 'msg' => $message, 'data' => $data];
             $result = ['ret' => $status, 'msg' => $message, 'data' => $data];
 
 
             if (isset($addition)) {
             if (isset($addition)) {
-                $result = array_merge($result, $addition);
+                $result += $addition;
             }
             }
         } else { // ProxyPanel client api 规范格式
         } else { // ProxyPanel client api 规范格式
             if (isset($data, $addition) && is_array($data)) {
             if (isset($data, $addition) && is_array($data)) {
-                $data = array_merge($data, $addition);
+                $data += $addition;
             }
             }
 
 
             $result = ['status' => $status ? 'success' : 'fail', 'code' => $code, 'message' => $message, 'data' => $data ?? $addition];
             $result = ['status' => $status ? 'success' : 'fail', 'code' => $code, 'message' => $message, 'data' => $data ?? $addition];

+ 11 - 11
app/Helpers/ResponseEnum.php

@@ -6,12 +6,12 @@ class ResponseEnum
 {
 {
     // 001 ~ 099 表示系统状态;100 ~ 199 表示授权业务;200 ~ 299 表示用户业务
     // 001 ~ 099 表示系统状态;100 ~ 199 表示授权业务;200 ~ 299 表示用户业务
 
 
-    /*-------------------------------------------------------------------------------------------*/
+    /* ------------------------------------------------------------------------------------------- */
     // 100开头的表示 信息提示,这类状态表示临时的响应
     // 100开头的表示 信息提示,这类状态表示临时的响应
     // 100 - 继续
     // 100 - 继续
     // 101 - 切换协议
     // 101 - 切换协议
 
 
-    /*-------------------------------------------------------------------------------------------*/
+    /* ------------------------------------------------------------------------------------------- */
     // 200表示服务器成功地接受了客户端请求
     // 200表示服务器成功地接受了客户端请求
     public const HTTP_OK = [200001, '操作成功'];
     public const HTTP_OK = [200001, '操作成功'];
 
 
@@ -33,13 +33,13 @@ class ResponseEnum
 
 
     public const USER_ACCOUNT_REGISTERED = [23001, '账号已注册'];
     public const USER_ACCOUNT_REGISTERED = [23001, '账号已注册'];
 
 
-    /*-------------------------------------------------------------------------------------------*/
+    /* ------------------------------------------------------------------------------------------- */
     // 300开头的表示服务器重定向,指向的别的地方,客户端浏览器必须采取更多操作来实现请求
     // 300开头的表示服务器重定向,指向的别的地方,客户端浏览器必须采取更多操作来实现请求
     // 302 - 对象已移动。
     // 302 - 对象已移动。
     // 304 - 未修改。
     // 304 - 未修改。
     // 307 - 临时重定向。
     // 307 - 临时重定向。
 
 
-    /*-------------------------------------------------------------------------------------------*/
+    /* ------------------------------------------------------------------------------------------- */
     // 400开头的表示客户端错误请求错误,请求不到数据,或者找不到等等
     // 400开头的表示客户端错误请求错误,请求不到数据,或者找不到等等
     // 400 - 错误的请求
     // 400 - 错误的请求
     public const CLIENT_NOT_FOUND_HTTP_ERROR = [400001, '请求失败'];
     public const CLIENT_NOT_FOUND_HTTP_ERROR = [400001, '请求失败'];
@@ -75,7 +75,7 @@ class ResponseEnum
     // 417 – 执行失败
     // 417 – 执行失败
     // 423 – 锁定的错误
     // 423 – 锁定的错误
 
 
-    /*-------------------------------------------------------------------------------------------*/
+    /* ------------------------------------------------------------------------------------------- */
     // 500开头的表示服务器错误,服务器因为代码,或者什么原因终止运行
     // 500开头的表示服务器错误,服务器因为代码,或者什么原因终止运行
     // 服务端操作错误码:500 ~ 599 开头,后拼接 3 位
     // 服务端操作错误码:500 ~ 599 开头,后拼接 3 位
     // 500 - 内部服务器错误
     // 500 - 内部服务器错误
@@ -98,10 +98,10 @@ class ResponseEnum
 
 
     public const SERVICE_USER_INTEGRAL_ERROR = [500200, '积分不足'];
     public const SERVICE_USER_INTEGRAL_ERROR = [500200, '积分不足'];
 
 
-    //501 - 页眉值指定了未实现的配置
-    //502 - Web 服务器用作网关或代理服务器时收到了无效响应
-    //503 - 服务不可用。这个错误代码为 IIS 6.0 所专用
-    //504 - 网关超时
-    //505 - HTTP 版本不受支持
-    /*-------------------------------------------------------------------------------------------*/
+    // 501 - 页眉值指定了未实现的配置
+    // 502 - Web 服务器用作网关或代理服务器时收到了无效响应
+    // 503 - 服务不可用。这个错误代码为 IIS 6.0 所专用
+    // 504 - 网关超时
+    // 505 - HTTP 版本不受支持
+    /* ------------------------------------------------------------------------------------------- */
 }
 }

+ 1 - 1
app/Helpers/WebApiResponse.php

@@ -20,7 +20,7 @@ trait WebApiResponse
         $code = $code < 1000 ? $code : (int) ($code / 1000);
         $code = $code < 1000 ? $code : (int) ($code / 1000);
         $data = compact('status', 'code', 'data', 'message');
         $data = compact('status', 'code', 'data', 'message');
         if (isset($addition)) {
         if (isset($addition)) {
-            $data = array_merge($data, $addition);
+            $data += $addition;
         }
         }
 
 
         return response()->json($data, $code, ['ETAG' => $etag ?? '']);
         return response()->json($data, $code, ['ETAG' => $etag ?? '']);

+ 1 - 1
app/Http/Controllers/Admin/InviteController.php

@@ -50,7 +50,7 @@ class InviteController extends Controller
         }
         }
 
 
         header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); // 输出07Excel文件
         header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); // 输出07Excel文件
-        //header('Content-Type:application/vnd.ms-excel'); // 输出Excel03版本文件
+        // header('Content-Type:application/vnd.ms-excel'); // 输出Excel03版本文件
         header('Content-Disposition: attachment;filename="'.$filename.'"');
         header('Content-Disposition: attachment;filename="'.$filename.'"');
         header('Cache-Control: max-age=0');
         header('Cache-Control: max-age=0');
         try {
         try {

+ 1 - 1
app/Http/Controllers/Admin/LogsController.php

@@ -259,7 +259,7 @@ class LogsController extends Controller
 
 
     public function userTrafficMonitor(User $user): View
     public function userTrafficMonitor(User $user): View
     { // 用户流量监控
     { // 用户流量监控
-        return view('admin.logs.userMonitor', array_merge(['username' => $user->username], $this->dataFlowChart($user->id)));
+        return view('admin.logs.userMonitor', ['username' => $user->username, ...$this->dataFlowChart($user->id)]);
     }
     }
 
 
     public function callbackList(Request $request): View
     public function callbackList(Request $request): View

+ 1 - 1
app/Http/Controllers/Admin/NodeController.php

@@ -282,6 +282,6 @@ class NodeController extends Controller
 
 
     public function nodeMonitor(Node $node): View
     public function nodeMonitor(Node $node): View
     { // 节点流量监控
     { // 节点流量监控
-        return view('admin.node.monitor', array_merge(['nodeName' => $node->name, 'nodeServer' => $node->server], $this->DataFlowChart($node->id, true)));
+        return view('admin.node.monitor', ['nodeName' => $node->name, 'nodeServer' => $node->server, ...$this->DataFlowChart($node->id, true)]);
     }
     }
 }
 }

+ 9 - 9
app/Http/Controllers/Admin/ReportController.php

@@ -23,7 +23,7 @@ class ReportController extends Controller
     {
     {
         $completedOrders = Order::where('status', '>=', 2)->has('goods')->selectRaw('DATE(created_at) as date, sum(amount)/100 as total')->groupBy('date')->get();
         $completedOrders = Order::where('status', '>=', 2)->has('goods')->selectRaw('DATE(created_at) as date, sum(amount)/100 as total')->groupBy('date')->get();
 
 
-        $ordersByDay = $completedOrders->filter(fn ($order) => $order->date >= now()->subMonthNoOverflow()->startOfMonth()->format('Y-m-d'))->pluck('total', 'date');
+        $ordersByDay = $completedOrders->filter(fn ($order) => $order->date >= now()->subMonthNoOverflow()->startOfMonth()->toDateString())->pluck('total', 'date');
 
 
         $ordersByMonth = $completedOrders->filter(fn ($order) => $order->date >= now()->subYearNoOverflow()->startOfYear())->groupBy(fn ($order) => Carbon::parse($order->date)->format('Y-m'))->map(fn ($rows) => round($rows->sum('total'),
         $ordersByMonth = $completedOrders->filter(fn ($order) => $order->date >= now()->subYearNoOverflow()->startOfYear())->groupBy(fn ($order) => Carbon::parse($order->date)->format('Y-m'))->map(fn ($rows) => round($rows->sum('total'),
             2))->toArray();
             2))->toArray();
@@ -54,7 +54,7 @@ class ReportController extends Controller
         $user = $uid ? User::find($uid) : ($username ? User::whereUsername($username)->first() : null);
         $user = $uid ? User::find($uid) : ($username ? User::whereUsername($username)->first() : null);
 
 
         $data = [
         $data = [
-            'start_date' => Carbon::parse(UserDailyDataFlow::whereNotNull('node_id')->orderBy('created_at')->value('created_at'))->format('Y-m-d'),
+            'start_date' => Carbon::parse(UserDailyDataFlow::whereNotNull('node_id')->orderBy('created_at')->value('created_at'))->toDateString(),
         ];
         ];
 
 
         if ($user) {
         if ($user) {
@@ -137,7 +137,7 @@ class ReportController extends Controller
                 $dailyFlows = $dailyFlows->concat($todayData->map(fn ($item) => $item['daily']));
                 $dailyFlows = $dailyFlows->concat($todayData->map(fn ($item) => $item['daily']));
             }
             }
 
 
-            $data = array_merge($data, [
+            $data += [
                 'hours' => range(0, 23),
                 'hours' => range(0, 23),
                 'days' => collect(CarbonPeriod::create($startDate, $endDate))->map(fn ($date) => $date->format('m-d')),
                 'days' => collect(CarbonPeriod::create($startDate, $endDate))->map(fn ($date) => $date->format('m-d')),
                 'nodes' => $hourlyFlows->concat($dailyFlows)->pluck('name', 'id')->unique()->toArray(),
                 'nodes' => $hourlyFlows->concat($dailyFlows)->pluck('name', 'id')->unique()->toArray(),
@@ -147,7 +147,7 @@ class ReportController extends Controller
                     ->orderByDesc('date')
                     ->orderByDesc('date')
                     ->pluck('date')
                     ->pluck('date')
                     ->toArray(),
                     ->toArray(),
-            ]);
+            ];
         }
         }
 
 
         return view('admin.report.userDataAnalysis', compact('data'));
         return view('admin.report.userDataAnalysis', compact('data'));
@@ -160,7 +160,7 @@ class ReportController extends Controller
         $currentHour = $currentTime->hour;
         $currentHour = $currentTime->hour;
         $nodeId = $request->input('nodes');
         $nodeId = $request->input('nodes');
         $startDate = $request->input('start') ?? $currentTime->format('Y-m-01');
         $startDate = $request->input('start') ?? $currentTime->format('Y-m-01');
-        $endDate = $request->input('end') ?? $currentTime->format('Y-m-d');
+        $endDate = $request->input('end') ?? $currentTime->toDateString();
         $hour_date = $request->input('hour_date') ?? $currentTime; // 默认是今天
         $hour_date = $request->input('hour_date') ?? $currentTime; // 默认是今天
 
 
         $nodes = Node::orderBy('name')->pluck('name', 'id'); // 用于前端节点显示
         $nodes = Node::orderBy('name')->pluck('name', 'id'); // 用于前端节点显示
@@ -177,7 +177,7 @@ class ReportController extends Controller
 
 
         $data = [
         $data = [
             'hours' => range(0, 23),
             'hours' => range(0, 23),
-            'start_date' => Carbon::parse(NodeDailyDataFlow::orderBy('created_at')->value('created_at'))->format('Y-m-d'), // 数据库里最早的日期
+            'start_date' => Carbon::parse(NodeDailyDataFlow::orderBy('created_at')->value('created_at'))->toDateString(), // 数据库里最早的日期
         ];
         ];
 
 
         $hoursFlow = $hourlyQuery->whereDate('created_at', $hour_date)->selectRaw('node_id, HOUR(created_at) as hour, u + d as total')->get()->map(fn ($item) => [
         $hoursFlow = $hourlyQuery->whereDate('created_at', $hour_date)->selectRaw('node_id, HOUR(created_at) as hour, u + d as total')->get()->map(fn ($item) => [
@@ -202,7 +202,7 @@ class ReportController extends Controller
                 'total' => round($item->total / GiB, 2),
                 'total' => round($item->total / GiB, 2),
             ])->toArray();
             ])->toArray();
 
 
-            $hoursFlow = array_merge($hoursFlow, $currentHourFlow);
+            $hoursFlow += $currentHourFlow;
 
 
             if (Carbon::parse($endDate)->isToday()) {
             if (Carbon::parse($endDate)->isToday()) {
                 $currentDayFlow = collect($hoursFlow)->groupBy('id')->map(fn ($items) => [
                 $currentDayFlow = collect($hoursFlow)->groupBy('id')->map(fn ($items) => [
@@ -212,7 +212,7 @@ class ReportController extends Controller
                     'total' => round($items->sum('total'), 2),
                     'total' => round($items->sum('total'), 2),
                 ])->values()->toArray();
                 ])->values()->toArray();
 
 
-                $daysFlow = array_merge($daysFlow, $currentDayFlow);
+                $daysFlow += $currentDayFlow;
             }
             }
         } elseif (Carbon::parse($endDate)->isToday()) { // 如果结束日期是今天,本日流量需要另外计算
         } elseif (Carbon::parse($endDate)->isToday()) { // 如果结束日期是今天,本日流量需要另外计算
             $todayHourlyQuery = NodeHourlyDataFlow::query();
             $todayHourlyQuery = NodeHourlyDataFlow::query();
@@ -242,7 +242,7 @@ class ReportController extends Controller
                 'total' => round($items->sum('total'), 2),
                 'total' => round($items->sum('total'), 2),
             ])->values()->toArray();
             ])->values()->toArray();
 
 
-            $daysFlow = array_merge($daysFlow, $currentDayFlow);
+            $daysFlow += $currentDayFlow;
         }
         }
 
 
         $data['hourlyFlows'] = $hoursFlow;
         $data['hourlyFlows'] = $hoursFlow;

+ 3 - 3
app/Http/Controllers/Admin/ToolsController.php

@@ -42,7 +42,7 @@ class ToolsController extends Controller
             }
             }
 
 
             // 生成转换好的JSON文件
             // 生成转换好的JSON文件
-            //file_put_contents(public_path('downloads/decompile.json'), $txt);
+            // file_put_contents(public_path('downloads/decompile.json'), $txt);
 
 
             return response()->json(['status' => 'success', 'data' => $txt, 'message' => trans('common.success_item', ['attribute' => trans('admin.tools.decompile.attribute')])]);
             return response()->json(['status' => 'success', 'data' => $txt, 'message' => trans('common.success_item', ['attribute' => trans('admin.tools.decompile.attribute')])]);
         }
         }
@@ -254,9 +254,9 @@ class ToolsController extends Controller
         $fp = fopen($file, 'rb');
         $fp = fopen($file, 'rb');
         $i = 0;
         $i = 0;
         while (! feof($fp)) {
         while (! feof($fp)) {
-            //每次读取2M
+            // 每次读取2M
             if ($data = fread($fp, 1024 * 1024 * 2)) {
             if ($data = fread($fp, 1024 * 1024 * 2)) {
-                //计算读取到的行数
+                // 计算读取到的行数
                 $num = substr_count($data, "\n");
                 $num = substr_count($data, "\n");
                 $i += $num;
                 $i += $num;
             }
             }

+ 2 - 2
app/Http/Controllers/MessageController.php

@@ -10,12 +10,12 @@ class MessageController extends Controller
 {
 {
     public function index(string $type, string $msgId): View
     public function index(string $type, string $msgId): View
     {
     {
-        //if ($type === 'markdown') {
+        // if ($type === 'markdown') {
         $log = NotificationLog::whereMsgId($msgId)->latest()->firstOrFail();
         $log = NotificationLog::whereMsgId($msgId)->latest()->firstOrFail();
         $title = $log->title;
         $title = $log->title;
         $content = Markdown::parse($log->content)->toHtml();
         $content = Markdown::parse($log->content)->toHtml();
 
 
         return view('components.message', compact('title', 'content'));
         return view('components.message', compact('title', 'content'));
-        //}
+        // }
     }
     }
 }
 }

+ 2 - 2
app/Http/Controllers/UserController.php

@@ -32,7 +32,7 @@ class UserController extends Controller
             $query->latest()->first();
             $query->latest()->first();
         }]);
         }]);
 
 
-        return view('user.index', array_merge([
+        return view('user.index', [
             'remainDays' => $userService->getRemainingDays(),
             'remainDays' => $userService->getRemainingDays(),
             'resetDays' => $userService->getResetDays(),
             'resetDays' => $userService->getResetDays(),
             'unusedPercent' => $userService->getUnusedTrafficPercent(),
             'unusedPercent' => $userService->getUnusedTrafficPercent(),
@@ -45,7 +45,7 @@ class UserController extends Controller
             'userLoginLog' => $user->loginLogs->first(), // 近期登录日志
             'userLoginLog' => $user->loginLogs->first(), // 近期登录日志
             'subType' => $nodeService->getActiveNodeTypes($user->nodes()),
             'subType' => $nodeService->getActiveNodeTypes($user->nodes()),
             'subscribe' => $user->subscribe->only(['status', 'ban_desc']),
             'subscribe' => $user->subscribe->only(['status', 'ban_desc']),
-        ], $this->dataFlowChart($user->id)));
+            ...$this->dataFlowChart($user->id)]);
     }
     }
 
 
     // 签到
     // 签到

+ 1 - 1
app/Http/Requests/Admin/RuleRequest.php

@@ -14,7 +14,7 @@ class RuleRequest extends FormRequest
         ];
         ];
 
 
         if (! in_array($this->method(), ['PATCH', 'PUT'], true)) {
         if (! in_array($this->method(), ['PATCH', 'PUT'], true)) {
-            $rules = array_merge(['type' => 'required|numeric|between:1,4'], $rules);
+            $rules += ['type' => 'required|numeric|between:1,4'];
         }
         }
 
 
         return $rules;
         return $rules;

+ 2 - 2
app/Observers/UserObserver.php

@@ -36,8 +36,8 @@ class UserObserver
                         addUser::dispatch($user->id, $allowNodes);
                         addUser::dispatch($user->id, $allowNodes);
                     }
                     }
                 } else {
                 } else {
-                    $old = $oldAllowNodes->diff($allowNodes); //old 有 allow 没有
-                    $new = $allowNodes->diff($oldAllowNodes); //allow 有 old 没有
+                    $old = $oldAllowNodes->diff($allowNodes); // old 有 allow 没有
+                    $new = $allowNodes->diff($oldAllowNodes); // allow 有 old 没有
                     if ($old->isNotEmpty()) {
                     if ($old->isNotEmpty()) {
                         delUser::dispatch($user->id, $old);
                         delUser::dispatch($user->id, $old);
                     }
                     }

+ 8 - 7
app/Services/OrderService.php

@@ -86,6 +86,7 @@ class OrderService
             'level' => self::$goods->level,
             'level' => self::$goods->level,
             'speed_limit' => self::$goods->speed_limit,
             'speed_limit' => self::$goods->speed_limit,
             'enable' => 1,
             'enable' => 1,
+            ...$this->resetTimeAndData(),
         ];
         ];
 
 
         // 无端口用户 添加端口
         // 无端口用户 添加端口
@@ -93,7 +94,7 @@ class OrderService
             $updateData['port'] = Helpers::getPort();
             $updateData['port'] = Helpers::getPort();
         }
         }
 
 
-        if (self::$user->update(array_merge($this->resetTimeAndData(), $updateData))) {
+        if (self::$user->update($updateData)) {
             return Helpers::addUserTrafficModifyLog($this->order->user_id, $oldData, self::$user->transfer_enable, trans('[:payment] plus the user’s purchased data plan.', ['payment' => $this->order->pay_way]), $this->order->id);
             return Helpers::addUserTrafficModifyLog($this->order->user_id, $oldData, self::$user->transfer_enable, trans('[:payment] plus the user’s purchased data plan.', ['payment' => $this->order->pay_way]), $this->order->id);
         }
         }
 
 
@@ -106,8 +107,8 @@ class OrderService
             $expired_at = $this->getFinallyExpiredTime();
             $expired_at = $this->getFinallyExpiredTime();
         }
         }
 
 
-        //账号流量重置日期
-        $nextResetTime = now()->addDays(self::$goods->period)->format('Y-m-d');
+        // 账号流量重置日期
+        $nextResetTime = now()->addDays(self::$goods->period)->toDateString();
         if ($nextResetTime >= $expired_at) {
         if ($nextResetTime >= $expired_at) {
             $nextResetTime = null;
             $nextResetTime = null;
         }
         }
@@ -126,7 +127,7 @@ class OrderService
         $orders = self::$user->orders()->whereIn('status', [2, 3])->whereIsExpire(0)->isPlan()->get();
         $orders = self::$user->orders()->whereIn('status', [2, 3])->whereIsExpire(0)->isPlan()->get();
         $current = $orders->where('status', '==', 2)->first();
         $current = $orders->where('status', '==', 2)->first();
 
 
-        return ($current->expired_at ?? now())->addDays($orders->except($current->id ?? 0)->sum('goods.days'))->format('Y-m-d');
+        return ($current->expired_at ?? now())->addDays($orders->except($current->id ?? 0)->sum('goods.days'))->toDateString();
     }
     }
 
 
     private function setCommissionExpense(User $user): void
     private function setCommissionExpense(User $user): void
@@ -159,8 +160,8 @@ class OrderService
     { // 刷新账号有效时间
     { // 刷新账号有效时间
         $data = ['expired_at' => $this->getFinallyExpiredTime()];
         $data = ['expired_at' => $this->getFinallyExpiredTime()];
 
 
-        if ($data['expired_at'] < now()->format('Y-m-d')) {
-            $data = array_merge([
+        if ($data['expired_at'] < now()->toDateString()) {
+            $data += [
                 'u' => 0,
                 'u' => 0,
                 'd' => 0,
                 'd' => 0,
                 'transfer_enable' => 0,
                 'transfer_enable' => 0,
@@ -168,7 +169,7 @@ class OrderService
                 'level' => 0,
                 'level' => 0,
                 'reset_time' => null,
                 'reset_time' => null,
                 'ban_time' => null,
                 'ban_time' => null,
-            ], $data);
+            ];
         }
         }
 
 
         return self::$user->update($data);
         return self::$user->update($data);

+ 2 - 1
app/Services/ProxyService.php

@@ -108,6 +108,7 @@ class ProxyService
             'udp' => $node->is_udp,
             'udp' => $node->is_udp,
         ];
         ];
 
 
+        // 如果是中转节点,递归处理父节点配置
         if ($node->relay_node_id) {
         if ($node->relay_node_id) {
             $parentConfig = $this->getProxyConfig($node->relayNode);
             $parentConfig = $this->getProxyConfig($node->relayNode);
             $config = array_merge($config, Arr::except($parentConfig, ['id', 'name', 'host', 'group', 'udp']));
             $config = array_merge($config, Arr::except($parentConfig, ['id', 'name', 'host', 'group', 'udp']));
@@ -207,7 +208,7 @@ class ProxyService
             }
             }
         }
         }
 
 
-        return URLSchemes::build($this->getServers()); // Origin
+        return URLSchemes::build($this->getServers()); // Default return
     }
     }
 
 
     public function getProxyCode(string $target, ?int $type = null): ?string
     public function getProxyCode(string $target, ?int $type = null): ?string

+ 2 - 2
app/Utils/Avatar.php

@@ -59,12 +59,12 @@ class Avatar
     }
     }
 
 
     private static function qZonePortrait(string $url, string $qq): ?string
     private static function qZonePortrait(string $url, string $qq): ?string
-    { //向接口发起请求获取json数据
+    { // 向接口发起请求获取json数据
         $response = self::$basicRequest->get($url);
         $response = self::$basicRequest->get($url);
         if ($response->ok()) {
         if ($response->ok()) {
             $message = mb_convert_encoding($response->body(), 'UTF-8', 'GBK');
             $message = mb_convert_encoding($response->body(), 'UTF-8', 'GBK');
             if (str_contains($message, $qq)) { // 接口是否异常
             if (str_contains($message, $qq)) { // 接口是否异常
-                $message = json_decode(substr($message, 17, -1), true); //对获取的json数据进行截取并解析成数组
+                $message = json_decode(substr($message, 17, -1), true); // 对获取的json数据进行截取并解析成数组
 
 
                 return stripslashes($message[$qq][0]);
                 return stripslashes($message[$qq][0]);
             }
             }

+ 1 - 1
app/Utils/Clients/Quantumult.php

@@ -19,7 +19,7 @@ class Quantumult implements Client
 
 
     public function getConfig(array $servers, User $user, string $target): string
     public function getConfig(array $servers, User $user, string $target): string
     {
     {
-        //display remaining traffic and expire date
+        // display remaining traffic and expire date
         if (sysConfig('is_custom_subscribe')) {
         if (sysConfig('is_custom_subscribe')) {
             header("Subscription-Userinfo: upload=$user->u; download=$user->d; total=$user->transfer_enable; expire=".strtotime($user->expired_at));
             header("Subscription-Userinfo: upload=$user->u; download=$user->d; total=$user->transfer_enable; expire=".strtotime($user->expired_at));
         }
         }

+ 1 - 1
app/Utils/Clients/Shadowrocket.php

@@ -13,7 +13,7 @@ class Shadowrocket implements Client
     public function getConfig(array $servers, User $user): string
     public function getConfig(array $servers, User $user): string
     {
     {
         $uri = '';
         $uri = '';
-        //display remaining traffic and expire date
+        // display remaining traffic and expire date
         if (sysConfig('is_custom_subscribe')) {
         if (sysConfig('is_custom_subscribe')) {
             $usedTraffic = formatBytes($user->used_traffic);
             $usedTraffic = formatBytes($user->used_traffic);
             $remainTraffic = formatBytes($user->unused_traffic);
             $remainTraffic = formatBytes($user->unused_traffic);

+ 4 - 4
app/Utils/DDNS/AliYun.php

@@ -66,16 +66,16 @@ class AliYun implements DNS
 
 
     private function sendRequest(string $action, array $parameters = []): array
     private function sendRequest(string $action, array $parameters = []): array
     {
     {
-        $parameters = array_merge([
+        $parameters += [
             'Action' => $action,
             'Action' => $action,
             'Format' => 'JSON',
             'Format' => 'JSON',
             'Version' => '2015-01-09',
             'Version' => '2015-01-09',
             'AccessKeyId' => $this->accessKeyID,
             'AccessKeyId' => $this->accessKeyID,
             'SignatureMethod' => 'HMAC-SHA1',
             'SignatureMethod' => 'HMAC-SHA1',
-            'Timestamp' => gmdate("Y-m-d\TH:i:s\Z"), //公共参数Timestamp GMT时间
+            'Timestamp' => gmdate("Y-m-d\TH:i:s\Z"), // 公共参数Timestamp GMT时间
             'SignatureVersion' => '1.0',
             'SignatureVersion' => '1.0',
-            'SignatureNonce' => str_replace('.', '', microtime(true)), //唯一数,用于防止网络重放攻击
-        ], $parameters);
+            'SignatureNonce' => str_replace('.', '', microtime(true)), // 唯一数,用于防止网络重放攻击
+        ];
         $parameters['Signature'] = $this->generateSignature($parameters);
         $parameters['Signature'] = $this->generateSignature($parameters);
 
 
         $response = Http::asForm()->timeout(15)->post(self::API_ENDPOINT, $parameters);
         $response = Http::asForm()->timeout(15)->post(self::API_ENDPOINT, $parameters);

+ 1 - 1
app/Utils/DDNS/ClouDNS.php

@@ -53,7 +53,7 @@ class ClouDNS implements DNS
 
 
     private function sendRequest(string $action, array $parameters = []): array
     private function sendRequest(string $action, array $parameters = []): array
     {
     {
-        $response = Http::timeout(15)->get(self::API_ENDPOINT."$action.json", array_merge(['auth-id' => $this->authID, 'auth-password' => $this->authPassword], $parameters));
+        $response = Http::timeout(15)->get(self::API_ENDPOINT."$action.json", ['auth-id' => $this->authID, 'auth-password' => $this->authPassword, ...$parameters]);
 
 
         if ($response->successful()) {
         if ($response->successful()) {
             $data = $response->json();
             $data = $response->json();

+ 1 - 9
app/Utils/DDNS/Namecheap.php

@@ -62,15 +62,7 @@ class Namecheap implements DNS
 
 
     private function sendRequest(string $action, array $parameters = []): array
     private function sendRequest(string $action, array $parameters = []): array
     {
     {
-        $parameters = array_merge([
-            'ApiUser' => $this->username,
-            'ApiKey' => $this->apiKey,
-            'UserName' => $this->username,
-            'ClientIp' => IP::getClientIP(),
-            'Command' => $action,
-        ], $parameters);
-
-        $response = Http::timeout(15)->retry(3, 1000)->get(self::API_ENDPOINT, $parameters);
+        $response = Http::timeout(15)->retry(3, 1000)->get(self::API_ENDPOINT, ['ApiUser' => $this->username, 'ApiKey' => $this->apiKey, 'UserName' => $this->username, 'ClientIp' => IP::getClientIP(), 'Command' => $action, ...$parameters]);
         $data = $response->body();
         $data = $response->body();
         if ($data) {
         if ($data) {
             $data = json_decode(json_encode(simplexml_load_string($data)), true);
             $data = json_decode(json_encode(simplexml_load_string($data)), true);

+ 1 - 1
app/Utils/DDNS/Namesilo.php

@@ -50,7 +50,7 @@ class Namesilo implements DNS
 
 
     private function sendRequest(string $action, array $parameters = []): array
     private function sendRequest(string $action, array $parameters = []): array
     {
     {
-        $response = Http::timeout(15)->retry(3, 1000)->get(self::API_ENDPOINT.$action, array_merge(['version' => 1, 'type' => 'json', 'key' => $this->apiKey], $parameters));
+        $response = Http::timeout(15)->retry(3, 1000)->get(self::API_ENDPOINT.$action, ['version' => 1, 'type' => 'json', 'key' => $this->apiKey, ...$parameters]);
 
 
         if ($response->ok()) {
         if ($response->ok()) {
             $data = $response->json();
             $data = $response->json();

+ 1 - 2
app/Utils/DDNS/Porkbun.php

@@ -53,8 +53,7 @@ class Porkbun implements DNS
 
 
     private function sendRequest(string $uri, array $parameters = []): array|bool
     private function sendRequest(string $uri, array $parameters = []): array|bool
     {
     {
-        $parameters = array_merge($parameters, ['apikey' => $this->apiKey, 'secretapikey' => $this->secretKey]);
-        $response = Http::timeout(15)->retry(3, 1000)->baseUrl(self::API_ENDPOINT)->asJson()->post($uri, $parameters);
+        $response = Http::timeout(15)->retry(3, 1000)->baseUrl(self::API_ENDPOINT)->asJson()->post($uri, ['apikey' => $this->apiKey, 'secretapikey' => $this->secretKey, ...$parameters]);
 
 
         $data = $response->json();
         $data = $response->json();
         if ($response->successful()) {
         if ($response->successful()) {

+ 1 - 1
app/Utils/Helpers.php

@@ -68,7 +68,7 @@ class Helpers
             'protocol' => self::getDefaultProtocol(),
             'protocol' => self::getDefaultProtocol(),
             'obfs' => self::getDefaultObfs(),
             'obfs' => self::getDefaultObfs(),
             'transfer_enable' => $transfer_enable,
             'transfer_enable' => $transfer_enable,
-            'expired_at' => now()->addDays($date)->format('Y-m-d'),
+            'expired_at' => now()->addDays($date)->toDateString(),
             'user_group_id' => null,
             'user_group_id' => null,
             'reg_ip' => IP::getClientIp(),
             'reg_ip' => IP::getClientIp(),
             'inviter_id' => $inviter_id,
             'inviter_id' => $inviter_id,

+ 23 - 23
config/client.php

@@ -46,31 +46,31 @@ return [
     'subscribe_url' => 'http://api.xxx.com',
     'subscribe_url' => 'http://api.xxx.com',
 
 
     // 签到获得流量
     // 签到获得流量
-    'checkinMin' => 1, //用户签到最少流量 单位MB
-    'checkinMax' => 50, //用户签到最多流量
+    'checkinMin' => 1, // 用户签到最少流量 单位MB
+    'checkinMax' => 50, // 用户签到最多流量
 
 
-    'code_payback' => 10, //充值返利百分比
-    'invite_gift' => 2, //邀请新用户获得流量奖励,单位G
+    'code_payback' => 10, // 充值返利百分比
+    'invite_gift' => 2, // 邀请新用户获得流量奖励,单位G
 
 
     // 软件版本和更新地址
     // 软件版本和更新地址
     'vpn_update' => [
     'vpn_update' => [
-        'enable' => false,                           //是否开启更新
+        'enable' => false,                           // 是否开启更新
         'android' => [
         'android' => [
             'version' => '2.4.3',                    // 版本号
             'version' => '2.4.3',                    // 版本号
-            'download_url' => env('APP_URL').'/clients/bob.apk',       //下载地址
-            'message' => '版本更新:<br/>1.添加点击签到提示框<br/>2.修复剩余流量显示问题',       //提示信息
-            'must' => false,                          //true:强制更新  false:不强制更新
+            'download_url' => env('APP_URL').'/clients/bob.apk',       // 下载地址
+            'message' => '版本更新:<br/>1.添加点击签到提示框<br/>2.修复剩余流量显示问题',       // 提示信息
+            'must' => false,                          // true:强制更新  false:不强制更新
         ],
         ],
         'windows' => [
         'windows' => [
             'version' => '3.7.0',                    // 版本号
             'version' => '3.7.0',                    // 版本号
-            'download_url' => env('APP_URL').'/clients/bob.exe',       //下载地址
-            'message' => '版本更新:<br/>1.修复剩余流量显示问题<br/>2.优化节点测试显示<br/>3.修复弹出网页部分按钮无法使用问题',       //提示信息
-            'must' => false,                          //true:强制更新  false:不强制更新
+            'download_url' => env('APP_URL').'/clients/bob.exe',       // 下载地址
+            'message' => '版本更新:<br/>1.修复剩余流量显示问题<br/>2.优化节点测试显示<br/>3.修复弹出网页部分按钮无法使用问题',       // 提示信息
+            'must' => false,                          // true:强制更新  false:不强制更新
         ],
         ],
         'mac' => [
         'mac' => [
             'version' => '3.7.0',                    // 版本号
             'version' => '3.7.0',                    // 版本号
             'download_url' => env('APP_URL').'/clients/bob.zip',       // 下载地址
             'download_url' => env('APP_URL').'/clients/bob.zip',       // 下载地址
-            'message' => '版本更新:<br/>1.修复剩余流量显示问题<br/>2.优化节点测试显示<br/>3.修复弹出网页部分按钮无法使用问题',       //提示信息
+            'message' => '版本更新:<br/>1.修复剩余流量显示问题<br/>2.优化节点测试显示<br/>3.修复弹出网页部分按钮无法使用问题',       // 提示信息
             'must' => false,                          // true:强制更新  false:不强制更新
             'must' => false,                          // true:强制更新  false:不强制更新
         ],
         ],
     ],
     ],
@@ -136,19 +136,19 @@ return [
         ],
         ],
         // 易支付
         // 易支付
         'policepay' => [
         'policepay' => [
-            'partner' => '', //商户号
-            'key' => '', //商户key
+            'partner' => '', // 商户号
+            'key' => '', // 商户key
             'sign_type' => strtoupper('MD5'),
             'sign_type' => strtoupper('MD5'),
             'input_charset' => strtolower('utf-8'),
             'input_charset' => strtolower('utf-8'),
-            'name' => '手抓饼',                  //商品名称,目前无意义
-            'transport' => 'https',                   //访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http
-            'appname' => 'PolicePay',           //网站英文名
-            'apiurl' => 'https://policepay.cc/',      //支付网关 注意结尾的/符号
-            'min_price' => '1',                       //最小支付金额(请填正数)
+            'name' => '手抓饼',                  // 商品名称,目前无意义
+            'transport' => 'https',                   // 访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http
+            'appname' => 'PolicePay',           // 网站英文名
+            'apiurl' => 'https://policepay.cc/',      // 支付网关 注意结尾的/符号
+            'min_price' => '1',                       // 最小支付金额(请填正数)
         ],
         ],
         // 当面付
         // 当面付
         'facepay' => [
         'facepay' => [
-            'alipay_app_id' => '',              //商户号
+            'alipay_app_id' => '',              // 商户号
             'merchant_private_key' => '',
             'merchant_private_key' => '',
             'alipay_public_key' => '',
             'alipay_public_key' => '',
         ],
         ],
@@ -156,9 +156,9 @@ return [
 
 
     // 商城配置
     // 商城配置
     'shop_plan' => [
     'shop_plan' => [
-        '标准会员' => [1, 2, 3, 4],  //对应商店显示的名称 + [商品ID]
-        '高级会员' => [1, 2, 3, 4],  //对应商店显示的名称 + [商品ID]
-        '至尊会员' => [1, 2, 3, 4],  //对应商店显示的名称 + [商品ID]
+        '标准会员' => [1, 2, 3, 4],  // 对应商店显示的名称 + [商品ID]
+        '高级会员' => [1, 2, 3, 4],  // 对应商店显示的名称 + [商品ID]
+        '至尊会员' => [1, 2, 3, 4],  // 对应商店显示的名称 + [商品ID]
     ],
     ],
 
 
     // 购买配置
     // 购买配置

+ 1 - 1
routes/admin.php

@@ -144,7 +144,7 @@ Route::prefix('admin')->name('admin.')->group(function () {
         Route::get('system', 'index')->name('system.index'); // 系统设置
         Route::get('system', 'index')->name('system.index'); // 系统设置
         Route::post('setExtend', 'setExtend')->name('system.extend'); // 设置logo图片文件
         Route::post('setExtend', 'setExtend')->name('system.extend'); // 设置logo图片文件
         Route::post('setConfig', 'setConfig')->name('system.update'); // 设置某个配置项
         Route::post('setConfig', 'setConfig')->name('system.update'); // 设置某个配置项
-        Route::post('sendTestNotification', 'sendTestNotification')->name('test.notify'); //推送通知测试
+        Route::post('sendTestNotification', 'sendTestNotification')->name('test.notify'); // 推送通知测试
         Route::get('config', 'common')->name('config.index'); // 系统通用配置
         Route::get('config', 'common')->name('config.index'); // 系统通用配置
     });
     });
     Route::get('epayInfo', [EPay::class, 'queryInfo'])->name('test.epay'); // 易支付信息
     Route::get('epayInfo', [EPay::class, 'queryInfo'])->name('test.epay'); // 易支付信息

+ 1 - 1
routes/api.php

@@ -57,7 +57,7 @@ Route::prefix('v1')->group(function () { // 客户端API
     Route::controller(AuthController::class)->group(function () {
     Route::controller(AuthController::class)->group(function () {
         Route::post('login', 'login'); // 登录
         Route::post('login', 'login'); // 登录
         Route::post('register', 'register'); // 注册
         Route::post('register', 'register'); // 注册
-        Route::get('logout', 'logout'); //登出
+        Route::get('logout', 'logout'); // 登出
     });
     });
     Route::controller(ClientController::class)->group(function () {
     Route::controller(ClientController::class)->group(function () {
         Route::get('getconfig', 'getConfig'); // 获取配置文件
         Route::get('getconfig', 'getConfig'); // 获取配置文件