Browse Source

Merge branch 'master' of http://git.bjzxtw.org.cn:3000/zxt/news_producer

LiuJ 14 giờ trước cách đây
mục cha
commit
23d3f31fcb
2 tập tin đã thay đổi với 358 bổ sung129 xóa
  1. 343 129
      app/JsonRpc/NewsService.php
  2. 15 0
      app/JsonRpc/NewsServiceInterface.php

+ 343 - 129
app/JsonRpc/NewsService.php

@@ -64,8 +64,7 @@ use Illuminate\Support\Facades\Cache;
 
 use App\Model\Company;
 use Hyperf\Paginator\Paginator;
-use App\Model\Project;
-
+use App\Model\Project;    
 #[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class NewsService implements NewsServiceInterface
 {
@@ -3366,20 +3365,25 @@ class NewsService implements NewsServiceInterface
           }
           break;
         case 6:
-          // 招工招聘
-          // `status` int DEFAULT '1' COMMENT '审核状态,1待审核2已审核3已拒绝',
-          $article = JobRecruiting::where('website_id', $data['website_id'])
+          // 企业
+          // `status` int DEFAULT '1' COMMENT '审核状态状态:0:未审核;1:已审核;2:已拒绝;',
+          $article = Company::where('website_id', $data['website_id'])
             ->where('status', 1)
             ->where('id', $data['id'])
             ->first(['cat_arr_id']);
           if (empty($article)) {
-            $article = JobHunting::where('website_id', $data['website_id'])
-              ->where('status', 2)
-              ->where('id', $data['id'])
-              ->first(['cat_arr_id']);
+            return Result::error("该企业不存在", 0);
           }
+          break;
+        case 7:
+          // 项目
+          // `status` int DEFAULT '1' COMMENT '审核状态状态:0:未审核;1:已审核;2:已拒绝;',
+          $article = Project::where('website_id', $data['website_id'])
+            ->where('status', 1)
+            ->where('id', $data['id'])
+            ->first(['cat_arr_id']);
           if (empty($article)) {
-            return Result::error("该招工招聘不存在", 0);
+            return Result::error("该项目不存在", 0);
           }
           break;
         default:
@@ -5690,86 +5694,46 @@ 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_name']) && !empty($data['website_name'])) {
-      array_push($where, ['website.website_name', 'like', '%' . $data['website_name'] . '%']);
-    }
-    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('用户不存在!');
         }
-        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) {
-            $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);
-        }
-      }
-      $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');
+            $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',
@@ -5777,12 +5741,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);
+        return Result::success($result);
     }
-  }
   /**
    * 添加企业
    * @param array $data
@@ -5954,45 +5917,104 @@ class NewsService implements NewsServiceInterface
     }
   }
   /**
-   * @param array $data
-   * @return array
-   */
-  public function getWebsiteCompany(array $data): array
-  {
-    $where['website_id'] = $data['website_id'];
-    $where['status'] = 1;
-    if (isset($data['category_id']) && !empty($data['category_id'])) {
-      $where['category_id'] = $data['category_id'];
-    }
-    if (isset($data['level']) && !empty($data['level'])) {
-      $where['level'] = $data['level'];
-    }
-    // return Result::success($where);
-    $query = Company::where($where);
-    $result['img'] = $this->processArticle(
-      $query->clone()
-        ->where('imgurl', '!=', '')
-        ->whereNotNull('imgurl')
-        ->select('id', 'imgurl', 'title', 'introduce', 'description', 'content', 'category_id', 'cat_arr_id')
-        ->orderBy('updated_at', 'desc')
-        ->limit($data['imgnum'])
-        ->get(),
-      $data
-    );
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteCompany(array $data): array
+    {
+        $categorys = json_decode($data['id'], true);
+        $category_arr = $this->processArticlePro($data['website_id']);
+        $cat_1st_arr = $category_arr['cat_1st_arr'];
+        $catiall = $category_arr['catiall'];
+        foreach($categorys as $key => $value){
+            if(array_key_exists('level',$value)){
+                $parts = explode(',', $value['level']);
+                $level = $parts[0] ?? null;
+                $imgnum = $parts[1] ?? null;
+                $textnum = $parts[2] ?? null;
+                if(!empty($textnum) && $textnum > 0){
+                    $text_num = Company::where('level', $level)
+                    ->where('website_id',$data['website_id'])
+                    ->where('status',1)
+                    ->select('company.id','company.title','company.description','company.updated_at',
+                    'company.category_id','company.cat_arr_id')
+                    ->orderBy('updated_at', 'desc')
+                    ->limit($textnum)
+                    ->get()->all();
+                }
+                if(!empty($imgnum) && $imgnum > 0){
+                    $img_num = Company::where('level', $level)
+                    ->where('website_id',$data['website_id'])
+                    ->where('status',1)
+                    ->where('imgurl','!=', '')
+                    ->whereNotNull('imgurl')
+                    ->select('company.id','company.title','company.description','company.updated_at',
+                    'company.imgurl as imgs','company.category_id','company.cat_arr_id')
+                    ->orderBy('updated_at', 'desc')
+                    ->limit($imgnum)
+                    ->get()->all();
+                }
+                
+            }
+            if(array_key_exists('id',$value)){
+                $parts = explode(',', $value['id']);
+                $category_id = $parts[0] ?? null;
+                $imgnum = $parts[1] ?? null;
+                $textnum = $parts[2] ?? null;
+                $category_arr = array_merge([$category_id], $cat_1st_arr[$category_id] ?? [0]);
+                if(!empty($textnum) && $textnum > 0){
+                    $text_num = Company::whereIn('category_id', $category_arr)
+                    ->where('website_id',$data['website_id'])
+                    ->where('status',1)
+                    ->select('company.id','company.title','company.description','company.updated_at',
+                    'company.category_id','company.cat_arr_id')
+                    ->orderBy('updated_at', 'desc')
+                    ->limit($textnum)
+                    ->get()->all();
+                }
+                if(!empty($imgnum) && $imgnum > 0){
+
+                    $img_num = Company::whereIn('category_id', $category_arr)
+                    ->where('website_id',$data['website_id'])
+                    ->where('status',1)
+                    ->where('imgurl','!=', '')
+                    ->whereNotNull('imgurl')
+                    ->select('company.id','company.title','company.description','company.updated_at',
+                    'company.imgurl as imgs','company.category_id','company.cat_arr_id')
+                    ->orderBy('updated_at', 'desc')
+                    ->limit($imgnum)
+                    ->get()->all();
+                }
+                
+                
+            }
+            if(!empty($text_num)){
+                foreach ($text_num as $k => $v) {
+                    $text_num[$k]->category_name = $catiall[$v->category_id]['alias'];
+                    $text_num[$k]->pinyin = $catiall[$v->category_id]['pinyin'];
+                }
+            }
+            if(!empty($img_num)){
+                foreach ($img_num as $k => $v) {
+                    $img_num[$k]->category_name = $catiall[$v->category_id]['alias'];
+                    $imgurl = json_decode($v['imgs'], true);
+                    if(!empty($imgurl)){
+                        $img_num[$k]->imgurl = $imgurl[0];
+                    }
+                    $img_num[$k]->pinyin = $catiall[$v->category_id]['pinyin'];
+
+                }
+            }
+                $company[$key]['img_num'] = $img_num ?? [];
+                $company[$key]['text_num'] = $text_num ?? [];
+        }
+        
+        if(empty($company)){
+            return Result::error("暂无相关企业信息", 0);
+        }
 
-    $result['text'] =  $this->processArticle(
-      $query->clone()
-        ->select('id', 'title', 'introduce', 'description', 'content', 'category_id', 'cat_arr_id')
-        ->orderBy('updated_at', 'desc')
-        ->limit($data['textnum'])
-        ->get(),
-      $data
-    );
-    if (empty($result)) {
-      return Result::error("暂无相关公司信息", 0);
+        return Result::success($company);
     }
-    return Result::success($result);
-  }
   /**
    * @param array $data
    * @return array
@@ -6009,7 +6031,7 @@ class NewsService implements NewsServiceInterface
     }
     $query = Company::where($where);
     $company = $this->processArticle(
-      $query->select('id', 'title', 'introduce', 'description', 'content', 'category_id', 'cat_arr_id')
+      $query->select('id', 'title', 'introduce', 'description', 'content', 'category_id', 'cat_arr_id','updated_at')
         ->orderBy('updated_at', 'desc')
         ->offset(($data['page'] - 1) * $data['pageSize'])
         ->limit($data['pageSize'])
@@ -6234,16 +6256,49 @@ class NewsService implements NewsServiceInterface
 
   public function getWebsiteCompanyInfo(array $data): array
   {
-    $company = Company::where('id', $data['id'])
-      ->where('status', 1)
-      ->where('website_id', $data['website_id'])
-      ->select('company.*')
-      ->first();
-    if (empty($company)) {
-      return Result::error("暂无相关公司信息", 0);
+        $company = Company::where('id', $data['id'])
+            ->leftJoin('job_industry','job_industry.hyid','company.hy_id')
+            ->where('status', 1)
+            ->where('website_id', $data['website_id'])
+            ->select('company.*','job_industry.hyname as hy_name')
+            ->first();
+        // 企业性质:0:市场监管;1:信访纪检;2:公检法司;3:高关注机构
+
+        switch($company->jobnature_id){
+            case null:
+                $company->jobnature_name = '';
+                break;
+            case 0:
+                $company->jobnature_name = '市场监督';
+                break;
+            case 1:
+                $company->jobnature_name = '信访纪检';
+                break;
+            case 2:
+                $company->jobnature_name = '公检法司';
+                break;
+            case 3:
+                $company->jobnature_name = '高关注机构';
+                break;
+            default:
+                $company->jobnature_name = '';
+                break;
+        }
+        $city_arr = $company->city_arr_id;
+        if(!empty($city_arr)){
+            $city_arr = json_decode($city_arr, true);
+            $cityNames = District::whereIn('id', $city_arr)
+            ->pluck('name')
+            ->implode('-');
+            $company->city_name = $cityNames;
+        }else{
+            $company->city_name = '';
+        }
+        if(empty($company)){
+            return Result::error("暂无相关公司信息", 0);
+        }
+        return Result::success($company);
     }
-    return Result::success($company);
-  }
   public function getMSG(array $data): array
   {
     $type_id = isset($data['type_id']) ? $data['type_id'] : 1;
@@ -6509,4 +6564,163 @@ class NewsService implements NewsServiceInterface
     var_dump($type_id, '-----------------test---------');
     return Result::success($result);
   }
+  /**
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteProject(array $data): array
+    {
+        $categorys = json_decode($data['id'], true);
+        if(!empty($categorys)){
+            $category_arr = $this->processArticlePro($data['website_id']);
+            $cat_1st_arr = $category_arr['cat_1st_arr'];
+            $catiall = $category_arr['catiall'];
+            // return Result::success($catiall);
+            foreach($categorys as $key => $val){
+                if(isset($val['level'][0]) && !empty($val['level'][0])){
+                    $level = $val['level'][0];
+                    $imgnum = $val['level'][1] ?? null;
+                    $textnum = $val['level'][2] ?? null;
+                    if(!empty($textnum) && $textnum > 0){
+                        $text_num = Project::where('level', $level)
+                        ->where('website_id',$data['website_id'])
+                        ->where('status',1)
+                        ->select('project.id','project.title','project.description','project.updated_at',
+                        'project.category_id','project.cat_arr_id')
+                        ->orderBy('updated_at', 'desc')
+                        ->limit($textnum)
+                        ->get()->all();
+                    }
+                    if(!empty($imgnum) && $imgnum > 0){
+                        $img_num = Project::where('level', $level)
+                        ->where('website_id',$data['website_id'])
+                        ->where('status',1)
+                        ->where('imgurl','!=', '')
+                        ->whereNotNull('imgurl')
+                        ->select('project.id','project.title','project.description','project.updated_at',
+                        'project.imgurl as imgs','project.category_id','project.cat_arr_id')
+                        ->orderBy('updated_at', 'desc')
+                        ->limit($imgnum)
+                        ->get()->all();
+                    }
+                }
+                if(isset($val['id'][0]) && !empty($val['id'][0])){
+                    $category_ids = explode(',', $val['id'])[0];
+                    $cat_imgnum = explode(',', $val['id'])[1] ?? null;
+                    $cat_textnum = explode(',', $val['id'])[2] ?? null;
+                    $category_arr = array_merge([$category_ids], $cat_1st_arr[$category_ids] ?? [0]);
+                    if(!empty($cat_textnum) && $cat_textnum > 0){
+                        $text_num = Project::whereIn('category_id', $category_arr)
+                        ->where('website_id',$data['website_id'])
+                        ->where('status',1)
+                        ->select('project.id','project.title','project.description','project.updated_at',
+                        'project.category_id','project.cat_arr_id')
+                        ->orderBy('updated_at', 'desc')
+                        ->limit($cat_textnum)
+                        ->get()->all();
+                    }
+                    if(!empty($cat_imgnum) && $cat_imgnum > 0){
+                        $img_num = Project::whereIn('category_id', $category_arr)
+                        ->where('website_id',$data['website_id'])
+                        ->where('status',1)
+                        ->where('imgurl','!=', '')
+                        ->whereNotNull('imgurl')
+                        ->select('project.id','project.title','project.description','project.updated_at',
+                        'project.imgurl as imgs','project.category_id','project.cat_arr_id')
+                        ->orderBy('updated_at', 'desc')
+                        ->limit($cat_imgnum)
+                        ->get()->all();
+                    }
+                }
+                if(!empty($img_num)){
+                    foreach ($img_num as $k => $v) {
+                        $img_num[$k]->category_name = $catiall[$v->category_id]['alias'];
+                        $imgurl = json_decode($v['imgs'], true);
+                        if(!empty($imgurl)){
+                            $img_num[$k]->imgurl = $imgurl[0];
+                        }
+                        $img_num[$k]->pinyin = $catiall[$v->category_id]['pinyin'];
+
+                    }
+                }
+                if(!empty($text_num)){
+                    foreach ($text_num as $k => $v) {
+                        $text_num[$k]->category_name = $catiall[$v->category_id]['alias'];
+                        $text_num[$k]->pinyin = $catiall[$v->category_id]['pinyin'];
+                    }
+                }
+                $project[$key]['img_num'] = $img_num ?? [];
+                $project[$key]['text_num'] = $text_num ?? [];
+            }
+        }
+        if(empty($project)){
+            return Result::error("暂无相关项目信息", 0);
+        }
+        return Result::success($project);
+    }
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteProjectInfo(array $data): array
+    {
+        $project = Project::where('id', $data['id'])
+            ->where('status', 1)
+            ->where('website_id', $data['website_id'])
+            ->select('project.*')
+            ->first();
+        if(empty($project)){
+            return Result::error("暂无相关项目信息", 0);
+        }
+        return Result::success($project);
+    }
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteProjectList(array $data): array
+    {
+        $where = [];
+        if(isset($data['category_id']) && !empty($data['category_id'])){
+            $where['category_id'] = $data['category_id'];
+        }
+        if(isset($data['keyword']) && !empty($data['keyword'])){
+            $where[] = ['title','like', '%' . $data['keyword'] . '%'];
+        }
+        $query = Project::where($where)
+            ->where('status', 1)
+            ->where('website_id', $data['website_id'])
+            ->select('project.id','project.title','project.introduce','project.imgurl as imgs',
+            'project.category_id','project.cat_arr_id')
+            ->orderBy('updated_at', 'desc');
+        $count = $query->count();
+        $project = $query->clone() 
+            ->offset(($data['page'] - 1) * $data['pageSize'])
+            ->limit($data['pageSize'])
+            ->get()->all();
+        if(empty($project)){
+            return Result::error("暂无相关项目信息", 0);
+        }
+        $categorys = $this->processArticlePro($data['website_id']);
+        $catiall = $categorys['catiall'];
+        foreach($project as $key => $val){
+            $project[$key]->category_name = $catiall[$val->category_id]['alias'];
+            if(!empty($val['imgs'])){
+                $imgurl = json_decode($val['imgs'], true);
+                 if(!empty($imgurl)){
+                    $project[$key]->imgurl = $imgurl[0];
+                }
+            }else{
+                $project[$key]->imgurl = '';
+            }
+           
+            $project[$key]->pinyin = $catiall[$val->category_id]['pinyin'];
+        }
+        $result = [
+            'rows' => $project,
+            'count' => $count,
+        ];
+        return Result::success($result);
+    }
+
 }

+ 15 - 0
app/JsonRpc/NewsServiceInterface.php

@@ -432,4 +432,19 @@ interface NewsServiceInterface
     public function delProject(array $data): array;
     public function checkProject(array $data): array;
     public function getProjectInfo(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteProject(array $data):array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteProjectInfo(array $data):array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteProjectList(array $data):array;
 }