LiuJ 5 dagen geleden
bovenliggende
commit
0450a0d62e
1 gewijzigde bestanden met toevoegingen van 252 en 244 verwijderingen
  1. 252 244
      app/JsonRpc/NewsService.php

+ 252 - 244
app/JsonRpc/NewsService.php

@@ -287,14 +287,14 @@ class NewsService implements NewsServiceInterface
       $result = Category::where($data)->delete();
       WebsiteCategory::where(['category_id' => $data['id']])->delete();
       if (!$result) {
-          Db::rollBack();
-         return Result::error("删除失败");
+        Db::rollBack();
+        return Result::error("删除失败");
       }
       Db::commit();
       return Result::success($result);
     } catch (\Exception $e) {
       Db::rollBack();
-      return Result::error("删除失败".$e->getMessage());
+      return Result::error("删除失败" . $e->getMessage());
     }
   }
 
@@ -4103,7 +4103,7 @@ class NewsService implements NewsServiceInterface
     $result = Notice::where('id', $data['id'])->delete();
     return Result::success($result);
   }
-  public function getMSG(array $data): array
+  public function c(array $data): array
   {
     $type_id = isset($data['type_id']) ? $data['type_id'] : 1;
     // '1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)
@@ -5979,39 +5979,62 @@ class NewsService implements NewsServiceInterface
         } else {
           $query =  Company::whereIn('company.status', [0, 2]);
         }
