IndexController.php 83 KB

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