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

This commit is contained in:
兔姬桑
2020-12-04 14:30:21 +08:00
parent ae3a94d873
commit fac8dacd17
9 changed files with 256 additions and 236 deletions

View File

@@ -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);

View File

@@ -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小时未处理系统已自动关闭');
}
}

View File

@@ -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' => '关闭失败']);
}

View File

@@ -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' => '关闭成功']);

View File

@@ -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']) {

461
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -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)

View File

@@ -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>