IndexController.php 90 KB

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