JobfairController.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wuzhenke
  5. * Date: 2019/1/17
  6. * Time: 16:19
  7. */
  8. namespace App\Http\Controllers\Mobile\Active;
  9. use App\Exceptions\ResponseException;
  10. use App\Http\Controllers\Mobile\MobileBaseController;
  11. use App\Services\Common\CategoryService;
  12. use App\Services\Common\SearchService;
  13. use App\Services\Company\JobsService;
  14. use Illuminate\Http\Request;
  15. use App\Services\Company\CompanyService;
  16. use Illuminate\Support\Facades\Cache;
  17. use Illuminate\Support\Facades\DB;
  18. class JobfairController extends MobileBaseController
  19. {
  20. protected $companyService;
  21. protected $jobsService;
  22. protected $categoryService;
  23. protected $searchService;
  24. /*
  25. * 企业中心
  26. * */
  27. /**
  28. * JobfairController constructor.
  29. * @param $jobfairJobsService
  30. * @param $jobfairCompanyRepository
  31. * @param $jobfairCompanyService
  32. * @param $jobfairService
  33. * @param $jobfairRepository
  34. * @param $jobfairPersonalJobsApplyRepository
  35. * @param $jobfairPersonalJopApplyService
  36. * @param $resumeService
  37. * @param $jobfairFloorplanStandRepository
  38. * @param $jobfairFloorPlanRepository
  39. * @param $jobfairPutJobRepository
  40. * @param $resumeRepository
  41. * @param $jobfairPutJobService
  42. * @param $companyService
  43. * @param $jobfairJobRepository
  44. * @param $companyDownResumeService
  45. * @param $articleService
  46. * @param $articleRepository
  47. */
  48. public function __construct(
  49. CompanyService $companyService,
  50. JobsService $jobsService,
  51. CategoryService $categoryService,
  52. SearchService $searchService
  53. )
  54. {
  55. $this->companyService = $companyService;
  56. $this->jobsService = $jobsService;
  57. $this->categoryService = $categoryService;
  58. $this->searchService = $searchService;
  59. }
  60. /**2020新春线上招聘会
  61. * @param Request $request
  62. * @param int $id
  63. * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\View\View
  64. * @throws \Throwable
  65. */
  66. public function online2020(Request $request)
  67. {
  68. $offset = isset($request->page)?$request->page:0;
  69. $limit = 20;
  70. $citycategory = $request->input('citycategory');
  71. $trade = $request->input('trade');
  72. $param_array = array('citycategory','trade','nature');
  73. $params= array();
  74. if ($request->all()) {
  75. foreach ($request->all() as $k => $v) {
  76. if (in_array($k, $param_array) && $v) {
  77. $params[$k] = $v;
  78. }
  79. }
  80. }
  81. $subsites = Cache::get('subsites_list');
  82. if ($subsites) {
  83. if (!array_has($params, 'citycategory')) {
  84. if (get_subsite_id() > 0) {
  85. $citycategory = $subsites[get_subsite_id()]['district'];
  86. }
  87. }
  88. $is_subsite = 1;
  89. }
  90. $citys = $this->categoryService->getCitys($citycategory);
  91. $companys = DB::table('jobs')->join('companys','jobs.company_id','=','companys.id')->whereRaw("jobs.created_at > '2020-01-01 00:00:00'")->groupBy('jobs.company_id')->select('jobs.company_id')->pluck('company_id')->toArray();
  92. // echo '<pre>';
  93. //
  94. // var_dump($companys);die;
  95. $where = array();
  96. $where[] = array('reg_time', '>', 1577808000);
  97. $where[] = array('user_status', '=', 1);
  98. $where[] = array('subsite_id', '=', get_subsite_id());
  99. $where[] = array('audit','=',1);
  100. $where[] = array('deleted_at','=',null);
  101. if(!empty($trade)){
  102. $where[] = array('trade','=',$trade);
  103. }
  104. //$where[] = array('id','in',$companys);
  105. $order_by = array('id','desc');
  106. //$list = $this->searchService->search('Company', $where, $order_by, '');
  107. //$list = DB::table('companys')->where($where)->whereRaw("(district like ? or district like ?)",["%.{$citys['select']['id']}%","%{$citys['select']['id']}.%"])->whereIn('id',$companys)->orderBy('id','desc')->offset($limit*$offset)->limit($limit)->get();
  108. $list = DB::table('companys')->where($where)->whereIn('id',$companys)->orderBy('id','desc')->offset($limit*$offset)->limit($limit)->get();
  109. // echo '<pre>';
  110. //
  111. // var_dump($list);die;
  112. $more = count($list) >= $limit ? true : false;
  113. // if ($list->total() >0) {
  114. // //处理企业信息
  115. // $list_items = $this->companyService->dealCompanyFields($list->items());
  116. // } else {
  117. // $list_items = array();
  118. // }
  119. $res = [];
  120. foreach ($list as $val) {
  121. $item = array(
  122. 'id' => $val->id,
  123. 'companyname' => $val->companyname,
  124. 'jobs' => []
  125. );
  126. //在招职位
  127. $jobs_where = array(
  128. array('company_id','=',$val->id),
  129. array('valid','=',1),
  130. array('display','=',1),
  131. array('audit','=',1)
  132. );
  133. //$jobs = $this->jobsService->getOtherJobs($jobs_where);
  134. $jobs = DB::table('jobs')->where($jobs_where)->get();
  135. if($jobs){
  136. foreach ($jobs as $value) {
  137. $job = array(
  138. 'id' => $value->id,
  139. 'jobs_name' => $value->jobs_name,
  140. 'amount' => $value->amount
  141. );
  142. array_push($item['jobs'],$job);
  143. }
  144. }
  145. array_push($res,$item);
  146. }
  147. $filter_where = array(
  148. 'AIX_trade' => 100,
  149. 'AIX_company_type' => 100
  150. );
  151. $categories = $this->categoryService->getCategories($filter_where);
  152. if ($request->ajax()) {
  153. if (count($res)) {
  154. return response()->json(['status'=>1,'data'=>view('app.active.ajax.ajax_jobfair_com', [
  155. 'res' => $res,
  156. 'city' => $citys,
  157. 'params' => $params,
  158. 'categories' => $categories,
  159. 'more' => $more
  160. ])->render()]);
  161. }
  162. return response()->json(['status'=>0]);
  163. }
  164. return view('app.active.online2020',[
  165. 'res' => $res,
  166. 'city' => $citys,
  167. 'params' => $params,
  168. 'categories' => $categories,
  169. 'more' => $more
  170. //'list_items' => $list_items,
  171. //'list' => $list,
  172. ]);
  173. }
  174. public function online2020m(Request $request){
  175. $offset = isset($request->page)?$request->page:0;
  176. $limit = 20;
  177. $citycategory = $request->input('citycategory');
  178. $trade = $request->input('trade');
  179. $param_array = array('citycategory','trade','nature');
  180. $params= array();
  181. if ($request->all()) {
  182. foreach ($request->all() as $k => $v) {
  183. if (in_array($k, $param_array) && $v) {
  184. $params[$k] = $v;
  185. }
  186. }
  187. }
  188. $filter_where = array(
  189. 'AIX_trade' => 100,
  190. 'AIX_company_type' => 100
  191. );
  192. $categories = $this->categoryService->getCategories($filter_where);
  193. $subsites = Cache::get('subsites_list');
  194. if ($subsites) {
  195. if (!array_has($params, 'citycategory')) {
  196. if (get_subsite_id() > 0) {
  197. $citycategory = $subsites[get_subsite_id()]['district'];
  198. }
  199. }
  200. $is_subsite = 1;
  201. }
  202. $citys = $this->categoryService->getCitys($citycategory);
  203. if(empty($citycategory)){
  204. $citys['select']['id'] = 623;
  205. }
  206. $companys = DB::table('jobs')->join('companys','jobs.company_id','=','companys.id')->whereRaw("jobs.created_at > '2020-01-01 00:00:00'")->groupBy('jobs.company_id')->select('jobs.company_id')->pluck('company_id')->toArray();
  207. $where = array();
  208. $where[] = array('reg_time', '>', 1577808000);
  209. $where[] = array('user_status', '=', 1);
  210. $where[] = array('subsite_id', '=', get_subsite_id());
  211. $where[] = array('audit','=',1);
  212. $where[] = array('deleted_at','=',null);
  213. if(!empty($trade)){
  214. $where[] = array('trade','=',$trade);
  215. }
  216. //$list = DB::table('companys')->where($where)->whereIn('id',$companys)->orderBy('id','desc')->offset($limit*$offset)->limit($limit)->get();
  217. $list = DB::table('companys')->where($where)->whereIn('id',$companys)->whereRaw("(district like ? or district like ? or district like ? or district like ?)",["%.{$citys['select']['id']}%","%{$citys['select']['id']}.%","%.245%","%245.%"])->orderBy('id','desc')->offset($limit*$offset)->limit($limit)->get();
  218. // echo '<pre>';
  219. // var_dump($citys);die;
  220. $more = count($list) >= $limit ? true : false;
  221. $res = [];
  222. foreach ($list as $val) {
  223. $item = array(
  224. 'id' => $val->id,
  225. 'companyname' => $val->companyname,
  226. 'trade' => $val->trade ? $categories['AIX_trade'][$val->trade]['demand'] : '未分类',
  227. 'jobs_num' => 0,
  228. 'amount_num' => 0,
  229. 'jobs' => []
  230. );
  231. //在招职位
  232. $jobs_where = array(
  233. array('company_id','=',$val->id),
  234. array('valid','=',1),
  235. array('display','=',1),
  236. array('audit','=',1)
  237. );
  238. //$jobs = $this->jobsService->getOtherJobs($jobs_where);
  239. $jobs = DB::table('jobs')->where($jobs_where)->get();
  240. if($jobs){
  241. $amount = 0;
  242. foreach ($jobs as $value) {
  243. $job = array(
  244. 'id' => $value->id,
  245. 'jobs_name' => $value->jobs_name,
  246. 'amount' => $value->amount,
  247. 'wage' => $value->wage_str
  248. );
  249. $amount += $value->amount;
  250. array_push($item['jobs'],$job);
  251. }
  252. $item['jobs_num'] = count($item['jobs']);
  253. $item['amount_num'] = $amount;
  254. }
  255. array_push($res,$item);
  256. }
  257. if ($request->ajax()) {
  258. if (count($res)) {
  259. return response()->json(['status'=>1,'data'=>view('mobile.app.active.ajax.ajax_jobfair_com', [
  260. 'res' => $res,
  261. 'city' => $citys,
  262. 'params' => $params,
  263. 'categories' => $categories,
  264. 'more' => $more
  265. ])->render()]);
  266. }
  267. return response()->json(['status'=>0]);
  268. }
  269. return view('mobile.app.active.online2020m',[
  270. 'res' => $res,
  271. 'city' => $citys,
  272. 'params' => $params,
  273. 'categories' => $categories,
  274. 'more' => $more
  275. ]);
  276. }
  277. }