IndexController.php 77 KB

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