LiuJ 5 месяцев назад
Родитель
Сommit
e0e70674ad
1 измененных файлов с 192 добавлено и 106 удалено
  1. 192 106
      app/JsonRpc/NewsService.php

+ 192 - 106
app/JsonRpc/NewsService.php

@@ -1180,9 +1180,8 @@ class NewsService implements NewsServiceInterface
     if (empty($result)) {
       return Result::error("暂无此新闻!", 0);
     }
-    if(!empty($result['publiced_at']))
-    {
-        $result['updated_at'] = $result['publiced_at'];
+    if (!empty($result['publiced_at'])) {
+      $result['updated_at'] = $result['publiced_at'];
     }
 
     $category = WebsiteCategory::leftJoin('website', 'website.id', '=', 'website_category.website_id')
@@ -3091,41 +3090,52 @@ class NewsService implements NewsServiceInterface
         $JobRecruiting = $this->processJob($JobRecruiting, $website_id);
       }
     }
-    if((isset($data['type']) && $data['type'] == 2) || !isset($data['type'])){
-      if(isset($data['zw_id']) && !empty($data['zw_id'])){
-          array_push($hunt_where, ['job_hunting.job',$data['zw_id']]);
+    if ((isset($data['type']) && $data['type'] == 2) || !isset($data['type'])) {
+      if (isset($data['zw_id']) && !empty($data['zw_id'])) {
+        array_push($hunt_where, ['job_hunting.job', $data['zw_id']]);
       }
-      if(isset($data['jtzw_id']) &&!empty($data['jtzw_id'])){
-          array_push($hunt_where, ['job_hunting.job_name_get',$data['jtzw_id']]);
+      if (isset($data['jtzw_id']) && !empty($data['jtzw_id'])) {
+        array_push($hunt_where, ['job_hunting.job_name_get', $data['jtzw_id']]);
       }
-      if(isset($data['hy_id']) && !empty($data['hy_id'])){
-          array_push($hunt_where, ['job_hunting.industry',$data['hy_id']]);
+      if (isset($data['hy_id']) && !empty($data['hy_id'])) {
+        array_push($hunt_where, ['job_hunting.industry', $data['hy_id']]);
+      }
+      if (isset($data['keyword']) && !empty($data['keyword'])) {
+        array_push($hunt_where, ['job_position.zwname', 'like', '%' . $data['keyword'] . '%']);
       }
-      if(isset($data['keyword']) && !empty($data['keyword'])){ 
-          array_push($hunt_where, ['job_position.zwname','like','%'.$data['keyword'].'%']); 
-
-      } 
       $query = JobHunting::where('job_hunting.status', 2)
-      ->where('job_hunting.website_id', $data['website_id'])
-      ->leftJoin('job_position', 'job_hunting.job_name_get', '=', 'job_position.zwid')
-      ->where($hunt_where) 
-      // ->when(isset($data['keyword']) &&!empty($data['keyword']), function ($query) use ($data) { 
-      //     $query->where('job_position.zwname','like','%'.$data['keyword'].'%'); 
-      // }) 
-      ->when(isset($data['city_id']) &&!empty($data['city_id']), function ($query) use ($data) {
-          $query->where(function($q) use ($data) {
-              $q->WhereRaw("JSON_CONTAINS(job_hunting.city_arr_id, '". intval($data['city_id']). "') = 1");
+        ->where('job_hunting.website_id', $data['website_id'])
+        ->leftJoin('job_position', 'job_hunting.job_name_get', '=', 'job_position.zwid')
+        ->where($hunt_where)
+        // ->when(isset($data['keyword']) &&!empty($data['keyword']), function ($query) use ($data) { 
+        //     $query->where('job_position.zwname','like','%'.$data['keyword'].'%'); 
+        // }) 
+        ->when(isset($data['city_id']) && !empty($data['city_id']), function ($query) use ($data) {
+          $query->where(function ($q) use ($data) {
+            $q->WhereRaw("JSON_CONTAINS(job_hunting.city_arr_id, '" . intval($data['city_id']) . "') = 1");
           });
-      })
-      ->when(isset($data['catid_id']) &&!empty($data['catid_id']), function ($query) use ($data) {
-          $query->where(function($q) use ($data) {
-              $q->WhereRaw("JSON_CONTAINS(job_hunting.cat_arr_id, '". intval($data['catid_id']). "') = 1");
+        })
+        ->when(isset($data['catid_id']) && !empty($data['catid_id']), function ($query) use ($data) {
+          $query->where(function ($q) use ($data) {
+            $q->WhereRaw("JSON_CONTAINS(job_hunting.cat_arr_id, '" . intval($data['catid_id']) . "') = 1");
           });
-      })
-      ->select('job_hunting.id','job_hunting.sexy','job_hunting.experience','job_hunting.origin','job_hunting.industry',
-      'job_hunting.name','job_hunting.job','job_hunting.job_name_get','job_hunting.city_arr_id','job_hunting.cat_arr_id',
-      'job_hunting.created_at','job_hunting.updated_at','job_position.zwname as job_name')
-      ->orderBy('job_hunting.updated_at', 'desc');
+        })
+        ->select(
+          'job_hunting.id',
+          'job_hunting.sexy',
+          'job_hunting.experience',
+          'job_hunting.origin',
+          'job_hunting.industry',
+          'job_hunting.name',
+          'job_hunting.job',
+          'job_hunting.job_name_get',
+          'job_hunting.city_arr_id',
+          'job_hunting.cat_arr_id',
+          'job_hunting.created_at',
+          'job_hunting.updated_at',
+          'job_position.zwname as job_name'
+        )
+        ->orderBy('job_hunting.updated_at', 'desc');
       $hunt_count = $query->count();
       $query = clone $query;
       $JobHunting = $query
@@ -3466,10 +3476,10 @@ class NewsService implements NewsServiceInterface
       $whiteRouterInfo = WhiteRouter::whereJsonContains("website_id", $data['website_id'])->where('router_url', $data['other_route'])->first();
       // 验证路由是否存在
       if (empty($whiteRouterInfo)) {
-            $whiteRouterInfo = WhiteRouter::where("router_type", 1)->where('router_url', $data['other_route'])->first();
+        $whiteRouterInfo = WhiteRouter::where("router_type", 1)->where('router_url', $data['other_route'])->first();
       }
       if (!empty($whiteRouterInfo)) {
-            return Result::success($whiteRouterInfo->toArray());
+        return Result::success($whiteRouterInfo->toArray());
       }
     }
     // 验证栏目路由
@@ -3479,10 +3489,10 @@ class NewsService implements NewsServiceInterface
     if (count($last_category) == 0) {
       return Result::error("该栏目不存在", 0);
     }
-    if(count($last_category) > 1){
+    if (count($last_category) > 1) {
       return Result::error("该子级栏目存在多个,路由验证失败!", 0);
     }
-    if(count($last_category) == 1){
+    if (count($last_category) == 1) {
       $last_category = $last_category[0];
     }
 
@@ -3575,32 +3585,32 @@ class NewsService implements NewsServiceInterface
           return Result::error("该数据不存在", 0);
           break;
       }
-      $catid =0 ;
+      $catid = 0;
       $catidArray = json_decode($article['cat_arr_id'], true);
       $catid = !empty($catidArray) ? end($catidArray) : null;
-    //    return Result::success($article['cat_arr_id']);
+      //    return Result::success($article['cat_arr_id']);
       if (empty($catid)) {
         return Result::error("该数据不存在", 0);
       }
-      
+
       $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
-        ->where('category_id',$catid)
+        ->where('category_id', $catid)
         ->select('path')
         ->pluck('path');
-    }else{
-        if ($last_category['pid'] != 0) {
-            $cat_arr = json_decode($last_category['category_arr_id'], true);
-            $catid = !empty($cat_arr) ? end($cat_arr) : null;
-            $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
-                ->where('category_id',$catid)
-                ->where('path',$data['all_route'])
-                ->pluck('path');
-        } else {
-            $pinyin[0] = $last_category['aLIas_pinyin'];
-        }
+    } else {
+      if ($last_category['pid'] != 0) {
+        $cat_arr = json_decode($last_category['category_arr_id'], true);
+        $catid = !empty($cat_arr) ? end($cat_arr) : null;
+        $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
+          ->where('category_id', $catid)
+          ->where('path', $data['all_route'])
+          ->pluck('path');
+      } else {
+        $pinyin[0] = $last_category['aLIas_pinyin'];
+      }
     }
     // return Result::success($pinyin[0]);
-    if (empty($pinyin) || count($pinyin)>1 || $pinyin[0] != $data['all_route']) {
+    if (empty($pinyin) || count($pinyin) > 1 || $pinyin[0] != $data['all_route']) {
       return Result::error('非法路径!');
     } else {
       return Result::success($pinyin);
@@ -4087,7 +4097,7 @@ class NewsService implements NewsServiceInterface
 
     return Result::success($result);
   }
-  public function noticeList(array $data): array
+  public function readNotice(array $data): array
   {
     $result = Notice::where('id', $data['id'])->first();
     // var_dump($result['re_user_ids'], '--------------------');
@@ -4265,6 +4275,82 @@ class NewsService implements NewsServiceInterface
     ];
     return Result::success($data);
   }
+
+
+  public function noticeList(array $data): array
+  {
+    $where = [];
+    //title
+    if (isset($data['title']) && !empty($data['title'])) {
+      $where[] = ['notice.title', 'like', '%' . $data['title'] . '%'];
+    }
+    //level
+    if (isset($data['level']) && !empty($data['level'])) {
+      $where[] = ['notice.level', '=', $data['level']];
+    }
+    //status
+    if (isset($data['status']) && !empty($data['status'])) {
+      $where[] = ['notice.status', '=', $data['status']];
+    }
+    //type
+    if (isset($data['type']) && !empty($data['type'])) {
+      $where[] = ['notice.type', '=', $data['type']];
+    }
+    var_dump($data, '------------11111-2----test---------');
+    if ($data['type_id'] == 10000) {
+      $result = Notice::when(!empty($data['status1']), function ($query) use ($data) {
+        return $query->whereIn('notice.status', [1, 3]);   //1待审核2已审核3已拒绝
+      })
+        ->where($where)
+        ->orderBy('updated_at', 'desc')
+        ->limit($data['page_size'])
+        ->offset(($data['page'] - 1) * $data['page_size'])
+        ->get();
+      $total = Notice::when(!empty($data['status1']), function ($query) use ($data) {
+        return $query->whereIn('notice.status', [1, 3]);   //1待审核2已审核3已拒绝
+      })
+        ->where($where)
+        ->orderBy('updated_at', 'desc')
+        ->count();
+    } else {
+      $result = Notice::where($where)
+        // ->where('user_id', $data['user_id'])
+        ->Where(function ($query) use ($data) {
+          $query->Where(function ($q) use ($data) {
+            $q->whereRaw('JSON_CONTAINS(notice.re_user_ids, \'' . $data['user_id'] . '\')')
+              ->orWhere('notice.user_id', $data['user_id']);
+          });
+        })
+
+        ->when(!empty($data['status1']), function ($query) use ($data) {
+          return $query->whereIn('notice.status', [1, 3]);   //1待审核2已审核3已拒绝
+        })
+        ->orderBy('updated_at', 'desc')
+        ->limit($data['page_size'])
+        ->offset(($data['page'] - 1) * $data['page_size'])
+        ->get();
+      $total = Notice::where($where)
+        ->when(!empty($data['status1']), function ($query) use ($data) {
+          return $query->whereIn('notice.status', [1, 3]);   //1待审核2已审核3已拒绝
+        })
+        // ->where('user_id', $data['user_id'])
+        ->Where(function ($query) use ($data) {
+          $query->Where(function ($q) use ($data) {
+            $q->whereRaw('JSON_CONTAINS(notice.re_user_ids, \'' . $data['user_id'] . '\')')
+              ->orWhere('notice.user_id', $data['user_id']);
+          });
+        })
+        ->count();
+    }
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+    $data = [
+      'rows' => $result,
+      'count' => $total,
+    ];
+    return Result::success($data);
+  }
   public function getNoticeDetail(array $data): array
   {
     $result = Notice::where('id', $data['id'])->first();
@@ -6291,58 +6377,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]);
-              }
-          }else{
-              $query =  Company::where('company.status', 1);
-          }
+  {
+    // 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]);
         }
-        $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);
+      } else {
+        $query =  Company::where('company.status', 1);
       }
-        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',
+        '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);
   }
   /**
    * 添加企业
@@ -6571,9 +6657,9 @@ class NewsService implements NewsServiceInterface
   {
     $result = Company::where('id', $data['id'])->first();
     $city_arr = json_decode($result['city_arr_id']);
-     $result['city_name'] = District::whereIn('id', $city_arr)
-        ->pluck('name')
-        ->implode('-');
+    $result['city_name'] = District::whereIn('id', $city_arr)
+      ->pluck('name')
+      ->implode('-');
 
     if (empty($result)) {
       return Result::error('企业不存在!');