Procházet zdrojové kódy

修改获取企业首页、项目首页的接口

15313670163 před 2 dny
rodič
revize
a282ee23de
1 změnil soubory, kde provedl 6 přidání a 4 odebrání
  1. 6 4
      app/JsonRpc/NewsService.php

+ 6 - 4
app/JsonRpc/NewsService.php

@@ -2847,8 +2847,9 @@ private function fetchArticles($catId, $website, $limit, $isImageArticle = false
                 $category_id = $parts[0] ?? null;
                 $imgnum = $parts[1] ?? null;
                 $textnum = $parts[2] ?? null;
+                $category_arr = array_merge([$category_id], $cat_1st_arr[$category_id] ?? [0]);
                 if(!empty($textnum) && $textnum > 0){
-                    $text_num = Company::where('category_id', $category_id)
+                    $text_num = Company::whereIn('category_id', $category_arr)
                     ->where('website_id',$data['website_id'])
                     ->where('status',1)
                     ->select('company.id','company.title','company.description','company.updated_at',
@@ -2859,7 +2860,7 @@ private function fetchArticles($catId, $website, $limit, $isImageArticle = false
                 }
                 if(!empty($imgnum) && $imgnum > 0){
 
-                    $img_num = Company::where('category_id', $category_id)
+                    $img_num = Company::whereIn('category_id', $category_arr)
                     ->where('website_id',$data['website_id'])
                     ->where('status',1)
                     ->where('imgurl','!=', '')
@@ -3025,8 +3026,9 @@ private function fetchArticles($catId, $website, $limit, $isImageArticle = false
                     $category_ids = explode(',', $val['id'])[0];
                     $cat_imgnum = explode(',', $val['id'])[1] ?? null;
                     $cat_textnum = explode(',', $val['id'])[2] ?? null;
+                    $category_arr = array_merge([$category_ids], $cat_1st_arr[$category_ids] ?? [0]);
                     if(!empty($cat_textnum) && $cat_textnum > 0){
-                        $text_num = Project::where('category_id', $category_ids)
+                        $text_num = Project::whereIn('category_id', $category_arr)
                         ->where('website_id',$data['website_id'])
                         ->where('status',1)
                         ->select('project.id','project.title','project.description','project.updated_at',
@@ -3036,7 +3038,7 @@ private function fetchArticles($catId, $website, $limit, $isImageArticle = false
                         ->get()->all();
                     }
                     if(!empty($cat_imgnum) && $cat_imgnum > 0){
-                        $img_num = Project::where('category_id', $category_ids)
+                        $img_num = Project::whereIn('category_id', $category_arr)
                         ->where('website_id',$data['website_id'])
                         ->where('status',1)
                         ->where('imgurl','!=', '')