request->input('cr_id', 0); $uid = 2054; $recordsInfo = ChatRecord::select(['msg_type', 'source', 'user_id', 'receive_id'])->where('id', $crId)->first(); if (!$recordsInfo) { return $this->response->fail('文件不存在...'); } //判断消息是否是当前用户发送(如果是则跳过权限验证) if ($recordsInfo->user_id != $uid) { if ($recordsInfo->source == 1) { if ($recordsInfo->receive_id != $uid) { return $this->response->fail('非法请求...'); } } else { if (!UsersGroup::isMember($recordsInfo->receive_id, $uid)) { return $this->response->fail('非法请求...'); } } } $fileInfo = ChatRecordsFile::select(['save_dir', 'original_name'])->where('record_id', $crId)->first(); if (!$fileInfo) { return $this->response->fail('文件不存在或没有下载权限...'); } return $response->download($uploadService->driver($fileInfo->save_dir), $fileInfo->original_name); } }