Переглянути джерело

'书籍所有非7477包过滤掉lianshang书籍'

zhuchengjie 2 роки тому
батько
коміт
67b90ec680

+ 6 - 2
app/Http/Controllers/QuickApp/Book/BookController.php

@@ -259,6 +259,10 @@ class BookController extends BaseController
      */
     private function getCheckBooks($bid_list,$channel)
     {
+        $hidden_cp = getHiddenCp();
+        if($this->distribution_channel_id == 7477){
+            $hidden_cp = array_merge($hidden_cp,['lianshang']);
+        }
         //获取书本数量
         $count = count($bid_list);
         //获取当前有效书本数量
@@ -475,8 +479,8 @@ class BookController extends BaseController
                 $bids = [159, 2439, 6276, 10074, 5409, 9379, 10323, 9078, 3603, 487];
             }
         }
-
-        $books = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds($bids));
+        $channel_id = $this->distribution_channel_id;
+        $books = collectionTransform(new BookTransformer, BookConfigService::getBookLists(compact($bids,$channel_id)));
         return response()->success($books);
     }
 

+ 7 - 6
app/Http/Controllers/QuickApp/User/ReadRecordController.php

@@ -73,12 +73,13 @@ class ReadRecordController extends BaseController
         $year_account = YearOrderService::getRecord($this->uid);
 
         if ($res) {
-            $id_arr = [];
-            foreach ($res as $key => $value) {
-                $id_arr[] = $value['bid'];
-            }
-
-            $book = BookConfigService::getBooksByIds($id_arr, [], false);//下架图书最近阅读可看到
+//            $id_arr = [];
+//            foreach ($res as $key => $value) {
+//                $id_arr[] = $value['bid'];
+//            }
+            $bids = array_column($res,'bid');
+            $channel_id = $this->distribution_channel_id;
+            $book = BookConfigService::getBookLists(compact($bids,$channel_id), [], false);//下架图书最近阅读可看到
             foreach ($res as $key => &$value) {
                 $value['cover']        = '';
                 $value['last_chapter'] = 0;

+ 67 - 0
app/Modules/Book/Models/BookConfig.php

@@ -229,6 +229,73 @@ class BookConfig extends Model
         return $res->limit(30)->get();
     }
 
+    public static function getBookLists(array $where, array $order = [], $is_external_shelf = true)
+    {
+        if (empty($where)) {
+            return [];
+        }
+
+        $res = self::join('books', 'book_configs.bid', '=', 'books.id')
+            ->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.is_on_shelf',
+                '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'
+            );
+        if(isset($where['bids']) && !empty($where['bids'])){
+            $res->whereIn('book_configs.bid', $where['bids']);
+        }
+
+        if($is_external_shelf) $res->where('is_on_shelf',2);// 默认外部上架
+
+        if ($order) {
+            $res->orderBy($order[0], $order[1]);
+        } else {
+            $str = implode(',', $bid_arr);
+            $field = 'bid,' . $str;
+            $res->orderBy(DB::raw('field(' . $field . ')'));
+        }
+        if(isset($where['channel_id']) && $where['channel_id'] == 7477){
+            $res->whereNotIn('book_configs.cp_source',getHiddenCp());
+        }else{
+            $res->whereNotIn('book_configs.cp_source',array_merge(getHiddenCp(),['lianshang']));
+        }
+
+
+        return $res->limit(30)->get();
+    }
+
 
     /**
      * 根据bid获取图书信息

+ 2 - 1
app/Modules/Book/Services/BookAuditService.php

@@ -32,7 +32,8 @@ class BookAuditService
 
         // 一次性获取书籍列表
         $bids  = array_merge($hotBids, $liveBids, $recomBids, $newBids);
-        $books = BookConfigService::getBooksByIds($bids);
+        $channel_id = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
+        $books = BookConfigService::getBookLists(compact($bids,$channel_id));
 
         return [
             [

+ 14 - 0
app/Modules/Book/Services/BookConfigService.php

@@ -65,6 +65,20 @@ class BookConfigService
         return $res;
     }
 
+    public static function getBookLists(array $where, $order = [],$is_external_shelf=true)
+    {
+        if (empty($where)) {
+            return (object)array();
+        }
+        if ($order) {
+            $res = BookConfig::getBookLists($where,$order,$is_external_shelf);
+        } else{
+            $res = BookConfig::getBookLists($where,[],$is_external_shelf);
+        }
+
+        return $res;
+    }
+
     /**
      *
      * 根据条件获取图书