소스 검색

修改c端:获取频道页图书信息的接口

FengR 4 달 전
부모
커밋
4a39bac6bb
1개의 변경된 파일31개의 추가작업 그리고 29개의 파일을 삭제
  1. 31 29
      app/JsonRpc/NewsService.php

+ 31 - 29
app/JsonRpc/NewsService.php

@@ -2712,6 +2712,7 @@ class NewsService implements NewsServiceInterface
             })
               ->where('book.status', 2)
               ->where('book.img_url', '!=', '')
+              ->where('book.website_id', $website['website_id'])   
               ->leftJoin('website_category', function ($join) use ($website) {
                 $join->on('book.cat_id', '=', 'website_category.category_id')
                   ->where('website_category.website_id', '=', $website['website_id']);
@@ -2729,35 +2730,36 @@ class NewsService implements NewsServiceInterface
                 'website_category.alias as category_name',
                 DB::raw("CASE WHEN book.cat_id = $parentCatId THEN '$parent_pinyin' 
                                         ELSE CONCAT('$parent_pinyin', '/', website_category.aLIas_pinyin) END as pinyin")
-              )
-              ->orderBy('updated_at', 'desc')
-              ->limit($parentImgNum)
-              ->get()->all();
-            // 查询文字新闻
-          }
-          if ($parentTextNum != 0) {
-            $textBooks = [];
-            $textBooks = Book::where(function ($query) use ($parentCatId) {
-              $query->whereRaw("JSON_CONTAINS(cat_arr_id, '\"$parentCatId\"')")
-                ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '$parentCatId')");
-            })
-              ->where('book.status', 2)
-              ->leftJoin('website_category', function ($join) use ($website) {
-                $join->on('book.cat_id', '=', 'website_category.category_id')
-                  ->where('website_category.website_id', '=', $website['website_id']);
-              })
-              ->select(
-                'book.id',
-                'book.title',
-                'book.img_url',
-                'book.price',
-                'book.market_price',
-                'book.description',
-                'book.cat_id',
-                'book.description',
-                'book.updated_at',
-                'website_category.alias as category_name',
-                DB::raw("CASE WHEN book.cat_id = $parentCatId THEN '$parent_pinyin' 
+                            )
+                            ->orderBy('updated_at', 'desc')
+                            ->limit($parentImgNum)
+                            ->get()->all();           
+                        // 查询文字新闻
+                    }
+                    if($parentTextNum!=0){  
+                        $textBooks = [];
+                        $textBooks = Book::where(function($query) use ($parentCatId) {
+                            $query->whereRaw("JSON_CONTAINS(cat_arr_id, '\"$parentCatId\"')")
+                                    ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '$parentCatId')");
+                            })
+                            ->where('book.status', 2)
+                            ->where('book.website_id', $website['website_id'])  
+                            ->leftJoin('website_category', function($join) use ($website) {
+                                $join->on('book.cat_id', '=', 'website_category.category_id')
+                                    ->where('website_category.website_id', '=', $website['website_id']);
+                            })
+                            ->select(
+                                'book.id',
+                                'book.title',
+                                'book.img_url',
+                                'book.price',
+                                'book.market_price',
+                                'book.description',
+                                'book.cat_id',
+                                'book.description',
+                                'book.updated_at',
+                                'website_category.alias as category_name',
+                                DB::raw("CASE WHEN book.cat_id = $parentCatId THEN '$parent_pinyin' 
                                         ELSE CONCAT('$parent_pinyin', '/', website_category.aLIas_pinyin) END as pinyin")
               )
               ->orderBy('updated_at', 'desc')