IndexController.php 86 KB

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