IndexController.php 76 KB

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