-        if($user['type_id']!= 10000){
-            $where['user_id'] = $data['user_id'];
+        if ($user['type_id'] != 10000) {
+          $where['user_id'] = $data['user_id'];
         }
-        if(isset($data['title']) && !empty($data['title'])){
-          array_push($where, ['company.title', 'like', '%'. $data['title']. '%']);
+        if (isset($data['title']) && !empty($data['title'])) {
+          array_push($where, ['company.title', 'like', '%' . $data['title'] . '%']);
         }
-        if(isset($data['website_id']) && !empty($data['website_id'])){
+        if (isset($data['website_id']) && !empty($data['website_id'])) {
           array_push($where, ['website.id', $data['website_id']]);
         }
-        if(isset($data['ischeck']) && !empty($data['ischeck'])){
-          if($data['ischeck'] == 1){
-              if(isset($data['status']) && $data['status'] != ''){
-                array_push($where, ['company.status', $data['status']]);
-                $query = Company::where($where);
-              }else{
-                $query =  Company::whereIn('company.status', [0,2]);
-              }
-          }else{
-              $query =  Company::where('company.status', 1);
+        if (isset($data['ischeck']) && !empty($data['ischeck'])) {
+          if ($data['ischeck'] == 1) {
+            if (isset($data['status']) && $data['status'] != '') {
+              array_push($where, ['company.status', $data['status']]);
+              $query = Company::where($where);
+            } else {
+              $query =  Company::whereIn('company.status', [0, 2]);
+            }
+          } else {
+            $query =  Company::where('company.status', 1);
           }
         }
         $result = $query->where($where)
-        ->leftJoin('website_category', function ($query) {
+          ->leftJoin('website_category', function ($query) {
             $query->on('website_category.category_id', '=', 'company.category_id')
-                ->on('website_category.website_id', '=', 'company.website_id');        
+              ->on('website_category.website_id', '=', 'company.website_id');
+          })
+          ->leftJoin('website', 'company.website_id', '=', 'website.id')
+          ->select(
+            'company.id',
+            'company.title',
+            'company.website_id',
+            'company.category_id',
+            'website.website_name',
+            'website_category.alias as category_name',
+            'company.status',
+            'company.updated_at',
+          )
+          ->orderBy('company.updated_at', 'desc')
+          ->paginate($data['pageSize'], ['*'], 'page', $data['page']);
+
+        if ($result->isEmpty()) {
+          return Result::error("暂无企业", 0);
+        }
+      }
+      $result = $query->where($where)
+        ->leftJoin('website_category', function ($query) {
+          $query->on('website_category.category_id', '=', 'company.category_id')
+            ->on('website_category.website_id', '=', 'company.website_id');
         })
         ->leftJoin('website', 'company.website_id', '=', 'website.id')
         ->select(
-          'company.id', 
-          'company.title', 
-          'company.website_id', 
-          'company.category_id', 
-          'website.website_name', 
+          'company.id',
+          'company.title',
+          'company.website_id',
+          'company.category_id',
+          'website.website_name',
           'website_category.alias as category_name',
           'company.status',
           'company.updated_at',
@@ -6019,33 +6042,11 @@ class NewsService implements NewsServiceInterface
         ->orderBy('company.updated_at', 'desc')
         ->paginate($data['pageSize'], ['*'], 'page', $data['page']);
 
-      if($result->isEmpty()){
-          return Result::error("暂无企业", 0);
+      if ($result->isEmpty()) {
+        return Result::error("暂无企业", 0);
       }
+      return Result::success($result);
     }
-    $result = $query->where($where)
-      ->leftJoin('website_category', function ($query) {
-        $query->on('website_category.category_id', '=', 'company.category_id')
-          ->on('website_category.website_id', '=', 'company.website_id');
-      })
-      ->leftJoin('website', 'company.website_id', '=', 'website.id')
-      ->select(
-        'company.id',
-        'company.title',
-        'company.website_id',
-        'company.category_id',
-        'website.website_name',
-        'website_category.alias as category_name',
-        'company.status',
-        'company.updated_at',
-      )
-      ->orderBy('company.updated_at', 'desc')
-      ->paginate($data['pageSize'], ['*'], 'page', $data['page']);
-
-    if ($result->isEmpty()) {
-      return Result::error("暂无企业", 0);
-    }
-    return Result::success($result);
   }
   /**
    * 添加企业
@@ -6270,7 +6271,8 @@ class NewsService implements NewsServiceInterface
     }
     if (isset($data['keyword']) && !empty($data['keyword'])) {
       array_push($where, ['title', 'like', '%' . $data['keyword'] . '%']);
-    }  $query = Company::where($where);
+    }
+    $query = Company::where($where);
     $company = $this->processArticle(
       $query->select('id', 'title', 'introduce', 'description', 'content', 'category_id', 'cat_arr_id')
         ->orderBy('updated_at', 'desc')
@@ -6288,204 +6290,210 @@ class NewsService implements NewsServiceInterface
     ];
     return Result::success($result);
   }
-    /**
-     * 获取项目列表
-     * @param array $data
-     * @return array
-     */
-    public function getProjectList(array $data): array
-    {
-        $where = [];
-        $user = User::where('id',$data['user_id'])->first();
-        if(empty($user)){
-            return Result::error('用户不存在!');
-        }
-        if($user->type_id != 10000){
-            array_push($where, ['project.user_id', $data['user_id']]);
-        }
-        $query = Project::query();
-        if(isset($data['website_id']) && !empty($data['website_id'])){
-           array_push($where, ['project.website_id', $data['website_id']]);
-        }
-        if(isset($data['title']) && !empty($data['title'])){
-            array_push($where, ['project.title', 'like', '%' . $data['title'] . '%']);
-        }
-        if($data['status'] != 3){
-              array_push($where, ['project.status', $data['status']]);
-        }
-        $query = Project::where($where)
-        ->when($data['status'] == 3, function($query){
-                $query->whereIn('project.status', [0, 2]);
-        });
-        $count = $query->clone()
-        ->count();
-        $rows = $query->clone()
-            ->leftJoin('website', 'project.website_id','website.id' )
-            ->leftJoin('website_category', function ($join) {
-              $join->on('project.website_id', '=', 'website_category.website_id')
-                ->on('project.category_id', '=', 'website_category.category_id');
-            })
-            ->select('project.id','project.title','project.updated_at','project.status','website.website_name',
-            'website_category.alias as category_name')
-            ->orderBy('project.updated_at', 'desc')
-            ->offset(($data['page'] - 1) * $data['pageSize'])
-            ->limit($data['pageSize'])
-            ->get();
-        if($rows->isEmpty()){
-            return Result::error("暂无相关项目信息", 0);
-        }
-        $result = [
-            'count' => $count,
-            'rows' => $rows,
-        ];
-        return Result::success($result);
+  /**
+   * 获取项目列表
+   * @param array $data
+   * @return array
+   */
+  public function getProjectList(array $data): array
+  {
+    $where = [];
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error('用户不存在!');
     }
-    /**
-     * 添加项目
-     * @param array $data
-     * @return array
-     */
-    public function addProject(array $data): array
-    {
-      $user = User::where('id',$data['user_id'])->first();
-      if(empty($user)){
-        return Result::error("暂无相关用户信息", 0);
-      }
-      if($user->type_id == 10000){
-        $data['status'] = 1;
-      }else{
-        $data['status'] = 0;
-      }
-      if ($data['keyword'] == '') {
-          //提取标题+内容中的关键词
-          $data['keyword'] = $data['title'];
-          //  . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
-          Jieba::init(); // 初始化 jieba-php
-          Finalseg::init();
-          $segList = Jieba::cut($data['keyword']);
-          $segList1 = array_slice($segList, 0, 8);
-          $data['keyword'] = implode(',', $segList1);
-      }
-      if ($data['description'] == '') {
-        //提取内容中的描述
-        // var_dump(11111);
-        $data['description'] = mb_substr(str_replace(' ', '', strip_tags($data['introduce'])), 0, 100);
-      }
-      $project = Project::insertGetId($data);
-      if(empty($project)){
-          return Result::error("暂无相关项目信息", 0);
-      }
-      return Result::success($project);
+    if ($user->type_id != 10000) {
+      array_push($where, ['project.user_id', $data['user_id']]);
     }
-    /**
-     * 更新项目
-     * @param array $data
-     * @return array
-     */
-    public function upProject(array $data): array
-    {
-        $project = Project::where('id', $data['id'])->first();
-        if(empty($project)){
-            return Result::error("暂无相关项目信息", 0);
-        }
-        $id = $data['id'];
-        unset($data['id']);
-        $user = User::where('id',$data['user_id'])->first();
-        if(empty($user)){
-          return Result::error("暂无相关用户信息", 0);
-        }
-        if($user->type_id == 10000){
-          $data['status'] = 1;
-        }else{
-          $data['status'] = 0;
-        }
-        unset($data['user_id']);
-        if ($data['keyword'] == '') {
-          //提取标题+内容中的关键词
-          $data['keyword'] = $data['title'];
-          //  . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
-          Jieba::init(); // 初始化 jieba-php
-          Finalseg::init();
-          $segList = Jieba::cut($data['keyword']);
-          $segList1 = array_slice($segList, 0, 8);
-          $data['keyword'] = implode(',', $segList1);
-        }
-        if ($data['description'] == '') {
-          //提取内容中的描述
-          // var_dump(11111);
-          $data['description'] = mb_substr(str_replace(' ', '', strip_tags($data['introduce'])), 0, 100);
-        }
-        $result = Project::where('id', $id)->update($data);
-        if(empty($result)){
-          return Result::error("更新失败", 0);
-        }
-        return Result::success($result);
+    $query = Project::query();
+    if (isset($data['website_id']) && !empty($data['website_id'])) {
+      array_push($where, ['project.website_id', $data['website_id']]);
     }
-    /**
-     * 删除项目
-     * @param array $data
-     * @return array
-     */
+    if (isset($data['title']) && !empty($data['title'])) {
+      array_push($where, ['project.title', 'like', '%' . $data['title'] . '%']);
+    }
+    if ($data['status'] != 3) {
+      array_push($where, ['project.status', $data['status']]);
+    }
+    $query = Project::where($where)
+      ->when($data['status'] == 3, function ($query) {
+        $query->whereIn('project.status', [0, 2]);
+      });
+    $count = $query->clone()
+      ->count();
+    $rows = $query->clone()
+      ->leftJoin('website', 'project.website_id', 'website.id')
+      ->leftJoin('website_category', function ($join) {
+        $join->on('project.website_id', '=', 'website_category.website_id')
+          ->on('project.category_id', '=', 'website_category.category_id');
+      })
+      ->select(
+        'project.id',
+        'project.title',
+        'project.updated_at',
+        'project.status',
+        'website.website_name',
+        'website_category.alias as category_name'
+      )
+      ->orderBy('project.updated_at', 'desc')
+      ->offset(($data['page'] - 1) * $data['pageSize'])
+      ->limit($data['pageSize'])
+      ->get();
+    if ($rows->isEmpty()) {
+      return Result::error("暂无相关项目信息", 0);
+    }
+    $result = [
+      'count' => $count,
+      'rows' => $rows,
+    ];
+    return Result::success($result);
+  }
+  /**
+   * 添加项目
+   * @param array $data
+   * @return array
+   */
+  public function addProject(array $data): array
+  {
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error("暂无相关用户信息", 0);
+    }
+    if ($user->type_id == 10000) {
+      $data['status'] = 1;
+    } else {
+      $data['status'] = 0;
+    }
+    if ($data['keyword'] == '') {
+      //提取标题+内容中的关键词
+      $data['keyword'] = $data['title'];
+      //  . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
+      Jieba::init(); // 初始化 jieba-php
+      Finalseg::init();
+      $segList = Jieba::cut($data['keyword']);
+      $segList1 = array_slice($segList, 0, 8);
+      $data['keyword'] = implode(',', $segList1);
+    }
+    if ($data['description'] == '') {
+      //提取内容中的描述
+      // var_dump(11111);
+      $data['description'] = mb_substr(str_replace(' ', '', strip_tags($data['introduce'])), 0, 100);
+    }
+    $project = Project::insertGetId($data);
+    if (empty($project)) {
+      return Result::error("暂无相关项目信息", 0);
+    }
+    return Result::success($project);
+  }
+  /**
+   * 更新项目
+   * @param array $data
+   * @return array
+   */
+  public function upProject(array $data): array
+  {
+    $project = Project::where('id', $data['id'])->first();
+    if (empty($project)) {
+      return Result::error("暂无相关项目信息", 0);
+    }
+    $id = $data['id'];
+    unset($data['id']);
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error("暂无相关用户信息", 0);
+    }
+    if ($user->type_id == 10000) {
+      $data['status'] = 1;
+    } else {
+      $data['status'] = 0;
+    }
+    unset($data['user_id']);
+    if ($data['keyword'] == '') {
+      //提取标题+内容中的关键词
+      $data['keyword'] = $data['title'];
+      //  . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
+      Jieba::init(); // 初始化 jieba-php
+      Finalseg::init();
+      $segList = Jieba::cut($data['keyword']);
+      $segList1 = array_slice($segList, 0, 8);
+      $data['keyword'] = implode(',', $segList1);
+    }
+    if ($data['description'] == '') {
+      //提取内容中的描述
+      // var_dump(11111);
+      $data['description'] = mb_substr(str_replace(' ', '', strip_tags($data['introduce'])), 0, 100);
+    }
+    $result = Project::where('id', $id)->update($data);
+    if (empty($result)) {
+      return Result::error("更新失败", 0);
+    }
+    return Result::success($result);
+  }
+  /**
+   * 删除项目
+   * @param array $data
+   * @return array
+   */
 
-    public function delProject(array $data): array
-    {
-      $user = User::where('id',$data['user_id'])->first();
-      if(empty($user)){
-        return Result::error("暂无相关用户信息", 0);
-      }
-      $project = Project::where('id', $data['id'])->first();
-      if(empty($project)){
-          return Result::error("暂无相关项目信息", 0);
-      }
-      $result = Project::where('id',$data['id'])->delete();
-      if(empty($result)){
-        return Result::error("删除失败", 0);
+  public function delProject(array $data): array
+  {
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error("暂无相关用户信息", 0);
+    }
+    $project = Project::where('id', $data['id'])->first();
+    if (empty($project)) {
+      return Result::error("暂无相关项目信息", 0);
+    }
+    $result = Project::where('id', $data['id'])->delete();
+    if (empty($result)) {
+      return Result::error("删除失败", 0);
+    }
+    return Result::success($result);
+  }
+  /**
+   * 审核项目
+   * @param array $data
+   * @return array
+   */
+  public function checkProject(array $data): array
+  {
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error("暂无相关用户信息", 0);
+    }
+    // 0:未审核;   1:已审核;   2:已拒绝;
+    if ($user->type_id != 10000) {
+      if ($data['status'] == 1 || $data['status'] == 2) {
+        return Result::error("此用户权限不足", 0);
       }
-      return Result::success($result);
     }
-    /**
-     * 审核项目
-     * @param array $data
-     * @return array
-     */
-    public function checkProject(array $data): array
-    {
-        $user = User::where('id',$data['user_id'])->first();
-        if(empty($user)){
-          return Result::error("暂无相关用户信息", 0);
-        }
-        // 0:未审核;   1:已审核;   2:已拒绝;
-        if($user->type_id != 10000){
-          if($data['status'] == 1 || $data['status'] == 2){
-            return Result::error("此用户权限不足", 0);
-          }
-        }
-        $project = Project::where('id', $data['id'])->first();
-        if(empty($project)){
-            return Result::error("暂无相关项目信息", 0);
-        }
-        if($data['status'] == 2){
-          $result = Project::where('id', $data['id'])->update(['status' => $data['status'],'refuse_reason' => $data['refuse_reason']]);
-        }else{
-          $result = Project::where('id',$data['id'])->update(['status' => $data['status']]);
-        }
-        
-        if(empty($result)){
-          return Result::error("审核失败", 0);
-        }
-        return Result::success($result);
+    $project = Project::where('id', $data['id'])->first();
+    if (empty($project)) {
+      return Result::error("暂无相关项目信息", 0);
     }
-    /**
-     * 获取项目详情
-     * @param array $data
-     * @return array
-     */
-    public function getProjectInfo(array $data): array
-    {
-        $project = Project::where('id', $data['id'])->first();
-        if(empty($project)){
-            return Result::error("暂无相关项目信息", 0);
-        }
-        return Result::success($project);
+    if ($data['status'] == 2) {
+      $result = Project::where('id', $data['id'])->update(['status' => $data['status'], 'refuse_reason' => $data['refuse_reason']]);
+    } else {
+      $result = Project::where('id', $data['id'])->update(['status' => $data['status']]);
     }
+
+    if (empty($result)) {
+      return Result::error("审核失败", 0);
+    }
+    return Result::success($result);
+  }
+  /**
+   * 获取项目详情
+   * @param array $data
+   * @return array
+   */
+  public function getProjectInfo(array $data): array
+  {
+    $project = Project::where('id', $data['id'])->first();
+    if (empty($project)) {
+      return Result::error("暂无相关项目信息", 0);
+    }
+    return Result::success($project);
+  }
 }