15313670163 1 месяц назад
Родитель
Сommit
92f41c1829

+ 2 - 2
.env

@@ -2,11 +2,11 @@ APP_NAME=user_producer
 APP_ENV=dev
 
 DB_DRIVER=mysql
-DB_HOST=101.254.114.211
+DB_HOST=192.168.1.123
 DB_PORT=13306
 DB_DATABASE=hyperf
 DB_USERNAME=root
-DB_PASSWORD=xKmapDpKCxMMSkbe
+DB_PASSWORD=zxt_mysql_dev
 DB_CHARSET=utf8mb4
 DB_COLLATION=utf8mb4_unicode_ci
 DB_PREFIX=

+ 36 - 18
app/JsonRpc/NewsService.php

@@ -395,24 +395,23 @@ class NewsService implements NewsServiceInterface
     public function getWebsiteArticleList(array $data): array
     {
 
-       $where[] = ['status', '=', 1];
-
+        $where[] = ['status', '=', 1];
        if(isset($data['keyword'])  && !empty($data['keyword'])){
             array_push($where,['article.title','like','%'.$data['keyword'].'%']);
         }
         if(isset($data['catid'])  && !empty($data['catid'])){
             if(is_array($data['catid'])){
                 $category = WebsiteCategory::where('website_id',$data['website_id'])->whereIn('category_id',$data['catid'])->pluck('category_id');
-                $where[] = ['catid', 'in', $data['catid']];
+                array_push($where,['catid', 'in', $data['catid']]);
             }else{
                 $category = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$data['catid'])->pluck('category_id');
-                $where[] = ['catid', '=', $data['catid']];
+                array_push($where,['catid', '=', $data['catid']]);
             }
             if(empty($category)){
                return Result::error("此网站暂无此栏目",0); 
             }
         }
-        // return Result::success($category);
+        // return Result::success($where);
         $rep = Article::where(function ($query) use ($where) {
             foreach ($where as $condition) {
                 if ($condition[1] === 'in') {
@@ -549,13 +548,14 @@ class NewsService implements NewsServiceInterface
         
     }
     /**
-     * 前端-调查问卷投票   --------未完待续-------
+     * 前端-调查问卷投票   
      * @param array $data
      * @return array
      */
     public function addWebsiteSurveyVote(array $data): array
     {
-        if(isset($data['website_id']) &&!empty($data['website_id'])){
+        
+        if(isset($data['website_id']) && !empty($data['website_id'])){
             $website = Website::where('id',$data['website_id'])->first(); 
             if(empty($website)){
                 return Result::error("暂无此网站",0); 
@@ -565,36 +565,54 @@ class NewsService implements NewsServiceInterface
                 if(empty($survey)){
                     return Result::error("此调查问卷不存在",0);
                 }
+                // return Result::success($survey);
                 // 调查问卷类型   0:单选 1:多选
                 $type = Article::where('survey_id',$data['sur_id'])->pluck('survey_type');
                 // return Result::success($type);
-                if(empty($type) || (!in_array($type, [0, 1], true))){
+                if(empty($type) || ($type[0]!= 1 && $type[0]!= 0)){
                     return Result::error("此调查问卷不可投票",0); 
                 }
-                return Result::success($type[0]);
+                // return Result::success($type[0]);
                 if(isset($data['choice_id']) &&!empty($data['choice_id'])){
                     if($type[0] == 0){
-                        $choice = ArticleSurvey::where('id',$data['choice_id'])->where('website_id',$data['website_id'])->first();
+                        if(is_array($data['choice_id'])){
+                            return Result::error("请选择一个选项!",0);
+                        }
+                        $data['choice_id'] = [$data['choice_id']];
                     }else{
-                        $choice = ArticleSurvey::whereIn('id',$data['choice_id'])->where('website_id',$data['website_id'])->get()->all();
+                        if(!is_array($data['choice_id'])){
+                            return Result::error("请传递数组!",0);
+                        }
+                    }
+                    // return Result::success($data['choice_id']);
+                    $choice['other'] = ArticleSurvey::whereIn('id',$data['choice_id'])
+                    ->where('website_id',$data['website_id'])
+                    ->where('is_other',1)
+                    ->where('other_id','!=',0)
+                    ->first();
+                    // return Result::success($data);
+                    if(!empty($choice['other'])){
+                        array_push($data['choice_id'],$choice['other']['other_id']);
+                        // return Result::success($data['choice_id']);
                     }
+                    // return Result::success($data);
+                    $choice = ArticleSurvey::whereIn('id',$data['choice_id'])
+                    ->where('website_id',$data['website_id'])
+                    ->increment('results', 1);                 
                     if(empty($choice)){
                         return Result::error("请选择已有的选项!",0);
                     }
+ 
                     return Result::success($choice);
-                    $where = [
-                        'website_id'=>$data['website_id'],
-                        'sur_id'=>$data['sur_id'],
-                        'choice_id'=>$data['choice_id']
-                    ];
+
                 }
-                return Result::success("111");
+                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("此调查问卷不存在",0);
         }
-        return Result::success("2222");
+        return Result::error("参数必填!");
     }
 }

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
runtime/container/classes.cache


+ 1 - 1
runtime/hyperf.pid

@@ -1 +1 @@
-48622
+64458

+ 1 - 0
vendor/composer/autoload_classmap.php

@@ -17,6 +17,7 @@ return array(
     'App\\Listener\\ResumeExitCoordinatorListener' => $baseDir . '/app/Listener/ResumeExitCoordinatorListener.php',
     'App\\Model\\Article' => $baseDir . '/app/Model/Article.php',
     'App\\Model\\ArticleData' => $baseDir . '/app/Model/ArticleData.php',
+    'App\\Model\\ArticleSurvey' => $baseDir . '/app/Model/ArticleSurvey.php',
     'App\\Model\\Category' => $baseDir . '/app/Model/Category.php',
     'App\\Model\\Link' => $baseDir . '/app/Model/Link.php',
     'App\\Model\\Model' => $baseDir . '/app/Model/Model.php',

+ 1 - 0
vendor/composer/autoload_static.php

@@ -701,6 +701,7 @@ class ComposerStaticInit88f2a4d4a4e81dc7d415bcdf39930654
         'App\\Listener\\ResumeExitCoordinatorListener' => __DIR__ . '/../..' . '/app/Listener/ResumeExitCoordinatorListener.php',
         'App\\Model\\Article' => __DIR__ . '/../..' . '/app/Model/Article.php',
         'App\\Model\\ArticleData' => __DIR__ . '/../..' . '/app/Model/ArticleData.php',
+        'App\\Model\\ArticleSurvey' => __DIR__ . '/../..' . '/app/Model/ArticleSurvey.php',
         'App\\Model\\Category' => __DIR__ . '/../..' . '/app/Model/Category.php',
         'App\\Model\\Link' => __DIR__ . '/../..' . '/app/Model/Link.php',
         'App\\Model\\Model' => __DIR__ . '/../..' . '/app/Model/Model.php',

Некоторые файлы не были показаны из-за большого количества измененных файлов