Browse Source

首页代码优化

wangzq 2 năm trước cách đây
mục cha
commit
8a316d1d70
1 tập tin đã thay đổi với 26 bổ sung20 xóa
  1. 26 20
      app/Http/Controllers/QuickApp/Book/BookController.php

+ 26 - 20
app/Http/Controllers/QuickApp/Book/BookController.php

@@ -309,26 +309,27 @@ class BookController extends BaseController
                 ['book_configs.charge_type','!=','BOOK'],
             ];
         }
-        //获取当前有效书本数量
-        $book_count = BookConfig::join('books', 'book_configs.bid', '=', 'books.id')
-            ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
-            ->whereIn('book_configs.bid',$bid_list)
-            ->where('book_configs.is_on_shelf',2)
-            ->where('book_configs.charge_type','!=','BOOK')
-            ->whereNotIn('book_configs.cp_source',$hidden_cp)
-            ->where($where)
-
-            ->where('book_categories.pid',$channel)
-            ->count();
-
-        if($count == $book_count){
-            return $bid_list;
-        }
+        // //获取当前有效书本数量
+        // $book_count = BookConfig::join('books', 'book_configs.bid', '=', 'books.id')
+        //     ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
+        //     ->whereIn('book_configs.bid',$bid_list)
+        //     ->where('book_configs.is_on_shelf',2)
+        //     ->where('book_configs.charge_type','!=','BOOK')
+        //     ->whereNotIn('book_configs.cp_source',$hidden_cp)
+        //     ->where($where)
+        //
+        //     ->where('book_categories.pid',$channel)
+        //     ->count();
+
+        //
+        // if($count == $book_count){
+        //     return $bid_list;
+        // }
         //获取需要补充的书籍数量
-        $supplement_count = (($count - $book_count) > 0) ? $count - $book_count : 0;
-        if($supplement_count <= 0){
-            return $bid_list;
-        }
+        // $supplement_count = (($count - $book_count) > 0) ? $count - $book_count : 0;
+        // if($supplement_count <= 0){
+        //     return $bid_list;
+        // }
         //获取书籍交集bid,过滤掉不符合要求的书
         $bids = BookConfig::join('books', 'book_configs.bid', '=', 'books.id')
             ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
@@ -338,8 +339,13 @@ class BookController extends BaseController
             ->whereNotIn('book_configs.cp_source',$hidden_cp)
             ->where('book_categories.pid',$channel)
             ->pluck('book_configs.bid')->all();
-        $bid_list = array_intersect($bid_list,$bids);
+        // $bid_list = array_intersect($bid_list,$bids);
+        $book_count = count($bids);
+        if ($book_count === $count){
+            return  $bid_list;
+        }
 
+        $supplement_count = $count - $book_count;
         //获取随机的有效的书籍bid
         $rand_bid = BookConfig::join('books', 'book_configs.bid', '=', 'books.id')
             ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')