wangzq 2 년 전
부모
커밋
72961367b7
2개의 변경된 파일18개의 추가작업 그리고 17개의 파일을 삭제
  1. 7 2
      app/Http/Controllers/QuickApp/Book/BookController.php
  2. 11 15
      app/Modules/Book/Services/BookConfigService.php

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

@@ -35,8 +35,8 @@ use App\Modules\Subscribe\Services\YearOrderService;
 use App\Modules\Subscribe\Services\OrderService;
 use App\Modules\User\Services\ReadRecordService;
 use Hashids;
+use Illuminate\Support\Facades\DB;
 use Log;
-use DB;
 use Illuminate\Support\Facades\Redis;
 
 class BookController extends BaseController
@@ -1266,7 +1266,12 @@ class BookController extends BaseController
     private function getRecommendBooks($package_id,$package, $channel, $is_auth)
     {
 
-        $bids = BookConfigService::getRecommendBids($package,$channel,$is_auth,[26],64);
+        $bids = BookConfigService::getRecommendBids($package,$channel,[26],64);
+        echo "<pre><hr>";
+        var_export($bids);
+        echo  "<hr>";
+        var_export(DB::getQueryLog());
+        die();
         // $hotBids   = BookConfigService::getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'hot',$package_id),$channel,$package,$isAuthor);
         // $liveBids  = BookConfigService::getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'live',$package_id),$channel,$package,$isAuthor);
         // $recomBids = BookConfigService::getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'recom',$package_id),$channel,$package,$isAuthor);

+ 11 - 15
app/Modules/Book/Services/BookConfigService.php

@@ -17,9 +17,9 @@ use App\Modules\Book\Models\BookKeyword;
 use App\Modules\Book\Models\FreeBook;
 use App\Modules\Book\Models\FreeBookConfig;
 use App\Modules\Book\Models\QappUserSearchBookLog;
+use Illuminate\Support\Facades\DB;
 use phpDocumentor\Reflection\Types\This;
 use Redis;
-use DB;
 use Vinkla\Hashids\Facades\Hashids;
 
 class BookConfigService
@@ -335,31 +335,27 @@ class BookConfigService
         return array_filter(array_merge($bid_list, $rand_bid));
     }
 
-    public static function getRecommendBids($package = '', $channel = 1, $is_auth = true, $no_in_bid = [], $limit = 64)
+    public static function getRecommendBids($package = '', $channel = 1, $no_in_bid = [], $limit = 36,$is_on_shelf = true)
     {
+        DB::enableQueryLog();
         $where = [
             ['book_configs.charge_type', '!=', 'BOOK'],
         ];
-        if (!$is_auth) {
-            $where[] = ['book_configs.cp_source', '=', 'ycsd'];
-        }
-
         //获取书籍交集bid,过滤掉不符合要求的书
         $bid_list = BookConfig::join('books', 'book_configs.bid', '=', 'books.id')
             ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
-            ->where('book_configs.is_on_shelf', 2)
+            ->distinct("books.name")
             ->where($where)
-            ->whereNotIn('book_configs.cp_source', getHiddenCp())
+            ->whereNotIn('book_configs.cp_source', getHiddenCp($package))
             ->where('book_categories.pid', $channel);
+        if ($is_on_shelf){
+            $bid_list->where('book_configs.is_on_shelf', 2);
+        }else{
+            $bid_list->whereIn('book_configs.is_on_shelf', [1,2]);
+        }
         if (!empty($no_in_bid)) {
              $bid_list->whereNotIn('book_configs.bid', $no_in_bid);
         }
-
-         $bid_list = $bid_list->orderBy('recommend_index' ,  'desc')->limit($limit)->pluck('book_configs.bid');
-
-        echo "<pre><hr>";
-        var_export($bid_list);
-        echo "<hr>";
-        die();
+        return $bid_list->orderBy('recommend_index' ,  'desc')->orderBy("book_configs.is_high_quality",'desc')->orderBy('books.id' ,  'asc')->limit($limit)->pluck('book_configs.bid')->toArray();
     }
 }