فهرست منبع

修改b端接口:获取项目列表、获取企业列表

15313670163 6 ماه پیش
والد
کامیت
2c155edc75
1فایلهای تغییر یافته به همراه53 افزوده شده و 50 حذف شده
  1. 53 50
      app/JsonRpc/NewsService.php

+ 53 - 50
app/JsonRpc/NewsService.php

@@ -6189,57 +6189,58 @@ class NewsService implements NewsServiceInterface
    * @return array
    */
   public function getCompanyList(array $data): array
-  {
-    // return Result::success($data);
-    $where = [];
-    $user = User::where('id', $data['user_id'])->first();
-    if (empty($user)) {
-      return Result::error('用户不存在!');
-    }
-    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['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]);
+    {
+      // return Result::success($data);
+        $where = [];
+        $user = User::where('id', $data['user_id'])->first();
+        if(empty($user)){
+            return Result::error('用户不存在!');
         }
-      } else {
-        $query =  Company::where('company.status', 1);
-      }
-    }
-    $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($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['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);
+          }
+        }
+        $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',
+          'company.user_id'
+        )
+        ->orderBy('company.updated_at', 'desc')
+        ->paginate($data['pageSize'], ['*'], 'page', $data['page']);
 
-    if ($result->isEmpty()) {
-      return Result::error("暂无企业", 0);
-    }
-    return Result::success($result);
+      if($result->isEmpty()){
+          return Result::error("暂无企业", 0);
+      }
+        return Result::success($result);
   }
   /**
    * 添加企业
@@ -6674,7 +6675,9 @@ class NewsService implements NewsServiceInterface
         'project.updated_at',
         'project.status',
         'website.website_name',
-        'website_category.alias as category_name'
+        'website_category.alias as category_name',
+        'project.website_id',
+        'project.user_id'
       )
       ->orderBy('project.updated_at', 'desc')
       ->offset(($data['page'] - 1) * $data['pageSize'])