|
@@ -12,6 +12,7 @@ use App\Repositories\Post\PostRepository;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Console\Command;
|
|
use App\Models\Download;
|
|
use App\Models\Download;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
+use Illuminate\Support\Facades\Storage;
|
|
|
|
|
|
class Downloads extends Command
|
|
class Downloads extends Command
|
|
{
|
|
{
|
|
@@ -60,28 +61,31 @@ class Downloads extends Command
|
|
if(!$download) exit;
|
|
if(!$download) exit;
|
|
|
|
|
|
if($download->download_type == 'post'){
|
|
if($download->download_type == 'post'){
|
|
- $filePath = $fileDir .$download->username.'内容-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
|
|
|
|
|
|
+ $fileName = '内容-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
|
|
}elseif($download->download_type == 'post_waste'){
|
|
}elseif($download->download_type == 'post_waste'){
|
|
- $filePath = $fileDir .$download->username.'回收站内容-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
|
|
|
|
|
|
+ $fileName = '回收站内容-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
|
|
}elseif($download->download_type == 'registered_record'){
|
|
}elseif($download->download_type == 'registered_record'){
|
|
- $filePath = $fileDir .$download->username.'新用户注册账本-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
|
|
|
|
|
|
+ $fileName = '新用户注册账本-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
|
|
}elseif($download->download_type == 'comment_record'){
|
|
}elseif($download->download_type == 'comment_record'){
|
|
- $filePath = $fileDir .$download->username.'评论账本-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
|
|
|
|
|
|
+ $fileName = '评论账本-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
|
|
}elseif($download->download_type == 'release_record'){
|
|
}elseif($download->download_type == 'release_record'){
|
|
- $filePath = $fileDir .$download->username.'发布账本-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
|
|
|
|
|
|
+ $fileName = '发布账本-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
|
|
}elseif($download->download_type == 'general_record'){
|
|
}elseif($download->download_type == 'general_record'){
|
|
- $filePath = $fileDir .$download->username.'唯一/普通行为账本-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
|
|
|
|
|
|
+ $fileName = '唯一/普通行为账本-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
|
|
}else{
|
|
}else{
|
|
exit;
|
|
exit;
|
|
}
|
|
}
|
|
$download->download_status = 1;
|
|
$download->download_status = 1;
|
|
$download->save();
|
|
$download->save();
|
|
|
|
|
|
|
|
+ $filePath = $fileDir .$download->username.$fileName;
|
|
try {
|
|
try {
|
|
$this->postRepository->download($filePath, $download->download_type, json_decode($download->params, true));
|
|
$this->postRepository->download($filePath, $download->download_type, json_decode($download->params, true));
|
|
|
|
+ Storage::put($filePath, file_get_contents(public_path($filePath)));
|
|
$download->url = $filePath;
|
|
$download->url = $filePath;
|
|
$download->download_status = 2;
|
|
$download->download_status = 2;
|
|
$download->save();
|
|
$download->save();
|
|
|
|
+ unlink(public_path($filePath));
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
$download->download_status = 3;
|
|
$download->download_status = 3;
|
|
$download->url = $e->getMessage();
|
|
$download->url = $e->getMessage();
|