JobController.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?php
  2. namespace App\Http\Controllers\Web\Hardware\Aio;
  3. use App\Http\Controllers\Web\WebBaseController;
  4. use App\Services\Company\JobsService;
  5. use Illuminate\Http\Request;
  6. use App\Services\Common\CategoryService;
  7. use App\Services\Common\SearchService;
  8. use App\Services\Company\PersonalJobsApplyService;
  9. use App\Services\Person\ResumeService;
  10. class JobController extends WebBaseController
  11. {
  12. protected $categoryService;
  13. protected $jobsService;
  14. protected $searchService;
  15. protected $personalJobsApplyService;
  16. protected $resumeService;
  17. /**
  18. * JobController constructor.
  19. * @param $categoryService
  20. * @param $jobsService
  21. * @param $searchService
  22. * @param $personalJobsApplyService
  23. * @param $resumeService
  24. */
  25. public function __construct(CategoryService $categoryService, JobsService $jobsService, SearchService $searchService, PersonalJobsApplyService $personalJobsApplyService,ResumeService $resumeService)
  26. {
  27. $this->categoryService = $categoryService;
  28. $this->jobsService = $jobsService;
  29. $this->searchService = $searchService;
  30. $this->personalJobsApplyService = $personalJobsApplyService;
  31. $this->resumeService = $resumeService;
  32. }
  33. public function index(Request $request)
  34. {
  35. $params = array();
  36. $param_array = array('citycategory','wage','trade','education','key');
  37. if ($request->all()) {
  38. foreach ($request->all() as $k => $v) {
  39. if (in_array($k, $param_array) && $v) {
  40. $params[$k] = $v;
  41. }
  42. }
  43. }
  44. //职位类别信息
  45. $filter_where = array(
  46. 'AIX_wage' => 100, //薪资
  47. 'AIX_trade' => 100, //职位类别信息
  48. 'AIX_education' => 100 //学历要求
  49. );
  50. $categories = $this->categoryService->getCategories($filter_where); //过滤条件信息
  51. //所在地区(默认地区)
  52. $citycategory = $request->input('citycategory', '');
  53. $citys = $this->categoryService->getCitys($citycategory);
  54. //查询数据
  55. $where = $this->setWhere($params, $citys);
  56. $order_by = array('stime'=>'desc', 'refresh_time'=>'desc');
  57. $search_key = '';
  58. if ($params) {
  59. $search_key = array_has($params, 'key')?$params['key']:'';
  60. }
  61. $list = $this->searchService->search('Job', $where, $order_by, $search_key, 6);
  62. if ($list->total()>0) {
  63. $list_items = $this->jobsService->dealjobFilelds($list->items());
  64. } else {
  65. $list_items = array();
  66. }
  67. $return_data = array(
  68. 'categories' => $categories,
  69. 'params' => $params,
  70. 'arealist' => $citys,
  71. 'list' => $list,
  72. 'list_items' => $list_items,
  73. 'user' => $this->getUser()
  74. );
  75. return view('app.hardware.aio.jobs.index', $return_data);
  76. }
  77. public function jobDetail($id)
  78. {
  79. //获取职位详细信息
  80. $job_rst = $this->jobsService->getJobInfo(array('id'=>$id), $this->getUser());
  81. if ($job_rst['status'] == 0) {
  82. $back_url = \Illuminate\Support\Facades\URL::previous();
  83. return $this->showMessage($job_rst['error'], $back_url, true, '上一页', '3');
  84. }
  85. $job_info = $job_rst['job'];
  86. $return_data = array(
  87. 'info' => $job_info,
  88. 'user' => $this->getUser()
  89. );
  90. return view('app.hardware.aio.jobs.detail', $return_data);
  91. }
  92. public function getUser()
  93. {
  94. $user = array();
  95. if (auth('web-member')->check()) {
  96. $user = auth('web-member')->user();
  97. } elseif (auth('web-company')->check()) {
  98. $user = auth('web-company')->user();
  99. }
  100. return $user;
  101. }
  102. public function jobApply(Request $request)
  103. {
  104. //判断个人资料是否完善
  105. $jobs_id = $request->input('jobs_id');
  106. $resume_id = $request->input('resume_id');
  107. $user = $this->getUser();
  108. if (!$jobs_id) {
  109. $return_data = array(
  110. 'status' => 0,
  111. 'html' => '请选择要投递的职位!'
  112. );
  113. return response()->json($return_data);
  114. }
  115. if (!is_array($jobs_id)) {
  116. $jobs_id = explode(',', $jobs_id);
  117. }
  118. if ($resume_id) {
  119. $this->resumeService->isOwn($resume_id,$user);
  120. $apply_rst = $this->personalJobsApplyService->applyJobs($jobs_id, $resume_id, $this->getUser());
  121. if (array_get($apply_rst, 'status') == 0) {
  122. $return_data = array(
  123. 'status' => array_get($apply_rst, 'status'),
  124. 'html' => array_get($apply_rst, 'error')
  125. );
  126. return response()->json($return_data);
  127. } else {
  128. $html = '投递成功!';
  129. if (array_get($apply_rst, 'status') == 1 && count($jobs_id) ==1) {
  130. $html = $apply_rst['data']['list'][$jobs_id[0]]['tip'];
  131. }
  132. $return_data = array(
  133. 'status' => array_get($apply_rst, 'status'),
  134. 'html' => $html
  135. );
  136. return response()->json($return_data);
  137. }
  138. } else {
  139. //未选择投递简历前
  140. $rst = $this->personalJobsApplyService->ifJobApply($jobs_id, $this->getUser());
  141. //判断是否需要选择简历
  142. if (array_get($rst, 'status') == 2) {
  143. $page_data = array('status'=>array_get($rst, 'status'),'resumes'=>array_get($rst, 'resumes'),'def_resume'=>array_get($rst, 'def_resume'),'jobs_id'=>implode(',', $jobs_id));
  144. $html = view('app.hardware.aio.jobs.ajax_apply', $page_data)->render();
  145. $return_data = array( 'status'=>2, 'html' => $html);
  146. return response()->json($return_data);
  147. } else {
  148. $return_data = array();
  149. if (array_get($rst, 'status') == 0) {
  150. $return_data = array(
  151. 'status' => array_get($rst, 'status'),
  152. 'html' => array_get($rst, 'error')
  153. );
  154. return response()->json($return_data);
  155. } else {
  156. $html = '投递成功!';
  157. if (array_get($rst, 'status') == 1 && count($jobs_id) ==1) {
  158. $html = $rst['data']['list'][$jobs_id[0]]['tip'];
  159. }
  160. $return_data = array(
  161. 'status' => array_get($rst, 'status'),
  162. 'html' => $html
  163. );
  164. return response()->json($return_data);
  165. }
  166. }
  167. }
  168. }
  169. public function setWhere($params, $citys)
  170. {
  171. $where = array(
  172. array('valid','=',1),
  173. array('display','=',1)
  174. );
  175. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  176. $where[] = array('audit','=',1);
  177. } else {
  178. $where[] = array('audit','<>',3);
  179. }
  180. if ($params) {
  181. foreach ($params as $k => $v) {
  182. if ($k == 'citycategory') {
  183. //地标地段
  184. $where[] = array('district','=',$citys['select']['id']);
  185. } elseif ($k =='wage') {
  186. //获取薪资最大值和最小值
  187. $filter_where = array( 'AIX_wage'=> 100);
  188. $categories = $this->categoryService->getCategories($filter_where);
  189. if ($categories) {
  190. $wage = $categories['AIX_wage'][$params['wage']]['origin_demand'];
  191. if ($wage) {
  192. $wage = format_wage($wage);
  193. }
  194. $wage_arr = explode_wage($wage);
  195. $where[] = $wage_arr[0];
  196. $where[] = $wage_arr[1];
  197. }
  198. } elseif ($k !='sort' && $k !='key' && $k !='search_type' && $k !='m_zoom') {
  199. $where[] = array($k, '=', $v);
  200. }
  201. }
  202. }
  203. $where[] = ['subsite_ids','=', get_subsite_id()];
  204. return $where;
  205. }
  206. }