mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
ticket notify
This commit is contained in:
parent
15a28e7bd3
commit
bf3b7bb66f
@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Jobs\SendEmailJob;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Ticket;
|
use App\Models\Ticket;
|
||||||
use App\Models\TicketMessage;
|
use App\Models\TicketMessage;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class TicketController extends Controller
|
class TicketController extends Controller
|
||||||
@ -80,6 +82,7 @@ class TicketController extends Controller
|
|||||||
abort(500, '工单回复失败');
|
abort(500, '工单回复失败');
|
||||||
}
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
$this->sendEmailNotify($ticket, $ticketMessage);
|
||||||
return response([
|
return response([
|
||||||
'data' => true
|
'data' => true
|
||||||
]);
|
]);
|
||||||
@ -103,4 +106,24 @@ class TicketController extends Controller
|
|||||||
'data' => true
|
'data' => true
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 半小时内不再重复通知
|
||||||
|
private function sendEmailNotify(Ticket $ticket, TicketMessage $ticketMessage)
|
||||||
|
{
|
||||||
|
$user = User::find($ticket->user_id);
|
||||||
|
$cacheKey = 'ticket_sendEmailNotify';
|
||||||
|
if (!Cache::get($cacheKey)) {
|
||||||
|
Cache::put($cacheKey, 1, 1800);
|
||||||
|
SendEmailJob::dispatch([
|
||||||
|
'email' => $user->email,
|
||||||
|
'subject' => '您在' . config('v2board.app_name', 'V2Board') . '的工单得到了回复',
|
||||||
|
'template_name' => 'notify',
|
||||||
|
'template_value' => [
|
||||||
|
'name' => config('v2board.app_name', 'V2Board'),
|
||||||
|
'url' => config('v2board.app_url'),
|
||||||
|
'content' => "主题:{$ticket->subject}\r\n回复内容:{$ticketMessage->message}"
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
7
app/Services/MailService.php
Normal file
7
app/Services/MailService.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
class MailService
|
||||||
|
{
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user