IndexController.php 91 KB

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