|
@@ -30,6 +30,8 @@ class BookAfterSpider extends Command
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
+ private $update_info = [];
|
|
|
+
|
|
|
public function __construct()
|
|
|
{
|
|
|
parent::__construct();
|
|
@@ -54,12 +56,13 @@ class BookAfterSpider extends Command
|
|
|
$this->starts($value);
|
|
|
}
|
|
|
}
|
|
|
+ $this->recordUpdateInfo();
|
|
|
}
|
|
|
|
|
|
private function starts($bid)
|
|
|
{
|
|
|
- $this->bookChapterInfo($bid);
|
|
|
$this->addbookConfig($bid);
|
|
|
+ $this->bookChapterInfo($bid);
|
|
|
$this->adjustSequentOne($bid);
|
|
|
}
|
|
|
|
|
@@ -98,6 +101,11 @@ class BookAfterSpider extends Command
|
|
|
if ($vip && isset($vip->sequence)) {
|
|
|
$vip_seq = $vip->sequence;
|
|
|
}
|
|
|
+ $this->update_info[$bid] = [];
|
|
|
+ $this->update_info[$bid]['add'] = true;
|
|
|
+ $this->update_info[$bid]['channel_name'] = $book_info->category_id >=13 ? '女频':'男频';
|
|
|
+ $this->update_info[$bid]['update_type'] = 'add_book';
|
|
|
+ $this->update_info[$bid]['book_name'] = $book_info->name;
|
|
|
DB::table('book_configs')->insert([
|
|
|
'bid' => $bid,
|
|
|
'force_subscribe_chapter_seq' => 10,
|
|
@@ -123,6 +131,10 @@ class BookAfterSpider extends Command
|
|
|
$res3 = DB::table('chapters')->where('bid', $bid)->count();
|
|
|
|
|
|
$res4 = DB::table('chapters')->where('bid', $bid)->sum('size');
|
|
|
+ if(isset($this->update_info[$bid])){
|
|
|
+ $this->update_info[$bid]['update_words'] = $res4;
|
|
|
+ $this->update_info[$bid]['update_chapter_count'] = $res3;
|
|
|
+ }
|
|
|
DB::table('books')->where('id', $bid)->update(
|
|
|
[
|
|
|
'chapter_count' => $res3,
|
|
@@ -161,4 +173,26 @@ class BookAfterSpider extends Command
|
|
|
$prev = $chapter->id;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private function recordUpdateInfo()
|
|
|
+ {
|
|
|
+ if(!$this->update_info) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ foreach ($this->update_info as $k=>$v){
|
|
|
+ if(!$v['add']) continue;
|
|
|
+ // 2 book_updates 的更新记录
|
|
|
+ DB::table('book_updates')->insert([
|
|
|
+ 'bid' => $k,
|
|
|
+ 'book_name' => $v['book_name'],
|
|
|
+ 'channel_name' => $v['channel_name'],
|
|
|
+ 'update_date' => date('Y-m-d'),
|
|
|
+ 'update_chapter_count' => $v['update_chapter_count'],
|
|
|
+ 'update_words' => $v['update_words'],
|
|
|
+ 'update_type' => $v['update_type'],
|
|
|
+ 'created_at' => date('Y-m-d H:i:s'),
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|