zz hace 6 años
padre
commit
d897ff0865
Se han modificado 2 ficheros con 21 adiciones y 6 borrados
  1. 19 4
      app/Console/Commands/BookSpider.php
  2. 2 2
      app/Modules/Book/Services/BookService.php

+ 19 - 4
app/Console/Commands/BookSpider.php

@@ -14,7 +14,7 @@ class BookSpider extends Command
      *
      * @var string
      */
-    protected $signature = 'zytest';
+    protected $signature = 'zytest {--type=} {--bid=}';
 
     /**
      * The console command description.
@@ -42,7 +42,15 @@ class BookSpider extends Command
     public function handle()
     {
         //32401811
-        $this->cpc();
+        //$this->cpc();
+        $type = $this->option('type');
+        if($type == 'yunqi'){
+            $bids = $this->option('bid');
+            $bids = explode(',',$bids);
+            foreach ($bids as $bid){
+                $this->newYunQi($bid);
+            }
+        }
     }
 
     private function cpc(){
@@ -160,7 +168,14 @@ WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
         return "";
     }
 
-    private function newYunQi(){
-        \App\Modules\Book\Services\BookService::newYunQiBook(1);
+    private function newYunQi($bid){
+        $result = \App\Modules\Book\Services\BookService::newYunQiBook($bid);
+        if($result == -1){
+            echo 'yunqi book had collected'.PHP_EOL;
+        }
+        if ($result == -2) {
+            echo 'new_yunqi book not exists'.PHP_EOL;
+        }
+        echo "OK!";
     }
 }

+ 2 - 2
app/Modules/Book/Services/BookService.php

@@ -110,7 +110,7 @@ class BookService
         ]);
         for ($i = 1;$i<=$new_yunqi_book->chapter_count;$i++){
             $temp = DB::connection('new_yunqi')->table('chapters')->where('bid',$bid)->where('sequence',$i)->select('name','content','is_vip','size')->first();
-            if($new_yunqi_book){
+            if($temp){
                 Chapter::create([
                     'bid'=>$book->id,
                     'name'=>$temp->name,
@@ -125,7 +125,7 @@ class BookService
                 ]);
             }
         }
-        \Artisan::callSilent('book:afs',['bid'=>[$book->id]]);
+        \Artisan::call('book:afs',['bid'=>[$book->id]]);
         return 0;
     }
 }