|
@@ -8,6 +8,8 @@ use App\Modules\Book\Models\Book;
|
|
|
use App\Modules\Book\Models\Chapter;
|
|
|
use App\Modules\Book\Services\ChapterService;
|
|
|
use App\Modules\Book\Services\BookConfigService;
|
|
|
+use DB;
|
|
|
+
|
|
|
class BookUpdateOne extends Command
|
|
|
{
|
|
|
/**
|
|
@@ -80,8 +82,10 @@ class BookUpdateOne extends Command
|
|
|
$res = $this->client->get(sprintf($chapter_list_fromat,$book_info->ly_bid));
|
|
|
$res = $res->getBody()->getContents();
|
|
|
if(!$res) return '';
|
|
|
+ $book_config_info = DB::table('book_configs')->where('bid',$bid)->first();
|
|
|
$res = json_decode($res,true);
|
|
|
$j = 0;
|
|
|
+ $size = 0;
|
|
|
$local_count = Chapter::where('bid',$bid)->count();
|
|
|
$remote_count = 0;
|
|
|
|
|
@@ -119,6 +123,7 @@ class BookUpdateOne extends Command
|
|
|
$cahpter_content = json_decode($cahpter_content, true);
|
|
|
$temp['size'] = ceil(strlen($cahpter_content['data']['chapter_content']) / 3);
|
|
|
$temp['content'] = $cahpter_content['data']['chapter_content'];
|
|
|
+ $size += $temp['size'];
|
|
|
}
|
|
|
$insert_res = Chapter::create($temp);
|
|
|
Chapter::where('id', $max_sequence_chapter_id)->update(['next_cid' => $insert_res->id]);
|
|
@@ -131,6 +136,13 @@ class BookUpdateOne extends Command
|
|
|
$chapter_size = Chapter::where('bid',$bid)->sum('size');
|
|
|
if($j>0){
|
|
|
Book::where('id',$bid)->update(['chapter_count'=>$chapter_count,'last_cid'=>$max_sequence_chapter_id,'size'=>$chapter_size,'last_chapter'=>$v['chapter_name']]);
|
|
|
+ $this->recordUpdateInfo($bid,[
|
|
|
+ 'book_name'=>$book_config_info->book_name,
|
|
|
+ 'update_chapter_count'=>$j,
|
|
|
+ 'update_words'=>$size,
|
|
|
+ 'update_type'=>'add_chapter',
|
|
|
+ 'channel_name'=>$book_info->category_id >=13 ? '女频':'男频'
|
|
|
+ ]);
|
|
|
}
|
|
|
return $j;
|
|
|
}
|
|
@@ -195,4 +207,20 @@ class BookUpdateOne extends Command
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private function recordUpdateInfo($bid, $data)
|
|
|
+ {
|
|
|
+ // 2 book_updates 的更新记录
|
|
|
+ DB::table('book_updates')->insert([
|
|
|
+ 'bid' => $bid,
|
|
|
+ 'book_name' => $data['book_name'],
|
|
|
+ 'channel_name' => $data['channel_name'],
|
|
|
+ 'update_date' => date('Y-m-d'),
|
|
|
+ 'update_chapter_count' => $data['update_chapter_count'],
|
|
|
+ 'update_words' => $data['update_words'],
|
|
|
+ 'update_type' => $data['update_type'],
|
|
|
+ 'created_at' => date('Y-m-d H:i:s'),
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
|
+ ]);
|
|
|
+ }
|
|
|
}
|