IndexController.php 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956
  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. $time = time();
  1222. if(strtotime($face_ticket->ex_start) < $time && strtotime($face_ticket->ex_end) > $time){
  1223. RecruitTicket::where('id',$face_ticket->id)->update(['ex_status' => 1]);
  1224. $recruit = Recruit::where('id',$recruit_id)->first();
  1225. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1226. $name = $recruit->name_en;
  1227. $date = date("Y-m-d",strtotime($recruit->created_at));
  1228. $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id].'_create';
  1229. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';
  1230. if(file_exists($file)){
  1231. header('Content-Description: File Transfer');
  1232. header('Content-Type: application/octet-stream');
  1233. header('Content-Disposition: attachment; filename='.basename($file));
  1234. header('Content-Transfer-Encoding: binary');
  1235. header('Expires: 0');
  1236. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1237. header('Pragma: public');
  1238. header('Content-Length: ' . filesize($file));
  1239. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1240. flush();
  1241. readfile($file);
  1242. }
  1243. }else{
  1244. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1245. }
  1246. }else{
  1247. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1248. }
  1249. }else{
  1250. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1251. }
  1252. }
  1253. /**
  1254. * 复试准考证
  1255. * @param Request $request
  1256. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1257. */
  1258. public function reexamine_ticket(Request $request)
  1259. {
  1260. $user = $this->getUser();
  1261. if (!empty($user)) {
  1262. $uid = $user->id;
  1263. } else {
  1264. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1265. }
  1266. $recruit_id = $request->input('recruit_id');
  1267. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1268. if($appoint_info){
  1269. $reexamine_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',4)->first();
  1270. if($reexamine_ticket){
  1271. $time = time();
  1272. if(strtotime($reexamine_ticket->ex_start) < $time && strtotime($reexamine_ticket->ex_end) > $time){
  1273. RecruitTicket::where('id',$reexamine_ticket->id)->update(['ex_status' => 1]);
  1274. $recruit = Recruit::where('id',$recruit_id)->first();
  1275. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1276. $name = $recruit->name_en;
  1277. $date = date("Y-m-d",strtotime($recruit->created_at));
  1278. $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id].'_create';
  1279. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';
  1280. if(file_exists($file)){
  1281. header('Content-Description: File Transfer');
  1282. header('Content-Type: application/octet-stream');
  1283. header('Content-Disposition: attachment; filename='.basename($file));
  1284. header('Content-Transfer-Encoding: binary');
  1285. header('Expires: 0');
  1286. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1287. header('Pragma: public');
  1288. header('Content-Length: ' . filesize($file));
  1289. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1290. flush();
  1291. readfile($file);
  1292. }
  1293. }else{
  1294. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1295. }
  1296. }else{
  1297. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1298. }
  1299. }else{
  1300. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1301. }
  1302. }
  1303. /**
  1304. * 材料补登
  1305. * @param Request $request
  1306. */
  1307. public function material_supplement(Request $request)
  1308. {
  1309. $user = $this->getUser();
  1310. if (!empty($user)) {
  1311. $uid = $user->id;
  1312. } else {
  1313. return redirect(route('login'));
  1314. }
  1315. //招考id
  1316. $id = $request->input('id', 0);
  1317. if (!$id) {
  1318. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1319. }
  1320. $recruit = Recruit::find($id);
  1321. if(!$recruit['status'] && !$user->recruit_test){
  1322. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1323. }
  1324. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  1325. if(!$appoint_info){
  1326. return $this->showMessage('抱歉,您没有报名,无需考察审核!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1327. }
  1328. if($appoint_info->pen_audit != 1){
  1329. return $this->showMessage('抱歉,您未入闱,无需考察审核!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1330. }
  1331. $uids = array (
  1332. 0 => '175624',
  1333. 1 => '175637',
  1334. 2 => '173543',
  1335. 3 => '175663',
  1336. 4 => '175628',
  1337. 5 => '159629',
  1338. 6 => '170066',
  1339. 7 => '175826',
  1340. 8 => '175629',
  1341. 9 => '175620',
  1342. 10 => '175738',
  1343. 11 => '175854',
  1344. 12 => '164974',
  1345. 13 => '167931',
  1346. 14 => '175757',
  1347. 15 => '175951',
  1348. 16 => '175893',
  1349. 17 => '175995',
  1350. 18 => '176024',
  1351. 19 => '176044',
  1352. 20 => '169828',
  1353. 21 => '152230',
  1354. 22 => '176147',
  1355. 23 => '176144',
  1356. 24 => '176189',
  1357. 25 => '169518',
  1358. 26 => '175925',
  1359. 27 => '176327',
  1360. 28 => '176347',
  1361. 29 => '176349',
  1362. 30 => '176407',
  1363. 31 => '170378',
  1364. 32 => '176463',
  1365. 33 => '176457',
  1366. 34 => '169219',
  1367. 35 => '169285',
  1368. 36 => '163039',
  1369. 37 => '176545',
  1370. 38 => '176551',
  1371. 39 => '169814',
  1372. 40 => '175847',
  1373. 41 => '175755',
  1374. 42 => '169240',
  1375. 43 => '176669',
  1376. 44 => '176605',
  1377. 45 => '176807',
  1378. 46 => '169917',
  1379. 47 => '176888',
  1380. 48 => '176578',
  1381. 49 => '176681',
  1382. 50 => '148287',
  1383. 51 => '176511',
  1384. 52 => '176946',
  1385. 53 => '176922',
  1386. 54 => '176955',
  1387. 55 => '167385',
  1388. 56 => '176971',
  1389. 57 => '176969',
  1390. 58 => '176984',
  1391. 59 => '169932',
  1392. 60 => '176250',
  1393. 61 => '149243',
  1394. 62 => '177026',
  1395. 63 => '169607',
  1396. 64 => '150162',
  1397. 65 => '177055',
  1398. 66 => '177061',
  1399. 67 => '177056',
  1400. 68 => '169761',
  1401. 69 => '177096',
  1402. 70 => '177118',
  1403. 71 => '177102',
  1404. 72 => '159073',
  1405. 73 => '177119',
  1406. 74 => '169641',
  1407. 75 => '177158',
  1408. 76 => '177128',
  1409. 77 => '170175',
  1410. 78 => '170822',
  1411. 79 => '177193',
  1412. 80 => '177234',
  1413. 81 => '177251',
  1414. 82 => '168964',
  1415. 83 => '176034',
  1416. 84 => '150532',
  1417. 85 => '168487',
  1418. 86 => '177304',
  1419. 87 => '170441',
  1420. 88 => '177262',
  1421. 89 => '177342',
  1422. 90 => '177356',
  1423. 91 => '170376',
  1424. 92 => '177316',
  1425. 93 => '177361',
  1426. 94 => '177170',
  1427. 95 => '171720',
  1428. 96 => '176736',
  1429. );
  1430. $limit_time = 1654078200;
  1431. if(in_array($uid,$uids)){
  1432. $limit_time = 1654164000;
  1433. }
  1434. $time = time();
  1435. if( $time > $limit_time){
  1436. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1437. }
  1438. $info = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();
  1439. if(!$info){
  1440. $info = [
  1441. 'appoint_id' => $appoint_info->id,
  1442. 'identification' => '',
  1443. 'household_register' => '',
  1444. 'education_certification' => '',
  1445. //'family_planning' => '',
  1446. 'manage' => '',
  1447. 'status' => 3
  1448. ];
  1449. }else{
  1450. $info = $info->toArray();
  1451. if(json_decode($info['identification'])){
  1452. $identification = json_decode($info['identification'],true);
  1453. foreach ($identification as $k => $v){
  1454. if(array_key_exists('response',$v)){
  1455. $identification[$k]['url'] = $v['response']['path'];
  1456. }
  1457. }
  1458. }else{
  1459. $identification = [];
  1460. }
  1461. $info['identification'] = $identification;
  1462. if(json_decode($info['household_register'])){
  1463. $household_register = json_decode($info['household_register'],true);
  1464. foreach ($household_register as $k => $v){
  1465. if(array_key_exists('response',$v)){
  1466. $household_register[$k]['url'] = $v['response']['path'];
  1467. }
  1468. }
  1469. }else{
  1470. $household_register = [];
  1471. }
  1472. $info['household_register'] = $household_register;
  1473. if(json_decode($info['education_certification'])){
  1474. $education_certification = json_decode($info['education_certification'],true);
  1475. foreach ($education_certification as $k => $v){
  1476. if(array_key_exists('response',$v)){
  1477. $education_certification[$k]['url'] = $v['response']['path'];
  1478. }
  1479. }
  1480. }else{
  1481. $education_certification = [];
  1482. }
  1483. $info['education_certification'] = $education_certification;
  1484. if(json_decode($info['family_planning'])){
  1485. $family_planning = json_decode($info['family_planning'],true);
  1486. foreach ($family_planning as $k => $v){
  1487. if(array_key_exists('response',$v)){
  1488. $family_planning[$k]['url'] = $v['response']['path'];
  1489. }
  1490. }
  1491. }else{
  1492. $family_planning = [];
  1493. }
  1494. $info['family_planning'] = $family_planning;
  1495. if(json_decode($info['manage'])){
  1496. $manage = json_decode($info['manage'],true);
  1497. foreach ($manage as $k => $v){
  1498. if(array_key_exists('response',$v)){
  1499. $manage[$k]['url'] = $v['response']['path'];
  1500. }
  1501. }
  1502. }else{
  1503. $manage = [];
  1504. }
  1505. $info['manage'] = $manage;
  1506. }
  1507. $view_data['info'] = json_encode($info);
  1508. $view_data['title'] = $recruit->company;
  1509. return view('app.recruit.supplement',$view_data);
  1510. }
  1511. /**
  1512. * 健康信息登记
  1513. * @param Request $request
  1514. */
  1515. public function health_info(Request $request)
  1516. {
  1517. $user = $this->getUser();
  1518. if (!empty($user)) {
  1519. $uid = $user->id;
  1520. } else {
  1521. return redirect(route('login'));
  1522. }
  1523. //招考id
  1524. $id = $request->input('id', 0);
  1525. if (!$id) {
  1526. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1527. }
  1528. $recruit = Recruit::find($id);
  1529. if(!$recruit['status'] && !$user->recruit_test){
  1530. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1531. }
  1532. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  1533. if(!$appoint_info){
  1534. return $this->showMessage('抱歉,您没有报名,无需登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1535. }
  1536. if($appoint_info->audit != 3){
  1537. return $this->showMessage('抱歉,您无需登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1538. }
  1539. $time = time();
  1540. if($time > 1654830000){//手动截止
  1541. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1542. }
  1543. $info = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();
  1544. if(!$info){
  1545. $info = [
  1546. 'appoint_id' => $appoint_info->id,
  1547. 'health_code' => '',
  1548. 'trip_code' => ''
  1549. ];
  1550. }else{
  1551. $info = $info->toArray();
  1552. if(json_decode($info['health_code'])){
  1553. $health_code = json_decode($info['health_code'],true);
  1554. foreach ($health_code as $k => $v){
  1555. if(array_key_exists('response',$v)){
  1556. $health_code[$k]['url'] = $v['response']['path'];
  1557. }
  1558. }
  1559. }else{
  1560. $health_code = [];
  1561. }
  1562. $info['health_code'] = $health_code;
  1563. if(json_decode($info['trip_code'])){
  1564. $trip_code = json_decode($info['trip_code'],true);
  1565. foreach ($trip_code as $k => $v){
  1566. if(array_key_exists('response',$v)){
  1567. $trip_code[$k]['url'] = $v['response']['path'];
  1568. }
  1569. }
  1570. }else{
  1571. $trip_code = [];
  1572. }
  1573. $info['trip_code'] = $trip_code;
  1574. }
  1575. $view_data['info'] = json_encode($info);
  1576. $view_data['title'] = $recruit->company;
  1577. return view('app.recruit.health',$view_data);
  1578. }
  1579. public function save_supplement(Request $request)
  1580. {
  1581. $user = $this->getUser();
  1582. if (!empty($user)) {
  1583. $uid = $user->id;
  1584. } else {
  1585. return redirect(route('login'));
  1586. }
  1587. $appoint_id = $request->input('appoint_id');
  1588. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',16)->where('id',$appoint_id)->first();
  1589. if(!$appoint_info){
  1590. return ['status' => 0, 'msg' => '抱歉,找不到您要补登的报名记录!'];
  1591. }
  1592. $info = RecruitSupplement::where('appoint_id',$appoint_id)->first();
  1593. if($info){
  1594. if($info->status == 1){
  1595. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  1596. }
  1597. if($info->status == 0){
  1598. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  1599. }
  1600. //身份证明
  1601. $identification = $request->input('identification');
  1602. if(is_array($identification)){
  1603. //删除掉没有成功返回路径的图片
  1604. foreach ($identification as $k => $v){
  1605. if(!array_key_exists('response',$v)){
  1606. unset($identification[$k]);
  1607. }
  1608. }
  1609. }
  1610. $info->identification = json_encode($identification);
  1611. //户口簿
  1612. $household_register = $request->input('household_register');
  1613. if(is_array($household_register)){
  1614. //删除掉没有成功返回路径的图片
  1615. foreach ($household_register as $k => $v){
  1616. if(!array_key_exists('response',$v)){
  1617. unset($household_register[$k]);
  1618. }
  1619. }
  1620. }
  1621. $info->household_register = json_encode($household_register);
  1622. //学信网
  1623. $education_certification = $request->input('education_certification');
  1624. if(is_array($education_certification)){
  1625. //删除掉没有成功返回路径的图片
  1626. foreach ($education_certification as $k => $v){
  1627. if(!array_key_exists('response',$v)){
  1628. unset($education_certification[$k]);
  1629. }
  1630. }
  1631. }
  1632. $info->education_certification = json_encode($education_certification);
  1633. //计生
  1634. // $family_planning = $request->input('family_planning');
  1635. // if(is_array($family_planning)){
  1636. // //删除掉没有成功返回路径的图片
  1637. // foreach ($family_planning as $k => $v){
  1638. // if(!array_key_exists('response',$v)){
  1639. // unset($family_planning[$k]);
  1640. // }
  1641. // }
  1642. // }
  1643. // $info->family_planning = json_encode($family_planning);
  1644. //综治
  1645. $manage = $request->input('manage');
  1646. if(is_array($manage)){
  1647. //删除掉没有成功返回路径的图片
  1648. foreach ($manage as $k => $v){
  1649. if(!array_key_exists('response',$v)){
  1650. unset($manage[$k]);
  1651. }
  1652. }
  1653. }
  1654. $info->manage = json_encode($manage);
  1655. $info->status = 0;
  1656. $info->save();
  1657. $appoint_info->political_audit = 4;
  1658. $appoint_info->save();
  1659. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1660. }else{
  1661. $data['appoint_id'] = $appoint_id;
  1662. //身份证明
  1663. $identification = $request->input('identification');
  1664. if(is_array($identification)){
  1665. //删除掉没有成功返回路径的图片
  1666. foreach ($identification as $k => $v){
  1667. if(!array_key_exists('response',$v)){
  1668. unset($identification[$k]);
  1669. }
  1670. }
  1671. }
  1672. $data['identification'] = json_encode($identification);
  1673. //户口簿
  1674. $household_register = $request->input('household_register');
  1675. if(is_array($household_register)){
  1676. //删除掉没有成功返回路径的图片
  1677. foreach ($household_register as $k => $v){
  1678. if(!array_key_exists('response',$v)){
  1679. unset($household_register[$k]);
  1680. }
  1681. }
  1682. }
  1683. $data['household_register'] = json_encode($household_register);
  1684. //学信网
  1685. $education_certification = $request->input('education_certification');
  1686. if(is_array($education_certification)){
  1687. //删除掉没有成功返回路径的图片
  1688. foreach ($education_certification as $k => $v){
  1689. if(!array_key_exists('response',$v)){
  1690. unset($education_certification[$k]);
  1691. }
  1692. }
  1693. }
  1694. $data['education_certification'] = json_encode($education_certification);
  1695. //计生
  1696. // $family_planning = $request->input('family_planning');
  1697. // if(is_array($family_planning)){sp
  1698. // //删除掉没有成功返回路径的图片
  1699. // foreach ($family_planning as $k => $v){
  1700. // if(!array_key_exists('response',$v)){
  1701. // unset($family_planning[$k]);
  1702. // }
  1703. // }
  1704. // }
  1705. // $data['family_planning'] = json_encode($family_planning);
  1706. //综治
  1707. $manage = $request->input('manage');
  1708. if(is_array($manage)){
  1709. //删除掉没有成功返回路径的图片
  1710. foreach ($manage as $k => $v){
  1711. if(!array_key_exists('response',$v)){
  1712. unset($manage[$k]);
  1713. }
  1714. }
  1715. }
  1716. $data['manage'] = json_encode($manage);
  1717. $data['status'] = 0;
  1718. $result = RecruitSupplement::create($data);
  1719. $appoint_info->political_audit = 4;
  1720. $appoint_info->save();
  1721. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1722. }
  1723. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  1724. }
  1725. public function save_healthinfo(Request $request)
  1726. {
  1727. $user = $this->getUser();
  1728. if (!empty($user)) {
  1729. $uid = $user->id;
  1730. } else {
  1731. return redirect(route('login'));
  1732. }
  1733. $appoint_id = $request->input('appoint_id');
  1734. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('id',$appoint_id)->first();
  1735. if(!$appoint_info){
  1736. return ['status' => 0, 'msg' => '抱歉,找不到您要登记的报名记录!'];
  1737. }
  1738. $info = RecruitSupplement::where('appoint_id',$appoint_id)->first();
  1739. if($info){
  1740. if($info->h_status == 1){
  1741. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  1742. }
  1743. if($info->h_status == 0){
  1744. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  1745. }
  1746. $health_code = $request->input('health_code');
  1747. if(is_array($health_code)){
  1748. //删除掉没有成功返回路径的图片
  1749. foreach ($health_code as $k => $v){
  1750. if(!array_key_exists('response',$v)){
  1751. unset($health_code[$k]);
  1752. }
  1753. }
  1754. }
  1755. $info->health_code = json_encode($health_code);
  1756. $trip_code = $request->input('trip_code');
  1757. if(is_array($trip_code)){
  1758. //删除掉没有成功返回路径的图片
  1759. foreach ($trip_code as $k => $v){
  1760. if(!array_key_exists('response',$v)){
  1761. unset($trip_code[$k]);
  1762. }
  1763. }
  1764. }
  1765. $info->trip_code = json_encode($trip_code);
  1766. $info->save();
  1767. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1768. }else{
  1769. $data['appoint_id'] = $appoint_id;
  1770. $health_code = $request->input('health_code');
  1771. if(is_array($health_code)){
  1772. //删除掉没有成功返回路径的图片
  1773. foreach ($health_code as $k => $v){
  1774. if(!array_key_exists('response',$v)){
  1775. unset($health_code[$k]);
  1776. }
  1777. }
  1778. }
  1779. $data['health_code'] = json_encode($health_code);
  1780. $trip_code = $request->input('trip_code');
  1781. if(is_array($trip_code)){
  1782. //删除掉没有成功返回路径的图片
  1783. foreach ($trip_code as $k => $v){
  1784. if(!array_key_exists('response',$v)){
  1785. unset($trip_code[$k]);
  1786. }
  1787. }
  1788. }
  1789. $data['trip_code'] = json_encode($trip_code);
  1790. $data['h_status'] = 0;
  1791. RecruitSupplement::create($data);
  1792. $appoint_info->health_audit = 4;
  1793. $appoint_info->save();
  1794. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1795. }
  1796. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  1797. }
  1798. public function interviewer_random(Request $request)
  1799. {
  1800. $model = $request->input('model',1);
  1801. $number1 = $request->input('number1',5);//考官人数
  1802. $number2 = $request->input('number2',1);//替补人数
  1803. $where[] = ['id','>',0];
  1804. switch ($model){
  1805. case '0':
  1806. $list = DB::table('recruit_interviewer')->get()->toArray();
  1807. shuffle($list);
  1808. $result = array_slice($list, 0, $number1+$number2);
  1809. break;
  1810. case '1':
  1811. $list = DB::table('recruit_interviewer')->get()->toArray();
  1812. shuffle($list);
  1813. $count = $number1;
  1814. for ($i = 0; $i < $count; $i++){
  1815. if(!$list[$i]->status){
  1816. $list[] = $list[$i];
  1817. unset($list[$i]);
  1818. $count++;
  1819. }
  1820. }
  1821. $result = array_slice($list, 0, $number1+$number2);
  1822. break;
  1823. case '2':
  1824. $list = DB::table('recruit_interviewer')->where('status',1)->get()->toArray();
  1825. shuffle($list);
  1826. $result = array_slice($list, 0, $number1+$number2);
  1827. break;
  1828. default:
  1829. $list = DB::table('recruit_interviewer')->get()->toArray();
  1830. shuffle($list);
  1831. for ($i = 0; $i < $number1; $i++){
  1832. dd($list[$i]);
  1833. if(!$list[$i]->status){
  1834. $list[] = $list[$i];
  1835. unset($list[$i]);
  1836. }
  1837. }
  1838. $result = array_slice($list, 0, $number1+$number2);
  1839. break;
  1840. }
  1841. $return_data = [
  1842. 'list' => $result,
  1843. 'number1' => $number1,
  1844. 'number2' => $number2
  1845. ];
  1846. return view('app.recruit.interviewer', $return_data);
  1847. }
  1848. }