|
@@ -9,7 +9,7 @@ use App\Modules\Channel\Models\ChannelRecommendBooks;
|
|
|
class ChannelRecommendBooksService
|
|
|
{
|
|
|
|
|
|
- static function getRecommendBooks($channel_id,$id,$limit = 3,$data = [])
|
|
|
+ static function getRecommendBooks($channel_id,$bid,$priority,$limit = 3,$data = [])
|
|
|
{
|
|
|
if(!isset($channel_id)) return [];
|
|
|
$query = ChannelRecommendBooks::leftjoin('book_configs','book_configs.bid','channel_recommend_books.bid')
|
|
@@ -19,15 +19,15 @@ class ChannelRecommendBooksService
|
|
|
|
|
|
$query->where('channel_recommend_books.channel_id',$channel_id);
|
|
|
|
|
|
- if(!empty($id) && $id != 0){
|
|
|
- $query->where('channel_recommend_books.id','<',$id);
|
|
|
+ if(!empty($priority) && $priority != 0){
|
|
|
+ $query->where('channel_recommend_books.id','<=',$priority)->where('bid','!=',$bid);
|
|
|
}
|
|
|
|
|
|
$list = $query->limit($limit)->get()->toArray();
|
|
|
$lists = array_merge($list,$data);
|
|
|
if(count($lists) < 3){
|
|
|
$count = 3 - count($lists);
|
|
|
- self::getRecommendBooks($channel_id,0,$count,$lists);
|
|
|
+ self::getRecommendBooks($channel_id,$bid,0,$count,$lists);
|
|
|
}else{
|
|
|
return $lists;
|
|
|
}
|