Browse Source

Merge remote-tracking branch 'origin/master'

zmw 6 months ago
parent
commit
7eed7fa941
1 changed files with 23 additions and 15 deletions
  1. 23 15
      app/Http/Controllers/Api/Soldier/JobController.php

+ 23 - 15
app/Http/Controllers/Api/Soldier/JobController.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api\Soldier;
 use App\Http\Controllers\Api\ApiBaseController;
 use App\Http\Controllers\Api\ApiBaseController;
 use App\Models\Category;
 use App\Models\Category;
 use App\Models\CategoryJobs;
 use App\Models\CategoryJobs;
+use App\Models\Company;
 use App\Models\Jobs;
 use App\Models\Jobs;
 use App\Models\JobsContact;
 use App\Models\JobsContact;
 use Illuminate\Http\Request;
 use Illuminate\Http\Request;
@@ -29,7 +30,7 @@ class JobController extends ApiBaseController
             $where[] = ['updated_at', '>', $update_at];
             $where[] = ['updated_at', '>', $update_at];
         }
         }
 
 
-        $list = Jobs::select('id', 'jobs_name', 'company_name', 'nature', 'sex', 'age', 'amount', 'topclass', 'category', 'subclass', 'trade', 'scale', 'tag', 'education', 'experience', 'wage', 'wage_max', 'negotiable', 'wage_min', 'wage_str', 'jobs_content', 'department', 'created_at', 'updated_at')
+        $list = Jobs::select('id', 'company_id', 'jobs_name', 'company_name', 'nature', 'sex', 'age', 'amount', 'topclass', 'category', 'subclass', 'trade', 'scale', 'tag', 'education', 'experience', 'wage', 'wage_max', 'negotiable', 'wage_min', 'wage_str', 'jobs_content', 'department', 'created_at', 'updated_at')
             ->where($where)
             ->where($where)
             ->offset(($page - 1) * $limit)
             ->offset(($page - 1) * $limit)
             ->limit($limit)
             ->limit($limit)
@@ -40,6 +41,7 @@ class JobController extends ApiBaseController
         $category     = [];
         $category     = [];
         $category_job = [];
         $category_job = [];
         $tag          = [];
         $tag          = [];
+        $company_ids  = [];
         foreach ($list as $v) {
         foreach ($list as $v) {
             $ids[]          = $v['id'];
             $ids[]          = $v['id'];
             $category[]     = $v['nature'];
             $category[]     = $v['nature'];
@@ -51,27 +53,34 @@ class JobController extends ApiBaseController
             if (!empty($v['tag'][0])) {
             if (!empty($v['tag'][0])) {
                 $tag = array_merge($tag, $v['tag']);
                 $tag = array_merge($tag, $v['tag']);
             }
             }
-            $category[] = $v['education'];
-            $category[] = $v['experience'];
+            $category[]    = $v['education'];
+            $category[]    = $v['experience'];
+            $company_ids[] = $v['company_id'];
         }
         }
 
 
         $category          = array_merge($category, $tag);
         $category          = array_merge($category, $tag);
         $contact_list      = JobsContact::select('job_id', 'contact', 'telephone', 'email', 'address')->whereIn('job_id', $ids)->get()->keyBy('job_id')->toArray();
         $contact_list      = JobsContact::select('job_id', 'contact', 'telephone', 'email', 'address')->whereIn('job_id', $ids)->get()->keyBy('job_id')->toArray();
         $category_list     = Category::whereIn('id', array_unique($category))->pluck('demand', 'id')->toArray();
         $category_list     = Category::whereIn('id', array_unique($category))->pluck('demand', 'id')->toArray();
         $category_job_list = CategoryJobs::whereIn('id', array_unique($category_job))->pluck('name', 'id')->toArray();
         $category_job_list = CategoryJobs::whereIn('id', array_unique($category_job))->pluck('name', 'id')->toArray();
