IndexController.php 74 KB

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