IndexController.php 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960
  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. public function preview(Request $request)
  570. {
  571. $modules = $request->input('modules');
  572. $view_data['module'] = $forms = explode(',', $modules);
  573. return view('app.recruit.preview',$view_data);
  574. }
  575. /**
  576. * 提交报名的处理程序
  577. * @param Request $request
  578. * @return array|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\think\response\Redirect|void
  579. */
  580. public function saveSignUp(Request $request)
  581. {
  582. $user = $this->getUser();
  583. if (!empty($user)) {
  584. $uid = $user->id;
  585. } else {
  586. return redirect(route('login'));
  587. }
  588. $recruit_id = $request->input('recruit_id', 0);
  589. if (!$recruit_id) {
  590. return response()->json(['status' => 0,'msg' => '请选择项目!']);
  591. }
  592. $recruit = Recruit::find($recruit_id);
  593. if(!$recruit['status']){
  594. return response()->json(['status' => 0,'msg' => '抱歉,该项目状态不正确,请联系客服!']);
  595. }
  596. if($recruit['current'] != 1){
  597. return response()->json(['status' => 0,'msg' => '抱歉,该项目报名通道已关闭,如有疑问,请联系客服!']);
  598. }
  599. $time = time();
  600. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  601. if(($time < strtotime($recruit['apply_start']) || strtotime($recruit['apply_end']) < $time)){//过了招考时间
  602. if($appoint_info){
  603. //如果有报名记录,先查询首次报名是什么时候
  604. $first_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->orderBy('created_at','asc')->first();
  605. if(!$first_post){//没有记录代表只是暂存
  606. return response()->json(['status' => 0,'msg' => '抱歉,该项目已过报名时间!']);
  607. }
  608. }
  609. if(!$appoint_info){
  610. return response()->json(['status' => 0,'msg' => '抱歉,该项目已过报名时间!']);
  611. }
  612. }
  613. //基础信息的检查
  614. $rules = [
  615. 'realname' => 'required',
  616. 'sex' => 'required',
  617. 'birthday' => 'required',
  618. 'avatar' => 'required',
  619. 'nation' => 'required',
  620. 'native_place' => 'required',
  621. 'political_affiliation' => 'required',
  622. 'post_id' => 'required',
  623. 'house_register' => 'required',
  624. //'edu_type' => 'required',
  625. 'education' => 'required',
  626. 'school' => 'required',
  627. 'address' => 'required',
  628. 'mobile' => 'required',
  629. 'email' => 'required',
  630. 'card' => 'required',
  631. 'concat_name' => 'required',
  632. 'concat_mobile' => 'required',
  633. 'resume' => 'required'
  634. ];
  635. $messages = [
  636. 'realname.required' => '请填写姓名',
  637. 'sex.required' => '请填写性别',
  638. 'birthday.required' => '请填写出生日期',
  639. 'avatar.required' => '请上传彩色免冠照',
  640. 'nation.required' => '请填写民族',
  641. 'native_place.required' => '请填写籍贯',
  642. 'political_affiliation.required' => '请选择政治面貌',
  643. 'post_id.required' => '请选择报名岗位',
  644. 'house_register.required' => '请填写户籍所在地',
  645. //'edu_type.required' => '请选择教育类型',
  646. 'education.required' => '请输入学历',
  647. 'school.required' => '请输入毕业院校',
  648. 'address.required' => '请填写通信地址',
  649. 'mobile.required' => '请填写手机号码',
  650. 'email.required' => '请填写电子邮箱',
  651. 'card.required' => '请填写身份证号码',
  652. 'resume.required' => '请填写个人简历',
  653. 'concat_name.required' => '请填写联系人姓名',
  654. 'concat_mobile.required' => '请填写联系人手机号码'
  655. ];
  656. $create_data = $request->all();
  657. $validator = Validator::make($create_data,$rules,$messages);
  658. if ($validator->fails()) {
  659. $msg = $validator->errors()->all();
  660. return response()->json(['status' => 0,'msg' => $msg[0]]);
  661. }else{
  662. $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');
  663. //身份证判断出生日期和性别
  664. $year = substr($data['card'],6,4);
  665. $month = substr($data['card'],10,2);
  666. $day = substr($data['card'],12,2);
  667. if($year.'-'.$month.'-'.$day != $data['birthday']){
  668. $data['birthday'] = $year.'-'.$month.'-'.$day;
  669. }
  670. if(intval(substr($data['card'],16,1)) % 2 == 0){
  671. $data['sex'] = 0;
  672. }else{
  673. $data['sex'] = 1;
  674. }
  675. $post_info = RecruitPost::where('id',$data['post_id'])->where('recruit_id',$recruit_id)->first();
  676. if(!$post_info['status'] || $post_info['deleted_at'] != null){
  677. return response()->json(['status' => 0,'msg' => '该岗位已失效']);
  678. }
  679. //获取操作符,是暂存还是提交
  680. $operation = $request->input('operation');
  681. if($operation == 1){
  682. $data['audit'] = 0;//暂存
  683. }else{
  684. $data['audit'] = 1;//提交
  685. }
  686. if(!empty($post_info['limit']) && json_decode($post_info['limit'])){
  687. //岗位限制条件的判断
  688. $post_limit = json_decode($post_info['limit'],true);
  689. if(is_array($post_limit)){
  690. foreach($post_limit as $k => $v){
  691. if($k == 'birthday'){
  692. $value = str_replace('-','',$data[$k]);
  693. }else{
  694. $value = $data[$k];
  695. }
  696. switch ($v['op']){
  697. case '=':
  698. if($value != $v['value']){
  699. return response()->json(['status' => 0,'msg' => $v['msg']]);
  700. }
  701. break;
  702. case '>':
  703. if($value <= $v['value']){
  704. return response()->json(['status' => 0,'msg' => $v['msg']]);
  705. }
  706. break;
  707. case '>=':
  708. if($value < $v['value']){
  709. return response()->json(['status' => 0,'msg' => $v['msg']]);
  710. }
  711. break;
  712. case '<':
  713. if($value >= $v['value']){
  714. return response()->json(['status' => 0,'msg' => $v['msg']]);
  715. }
  716. break;
  717. case '<=':
  718. if($value > $v['value']){
  719. return response()->json(['status' => 0,'msg' => $v['msg']]);
  720. }
  721. break;
  722. case '!=':
  723. if($value == $v['value']){
  724. return response()->json(['status' => 0,'msg' => $v['msg']]);
  725. }
  726. break;
  727. case 'like':
  728. if(strpos($value,$v['value']) === false){
  729. return response()->json(['status' => 0,'msg' => $v['msg']]);
  730. }
  731. break;
  732. case 'in':
  733. if(strpos($v['value'],$value) === false){
  734. return response()->json(['status' => 0,'msg' => $v['msg']]);
  735. }
  736. break;
  737. }
  738. }
  739. }
  740. }
  741. //前置审核 判断完成,先将数据入报名信息基础表
  742. //解析家庭成员数据
  743. $familys = $request->input('family');
  744. $family = [];
  745. if(is_array($familys)){
  746. foreach ($familys as $value){
  747. $item = [
  748. 'relation' => $value['relation'],
  749. 'realname' => $value['realname'],
  750. 'birthday' => $value['birthday'],
  751. 'political_affiliation' => $value['political_affiliation'],
  752. 'work' => $value['work']
  753. ];
  754. array_push($family,$item);
  755. }
  756. }
  757. $data['family'] = json_encode($family);
  758. if($appoint_info){
  759. //如果已有报名记录,进入修改阶段的处理流程
  760. DB::beginTransaction();
  761. try{
  762. RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->update($data);
  763. //分模块解析数据
  764. $forms = explode(',', $recruit['forms']);
  765. //如果有加分模块
  766. if(in_array('expand_special',$forms)){
  767. $special = $request->input('special');
  768. if($special['point_apply']){
  769. //删除掉没有成功返回路径的图片
  770. if(is_array($special['material'])){
  771. foreach ($special['material'] as $k => $v){
  772. if(!array_key_exists('response',$v)){
  773. unset($special['material'][$k]);
  774. }
  775. }
  776. }
  777. $special['material'] = json_encode($special['material']);
  778. }else{
  779. $special['material'] = json_encode([]);
  780. }
  781. $hasRecord = RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint_info->id)->first();
  782. if($hasRecord){
  783. RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint_info->id)->update($special);
  784. }else{
  785. $special['recruit_appoint_id'] = $appoint_info->id;
  786. RecruitAppointExpandSpecial::create($special);
  787. }
  788. }
  789. //如果有详情模块
  790. if(in_array('detail',$forms) || in_array('internship',$forms)){
  791. $detail = $request->input('detail');
  792. $hasRecord = RecruitAppointDetail::where('recruit_appoint_id',$appoint_info->id)->first();
  793. if($hasRecord){
  794. RecruitAppointDetail::where('recruit_appoint_id',$appoint_info->id)->update($detail);
  795. }else{
  796. $detail['recruit_appoint_id'] = $appoint_info->id;
  797. RecruitAppointDetail::create($detail);
  798. }
  799. }
  800. //如果有身份证明模块
  801. if(in_array('identification',$forms) || in_array('internship',$forms)){
  802. $identification = $request->input('identification');
  803. if(is_array($identification)){
  804. //删除掉没有成功返回路径的图片
  805. foreach ($identification as $k => $v){
  806. if(!array_key_exists('response',$v)){
  807. unset($identification[$k]);
  808. }
  809. }
  810. }
  811. $appoint_info->identification = json_encode($identification);
  812. $appoint_info->save();
  813. }
  814. //如果有教育证明模块
  815. if(in_array('education_certification',$forms) || in_array('internship',$forms)){
  816. $education_certification = $request->input('education_certification');
  817. if(is_array($education_certification)){
  818. //删除掉没有成功返回路径的图片
  819. foreach ($education_certification as $k => $v){
  820. if(!array_key_exists('response',$v)){
  821. unset($education_certification[$k]);
  822. }
  823. }
  824. }
  825. $appoint_info->education_certification = json_encode($education_certification);
  826. $appoint_info->save();
  827. }
  828. //如果有其他证明模块
  829. if(in_array('other_certification',$forms) || in_array('internship',$forms)){
  830. $other_certification = $request->input('other_certification');
  831. if(is_array($other_certification)){
  832. //删除掉没有成功返回路径的图片
  833. foreach ($other_certification as $k => $v){
  834. if(!array_key_exists('response',$v)){
  835. unset($other_certification[$k]);
  836. }
  837. }
  838. }
  839. if($other_certification){
  840. $appoint_info->other_certification = json_encode($other_certification);
  841. $appoint_info->save();
  842. }
  843. }
  844. DB::commit();
  845. if($operation == 2){
  846. $log = [
  847. 'type' => 3,
  848. 'appoint_id'=> $appoint_info->id,
  849. 'uid' => $uid,
  850. 'log' => '用户提交报名'
  851. ];
  852. RecruitAppointLog::create($log);
  853. return ['status' => 1, 'msg' => '提交成功', 'data' => $appoint_info->id];
  854. }else{
  855. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $appoint_info->id];
  856. }
  857. } catch (\Exception $e){
  858. DB::rollback();
  859. return ['status' => 0, 'msg' => $e->getMessage()];
  860. }
  861. }else{
  862. //没有报名记录,进入增加阶段的处理流程
  863. DB::beginTransaction();
  864. try{
  865. $data['uid'] = $uid;
  866. $data['recruit_id'] = $recruit_id;
  867. $result = RecruitAppointInfo::create($data);
  868. //分模块解析数据
  869. $forms = explode(',', $recruit['forms']);
  870. //如果有加分模块
  871. if(in_array('expand_special',$forms)){
  872. $special = $request->input('special');
  873. if($special['point_apply']){
  874. if(is_array($special['material'])){
  875. //删除掉没有成功返回路径的图片
  876. foreach ($special['material'] as $k => $v){
  877. if(!array_key_exists('response',$v)){
  878. unset($special['material'][$k]);
  879. }
  880. }
  881. }
  882. $special['material'] = json_encode($special['material']);
  883. }
  884. $special['recruit_appoint_id'] = $result->id;
  885. RecruitAppointExpandSpecial::create($special);
  886. }
  887. //如果有详情模块
  888. if(in_array('detail',$forms) || in_array('internship',$forms)){
  889. $detail = $request->input('detail');
  890. $detail['recruit_appoint_id'] = $result->id;
  891. RecruitAppointDetail::create($detail);
  892. }
  893. //如果有身份证明模块
  894. if(in_array('identification',$forms) || in_array('internship',$forms)){
  895. $identification = $request->input('identification');
  896. if(is_array($identification)){
  897. //删除掉没有成功返回路径的图片
  898. foreach ($identification as $k => $v){
  899. if(!array_key_exists('response',$v)){
  900. unset($identification[$k]);
  901. }
  902. }
  903. }
  904. $result->identification = json_encode($identification);
  905. $result->save();
  906. }
  907. //如果有教育证明模块
  908. if(in_array('education_certification',$forms) || in_array('internship',$forms)){
  909. $education_certification = $request->input('education_certification');
  910. if(is_array($education_certification)){
  911. //删除掉没有成功返回路径的图片
  912. foreach ($education_certification as $k => $v){
  913. if(!array_key_exists('response',$v)){
  914. unset($education_certification[$k]);
  915. }
  916. }
  917. }
  918. $result->education_certification = json_encode($education_certification);
  919. $result->save();
  920. }
  921. //如果有其他证明模块
  922. if(in_array('other_certification',$forms) || in_array('internship',$forms)){
  923. $other_certification = $request->input('other_certification');
  924. if($other_certification){
  925. if(is_array($other_certification)){
  926. //删除掉没有成功返回路径的图片
  927. foreach ($other_certification as $k => $v){
  928. if(!array_key_exists('response',$v)){
  929. unset($other_certification[$k]);
  930. }
  931. }
  932. }
  933. $result->other_certification = json_encode($other_certification);
  934. $result->save();
  935. }
  936. }
  937. DB::commit();
  938. if($operation == 2){
  939. $log = [
  940. 'type' => 3,
  941. 'appoint_id'=> $result->id,
  942. 'uid' => $uid,
  943. 'log' => '用户首次提交报名'
  944. ];
  945. RecruitAppointLog::create($log);
  946. return ['status' => 1, 'msg' => '提交成功', 'data' => $result->id];
  947. }else{
  948. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $result->id];
  949. }
  950. } catch (\Exception $e){
  951. DB::rollback();
  952. return ['status' => 0, 'msg' => $e->getMessage()];
  953. }
  954. }
  955. }
  956. }
  957. /**
  958. * 获得当前登录的用户
  959. * @return \Illuminate\Contracts\Auth\Authenticatable|null
  960. */
  961. public function getUser()
  962. {
  963. if (auth('web-member')->check()) {
  964. $user = auth('web-member')->user();
  965. } else {
  966. $user = null;
  967. }
  968. return $user;
  969. }
  970. /**
  971. * 检查用户基本信息
  972. * @return array
  973. */
  974. public function checkUserBasicInfo()
  975. {
  976. $user = $this->getUser();
  977. if (!empty($user)) {
  978. $uid = $user->id;
  979. } else {
  980. $arr = ['status' => 401, 'msg'=>'请登录!'];
  981. return $arr;
  982. }
  983. $info = RecruitAppointBasic::where('uid',$uid)->first();
  984. if (empty($info)){
  985. $arr = ['status'=>401,'msg'=>'请先完善招考基本信息','url'=> route('recruit.recruitInfo')];
  986. return $arr;
  987. }
  988. return ['status' => 200, 'msg' => ''];
  989. }
  990. /**
  991. * 个人中心招考页面
  992. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  993. */
  994. public function person_recruit()
  995. {
  996. $user = auth('web-member')->user();
  997. $list = RecruitAppointInfo::where('uid',$user->id)
  998. ->join('recruit', 'recruit.id', '=', 'recruit_appoint_info.recruit_id', 'left')
  999. ->join('recruit_post', 'recruit_post.id', '=', 'recruit_appoint_info.post_id', 'left')
  1000. ->select('recruit.name as recruit_name','recruit_appoint_info.*','recruit_post.code','recruit_post.name')
  1001. ->get();
  1002. return view('app.person.recruit')->with(['list' => $list,'total' => count($list)]);
  1003. }
  1004. /**
  1005. * 招考信息基础页
  1006. * @param Request $request
  1007. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  1008. */
  1009. public function recruit_info(Request $request)
  1010. {
  1011. $user = auth('web-member')->user();
  1012. $info = RecruitAppointBasic::where('uid',$user->id)->first();
  1013. if(!$info){
  1014. $info = [
  1015. 'realname' => '',
  1016. 'sex' => '0',
  1017. 'birthday' => '',
  1018. 'avatar' => '',
  1019. 'nation' => '',
  1020. 'native_place' => '',
  1021. 'political_affiliation' => '',
  1022. 'titles' => '',
  1023. 'work' => '',
  1024. 'house_register' => '',
  1025. 'join_time' => '',
  1026. 'edu_type' => '',
  1027. 'education' => '',
  1028. 'school' => '',
  1029. 'degree' => '',
  1030. 'pro' => '',
  1031. 'address' => '',
  1032. 'card' => '',
  1033. 'mobile' => '',
  1034. 'email' => '',
  1035. 'concat_name' => '',
  1036. 'concat_mobile' => '',
  1037. 'resume' => '',
  1038. 'family' => [
  1039. [
  1040. 'relation' => '',
  1041. 'realname' => '',
  1042. 'birthday' => '',
  1043. 'political_affiliation' => '',
  1044. 'work' => ''
  1045. ]
  1046. ],
  1047. 'is_push' => '1'
  1048. ];
  1049. }else{
  1050. $info->sex = (string)$info->sex;
  1051. $info->edu_type = (string)$info->edu_type;
  1052. $info->is_push = (string)$info->is_push;
  1053. $info->family = empty($info->family) ? [[
  1054. 'relation' => '',
  1055. 'realname' => '',
  1056. 'birthday' => '',
  1057. 'political_affiliation' => '',
  1058. 'work' => ''
  1059. ]] : json_decode($info->family);
  1060. }
  1061. $recruit_id = $request->input('recruit_id',0);
  1062. return view('app.person.recruit_info',[
  1063. 'info' => json_encode($info),
  1064. 'recruit_id'=> $recruit_id
  1065. ]);
  1066. }
  1067. /**
  1068. * 保存招考信息
  1069. * @param RecruitValidatorRequest $request
  1070. * @return \Illuminate\Http\JsonResponse
  1071. */
  1072. public function saveRecruitInfo(RecruitValidatorRequest $request)
  1073. {
  1074. $user = auth('web-member')->user();
  1075. $basic = RecruitAppointBasic::where('uid',$user->id)->first();
  1076. $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');
  1077. if(count($data['family']) > 0){
  1078. $data['family'] = json_encode($data['family']);
  1079. }
  1080. if($basic){
  1081. //更新基础信息
  1082. $res = RecruitAppointBasic::where('uid',$user->id)->update($data);
  1083. if (!$res) {
  1084. return response()->json(['status'=>0,'msg'=>'保存失败,请联系客服']);
  1085. }else{
  1086. return response()->json(['status'=>1,'msg'=>'个人基础信息保存成功,快去报名吧!']);
  1087. }
  1088. }else{
  1089. //新增基础信息
  1090. $data['uid'] = $user->id;
  1091. $res = RecruitAppointBasic::create($data);
  1092. if (!$res) {
  1093. return response()->json(['status'=>0,'msg'=>'保存失败,请联系客服']);
  1094. }else{
  1095. return response()->json(['status'=>1,'msg'=>'个人基础信息保存成功,快去报名吧!']);
  1096. }
  1097. }
  1098. }
  1099. /**
  1100. * 笔试准考证
  1101. * @param Request $request
  1102. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1103. */
  1104. public function pen_ticket(Request $request)
  1105. {
  1106. $user = $this->getUser();
  1107. if (!empty($user)) {
  1108. $uid = $user->id;
  1109. } else {
  1110. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1111. }
  1112. $recruit_id = $request->input('recruit_id');
  1113. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1114. if($appoint_info){
  1115. $pen_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',1)->first();
  1116. if($pen_ticket){
  1117. $health = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();
  1118. if(!$health || $health->h_status == 0){
  1119. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1120. }
  1121. $time = time();
  1122. if(strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time){
  1123. RecruitTicket::where('appoint_id',$appoint_info->id)->update(['ex_status' => 1]);
  1124. $recruit = Recruit::where('id',$recruit_id)->first();
  1125. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1126. $name = $recruit->name_en;
  1127. $date = date("Y-m-d",strtotime($recruit->created_at));
  1128. $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1129. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/pen/" . $filename . '_create.pdf';
  1130. if(file_exists($file)){
  1131. header('Content-Description: File Transfer');
  1132. header('Content-Type: application/octet-stream');
  1133. header('Content-Disposition: attachment; filename='.basename($file));
  1134. header('Content-Transfer-Encoding: binary');
  1135. header('Expires: 0');
  1136. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1137. header('Pragma: public');
  1138. header('Content-Length: ' . filesize($file));
  1139. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1140. flush();
  1141. readfile($file);
  1142. }
  1143. }else{
  1144. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1145. }
  1146. }else{
  1147. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1148. }
  1149. }else{
  1150. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1151. }
  1152. }
  1153. /**
  1154. * 审核准考证
  1155. * @param Request $request
  1156. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1157. */
  1158. public function check_ticket(Request $request)
  1159. {
  1160. $user = $this->getUser();
  1161. if (!empty($user)) {
  1162. $uid = $user->id;
  1163. } else {
  1164. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1165. }
  1166. $recruit_id = $request->input('recruit_id');
  1167. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1168. if($appoint_info){
  1169. $check_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',2)->first();
  1170. if($check_ticket){
  1171. $time = time();
  1172. if(strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time){
  1173. RecruitTicket::where('appoint_id',$appoint_info->id)->update(['ex_status' => 1]);
  1174. $recruit = Recruit::where('id',$recruit_id)->first();
  1175. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1176. $name = $recruit->name_en;
  1177. $date = date("Y-m-d",strtotime($recruit->created_at));
  1178. $filename = date("Y-m-18",time()) . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1179. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/check/" . $filename . '.pdf';
  1180. if(file_exists($file)){
  1181. header('Content-Description: File Transfer');
  1182. header('Content-Type: application/octet-stream');
  1183. header('Content-Disposition: attachment; filename='.basename($file));
  1184. header('Content-Transfer-Encoding: binary');
  1185. header('Expires: 0');
  1186. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1187. header('Pragma: public');
  1188. header('Content-Length: ' . filesize($file));
  1189. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1190. flush();
  1191. readfile($file);
  1192. }
  1193. }else{
  1194. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1195. }
  1196. }else{
  1197. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1198. }
  1199. }else{
  1200. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1201. }
  1202. }
  1203. /**
  1204. * 面试准考证
  1205. * @param Request $request
  1206. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1207. */
  1208. public function face_ticket(Request $request)
  1209. {
  1210. $user = $this->getUser();
  1211. if (!empty($user)) {
  1212. $uid = $user->id;
  1213. } else {
  1214. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1215. }
  1216. $recruit_id = $request->input('recruit_id');
  1217. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1218. if($appoint_info){
  1219. $face_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',3)->first();
  1220. if($face_ticket){
  1221. $health = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();
  1222. if(!$health || $health->h_status == 0){
  1223. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1224. }
  1225. $time = time();
  1226. if(strtotime($face_ticket->ex_start) < $time && strtotime($face_ticket->ex_end) > $time){
  1227. RecruitTicket::where('id',$face_ticket->id)->update(['ex_status' => 1]);
  1228. $recruit = Recruit::where('id',$recruit_id)->first();
  1229. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1230. $name = $recruit->name_en;
  1231. $date = date("Y-m-d",strtotime($recruit->created_at));
  1232. $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id].'_create';
  1233. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';
  1234. if(file_exists($file)){
  1235. header('Content-Description: File Transfer');
  1236. header('Content-Type: application/octet-stream');
  1237. header('Content-Disposition: attachment; filename='.basename($file));
  1238. header('Content-Transfer-Encoding: binary');
  1239. header('Expires: 0');
  1240. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1241. header('Pragma: public');
  1242. header('Content-Length: ' . filesize($file));
  1243. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1244. flush();
  1245. readfile($file);
  1246. }
  1247. }else{
  1248. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1249. }
  1250. }else{
  1251. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1252. }
  1253. }else{
  1254. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1255. }
  1256. }
  1257. /**
  1258. * 复试准考证
  1259. * @param Request $request
  1260. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1261. */
  1262. public function reexamine_ticket(Request $request)
  1263. {
  1264. $user = $this->getUser();
  1265. if (!empty($user)) {
  1266. $uid = $user->id;
  1267. } else {
  1268. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1269. }
  1270. $recruit_id = $request->input('recruit_id');
  1271. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1272. if($appoint_info){
  1273. $reexamine_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',4)->first();
  1274. if($reexamine_ticket){
  1275. $time = time();
  1276. if(strtotime($reexamine_ticket->ex_start) < $time && strtotime($reexamine_ticket->ex_end) > $time){
  1277. RecruitTicket::where('id',$reexamine_ticket->id)->update(['ex_status' => 1]);
  1278. $recruit = Recruit::where('id',$recruit_id)->first();
  1279. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1280. $name = $recruit->name_en;
  1281. $date = date("Y-m-d",strtotime($recruit->created_at));
  1282. $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id].'_create';
  1283. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';
  1284. if(file_exists($file)){
  1285. header('Content-Description: File Transfer');
  1286. header('Content-Type: application/octet-stream');
  1287. header('Content-Disposition: attachment; filename='.basename($file));
  1288. header('Content-Transfer-Encoding: binary');
  1289. header('Expires: 0');
  1290. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1291. header('Pragma: public');
  1292. header('Content-Length: ' . filesize($file));
  1293. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1294. flush();
  1295. readfile($file);
  1296. }
  1297. }else{
  1298. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1299. }
  1300. }else{
  1301. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1302. }
  1303. }else{
  1304. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1305. }
  1306. }
  1307. /**
  1308. * 材料补登
  1309. * @param Request $request
  1310. */
  1311. public function material_supplement(Request $request)
  1312. {
  1313. $user = $this->getUser();
  1314. if (!empty($user)) {
  1315. $uid = $user->id;
  1316. } else {
  1317. return redirect(route('login'));
  1318. }
  1319. //招考id
  1320. $id = $request->input('id', 0);
  1321. if (!$id) {
  1322. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1323. }
  1324. $recruit = Recruit::find($id);
  1325. if(!$recruit['status'] && !$user->recruit_test){
  1326. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1327. }
  1328. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  1329. if(!$appoint_info){
  1330. return $this->showMessage('抱歉,您没有报名,无需考察审核!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1331. }
  1332. if($appoint_info->pen_audit != 1){
  1333. return $this->showMessage('抱歉,您未入闱,无需考察审核!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1334. }
  1335. $uids = array (
  1336. 0 => '175624',
  1337. 1 => '175637',
  1338. 2 => '173543',
  1339. 3 => '175663',
  1340. 4 => '175628',
  1341. 5 => '159629',
  1342. 6 => '170066',
  1343. 7 => '175826',
  1344. 8 => '175629',
  1345. 9 => '175620',
  1346. 10 => '175738',
  1347. 11 => '175854',
  1348. 12 => '164974',
  1349. 13 => '167931',
  1350. 14 => '175757',
  1351. 15 => '175951',
  1352. 16 => '175893',
  1353. 17 => '175995',
  1354. 18 => '176024',
  1355. 19 => '176044',
  1356. 20 => '169828',
  1357. 21 => '152230',
  1358. 22 => '176147',
  1359. 23 => '176144',
  1360. 24 => '176189',
  1361. 25 => '169518',
  1362. 26 => '175925',
  1363. 27 => '176327',
  1364. 28 => '176347',
  1365. 29 => '176349',
  1366. 30 => '176407',
  1367. 31 => '170378',
  1368. 32 => '176463',
  1369. 33 => '176457',
  1370. 34 => '169219',
  1371. 35 => '169285',
  1372. 36 => '163039',
  1373. 37 => '176545',
  1374. 38 => '176551',
  1375. 39 => '169814',
  1376. 40 => '175847',
  1377. 41 => '175755',
  1378. 42 => '169240',
  1379. 43 => '176669',
  1380. 44 => '176605',
  1381. 45 => '176807',
  1382. 46 => '169917',
  1383. 47 => '176888',
  1384. 48 => '176578',
  1385. 49 => '176681',
  1386. 50 => '148287',
  1387. 51 => '176511',
  1388. 52 => '176946',
  1389. 53 => '176922',
  1390. 54 => '176955',
  1391. 55 => '167385',
  1392. 56 => '176971',
  1393. 57 => '176969',
  1394. 58 => '176984',
  1395. 59 => '169932',
  1396. 60 => '176250',
  1397. 61 => '149243',
  1398. 62 => '177026',
  1399. 63 => '169607',
  1400. 64 => '150162',
  1401. 65 => '177055',
  1402. 66 => '177061',
  1403. 67 => '177056',
  1404. 68 => '169761',
  1405. 69 => '177096',
  1406. 70 => '177118',
  1407. 71 => '177102',
  1408. 72 => '159073',
  1409. 73 => '177119',
  1410. 74 => '169641',
  1411. 75 => '177158',
  1412. 76 => '177128',
  1413. 77 => '170175',
  1414. 78 => '170822',
  1415. 79 => '177193',
  1416. 80 => '177234',
  1417. 81 => '177251',
  1418. 82 => '168964',
  1419. 83 => '176034',
  1420. 84 => '150532',
  1421. 85 => '168487',
  1422. 86 => '177304',
  1423. 87 => '170441',
  1424. 88 => '177262',
  1425. 89 => '177342',
  1426. 90 => '177356',
  1427. 91 => '170376',
  1428. 92 => '177316',
  1429. 93 => '177361',
  1430. 94 => '177170',
  1431. 95 => '171720',
  1432. 96 => '176736',
  1433. );
  1434. $limit_time = 1654078200;
  1435. if(in_array($uid,$uids)){
  1436. $limit_time = 1654164000;
  1437. }
  1438. $time = time();
  1439. if( $time > $limit_time){
  1440. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1441. }
  1442. $info = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();
  1443. if(!$info){
  1444. $info = [
  1445. 'appoint_id' => $appoint_info->id,
  1446. 'identification' => '',
  1447. 'household_register' => '',
  1448. 'education_certification' => '',
  1449. //'family_planning' => '',
  1450. 'manage' => '',
  1451. 'status' => 3
  1452. ];
  1453. }else{
  1454. $info = $info->toArray();
  1455. if(json_decode($info['identification'])){
  1456. $identification = json_decode($info['identification'],true);
  1457. foreach ($identification as $k => $v){
  1458. if(array_key_exists('response',$v)){
  1459. $identification[$k]['url'] = $v['response']['path'];
  1460. }
  1461. }
  1462. }else{
  1463. $identification = [];
  1464. }
  1465. $info['identification'] = $identification;
  1466. if(json_decode($info['household_register'])){
  1467. $household_register = json_decode($info['household_register'],true);
  1468. foreach ($household_register as $k => $v){
  1469. if(array_key_exists('response',$v)){
  1470. $household_register[$k]['url'] = $v['response']['path'];
  1471. }
  1472. }
  1473. }else{
  1474. $household_register = [];
  1475. }
  1476. $info['household_register'] = $household_register;
  1477. if(json_decode($info['education_certification'])){
  1478. $education_certification = json_decode($info['education_certification'],true);
  1479. foreach ($education_certification as $k => $v){
  1480. if(array_key_exists('response',$v)){
  1481. $education_certification[$k]['url'] = $v['response']['path'];
  1482. }
  1483. }
  1484. }else{
  1485. $education_certification = [];
  1486. }
  1487. $info['education_certification'] = $education_certification;
  1488. if(json_decode($info['family_planning'])){
  1489. $family_planning = json_decode($info['family_planning'],true);
  1490. foreach ($family_planning as $k => $v){
  1491. if(array_key_exists('response',$v)){
  1492. $family_planning[$k]['url'] = $v['response']['path'];
  1493. }
  1494. }
  1495. }else{
  1496. $family_planning = [];
  1497. }
  1498. $info['family_planning'] = $family_planning;
  1499. if(json_decode($info['manage'])){
  1500. $manage = json_decode($info['manage'],true);
  1501. foreach ($manage as $k => $v){
  1502. if(array_key_exists('response',$v)){
  1503. $manage[$k]['url'] = $v['response']['path'];
  1504. }
  1505. }
  1506. }else{
  1507. $manage = [];
  1508. }
  1509. $info['manage'] = $manage;
  1510. }
  1511. $view_data['info'] = json_encode($info);
  1512. $view_data['title'] = $recruit->company;
  1513. return view('app.recruit.supplement',$view_data);
  1514. }
  1515. /**
  1516. * 健康信息登记
  1517. * @param Request $request
  1518. */
  1519. public function health_info(Request $request)
  1520. {
  1521. $user = $this->getUser();
  1522. if (!empty($user)) {
  1523. $uid = $user->id;
  1524. } else {
  1525. return redirect(route('login'));
  1526. }
  1527. //招考id
  1528. $id = $request->input('id', 0);
  1529. if (!$id) {
  1530. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1531. }
  1532. $recruit = Recruit::find($id);
  1533. if(!$recruit['status'] && !$user->recruit_test){
  1534. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1535. }
  1536. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  1537. if(!$appoint_info){
  1538. return $this->showMessage('抱歉,您没有报名,无需登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1539. }
  1540. if($appoint_info->audit != 3){
  1541. return $this->showMessage('抱歉,您无需登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1542. }
  1543. $time = time();
  1544. if($time > 1655438400){//手动截止
  1545. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1546. }
  1547. $info = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();
  1548. if(!$info){
  1549. $info = [
  1550. 'appoint_id' => $appoint_info->id,
  1551. 'health_code' => '',
  1552. 'trip_code' => ''
  1553. ];
  1554. }else{
  1555. $info = $info->toArray();
  1556. if(json_decode($info['health_code'])){
  1557. $health_code = json_decode($info['health_code'],true);
  1558. foreach ($health_code as $k => $v){
  1559. if(array_key_exists('response',$v)){
  1560. $health_code[$k]['url'] = $v['response']['path'];
  1561. }
  1562. }
  1563. }else{
  1564. $health_code = [];
  1565. }
  1566. $info['health_code'] = $health_code;
  1567. if(json_decode($info['trip_code'])){
  1568. $trip_code = json_decode($info['trip_code'],true);
  1569. foreach ($trip_code as $k => $v){
  1570. if(array_key_exists('response',$v)){
  1571. $trip_code[$k]['url'] = $v['response']['path'];
  1572. }
  1573. }
  1574. }else{
  1575. $trip_code = [];
  1576. }
  1577. $info['trip_code'] = $trip_code;
  1578. }
  1579. $view_data['info'] = json_encode($info);
  1580. $view_data['title'] = $recruit->company;
  1581. return view('app.recruit.health',$view_data);
  1582. }
  1583. public function save_supplement(Request $request)
  1584. {
  1585. $user = $this->getUser();
  1586. if (!empty($user)) {
  1587. $uid = $user->id;
  1588. } else {
  1589. return redirect(route('login'));
  1590. }
  1591. $appoint_id = $request->input('appoint_id');
  1592. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',16)->where('id',$appoint_id)->first();
  1593. if(!$appoint_info){
  1594. return ['status' => 0, 'msg' => '抱歉,找不到您要补登的报名记录!'];
  1595. }
  1596. $info = RecruitSupplement::where('appoint_id',$appoint_id)->first();
  1597. if($info){
  1598. if($info->status == 1){
  1599. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  1600. }
  1601. if($info->status == 0){
  1602. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  1603. }
  1604. //身份证明
  1605. $identification = $request->input('identification');
  1606. if(is_array($identification)){
  1607. //删除掉没有成功返回路径的图片
  1608. foreach ($identification as $k => $v){
  1609. if(!array_key_exists('response',$v)){
  1610. unset($identification[$k]);
  1611. }
  1612. }
  1613. }
  1614. $info->identification = json_encode($identification);
  1615. //户口簿
  1616. $household_register = $request->input('household_register');
  1617. if(is_array($household_register)){
  1618. //删除掉没有成功返回路径的图片
  1619. foreach ($household_register as $k => $v){
  1620. if(!array_key_exists('response',$v)){
  1621. unset($household_register[$k]);
  1622. }
  1623. }
  1624. }
  1625. $info->household_register = json_encode($household_register);
  1626. //学信网
  1627. $education_certification = $request->input('education_certification');
  1628. if(is_array($education_certification)){
  1629. //删除掉没有成功返回路径的图片
  1630. foreach ($education_certification as $k => $v){
  1631. if(!array_key_exists('response',$v)){
  1632. unset($education_certification[$k]);
  1633. }
  1634. }
  1635. }
  1636. $info->education_certification = json_encode($education_certification);
  1637. //计生
  1638. // $family_planning = $request->input('family_planning');
  1639. // if(is_array($family_planning)){
  1640. // //删除掉没有成功返回路径的图片
  1641. // foreach ($family_planning as $k => $v){
  1642. // if(!array_key_exists('response',$v)){
  1643. // unset($family_planning[$k]);
  1644. // }
  1645. // }
  1646. // }
  1647. // $info->family_planning = json_encode($family_planning);
  1648. //综治
  1649. $manage = $request->input('manage');
  1650. if(is_array($manage)){
  1651. //删除掉没有成功返回路径的图片
  1652. foreach ($manage as $k => $v){
  1653. if(!array_key_exists('response',$v)){
  1654. unset($manage[$k]);
  1655. }
  1656. }
  1657. }
  1658. $info->manage = json_encode($manage);
  1659. $info->status = 0;
  1660. $info->save();
  1661. $appoint_info->political_audit = 4;
  1662. $appoint_info->save();
  1663. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1664. }else{
  1665. $data['appoint_id'] = $appoint_id;
  1666. //身份证明
  1667. $identification = $request->input('identification');
  1668. if(is_array($identification)){
  1669. //删除掉没有成功返回路径的图片
  1670. foreach ($identification as $k => $v){
  1671. if(!array_key_exists('response',$v)){
  1672. unset($identification[$k]);
  1673. }
  1674. }
  1675. }
  1676. $data['identification'] = json_encode($identification);
  1677. //户口簿
  1678. $household_register = $request->input('household_register');
  1679. if(is_array($household_register)){
  1680. //删除掉没有成功返回路径的图片
  1681. foreach ($household_register as $k => $v){
  1682. if(!array_key_exists('response',$v)){
  1683. unset($household_register[$k]);
  1684. }
  1685. }
  1686. }
  1687. $data['household_register'] = json_encode($household_register);
  1688. //学信网
  1689. $education_certification = $request->input('education_certification');
  1690. if(is_array($education_certification)){
  1691. //删除掉没有成功返回路径的图片
  1692. foreach ($education_certification as $k => $v){
  1693. if(!array_key_exists('response',$v)){
  1694. unset($education_certification[$k]);
  1695. }
  1696. }
  1697. }
  1698. $data['education_certification'] = json_encode($education_certification);
  1699. //计生
  1700. // $family_planning = $request->input('family_planning');
  1701. // if(is_array($family_planning)){sp
  1702. // //删除掉没有成功返回路径的图片
  1703. // foreach ($family_planning as $k => $v){
  1704. // if(!array_key_exists('response',$v)){
  1705. // unset($family_planning[$k]);
  1706. // }
  1707. // }
  1708. // }
  1709. // $data['family_planning'] = json_encode($family_planning);
  1710. //综治
  1711. $manage = $request->input('manage');
  1712. if(is_array($manage)){
  1713. //删除掉没有成功返回路径的图片
  1714. foreach ($manage as $k => $v){
  1715. if(!array_key_exists('response',$v)){
  1716. unset($manage[$k]);
  1717. }
  1718. }
  1719. }
  1720. $data['manage'] = json_encode($manage);
  1721. $data['status'] = 0;
  1722. $result = RecruitSupplement::create($data);
  1723. $appoint_info->political_audit = 4;
  1724. $appoint_info->save();
  1725. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1726. }
  1727. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  1728. }
  1729. public function save_healthinfo(Request $request)
  1730. {
  1731. $user = $this->getUser();
  1732. if (!empty($user)) {
  1733. $uid = $user->id;
  1734. } else {
  1735. return redirect(route('login'));
  1736. }
  1737. $appoint_id = $request->input('appoint_id');
  1738. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('id',$appoint_id)->first();
  1739. if(!$appoint_info){
  1740. return ['status' => 0, 'msg' => '抱歉,找不到您要登记的报名记录!'];
  1741. }
  1742. $info = RecruitSupplement::where('appoint_id',$appoint_id)->first();
  1743. if($info){
  1744. if($info->h_status == 1){
  1745. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  1746. }
  1747. if($info->h_status == 0){
  1748. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  1749. }
  1750. $health_code = $request->input('health_code');
  1751. if(is_array($health_code)){
  1752. //删除掉没有成功返回路径的图片
  1753. foreach ($health_code as $k => $v){
  1754. if(!array_key_exists('response',$v)){
  1755. unset($health_code[$k]);
  1756. }
  1757. }
  1758. }
  1759. $info->health_code = json_encode($health_code);
  1760. $trip_code = $request->input('trip_code');
  1761. if(is_array($trip_code)){
  1762. //删除掉没有成功返回路径的图片
  1763. foreach ($trip_code as $k => $v){
  1764. if(!array_key_exists('response',$v)){
  1765. unset($trip_code[$k]);
  1766. }
  1767. }
  1768. }
  1769. $info->trip_code = json_encode($trip_code);
  1770. $info->save();
  1771. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1772. }else{
  1773. $data['appoint_id'] = $appoint_id;
  1774. $health_code = $request->input('health_code');
  1775. if(is_array($health_code)){
  1776. //删除掉没有成功返回路径的图片
  1777. foreach ($health_code as $k => $v){
  1778. if(!array_key_exists('response',$v)){
  1779. unset($health_code[$k]);
  1780. }
  1781. }
  1782. }
  1783. $data['health_code'] = json_encode($health_code);
  1784. $trip_code = $request->input('trip_code');
  1785. if(is_array($trip_code)){
  1786. //删除掉没有成功返回路径的图片
  1787. foreach ($trip_code as $k => $v){
  1788. if(!array_key_exists('response',$v)){
  1789. unset($trip_code[$k]);
  1790. }
  1791. }
  1792. }
  1793. $data['trip_code'] = json_encode($trip_code);
  1794. $data['h_status'] = 0;
  1795. RecruitSupplement::create($data);
  1796. $appoint_info->health_audit = 4;
  1797. $appoint_info->save();
  1798. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1799. }
  1800. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  1801. }
  1802. public function interviewer_random(Request $request)
  1803. {
  1804. $model = $request->input('model',1);
  1805. $number1 = $request->input('number1',5);//考官人数
  1806. $number2 = $request->input('number2',1);//替补人数
  1807. $where[] = ['id','>',0];
  1808. switch ($model){
  1809. case '0':
  1810. $list = DB::table('recruit_interviewer')->get()->toArray();
  1811. shuffle($list);
  1812. $result = array_slice($list, 0, $number1+$number2);
  1813. break;
  1814. case '1':
  1815. $list = DB::table('recruit_interviewer')->get()->toArray();
  1816. shuffle($list);
  1817. $count = $number1;
  1818. for ($i = 0; $i < $count; $i++){
  1819. if(!$list[$i]->status){
  1820. $list[] = $list[$i];
  1821. unset($list[$i]);
  1822. $count++;
  1823. }
  1824. }
  1825. $result = array_slice($list, 0, $number1+$number2);
  1826. break;
  1827. case '2':
  1828. $list = DB::table('recruit_interviewer')->where('status',1)->get()->toArray();
  1829. shuffle($list);
  1830. $result = array_slice($list, 0, $number1+$number2);
  1831. break;
  1832. default:
  1833. $list = DB::table('recruit_interviewer')->get()->toArray();
  1834. shuffle($list);
  1835. for ($i = 0; $i < $number1; $i++){
  1836. dd($list[$i]);
  1837. if(!$list[$i]->status){
  1838. $list[] = $list[$i];
  1839. unset($list[$i]);
  1840. }
  1841. }
  1842. $result = array_slice($list, 0, $number1+$number2);
  1843. break;
  1844. }
  1845. $return_data = [
  1846. 'list' => $result,
  1847. 'number1' => $number1,
  1848. 'number2' => $number2
  1849. ];
  1850. return view('app.recruit.interviewer', $return_data);
  1851. }
  1852. }