wzq 5 years ago
parent
commit
db4b6b7ce7

+ 6 - 4
app/Console/Commands/Downloads.php

@@ -60,20 +60,22 @@ class Downloads extends Command
         if(!$download) exit;
 
         if($download->download_type == 'post'){
-            $filePath = $fileDir .'内容-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
+            $filePath = $fileDir .$download->username.'内容-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
         }elseif($download->download_type == 'post_waste'){
-            $filePath = $fileDir .'回收站内容-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
+            $filePath = $fileDir .$download->username.'回收站内容-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
         }else{
             exit;
         }
+        $download->download_status = 1;
+        $download->save();
 
         try {
             $this->postRepository->download($filePath, $download->download_type, json_decode($download->params, true));
             $download->url = $filePath;
-            $download->download_status = 1;
+            $download->download_status = 2;
             $download->save();
         } catch (\Exception $e) {
-            $download->download_status = 2;
+            $download->download_status = 3;
             $download->url = $e->getMessage();
             $download->save();
         }

+ 4 - 3
app/Http/Controllers/ConfigController.php

@@ -71,9 +71,10 @@ class ConfigController extends Controller
             ],
             //下载状态
             'download_status' => [
-                '1' => '成功',
-                '0' => '生成中',
-                '2' => '失败',
+                '1' => '生成中',
+                '0' => '待处理',
+                '2' => '成功',
+                '3' => '失败',
             ],
             'topic_status'=>[
                 'is_suggest'=>'推荐话题',

+ 30 - 0
database/migrations/2019_06_11_163708_modify_download_status_to_table_download.php

@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class ModifyDownloadStatusToTableDownload extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        DB::statement("ALTER TABLE downloads MODIFY COLUMN download_status TINYINT (4) NOT NULL DEFAULT 0 COMMENT '下载状态:0待处理,1生成中,2成功,3失败'");
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('download', function (Blueprint $table) {
+            //
+        });
+    }
+}