瀏覽代碼

招工招聘-b端

15313670163 6 天之前
父節點
當前提交
97835d759e
共有 3 個文件被更改,包括 100 次插入6 次删除
  1. 68 6
      app/JsonRpc/NewsService.php
  2. 5 0
      app/JsonRpc/NewsServiceInterface.php
  3. 27 0
      app/Model/JobApply.php

+ 68 - 6
app/JsonRpc/NewsService.php

@@ -48,7 +48,7 @@ use Hamcrest\Arrays\IsArray;
 use Hyperf\Codec\Json;
 
 use App\Tools\buildMenuTree;
-
+use App\Model\JobApply;
 #[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class NewsService implements NewsServiceInterface
 {
@@ -3134,7 +3134,16 @@ class NewsService implements NewsServiceInterface
                 'job_company.email'
             )
             ->first();
-        if (empty($result)) {
+        $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);
         }
         // return Result::success($job);
@@ -3352,10 +3361,10 @@ class NewsService implements NewsServiceInterface
     * */
     public function getJobRecruitingArea(array $data): array
     {
-        if (isset($data['province_id']) && $data['province_id'] != null) {
-            $result = District::where('pid', $data['pid'])->get()->all();
-        } else {
-            $result = District::where('level', 1)->get()->all();
+        if(isset($data['pid']) && $data['pid']!=null){
+            $result = District::where('pid',$data['pid'])->get()->all();
+        }else{
+            $result = District::where('level',1)->get()->all();
         }
         if (empty($result)) {
             return Result::error("暂无此省市", 0);
@@ -3507,6 +3516,59 @@ class NewsService implements NewsServiceInterface
         }
         return Result::success($result);
     }
+    /*
+    * 获取招聘信息列表
+    * */
+    public function getRecruitingList(array $data): array
+    {
+        $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 招聘
     //20250422  书刊音像
     public function addBook(array $data): array

+ 5 - 0
app/JsonRpc/NewsServiceInterface.php

@@ -304,4 +304,9 @@ interface NewsServiceInterface
      * @return array
      */
     public function getWebsiteshop(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getRecruitingList(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 = [];
+}