邮件修复
This commit is contained in:
@@ -31,6 +31,24 @@ class ConversationController extends BaseController
|
|||||||
return $this->error($th->getMessage());
|
return $this->error($th->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工单邮件补发
|
||||||
|
* @param Request $request
|
||||||
|
* @return \support\Response
|
||||||
|
*/
|
||||||
|
public function sendEmail(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$res = (new ConversationService())->sendEmail($request->all());
|
||||||
|
return $res
|
||||||
|
? $this->success($res)
|
||||||
|
: $this->error();
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->error($th->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function edit(Request $request)
|
public function edit(Request $request)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -64,19 +64,25 @@ class ConversationService
|
|||||||
if (empty($conversation)) {
|
if (empty($conversation)) {
|
||||||
$email = $emailDefault;
|
$email = $emailDefault;
|
||||||
}else{
|
}else{
|
||||||
$tiket = (new TicketLogic)->find($conversation['ticket_id']);
|
$tiket = (new TicketLogic())->find($conversation['ticket_id']);
|
||||||
if($data['user_id'] != $tiket['user_id']){
|
if($data['user_id'] != $tiket['user_id']){
|
||||||
$email = User::find($tiket['user_id'])->value('email');
|
$email = User::where('id',$tiket['user_id'])->value('email');
|
||||||
}else{
|
}else{
|
||||||
$conversationLast = Conversation::where('ticket_id', '=', $conversation['ticket_id'])
|
$conversationLast = Conversation::where('ticket_id', '=', $conversation['ticket_id'])
|
||||||
->where('user_id', '!=', $data['user_id'])
|
->where('user_id', '!=', $data['user_id'])
|
||||||
->orderBy('id', 'desc')
|
->orderBy('id', 'desc')
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
$email = (!empty($conversationLast['user_id']))?User::find($conversationLast['user_id'])->value('email',$emailDefault):$emailDefault;
|
$email = (!empty($conversationLast['user_id']))?User::where('id',$conversationLast['user_id'])->value('email',$emailDefault):$emailDefault;
|
||||||
}
|
}
|
||||||
$notice['content'] = $tiket['content'];
|
$notice['content'] = $tiket['content'];
|
||||||
$notice['reply'] = '<li>最新回复:' . $data['content'] . '</li>';
|
|
||||||
|
$status_fanyi = array_map(fn($v) => "{{{$v}}}", array_flip(Constants::TICKET_STATUS));
|
||||||
|
$locale = locale();
|
||||||
|
$ticket_status = $locale == 'zh'? Constants::TICKET_STATUS_ZH:Constants::TICKET_STATUS_EN;
|
||||||
|
$content = str_replace($status_fanyi,$ticket_status,$data['content']);
|
||||||
|
|
||||||
|
$notice['reply'] = '<li>最新回复:' . $content . '</li>';
|
||||||
}
|
}
|
||||||
\app\common\utils\email\MailSend::send($email, '【XYH】新的工单提醒', replaceTpl($notice, 'work_order'));
|
\app\common\utils\email\MailSend::send($email, '【XYH】新的工单提醒', replaceTpl($notice, 'work_order'));
|
||||||
|
|
||||||
@@ -89,6 +95,44 @@ class ConversationService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sendEmail(array $data)
|
||||||
|
{
|
||||||
|
$conversation = (new ConversationLogic())->firstByTicket($data['ticket_id']);
|
||||||
|
$ticket = (new TicketLogic())->find($data['ticket_id']);
|
||||||
|
$categorie= (new CategorieLogic())->find($ticket['categorie_id']);
|
||||||
|
$categorieName = isset($categorie['translation']) ? $categorie['translation']['name'] : '';
|
||||||
|
$notice = [
|
||||||
|
'code' => $ticket['code'],
|
||||||
|
'category' => $categorieName,
|
||||||
|
'content' => $ticket['content'],
|
||||||
|
'reply' => '',
|
||||||
|
];
|
||||||
|
//$emailDefault = 'app@hnxinyouhe.com'; //公共邮箱
|
||||||
|
$emailDefault = 'tuotuo@hnxinyouhe.com'; //范彩凤
|
||||||
|
if (empty($conversation)) {
|
||||||
|
$email = $emailDefault;
|
||||||
|
}else{
|
||||||
|
$tiket = (new TicketLogic())->find($conversation['ticket_id']);
|
||||||
|
|
||||||
|
if($conversation['user_id'] != $tiket['user_id']){
|
||||||
|
$email = User::where('id',$tiket['user_id'])->value('email');
|
||||||
|
}else{
|
||||||
|
$conversationLast = Conversation::where('ticket_id', '=', $conversation['ticket_id'])
|
||||||
|
->where('user_id', '!=', $conversation['user_id'])
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->first();
|
||||||
|
$email = (!empty($conversationLast['user_id']))?User::where('id',$conversationLast['user_id'])->value('email',$emailDefault):$emailDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
$notice['content'] = $tiket['content'];
|
||||||
|
// $notice['reply'] = '<li>最新回复:' . $conversation['content'] . '</li>';
|
||||||
|
$notice['reply'] = '<li>最新回复:' . '卡罗拉、极石01、比亚迪唐,宋Plus、丰田荣放、捷途T2、极氪7x、(阿联酋, 亚美尼亚, 阿塞拜疆, 白俄罗斯, 哥斯达黎加, 埃塞俄比亚, 格鲁吉亚, 加纳, 吉尔吉斯斯坦, 蒙古, 巴拉圭, 沙特阿拉伯, 塔吉克斯坦, 土库曼斯坦, 乌兹别克斯坦,委内瑞拉)起亚亦跑(阿尔及利亚),基本上每个车都推中亚中东南美非洲' . '</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
\app\common\utils\email\MailSend::send($email, '【XYH】新的工单提醒', replaceTpl($notice, 'work_order'));
|
||||||
|
return $email;
|
||||||
|
}
|
||||||
|
|
||||||
public function edit(array $data)
|
public function edit(array $data)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ Route::group('/ticket', function () {
|
|||||||
|
|
||||||
//工单沟通记录
|
//工单沟通记录
|
||||||
Route::any('/conversation/add', [app\ticket\controller\ConversationController::class, 'add']);
|
Route::any('/conversation/add', [app\ticket\controller\ConversationController::class, 'add']);
|
||||||
|
Route::any('/conversation/sendEmail', [app\ticket\controller\ConversationController::class, 'sendEmail']);
|
||||||
Route::any('/conversation/edit', [app\ticket\controller\ConversationController::class, 'edit']);
|
Route::any('/conversation/edit', [app\ticket\controller\ConversationController::class, 'edit']);
|
||||||
Route::any('/conversation/list', [app\ticket\controller\ConversationController::class, 'index']);
|
Route::any('/conversation/list', [app\ticket\controller\ConversationController::class, 'index']);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user