IndexController.php 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258
  1. <?php
  2. namespace App\Http\Controllers\Web\Recruit;
  3. use App\Http\Controllers\Web\WebBaseController;
  4. use App\Models\RecruitAppointLog;
  5. use App\Models\RecruitTicket;
  6. use App\Validators\RecruitValidatorRequest;
  7. use Illuminate\Http\Request;
  8. use App\Models\Recruit;
  9. use App\Services\Recruit\RecruitService;
  10. use App\Models\RecruitAppointBasic;
  11. use App\Models\RecruitPost;
  12. use App\Models\RecruitAppointInfo;
  13. use think\Route;
  14. use Illuminate\Support\Facades\Validator;
  15. use Illuminate\Support\Facades\DB;
  16. use App\Models\RecruitAppointExpandSpecial;
  17. use App\Models\RecruitAppointDetail;
  18. use App\Models\RecruitArticle;
  19. use Illuminate\Support\Facades\Cache;
  20. class IndexController extends WebBaseController
  21. {
  22. protected $recruitService;
  23. public function __construct(RecruitService $recruitService)
  24. {
  25. $this->recruitService = $recruitService;
  26. }
  27. /**
  28. * 招考列表页
  29. * @param Request $request
  30. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  31. */
  32. public function index(Request $request)
  33. {
  34. $key = $request->input('key');
  35. $list = $this->recruitService->getRecruit($key, 10);
  36. $return_data = [
  37. 'list' => $list,
  38. 'key' => $key,
  39. ];
  40. return view('app.recruit.index', $return_data);
  41. }
  42. /**
  43. * 招考详情页
  44. * @param Request $request
  45. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View|mixed|\think\response\Redirect|\think\response\View|void
  46. */
  47. public function show(Request $request)
  48. {
  49. $user = $this->getUser();
  50. if($user){
  51. $uid = $user->id;
  52. $utype = $user->utype;
  53. }else{
  54. $uid = 0;
  55. $utype = 0;
  56. }
  57. $id = $request->input('id', 0);
  58. if (empty($id)) {
  59. return $this->showMessage('抱歉,请输入指定的招考场次!', route('recruit.list'), true, '上一页', '2');
  60. }
  61. $recruit = Recruit::find($id);
  62. if (empty($recruit)) {
  63. return redirect(route('/recruit/list'));
  64. }
  65. $info = Recruit::parse_info($recruit);
  66. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  67. if(!$info->isApply && $appoint_info){
  68. $first_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->orderBy('created_at','asc')->first();
  69. if($first_post){
  70. $info->isApply = 1;
  71. }
  72. }
  73. if($appoint_info){
  74. //笔试
  75. $pen_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',1)->first();
  76. if($pen_ticket){
  77. $time = time();
  78. if(strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time){
  79. $appoint_info->pen_ticket = 1;
  80. }else{
  81. $appoint_info->pen_ticket = -1;
  82. }
  83. }else{
  84. $appoint_info->pen_ticket = 0;
  85. }
  86. //考核测试
  87. $check_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',2)->first();
  88. if($check_ticket){
  89. $time = time();
  90. if(strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time){
  91. $appoint_info->check_ticket = 1;
  92. }else{
  93. $appoint_info->check_ticket = -1;
  94. }
  95. }else{
  96. $appoint_info->check_ticket = 0;
  97. }
  98. //面试
  99. $face_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',3)->first();
  100. if($face_ticket && $appoint_info->face_audit == -1){
  101. $appoint_info->face_ticket = 1;
  102. }else{
  103. $appoint_info->face_ticket = 0;
  104. }
  105. }else{
  106. $appoint_info = new \stdClass();
  107. $appoint_info->pen_audit = 0;
  108. $appoint_info->post_id = 0;
  109. $appoint_info->pen_ticket = 0;
  110. $appoint_info->computer_ticket = 0;
  111. $appoint_info->face_ticket = 0;
  112. $appoint_info->check_ticket = 0;
  113. $appoint_info->realname = '';
  114. $appoint_info->card = '';
  115. $appoint_info->mobile = '';
  116. $appoint_info->sex = 0;
  117. }
  118. $notice = $request->input('notice',0);
  119. if($notice){
  120. $public_notice_switch = 0;
  121. $public_notice = RecruitArticle::where('id',$notice)->where('released_at','<',time())->first();
  122. if (!empty($info)) {
  123. $view_data = [
  124. 'recruit' => $recruit,
  125. 'info' => $info,
  126. 'uid' => $uid,
  127. 'utype' => $utype,
  128. 'public_notice' => $public_notice,
  129. 'public_notice_switch' => $public_notice_switch,
  130. 'appoint_info' => $appoint_info
  131. ];
  132. return view('app.recruit.show')->with($view_data);
  133. } else {
  134. return back();
  135. }
  136. }else{
  137. $list = RecruitArticle::where('recruit_id',$id)->orderBy('created_at','desc')->where('released_at','<',time())->get();
  138. $public_notice_switch = 1;//有补充公告的模式
  139. if (!empty($info)) {
  140. $view_data = [
  141. 'recruit' => $recruit,
  142. 'info' => $info,
  143. 'uid' => $uid,
  144. 'utype' => $utype,
  145. 'list' => $list,
  146. 'public_notice_switch' => $public_notice_switch,
  147. 'appoint_info' => $appoint_info
  148. ];
  149. return view('app.recruit.show')->with($view_data);
  150. } else {
  151. return back();
  152. }
  153. }
  154. }
  155. /**
  156. * 上传文件的方法
  157. * @param Request $request
  158. * @return \Illuminate\Http\JsonResponse
  159. */
  160. public function upload(Request $request)
  161. {
  162. $user = $this->getUser();
  163. if($user){
  164. $uid = $user->id;
  165. $utype = $user->utype;
  166. }else{
  167. $uid = 0;
  168. $utype = 0;
  169. }
  170. $file = $request->file('file');
  171. if ($file->isValid()) { //判断文件是否存在
  172. //获取文件的扩展名
  173. $ext = $file->getClientOriginalExtension();
  174. if (!in_array(strtolower($ext), ['jpg', 'jpeg', 'png', 'doc', 'docx', 'pdf'])) {
  175. $res['status'] = 0;
  176. $res['msg'] = '文件格式不正确';
  177. } else {
  178. //获取文件的绝对路径
  179. $path = $file->getRealPath();
  180. $oldname = $file->getClientOriginalName();
  181. //定义文件名
  182. $filename = 'storage/recruit/' . uniqid() . mt_rand(10000, 99999) . '.' . $ext;
  183. //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置
  184. Storage::disk('public')->put($filename, file_get_contents($path));
  185. $res['status'] = 1;
  186. $res['filename'] = $oldname;
  187. $res['path'] = "/storage/" . $filename;
  188. $res['msg'] = '上传成功';
  189. }
  190. } else {
  191. $res['status'] = 0;
  192. $res['msg'] = '上传失败';
  193. }
  194. return response()->json($res);
  195. }
  196. /**
  197. * 查看报名人数统计
  198. * @param Request $request
  199. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View|mixed|\think\response\Redirect|\think\response\View|void
  200. */
  201. public function sign_up_count(Request $request)
  202. {
  203. $user = $this->getUser();
  204. if($user){
  205. $uid = $user->id;
  206. $utype = $user->utype;
  207. }else{
  208. $uid = 0;
  209. $utype = 0;
  210. }
  211. $id = $request->input('id', 0);
  212. if (empty($id)) {
  213. return $this->showMessage('抱歉,请输入指定的招考场次!', route('recruit.list'), true, '上一页', '2');
  214. }
  215. $recruit = Recruit::find($id);
  216. if (empty($recruit)) {
  217. return redirect(route('/recruit/list'));
  218. }
  219. if(!$recruit->show_report){
  220. return $this->showMessage('抱歉,该场次不允许查看报名人数统计结果!', route('recruit.list'), true, '上一页', '2');
  221. }
  222. if(Cache::has("sign_up_count_{$recruit->id}")) {
  223. $cache_data = Cache::get("sign_up_count_{$recruit->id}");
  224. $list = $cache_data['list'];
  225. $time = $cache_data['time'];
  226. }else{
  227. $list = RecruitPost::where('recruit_id',$recruit->id)->where('status',1)->get();
  228. if(!$list){
  229. return $this->showMessage('抱歉,数据暂时未更新或更新出错!', route('recruit.list'), true, '上一页', '2');
  230. }
  231. foreach ($list as $k => $v){
  232. $res = RecruitAppointInfo::select(DB::raw("count(case audit when 1 then 1 end) as 'checking', count(case audit when 2 then 2 end) as 'fail',count(case audit when 3 then 3 end) as 'success'"))->where('recruit_id',$recruit->id)->where('post_id',$v->id)->first();
  233. $list[$k]['checking'] = $res->checking;
  234. $list[$k]['fail'] = $res->fail;
  235. $list[$k]['success'] = $res->success;
  236. }
  237. $time = date('Y-m-d H:i',time());
  238. $cache_data = [
  239. 'list' => $list,
  240. 'time' => $time
  241. ];
  242. Cache::put("sign_up_count_{$recruit->id}",$cache_data,60);
  243. }
  244. $view_data = [
  245. 'list' => $list,
  246. 'time' => $time
  247. ];
  248. return view('app.recruit.sign_up_count')->with($view_data);
  249. }
  250. /**
  251. * 报名功能页
  252. * @param Request $request
  253. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View|mixed|\think\response\Redirect|\think\response\View|void
  254. */
  255. public function sign_up(Request $request)
  256. {
  257. $user = $this->getUser();
  258. if (!empty($user)) {
  259. $uid = $user->id;
  260. } else {
  261. return redirect(route('login'));
  262. }
  263. //招考id
  264. $id = $request->input('id', 0);
  265. if (!$id) {
  266. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  267. }
  268. //招考信息
  269. $recruit = Recruit::find($id);
  270. if(!$recruit['status'] && !$user->recruit_test){
  271. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  272. }
  273. if($recruit['current'] != 1){
  274. return $this->showMessage('抱歉,该项目报名通道已关闭,如有疑问,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  275. }
  276. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  277. $time = time();
  278. $formDisabled = 0;
  279. if(($time < strtotime($recruit['apply_start']) || strtotime($recruit['apply_end']) < $time)){//过了招考时间
  280. if(!$appoint_info){
  281. return $this->showMessage('抱歉,该项目已过报名时间或尚未开始!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  282. }
  283. if($appoint_info){
  284. //如果有报名记录,先查询首次报名是什么时候
  285. $first_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->where('appoint_id',$appoint_info->id)->orderBy('created_at','asc')->first();
  286. if(!$first_post){//没有记录代表只是暂存
  287. return $this->showMessage('抱歉,该项目已过报名时间或尚未开始!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  288. }
  289. // $has_late_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->where('created_at','>',$recruit['apply_end'])->first();//查找在过了报名时间后,有报名记录,且仍是审核失败的报名记录,看其是否在报名时间后是否有再次提交的记录
  290. // if($has_late_post){
  291. // $formDisabled = 1;
  292. // }else{
  293. // $formDisabled = 0;
  294. // }
  295. }
  296. }
  297. $view_data['module'] = $forms = explode(',', $recruit['forms']);
  298. //查询报名表是否已有记录
  299. if($appoint_info){
  300. if(in_array('internship',$forms)) {
  301. //如果已有该场次的报名记录,读取录入的数据集合
  302. $user_info = $appoint_info;
  303. $user_info['sex'] = (string)$user_info['sex'];
  304. $user_info['adjust'] = (string)$user_info['adjust'];
  305. $user_info['edu_type'] = (string)$user_info['edu_type'];
  306. $user_info['family'] = json_decode($user_info['family']);
  307. $detail = RecruitAppointDetail::where('recruit_appoint_id',$user_info['id'])->first();
  308. if($detail){
  309. $user_info['detail'] = $detail->toArray();
  310. }else{
  311. $user_info['detail'] = [
  312. 'rewards_and_punishments' => '',
  313. 'introduce' => ''
  314. ];
  315. }
  316. if(json_decode($user_info['identification'])){
  317. $identification = json_decode($user_info['identification'],true);
  318. foreach ($identification as $k => $v){
  319. if(array_key_exists('response',$v)){
  320. $identification[$k]['url'] = $v['response']['path'];
  321. }
  322. }
  323. }else{
  324. $identification = [];
  325. }
  326. $user_info['identification'] = $identification;
  327. if(json_decode($user_info['education_certification'])){
  328. $education_certification = json_decode($user_info['education_certification'],true);
  329. foreach ($education_certification as $k => $v){
  330. if(array_key_exists('response',$v)){
  331. $education_certification[$k]['url'] = $v['response']['path'];
  332. }
  333. }
  334. }else{
  335. $education_certification = [];
  336. }
  337. $user_info['education_certification'] = $education_certification;
  338. if(json_decode($user_info['other_certification'])){
  339. $other_certification = json_decode($user_info['other_certification'],true);
  340. foreach ($other_certification as $k => $v){
  341. if(array_key_exists('response',$v)){
  342. $other_certification[$k]['url'] = $v['response']['path'];
  343. }
  344. }
  345. }else{
  346. $other_certification = [];
  347. }
  348. $user_info['other_certification'] = $other_certification;
  349. //获取最新的报名审核信息
  350. $logs = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',2)->orderBy('created_at','desc')->first();
  351. if($logs){
  352. $user_info['audit_log'] = $logs->log;
  353. }else{
  354. $user_info['audit_log'] = '';
  355. }
  356. }else{
  357. //如果已有该场次的报名记录,读取录入的数据集合
  358. $user_info = $appoint_info;
  359. $user_info['sex'] = (string)$user_info['sex'];
  360. $user_info['edu_type'] = (string)$user_info['edu_type'];
  361. $user_info['family'] = json_decode($user_info['family']);
  362. if(in_array('expand_special',$forms)){
  363. $special = RecruitAppointExpandSpecial::where('recruit_appoint_id',$user_info['id'])->first();
  364. if(json_decode($special['material'])){
  365. $material = json_decode($special['material'],true);
  366. foreach ($material as $k => $v){
  367. if(array_key_exists('response',$v)){
  368. $material[$k]['url'] = $v['response']['path'];
  369. }
  370. }
  371. }else{
  372. $material = [];
  373. }
  374. $user_info['special'] = [
  375. 'point_apply' => (string)$special['point_apply'],
  376. 'condition' => $special['condition'],
  377. 'material' => $material
  378. ];
  379. }
  380. if(in_array('detail',$forms)){
  381. $detail = RecruitAppointDetail::where('recruit_appoint_id',$user_info['id'])->first();
  382. if($detail){
  383. $user_info['detail'] = $detail->toArray();
  384. }else{
  385. $user_info['detail'] = [
  386. 'train' => '',
  387. 'rewards_and_punishments' => '',
  388. 'introduce' => ''
  389. ];
  390. }
  391. }
  392. //如果有身份证明模块
  393. if(in_array('identification',$forms)){
  394. if(json_decode($user_info['identification'])){
  395. $identification = json_decode($user_info['identification'],true);
  396. foreach ($identification as $k => $v){
  397. if(array_key_exists('response',$v)){
  398. $identification[$k]['url'] = $v['response']['path'];
  399. }
  400. }
  401. }else{
  402. $identification = [];
  403. }
  404. $user_info['identification'] = $identification;
  405. }
  406. //如果有教育证明模块
  407. if(in_array('education_certification',$forms)){
  408. if(json_decode($user_info['education_certification'])){
  409. $education_certification = json_decode($user_info['education_certification'],true);
  410. foreach ($education_certification as $k => $v){
  411. if(array_key_exists('response',$v)){
  412. $education_certification[$k]['url'] = $v['response']['path'];
  413. }
  414. }
  415. }else{
  416. $education_certification = [];
  417. }
  418. $user_info['education_certification'] = $education_certification;
  419. }
  420. //如果有其他证明模块
  421. if(in_array('other_certification',$forms)){
  422. if(json_decode($user_info['other_certification'])){
  423. $other_certification = json_decode($user_info['other_certification'],true);
  424. foreach ($other_certification as $k => $v){
  425. if(array_key_exists('response',$v)){
  426. $other_certification[$k]['url'] = $v['response']['path'];
  427. }
  428. }
  429. }else{
  430. $other_certification = [];
  431. }
  432. $user_info['other_certification'] = $other_certification;
  433. }
  434. //获取最新的报名审核信息
  435. $logs = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',2)->orderBy('created_at','desc')->first();
  436. if($logs){
  437. $user_info['audit_log'] = $logs->log;
  438. }else{
  439. $user_info['audit_log'] = '';
  440. }
  441. //获取提交报名的次数
  442. // $number = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',3)->count();
  443. // $post_number = $number+1;//todo
  444. }
  445. }
  446. else{
  447. //实习专场
  448. if(in_array('internship',$forms)){
  449. $user_info = json_encode([
  450. 'recruit_id' => $id,
  451. 'operation' => 1,
  452. 'realname' => '',
  453. 'sex' => '1',
  454. 'birthday' => '',
  455. 'card' => '',
  456. 'nation' => '',
  457. 'native_place' => '',
  458. 'political_affiliation' => '',
  459. 'join_time' => '',
  460. 'house_register' => '',
  461. 'education' => '',
  462. 'school' => '',
  463. 'pro' => '',
  464. 'adjust' => '',
  465. 'mobile' => '',
  466. 'email' => '',
  467. 'address' => '',
  468. 'post_id' => '',
  469. 'concat_name' => '',
  470. 'concat_mobile' => '',
  471. 'resume' => '',
  472. 'avatar' => '',
  473. 'family' => [
  474. [
  475. 'relation' => '',
  476. 'realname' => '',
  477. 'birthday' => '',
  478. 'political_affiliation' => '',
  479. 'work' => ''
  480. ]
  481. ],
  482. 'detail' => [
  483. 'rewards_and_punishments' => '',
  484. 'introduce' => ''
  485. ],
  486. 'identification' => [],
  487. 'education_certification' => [],
  488. 'other_certification' => []
  489. ]);
  490. }else{
  491. //如果没有,结合基础数据及模块表单信息,制作数据对象
  492. $user_info = RecruitAppointBasic::where('uid',$uid)->first();
  493. if(!$user_info){
  494. //没有基础信息跳转完善route('person.recruitInfo')
  495. return $this->showMessage('请先完善招考基础信息!', route('recruit.recruitInfo',array('recruit_id',$id)), true, '上一页', '3');
  496. }
  497. $user_info['sex'] = (string)$user_info['sex'];
  498. $user_info['edu_type'] = (string)$user_info['edu_type'];
  499. $user_info['family'] = json_decode($user_info['family']);
  500. if(in_array('expand_special',$forms)){
  501. $user_info['special'] = [
  502. 'point_apply' => '0',
  503. 'condition' => '',
  504. 'material' => []
  505. ];
  506. }
  507. if(in_array('detail',$forms)){
  508. $user_info['detail'] = [
  509. 'train' => '',
  510. 'rewards_and_punishments' => '',
  511. 'introduce' => ''
  512. ];
  513. }
  514. if(in_array('identification',$forms)){
  515. $user_info['identification'] = [];
  516. }
  517. if(in_array('education_certification',$forms)){
  518. $user_info['education_certification'] = [];
  519. }
  520. if(in_array('other_certification',$forms)){
  521. $user_info['other_certification'] = [];
  522. }
  523. $user_info['recruit_id'] = $id;
  524. $user_info['operation'] = 1;
  525. }
  526. }
  527. //招考岗位
  528. $where_post[] = ['recruit_id', '=', $id];
  529. $recruit_post = RecruitPost::where($where_post)->get();
  530. $post = [];
  531. $post_limit = [];
  532. foreach ($recruit_post as $value){
  533. $item = [
  534. 'value' => $value['id'],
  535. 'label' => $value['code'] . " " . $value['name']
  536. ];
  537. $post_limit[$value['id']] = json_decode($value['limit']);
  538. array_push($post,$item);
  539. }
  540. $view_data['appoint_info'] = $user_info;
  541. $view_data['post'] = json_encode($post);
  542. // $view_data['post_number'] = $post_number;
  543. // $view_data['post_times'] = $recruit['post_times'];
  544. $view_data['post_limit'] = json_encode($post_limit);
  545. $view_data['formDisable'] = $formDisabled;
  546. $view_data['title'] = $recruit->company;
  547. return view('app.recruit.sign_up',$view_data);
  548. }
  549. /**
  550. * 提交报名的处理程序
  551. * @param Request $request
  552. * @return array|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\think\response\Redirect|void
  553. */
  554. public function saveSignUp(Request $request)
  555. {
  556. $user = $this->getUser();
  557. if (!empty($user)) {
  558. $uid = $user->id;
  559. } else {
  560. return redirect(route('login'));
  561. }
  562. $recruit_id = $request->input('recruit_id', 0);
  563. if (!$recruit_id) {
  564. return response()->json(['status' => 0,'msg' => '请选择项目!']);
  565. }
  566. $recruit = Recruit::find($recruit_id);
  567. if(!$recruit['status']){
  568. return response()->json(['status' => 0,'msg' => '抱歉,该项目状态不正确,请联系客服!']);
  569. }
  570. if($recruit['current'] != 1){
  571. return response()->json(['status' => 0,'msg' => '抱歉,该项目报名通道已关闭,如有疑问,请联系客服!']);
  572. }
  573. $time = time();
  574. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  575. if(($time < strtotime($recruit['apply_start']) || strtotime($recruit['apply_end']) < $time)){//过了招考时间
  576. if($appoint_info){
  577. //如果有报名记录,先查询首次报名是什么时候
  578. $first_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->orderBy('created_at','asc')->first();
  579. if(!$first_post){//没有记录代表只是暂存
  580. return response()->json(['status' => 0,'msg' => '抱歉,该项目已过报名时间!']);
  581. }
  582. }
  583. if(!$appoint_info){
  584. return response()->json(['status' => 0,'msg' => '抱歉,该项目已过报名时间!']);
  585. }
  586. }
  587. //基础信息的检查
  588. $rules = [
  589. 'realname' => 'required',
  590. 'sex' => 'required',
  591. 'birthday' => 'required',
  592. 'avatar' => 'required',
  593. 'nation' => 'required',
  594. 'native_place' => 'required',
  595. 'political_affiliation' => 'required',
  596. 'post_id' => 'required',
  597. 'house_register' => 'required',
  598. //'edu_type' => 'required',
  599. 'education' => 'required',
  600. 'school' => 'required',
  601. 'address' => 'required',
  602. 'mobile' => 'required',
  603. 'email' => 'required',
  604. 'card' => 'required',
  605. 'concat_name' => 'required',
  606. 'concat_mobile' => 'required',
  607. 'resume' => 'required'
  608. ];
  609. $messages = [
  610. 'realname.required' => '请填写姓名',
  611. 'sex.required' => '请填写性别',
  612. 'birthday.required' => '请填写出生日期',
  613. 'avatar.required' => '请上传彩色免冠照',
  614. 'nation.required' => '请填写民族',
  615. 'native_place.required' => '请填写籍贯',
  616. 'political_affiliation.required' => '请选择政治面貌',
  617. 'post_id.required' => '请选择报名岗位',
  618. 'house_register.required' => '请填写户籍所在地',
  619. //'edu_type.required' => '请选择教育类型',
  620. 'education.required' => '请输入学历',
  621. 'school.required' => '请输入毕业院校',
  622. 'address.required' => '请填写通信地址',
  623. 'mobile.required' => '请填写手机号码',
  624. 'email.required' => '请填写电子邮箱',
  625. 'card.required' => '请填写身份证号码',
  626. 'resume.required' => '请填写个人简历',
  627. 'concat_name.required' => '请填写联系人姓名',
  628. 'concat_mobile.required' => '请填写联系人手机号码'
  629. ];
  630. $create_data = $request->all();
  631. $validator = Validator::make($create_data,$rules,$messages);
  632. if ($validator->fails()) {
  633. $msg = $validator->errors()->all();
  634. return response()->json(['status' => 0,'msg' => $msg[0]]);
  635. }else{
  636. $data = $request->only('realname','sex','birthday','avatar','nation','native_place','political_affiliation','titles','join_time','work','house_register','education','school','degree','pro','address','card','mobile','email','concat_name','concat_mobile','resume','post_id','adjust','remark');
  637. //身份证判断出生日期和性别
  638. $year = substr($data['card'],6,4);
  639. $month = substr($data['card'],10,2);
  640. $day = substr($data['card'],12,2);
  641. if($year.'-'.$month.'-'.$day != $data['birthday']){
  642. $data['birthday'] = $year.'-'.$month.'-'.$day;
  643. }
  644. if(intval(substr($data['card'],16,1)) % 2 == 0){
  645. $data['sex'] = 0;
  646. }else{
  647. $data['sex'] = 1;
  648. }
  649. $post_info = RecruitPost::where('id',$data['post_id'])->where('recruit_id',$recruit_id)->first();
  650. if(!$post_info['status'] || $post_info['deleted_at'] != null){
  651. return response()->json(['status' => 0,'msg' => '该岗位已失效']);
  652. }
  653. //获取操作符,是暂存还是提交
  654. $operation = $request->input('operation');
  655. if($operation == 1){
  656. $data['audit'] = 0;//暂存
  657. }else{
  658. $data['audit'] = 1;//提交
  659. }
  660. if(!empty($post_info['limit']) && json_decode($post_info['limit'])){
  661. //岗位限制条件的判断
  662. $post_limit = json_decode($post_info['limit'],true);
  663. if(is_array($post_limit)){
  664. foreach($post_limit as $k => $v){
  665. if($k == 'birthday'){
  666. $value = str_replace('-','',$data[$k]);
  667. }else{
  668. $value = $data[$k];
  669. }
  670. switch ($v['op']){
  671. case '=':
  672. if($value != $v['value']){
  673. return response()->json(['status' => 0,'msg' => $v['msg']]);
  674. }
  675. break;
  676. case '>':
  677. if($value <= $v['value']){
  678. return response()->json(['status' => 0,'msg' => $v['msg']]);
  679. }
  680. break;
  681. case '>=':
  682. if($value < $v['value']){
  683. return response()->json(['status' => 0,'msg' => $v['msg']]);
  684. }
  685. break;
  686. case '<':
  687. if($value >= $v['value']){
  688. return response()->json(['status' => 0,'msg' => $v['msg']]);
  689. }
  690. break;
  691. case '<=':
  692. if($value > $v['value']){
  693. return response()->json(['status' => 0,'msg' => $v['msg']]);
  694. }
  695. break;
  696. case '!=':
  697. if($value == $v['value']){
  698. return response()->json(['status' => 0,'msg' => $v['msg']]);
  699. }
  700. break;
  701. case 'like':
  702. if(strpos($value,$v['value']) === false){
  703. return response()->json(['status' => 0,'msg' => $v['msg']]);
  704. }
  705. break;
  706. case 'in':
  707. if(strpos($v['value'],$value) === false){
  708. return response()->json(['status' => 0,'msg' => $v['msg']]);
  709. }
  710. break;
  711. }
  712. }
  713. }
  714. }
  715. //前置审核 判断完成,先将数据入报名信息基础表
  716. //解析家庭成员数据
  717. $familys = $request->input('family');
  718. $family = [];
  719. if(is_array($familys)){
  720. foreach ($familys as $value){
  721. $item = [
  722. 'relation' => $value['relation'],
  723. 'realname' => $value['realname'],
  724. 'birthday' => $value['birthday'],
  725. 'political_affiliation' => $value['political_affiliation'],
  726. 'work' => $value['work']
  727. ];
  728. array_push($family,$item);
  729. }
  730. }
  731. $data['family'] = json_encode($family);
  732. if($appoint_info){
  733. //如果已有报名记录,进入修改阶段的处理流程
  734. DB::beginTransaction();
  735. try{
  736. RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->update($data);
  737. //分模块解析数据
  738. $forms = explode(',', $recruit['forms']);
  739. //如果有加分模块
  740. if(in_array('expand_special',$forms)){
  741. $special = $request->input('special');
  742. if($special['point_apply']){
  743. //删除掉没有成功返回路径的图片
  744. if(is_array($special['material'])){
  745. foreach ($special['material'] as $k => $v){
  746. if(!array_key_exists('response',$v)){
  747. unset($special['material'][$k]);
  748. }
  749. }
  750. }
  751. $special['material'] = json_encode($special['material']);
  752. }else{
  753. $special['material'] = json_encode([]);
  754. }
  755. $hasRecord = RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint_info->id)->first();
  756. if($hasRecord){
  757. RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint_info->id)->update($special);
  758. }else{
  759. $special['recruit_appoint_id'] = $appoint_info->id;
  760. RecruitAppointExpandSpecial::create($special);
  761. }
  762. }
  763. //如果有详情模块
  764. if(in_array('detail',$forms) || in_array('internship',$forms)){
  765. $detail = $request->input('detail');
  766. $hasRecord = RecruitAppointDetail::where('recruit_appoint_id',$appoint_info->id)->first();
  767. if($hasRecord){
  768. RecruitAppointDetail::where('recruit_appoint_id',$appoint_info->id)->update($detail);
  769. }else{
  770. $detail['recruit_appoint_id'] = $appoint_info->id;
  771. RecruitAppointDetail::create($detail);
  772. }
  773. }
  774. //如果有身份证明模块
  775. if(in_array('identification',$forms) || in_array('internship',$forms)){
  776. $identification = $request->input('identification');
  777. if(is_array($identification)){
  778. //删除掉没有成功返回路径的图片
  779. foreach ($identification as $k => $v){
  780. if(!array_key_exists('response',$v)){
  781. unset($identification[$k]);
  782. }
  783. }
  784. }
  785. $appoint_info->identification = json_encode($identification);
  786. $appoint_info->save();
  787. }
  788. //如果有教育证明模块
  789. if(in_array('education_certification',$forms) || in_array('internship',$forms)){
  790. $education_certification = $request->input('education_certification');
  791. if(is_array($education_certification)){
  792. //删除掉没有成功返回路径的图片
  793. foreach ($education_certification as $k => $v){
  794. if(!array_key_exists('response',$v)){
  795. unset($education_certification[$k]);
  796. }
  797. }
  798. }
  799. $appoint_info->education_certification = json_encode($education_certification);
  800. $appoint_info->save();
  801. }
  802. //如果有其他证明模块
  803. if(in_array('other_certification',$forms) || in_array('internship',$forms)){
  804. $other_certification = $request->input('other_certification');
  805. if(is_array($other_certification)){
  806. //删除掉没有成功返回路径的图片
  807. foreach ($other_certification as $k => $v){
  808. if(!array_key_exists('response',$v)){
  809. unset($other_certification[$k]);
  810. }
  811. }
  812. }
  813. if($other_certification){
  814. $appoint_info->other_certification = json_encode($other_certification);
  815. $appoint_info->save();
  816. }
  817. }
  818. DB::commit();
  819. if($operation == 2){
  820. $log = [
  821. 'type' => 3,
  822. 'appoint_id'=> $appoint_info->id,
  823. 'uid' => $uid,
  824. 'log' => '用户提交报名'
  825. ];
  826. RecruitAppointLog::create($log);
  827. return ['status' => 1, 'msg' => '提交成功', 'data' => $appoint_info->id];
  828. }else{
  829. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $appoint_info->id];
  830. }
  831. } catch (\Exception $e){
  832. DB::rollback();
  833. return ['status' => 0, 'msg' => $e->getMessage()];
  834. }
  835. }else{
  836. //没有报名记录,进入增加阶段的处理流程
  837. DB::beginTransaction();
  838. try{
  839. $data['uid'] = $uid;
  840. $data['recruit_id'] = $recruit_id;
  841. $result = RecruitAppointInfo::create($data);
  842. //分模块解析数据
  843. $forms = explode(',', $recruit['forms']);
  844. //如果有加分模块
  845. if(in_array('expand_special',$forms)){
  846. $special = $request->input('special');
  847. if($special['point_apply']){
  848. if(is_array($special['material'])){
  849. //删除掉没有成功返回路径的图片
  850. foreach ($special['material'] as $k => $v){
  851. if(!array_key_exists('response',$v)){
  852. unset($special['material'][$k]);
  853. }
  854. }
  855. }
  856. $special['material'] = json_encode($special['material']);
  857. }
  858. $special['recruit_appoint_id'] = $result->id;
  859. RecruitAppointExpandSpecial::create($special);
  860. }
  861. //如果有详情模块
  862. if(in_array('detail',$forms) || in_array('internship',$forms)){
  863. $detail = $request->input('detail');
  864. $detail['recruit_appoint_id'] = $result->id;
  865. RecruitAppointDetail::create($detail);
  866. }
  867. //如果有身份证明模块
  868. if(in_array('identification',$forms) || in_array('internship',$forms)){
  869. $identification = $request->input('identification');
  870. if(is_array($identification)){
  871. //删除掉没有成功返回路径的图片
  872. foreach ($identification as $k => $v){
  873. if(!array_key_exists('response',$v)){
  874. unset($identification[$k]);
  875. }
  876. }
  877. }
  878. $result->identification = json_encode($identification);
  879. $result->save();
  880. }
  881. //如果有教育证明模块
  882. if(in_array('education_certification',$forms) || in_array('internship',$forms)){
  883. $education_certification = $request->input('education_certification');
  884. if(is_array($education_certification)){
  885. //删除掉没有成功返回路径的图片
  886. foreach ($education_certification as $k => $v){
  887. if(!array_key_exists('response',$v)){
  888. unset($education_certification[$k]);
  889. }
  890. }
  891. }
  892. $result->education_certification = json_encode($education_certification);
  893. $result->save();
  894. }
  895. //如果有其他证明模块
  896. if(in_array('other_certification',$forms) || in_array('internship',$forms)){
  897. $other_certification = $request->input('other_certification');
  898. if($other_certification){
  899. if(is_array($other_certification)){
  900. //删除掉没有成功返回路径的图片
  901. foreach ($other_certification as $k => $v){
  902. if(!array_key_exists('response',$v)){
  903. unset($other_certification[$k]);
  904. }
  905. }
  906. }
  907. $result->other_certification = json_encode($other_certification);
  908. $result->save();
  909. }
  910. }
  911. DB::commit();
  912. if($operation == 2){
  913. $log = [
  914. 'type' => 3,
  915. 'appoint_id'=> $result->id,
  916. 'uid' => $uid,
  917. 'log' => '用户首次提交报名'
  918. ];
  919. RecruitAppointLog::create($log);
  920. return ['status' => 1, 'msg' => '提交成功', 'data' => $result->id];
  921. }else{
  922. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $result->id];
  923. }
  924. } catch (\Exception $e){
  925. DB::rollback();
  926. return ['status' => 0, 'msg' => $e->getMessage()];
  927. }
  928. }
  929. }
  930. }
  931. /**
  932. * 获得当前登录的用户
  933. * @return \Illuminate\Contracts\Auth\Authenticatable|null
  934. */
  935. public function getUser()
  936. {
  937. if (auth('web-member')->check()) {
  938. $user = auth('web-member')->user();
  939. } else {
  940. $user = null;
  941. }
  942. return $user;
  943. }
  944. public function checkUserBasicInfo()
  945. {
  946. $user = $this->getUser();
  947. if (!empty($user)) {
  948. $uid = $user->id;
  949. } else {
  950. $arr = ['status' => 401, 'msg'=>'请登录!'];
  951. return $arr;
  952. }
  953. $info = RecruitAppointBasic::where('uid',$uid)->first();
  954. if (empty($info)){
  955. $arr = ['status'=>401,'msg'=>'请先完善招考基本信息','url'=> route('recruit.recruitInfo')];
  956. return $arr;
  957. }
  958. return ['status' => 200, 'msg' => ''];
  959. }
  960. public function person_recruit()
  961. {
  962. $user = auth('web-member')->user();
  963. $list = RecruitAppointInfo::where('uid',$user->id)
  964. ->join('recruit', 'recruit.id', '=', 'recruit_appoint_info.recruit_id', 'left')
  965. ->join('recruit_post', 'recruit_post.id', '=', 'recruit_appoint_info.post_id', 'left')
  966. ->select('recruit.name as recruit_name','recruit_appoint_info.*','recruit_post.code','recruit_post.name')
  967. ->get();
  968. return view('app.person.recruit')->with(['list' => $list,'total' => count($list)]);
  969. }
  970. public function recruit_info(Request $request)
  971. {
  972. $user = auth('web-member')->user();
  973. $info = RecruitAppointBasic::where('uid',$user->id)->first();
  974. if(!$info){
  975. $info = [
  976. 'realname' => '',
  977. 'sex' => '0',
  978. 'birthday' => '',
  979. 'avatar' => '',
  980. 'nation' => '',
  981. 'native_place' => '',
  982. 'political_affiliation' => '',
  983. 'titles' => '',
  984. 'work' => '',
  985. 'house_register' => '',
  986. 'join_time' => '',
  987. 'edu_type' => '',
  988. 'education' => '',
  989. 'school' => '',
  990. 'degree' => '',
  991. 'pro' => '',
  992. 'address' => '',
  993. 'card' => '',
  994. 'mobile' => '',
  995. 'email' => '',
  996. 'concat_name' => '',
  997. 'concat_mobile' => '',
  998. 'resume' => '',
  999. 'family' => [
  1000. [
  1001. 'relation' => '',
  1002. 'realname' => '',
  1003. 'birthday' => '',
  1004. 'political_affiliation' => '',
  1005. 'work' => ''
  1006. ]
  1007. ],
  1008. 'is_push' => '1'
  1009. ];
  1010. }else{
  1011. $info->sex = (string)$info->sex;
  1012. $info->edu_type = (string)$info->edu_type;
  1013. $info->is_push = (string)$info->is_push;
  1014. $info->family = empty($info->family) ? [[
  1015. 'relation' => '',
  1016. 'realname' => '',
  1017. 'birthday' => '',
  1018. 'political_affiliation' => '',
  1019. 'work' => ''
  1020. ]] : json_decode($info->family);
  1021. }
  1022. $recruit_id = $request->input('recruit_id',0);
  1023. return view('app.person.recruit_info',[
  1024. 'info' => json_encode($info),
  1025. 'recruit_id'=> $recruit_id
  1026. ]);
  1027. }
  1028. public function saveRecruitInfo(RecruitValidatorRequest $request)
  1029. {
  1030. $user = auth('web-member')->user();
  1031. $basic = RecruitAppointBasic::where('uid',$user->id)->first();
  1032. $data = $request->only('realname','sex','birthday','avatar','nation','native_place','political_affiliation','titles','work','house_register','join_time','education','school','degree','pro','address','card','mobile','email','concat_name','concat_mobile','resume','family','is_push');
  1033. if(count($data['family']) > 0){
  1034. $data['family'] = json_encode($data['family']);
  1035. }
  1036. if($basic){
  1037. //更新基础信息
  1038. $res = RecruitAppointBasic::where('uid',$user->id)->update($data);
  1039. if (!$res) {
  1040. return response()->json(['status'=>0,'msg'=>'保存失败,请联系客服']);
  1041. }else{
  1042. return response()->json(['status'=>1,'msg'=>'个人基础信息保存成功,快去报名吧!']);
  1043. }
  1044. }else{
  1045. //新增基础信息
  1046. $data['uid'] = $user->id;
  1047. $res = RecruitAppointBasic::create($data);
  1048. if (!$res) {
  1049. return response()->json(['status'=>0,'msg'=>'保存失败,请联系客服']);
  1050. }else{
  1051. return response()->json(['status'=>1,'msg'=>'个人基础信息保存成功,快去报名吧!']);
  1052. }
  1053. }
  1054. }
  1055. public function pen_ticket(Request $request)
  1056. {
  1057. $user = $this->getUser();
  1058. if (!empty($user)) {
  1059. $uid = $user->id;
  1060. } else {
  1061. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1062. }
  1063. $recruit_id = $request->input('recruit_id');
  1064. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1065. if($appoint_info){
  1066. $pen_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',1)->first();
  1067. if($pen_ticket){
  1068. $time = time();
  1069. if(strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time){
  1070. RecruitTicket::where('appoint_id',$appoint_info->id)->update(['ex_status' => 1]);
  1071. $recruit = Recruit::where('id',$recruit_id)->first();
  1072. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1073. $name = $recruit->name_en;
  1074. $date = date("Y-m-d",strtotime($recruit->created_at));
  1075. $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1076. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/pen/" . $filename . '_create.pdf';
  1077. if(file_exists($file)){
  1078. header('Content-Description: File Transfer');
  1079. header('Content-Type: application/octet-stream');
  1080. header('Content-Disposition: attachment; filename='.basename($file));
  1081. header('Content-Transfer-Encoding: binary');
  1082. header('Expires: 0');
  1083. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1084. header('Pragma: public');
  1085. header('Content-Length: ' . filesize($file));
  1086. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1087. flush();
  1088. readfile($file);
  1089. }
  1090. }else{
  1091. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1092. }
  1093. }else{
  1094. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1095. }
  1096. }else{
  1097. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1098. }
  1099. }
  1100. public function check_ticket(Request $request)
  1101. {
  1102. $user = $this->getUser();
  1103. if (!empty($user)) {
  1104. $uid = $user->id;
  1105. } else {
  1106. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1107. }
  1108. $recruit_id = $request->input('recruit_id');
  1109. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1110. if($appoint_info){
  1111. $check_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',2)->first();
  1112. if($check_ticket){
  1113. $time = time();
  1114. if(strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time){
  1115. RecruitTicket::where('appoint_id',$appoint_info->id)->update(['ex_status' => 1]);
  1116. $recruit = Recruit::where('id',$recruit_id)->first();
  1117. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1118. $name = $recruit->name_en;
  1119. $date = date("Y-m-d",strtotime($recruit->created_at));
  1120. $filename = date("Y-m-18",time()) . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1121. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/check/" . $filename . '.pdf';
  1122. if(file_exists($file)){
  1123. header('Content-Description: File Transfer');
  1124. header('Content-Type: application/octet-stream');
  1125. header('Content-Disposition: attachment; filename='.basename($file));
  1126. header('Content-Transfer-Encoding: binary');
  1127. header('Expires: 0');
  1128. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1129. header('Pragma: public');
  1130. header('Content-Length: ' . filesize($file));
  1131. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1132. flush();
  1133. readfile($file);
  1134. }
  1135. }else{
  1136. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1137. }
  1138. }else{
  1139. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1140. }
  1141. }else{
  1142. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1143. }
  1144. }
  1145. public function face_ticket(Request $request)
  1146. {
  1147. $user = $this->getUser();
  1148. if (!empty($user)) {
  1149. $uid = $user->id;
  1150. } else {
  1151. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1152. }
  1153. $recruit_id = $request->input('recruit_id');
  1154. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1155. if($appoint_info){
  1156. $face_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',3)->first();
  1157. if($face_ticket){
  1158. $time = time();
  1159. if(strtotime($face_ticket->ex_start) < $time && strtotime($face_ticket->ex_end) > $time){
  1160. RecruitTicket::where('id',$face_ticket->id)->update(['ex_status' => 1]);
  1161. $recruit = Recruit::where('id',$recruit_id)->first();
  1162. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1163. $name = $recruit->name_en;
  1164. $date = date("Y-m-d",strtotime($recruit->created_at));
  1165. $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id].'_create';
  1166. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';
  1167. if(file_exists($file)){
  1168. header('Content-Description: File Transfer');
  1169. header('Content-Type: application/octet-stream');
  1170. header('Content-Disposition: attachment; filename='.basename($file));
  1171. header('Content-Transfer-Encoding: binary');
  1172. header('Expires: 0');
  1173. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1174. header('Pragma: public');
  1175. header('Content-Length: ' . filesize($file));
  1176. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1177. flush();
  1178. readfile($file);
  1179. }
  1180. }else{
  1181. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1182. }
  1183. }else{
  1184. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1185. }
  1186. }else{
  1187. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1188. }
  1189. }
  1190. }