工单发送邮件通知
This commit is contained in:
@@ -4,7 +4,10 @@ namespace app\ticket\service;
|
||||
|
||||
use app\common\model\User;
|
||||
use app\common\service\OssService;
|
||||
use app\ticket\logic\CategorieLogic;
|
||||
use app\ticket\logic\ConversationLogic;
|
||||
use app\ticket\logic\TicketLogic;
|
||||
use app\ticket\model\Conversation;
|
||||
use config\constants\Constants;
|
||||
use support\Db;
|
||||
use support\exception\BusinessException;
|
||||
@@ -44,6 +47,39 @@ class ConversationService
|
||||
if (empty($data['content'])) {
|
||||
throw new BusinessException('消息内容不能为空');
|
||||
}
|
||||
|
||||
$conversation = (new ConversationLogic())->firstByTicket($data['ticket_id']);
|
||||
$categorie= (new CategorieLogic())->find($data['categorie_id']);
|
||||
$categorieName = isset($categorie['translation']) ? $categorie['translation']['name'] : '';
|
||||
|
||||
$notice = [
|
||||
'code' => $data['code'],
|
||||
'category' => $categorieName,
|
||||
'content' => $data['content'],
|
||||
'reply' => '',
|
||||
];
|
||||
if (empty($conversation)) {
|
||||
$email = 'app@hnxinyouhe.com';
|
||||
}else{
|
||||
$tiket = (new TicketLogic)->find($conversation['ticket_id']);
|
||||
if($data['user_id'] != $tiket['user_id']){
|
||||
$email = User::find($tiket['user_id'])->value('email');
|
||||
}else{
|
||||
$conversationLast = Conversation::where('user_id', '=', $conversation['user_id'])
|
||||
->where('ticket_id', '=', $conversation['ticket_id'])
|
||||
->where('user_id', '!=', $conversation['user_id'])
|
||||
->orderBy('id', 'desc')
|
||||
->first();
|
||||
$email = User::find($conversationLast['user_id'])->value('email','app@hnxinyouhe.com');
|
||||
}
|
||||
$notice['content'] = $tiket['content'];
|
||||
$notice['reply'] = '<li>最新回复:' . $data['content'] . '</li>';
|
||||
}
|
||||
\app\common\utils\email\MailSend::send($email, '【XYH】新的工单提醒', replaceTpl($notice, 'work_order'));
|
||||
|
||||
unset($data['categorie_id']);
|
||||
unset($data['code']);
|
||||
|
||||
return (new ConversationLogic())->add($data);
|
||||
} catch (\Throwable $e) {
|
||||
throw $e;
|
||||
|
||||
Reference in New Issue
Block a user