From 52b44c457ac47d5ff8255ed50bd5fa7057e3090b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=94=E5=A7=AC=E6=A1=91?= <867057410@qq.com> Date: Sun, 4 Sep 2022 22:23:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 去除 中转节点每小时/每日流量统计; 添加 中转节点状态检测; 添加 人工支付订单未处理自动关闭; --- app/Console/Commands/AutoJob.php | 5 +++++ app/Console/Commands/DailyJob.php | 4 ++-- app/Console/Commands/NodeDailyTrafficStatistics.php | 2 +- app/Console/Commands/NodeHourlyTrafficStatistics.php | 3 +-- app/Console/Commands/NodeStatusDetection.php | 2 +- app/Models/Order.php | 2 +- config/tasks.php | 7 ++++--- resources/views/user/components/payment/default.blade.php | 2 +- 8 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/Console/Commands/AutoJob.php b/app/Console/Commands/AutoJob.php index 6bbbed06..29b83aab 100644 --- a/app/Console/Commands/AutoJob.php +++ b/app/Console/Commands/AutoJob.php @@ -28,6 +28,11 @@ class AutoJob extends Command Order::recentUnPay()->chunk(config('tasks.chunk'), function ($orders) { $orders->each->close(); }); // 关闭超时未支付本地订单 + + Order::whereStatus(1)->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-'.config('tasks.close.confirmation_orders').' hours')))->chunk(config('tasks.chunk'), function ($orders) { + $orders->each->close(); + }); // 关闭未处理的人工支付订单 + $this->expireCode(); //过期验证码、优惠券、邀请码无效化 if (sysConfig('is_subscribe_ban')) { diff --git a/app/Console/Commands/DailyJob.php b/app/Console/Commands/DailyJob.php index 98583815..1a5fe549 100644 --- a/app/Console/Commands/DailyJob.php +++ b/app/Console/Commands/DailyJob.php @@ -82,12 +82,12 @@ class DailyJob extends Command $q->where('admin_id', '<>', null); }) ->has('reply') - ->where('updated_at', '<=', date('Y-m-d', strtotime('-'.config('tasks.close.ticket').' hours'))) + ->where('updated_at', '<=', date('Y-m-d', strtotime('-'.config('tasks.close.tickets').' hours'))) ->chunk(config('tasks.chunk'), function ($tickets) { foreach ($tickets as $ticket) { if ($ticket->close()) { $ticket->user->notify(new TicketClosed($ticket->id, $ticket->title, route('replyTicket', ['id' => $ticket->id]), - __('You have not responded this ticket in :num hours, System has closed your ticket.', ['num' => config('tasks.close.ticket')]))); + __('You have not responded this ticket in :num hours, System has closed your ticket.', ['num' => config('tasks.close.tickets')]))); } } }); diff --git a/app/Console/Commands/NodeDailyTrafficStatistics.php b/app/Console/Commands/NodeDailyTrafficStatistics.php index 2c60912b..8577a860 100644 --- a/app/Console/Commands/NodeDailyTrafficStatistics.php +++ b/app/Console/Commands/NodeDailyTrafficStatistics.php @@ -15,7 +15,7 @@ class NodeDailyTrafficStatistics extends Command { $jobTime = microtime(true); - foreach (Node::whereStatus(1)->orderBy('id')->with('userDataFlowLogs')->whereHas('userDataFlowLogs')->get() as $node) { + foreach (Node::whereRelayNodeId(null)->whereStatus(1)->orderBy('id')->with('userDataFlowLogs')->whereHas('userDataFlowLogs')->get() as $node) { $this->statisticsByNode($node); } diff --git a/app/Console/Commands/NodeHourlyTrafficStatistics.php b/app/Console/Commands/NodeHourlyTrafficStatistics.php index b2841e45..87d083c4 100644 --- a/app/Console/Commands/NodeHourlyTrafficStatistics.php +++ b/app/Console/Commands/NodeHourlyTrafficStatistics.php @@ -10,13 +10,12 @@ class NodeHourlyTrafficStatistics extends Command { protected $signature = 'nodeHourlyTrafficStatistics'; protected $description = '节点每小时流量统计'; - protected $guarded = []; public function handle() { $jobTime = microtime(true); - foreach (Node::whereStatus(1)->orderBy('id')->with('userDataFlowLogs')->whereHas('userDataFlowLogs')->get() as $node) { + foreach (Node::whereRelayNodeId(null)->whereStatus(1)->orderBy('id')->with('userDataFlowLogs')->whereHas('userDataFlowLogs')->get() as $node) { $this->statisticsByNode($node); } diff --git a/app/Console/Commands/NodeStatusDetection.php b/app/Console/Commands/NodeStatusDetection.php index 463a5fb2..8aea8f70 100644 --- a/app/Console/Commands/NodeStatusDetection.php +++ b/app/Console/Commands/NodeStatusDetection.php @@ -74,7 +74,7 @@ class NodeStatusDetection extends Command { $detectionCheckTimes = sysConfig('detection_check_times'); - foreach (Node::whereRelayNodeId(null)->whereStatus(1)->where('detection_type', '<>', 0)->get() as $node) { + foreach (Node::whereStatus(1)->where('detection_type', '<>', 0)->get() as $node) { $node_id = $node->id; // 使用DDNS的node先通过gethostbyname获取ipv4地址 foreach ($node->ips() as $ip) { diff --git a/app/Models/Order.php b/app/Models/Order.php index e8417d66..c40f158c 100644 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -48,7 +48,7 @@ class Order extends Model public function scopeRecentUnPay($query, int $minutes = 0) { if (! $minutes) { - $minutes = config('tasks.close.order'); + $minutes = config('tasks.close.orders'); } return $query->whereStatus(0)->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-'.$minutes.' minutes'))); diff --git a/config/tasks.php b/config/tasks.php index 3933e07e..577fc54b 100644 --- a/config/tasks.php +++ b/config/tasks.php @@ -20,9 +20,10 @@ return [ 'traffic_logs' => '-3 days', // 清除用户流量日志 ], 'close' => [ - 'ticket' => 72, // 自动关闭工单,单位:小时 - 'order' => 15, // 自动关闭订单,单位:分钟 - 'verify' => 15, // 自动失效验证码,单位:分钟 + 'tickets' => 72, // 自动关闭工单,单位:小时 + 'confirmation_orders' => 12, // 自动关闭人工支付订单,单位:小时 + 'orders' => 15, // 自动关闭订单,单位:分钟 + 'verify' => 15, // 自动失效验证码,单位:分钟 ], 'release_port' => 30, // 端口自动释放,单位:天 'recently_heartbeat' => '-10 minutes', // 节点近期负载 diff --git a/resources/views/user/components/payment/default.blade.php b/resources/views/user/components/payment/default.blade.php index d1a248b4..fb3b0717 100644 --- a/resources/views/user/components/payment/default.blade.php +++ b/resources/views/user/components/payment/default.blade.php @@ -19,7 +19,7 @@ @if($days !== 0)