IndexController.php 62 KB

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