Эх сурвалжийг харах

Merge branch 'web_sannong_fr'

15313670163 3 өдөр өмнө
parent
commit
de85721f8c
1 өөрчлөгдсөн 24 нэмэгдсэн , 32 устгасан
  1. 24 32
      app/JsonRpc/NewsService.php

+ 24 - 32
app/JsonRpc/NewsService.php

@@ -6183,16 +6183,16 @@ class NewsService implements NewsServiceInterface
      */
     public function getWebsiteCompany(array $data): array
     {
-        // $where['website_id'] = $data['website_id'];
         $categorys = json_decode($data['id'], true);
         $category_arr = $this->processArticlePro($data['website_id']);
         $cat_1st_arr = $category_arr['cat_1st_arr'];
         $catiall = $category_arr['catiall'];
         foreach($categorys as $key => $value){
             if(array_key_exists('level',$value)){
-                $level = $value['level'][0];
-                $imgnum = $value['level'][1] ?? null;
-                $textnum = $value['level'][2] ?? null;
+                $parts = explode(',', $value['id']);
+                $level = $parts[0] ?? null;
+                $imgnum = $parts[1] ?? null;
+                $textnum = $parts[2] ?? null;
                 if(!empty($textnum) && $textnum > 0){
                     $text_num = Company::where('level', $level)
                     ->where('website_id',$data['website_id'])
@@ -6215,23 +6215,13 @@ class NewsService implements NewsServiceInterface
                     ->limit($imgnum)
                     ->get()->all();
                 }
-                if(!empty($img_num)){
-                    foreach ($img_num as $k => $v) {
-                        $img_num[$k]->category_name = $catiall[$v->category_id]['alias'];
-                        $imgurl = json_decode($v['imgs'], true);
-                        if(!empty($imgurl)){
-                            $img_num[$k]->imgurl = $imgurl[0];
-                        }
-                        $img_num[$k]->pinyin = $catiall[$v->category_id]['pinyin'];
-
-                    }
-                }
                 
             }
             if(array_key_exists('id',$value)){
-                $category_id = $value['id'];
-                $imgnum = $value['id'][1] ?? null;
-                $textnum = $value['id'][2] ?? null;
+                $parts = explode(',', $value['id']);
+                $category_id = $parts[0] ?? null;
+                $imgnum = $parts[1] ?? null;
+                $textnum = $parts[2] ?? null;
                 if(!empty($textnum) && $textnum > 0){
                     $text_num = Company::where('category_id', $category_id)
                     ->where('website_id',$data['website_id'])
@@ -6243,6 +6233,7 @@ class NewsService implements NewsServiceInterface
                     ->get()->all();
                 }
                 if(!empty($imgnum) && $imgnum > 0){
+
                     $img_num = Company::where('category_id', $category_id)
                     ->where('website_id',$data['website_id'])
                     ->where('status',1)
@@ -6254,25 +6245,26 @@ class NewsService implements NewsServiceInterface
                     ->limit($imgnum)
                     ->get()->all();
                 }
-                if(!empty($img_num)){
-                    foreach ($img_num as $k => $v) {
-                        $img_num[$k]->category_name = $catiall[$v->category_id]['alias'];
-                        $imgurl = json_decode($v['imgs'], true);
-                        if(!empty($imgurl)){
-                            $img_num[$k]->imgurl = $imgurl[0];
-                        }
-                        $img_num[$k]->pinyin = $catiall[$v->category_id]['pinyin'];
-
-                    }
-                }
+                
                 
             }
             if(!empty($text_num)){
-                    foreach ($text_num as $k => $v) {
-                        $text_num[$k]->category_name = $catiall[$v->category_id]['alias'];
-                        $text_num[$k]->pinyin = $catiall[$v->category_id]['pinyin'];
+                foreach ($text_num as $k => $v) {
+                    $text_num[$k]->category_name = $catiall[$v->category_id]['alias'];
+                    $text_num[$k]->pinyin = $catiall[$v->category_id]['pinyin'];
+                }
+            }
+            if(!empty($img_num)){
+                foreach ($img_num as $k => $v) {
+                    $img_num[$k]->category_name = $catiall[$v->category_id]['alias'];
+                    $imgurl = json_decode($v['imgs'], true);
+                    if(!empty($imgurl)){
+                        $img_num[$k]->imgurl = $imgurl[0];
                     }
+                    $img_num[$k]->pinyin = $catiall[$v->category_id]['pinyin'];
+
                 }
+            }
                 $company[$key]['img_num'] = $img_num ?? [];
                 $company[$key]['text_num'] = $text_num ?? [];
         }