Selaa lähdekoodia

content split

zz 6 vuotta sitten
vanhempi
commit
07260434ad

+ 2 - 0
app/Console/Commands/BookAfterSpider.php

@@ -2,6 +2,7 @@
 
 namespace App\Console\Commands;
 
+use App\Modules\Book\Services\ChapterService;
 use Illuminate\Console\Command;
 use App\Modules\Product\Services\ProductService;
 use App\Modules\Book\Models\BookConfig;
@@ -64,6 +65,7 @@ class BookAfterSpider extends Command
         $this->addbookConfig($bid);
         $this->bookChapterInfo($bid);
         $this->adjustSequentOne($bid);
+        ChapterService::splitContentAll($bid);
     }
 
     private function addproducts()

+ 2 - 1
app/Console/Commands/BookUpdateOne.php

@@ -92,7 +92,7 @@ class BookUpdateOne extends Command
             ->first();
         $max_sequence_chapter_id = isset($last_chapter->id)?$last_chapter->id:0;
         $max_sequence = isset($last_chapter->sequence)?$last_chapter->sequence:0;
-
+        $from_sequence = $max_sequence;
         $chapter_list_fromat = "http://www.leyuee.com/services/zwfx.aspx?method=chapterlist&bid=%s&token=sefaf23h7face";
         $res = $this->client->get(sprintf($chapter_list_fromat,$book_info->ly_bid));
         $res = $res->getBody()->getContents();
@@ -174,6 +174,7 @@ class BookUpdateOne extends Command
                 'update_type'=>'add_chapter',
                 'channel_name'=>$book_info->category_id >=13 ? '女频':'男频'
             ]);
+            ChapterService::splitContentAll($bid,$from_sequence);
         }
         return $j;
     }

+ 5 - 2
app/Modules/Book/Services/ChapterService.php

@@ -289,8 +289,11 @@ class ChapterService
         return null;
     }
 
-    public static function splitContentAll($bid){
-        $chapters = Chapter::where('bid',$bid)->where('size','>=',3300)->select('id','sequence')->orderBy('sequence')->get();
+    public static function splitContentAll($bid,$sequence=1){
+        $chapters = Chapter::where('bid',$bid)->where('size','>=',3300)
+            ->where('sequence','>=',$sequence)
+            ->select('id','sequence')
+            ->orderBy('sequence')->get();
         $i = 0;
         $count = 0;
         $end_sequence = 0;