Pārlūkot izejas kodu

Merge branch 'web_sannong_fr'

15313670163 3 nedēļas atpakaļ
vecāks
revīzija
1733c84743
1 mainītis faili ar 45 papildinājumiem un 13 dzēšanām
  1. 45 13
      app/JsonRpc/NewsService.php

+ 45 - 13
app/JsonRpc/NewsService.php

@@ -1220,6 +1220,11 @@ class NewsService implements NewsServiceInterface
 
                 // 查询所有子级栏目的图文新闻
                 $imgArticles = Article::where('catid', $childCategoryIds[0])
+                    ->where(function ($query) use ($data) {
+                        $query->where(function ($subQuery) use ($data) {
+                            $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0");
+                        })->orWhereNull("ignore_ids");
+                    })
                     ->where('status', 1)
                     ->where('imgurl', '!=', '')
                     ->select('*')
@@ -1231,6 +1236,11 @@ class NewsService implements NewsServiceInterface
                 // 查询所有子级栏目的文字新闻
                 $textArticles = Article::where('catid', $childCategoryIds[0])
                     ->where('status', 1)
+                    ->where(function ($query) use ($data) {
+                        $query->where(function ($subQuery) use ($data) {
+                            $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0");
+                        })->orWhereNull("ignore_ids");
+                    })
                 // ->where(function ($query) {
                 //     $query->whereNull('imgurl')
                 //         ->orWhere('imgurl', '');
@@ -1309,23 +1319,36 @@ class NewsService implements NewsServiceInterface
             }else{
                 // 查询图片新闻
                 $imgArticles = Article::where('catid', $parentCatId)
+                ->where('status', 1)
+                ->where(function ($query) use ($website) {
+                    $query->where(function ($subQuery) use ($website) {
+                        $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($website['website_id'])."') = 0");
+                    })->orWhereNull("ignore_ids");
+                })
                 ->where('imgurl', '!=', '')
-                // ->where($website)
+                ->orderBy('updated_at', 'desc')
                 ->limit($parentImgNum)
                 ->get()->all();
 
                 // 查询文字新闻
                 $textArticles = Article::where('catid', $parentCatId)
-                    // ->where($website)
+                    ->where('status', 1)
+                    ->where(function ($query) use ($website) {
+                        $query->where(function ($subQuery) use ($website) {
+                            $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($website['website_id'])."') = 0");
+                        })->orWhereNull("ignore_ids");
+                    })
+                    ->orderBy('updated_at', 'desc')
                     ->limit($parentTextNum)
                     ->get()->all();
             }
             $resultItem = [
                 'alias' => $category ? $category->alias : null,
                 'category_id' => $parentCatId,
+                'pinyin' => $category->aLIas_pinyin ?? '',
                 'imgnum' => $imgArticles,
                 'textnum' => $textArticles,
-                'pinyin' => $category->aLIas_pinyin ?? '',
+                
             ];
 
             if (!empty($item['child']) && $item['child'] != "") {
@@ -1333,7 +1356,6 @@ class NewsService implements NewsServiceInterface
                 $childCategory = WebsiteCategory::where('pid', $parentCatId)->where($website)->select('category_id','alias','aLIas_pinyin')->get()->all();
                 if ($childCategory) {
                     list($childCatId, $childImgNum, $childTextNum) = explode(',', $item['child']);
-
                     // 查询子栏目名称
                     $childCategoryInfo = WebsiteCategory::where('category_id', $childCatId)->where($website)->first(['alias', 'category_id','aLIas_pinyin']);
                     // $childAllCartegory = WebsiteCategory::where('pid', $childCatId)->where($website)->first(['category_id']);
@@ -1343,26 +1365,36 @@ class NewsService implements NewsServiceInterface
                     }else{
                          // 查询子栏目图片新闻
                         $childImgArticles = Article::where('catid', $childCatId)
-                        ->where('imgurl', '!=', '')
-                        // ->where($website)
-                        ->limit($childImgNum)
-                        ->get()->all();
-
+                            ->where('status', 1)
+                            ->where(function ($query) use ($website) {
+                                $query->where(function ($subQuery) use ($website) {
+                                    $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($website['website_id'])."') = 0");
+                                })->orWhereNull("ignore_ids");
+                            })
+                            ->where('imgurl', '!=', '')
+                            ->orderBy('updated_at', 'desc')
+                            ->limit($childImgNum)
+                            ->get()->all();
                         // 查询子栏目文字新闻
                         $childTextArticles = Article::where('catid', $childCatId)
-                            // ->where($website)
+                            ->where('status', 1)
+                            ->where(function ($query) use ($website) {
+                                $query->where(function ($subQuery) use ($website) {
+                                    $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($website['website_id'])."') = 0");
+                                })->orWhereNull("ignore_ids");
+                            })
+                            ->orderBy('updated_at', 'desc')
                             ->limit($childTextNum)
                             ->get()->all();
-
                     }
-                   
                     $resultItem['child'] = [
                         'alias' => $childCategoryInfo ? $childCategoryInfo->alias : null,
                         'category_id' => $childCatId,
+                        'pinyin' => $childCategoryInfo->aLIas_pinyin?? '',
                         'all_childcat' => $childCategory,
                         'imgnum' => $childImgArticles,
                         'textnum' => $childTextArticles,
-                        'pinyin' => $childCategoryInfo->aLIas_pinyin?? '',
+                        
                     ];
                     // $resultItem['pinyin'] = $childCategoryInfo->aLIas_pinyin ?? '';
                 }