15313670163 1 maand geleden
bovenliggende
commit
7480f89e6d
5 gewijzigde bestanden met toevoegingen van 81 en 35 verwijderingen
  1. 71 22
      app/JsonRpc/NewsService.php
  2. 10 1
      app/JsonRpc/NewsServiceInterface.php
  3. 0 1
      runtime/container/scan.cache
  4. 0 1
      runtime/hyperf.pid
  5. 0 10
      runtime/logs/hyperf.log

+ 71 - 22
app/JsonRpc/NewsService.php

@@ -654,16 +654,16 @@ class NewsService implements NewsServiceInterface
      */
     public function getWebsiteSurvey(array $data): array
     {
-        if (isset($data['survey_id']) && !empty($data['survey_id'])) {
-            $website = Website::where('id', $data['website_id'])->first();
-            if (empty($website)) {
-                return Result::error("暂无此网站", 0);
+        if(isset($data['website_id']) && !empty($data['website_id'])){
+            $website = Website::where('id',$data['website_id'])->first();
+            if(empty($website)){
+                return Result::error("暂无此网站",0);
             }
         }
-        if (isset($data['art_id']) && !empty($data['art_id'])) {
-            $article = Article::where('id', $data['art_id'])->first();
-            if (empty($article)) {
-                return Result::error("暂无此文章", 0);
+        if(isset($data['art_id'])  && !empty($data['art_id'])){
+            $article = Article::where('id',$data['art_id'])->where('status',1)->first();
+            if(empty($article)){
+                return Result::error("暂无此文章",0);
             }
             // return Result::error($data,0);
             $where['art_id'] = $data['art_id'];
@@ -677,14 +677,14 @@ 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)
-            ->leftJoin('article', 'article_survey.art_id', 'article.id')
-            ->select('article_survey.*', 'article.survey_type')
-            ->get()->all();
-        $result['others'] = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', 0)->first();
-        $result['other'] = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', '!=', 0)->orderByDesc('created_at')->first();
-        if (empty($result)) {
-            return Result::error("此文章暂无调查问卷", 0);
+        $result['survey'] =  ArticleSurvey::where($where)->where('is_other',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); 
         }
         return Result::success($result);
     }
@@ -735,11 +735,11 @@ class NewsService implements NewsServiceInterface
      */
     public function addWebsiteSurveyVote(array $data): array
     {
-
-        if (isset($data['website_id']) && !empty($data['website_id'])) {
-            $website = Website::where('id', $data['website_id'])->first();
-            if (empty($website)) {
-                return Result::error("暂无此网站", 0);
+        
+        if(isset($data['website_id']) && !empty($data['website_id'])){
+            $website = Website::where('id',$data['website_id'])->first(); 
+            if(empty($website)){
+                return Result::error("暂无此网站",0); 
             }
             if (isset($data['sur_id']) && !empty($data['sur_id'])) {
                 $survey = ArticleSurvey::where('sur_id', $data['sur_id'])->where('website_id', $data['website_id'])->pluck('sur_id');
@@ -900,4 +900,53 @@ class NewsService implements NewsServiceInterface
     }
 
     //20250226  产品列表
-}
+
+    /**
+     * 后端-获取网站调查问卷列表
+     * @param array $data
+     * @return array
+     */
+    public function getSurveyList(array $data): array
+    {
+        $result = Article::where('is_survey',1)
+        // ->select('id','survey_id','survey_type')
+        ->orderByDesc('updated_at')
+        ->limit($data['pageSize'])
+        ->offset(($data['page']-1)*$data['pageSize'])
+        ->get();
+        if(empty($result)){
+            return Result::error("暂无调查问卷",0);
+        }
+        return Result::success($result);
+    }
+    /**
+     * 后端-获取网站调查问卷详情
+     * @param array $data
+     * @return array 
+     */
+    public function getSurveyInfo(array $data): array
+    {
+        if(isset($data['sur_id']) &&!empty($data['sur_id'])){
+            $where = [ 'sur_id'=>$data['sur_id']];
+            $result['survey'] =  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)){
+                return Result::error("此调查问卷不存在",0);
+            }
+            $resultsArray  = array_column($result['survey'], '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();
+            
+            // $total = 0;
+            if(!empty($result['other'])){
+                $total = $total + $result['other']['results'];
+            }
+            $result['total'] = $total;
+        }
+        return Result::success($result);
+    }
+}

+ 10 - 1
app/JsonRpc/NewsServiceInterface.php

@@ -134,5 +134,14 @@ interface NewsServiceInterface
     public function updateGood(array $data): array;
 
     //20250226  产品列表
-
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getSurveyList(array $data):array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getSurveyInfo(array $data):array;
 }

File diff suppressed because it is too large
+ 0 - 1
runtime/container/scan.cache


+ 0 - 1
runtime/hyperf.pid

@@ -1 +0,0 @@
-64458

+ 0 - 10
runtime/logs/hyperf.log

@@ -1,10 +0,0 @@
-<<<<<<< HEAD
-=======
-[2024-12-30T06:38:12.496098+00:00] sql.INFO: [709.21] select `category`.*, `category`.`id` as `category_id` from `category` where (`pid` = '7') [] []
-[2024-12-30T06:38:47.428649+00:00] sql.INFO: [17.24] select `category`.*, `category`.`id` as `category_id` from `category` where (`pid` = '5') [] []
-[2024-12-30T06:51:39.863013+00:00] sql.INFO: [65.56] select `category`.*, `category`.`id` as `category_id` from `category` where (`pid` = '5') [] []
-[2024-12-30T06:54:42.876483+00:00] sql.INFO: [68.75] select `category`.*, `category`.`id` as `category_id` from `category` where (`pid` = '5') [] []
-[2024-12-30T06:54:56.791140+00:00] sql.INFO: [3328.19] select `category`.*, `category`.`id` as `category_id` from `category` where (`pid` = '0') [] []
-[2024-12-30T06:56:06.854836+00:00] sql.INFO: [67] select `category`.*, `category`.`id` as `category_id` from `category` where (`pid` = '0') [] []
-[2024-12-30T06:56:15.144154+00:00] sql.INFO: [17.25] select `category`.*, `category`.`id` as `category_id` from `category` where (`pid` = '5') [] []
->>>>>>> bugfix_02025_02_24

Some files were not shown because too many files changed in this diff