leftjoin('book_categories', 'books.category_id', 'book_categories.id') ->select('book_configs.bid', 'book_configs.force_subscribe_chapter_seq', 'book_configs.vip_seq', 'book_configs.price', 'book_configs.cover', 'book_configs.book_name', 'book_configs.copyright', 'book_configs.charge_type', 'book_configs.is_on_shelf', 'books.author', 'books.intro', 'book_categories.category_name', 'category_id', 'status', 'chapter_count', 'book_configs.click_count', 'first_cid', 'last_cid', 'size', 'last_chapter', 'books.keyword', 'book_configs.recommend_index', 'book_configs.is_show_index_content', 'book_configs.product_id', 'book_categories.channel_name', 'books.last_cid', 'books.last_chapter', 'book_configs.product_id', 'books.updated_at as last_update_time', 'book_configs.copyright_limit_data', 'book_configs.promotion_domain', 'books.name as old_name', 'book_configs.recommend_cid' ) ->whereIn('book_configs.bid', $bid_arr); if($is_on_shelf !='all' && !empty($is_on_shelf)) { $res->where('is_on_shelf',$is_on_shelf); } if ($order) { $res->orderBy($order[0], $order[1]); } else { $str = implode(',', $bid_arr); $field = 'bid,' . $str; $res->orderBy(DB::raw('field(' . $field . ')')); } return $res->limit(50)->get(); } /** * 根据bid获取图书信息 * @param $bid * @return mixed */ public static function getBookById($bid) { if (empty($bid)) return null; return self::join('books', 'book_configs.bid', '=', 'books.id') ->leftjoin('book_categories', 'books.category_id', 'book_categories.id') ->select('book_configs.bid', 'book_configs.is_on_shelf', 'book_configs.force_subscribe_chapter_seq', 'book_configs.vip_seq', 'book_configs.cp_source', 'book_configs.price', 'book_configs.cover', 'book_configs.book_name', 'book_configs.copyright', 'book_configs.created_at', 'book_configs.charge_type', 'book_configs.is_on_shelf', 'books.author', 'books.intro', 'book_categories.category_name', 'category_id', 'status', 'chapter_count', 'first_cid', 'last_cid', 'size', 'last_chapter', 'books.keyword', 'book_configs.recommend_index','book_configs.test_status','book_configs.unit_price','book_configs.calculate_price_type', 'book_configs.is_show_index_content', 'book_configs.click_count', 'book_configs.product_id', 'book_categories.channel_name', 'books.last_cid', 'books.updated_at as last_update_time', 'books.last_chapter', 'book_configs.product_id', 'book_configs.copyright_limit_data', 'book_configs.promotion_domain', 'books.name as old_name', 'book_configs.recommend_cid', 'book_configs.is_high_quality' , 'book_configs.copyright_from' )->where('book_configs.bid', $bid)->first(); } /** * 通过书名模糊搜索bid * @param $book_name * @return mixed */ static function getIdByName($book_name) { return self::select('bid')->where('book_name', 'like', '%' . $book_name . '%')->get(); } }