wangzq 2 роки тому
батько
коміт
99abfe7ceb

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

@@ -1271,14 +1271,17 @@ class BookController extends BaseController
     private function getRecommendBooks($package_id,$package, $channel, $is_auth)
     {
 
-        $bids = BookConfigService::getRecommendBids($package,$channel,[26],64);
-        $bids = array_chunk($bids,12);
+        $data = BookConfigService::getRecommendBids($package,$channel,[],48);
+        $bids = array_chunk($data,12);
+        $guss_like = BookConfigService::getRecommendBids($package,$channel,$data,20);
+        // $new_recom = BookConfigService::getNewRecommendBids($package,$channel,$data);
         $default = [1,1,1,1,1,1,1,1,1,1,1,1];
         return array_filter([
             ['type' => 'hot', 'lable' => '热门书单', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds($bids[0] ?? BookConfigService::getCheckBooks($default,$channel,$package,$is_auth)))],
             ['type' => 'zhibo', 'lable' => '神书直播', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds($bids[2] ?? BookConfigService::getCheckBooks($default,$channel,$package,$is_auth)))],
             ['type' => 'recom', 'lable' => '小编精选', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds($bids[3] ?? BookConfigService::getCheckBooks($default,$channel,$package,$is_auth)))],
-            ['type' => 'new_recom', 'lable' => '人气新书', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds($bids[4] ?? BookConfigService::getCheckBooks($default,$channel,$package,$is_auth)))]
+            ['type' => 'new_recom', 'lable' => '人气新书', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds($bids[4] ?? BookConfigService::getCheckBooks($default,$channel,$package,$is_auth)))],
+            ['type' => 'guss_like', 'lable' => '猜你喜欢', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds($guss_like))],
         ]);
         return [];
     }

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

@@ -379,4 +379,32 @@ class BookConfigService
                 ->value('type');
 
     }
+
+    public static function getNewRecommendBids($package, $channel, $bids = [], $limit=12,$is_on_shelf = true)
+    {
+        $begin_time = date('Y-m-d',strtotime('-2 month'));
+        $end_time =  date('Y-m-d');
+        $where = "  and  book_configs.charge_type = 'BOOK' and book_categories.pid= {$channel}";
+        $hide = getHiddenCp($package);
+
+        if ($hide){
+            $where .= " and book_configs.cp_source not in ( '" . implode("','",$hide) . "')";
+        }
+        if ($is_on_shelf){
+            $where .= " and  book_configs.is_on_shelf = 2";
+        }else{
+            $where .= " and  book_configs.is_on_shelf in (1,2)";
+        }
+
+        if (!empty($bids)){
+            $where .= " and  books.id not in (" . implode(",",$bids) .  ")";
+        }
+
+        $sql = "select book_configs.bid from book_promotion_day_stats
+                    inner join books on books.id=book_promotion_day_stats.bid
+                    LEFT join book_configs on book_configs.bid = books.id
+                    INNER JOIN book_categories ON book_categories.id=books.category_id
+                     where date >='{$begin_time}' and date <= '{$end_time}' {$where}  group by bid order by sum(rechareg_amount) desc limit {$limit}";
+
+    }
 }