|
@@ -1423,6 +1423,7 @@ class NewsService implements NewsServiceInterface
|
|
|
];
|
|
|
// 查询栏目名称
|
|
|
$category = WebsiteCategory::where('category_id', $parentCatId)->where($website)->first(['alias', 'category_id','aLIas_pinyin']);
|
|
|
+
|
|
|
if(empty($category)){
|
|
|
$parent_alias = '';
|
|
|
$parent_pinyin = null;
|
|
@@ -1431,14 +1432,22 @@ class NewsService implements NewsServiceInterface
|
|
|
}else{
|
|
|
$parent_alias = $category->alias ?? '';
|
|
|
$parent_pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
|
|
|
+ // 查找子分类ID数组
|
|
|
+ $childCategoryIds = WebsiteCategory::where('pid', $parentCatId)->where($website)->pluck('category_id')->toArray();
|
|
|
+ array_push($childCategoryIds,$parentCatId);
|
|
|
+ $childCategoryIds = json_encode(array_values(array_unique($childCategoryIds)));
|
|
|
if($parentImgNum!=0){
|
|
|
// 查询图片新闻
|
|
|
- $imgArticles = Article::where('article.status', 1)
|
|
|
- ->where(function ($query) use ($website, $parentCatId) {
|
|
|
- $query->where(function ($subQuery) use ($website, $parentCatId) {
|
|
|
+ $imgArticles = Article::where('article.status', 1)
|
|
|
+ ->where(function($query) use ($parentCatId) {
|
|
|
+ $query->whereRaw("JSON_CONTAINS(cat_arr_id, '\"$parentCatId\"')")
|
|
|
+ ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '$parentCatId')");
|
|
|
+ })
|
|
|
+ ->where(function ($query) use ($website) {
|
|
|
+ $query->where(function ($subQuery) use ($website) {
|
|
|
$subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($website['website_id'])."') = 0")
|
|
|
- ->whereRaw("JSON_CONTAINS(article.cat_arr_id, '".intval($parentCatId)."') = 0");
|
|
|
- })->orWhereNull("ignore_ids");
|
|
|
+ ->orWhereNull("ignore_ids");
|
|
|
+ });
|
|
|
})
|
|
|
->where('imgurl', '!=', '')
|
|
|
->leftJoin('website_category', function($join) use ($website) {
|
|
@@ -1463,38 +1472,44 @@ class NewsService implements NewsServiceInterface
|
|
|
->orderBy('updated_at', 'desc')
|
|
|
->limit($parentImgNum)
|
|
|
->get()->all();
|
|
|
- // 查询文字新闻
|
|
|
+
|
|
|
+ // 查询文字新闻
|
|
|
}
|
|
|
if($parentTextNum!=0){
|
|
|
+ $textArticles = [];
|
|
|
$textArticles = Article::where('article.status', 1)
|
|
|
- ->where(function ($query) use ($website, $parentCatId) {
|
|
|
- $query->where(function ($subQuery) use ($website, $parentCatId) {
|
|
|
- $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($website['website_id'])."') = 0")
|
|
|
- ->whereRaw("JSON_CONTAINS(article.cat_arr_id, '".intval($parentCatId)."') = 0");
|
|
|
- })->orWhereNull("ignore_ids");
|
|
|
- })
|
|
|
- ->leftJoin('website_category', function($join) use ($website) {
|
|
|
- $join->on('article.catid', '=', 'website_category.category_id')
|
|
|
- ->where('website_category.website_id', '=', $website['website_id']);
|
|
|
- })
|
|
|
- ->select(
|
|
|
- 'article.id',
|
|
|
- 'article.title',
|
|
|
- 'article.imgurl',
|
|
|
- 'article.author',
|
|
|
- 'article.updated_at',
|
|
|
- 'article.introduce',
|
|
|
- 'article.islink',
|
|
|
- 'article.linkurl',
|
|
|
- 'article.copyfrom',
|
|
|
- 'article.catid',
|
|
|
- 'website_category.alias as category_name',
|
|
|
- DB::raw("CASE WHEN article.catid = $parentCatId THEN '$parent_pinyin'
|
|
|
- ELSE CONCAT('$parent_pinyin', '/', website_category.aLIas_pinyin) END as pinyin")
|
|
|
- )
|
|
|
- ->orderBy('updated_at', 'desc')
|
|
|
- ->limit($parentTextNum)
|
|
|
- ->get()->all();
|
|
|
+ ->where(function($query) use ($parentCatId) {
|
|
|
+ $query->whereRaw("JSON_CONTAINS(cat_arr_id, '\"$parentCatId\"')")
|
|
|
+ ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '$parentCatId')");
|
|
|
+ })
|
|
|
+ ->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");
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->leftJoin('website_category', function($join) use ($website) {
|
|
|
+ $join->on('article.catid', '=', 'website_category.category_id')
|
|
|
+ ->where('website_category.website_id', '=', $website['website_id']);
|
|
|
+ })
|
|
|
+ ->select(
|
|
|
+ 'article.id',
|
|
|
+ 'article.title',
|
|
|
+ 'article.imgurl',
|
|
|
+ 'article.author',
|
|
|
+ 'article.updated_at',
|
|
|
+ 'article.introduce',
|
|
|
+ 'article.islink',
|
|
|
+ 'article.linkurl',
|
|
|
+ 'article.copyfrom',
|
|
|
+ 'article.catid',
|
|
|
+ 'website_category.alias as category_name',
|
|
|
+ DB::raw("CASE WHEN article.catid = $parentCatId THEN '$parent_pinyin'
|
|
|
+ ELSE CONCAT('$parent_pinyin', '/', website_category.aLIas_pinyin) END as pinyin")
|
|
|
+ )
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
+ ->limit($parentTextNum)
|
|
|
+ ->get()->all();
|
|
|
}
|
|
|
}
|
|
|
|