RecruitController.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. namespace App\Http\Controllers\Mobile\Active;
  3. use App\Http\Controllers\Mobile\MobileBaseController;
  4. use App\Services\Common\CategoryService;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Support\Facades\Cache;
  7. use Illuminate\Support\Facades\DB;
  8. class RecruitController extends MobileBaseController
  9. {
  10. protected $categoryService;
  11. public function __construct(CategoryService $categoryService)
  12. {
  13. $this->categoryService = $categoryService;
  14. }
  15. public function index(Request $request)
  16. {
  17. $offset = isset($request->page) ? $request->page : 0;
  18. $limit = 8;
  19. $citycategory = 'jjkfq';
  20. $trade = $request->input('trade', '');
  21. $param_array = ['citycategory', 'trade', 'nature'];
  22. $params = [];
  23. if ($request->all()) {
  24. foreach ($request->all() as $k => $v) {
  25. if (in_array($k, $param_array) && $v) {
  26. $params[$k] = $v;
  27. }
  28. }
  29. }
  30. $filter_where = [
  31. 'AIX_trade' => 100,
  32. 'AIX_company_type' => 100,
  33. ];
  34. $categories = $this->categoryService->getCategories($filter_where);
  35. $subsites = Cache::get('subsites_list');
  36. if ($subsites) {
  37. if (!array_has($params, 'citycategory')) {
  38. if (get_subsite_id() > 0) {
  39. $citycategory = $subsites[get_subsite_id()]['district'];
  40. }
  41. }
  42. }
  43. $title = '晋江市新春招聘会';
  44. $citys = $this->categoryService->getCitys($citycategory);
  45. if (empty($citycategory)) {
  46. $district_str = "(district like ? or district like ?)";
  47. $district_arr = ["%.623%", "%623.%"];
  48. } else {
  49. $select_id = $citys['select']['id'];
  50. $district_str = "(district like ? or district like ?)";
  51. $district_arr = ["%.{$select_id}%", "%{$select_id}.%"];
  52. $title = $citys['select']['name'] . '专区';
  53. }
  54. $whereRaw = "jobs.updated_at > '2022-06-01 00:00:00' and jobs.deleted_at is null and jobs.valid = 1 and jobs.audit = 1 and jobs.display = 1 and education > 68";
  55. $companys = DB::table('jobs')->join('companys', 'jobs.company_id', '=', 'companys.id')->whereRaw($whereRaw)->groupBy('jobs.company_id')->select('jobs.company_id')->pluck('company_id')->toArray();
  56. $where = [];
  57. $where[] = ['user_status', '=', 1];
  58. $where[] = ['audit', '=', 1];
  59. $where[] = ['deleted_at', '=', null];
  60. if (!empty($trade)) {
  61. $where[] = ['trade', '=', $trade];
  62. }
  63. $list = DB::table('companys')->where($where)->whereRaw($district_str, $district_arr)->whereIn('id', $companys)->orderBy('sort_index', 'desc')->orderBy('id', 'desc')->offset($limit * $offset)->limit($limit)->get();
  64. $more = count($list) >= $limit ? true : false;
  65. $res = [];
  66. foreach ($list as $val) {
  67. $item = [
  68. 'id' => $val->id,
  69. 'companyname' => $val->companyname,
  70. 'jobs' => [],
  71. 'tag_arr' => [],
  72. ];
  73. //在招职位
  74. $jobs_where = [
  75. ['company_id', '=', $val->id],
  76. ['valid', '=', 1],
  77. ['display', '=', 1],
  78. ['audit', '=', 1],
  79. ['deleted_at', '=', null],
  80. ['education', '>', 68],
  81. ];
  82. $jobs = DB::table('jobs')->where($jobs_where)->get();
  83. if (!$jobs->isEmpty()) {
  84. foreach ($jobs as $value) {
  85. $job = [
  86. 'id' => $value->id,
  87. 'jobs_name' => $value->jobs_name,
  88. 'amount' => $value->amount,
  89. 'wage' => $value->wage,
  90. 'wage_min' => $value->wage_min,
  91. 'wage_max' => $value->wage_max,
  92. ];
  93. array_push($item['jobs'], $job);
  94. }
  95. }
  96. //企业福利
  97. if (!empty($val->tag)) {
  98. $tags = explode(',', $val->tag);
  99. $tag_arr = DB::table('categorys')->whereIn('id', $tags)->limit(3)->get(['demand'])->toArray();
  100. $item['tag_arr'] = $tag_arr;
  101. }
  102. array_push($res, $item);
  103. }
  104. if ($request->ajax()) {
  105. if (count($res)) {
  106. return response()->json(['status' => 1, 'data' => view('mobile.app.active.ajax.ajax_recruit', [
  107. 'res' => $res,
  108. 'city' => $citys,
  109. 'params' => $params,
  110. 'categories' => $categories,
  111. 'more' => $more,
  112. ])->render()]);
  113. }
  114. return response()->json(['status' => 0]);
  115. }
  116. return view('mobile.app.active.recruit', [
  117. 'title' => $title,
  118. 'res' => $res,
  119. 'city' => $citys,
  120. 'params' => $params,
  121. 'categories' => $categories,
  122. 'more' => $more,
  123. 'share_title' => "【{$title}】免费找工作",
  124. 'share_desc' => '晋江好福利!免费找工作、找人才,还能抽奖,100%中奖,万份好礼免费拿!',
  125. 'share_image_url' => theme_asset('mobile/images/online2021/share_logo.jpg'),
  126. 'share_link' => route('mobile.active.spring_special') . '?citycategory=' . $citycategory,
  127. ]);
  128. }
  129. }