IndexController.php 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679
  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. $material[$k]['url'] = $v['response']['path'];
  381. }
  382. }
  383. }else{
  384. $material = [];
  385. }
  386. $user_info['special'] = [
  387. 'point_apply' => (string)$special['point_apply'],
  388. 'condition' => $special['condition'],
  389. 'material' => $material
  390. ];
  391. }
  392. if(in_array('detail',$forms)){
  393. $detail = RecruitAppointDetail::where('recruit_appoint_id',$user_info['id'])->first();
  394. if($detail){
  395. $user_info['detail'] = $detail->toArray();
  396. }else{
  397. $user_info['detail'] = [
  398. 'train' => '',
  399. 'rewards_and_punishments' => '',
  400. 'introduce' => ''
  401. ];
  402. }
  403. }
  404. //如果有身份证明模块
  405. if(in_array('identification',$forms)){
  406. if(json_decode($user_info['identification'])){
  407. $identification = json_decode($user_info['identification'],true);
  408. foreach ($identification as $k => $v){
  409. if(array_key_exists('response',$v)){
  410. $identification[$k]['url'] = $v['response']['path'];
  411. }
  412. }
  413. }else{
  414. $identification = [];
  415. }
  416. $user_info['identification'] = $identification;
  417. }
  418. //如果有教育证明模块
  419. if(in_array('education_certification',$forms)){
  420. if(json_decode($user_info['education_certification'])){
  421. $education_certification = json_decode($user_info['education_certification'],true);
  422. foreach ($education_certification as $k => $v){
  423. if(array_key_exists('response',$v)){
  424. $education_certification[$k]['url'] = $v['response']['path'];
  425. }
  426. }
  427. }else{
  428. $education_certification = [];
  429. }
  430. $user_info['education_certification'] = $education_certification;
  431. }
  432. //如果有其他证明模块
  433. if(in_array('other_certification',$forms)){
  434. if(json_decode($user_info['other_certification'])){
  435. $other_certification = json_decode($user_info['other_certification'],true);
  436. foreach ($other_certification as $k => $v){
  437. if(array_key_exists('response',$v)){
  438. $other_certification[$k]['url'] = $v['response']['path'];
  439. }
  440. }
  441. }else{
  442. $other_certification = [];
  443. }
  444. $user_info['other_certification'] = $other_certification;
  445. }
  446. //获取最新的报名审核信息
  447. $logs = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',2)->orderBy('created_at','desc')->first();
  448. if($logs){
  449. $user_info['audit_log'] = $logs->log;
  450. }else{
  451. $user_info['audit_log'] = '';
  452. }
  453. //获取提交报名的次数
  454. // $number = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',3)->count();
  455. // $post_number = $number+1;//todo
  456. }
  457. }
  458. else{
  459. //实习专场
  460. if(in_array('internship',$forms)){
  461. $user_info = json_encode([
  462. 'recruit_id' => $id,
  463. 'operation' => 1,
  464. 'realname' => '',
  465. 'sex' => '1',
  466. 'birthday' => '',
  467. 'card' => '',
  468. 'nation' => '',
  469. 'native_place' => '',
  470. 'political_affiliation' => '',
  471. 'join_time' => '',
  472. 'house_register' => '',
  473. 'education' => '',
  474. 'school' => '',
  475. 'pro' => '',
  476. 'adjust' => '',
  477. 'mobile' => '',
  478. 'email' => '',
  479. 'address' => '',
  480. 'post_id' => '',
  481. 'concat_name' => '',
  482. 'concat_mobile' => '',
  483. 'resume' => '',
  484. 'avatar' => '',
  485. 'family' => [
  486. [
  487. 'relation' => '',
  488. 'realname' => '',
  489. 'birthday' => '',
  490. 'political_affiliation' => '',
  491. 'work' => ''
  492. ]
  493. ],
  494. 'detail' => [
  495. 'rewards_and_punishments' => '',
  496. 'introduce' => ''
  497. ],
  498. 'identification' => [],
  499. 'education_certification' => [],
  500. 'other_certification' => []
  501. ]);
  502. }else{
  503. //如果没有,结合基础数据及模块表单信息,制作数据对象
  504. $user_info = RecruitAppointBasic::where('uid',$uid)->first();
  505. if(!$user_info){
  506. //没有基础信息跳转完善route('person.recruitInfo')
  507. return $this->showMessage('请先完善招考基础信息!', route('recruit.recruitInfo',array('recruit_id',$id)), true, '上一页', '3');
  508. }
  509. $user_info['sex'] = (string)$user_info['sex'];
  510. $user_info['edu_type'] = (string)$user_info['edu_type'];
  511. $user_info['family'] = json_decode($user_info['family']);
  512. if(in_array('expand_special',$forms)){
  513. $user_info['special'] = [
  514. 'point_apply' => '0',
  515. 'condition' => '',
  516. 'material' => []
  517. ];
  518. }
  519. if(in_array('detail',$forms)){
  520. $user_info['detail'] = [
  521. 'train' => '',
  522. 'rewards_and_punishments' => '',
  523. 'introduce' => ''
  524. ];
  525. }
  526. if(in_array('identification',$forms)){
  527. $user_info['identification'] = [];
  528. }
  529. if(in_array('education_certification',$forms)){
  530. $user_info['education_certification'] = [];
  531. }
  532. if(in_array('other_certification',$forms)){
  533. $user_info['other_certification'] = [];
  534. }
  535. $user_info['recruit_id'] = $id;
  536. $user_info['operation'] = 1;
  537. }
  538. }
  539. //招考岗位
  540. $where_post[] = ['recruit_id', '=', $id];
  541. $where_post[] = ['status', '=', 1];
  542. $recruit_post = RecruitPost::where($where_post)->get();
  543. $post = [];
  544. $post_limit = [];
  545. foreach ($recruit_post as $value){
  546. $item = [
  547. 'value' => $value['id'],
  548. 'label' => $value['code'] . " " . $value['name']
  549. ];
  550. $post_limit[$value['id']] = json_decode($value['limit']);
  551. array_push($post,$item);
  552. }
  553. $view_data['appoint_info'] = $user_info;
  554. $view_data['post'] = json_encode($post);
  555. // $view_data['post_number'] = $post_number;
  556. // $view_data['post_times'] = $recruit['post_times'];
  557. $view_data['post_limit'] = json_encode($post_limit);
  558. $view_data['formDisable'] = $formDisabled;
  559. $view_data['title'] = $recruit->company;
  560. return view('app.recruit.sign_up',$view_data);
  561. }
  562. /**
  563. * 提交报名的处理程序
  564. * @param Request $request
  565. * @return array|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\think\response\Redirect|void
  566. */
  567. public function saveSignUp(Request $request)
  568. {
  569. $user = $this->getUser();
  570. if (!empty($user)) {
  571. $uid = $user->id;
  572. } else {
  573. return redirect(route('login'));
  574. }
  575. $recruit_id = $request->input('recruit_id', 0);
  576. if (!$recruit_id) {
  577. return response()->json(['status' => 0,'msg' => '请选择项目!']);
  578. }
  579. $recruit = Recruit::find($recruit_id);
  580. if(!$recruit['status']){
  581. return response()->json(['status' => 0,'msg' => '抱歉,该项目状态不正确,请联系客服!']);
  582. }
  583. if($recruit['current'] != 1){
  584. return response()->json(['status' => 0,'msg' => '抱歉,该项目报名通道已关闭,如有疑问,请联系客服!']);
  585. }
  586. $time = time();
  587. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  588. if(($time < strtotime($recruit['apply_start']) || strtotime($recruit['apply_end']) < $time)){//过了招考时间
  589. if($appoint_info){
  590. //如果有报名记录,先查询首次报名是什么时候
  591. $first_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->orderBy('created_at','asc')->first();
  592. if(!$first_post){//没有记录代表只是暂存
  593. return response()->json(['status' => 0,'msg' => '抱歉,该项目已过报名时间!']);
  594. }
  595. }
  596. if(!$appoint_info){
  597. return response()->json(['status' => 0,'msg' => '抱歉,该项目已过报名时间!']);
  598. }
  599. }
  600. //基础信息的检查
  601. $rules = [
  602. 'realname' => 'required',
  603. 'sex' => 'required',
  604. 'birthday' => 'required',
  605. 'avatar' => 'required',
  606. 'nation' => 'required',
  607. 'native_place' => 'required',
  608. 'political_affiliation' => 'required',
  609. 'post_id' => 'required',
  610. 'house_register' => 'required',
  611. //'edu_type' => 'required',
  612. 'education' => 'required',
  613. 'school' => 'required',
  614. 'address' => 'required',
  615. 'mobile' => 'required',
  616. 'email' => 'required',
  617. 'card' => 'required',
  618. 'concat_name' => 'required',
  619. 'concat_mobile' => 'required',
  620. 'resume' => 'required'
  621. ];
  622. $messages = [
  623. 'realname.required' => '请填写姓名',
  624. 'sex.required' => '请填写性别',
  625. 'birthday.required' => '请填写出生日期',
  626. 'avatar.required' => '请上传彩色免冠照',
  627. 'nation.required' => '请填写民族',
  628. 'native_place.required' => '请填写籍贯',
  629. 'political_affiliation.required' => '请选择政治面貌',
  630. 'post_id.required' => '请选择报名岗位',
  631. 'house_register.required' => '请填写户籍所在地',
  632. //'edu_type.required' => '请选择教育类型',
  633. 'education.required' => '请输入学历',
  634. 'school.required' => '请输入毕业院校',
  635. 'address.required' => '请填写通信地址',
  636. 'mobile.required' => '请填写手机号码',
  637. 'email.required' => '请填写电子邮箱',
  638. 'card.required' => '请填写身份证号码',
  639. 'resume.required' => '请填写个人简历',
  640. 'concat_name.required' => '请填写联系人姓名',
  641. 'concat_mobile.required' => '请填写联系人手机号码'
  642. ];
  643. $create_data = $request->all();
  644. $validator = Validator::make($create_data,$rules,$messages);
  645. if ($validator->fails()) {
  646. $msg = $validator->errors()->all();
  647. return response()->json(['status' => 0,'msg' => $msg[0]]);
  648. }else{
  649. $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');
  650. //身份证判断出生日期和性别
  651. $year = substr($data['card'],6,4);
  652. $month = substr($data['card'],10,2);
  653. $day = substr($data['card'],12,2);
  654. if($year.'-'.$month.'-'.$day != $data['birthday']){
  655. $data['birthday'] = $year.'-'.$month.'-'.$day;
  656. }
  657. if(intval(substr($data['card'],16,1)) % 2 == 0){
  658. $data['sex'] = 0;
  659. }else{
  660. $data['sex'] = 1;
  661. }
  662. $post_info = RecruitPost::where('id',$data['post_id'])->where('recruit_id',$recruit_id)->first();
  663. if(!$post_info['status'] || $post_info['deleted_at'] != null){
  664. return response()->json(['status' => 0,'msg' => '该岗位已失效']);
  665. }
  666. //获取操作符,是暂存还是提交
  667. $operation = $request->input('operation');
  668. if($operation == 1){
  669. $data['audit'] = 0;//暂存
  670. }else{
  671. $data['audit'] = 1;//提交
  672. }
  673. if(!empty($post_info['limit']) && json_decode($post_info['limit'])){
  674. //岗位限制条件的判断
  675. $post_limit = json_decode($post_info['limit'],true);
  676. if(is_array($post_limit)){
  677. foreach($post_limit as $k => $v){
  678. if($k == 'birthday'){
  679. $value = str_replace('-','',$data[$k]);
  680. }else{
  681. $value = $data[$k];
  682. }
  683. switch ($v['op']){
  684. case '=':
  685. if($value != $v['value']){
  686. return response()->json(['status' => 0,'msg' => $v['msg']]);
  687. }
  688. break;
  689. case '>':
  690. if($value <= $v['value']){
  691. return response()->json(['status' => 0,'msg' => $v['msg']]);
  692. }
  693. break;
  694. case '>=':
  695. if($value < $v['value']){
  696. return response()->json(['status' => 0,'msg' => $v['msg']]);
  697. }
  698. break;
  699. case '<':
  700. if($value >= $v['value']){
  701. return response()->json(['status' => 0,'msg' => $v['msg']]);
  702. }
  703. break;
  704. case '<=':
  705. if($value > $v['value']){
  706. return response()->json(['status' => 0,'msg' => $v['msg']]);
  707. }
  708. break;
  709. case '!=':
  710. if($value == $v['value']){
  711. return response()->json(['status' => 0,'msg' => $v['msg']]);
  712. }
  713. break;
  714. case 'like':
  715. if(strpos($value,$v['value']) === false){
  716. return response()->json(['status' => 0,'msg' => $v['msg']]);
  717. }
  718. break;
  719. case 'in':
  720. if(strpos($v['value'],$value) === false){
  721. return response()->json(['status' => 0,'msg' => $v['msg']]);
  722. }
  723. break;
  724. }
  725. }
  726. }
  727. }
  728. //前置审核 判断完成,先将数据入报名信息基础表
  729. //解析家庭成员数据
  730. $familys = $request->input('family');
  731. $family = [];
  732. if(is_array($familys)){
  733. foreach ($familys as $value){
  734. $item = [
  735. 'relation' => $value['relation'],
  736. 'realname' => $value['realname'],
  737. 'birthday' => $value['birthday'],
  738. 'political_affiliation' => $value['political_affiliation'],
  739. 'work' => $value['work']
  740. ];
  741. array_push($family,$item);
  742. }
  743. }
  744. $data['family'] = json_encode($family);
  745. if($appoint_info){
  746. //如果已有报名记录,进入修改阶段的处理流程
  747. DB::beginTransaction();
  748. try{
  749. RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->update($data);
  750. //分模块解析数据
  751. $forms = explode(',', $recruit['forms']);
  752. //如果有加分模块
  753. if(in_array('expand_special',$forms)){
  754. $special = $request->input('special');
  755. if($special['point_apply']){
  756. //删除掉没有成功返回路径的图片
  757. if(is_array($special['material'])){
  758. foreach ($special['material'] as $k => $v){
  759. if(!array_key_exists('response',$v)){
  760. unset($special['material'][$k]);
  761. }
  762. }
  763. }
  764. $special['material'] = json_encode($special['material']);
  765. }else{
  766. $special['material'] = json_encode([]);
  767. }
  768. $hasRecord = RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint_info->id)->first();
  769. if($hasRecord){
  770. RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint_info->id)->update($special);
  771. }else{
  772. $special['recruit_appoint_id'] = $appoint_info->id;
  773. RecruitAppointExpandSpecial::create($special);
  774. }
  775. }
  776. //如果有详情模块
  777. if(in_array('detail',$forms) || in_array('internship',$forms)){
  778. $detail = $request->input('detail');
  779. $hasRecord = RecruitAppointDetail::where('recruit_appoint_id',$appoint_info->id)->first();
  780. if($hasRecord){
  781. RecruitAppointDetail::where('recruit_appoint_id',$appoint_info->id)->update($detail);
  782. }else{
  783. $detail['recruit_appoint_id'] = $appoint_info->id;
  784. RecruitAppointDetail::create($detail);
  785. }
  786. }
  787. //如果有身份证明模块
  788. if(in_array('identification',$forms) || in_array('internship',$forms)){
  789. $identification = $request->input('identification');
  790. if(is_array($identification)){
  791. //删除掉没有成功返回路径的图片
  792. foreach ($identification as $k => $v){
  793. if(!array_key_exists('response',$v)){
  794. unset($identification[$k]);
  795. }
  796. }
  797. }
  798. $appoint_info->identification = json_encode($identification);
  799. $appoint_info->save();
  800. }
  801. //如果有教育证明模块
  802. if(in_array('education_certification',$forms) || in_array('internship',$forms)){
  803. $education_certification = $request->input('education_certification');
  804. if(is_array($education_certification)){
  805. //删除掉没有成功返回路径的图片
  806. foreach ($education_certification as $k => $v){
  807. if(!array_key_exists('response',$v)){
  808. unset($education_certification[$k]);
  809. }
  810. }
  811. }
  812. $appoint_info->education_certification = json_encode($education_certification);
  813. $appoint_info->save();
  814. }
  815. //如果有其他证明模块
  816. if(in_array('other_certification',$forms) || in_array('internship',$forms)){
  817. $other_certification = $request->input('other_certification');
  818. if(is_array($other_certification)){
  819. //删除掉没有成功返回路径的图片
  820. foreach ($other_certification as $k => $v){
  821. if(!array_key_exists('response',$v)){
  822. unset($other_certification[$k]);
  823. }
  824. }
  825. }
  826. if($other_certification){
  827. $appoint_info->other_certification = json_encode($other_certification);
  828. $appoint_info->save();
  829. }
  830. }
  831. DB::commit();
  832. if($operation == 2){
  833. $log = [
  834. 'type' => 3,
  835. 'appoint_id'=> $appoint_info->id,
  836. 'uid' => $uid,
  837. 'log' => '用户提交报名'
  838. ];
  839. RecruitAppointLog::create($log);
  840. return ['status' => 1, 'msg' => '提交成功', 'data' => $appoint_info->id];
  841. }else{
  842. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $appoint_info->id];
  843. }
  844. } catch (\Exception $e){
  845. DB::rollback();
  846. return ['status' => 0, 'msg' => $e->getMessage()];
  847. }
  848. }else{
  849. //没有报名记录,进入增加阶段的处理流程
  850. DB::beginTransaction();
  851. try{
  852. $data['uid'] = $uid;
  853. $data['recruit_id'] = $recruit_id;
  854. $result = RecruitAppointInfo::create($data);
  855. //分模块解析数据
  856. $forms = explode(',', $recruit['forms']);
  857. //如果有加分模块
  858. if(in_array('expand_special',$forms)){
  859. $special = $request->input('special');
  860. if($special['point_apply']){
  861. if(is_array($special['material'])){
  862. //删除掉没有成功返回路径的图片
  863. foreach ($special['material'] as $k => $v){
  864. if(!array_key_exists('response',$v)){
  865. unset($special['material'][$k]);
  866. }
  867. }
  868. }
  869. $special['material'] = json_encode($special['material']);
  870. }
  871. $special['recruit_appoint_id'] = $result->id;
  872. RecruitAppointExpandSpecial::create($special);
  873. }
  874. //如果有详情模块
  875. if(in_array('detail',$forms) || in_array('internship',$forms)){
  876. $detail = $request->input('detail');
  877. $detail['recruit_appoint_id'] = $result->id;
  878. RecruitAppointDetail::create($detail);
  879. }
  880. //如果有身份证明模块
  881. if(in_array('identification',$forms) || in_array('internship',$forms)){
  882. $identification = $request->input('identification');
  883. if(is_array($identification)){
  884. //删除掉没有成功返回路径的图片
  885. foreach ($identification as $k => $v){
  886. if(!array_key_exists('response',$v)){
  887. unset($identification[$k]);
  888. }
  889. }
  890. }
  891. $result->identification = json_encode($identification);
  892. $result->save();
  893. }
  894. //如果有教育证明模块
  895. if(in_array('education_certification',$forms) || in_array('internship',$forms)){
  896. $education_certification = $request->input('education_certification');
  897. if(is_array($education_certification)){
  898. //删除掉没有成功返回路径的图片
  899. foreach ($education_certification as $k => $v){
  900. if(!array_key_exists('response',$v)){
  901. unset($education_certification[$k]);
  902. }
  903. }
  904. }
  905. $result->education_certification = json_encode($education_certification);
  906. $result->save();
  907. }
  908. //如果有其他证明模块
  909. if(in_array('other_certification',$forms) || in_array('internship',$forms)){
  910. $other_certification = $request->input('other_certification');
  911. if($other_certification){
  912. if(is_array($other_certification)){
  913. //删除掉没有成功返回路径的图片
  914. foreach ($other_certification as $k => $v){
  915. if(!array_key_exists('response',$v)){
  916. unset($other_certification[$k]);
  917. }
  918. }
  919. }
  920. $result->other_certification = json_encode($other_certification);
  921. $result->save();
  922. }
  923. }
  924. DB::commit();
  925. if($operation == 2){
  926. $log = [
  927. 'type' => 3,
  928. 'appoint_id'=> $result->id,
  929. 'uid' => $uid,
  930. 'log' => '用户首次提交报名'
  931. ];
  932. RecruitAppointLog::create($log);
  933. return ['status' => 1, 'msg' => '提交成功', 'data' => $result->id];
  934. }else{
  935. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $result->id];
  936. }
  937. } catch (\Exception $e){
  938. DB::rollback();
  939. return ['status' => 0, 'msg' => $e->getMessage()];
  940. }
  941. }
  942. }
  943. }
  944. /**
  945. * 获得当前登录的用户
  946. * @return \Illuminate\Contracts\Auth\Authenticatable|null
  947. */
  948. public function getUser()
  949. {
  950. if (auth('web-member')->check()) {
  951. $user = auth('web-member')->user();
  952. } else {
  953. $user = null;
  954. }
  955. return $user;
  956. }
  957. /**
  958. * 检查用户基本信息
  959. * @return array
  960. */
  961. public function checkUserBasicInfo()
  962. {
  963. $user = $this->getUser();
  964. if (!empty($user)) {
  965. $uid = $user->id;
  966. } else {
  967. $arr = ['status' => 401, 'msg'=>'请登录!'];
  968. return $arr;
  969. }
  970. $info = RecruitAppointBasic::where('uid',$uid)->first();
  971. if (empty($info)){
  972. $arr = ['status'=>401,'msg'=>'请先完善招考基本信息','url'=> route('recruit.recruitInfo')];
  973. return $arr;
  974. }
  975. return ['status' => 200, 'msg' => ''];
  976. }
  977. /**
  978. * 个人中心招考页面
  979. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  980. */
  981. public function person_recruit()
  982. {
  983. $user = auth('web-member')->user();
  984. $list = RecruitAppointInfo::where('uid',$user->id)
  985. ->join('recruit', 'recruit.id', '=', 'recruit_appoint_info.recruit_id', 'left')
  986. ->join('recruit_post', 'recruit_post.id', '=', 'recruit_appoint_info.post_id', 'left')
  987. ->select('recruit.name as recruit_name','recruit_appoint_info.*','recruit_post.code','recruit_post.name')
  988. ->get();
  989. return view('app.person.recruit')->with(['list' => $list,'total' => count($list)]);
  990. }
  991. /**
  992. * 招考信息基础页
  993. * @param Request $request
  994. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  995. */
  996. public function recruit_info(Request $request)
  997. {
  998. $user = auth('web-member')->user();
  999. $info = RecruitAppointBasic::where('uid',$user->id)->first();
  1000. if(!$info){
  1001. $info = [
  1002. 'realname' => '',
  1003. 'sex' => '0',
  1004. 'birthday' => '',
  1005. 'avatar' => '',
  1006. 'nation' => '',
  1007. 'native_place' => '',
  1008. 'political_affiliation' => '',
  1009. 'titles' => '',
  1010. 'work' => '',
  1011. 'house_register' => '',
  1012. 'join_time' => '',
  1013. 'edu_type' => '',
  1014. 'education' => '',
  1015. 'school' => '',
  1016. 'degree' => '',
  1017. 'pro' => '',
  1018. 'address' => '',
  1019. 'card' => '',
  1020. 'mobile' => '',
  1021. 'email' => '',
  1022. 'concat_name' => '',
  1023. 'concat_mobile' => '',
  1024. 'resume' => '',
  1025. 'family' => [
  1026. [
  1027. 'relation' => '',
  1028. 'realname' => '',
  1029. 'birthday' => '',
  1030. 'political_affiliation' => '',
  1031. 'work' => ''
  1032. ]
  1033. ],
  1034. 'is_push' => '1'
  1035. ];
  1036. }else{
  1037. $info->sex = (string)$info->sex;
  1038. $info->edu_type = (string)$info->edu_type;
  1039. $info->is_push = (string)$info->is_push;
  1040. $info->family = empty($info->family) ? [[
  1041. 'relation' => '',
  1042. 'realname' => '',
  1043. 'birthday' => '',
  1044. 'political_affiliation' => '',
  1045. 'work' => ''
  1046. ]] : json_decode($info->family);
  1047. }
  1048. $recruit_id = $request->input('recruit_id',0);
  1049. return view('app.person.recruit_info',[
  1050. 'info' => json_encode($info),
  1051. 'recruit_id'=> $recruit_id
  1052. ]);
  1053. }
  1054. /**
  1055. * 保存招考信息
  1056. * @param RecruitValidatorRequest $request
  1057. * @return \Illuminate\Http\JsonResponse
  1058. */
  1059. public function saveRecruitInfo(RecruitValidatorRequest $request)
  1060. {
  1061. $user = auth('web-member')->user();
  1062. $basic = RecruitAppointBasic::where('uid',$user->id)->first();
  1063. $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');
  1064. if(count($data['family']) > 0){
  1065. $data['family'] = json_encode($data['family']);
  1066. }
  1067. if($basic){
  1068. //更新基础信息
  1069. $res = RecruitAppointBasic::where('uid',$user->id)->update($data);
  1070. if (!$res) {
  1071. return response()->json(['status'=>0,'msg'=>'保存失败,请联系客服']);
  1072. }else{
  1073. return response()->json(['status'=>1,'msg'=>'个人基础信息保存成功,快去报名吧!']);
  1074. }
  1075. }else{
  1076. //新增基础信息
  1077. $data['uid'] = $user->id;
  1078. $res = RecruitAppointBasic::create($data);
  1079. if (!$res) {
  1080. return response()->json(['status'=>0,'msg'=>'保存失败,请联系客服']);
  1081. }else{
  1082. return response()->json(['status'=>1,'msg'=>'个人基础信息保存成功,快去报名吧!']);
  1083. }
  1084. }
  1085. }
  1086. /**
  1087. * 笔试准考证
  1088. * @param Request $request
  1089. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1090. */
  1091. public function pen_ticket(Request $request)
  1092. {
  1093. $user = $this->getUser();
  1094. if (!empty($user)) {
  1095. $uid = $user->id;
  1096. } else {
  1097. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1098. }
  1099. $recruit_id = $request->input('recruit_id');
  1100. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1101. if($appoint_info){
  1102. $pen_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',1)->first();
  1103. if($pen_ticket){
  1104. $time = time();
  1105. if(strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time){
  1106. RecruitTicket::where('appoint_id',$appoint_info->id)->update(['ex_status' => 1]);
  1107. $recruit = Recruit::where('id',$recruit_id)->first();
  1108. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1109. $name = $recruit->name_en;
  1110. $date = date("Y-m-d",strtotime($recruit->created_at));
  1111. $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1112. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/pen/" . $filename . '_create.pdf';
  1113. if(file_exists($file)){
  1114. header('Content-Description: File Transfer');
  1115. header('Content-Type: application/octet-stream');
  1116. header('Content-Disposition: attachment; filename='.basename($file));
  1117. header('Content-Transfer-Encoding: binary');
  1118. header('Expires: 0');
  1119. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1120. header('Pragma: public');
  1121. header('Content-Length: ' . filesize($file));
  1122. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1123. flush();
  1124. readfile($file);
  1125. }
  1126. }else{
  1127. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1128. }
  1129. }else{
  1130. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1131. }
  1132. }else{
  1133. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1134. }
  1135. }
  1136. /**
  1137. * 审核准考证
  1138. * @param Request $request
  1139. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1140. */
  1141. public function check_ticket(Request $request)
  1142. {
  1143. $user = $this->getUser();
  1144. if (!empty($user)) {
  1145. $uid = $user->id;
  1146. } else {
  1147. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1148. }
  1149. $recruit_id = $request->input('recruit_id');
  1150. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1151. if($appoint_info){
  1152. $check_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',2)->first();
  1153. if($check_ticket){
  1154. $time = time();
  1155. if(strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time){
  1156. RecruitTicket::where('appoint_id',$appoint_info->id)->update(['ex_status' => 1]);
  1157. $recruit = Recruit::where('id',$recruit_id)->first();
  1158. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1159. $name = $recruit->name_en;
  1160. $date = date("Y-m-d",strtotime($recruit->created_at));
  1161. $filename = date("Y-m-18",time()) . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1162. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/check/" . $filename . '.pdf';
  1163. if(file_exists($file)){
  1164. header('Content-Description: File Transfer');
  1165. header('Content-Type: application/octet-stream');
  1166. header('Content-Disposition: attachment; filename='.basename($file));
  1167. header('Content-Transfer-Encoding: binary');
  1168. header('Expires: 0');
  1169. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1170. header('Pragma: public');
  1171. header('Content-Length: ' . filesize($file));
  1172. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1173. flush();
  1174. readfile($file);
  1175. }
  1176. }else{
  1177. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1178. }
  1179. }else{
  1180. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1181. }
  1182. }else{
  1183. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1184. }
  1185. }
  1186. /**
  1187. * 面试准考证
  1188. * @param Request $request
  1189. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1190. */
  1191. public function face_ticket(Request $request)
  1192. {
  1193. $user = $this->getUser();
  1194. if (!empty($user)) {
  1195. $uid = $user->id;
  1196. } else {
  1197. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1198. }
  1199. $recruit_id = $request->input('recruit_id');
  1200. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1201. if($appoint_info){
  1202. $face_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',3)->first();
  1203. if($face_ticket){
  1204. $time = time();
  1205. if(strtotime($face_ticket->ex_start) < $time && strtotime($face_ticket->ex_end) > $time){
  1206. RecruitTicket::where('id',$face_ticket->id)->update(['ex_status' => 1]);
  1207. $recruit = Recruit::where('id',$recruit_id)->first();
  1208. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1209. $name = $recruit->name_en;
  1210. $date = date("Y-m-d",strtotime($recruit->created_at));
  1211. $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id].'_create';
  1212. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';
  1213. if(file_exists($file)){
  1214. header('Content-Description: File Transfer');
  1215. header('Content-Type: application/octet-stream');
  1216. header('Content-Disposition: attachment; filename='.basename($file));
  1217. header('Content-Transfer-Encoding: binary');
  1218. header('Expires: 0');
  1219. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1220. header('Pragma: public');
  1221. header('Content-Length: ' . filesize($file));
  1222. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1223. flush();
  1224. readfile($file);
  1225. }
  1226. }else{
  1227. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1228. }
  1229. }else{
  1230. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1231. }
  1232. }else{
  1233. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1234. }
  1235. }
  1236. /**
  1237. * 复试准考证
  1238. * @param Request $request
  1239. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1240. */
  1241. public function reexamine_ticket(Request $request)
  1242. {
  1243. $user = $this->getUser();
  1244. if (!empty($user)) {
  1245. $uid = $user->id;
  1246. } else {
  1247. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1248. }
  1249. $recruit_id = $request->input('recruit_id');
  1250. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1251. if($appoint_info){
  1252. $reexamine_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',4)->first();
  1253. if($reexamine_ticket){
  1254. $time = time();
  1255. if(strtotime($reexamine_ticket->ex_start) < $time && strtotime($reexamine_ticket->ex_end) > $time){
  1256. RecruitTicket::where('id',$reexamine_ticket->id)->update(['ex_status' => 1]);
  1257. $recruit = Recruit::where('id',$recruit_id)->first();
  1258. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1259. $name = $recruit->name_en;
  1260. $date = date("Y-m-d",strtotime($recruit->created_at));
  1261. $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id].'_create';
  1262. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';
  1263. if(file_exists($file)){
  1264. header('Content-Description: File Transfer');
  1265. header('Content-Type: application/octet-stream');
  1266. header('Content-Disposition: attachment; filename='.basename($file));
  1267. header('Content-Transfer-Encoding: binary');
  1268. header('Expires: 0');
  1269. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1270. header('Pragma: public');
  1271. header('Content-Length: ' . filesize($file));
  1272. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1273. flush();
  1274. readfile($file);
  1275. }
  1276. }else{
  1277. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1278. }
  1279. }else{
  1280. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1281. }
  1282. }else{
  1283. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1284. }
  1285. }
  1286. /**
  1287. * 材料补登
  1288. * @param Request $request
  1289. */
  1290. public function material_supplement(Request $request)
  1291. {
  1292. $user = $this->getUser();
  1293. if (!empty($user)) {
  1294. $uid = $user->id;
  1295. } else {
  1296. return redirect(route('login'));
  1297. }
  1298. //招考id
  1299. $id = $request->input('id', 0);
  1300. if (!$id) {
  1301. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1302. }
  1303. $recruit = Recruit::find($id);
  1304. if(!$recruit['status'] && !$user->recruit_test){
  1305. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1306. }
  1307. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  1308. if(!$appoint_info){
  1309. return $this->showMessage('抱歉,您没有报名,无需考察审核!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1310. }
  1311. if($appoint_info->pen_audit != 1){
  1312. return $this->showMessage('抱歉,您未入闱,无需考察审核!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1313. }
  1314. $uids = [169955];
  1315. $time = time();
  1316. if(!in_array($uid,$uids) || $time > 1626661200){
  1317. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1318. }
  1319. $info = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();
  1320. if(!$info){
  1321. $info = [
  1322. 'appoint_id' => $appoint_info->id,
  1323. 'identification' => '',
  1324. 'household_register' => '',
  1325. 'education_certification' => '',
  1326. 'family_planning' => '',
  1327. 'manage' => '',
  1328. 'status' => 3
  1329. ];
  1330. }else{
  1331. $info = $info->toArray();
  1332. if(json_decode($info['identification'])){
  1333. $identification = json_decode($info['identification'],true);
  1334. foreach ($identification as $k => $v){
  1335. if(array_key_exists('response',$v)){
  1336. $identification[$k]['url'] = $v['response']['path'];
  1337. }
  1338. }
  1339. }else{
  1340. $identification = [];
  1341. }
  1342. $info['identification'] = $identification;
  1343. if(json_decode($info['household_register'])){
  1344. $household_register = json_decode($info['household_register'],true);
  1345. foreach ($household_register as $k => $v){
  1346. if(array_key_exists('response',$v)){
  1347. $household_register[$k]['url'] = $v['response']['path'];
  1348. }
  1349. }
  1350. }else{
  1351. $household_register = [];
  1352. }
  1353. $info['household_register'] = $household_register;
  1354. if(json_decode($info['education_certification'])){
  1355. $education_certification = json_decode($info['education_certification'],true);
  1356. foreach ($education_certification as $k => $v){
  1357. if(array_key_exists('response',$v)){
  1358. $education_certification[$k]['url'] = $v['response']['path'];
  1359. }
  1360. }
  1361. }else{
  1362. $education_certification = [];
  1363. }
  1364. $info['education_certification'] = $education_certification;
  1365. if(json_decode($info['family_planning'])){
  1366. $family_planning = json_decode($info['family_planning'],true);
  1367. foreach ($family_planning as $k => $v){
  1368. if(array_key_exists('response',$v)){
  1369. $family_planning[$k]['url'] = $v['response']['path'];
  1370. }
  1371. }
  1372. }else{
  1373. $family_planning = [];
  1374. }
  1375. $info['family_planning'] = $family_planning;
  1376. if(json_decode($info['manage'])){
  1377. $manage = json_decode($info['manage'],true);
  1378. foreach ($manage as $k => $v){
  1379. if(array_key_exists('response',$v)){
  1380. $manage[$k]['url'] = $v['response']['path'];
  1381. }
  1382. }
  1383. }else{
  1384. $manage = [];
  1385. }
  1386. $info['manage'] = $manage;
  1387. }
  1388. $view_data['info'] = json_encode($info);
  1389. $view_data['title'] = $recruit->company;
  1390. return view('app.recruit.supplement',$view_data);
  1391. }
  1392. public function save_supplement(Request $request)
  1393. {
  1394. $user = $this->getUser();
  1395. if (!empty($user)) {
  1396. $uid = $user->id;
  1397. } else {
  1398. return redirect(route('login'));
  1399. }
  1400. $appoint_id = $request->input('appoint_id');
  1401. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',5)->where('id',$appoint_id)->first();
  1402. if(!$appoint_info){
  1403. return ['status' => 0, 'msg' => '抱歉,找不到您要补登的报名记录!'];
  1404. }
  1405. $info = RecruitSupplement::where('appoint_id',$appoint_id)->first();
  1406. if($info){
  1407. if($info->status == 1){
  1408. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  1409. }
  1410. if($info->status == 0){
  1411. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  1412. }
  1413. //身份证明
  1414. $identification = $request->input('identification');
  1415. if(is_array($identification)){
  1416. //删除掉没有成功返回路径的图片
  1417. foreach ($identification as $k => $v){
  1418. if(!array_key_exists('response',$v)){
  1419. unset($identification[$k]);
  1420. }
  1421. }
  1422. }
  1423. $info->identification = json_encode($identification);
  1424. //户口簿
  1425. $household_register = $request->input('household_register');
  1426. if(is_array($household_register)){
  1427. //删除掉没有成功返回路径的图片
  1428. foreach ($household_register as $k => $v){
  1429. if(!array_key_exists('response',$v)){
  1430. unset($household_register[$k]);
  1431. }
  1432. }
  1433. }
  1434. $info->household_register = json_encode($household_register);
  1435. //学信网
  1436. $education_certification = $request->input('education_certification');
  1437. if(is_array($education_certification)){
  1438. //删除掉没有成功返回路径的图片
  1439. foreach ($education_certification as $k => $v){
  1440. if(!array_key_exists('response',$v)){
  1441. unset($education_certification[$k]);
  1442. }
  1443. }
  1444. }
  1445. $info->education_certification = json_encode($education_certification);
  1446. //计生
  1447. $family_planning = $request->input('family_planning');
  1448. if(is_array($family_planning)){
  1449. //删除掉没有成功返回路径的图片
  1450. foreach ($family_planning as $k => $v){
  1451. if(!array_key_exists('response',$v)){
  1452. unset($family_planning[$k]);
  1453. }
  1454. }
  1455. }
  1456. $info->family_planning = json_encode($family_planning);
  1457. //综治
  1458. $manage = $request->input('manage');
  1459. if(is_array($manage)){
  1460. //删除掉没有成功返回路径的图片
  1461. foreach ($manage as $k => $v){
  1462. if(!array_key_exists('response',$v)){
  1463. unset($manage[$k]);
  1464. }
  1465. }
  1466. }
  1467. $info->manage = json_encode($manage);
  1468. $info->status = 0;
  1469. $info->save();
  1470. $appoint_info->political_audit = 4;
  1471. $appoint_info->save();
  1472. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1473. }else{
  1474. $data['appoint_id'] = $appoint_id;
  1475. //身份证明
  1476. $identification = $request->input('identification');
  1477. if(is_array($identification)){
  1478. //删除掉没有成功返回路径的图片
  1479. foreach ($identification as $k => $v){
  1480. if(!array_key_exists('response',$v)){
  1481. unset($identification[$k]);
  1482. }
  1483. }
  1484. }
  1485. $data['identification'] = json_encode($identification);
  1486. //户口簿
  1487. $household_register = $request->input('household_register');
  1488. if(is_array($household_register)){
  1489. //删除掉没有成功返回路径的图片
  1490. foreach ($household_register as $k => $v){
  1491. if(!array_key_exists('response',$v)){
  1492. unset($household_register[$k]);
  1493. }
  1494. }
  1495. }
  1496. $data['household_register'] = json_encode($household_register);
  1497. //学信网
  1498. $education_certification = $request->input('education_certification');
  1499. if(is_array($education_certification)){
  1500. //删除掉没有成功返回路径的图片
  1501. foreach ($education_certification as $k => $v){
  1502. if(!array_key_exists('response',$v)){
  1503. unset($education_certification[$k]);
  1504. }
  1505. }
  1506. }
  1507. $data['education_certification'] = json_encode($education_certification);
  1508. //计生
  1509. $family_planning = $request->input('family_planning');
  1510. if(is_array($family_planning)){
  1511. //删除掉没有成功返回路径的图片
  1512. foreach ($family_planning as $k => $v){
  1513. if(!array_key_exists('response',$v)){
  1514. unset($family_planning[$k]);
  1515. }
  1516. }
  1517. }
  1518. $data['family_planning'] = json_encode($family_planning);
  1519. //综治
  1520. $manage = $request->input('manage');
  1521. if(is_array($manage)){
  1522. //删除掉没有成功返回路径的图片
  1523. foreach ($manage as $k => $v){
  1524. if(!array_key_exists('response',$v)){
  1525. unset($manage[$k]);
  1526. }
  1527. }
  1528. }
  1529. $data['manage'] = json_encode($manage);
  1530. $data['status'] = 0;
  1531. $result = RecruitSupplement::create($data);
  1532. $appoint_info->political_audit = 4;
  1533. $appoint_info->save();
  1534. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1535. }
  1536. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  1537. }
  1538. public function interviewer_random(Request $request)
  1539. {
  1540. $model = $request->input('model',1);
  1541. $number1 = $request->input('number1',5);//考官人数
  1542. $number2 = $request->input('number2',1);//替补人数
  1543. $where[] = ['id','>',0];
  1544. switch ($model){
  1545. case '0':
  1546. $list = DB::table('recruit_interviewer')->get()->toArray();
  1547. shuffle($list);
  1548. $result = array_slice($list, 0, $number1+$number2);
  1549. break;
  1550. case '1':
  1551. $list = DB::table('recruit_interviewer')->get()->toArray();
  1552. shuffle($list);
  1553. $count = $number1;
  1554. for ($i = 0; $i < $count; $i++){
  1555. if(!$list[$i]->status){
  1556. $list[] = $list[$i];
  1557. unset($list[$i]);
  1558. $count++;
  1559. }
  1560. }
  1561. $result = array_slice($list, 0, $number1+$number2);
  1562. break;
  1563. case '2':
  1564. $list = DB::table('recruit_interviewer')->where('status',1)->get()->toArray();
  1565. shuffle($list);
  1566. $result = array_slice($list, 0, $number1+$number2);
  1567. break;
  1568. default:
  1569. $list = DB::table('recruit_interviewer')->get()->toArray();
  1570. shuffle($list);
  1571. for ($i = 0; $i < $number1; $i++){
  1572. dd($list[$i]);
  1573. if(!$list[$i]->status){
  1574. $list[] = $list[$i];
  1575. unset($list[$i]);
  1576. }
  1577. }
  1578. $result = array_slice($list, 0, $number1+$number2);
  1579. break;
  1580. }
  1581. $return_data = [
  1582. 'list' => $result,
  1583. 'number1' => $number1,
  1584. 'number2' => $number2
  1585. ];
  1586. return view('app.recruit.interviewer', $return_data);
  1587. }
  1588. }