Browse Source

修改b端获取招工招聘详情的接口;建立获取职场机会列表页的接口;

15313670163 1 day ago
parent
commit
7ed7ecc145
3 changed files with 85 additions and 16 deletions
  1. 58 11
      app/JsonRpc/NewsService.php
  2. 0 5
      app/JsonRpc/NewsServiceInterface.php
  3. 27 0
      app/Model/JobApply.php

+ 58 - 11
app/JsonRpc/NewsService.php

@@ -30,7 +30,7 @@ use Ramsey\Uuid\Uuid;
 use Hyperf\Utils\Random;
 
 use function Hyperf\Support\retry;
-
+use App\Model\JobApply;
 #[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class NewsService implements NewsServiceInterface
 {
@@ -1247,6 +1247,15 @@ class NewsService implements NewsServiceInterface
                 'job_company.email'
             )
             ->first();
+        $cityId = json_decode($result['city_arr_id'], true) ?? [];
+        if(!empty($cityId)){
+            if(isset($cityId[1]) && $cityId[1] != null){
+                $city = District::where('id', $cityId[1])->first(['name']);
+            }else{
+                $city = District::where('id', $cityId[0])->first(['name']);
+            }
+            $result['city'] = $city['name'] ?? '';
+        }
         if(empty($result)){
             return Result::error("招聘信息不存在", 0);
         }
@@ -1466,7 +1475,7 @@ class NewsService implements NewsServiceInterface
     * */
     public function getJobRecruitingArea(array $data): array
     {
-        if(isset($data['province_id']) && $data['province_id']!=null){
+        if(isset($data['pid']) && $data['pid']!=null){
             $result = District::where('pid',$data['pid'])->get()->all();
         }else{
             $result = District::where('level',1)->get()->all();
@@ -1626,15 +1635,53 @@ class NewsService implements NewsServiceInterface
     * */
     public function getRecruitingList(array $data): array
     {
-        // $user = User::where('id', $data['user_id'])->first();
-        // if(empty($user)){
-        //     return Result::error("用户不存在", 0);
-        // }
-        // $web = Website::where('id', $data['website_id'])->first();
-        // if(empty($web)){
-        //     return Result::error("网站不存在", 0);
-        // }
-
+        $user = User::where('id', $data['user_id'])->first();
+        if(empty($user) || ($user['type_id']!= 10000 && $user['type_id']!= 1)){
+            return Result::error("用户不存在", 0);
+        }
+        $recruitingId = JobApply::where('user_id', $data['user_id'])
+        ->pluck('recruit_id');
+        $where = [];
+        if(isset($data['salary']) && $data['salary']!=null){
+            $where['job_recruiting.salary'] = $data['salary'];
+        }
+        if(isset($data['experience']) && $data['experience']!=null){
+            $where['job_recruiting.experience'] = $data['experience'];   
+        }
+        if(isset($data['business_name']) && $data['business_name']!=null){
+            array_push($where, ['job_company.business_name', 'like', '%' . $data['business_name'] . '%']);
+        }
+        $query = JobRecruiting::whereIn('job_recruiting.id', $recruitingId)
+            ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
+            ->where($where);
+            // ->count();
+        $count = $query->count();
+        $query = clone $query;
+        $job = $query
+            ->leftJoin('job_enum as income_enum', function ($join) {
+                $join->on('job_recruiting.salary', '=', 'income_enum.evalue')
+                    ->where('income_enum.egroup', 'income');
+            })
+            ->leftJoin('job_enum as years_enum', function ($join) {
+                $join->on('job_recruiting.experience', '=', 'years_enum.evalue')
+                    ->where('years_enum.egroup', 'years');
+            })
+            // ->where($where)
+            ->orderBy('job_recruiting.updated_at', 'desc')
+            ->select('job_recruiting.id','job_recruiting.title', 'job_company.business_name', 'income_enum.evalue as salary_evalue', 'income_enum.ename as salary_ename', 'years_enum.evalue as experience_evalue', 'years_enum.ename as experience_ename')
+            ->offset(($data['page'] - 1) * $data['pageSize'])
+            ->limit($data['pageSize'])
+            ->get()
+            ->all();
+       
+        if (empty($job)) {
+            return Result::error("暂无招聘信息", 0);
+        }
+        $result = [
+            'row' => $job,
+            'count' => $count,
+        ];
+        return Result::success($result);
     }
     // 20250306 招聘
 }

+ 0 - 5
app/JsonRpc/NewsServiceInterface.php

@@ -240,9 +240,4 @@ interface NewsServiceInterface
      * @return array
      */
     public function getRecruitingList(array $data):array;
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function getRecruitingInfo(array $data):array;
 }

+ 27 - 0
app/Model/JobApply.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class JobApply extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'job_apply';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}