list($params); $status_fanyi = array_map(fn($v) => "{{{$v}}}", array_flip(Constants::TICKET_STATUS)); $ossservice = new OssService(); foreach ($result as $key => $value) { $value=$value->toArray(); $value['content'] = str_replace($status_fanyi,$ticket_status,$value['content']); $value['attachment'] = empty($value['attachment'])?[]:unserialize($value['attachment']); foreach ($value['attachment'] as $k => $attachment) { $value['attachment'][$k]['storage_path_full'] = (!empty($attachment))?$ossservice->generatePrivateUrl($attachment['storage_path']):''; } $user = User::where('id', $value['user_id'])->first(); $value['user_name'] = $user?->name; $value['user_avatar'] = $user?->avatar; $result[$key] = $value; } return $result; } public function add(array $data) { try { $data['attachment'] = serialize($data['attachment']); if (empty($data['content'])) { throw new BusinessException('消息内容不能为空'); } $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' => $data['content'], 'reply' => '', ]; //$emailDefault = 'app@hnxinyouhe.com'; //公共邮箱 $emailDefault = 'tuotuo@hnxinyouhe.com'; //范彩凤 if (empty($conversation)) { $email = $emailDefault; }else{ $tiket = (new TicketLogic())->find($conversation['ticket_id']); if($data['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', '!=', $data['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']; $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'] = '