IndexController.php 84 KB

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