瀏覽代碼

优化关闭工单操作 & 维护模式判断条件

兔姬桑 4 年之前
父節點
當前提交
fac8dacd17

+ 2 - 2
app/Console/Commands/AutoJob.php

@@ -53,8 +53,8 @@ class AutoJob extends Command
         $this->checkNodeStatus();
 
         // 检查维护模式
-        if (sysConfig('maintenance_mode')) {
-            Config::whereIn('name', ['maintenance_mode', 'maintenance_time'])->update(['value' => null]);
+        if (sysConfig('maintenance_mode') && sysConfig('maintenance_time') && sysConfig('maintenance_time') <= date('c')) {
+            Config::whereIn('name', ['maintenance_mode', 'maintenance_content', 'maintenance_time'])->update(['value' => null]);
         }
 
         $jobEndTime = microtime(true);

+ 2 - 4
app/Console/Commands/DailyJob.php

@@ -104,10 +104,8 @@ class DailyJob extends Command
     // 关闭超过72小时未处理的工单
     private function closeTickets(): void
     {
-        $ticketList = Ticket::where('updated_at', '<=', date('Y-m-d', strtotime('-3 days')))->whereStatus(1)->get();
-        foreach ($ticketList as $ticket) {
-            $ret = Ticket::whereId($ticket->id)->update(['status' => 2]);
-            if ($ret) {
+        foreach (Ticket::where('updated_at', '<=', date('Y-m-d', strtotime('-3 days')))->whereStatus(1)->get() as $ticket) {
+            if ($ticket->close()) {
                 PushNotification::send('工单关闭提醒', '工单:ID'.$ticket->id.'超过72小时未处理,系统已自动关闭');
             }
         }

+ 2 - 2
app/Http/Controllers/Admin/TicketController.php

@@ -125,9 +125,9 @@ class TicketController extends Controller
     // 关闭工单
     public function destroy($id)
     {
-        $ticket = Ticket::findOrFail($id)->with('user');
+        $ticket = Ticket::with('user')->find($id);
 
-        if (! Ticket::whereId($id)->update(['status' => 2])) {
+        if (! $ticket->close()) {
             return Response::json(['status' => 'fail', 'message' => '关闭失败']);
         }
 

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

@@ -384,8 +384,7 @@ class UserController extends Controller
     {
         $id = $request->input('id');
 
-        $ret = Ticket::uid()->whereId($id)->update(['status' => 2]);
-        if ($ret) {
+        if (Ticket::uid()->whereId($id)->close()) {
             PushNotification::send('工单关闭提醒', '工单:ID'.$id.'用户已手动关闭');
 
             return Response::json(['status' => 'success', 'message' => '关闭成功']);

+ 7 - 0
app/Models/Ticket.php

@@ -28,6 +28,13 @@ class Ticket extends Model
         return $this->BelongsTo(User::class);
     }
 
+    public function close(): bool
+    {
+        $this->status = 2;
+
+        return $this->save();
+    }
+
     public function getStatusLabelAttribute(): string
     {
         switch ($this->attributes['status']) {

File diff suppressed because it is too large
+ 174 - 160
composer.lock


+ 1 - 1
config/version.php

@@ -2,5 +2,5 @@
 
 return [
     'name' => 'ProxyPanel',
-    'number' => '2.5.1',
+    'number' => '2.5.x',
 ];

+ 2 - 1
readme.md

@@ -3,9 +3,10 @@
 
 Support but not limited to: Shadowsocks,ShadowsocksR,ShadowsocksRR,V2Ray,Trojan,VNET
 
-- [Demo](https://demo.proxypanel.ml/) 
+- [Demo](https://demo.proxypanel.ml/) Demo will always on dev/latest code, rather than the stable version.
     - Account: test@test.com
     - Password: 123456
+- [Wiki](https://proxypanel.gitbook.io/wiki/)
 - [Issues](https://github.com/ZBrettonYe/ProxyPanel/issues)
 - [UpdateLog](https://proxypanel.gitbook.io/wiki/updatelog)
 - [Upcoming](https://github.com/ZBrettonYe/ProxyPanel/projects/2)

+ 1 - 1
resources/views/admin/layouts.blade.php

@@ -38,7 +38,7 @@
     <!-- Scripts -->
     <script src="/assets/global/vendor/breakpoints/breakpoints.min.js" type="text/javascript"></script>
     <script type="text/javascript">
-        Breakpoints();
+      Breakpoints();
     </script>
     @yield('css')
 </head>

Some files were not shown because too many files changed in this diff