IndexController.php 62 KB

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