+        $company_list      = Company::select('id', 'district_cn', 'address', 'map_x', 'map_y')->whereIn('id', $company_ids)->get()->keyBy('id')->toArray();
 
 
         foreach ($list as $k => $v) {
         foreach ($list as $k => $v) {
-            $list[$k]['contact_name']         = $contact_list[$v['id']]['contact'];
-            $list[$k]['contact_telephone']    = $contact_list[$v['id']]['telephone'];
-            $list[$k]['contact_email']        = $contact_list[$v['id']]['email'];
-            $list[$k]['contact_address']      = $contact_list[$v['id']]['address'];
-            $list[$k]['nature']               = empty($category_list[$v['nature']]) ? '' : $category_list[$v['nature']];
-            $list[$k]['topclass']             = empty($category_job_list[$v['topclass']]) ? '' : $category_job_list[$v['topclass']];
-            $list[$k]['category']             = empty($category_job_list[$v['category']]) ? '' : $category_job_list[$v['category']];
-            $list[$k]['subclass']             = empty($category_job_list[$v['subclass']]) ? '' : $category_job_list[$v['subclass']];
-            $list[$k]['trade']                = empty($category_list[$v['trade']]) ? '' : $category_list[$v['trade']];
-            $list[$k]['scale']                = empty($category_list[$v['scale']]) ? '' : $category_list[$v['scale']];
-            $tags                             = [];
+            $list[$k]['contact_name']      = $contact_list[$v['id']]['contact'];
+            $list[$k]['contact_telephone'] = $contact_list[$v['id']]['telephone'];
+            $list[$k]['contact_email']     = $contact_list[$v['id']]['email'];
+            $list[$k]['contact_address']   = $contact_list[$v['id']]['address'];
+            $list[$k]['nature']            = empty($category_list[$v['nature']]) ? '' : $category_list[$v['nature']];
+            $list[$k]['topclass']          = empty($category_job_list[$v['topclass']]) ? '' : $category_job_list[$v['topclass']];
+            $list[$k]['category']          = empty($category_job_list[$v['category']]) ? '' : $category_job_list[$v['category']];
+            $list[$k]['subclass']          = empty($category_job_list[$v['subclass']]) ? '' : $category_job_list[$v['subclass']];
+            $list[$k]['trade']             = empty($category_list[$v['trade']]) ? '' : $category_list[$v['trade']];
+            $list[$k]['scale']             = empty($category_list[$v['scale']]) ? '' : $category_list[$v['scale']];
+            $list[$k]['company_district']  = $company_list[$v['company_id']]['district_cn'];
+            $list[$k]['company_address']   = $company_list[$v['company_id']]['address'];
+            $list[$k]['company_map_x']     = $company_list[$v['company_id']]['map_x'];
+            $list[$k]['company_map_y']     = $company_list[$v['company_id']]['map_y'];
+
+            $tags = [];
             foreach ($v['tag'] as $tag) {
             foreach ($v['tag'] as $tag) {
                 if (!empty($category_list[$tag])) {
                 if (!empty($category_list[$tag])) {
                     $tags[] = $category_list[$tag];
                     $tags[] = $category_list[$tag];
@@ -80,7 +89,6 @@ class JobController extends ApiBaseController
             $list[$k]['tag']        = $tags;
             $list[$k]['tag']        = $tags;
             $list[$k]['education']  = empty($category_list[$v['education']]) ? '' : $category_list[$v['education']];
             $list[$k]['education']  = empty($category_list[$v['education']]) ? '' : $category_list[$v['education']];
             $list[$k]['experience'] = empty($category_list[$v['experience']]) ? '' : $category_list[$v['experience']];
             $list[$k]['experience'] = empty($category_list[$v['experience']]) ? '' : $category_list[$v['experience']];
-            $list[$k]['experience'] = empty($category_list[$v['experience']]) ? '' : $category_list[$v['experience']];
         }
         }
 
 
         return response()->json($list);
         return response()->json($list);