IndexController.php 90 KB

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