IndexController.php 86 KB

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