IndexController.php 76 KB

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