Преглед изворни кода

Merge branch 'web_sannong_fr' into dev

15313670163 пре 1 месец
родитељ
комит
837788f71a
1 измењених фајлова са 16 додато и 15 уклоњено
  1. 16 15
      app/JsonRpc/NewsService.php

+ 16 - 15
app/JsonRpc/NewsService.php

@@ -571,8 +571,8 @@ class NewsService implements NewsServiceInterface
      */
     public function getWebsiteArticlett(array $data): array
     {
-
-        $category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
+    
+       $category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
         $result = [];
         if ($category) {
             $placeid = isset($data['placeid']) && !empty($data['placeid']) ? $data['placeid'] - 1 : 0;
@@ -693,6 +693,7 @@ class NewsService implements NewsServiceInterface
         }
         return Result::success($result);
 
+        
     }
 
     /**
@@ -822,14 +823,19 @@ class NewsService implements NewsServiceInterface
             $where['sur_id'] = $survey['sur_id'];
             // $query = ArticleSurvey::where('sur_id',$survey['sur_id']);
         }
-        $result['survey'] = ArticleSurvey::where($where)->where('is_other', 0)
+        $result =  ArticleSurvey::where($where)
+            ->where(function ($query) {
+                $query->where('is_other', 0)
+                      ->orWhere(function ($subQuery) {
+                          $subQuery->where('is_other', 1)
+                                   ->where('other_id', 0);
+                      });
+            })
             ->leftJoin('article', 'article_survey.art_id', 'article.id')
             ->select('article_survey.*', 'article.survey_type')
             ->get()->all();
-        $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();
-        if (empty($result)) {
-            return Result::error("此文章暂无调查问卷", 0);
+        if(empty($result)){
+            return Result::error("此文章暂无调查问卷",0); 
         }
         return Result::success($result);
     }
@@ -937,16 +943,11 @@ class NewsService implements NewsServiceInterface
                         return Result::error("请选择已有的选项!", 0);
                     }
                     $retult_survey = ArticleSurvey::where('website_id', $data['website_id'])
-                        ->where('sur_id', $data['sur_id'])
-                        ->get();
-
+                    ->where('sur_id', $data['sur_id'])
+                    ->get();
                     return Result::success($retult_survey);
-
                 }
-                return Result::error("参数必填!");
-                // if(isset($data['choice_id']) && !empty($data['choice_id'])){
-                //     $choice = ArticleSurvey::whereIn('id',$data['choice_id'])->where('website_id',$data['website_id'])->where('is_other',1)->where('other_id',0)->first();
-                // }
+                return Result::error("参数必填!"); 
             }
             return Result::error("此调查问卷不存在", 0);
         }