IndexController.php 83 KB

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