15313670163 1 bulan lalu
induk
melakukan
706fcbc5a2
3 mengubah file dengan 29 tambahan dan 11 penghapusan
  1. 28 10
      app/JsonRpc/NewsService.php
  2. 0 0
      runtime/container/scan.cache
  3. 1 1
      runtime/hyperf.pid

+ 28 - 10
app/JsonRpc/NewsService.php

@@ -947,24 +947,42 @@ class NewsService implements NewsServiceInterface
     {
         if(isset($data['sur_id']) &&!empty($data['sur_id'])){
             $where = [ 'sur_id'=>$data['sur_id']];
-            $result['survey'] =  ArticleSurvey::where($where)->where('is_other',0)
+            $choose =  ArticleSurvey::where($where)->where('is_other',0)
             ->leftJoin('article','article_survey.art_id','article.id')
             ->select('article_survey.*','article.survey_type')
             ->get()->all();
-            if(empty($result)){
+            if(empty($choose)){
                 return Result::error("此调查问卷不存在",0);
             }
-            $resultsArray  = array_column($result['survey'], 'results');
+            $resultsArray  = array_column($choose, 'results');
             $total = array_sum($resultsArray);
-            // $total = $result['survey']->sum('results');
-            $result['other'] = ArticleSurvey::where($where)->where('is_other',1)->where('other_id',0)->first();
-            $result['others'] = ArticleSurvey::where($where)->where('is_other',1)->where('other_id','!=',0)->orderByDesc('created_at')->first();
-            
+            $other = ArticleSurvey::where($where)->where('is_other',1)->where('other_id',0)->first();
+            $others = ArticleSurvey::where($where)->where('is_other',1)->where('other_id','!=',0)->orderByDesc('created_at')->get()->all();
             // $total = 0;
-            if(!empty($result['other'])){
-                $total = $total + $result['other']['results'];
+            if(!empty($other)){
+                $total = $total + $other['results'];
+                if(!empty($others)){
+                    $other['hasChildren'] = true;
+                    // array_push($other,['hasChildren','=',true]);
+                    $other['children'] = $others;
+                    $other_choices = [$other->toArray()];
+                    $mer_choice = array_merge($choose,$other_choices);
+                    $value_choice = array_values($mer_choice);
+                }
+                else{
+                    // return Result::error('1111');
+                    $other_choices = [$other->toArray()];
+                    $other_choices = array_merge($choose,$other_choices);
+                    $value_choice = array_values($other_choices);
+                    // return Result::success($result);
+                }
+            }else{
+                $value_choice = $choose;
             }
-            $result['total'] = $total;
+            $result = [
+                'choose'=>$value_choice,
+                'total'=>$total 
+            ];
         }
         return Result::success($result);
     }

File diff ditekan karena terlalu besar
+ 0 - 0
runtime/container/scan.cache


+ 1 - 1
runtime/hyperf.pid

@@ -1 +1 @@
-34601
+37818

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini