Browse Source

修改招工招聘中封装处理由问题、c端-获取招工招聘、 c端-获取招工招聘列表、c端-获取招工招聘详情的接口;完成c端-申请职位、c端-招工招聘-沟通简历的接口;

15313670163 2 days ago
parent
commit
cb45f8a354
1 changed files with 37 additions and 32 deletions
  1. 37 32
      app/JsonRpc/NewsService.php

+ 37 - 32
app/JsonRpc/NewsService.php

@@ -1677,23 +1677,23 @@ class NewsService implements NewsServiceInterface
     // 封装处理由问题
     function processJob($job, $data) {
         return $job->map(function ($job) use ($data) {
-
             $category = $job->cat_arr_id?? '';
             $cityid = $job->city_arr_id?? '';
             $city = json_decode($cityid, true);
             $pinyin = '';
             $level = json_decode($category, true);
             // 路由
-            if(!empty($level)){
+            if(!empty($level) && is_array($level)){
                 $pinyin = WebsiteCategory::whereIn('category_id', $level)
-                ->where('website_id', $data['website_id']) // 添加网站ID条件 her
+                ->where('website_id', $data['website_id']) // 添加网站ID条件 
                 ->orderByRaw('FIELD(category_id, '. implode(',', $level). ')')
                 ->get(['aLIas_pinyin'])
                 ->pluck('aLIas_pinyin')
                 ->implode('/');
                 if(empty($pinyin)){
-                    $pinyin = $category->aLIas_pinyin?? '';
+                    $pinyin = $pinyin->aLIas_pinyin?? '';
                 }
+                $job->pinyin = $pinyin;
             }
             // 取城市-市??省
             if(!empty($city) && is_array($city)){
@@ -1762,12 +1762,7 @@ class NewsService implements NewsServiceInterface
             }
             // 薪资
             if(isset($job->salary) &&!empty($job->salary)){
-                if(isset($job->type) &&!empty($job->type) && $job->type == 1){
-                    $where['evalue'] = $job->salary;
-                }else{
-                    $where['id'] = $job->salary;
-                }
-                $salary = JobEnum::where('egroup','income')->where($where)->first(['ename']);
+                $salary = JobEnum::where('egroup','income')->where('evalue',$job->salary)->first(['ename']);
                 $job->salary_name = $salary->ename?? '';
             }
             // 职位性质
@@ -1785,7 +1780,7 @@ class NewsService implements NewsServiceInterface
                 $company_nature = JobNature::where('id',$job->company_nature)->first(['nature_name']);
                 $job->company_nature_name = $company_nature->nature_name?? '';
             }
-            $job->pinyin = $pinyin;
+            // $job->pinyin = $pinyin;
             return $job;
         });
     }
@@ -2107,18 +2102,18 @@ class NewsService implements NewsServiceInterface
      *  */
     function processArticle($article, $data) {
         $article['img'] = Article::where('article.status', 1)
-                    ->whereIn('article.id', $$article[0])
-                    ->where(function ($query) use ($data) {
-                        $query->where(function ($subQuery) use ($data) {
-                            $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0");
-                        })->orWhereNull("ignore_ids");
-                    })
-                    ->select(
-                        'article.id',
-                        'article.title',
-                        'article.imgurl',
-                        'article.author',
-                    );
+            ->whereIn('article.id', $$article[0])
+            ->where(function ($query) use ($data) {
+                $query->where(function ($subQuery) use ($data) {
+                    $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0");
+                })->orWhereNull("ignore_ids");
+            })
+            ->select(
+                'article.id',
+                'article.title',
+                'article.imgurl',
+                'article.author',
+            );
          return $article->map(function ($article) use ($data) {
             $catid = $article->cat_arr_id?? '';
             $level = json_decode($catid, true);
@@ -2155,9 +2150,8 @@ class NewsService implements NewsServiceInterface
                     $q->WhereRaw("JSON_CONTAINS(job_hunting.city_arr_id, '". intval($data['city_id']). "') = 1");
                 });
             })
-            ->select('job_hunting.id','job_hunting.cat_arr_id','job_hunting.name','job_hunting.job',
-            'job_hunting.job_name','job_hunting.industry','job_hunting.city_arr_id','job_hunting.experience',
-            'job_hunting.updated_at')
+            ->select('job_hunting.id','job_hunting.cat_arr_id','job_hunting.job','job_hunting.industry',
+            'job_hunting.city_arr_id','job_hunting.experience','job_hunting.updated_at')
             ->orderBy('updated_at', 'desc')
             ->limit($data['job1_num'])
             ->get();
@@ -2242,8 +2236,8 @@ class NewsService implements NewsServiceInterface
         $recruit_count = $query->count();
         $query = clone $query;
         $JobRecruiting = $query
-            ->limit($data['pageSize'])
             ->offset(($data['page']-1)*$data['pageSize'])
+            ->limit($data['pageSize'])
             ->get();
         if(empty($JobRecruiting)){
             $JobRecruiting = "暂无相关职位信息";
@@ -2308,7 +2302,14 @@ class NewsService implements NewsServiceInterface
             if(!empty($company)){
                 $result['company'] = $this->processJob($company, $webid);
             }
-            $other_job = $query->where('id','!=',$data['id'])->where('user_id', '=', $job[0]['user_id'])->get();
+
+            $other_job =JobRecruiting::where('status', 1)
+                ->where('website_id', $data['website_id'])
+                ->select('title','id','updated_at','cat_arr_id','user_id')
+                ->where('id','!=',$data['id'])
+                ->where('user_id', '=', $job[0]['user_id'])
+                ->limit($data['pageSize'])
+                ->get();
             if(!empty($other_job)){
                 $result['other_job'] = $this->processJob($other_job, $webid);
             }
@@ -2319,12 +2320,16 @@ class NewsService implements NewsServiceInterface
                 ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id')
                 ->select('job_hunting.*','user_name')
                 ->get();
+            $resume = JobRemuse::where('hunt_id',$data['id'])->get();
+            if(!empty($resume->toArray())){
+                $result['resume'] = 1;
+            } else{
+                $result['resume'] = 0;
+            }
         }
-        if(empty($job)){
+        if(empty($job->toArray())){
             return Result::error("id参数错误", 0);
         }
-
-        $job[0]['type'] = $data['type'];
         $result['job'] = $this->processJob($job, $webid);
         // 返现对应的栏目
         $catid = json_decode($job[0]['cat_arr_id'],true) ?? '';
@@ -2336,7 +2341,7 @@ class NewsService implements NewsServiceInterface
                 $result['category'] = $category;
             }
         if(empty($result)){
-            return Result::error("id参数错误", 0);
+            return Result::error("参数错误", 0);
         }
         return Result::success($result);
     }