|
@@ -3,9 +3,11 @@
|
|
|
namespace App\Modules\Book\Services;
|
|
|
|
|
|
use App\Modules\Book\Models\Book;
|
|
|
+use App\Modules\Book\Models\Chapter;
|
|
|
+use GuzzleHttp\Client;
|
|
|
use Redis;
|
|
|
use App\Modules\Statistic\Services\WapVisitStatService;
|
|
|
-
|
|
|
+use DB;
|
|
|
|
|
|
class BookService
|
|
|
{
|
|
@@ -80,4 +82,50 @@ class BookService
|
|
|
public static function getBookById($bid){
|
|
|
return Book::find($bid);
|
|
|
}
|
|
|
+
|
|
|
+ public static function newYunQiBook($bid){
|
|
|
+ $old = DB::table('book_yunqi')->where('yq_bid',$bid)->where('type','NEW_YUNQI')->first();
|
|
|
+ if($old){
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ $new_yunqi_book = DB::connection('new_yunqi')->table('books')->where('id',$bid)->fist();
|
|
|
+ if(!$new_yunqi_book){
|
|
|
+ return -2;
|
|
|
+ }
|
|
|
+
|
|
|
+ $book = Book::create(
|
|
|
+ [
|
|
|
+ 'ly_bid'=>0,'name'=>$new_yunqi_book->name,'author'=>$new_yunqi_book->author,'intro'=>$new_yunqi_book->intro,'cover'=>$new_yunqi_book->cover,
|
|
|
+ 'category_name'=>$new_yunqi_book->category_name,'keyword'=>$new_yunqi_book->keyword,'category_id'=>0,'status'=>$new_yunqi_book->status,
|
|
|
+ 'chapter_count'=>$new_yunqi_book->chapter_count,'first_cid'=>0,'last_cid'=>0,'size'=>$new_yunqi_book->size,'last_chapter'=>$new_yunqi_book->last_chapter,
|
|
|
+ 'sequence'=>0,'yq_bid'=>$bid
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ DB::table('book_yunqi')->insert([
|
|
|
+ 'bid'=>$book->id,
|
|
|
+ 'yq_bid'=>$bid,
|
|
|
+ 'type'=>'NEW_YUNQI',
|
|
|
+ 'created_at'=>date('Y-m-d H:i:s'),
|
|
|
+ 'updated_at'=>date('Y-m-d H:i:s')
|
|
|
+ ]);
|
|
|
+ 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){
|
|
|
+ Chapter::create([
|
|
|
+ 'bid'=>$book->id,
|
|
|
+ 'name'=>$temp->name,
|
|
|
+ 'sequence'=>$i,
|
|
|
+ 'is_vip'=>$temp->is_vip,
|
|
|
+ 'size'=>$temp->size,
|
|
|
+ 'prev_cid'=>0,
|
|
|
+ 'next_cid'=>0,
|
|
|
+ 'recent_update_at'=>date('Y-m-d H:i:s'),
|
|
|
+ 'content'=>$temp->content,
|
|
|
+ 'ly_chapter_id'=>0
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ \Artisan::callSilent('book:afs',['bid'=>[$book->id]]);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
}
|