IndexController.php 108 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492
  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. use App\Models\RecruitAppointSelect;
  23. class IndexController extends WebBaseController
  24. {
  25. protected $recruitService,$baiduService;
  26. public function __construct(RecruitService $recruitService,BaiduService $baiduService)
  27. {
  28. $this->recruitService = $recruitService;
  29. $this->baiduService = $baiduService;
  30. }
  31. /**
  32. * 招考列表页
  33. * @param Request $request
  34. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  35. */
  36. public function index(Request $request)
  37. {
  38. $key = $request->input('key');
  39. $list = $this->recruitService->getRecruit($key, 10);
  40. $return_data = [
  41. 'list' => $list,
  42. 'key' => $key,
  43. ];
  44. return view('app.recruit.index', $return_data);
  45. }
  46. /**
  47. * 招考详情页
  48. * @param Request $request
  49. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View|mixed|\think\response\Redirect|\think\response\View|void
  50. */
  51. public function show(Request $request)
  52. {
  53. $user = $this->getUser();
  54. if($user){
  55. $uid = $user->id;
  56. $utype = $user->utype;
  57. }else{
  58. $uid = 0;
  59. $utype = 0;
  60. }
  61. $id = $request->input('id', 0);
  62. if (empty($id)) {
  63. return $this->showMessage('抱歉,请输入指定的招考场次!', route('recruit.list'), true, '上一页', '2');
  64. }
  65. $recruit = Recruit::find($id);
  66. if (empty($recruit)) {
  67. return redirect(route('/recruit/list'));
  68. }
  69. $info = Recruit::parse_info($recruit);
  70. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  71. if(!$info->isApply && $appoint_info){
  72. $first_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->orderBy('created_at','asc')->first();
  73. if($first_post){
  74. $info->isApply = 1;
  75. }
  76. }
  77. if($appoint_info){
  78. //笔试
  79. $pen_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',1)->first();
  80. if($pen_ticket){
  81. $pen_health = RecruitSupplement::where("appoint_id",$appoint_info->id)->where("type","pen")->where('h_status',1)->first();
  82. if(!$pen_health){
  83. $appoint_info->pen_ticket = -2;
  84. }else{
  85. $time = time();
  86. if(strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time){
  87. $appoint_info->pen_ticket = 1;
  88. }else{
  89. $appoint_info->pen_ticket = -1;
  90. }
  91. }
  92. }else{
  93. $appoint_info->pen_ticket = 0;
  94. }
  95. //考核测试
  96. $check_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',2)->first();
  97. if($check_ticket){
  98. $time = time();
  99. if(strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time){
  100. $appoint_info->check_ticket = 1;
  101. }else{
  102. $appoint_info->check_ticket = -1;
  103. }
  104. }else{
  105. $appoint_info->check_ticket = 0;
  106. }
  107. //面试
  108. $face_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',3)->first();
  109. if($face_ticket && $appoint_info->face_audit == -1){
  110. $face_health = RecruitSupplement::where("appoint_id",$appoint_info->id)->where("type","face")->where('h_status',1)->first();
  111. if(!$face_health){
  112. $appoint_info->face_ticket = -2;
  113. }else{
  114. $appoint_info->face_ticket = 1;
  115. }
  116. }else{
  117. $appoint_info->face_ticket = 0;
  118. }
  119. //复试
  120. $reexamine_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',4)->first();
  121. if($reexamine_ticket && $appoint_info->reexamine_audit == -1){
  122. $appoint_info->reexamine_ticket = 1;
  123. }else{
  124. $appoint_info->reexamine_ticket = 0;
  125. }
  126. }else{
  127. $appoint_info = new \stdClass();
  128. $appoint_info->pen_audit = 0;
  129. $appoint_info->post_id = 0;
  130. $appoint_info->pen_ticket = 0;
  131. $appoint_info->computer_ticket = 0;
  132. $appoint_info->face_ticket = 0;
  133. $appoint_info->check_ticket = 0;
  134. $appoint_info->reexamine_ticket = 0;
  135. $appoint_info->realname = '';
  136. $appoint_info->card = '';
  137. $appoint_info->mobile = '';
  138. $appoint_info->sex = 0;
  139. }
  140. $notice = $request->input('notice',0);
  141. if($notice){
  142. $public_notice_switch = 0;
  143. $public_notice = RecruitArticle::where('id',$notice)->where('released_at','<',time())->first();
  144. if (!empty($info)) {
  145. $view_data = [
  146. 'recruit' => $recruit,
  147. 'info' => $info,
  148. 'uid' => $uid,
  149. 'utype' => $utype,
  150. 'public_notice' => $public_notice,
  151. 'public_notice_switch' => $public_notice_switch,
  152. 'appoint_info' => $appoint_info
  153. ];
  154. return view('app.recruit.show')->with($view_data);
  155. } else {
  156. return back();
  157. }
  158. }else{
  159. $list = RecruitArticle::where('recruit_id',$id)->orderBy('created_at','desc')->where('released_at','<',time())->get();
  160. $public_notice_switch = 1;//有补充公告的模式
  161. if (!empty($info)) {
  162. $view_data = [
  163. 'recruit' => $recruit,
  164. 'info' => $info,
  165. 'uid' => $uid,
  166. 'utype' => $utype,
  167. 'list' => $list,
  168. 'public_notice_switch' => $public_notice_switch,
  169. 'appoint_info' => $appoint_info
  170. ];
  171. return view('app.recruit.show')->with($view_data);
  172. } else {
  173. return back();
  174. }
  175. }
  176. }
  177. /**
  178. * 上传文件的方法
  179. * @param Request $request
  180. * @return \Illuminate\Http\JsonResponse
  181. */
  182. public function upload(Request $request)
  183. {
  184. $user = $this->getUser();
  185. if($user){
  186. $uid = $user->id;
  187. $utype = $user->utype;
  188. }else{
  189. $uid = 0;
  190. $utype = 0;
  191. }
  192. $file = $request->file('file');
  193. if ($file->isValid()) { //判断文件是否存在
  194. //获取文件的扩展名
  195. $ext = $file->getClientOriginalExtension();
  196. if (!in_array(strtolower($ext), ['jpg', 'jpeg', 'png', 'doc', 'docx', 'pdf'])) {
  197. $res['status'] = 0;
  198. $res['msg'] = '文件格式不正确';
  199. } else {
  200. //获取文件的绝对路径
  201. $path = $file->getRealPath();
  202. $oldname = $file->getClientOriginalName();
  203. //定义文件名
  204. $filename = 'storage/recruit/' . uniqid() . mt_rand(10000, 99999) . '.' . $ext;
  205. //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置
  206. Storage::disk('public')->put($filename, file_get_contents($path));
  207. $res['status'] = 1;
  208. $res['filename'] = $oldname;
  209. $res['path'] = "/storage/" . $filename;
  210. $res['msg'] = '上传成功';
  211. }
  212. } else {
  213. $res['status'] = 0;
  214. $res['msg'] = '上传失败';
  215. }
  216. return response()->json($res);
  217. }
  218. /**
  219. * 查看报名人数统计
  220. * @param Request $request
  221. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View|mixed|\think\response\Redirect|\think\response\View|void
  222. */
  223. public function sign_up_count(Request $request)
  224. {
  225. $user = $this->getUser();
  226. if($user){
  227. $uid = $user->id;
  228. $utype = $user->utype;
  229. }else{
  230. $uid = 0;
  231. $utype = 0;
  232. }
  233. $id = $request->input('id', 0);
  234. $refresh = $request->input('refresh', '');
  235. if (empty($id)) {
  236. return $this->showMessage('抱歉,请输入指定的招考场次!', route('recruit.list'), true, '上一页', '2');
  237. }
  238. $recruit = Recruit::find($id);
  239. if (empty($recruit)) {
  240. return redirect(route('/recruit/list'));
  241. }
  242. if(!$recruit->show_report){
  243. return $this->showMessage('抱歉,该场次不允许查看报名人数统计结果!', route('recruit.list'), true, '上一页', '2');
  244. }
  245. if(Cache::has("sign_up_count_{$recruit->id}") && $refresh != 'jjhc2019') {
  246. $cache_data = Cache::get("sign_up_count_{$recruit->id}");
  247. $list = $cache_data['list'];
  248. $time = $cache_data['time'];
  249. }else{
  250. $list = RecruitPost::where('recruit_id',$recruit->id)->where('status',1)->get();
  251. if(!$list){
  252. return $this->showMessage('抱歉,数据暂时未更新或更新出错!', route('recruit.list'), true, '上一页', '2');
  253. }
  254. foreach ($list as $k => $v){
  255. $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();
  256. $list[$k]['checking'] = $res->checking;
  257. $list[$k]['fail'] = $res->fail;
  258. $list[$k]['success'] = $res->success;
  259. }
  260. $time = date('Y-m-d H:i',time());
  261. $cache_data = [
  262. 'list' => $list,
  263. 'time' => $time
  264. ];
  265. Cache::put("sign_up_count_{$recruit->id}",$cache_data,60);
  266. }
  267. $view_data = [
  268. 'list' => $list,
  269. 'time' => $time
  270. ];
  271. return view('app.recruit.sign_up_count')->with($view_data);
  272. }
  273. /**
  274. * 报名功能页
  275. * @param Request $request
  276. * @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
  277. */
  278. public function sign_up(Request $request)
  279. {
  280. $user = $this->getUser();
  281. if (!empty($user)) {
  282. $uid = $user->id;
  283. } else {
  284. return redirect(route('login'));
  285. }
  286. //招考id
  287. $id = $request->input('id', 0);
  288. if (!$id) {
  289. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  290. }
  291. //招考信息
  292. $recruit = Recruit::find($id);
  293. if(!$recruit['status'] && !$user->recruit_test){
  294. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  295. }
  296. if($recruit['current'] != 1){
  297. return $this->showMessage('抱歉,该项目报名通道已关闭,如有疑问,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  298. }
  299. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  300. $time = time();
  301. $formDisabled = 0;
  302. if(($time < strtotime($recruit['apply_start']) || strtotime($recruit['apply_end']) < $time)){//过了招考时间
  303. if(!in_array($uid,[161027,59041])){
  304. if(!$appoint_info){
  305. return $this->showMessage('抱歉,该项目已过报名时间或尚未开始!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  306. }
  307. if($appoint_info){
  308. //如果有报名记录,先查询首次报名是什么时候
  309. $first_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->where('appoint_id',$appoint_info->id)->orderBy('created_at','asc')->first();
  310. if(!$first_post){//没有记录代表只是暂存
  311. return $this->showMessage('抱歉,该项目已过报名时间或尚未开始!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  312. }
  313. // $has_late_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->where('created_at','>',$recruit['apply_end'])->first();//查找在过了报名时间后,有报名记录,且仍是审核失败的报名记录,看其是否在报名时间后是否有再次提交的记录
  314. // if($has_late_post){
  315. // $formDisabled = 1;
  316. // }else{
  317. // $formDisabled = 0;
  318. // }
  319. }
  320. }
  321. }
  322. $view_data['module'] = $forms = explode(',', $recruit['forms']);
  323. //查询报名表是否已有记录
  324. if($appoint_info){
  325. if(in_array('internship',$forms)) {
  326. //如果已有该场次的报名记录,读取录入的数据集合
  327. $user_info = $appoint_info;
  328. $user_info['sex'] = (string)$user_info['sex'];
  329. $user_info['adjust'] = (string)$user_info['adjust'];
  330. $user_info['edu_type'] = (string)$user_info['edu_type'];
  331. $user_info['family'] = json_decode($user_info['family']);
  332. $detail = RecruitAppointDetail::where('recruit_appoint_id',$user_info['id'])->first();
  333. if($detail){
  334. $user_info['detail'] = $detail->toArray();
  335. }else{
  336. $user_info['detail'] = [
  337. 'rewards_and_punishments' => '',
  338. 'introduce' => ''
  339. ];
  340. }
  341. if(json_decode($user_info['identification'])){
  342. $identification = json_decode($user_info['identification'],true);
  343. foreach ($identification as $k => $v){
  344. if(array_key_exists('response',$v)){
  345. $identification[$k]['url'] = $v['response']['path'];
  346. }
  347. }
  348. }else{
  349. $identification = [];
  350. }
  351. $user_info['identification'] = $identification;
  352. if(json_decode($user_info['education_certification'])){
  353. $education_certification = json_decode($user_info['education_certification'],true);
  354. foreach ($education_certification as $k => $v){
  355. if(array_key_exists('response',$v)){
  356. $education_certification[$k]['url'] = $v['response']['path'];
  357. }
  358. }
  359. }else{
  360. $education_certification = [];
  361. }
  362. $user_info['education_certification'] = $education_certification;
  363. if(json_decode($user_info['other_certification'])){
  364. $other_certification = json_decode($user_info['other_certification'],true);
  365. foreach ($other_certification as $k => $v){
  366. if(array_key_exists('response',$v)){
  367. $other_certification[$k]['url'] = $v['response']['path'];
  368. }
  369. }
  370. }else{
  371. $other_certification = [];
  372. }
  373. $user_info['other_certification'] = $other_certification;
  374. //获取最新的报名审核信息
  375. $logs = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',2)->orderBy('created_at','desc')->first();
  376. if($logs){
  377. $user_info['audit_log'] = $logs->log;
  378. }else{
  379. $user_info['audit_log'] = '';
  380. }
  381. }else{
  382. //如果已有该场次的报名记录,读取录入的数据集合
  383. $user_info = $appoint_info;
  384. $user_info['sex'] = (string)$user_info['sex'];
  385. $user_info['edu_type'] = (string)$user_info['edu_type'];
  386. $user_info['family'] = json_decode($user_info['family']);
  387. if(in_array('expand_special',$forms)){
  388. $special = RecruitAppointExpandSpecial::where('recruit_appoint_id',$user_info['id'])->first();
  389. if($special){
  390. $material = json_decode($special['material'],true);
  391. if(is_array($material)){
  392. foreach ($material as $k => $v){
  393. if(array_key_exists('response',$v)){
  394. if(array_key_exists('path',$v['response'])){
  395. $material[$k]['url'] = $v['response']['path'];
  396. }
  397. }
  398. }
  399. }
  400. }else{
  401. $material = [];
  402. $special = [
  403. 'point_apply' => '0',
  404. 'condition' => ''
  405. ];
  406. }
  407. $user_info['special'] = [
  408. 'point_apply' => (string)$special['point_apply'],
  409. 'condition' => $special['condition'],
  410. 'material' => $material
  411. ];
  412. }
  413. if(in_array('detail',$forms)){
  414. $detail = RecruitAppointDetail::where('recruit_appoint_id',$user_info['id'])->first();
  415. if($detail){
  416. $user_info['detail'] = $detail->toArray();
  417. }else{
  418. $user_info['detail'] = [
  419. 'train' => '',
  420. 'rewards_and_punishments' => '',
  421. 'introduce' => ''
  422. ];
  423. }
  424. }
  425. //如果有身份证明模块
  426. if(in_array('identification',$forms)){
  427. if(json_decode($user_info['identification'])){
  428. $identification = json_decode($user_info['identification'],true);
  429. foreach ($identification as $k => $v){
  430. if(array_key_exists('response',$v)){
  431. if(array_key_exists('path',$v['response'])){
  432. $identification[$k]['url'] = $v['response']['path'];
  433. }
  434. }
  435. }
  436. }else{
  437. $identification = [];
  438. }
  439. $user_info['identification'] = $identification;
  440. }
  441. //如果有教育证明模块
  442. if(in_array('education_certification',$forms)){
  443. if(json_decode($user_info['education_certification'])){
  444. $education_certification = json_decode($user_info['education_certification'],true);
  445. foreach ($education_certification as $k => $v){
  446. if(array_key_exists('response',$v)){
  447. if(array_key_exists('path',$v['response'])){
  448. $education_certification[$k]['url'] = $v['response']['path'];
  449. }
  450. }
  451. }
  452. }else{
  453. $education_certification = [];
  454. }
  455. $user_info['education_certification'] = $education_certification;
  456. }
  457. //如果有其他证明模块
  458. if(in_array('other_certification',$forms)){
  459. if(json_decode($user_info['other_certification'])){
  460. $other_certification = json_decode($user_info['other_certification'],true);
  461. foreach ($other_certification as $k => $v){
  462. if(array_key_exists('response',$v)){
  463. if(array_key_exists('path',$v['response'])){
  464. $other_certification[$k]['url'] = $v['response']['path'];
  465. }
  466. }
  467. }
  468. }else{
  469. $other_certification = [];
  470. }
  471. $user_info['other_certification'] = $other_certification;
  472. }
  473. //获取最新的报名审核信息
  474. $logs = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',2)->orderBy('created_at','desc')->first();
  475. if($logs){
  476. $user_info['audit_log'] = $logs->log;
  477. }else{
  478. $user_info['audit_log'] = '';
  479. }
  480. //获取提交报名的次数
  481. // $number = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',3)->count();
  482. // $post_number = $number+1;//todo
  483. }
  484. }
  485. else{
  486. //实习专场
  487. if(in_array('internship',$forms)){
  488. $user_info = json_encode([
  489. 'recruit_id' => $id,
  490. 'operation' => 1,
  491. 'realname' => '',
  492. 'sex' => '1',
  493. 'birthday' => '',
  494. 'card' => '',
  495. 'nation' => '',
  496. 'native_place' => '',
  497. 'political_affiliation' => '',
  498. 'join_time' => '',
  499. 'house_register' => '',
  500. 'education' => '',
  501. 'school' => '',
  502. 'pro' => '',
  503. 'adjust' => '',
  504. 'mobile' => '',
  505. 'email' => '',
  506. 'address' => '',
  507. 'post_id' => '',
  508. 'concat_name' => '',
  509. 'concat_mobile' => '',
  510. 'resume' => '',
  511. 'avatar' => '',
  512. 'family' => [
  513. [
  514. 'relation' => '',
  515. 'realname' => '',
  516. 'birthday' => '',
  517. 'political_affiliation' => '',
  518. 'work' => ''
  519. ]
  520. ],
  521. 'detail' => [
  522. 'rewards_and_punishments' => '',
  523. 'introduce' => ''
  524. ],
  525. 'identification' => [],
  526. 'education_certification' => [],
  527. 'other_certification' => []
  528. ]);
  529. }else{
  530. //如果没有,结合基础数据及模块表单信息,制作数据对象
  531. $user_info = RecruitAppointBasic::where('uid',$uid)->first();
  532. if(!$user_info){
  533. //没有基础信息跳转完善route('person.recruitInfo')
  534. return $this->showMessage('请先完善招考基础信息!', route('recruit.recruitInfo',array('recruit_id',$id)), true, '上一页', '3');
  535. }
  536. $user_info['sex'] = (string)$user_info['sex'];
  537. $user_info['edu_type'] = (string)$user_info['edu_type'];
  538. $user_info['family'] = json_decode($user_info['family']);
  539. if(in_array('expand_special',$forms)){
  540. $user_info['special'] = [
  541. 'point_apply' => '0',
  542. 'condition' => '',
  543. 'material' => []
  544. ];
  545. }
  546. if(in_array('detail',$forms)){
  547. $user_info['detail'] = [
  548. 'train' => '',
  549. 'rewards_and_punishments' => '',
  550. 'introduce' => ''
  551. ];
  552. }
  553. if(in_array('identification',$forms)){
  554. $user_info['identification'] = [];
  555. }
  556. if(in_array('education_certification',$forms)){
  557. $user_info['education_certification'] = [];
  558. }
  559. if(in_array('other_certification',$forms)){
  560. $user_info['other_certification'] = [];
  561. }
  562. $user_info['recruit_id'] = $id;
  563. $user_info['operation'] = 1;
  564. }
  565. }
  566. //招考岗位
  567. $where_post[] = ['recruit_id', '=', $id];
  568. $where_post[] = ['status', '=', 1];
  569. $recruit_post = RecruitPost::where($where_post)->get();
  570. $post = [];
  571. $post_limit = [];
  572. foreach ($recruit_post as $value){
  573. $item = [
  574. 'value' => $value['id'],
  575. 'label' => $value['code'] . " " . $value['name']
  576. ];
  577. $post_limit[$value['id']] = json_decode($value['limit']);
  578. array_push($post,$item);
  579. }
  580. $view_data['appoint_info'] = $user_info;
  581. $view_data['post'] = json_encode($post);
  582. // $view_data['post_number'] = $post_number;
  583. // $view_data['post_times'] = $recruit['post_times'];
  584. $view_data['post_limit'] = json_encode($post_limit);
  585. $view_data['formDisable'] = $formDisabled;
  586. $view_data['title'] = $recruit->company;
  587. return view('app.recruit.sign_up',$view_data);
  588. }
  589. public function preview(Request $request)
  590. {
  591. $modules = $request->input('modules');
  592. $view_data['module'] = $forms = explode(',', $modules);
  593. return view('app.recruit.preview',$view_data);
  594. }
  595. /**
  596. * 提交报名的处理程序
  597. * @param Request $request
  598. * @return array|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\think\response\Redirect|void
  599. */
  600. public function saveSignUp(Request $request)
  601. {
  602. $user = $this->getUser();
  603. if (!empty($user)) {
  604. $uid = $user->id;
  605. } else {
  606. return redirect(route('login'));
  607. }
  608. $recruit_id = $request->input('recruit_id', 0);
  609. if (!$recruit_id) {
  610. return response()->json(['status' => 0,'msg' => '请选择项目!']);
  611. }
  612. $recruit = Recruit::find($recruit_id);
  613. if(!$recruit['status']){
  614. return response()->json(['status' => 0,'msg' => '抱歉,该项目状态不正确,请联系客服!']);
  615. }
  616. if($recruit['current'] != 1){
  617. return response()->json(['status' => 0,'msg' => '抱歉,该项目报名通道已关闭,如有疑问,请联系客服!']);
  618. }
  619. $card = $request->input('card');
  620. $appointinfo_exist = RecruitAppointInfo::where('card',$card)->where('uid','<>',$uid)->where('recruit_id',$recruit_id)->first();
  621. if($appointinfo_exist){
  622. return response()->json(['status' => 0,'msg' => '您的证件已有其他账号的报名记录,请检查!']);
  623. }
  624. $time = time();
  625. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  626. if(($time < strtotime($recruit['apply_start']) || strtotime($recruit['apply_end']) < $time)){//过了招考时间
  627. if($appoint_info){
  628. //如果有报名记录,先查询首次报名是什么时候
  629. $first_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->orderBy('created_at','asc')->first();
  630. if(!$first_post){//没有记录代表只是暂存
  631. return response()->json(['status' => 0,'msg' => '抱歉,该项目已过报名时间!']);
  632. }
  633. }
  634. if(!$appoint_info){
  635. return response()->json(['status' => 0,'msg' => '抱歉,该项目已过报名时间!']);
  636. }
  637. }
  638. //基础信息的检查
  639. $rules = [
  640. 'realname' => 'required',
  641. 'sex' => 'required',
  642. 'birthday' => 'required',
  643. 'avatar' => 'required',
  644. 'nation' => 'required',
  645. 'native_place' => 'required',
  646. 'political_affiliation' => 'required',
  647. 'post_id' => 'required',
  648. 'house_register' => 'required',
  649. //'edu_type' => 'required',
  650. 'education' => 'required',
  651. 'school' => 'required',
  652. 'address' => 'required',
  653. 'mobile' => 'required',
  654. 'email' => 'required',
  655. 'card' => 'required',
  656. 'concat_name' => 'required',
  657. 'concat_mobile' => 'required',
  658. 'resume' => 'required'
  659. ];
  660. $messages = [
  661. 'realname.required' => '请填写姓名',
  662. 'sex.required' => '请填写性别',
  663. 'birthday.required' => '请填写出生日期',
  664. 'avatar.required' => '请上传彩色免冠照',
  665. 'nation.required' => '请填写民族',
  666. 'native_place.required' => '请填写籍贯',
  667. 'political_affiliation.required' => '请选择政治面貌',
  668. 'post_id.required' => '请选择报名岗位',
  669. 'house_register.required' => '请填写户籍所在地',
  670. //'edu_type.required' => '请选择教育类型',
  671. 'education.required' => '请输入学历',
  672. 'school.required' => '请输入毕业院校',
  673. 'address.required' => '请填写通信地址',
  674. 'mobile.required' => '请填写手机号码',
  675. 'email.required' => '请填写电子邮箱',
  676. 'card.required' => '请填写身份证号码',
  677. 'resume.required' => '请填写个人简历',
  678. 'concat_name.required' => '请填写联系人姓名',
  679. 'concat_mobile.required' => '请填写联系人手机号码'
  680. ];
  681. $create_data = $request->all();
  682. $validator = Validator::make($create_data,$rules,$messages);
  683. if ($validator->fails()) {
  684. $msg = $validator->errors()->all();
  685. return response()->json(['status' => 0,'msg' => $msg[0]]);
  686. }else{
  687. $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');
  688. //身份证判断出生日期和性别
  689. $year = substr($data['card'],6,4);
  690. $month = substr($data['card'],10,2);
  691. $day = substr($data['card'],12,2);
  692. if($year.'-'.$month.'-'.$day != $data['birthday']){
  693. $data['birthday'] = $year.'-'.$month.'-'.$day;
  694. }
  695. if(intval(substr($data['card'],16,1)) % 2 == 0){
  696. $data['sex'] = 0;
  697. }else{
  698. $data['sex'] = 1;
  699. }
  700. $post_info = RecruitPost::where('id',$data['post_id'])->where('recruit_id',$recruit_id)->first();
  701. if(!$post_info['status'] || $post_info['deleted_at'] != null){
  702. return response()->json(['status' => 0,'msg' => '该岗位已失效']);
  703. }
  704. //获取操作符,是暂存还是提交
  705. $operation = $request->input('operation');
  706. if($operation == 1){
  707. $data['audit'] = 0;//暂存
  708. }else{
  709. $data['audit'] = 1;//提交
  710. }
  711. if(!empty($post_info['limit']) && json_decode($post_info['limit'])){
  712. //岗位限制条件的判断
  713. $post_limit = json_decode($post_info['limit'],true);
  714. if(is_array($post_limit)){
  715. foreach($post_limit as $k => $v){
  716. if($k == 'birthday'){
  717. $value = str_replace('-','',$data[$k]);
  718. }else{
  719. $value = $data[$k];
  720. }
  721. switch ($v['op']){
  722. case '=':
  723. if($value != $v['value']){
  724. return response()->json(['status' => 0,'msg' => $v['msg']]);
  725. }
  726. break;
  727. case '>':
  728. if($value <= $v['value']){
  729. return response()->json(['status' => 0,'msg' => $v['msg']]);
  730. }
  731. break;
  732. case '>=':
  733. if($value < $v['value']){
  734. return response()->json(['status' => 0,'msg' => $v['msg']]);
  735. }
  736. break;
  737. case '<':
  738. if($value >= $v['value']){
  739. return response()->json(['status' => 0,'msg' => $v['msg']]);
  740. }
  741. break;
  742. case '<=':
  743. if($value > $v['value']){
  744. return response()->json(['status' => 0,'msg' => $v['msg']]);
  745. }
  746. break;
  747. case '!=':
  748. if($value == $v['value']){
  749. return response()->json(['status' => 0,'msg' => $v['msg']]);
  750. }
  751. break;
  752. case 'like':
  753. if(strpos($value,$v['value']) === false){
  754. return response()->json(['status' => 0,'msg' => $v['msg']]);
  755. }
  756. break;
  757. case 'in':
  758. if(strpos($v['value'],$value) === false){
  759. return response()->json(['status' => 0,'msg' => $v['msg']]);
  760. }
  761. break;
  762. }
  763. }
  764. }
  765. }
  766. //前置审核 判断完成,先将数据入报名信息基础表
  767. //解析家庭成员数据
  768. $familys = $request->input('family');
  769. $family = [];
  770. if(is_array($familys)){
  771. foreach ($familys as $value){
  772. $item = [
  773. 'relation' => $value['relation'],
  774. 'realname' => $value['realname'],
  775. 'birthday' => $value['birthday'],
  776. 'political_affiliation' => $value['political_affiliation'],
  777. 'work' => $value['work']
  778. ];
  779. array_push($family,$item);
  780. }
  781. }
  782. $data['family'] = json_encode($family);
  783. if($appoint_info){
  784. //如果已有报名记录,进入修改阶段的处理流程
  785. DB::beginTransaction();
  786. try{
  787. RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->update($data);
  788. //分模块解析数据
  789. $forms = explode(',', $recruit['forms']);
  790. //如果有加分模块
  791. if(in_array('expand_special',$forms)){
  792. $special = $request->input('special');
  793. if($special['point_apply']){
  794. //删除掉没有成功返回路径的图片
  795. if(is_array($special['material'])){
  796. foreach ($special['material'] as $k => $v){
  797. if(!array_key_exists('response',$v)){
  798. unset($special['material'][$k]);
  799. }
  800. }
  801. }
  802. $special['material'] = json_encode($special['material']);
  803. }else{
  804. $special['condition'] = '';
  805. $special['material'] = json_encode([]);
  806. }
  807. $hasRecord = RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint_info->id)->first();
  808. if($hasRecord){
  809. RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint_info->id)->update($special);
  810. }else{
  811. $special['recruit_appoint_id'] = $appoint_info->id;
  812. RecruitAppointExpandSpecial::create($special);
  813. }
  814. }
  815. //如果有详情模块
  816. if(in_array('detail',$forms) || in_array('internship',$forms)){
  817. $detail = $request->input('detail');
  818. $hasRecord = RecruitAppointDetail::where('recruit_appoint_id',$appoint_info->id)->first();
  819. if($hasRecord){
  820. RecruitAppointDetail::where('recruit_appoint_id',$appoint_info->id)->update($detail);
  821. }else{
  822. $detail['recruit_appoint_id'] = $appoint_info->id;
  823. RecruitAppointDetail::create($detail);
  824. }
  825. }
  826. //如果有身份证明模块
  827. if(in_array('identification',$forms) || in_array('internship',$forms)){
  828. $identification = $request->input('identification');
  829. if(is_array($identification)){
  830. //删除掉没有成功返回路径的图片
  831. foreach ($identification as $k => $v){
  832. if(!array_key_exists('response',$v)){
  833. unset($identification[$k]);
  834. }
  835. }
  836. }
  837. $appoint_info->identification = json_encode($identification);
  838. $appoint_info->save();
  839. }
  840. //如果有教育证明模块
  841. if(in_array('education_certification',$forms) || in_array('internship',$forms)){
  842. $education_certification = $request->input('education_certification');
  843. if(is_array($education_certification)){
  844. //删除掉没有成功返回路径的图片
  845. foreach ($education_certification as $k => $v){
  846. if(!array_key_exists('response',$v)){
  847. unset($education_certification[$k]);
  848. }
  849. }
  850. }
  851. $appoint_info->education_certification = json_encode($education_certification);
  852. $appoint_info->save();
  853. }
  854. //如果有其他证明模块
  855. if(in_array('other_certification',$forms) || in_array('internship',$forms)){
  856. $other_certification = $request->input('other_certification');
  857. if(is_array($other_certification)){
  858. //删除掉没有成功返回路径的图片
  859. foreach ($other_certification as $k => $v){
  860. if(!array_key_exists('response',$v)){
  861. unset($other_certification[$k]);
  862. }
  863. }
  864. }
  865. if($other_certification){
  866. $appoint_info->other_certification = json_encode($other_certification);
  867. $appoint_info->save();
  868. }
  869. }
  870. DB::commit();
  871. if($operation == 2){
  872. $log = [
  873. 'type' => 3,
  874. 'appoint_id'=> $appoint_info->id,
  875. 'uid' => $uid,
  876. 'log' => '用户提交报名'
  877. ];
  878. RecruitAppointLog::create($log);
  879. return ['status' => 1, 'msg' => '提交成功', 'data' => $appoint_info->id];
  880. }else{
  881. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $appoint_info->id];
  882. }
  883. } catch (\Exception $e){
  884. DB::rollback();
  885. return ['status' => 0, 'msg' => $e->getMessage()];
  886. }
  887. }else{
  888. //没有报名记录,进入增加阶段的处理流程
  889. DB::beginTransaction();
  890. try{
  891. //20220726增加地区undefined选项处理
  892. if($index = stripos($data['native_place'],',undefined')){
  893. $data['native_place'] = substr($data['native_place'],0,$index);
  894. }
  895. if($index = stripos($data['house_register'],',undefined')){
  896. $data['house_register'] = substr($data['house_register'],0,$index);
  897. }
  898. $data['uid'] = $uid;
  899. $data['recruit_id'] = $recruit_id;
  900. $result = RecruitAppointInfo::create($data);
  901. //分模块解析数据
  902. $forms = explode(',', $recruit['forms']);
  903. //如果有加分模块
  904. if(in_array('expand_special',$forms)){
  905. $special = $request->input('special');
  906. if($special['point_apply']){
  907. if(is_array($special['material'])){
  908. //删除掉没有成功返回路径的图片
  909. foreach ($special['material'] as $k => $v){
  910. if(!array_key_exists('response',$v)){
  911. unset($special['material'][$k]);
  912. }
  913. }
  914. }
  915. $special['material'] = json_encode($special['material']);
  916. }
  917. $special['recruit_appoint_id'] = $result->id;
  918. RecruitAppointExpandSpecial::create($special);
  919. }
  920. //如果有详情模块
  921. if(in_array('detail',$forms) || in_array('internship',$forms)){
  922. $detail = $request->input('detail');
  923. $detail['recruit_appoint_id'] = $result->id;
  924. RecruitAppointDetail::create($detail);
  925. }
  926. //如果有身份证明模块
  927. if(in_array('identification',$forms) || in_array('internship',$forms)){
  928. $identification = $request->input('identification');
  929. if(is_array($identification)){
  930. //删除掉没有成功返回路径的图片
  931. foreach ($identification as $k => $v){
  932. if(!array_key_exists('response',$v)){
  933. unset($identification[$k]);
  934. }
  935. }
  936. }
  937. $result->identification = json_encode($identification);
  938. $result->save();
  939. }
  940. //如果有教育证明模块
  941. if(in_array('education_certification',$forms) || in_array('internship',$forms)){
  942. $education_certification = $request->input('education_certification');
  943. if(is_array($education_certification)){
  944. //删除掉没有成功返回路径的图片
  945. foreach ($education_certification as $k => $v){
  946. if(!array_key_exists('response',$v)){
  947. unset($education_certification[$k]);
  948. }
  949. }
  950. }
  951. $result->education_certification = json_encode($education_certification);
  952. $result->save();
  953. }
  954. //如果有其他证明模块
  955. if(in_array('other_certification',$forms) || in_array('internship',$forms)){
  956. $other_certification = $request->input('other_certification');
  957. if($other_certification){
  958. if(is_array($other_certification)){
  959. //删除掉没有成功返回路径的图片
  960. foreach ($other_certification as $k => $v){
  961. if(!array_key_exists('response',$v)){
  962. unset($other_certification[$k]);
  963. }
  964. }
  965. }
  966. $result->other_certification = json_encode($other_certification);
  967. $result->save();
  968. }
  969. }
  970. DB::commit();
  971. if($operation == 2){
  972. $log = [
  973. 'type' => 3,
  974. 'appoint_id'=> $result->id,
  975. 'uid' => $uid,
  976. 'log' => '用户首次提交报名'
  977. ];
  978. RecruitAppointLog::create($log);
  979. return ['status' => 1, 'msg' => '提交成功', 'data' => $result->id];
  980. }else{
  981. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $result->id];
  982. }
  983. } catch (\Exception $e){
  984. DB::rollback();
  985. return ['status' => 0, 'msg' => $e->getMessage()];
  986. }
  987. }
  988. }
  989. }
  990. /**
  991. * 获得当前登录的用户
  992. * @return \Illuminate\Contracts\Auth\Authenticatable|null
  993. */
  994. public function getUser()
  995. {
  996. if (auth('web-member')->check()) {
  997. $user = auth('web-member')->user();
  998. } else {
  999. $user = null;
  1000. }
  1001. return $user;
  1002. }
  1003. /**
  1004. * 检查用户基本信息
  1005. * @return array
  1006. */
  1007. public function checkUserBasicInfo()
  1008. {
  1009. $user = $this->getUser();
  1010. if (!empty($user)) {
  1011. $uid = $user->id;
  1012. } else {
  1013. $arr = ['status' => 401, 'msg'=>'请登录!'];
  1014. return $arr;
  1015. }
  1016. $info = RecruitAppointBasic::where('uid',$uid)->first();
  1017. if (empty($info)){
  1018. $arr = ['status'=>401,'msg'=>'请先完善招考基本信息','url'=> route('recruit.recruitInfo')];
  1019. return $arr;
  1020. }
  1021. return ['status' => 200, 'msg' => ''];
  1022. }
  1023. /**
  1024. * 个人中心招考页面
  1025. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  1026. */
  1027. public function person_recruit()
  1028. {
  1029. $user = auth('web-member')->user();
  1030. $list = RecruitAppointInfo::where('uid',$user->id)
  1031. ->join('recruit', 'recruit.id', '=', 'recruit_appoint_info.recruit_id', 'left')
  1032. ->join('recruit_post', 'recruit_post.id', '=', 'recruit_appoint_info.post_id', 'left')
  1033. ->select('recruit.name as recruit_name','recruit_appoint_info.*','recruit_post.code','recruit_post.name')
  1034. ->get();
  1035. return view('app.person.recruit')->with(['list' => $list,'total' => count($list)]);
  1036. }
  1037. /**
  1038. * 招考信息基础页
  1039. * @param Request $request
  1040. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  1041. */
  1042. public function recruit_info(Request $request)
  1043. {
  1044. $user = auth('web-member')->user();
  1045. if (!empty($user)) {
  1046. $uid = $user->id;
  1047. } else {
  1048. return redirect(route('login'));
  1049. }
  1050. $info = RecruitAppointBasic::where('uid',$user->id)->first();
  1051. if(!$info){
  1052. $info = [
  1053. 'realname' => '',
  1054. 'sex' => '0',
  1055. 'birthday' => '',
  1056. 'avatar' => '',
  1057. 'nation' => '',
  1058. 'native_place' => '',
  1059. 'political_affiliation' => '',
  1060. 'titles' => '',
  1061. 'work' => '',
  1062. 'house_register' => '',
  1063. 'join_time' => '',
  1064. 'edu_type' => '',
  1065. 'education' => '',
  1066. 'school' => '',
  1067. 'degree' => '',
  1068. 'pro' => '',
  1069. 'address' => '',
  1070. 'card' => '',
  1071. 'mobile' => '',
  1072. 'email' => '',
  1073. 'concat_name' => '',
  1074. 'concat_mobile' => '',
  1075. 'resume' => '',
  1076. 'family' => [
  1077. [
  1078. 'relation' => '',
  1079. 'realname' => '',
  1080. 'birthday' => '',
  1081. 'political_affiliation' => '',
  1082. 'work' => ''
  1083. ]
  1084. ],
  1085. 'is_push' => '1'
  1086. ];
  1087. }else{
  1088. $info->sex = (string)$info->sex;
  1089. $info->edu_type = (string)$info->edu_type;
  1090. $info->is_push = (string)$info->is_push;
  1091. $info->family = empty($info->family) ? [[
  1092. 'relation' => '',
  1093. 'realname' => '',
  1094. 'birthday' => '',
  1095. 'political_affiliation' => '',
  1096. 'work' => ''
  1097. ]] : json_decode($info->family);
  1098. }
  1099. $recruit_id = $request->input('recruit_id',0);
  1100. return view('app.person.recruit_info',[
  1101. 'info' => json_encode($info),
  1102. 'recruit_id'=> $recruit_id
  1103. ]);
  1104. }
  1105. /**
  1106. * 保存招考信息
  1107. * @param RecruitValidatorRequest $request
  1108. * @return \Illuminate\Http\JsonResponse
  1109. */
  1110. public function saveRecruitInfo(RecruitValidatorRequest $request)
  1111. {
  1112. $user = auth('web-member')->user();
  1113. $basic = RecruitAppointBasic::where('uid',$user->id)->first();
  1114. $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');
  1115. if(count($data['family']) > 0){
  1116. $data['family'] = json_encode($data['family']);
  1117. }
  1118. if($basic){
  1119. //更新基础信息
  1120. $res = RecruitAppointBasic::where('uid',$user->id)->update($data);
  1121. if (!$res) {
  1122. return response()->json(['status'=>0,'msg'=>'保存失败,请联系客服']);
  1123. }else{
  1124. return response()->json(['status'=>1,'msg'=>'个人基础信息保存成功,快去报名吧!']);
  1125. }
  1126. }else{
  1127. //新增基础信息
  1128. $data['uid'] = $user->id;
  1129. $res = RecruitAppointBasic::create($data);
  1130. if (!$res) {
  1131. return response()->json(['status'=>0,'msg'=>'保存失败,请联系客服']);
  1132. }else{
  1133. return response()->json(['status'=>1,'msg'=>'个人基础信息保存成功,快去报名吧!']);
  1134. }
  1135. }
  1136. }
  1137. /**
  1138. * 笔试准考证
  1139. * @param Request $request
  1140. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1141. */
  1142. public function pen_ticket(Request $request)
  1143. {
  1144. $user = $this->getUser();
  1145. if (!empty($user)) {
  1146. $uid = $user->id;
  1147. } else {
  1148. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1149. }
  1150. $recruit_id = $request->input('recruit_id');
  1151. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1152. if($appoint_info){
  1153. $pen_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',1)->first();
  1154. if($pen_ticket){
  1155. $health = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();
  1156. if(!$health || $health->h_status == 0){
  1157. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1158. }
  1159. $time = time();
  1160. if(strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time){
  1161. RecruitTicket::where('appoint_id',$appoint_info->id)->update(['ex_status' => 1]);
  1162. $recruit = Recruit::where('id',$recruit_id)->first();
  1163. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1164. $name = $recruit->name_en;
  1165. $date = date("Y-m-d",strtotime($recruit->created_at));
  1166. $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1167. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/pen/" . $filename . '.pdf';
  1168. if(file_exists($file)){
  1169. header('Content-Description: File Transfer');
  1170. header('Content-Type: application/octet-stream');
  1171. header('Content-Disposition: attachment; filename='.basename($file));
  1172. header('Content-Transfer-Encoding: binary');
  1173. header('Expires: 0');
  1174. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1175. header('Pragma: public');
  1176. header('Content-Length: ' . filesize($file));
  1177. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1178. flush();
  1179. readfile($file);
  1180. }
  1181. }else{
  1182. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1183. }
  1184. }else{
  1185. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1186. }
  1187. }else{
  1188. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1189. }
  1190. }
  1191. /**
  1192. * 审核准考证
  1193. * @param Request $request
  1194. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1195. */
  1196. public function check_ticket(Request $request)
  1197. {
  1198. $user = $this->getUser();
  1199. if (!empty($user)) {
  1200. $uid = $user->id;
  1201. } else {
  1202. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1203. }
  1204. $recruit_id = $request->input('recruit_id');
  1205. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1206. if($appoint_info){
  1207. $check_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',2)->first();
  1208. if($check_ticket){
  1209. $time = time();
  1210. if(strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time){
  1211. RecruitTicket::where('appoint_id',$appoint_info->id)->update(['ex_status' => 1]);
  1212. $recruit = Recruit::where('id',$recruit_id)->first();
  1213. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1214. $name = $recruit->name_en;
  1215. $date = date("Y-m-d",strtotime($recruit->created_at));
  1216. $filename = date("Y-m-18",time()) . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1217. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/check/" . $filename . '.pdf';
  1218. if(file_exists($file)){
  1219. header('Content-Description: File Transfer');
  1220. header('Content-Type: application/octet-stream');
  1221. header('Content-Disposition: attachment; filename='.basename($file));
  1222. header('Content-Transfer-Encoding: binary');
  1223. header('Expires: 0');
  1224. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1225. header('Pragma: public');
  1226. header('Content-Length: ' . filesize($file));
  1227. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1228. flush();
  1229. readfile($file);
  1230. }
  1231. }else{
  1232. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1233. }
  1234. }else{
  1235. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1236. }
  1237. }else{
  1238. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1239. }
  1240. }
  1241. /**
  1242. * 面试准考证
  1243. * @param Request $request
  1244. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1245. */
  1246. public function face_ticket(Request $request)
  1247. {
  1248. $user = $this->getUser();
  1249. if (!empty($user)) {
  1250. $uid = $user->id;
  1251. } else {
  1252. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1253. }
  1254. $recruit_id = $request->input('recruit_id');
  1255. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1256. if($appoint_info){
  1257. $face_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',3)->first();
  1258. if($face_ticket){
  1259. $health = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();
  1260. if(!$health || $health->h_status == 0){
  1261. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1262. }
  1263. $time = time();
  1264. if(strtotime($face_ticket->ex_start) < $time && strtotime($face_ticket->ex_end) > $time){
  1265. RecruitTicket::where('id',$face_ticket->id)->update(['ex_status' => 1]);
  1266. $recruit = Recruit::where('id',$recruit_id)->first();
  1267. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1268. $name = $recruit->name_en;
  1269. $date = date("Y-m-d",strtotime($recruit->created_at));
  1270. $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1271. $file = base_path() . "/storage/app/public/recruit/ticket/word/{$date}/{$name}/face/" . $filename . '.docx';
  1272. if(file_exists($file)){
  1273. header('Content-Description: File Transfer');
  1274. header('Content-Type: application/octet-stream');
  1275. header('Content-Disposition: attachment; filename='.basename($file));
  1276. header('Content-Transfer-Encoding: binary');
  1277. header('Expires: 0');
  1278. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1279. header('Pragma: public');
  1280. header('Content-Length: ' . filesize($file));
  1281. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1282. flush();
  1283. readfile($file);
  1284. }
  1285. }else{
  1286. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1287. }
  1288. }else{
  1289. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1290. }
  1291. }else{
  1292. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1293. }
  1294. }
  1295. /**
  1296. * 复试准考证
  1297. * @param Request $request
  1298. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1299. */
  1300. public function reexamine_ticket(Request $request)
  1301. {
  1302. $user = $this->getUser();
  1303. if (!empty($user)) {
  1304. $uid = $user->id;
  1305. } else {
  1306. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1307. }
  1308. $recruit_id = $request->input('recruit_id');
  1309. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1310. if($appoint_info){
  1311. $reexamine_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',4)->first();
  1312. if($reexamine_ticket){
  1313. $time = time();
  1314. if(strtotime($reexamine_ticket->ex_start) < $time && strtotime($reexamine_ticket->ex_end) > $time){
  1315. RecruitTicket::where('id',$reexamine_ticket->id)->update(['ex_status' => 1]);
  1316. $recruit = Recruit::where('id',$recruit_id)->first();
  1317. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1318. $name = $recruit->name_en;
  1319. $date = date("Y-m-d",strtotime($recruit->created_at));
  1320. $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id].'_create';
  1321. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';
  1322. if(file_exists($file)){
  1323. header('Content-Description: File Transfer');
  1324. header('Content-Type: application/octet-stream');
  1325. header('Content-Disposition: attachment; filename='.basename($file));
  1326. header('Content-Transfer-Encoding: binary');
  1327. header('Expires: 0');
  1328. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1329. header('Pragma: public');
  1330. header('Content-Length: ' . filesize($file));
  1331. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1332. flush();
  1333. readfile($file);
  1334. }
  1335. }else{
  1336. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1337. }
  1338. }else{
  1339. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1340. }
  1341. }else{
  1342. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1343. }
  1344. }
  1345. /**
  1346. * 材料补登
  1347. * @param Request $request
  1348. */
  1349. public function material_supplement(Request $request)
  1350. {
  1351. $user = $this->getUser();
  1352. if (!empty($user)) {
  1353. $uid = $user->id;
  1354. } else {
  1355. return redirect(route('login'));
  1356. }
  1357. //招考id
  1358. $id = $request->input('id', 0);
  1359. if (!$id) {
  1360. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1361. }
  1362. $recruit = Recruit::find($id);
  1363. if(!$recruit['status'] && !$user->recruit_test){
  1364. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1365. }
  1366. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  1367. if(!$appoint_info){
  1368. return $this->showMessage('抱歉,您没有报名,无需考察审核!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1369. }
  1370. if($appoint_info->pen_audit != 1){
  1371. return $this->showMessage('抱歉,您未入闱,无需考察审核!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1372. }
  1373. $limit_time = 1662543000;
  1374. $time = time();
  1375. if( $time > $limit_time){
  1376. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1377. }
  1378. $info = RecruitSupplement::where('appoint_id',$appoint_info->id)->where('type','supplement')->first();
  1379. if(!$info){
  1380. $info = [
  1381. 'appoint_id' => $appoint_info->id,
  1382. 'identification' => '',
  1383. 'household_register' => '',
  1384. 'education_certification' => '',
  1385. //'family_planning' => '',
  1386. 'manage' => '',
  1387. 'status' => 3
  1388. ];
  1389. }else{
  1390. $info = $info->toArray();
  1391. if(json_decode($info['identification'])){
  1392. $identification = json_decode($info['identification'],true);
  1393. foreach ($identification as $k => $v){
  1394. if(array_key_exists('response',$v)){
  1395. $identification[$k]['url'] = $v['response']['path'];
  1396. }
  1397. }
  1398. }else{
  1399. $identification = [];
  1400. }
  1401. $info['identification'] = $identification;
  1402. if(json_decode($info['household_register'])){
  1403. $household_register = json_decode($info['household_register'],true);
  1404. foreach ($household_register as $k => $v){
  1405. if(array_key_exists('response',$v)){
  1406. $household_register[$k]['url'] = $v['response']['path'];
  1407. }
  1408. }
  1409. }else{
  1410. $household_register = [];
  1411. }
  1412. $info['household_register'] = $household_register;
  1413. if(json_decode($info['education_certification'])){
  1414. $education_certification = json_decode($info['education_certification'],true);
  1415. foreach ($education_certification as $k => $v){
  1416. if(array_key_exists('response',$v)){
  1417. $education_certification[$k]['url'] = $v['response']['path'];
  1418. }
  1419. }
  1420. }else{
  1421. $education_certification = [];
  1422. }
  1423. $info['education_certification'] = $education_certification;
  1424. if(json_decode($info['family_planning'])){
  1425. $family_planning = json_decode($info['family_planning'],true);
  1426. foreach ($family_planning as $k => $v){
  1427. if(array_key_exists('response',$v)){
  1428. $family_planning[$k]['url'] = $v['response']['path'];
  1429. }
  1430. }
  1431. }else{
  1432. $family_planning = [];
  1433. }
  1434. $info['family_planning'] = $family_planning;
  1435. if(json_decode($info['manage'])){
  1436. $manage = json_decode($info['manage'],true);
  1437. foreach ($manage as $k => $v){
  1438. if(array_key_exists('response',$v)){
  1439. $manage[$k]['url'] = $v['response']['path'];
  1440. }
  1441. }
  1442. }else{
  1443. $manage = [];
  1444. }
  1445. $info['manage'] = $manage;
  1446. }
  1447. $view_data['info'] = json_encode($info);
  1448. $view_data['title'] = $recruit->company;
  1449. return view('app.recruit.supplement',$view_data);
  1450. }
  1451. /**
  1452. * 健康信息登记
  1453. * @param Request $request
  1454. */
  1455. public function health_info(Request $request)
  1456. {
  1457. $user = $this->getUser();
  1458. if (!empty($user)) {
  1459. $uid = $user->id;
  1460. } else {
  1461. return redirect(route('login'));
  1462. }
  1463. //招考id
  1464. $id = $request->input('id', 0);
  1465. if (!$id) {
  1466. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1467. }
  1468. $recruit = Recruit::find($id);
  1469. if(!$recruit['status'] && !$user->recruit_test){
  1470. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1471. }
  1472. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  1473. if(!$appoint_info){
  1474. return $this->showMessage('抱歉,您没有报名,无需登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1475. }
  1476. if($appoint_info->audit != 3){
  1477. return $this->showMessage('抱歉,您无需登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1478. }
  1479. $time = time();
  1480. $type = $request->input('type',null);
  1481. $where = [];
  1482. if($type){
  1483. switch ($type){
  1484. case 'pen':
  1485. $start = strtotime($recruit->pen_health_start);
  1486. $end = strtotime($recruit->pen_health_end);
  1487. break;
  1488. case 'computer':
  1489. $start = strtotime($recruit->computer_health_start);
  1490. $end = strtotime($recruit->computer_health_end);
  1491. break;
  1492. case 'face':
  1493. $start = strtotime($recruit->face_health_start);
  1494. $end = strtotime($recruit->face_health_end);
  1495. break;
  1496. default:
  1497. $start = strtotime($recruit->supplement_start);
  1498. $end = strtotime($recruit->supplement_end);
  1499. break;
  1500. }
  1501. $where[] = ['type', '=', $type];
  1502. }else{
  1503. $start = strtotime($recruit->supplement_start);
  1504. $end = strtotime($recruit->supplement_end);
  1505. }
  1506. if($time > $end || $time < $start){
  1507. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1508. }
  1509. $where[] = ['appoint_id', '=', $appoint_info->id];
  1510. $info = RecruitSupplement::where($where)->first();
  1511. if(!$info){
  1512. $info = [
  1513. 'appoint_id' => $appoint_info->id,
  1514. 'health_code' => '',
  1515. 'trip_code' => '',
  1516. 'type' => $type
  1517. ];
  1518. }else{
  1519. $info = $info->toArray();
  1520. if(json_decode($info['health_code'])){
  1521. $health_code = json_decode($info['health_code'],true);
  1522. foreach ($health_code as $k => $v){
  1523. if(array_key_exists('response',$v)){
  1524. $health_code[$k]['url'] = $v['response']['path'];
  1525. }
  1526. }
  1527. }else{
  1528. $health_code = [];
  1529. }
  1530. $info['health_code'] = $health_code;
  1531. if(json_decode($info['trip_code'])){
  1532. $trip_code = json_decode($info['trip_code'],true);
  1533. foreach ($trip_code as $k => $v){
  1534. if(array_key_exists('response',$v)){
  1535. $trip_code[$k]['url'] = $v['response']['path'];
  1536. }
  1537. }
  1538. }else{
  1539. $trip_code = [];
  1540. }
  1541. $info['trip_code'] = $trip_code;
  1542. }
  1543. $view_data['info'] = json_encode($info);
  1544. $view_data['title'] = $recruit->company;
  1545. return view('app.recruit.health',$view_data);
  1546. }
  1547. public function save_supplement(Request $request)
  1548. {
  1549. $user = $this->getUser();
  1550. if (!empty($user)) {
  1551. $uid = $user->id;
  1552. } else {
  1553. return redirect(route('login'));
  1554. }
  1555. $limit_time = 1662543000;
  1556. $time = time();
  1557. if( $time > $limit_time){
  1558. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',18)), true, '上一页', '3');
  1559. }
  1560. $appoint_id = $request->input('appoint_id');
  1561. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',18)->where('id',$appoint_id)->first();
  1562. if(!$appoint_info){
  1563. return ['status' => 0, 'msg' => '抱歉,找不到您要补登的报名记录!'];
  1564. }
  1565. $info = RecruitSupplement::where('appoint_id',$appoint_id)->where('type','supplement')->first();
  1566. if($info){
  1567. if($info->status == 1){
  1568. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  1569. }
  1570. if($info->status == 0){
  1571. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  1572. }
  1573. //身份证明
  1574. $identification = $request->input('identification');
  1575. if(is_array($identification)){
  1576. //删除掉没有成功返回路径的图片
  1577. foreach ($identification as $k => $v){
  1578. if(!array_key_exists('response',$v)){
  1579. unset($identification[$k]);
  1580. }
  1581. }
  1582. }
  1583. $info->identification = json_encode($identification);
  1584. //户口簿
  1585. $household_register = $request->input('household_register');
  1586. if(is_array($household_register)){
  1587. //删除掉没有成功返回路径的图片
  1588. foreach ($household_register as $k => $v){
  1589. if(!array_key_exists('response',$v)){
  1590. unset($household_register[$k]);
  1591. }
  1592. }
  1593. }
  1594. $info->household_register = json_encode($household_register);
  1595. //学信网
  1596. $education_certification = $request->input('education_certification');
  1597. if(is_array($education_certification)){
  1598. //删除掉没有成功返回路径的图片
  1599. foreach ($education_certification as $k => $v){
  1600. if(!array_key_exists('response',$v)){
  1601. unset($education_certification[$k]);
  1602. }
  1603. }
  1604. }
  1605. $info->education_certification = json_encode($education_certification);
  1606. //计生
  1607. // $family_planning = $request->input('family_planning');
  1608. // if(is_array($family_planning)){
  1609. // //删除掉没有成功返回路径的图片
  1610. // foreach ($family_planning as $k => $v){
  1611. // if(!array_key_exists('response',$v)){
  1612. // unset($family_planning[$k]);
  1613. // }
  1614. // }
  1615. // }
  1616. // $info->family_planning = json_encode($family_planning);
  1617. //综治
  1618. $manage = $request->input('manage');
  1619. if(is_array($manage)){
  1620. //删除掉没有成功返回路径的图片
  1621. foreach ($manage as $k => $v){
  1622. if(!array_key_exists('response',$v)){
  1623. unset($manage[$k]);
  1624. }
  1625. }
  1626. }
  1627. $info->manage = json_encode($manage);
  1628. $info->status = 0;
  1629. $info->save();
  1630. $appoint_info->political_audit = 4;
  1631. $appoint_info->save();
  1632. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1633. }else{
  1634. $data['appoint_id'] = $appoint_id;
  1635. //身份证明
  1636. $identification = $request->input('identification');
  1637. if(is_array($identification)){
  1638. //删除掉没有成功返回路径的图片
  1639. foreach ($identification as $k => $v){
  1640. if(!array_key_exists('response',$v)){
  1641. unset($identification[$k]);
  1642. }
  1643. }
  1644. }
  1645. $data['identification'] = json_encode($identification);
  1646. //户口簿
  1647. $household_register = $request->input('household_register');
  1648. if(is_array($household_register)){
  1649. //删除掉没有成功返回路径的图片
  1650. foreach ($household_register as $k => $v){
  1651. if(!array_key_exists('response',$v)){
  1652. unset($household_register[$k]);
  1653. }
  1654. }
  1655. }
  1656. $data['household_register'] = json_encode($household_register);
  1657. //学信网
  1658. $education_certification = $request->input('education_certification');
  1659. if(is_array($education_certification)){
  1660. //删除掉没有成功返回路径的图片
  1661. foreach ($education_certification as $k => $v){
  1662. if(!array_key_exists('response',$v)){
  1663. unset($education_certification[$k]);
  1664. }
  1665. }
  1666. }
  1667. $data['education_certification'] = json_encode($education_certification);
  1668. //计生
  1669. // $family_planning = $request->input('family_planning');
  1670. // if(is_array($family_planning)){sp
  1671. // //删除掉没有成功返回路径的图片
  1672. // foreach ($family_planning as $k => $v){
  1673. // if(!array_key_exists('response',$v)){
  1674. // unset($family_planning[$k]);
  1675. // }
  1676. // }
  1677. // }
  1678. // $data['family_planning'] = json_encode($family_planning);
  1679. //综治
  1680. $manage = $request->input('manage');
  1681. if(is_array($manage)){
  1682. //删除掉没有成功返回路径的图片
  1683. foreach ($manage as $k => $v){
  1684. if(!array_key_exists('response',$v)){
  1685. unset($manage[$k]);
  1686. }
  1687. }
  1688. }
  1689. $data['manage'] = json_encode($manage);
  1690. $data['status'] = 0;
  1691. $data['type'] = 'supplement';
  1692. $result = RecruitSupplement::create($data);
  1693. $appoint_info->political_audit = 4;
  1694. $appoint_info->save();
  1695. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1696. }
  1697. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  1698. }
  1699. public function save_healthinfo(Request $request)
  1700. {
  1701. $user = $this->getUser();
  1702. if (!empty($user)) {
  1703. $uid = $user->id;
  1704. } else {
  1705. return redirect(route('login'));
  1706. }
  1707. $appoint_id = $request->input('appoint_id');
  1708. $type = $request->input('type');
  1709. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('id',$appoint_id)->first();
  1710. if(!$appoint_info){
  1711. return ['status' => 0, 'msg' => '抱歉,找不到您要登记的报名记录!'];
  1712. }
  1713. $recruit = Recruit::where('id',$appoint_info->recruit_id)->first();
  1714. $info = RecruitSupplement::where('appoint_id',$appoint_id)->where('type',$type)->first();
  1715. if($info){
  1716. if($info->h_status == 1){
  1717. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  1718. }
  1719. if($info->h_status == 0){
  1720. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  1721. }
  1722. $health_code = $request->input('health_code');
  1723. if(is_array($health_code)){
  1724. //删除掉没有成功返回路径的图片
  1725. foreach ($health_code as $k => $v){
  1726. if(!array_key_exists('response',$v)){
  1727. unset($health_code[$k]);
  1728. }
  1729. }
  1730. }
  1731. $info->health_code = json_encode($health_code);
  1732. $trip_code = $request->input('trip_code');
  1733. if(is_array($trip_code)){
  1734. //删除掉没有成功返回路径的图片
  1735. foreach ($trip_code as $k => $v){
  1736. if(!array_key_exists('response',$v)){
  1737. unset($trip_code[$k]);
  1738. }
  1739. }
  1740. }
  1741. $info->trip_code = json_encode($trip_code);
  1742. $info->h_status = 0;
  1743. $appoint_info->health_audit = 4;
  1744. $appoint_info->save();
  1745. $info->save();
  1746. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1747. }else{
  1748. $data['appoint_id'] = $appoint_id;
  1749. $data['type'] = $type;
  1750. $data['h_status'] = 0;
  1751. $appoint_info->health_audit = 4;
  1752. $health_code = $request->input('health_code');
  1753. if(is_array($health_code)){
  1754. //删除掉没有成功返回路径的图片
  1755. foreach ($health_code as $k => $v){
  1756. if(!array_key_exists('response',$v)){
  1757. unset($health_code[$k]);
  1758. }
  1759. }
  1760. }
  1761. $health_result = $this->baiduService->health_code(file_get_contents(base_path() . "/public" . $health_code[0]['response']['path']));
  1762. $health_msg = ['健康码自动审核通过'];
  1763. //$h_status = 1;
  1764. //$appoint_info->health_audit = 1;
  1765. if(!array_key_exists('error_msg',$health_result) && !array_key_exists('error_code',$health_result)){
  1766. if(array_key_exists('姓名',$health_result)){
  1767. if(stripos($health_result['姓名'][0]['word'],'*')>0){
  1768. return ['status' => 0, 'msg' => '请打开健康码的“眼睛开关”,显示完整个人信息'];
  1769. }
  1770. if($health_result['姓名'][0]['word'] != $appoint_info->realname){
  1771. array_push($health_msg,'抱歉,请上传您本人的健康码!');
  1772. }
  1773. }else{
  1774. array_push($health_msg,'健康码错误,识别不到姓名!');
  1775. }
  1776. if(array_key_exists('状态',$health_result)){
  1777. if($health_result['状态'][0]['word'] != '绿码'){
  1778. array_push($health_msg,'抱歉,您的健康码非绿码!');
  1779. }
  1780. }else{
  1781. array_push($health_msg,'健康码错误,识别不到状态!');
  1782. }
  1783. if(array_key_exists('更新时间',$health_result)){
  1784. $time = strtotime($health_result['更新时间'][0]['word']);
  1785. if($time < strtotime($recruit->pen_health_start) || $time > strtotime($recruit->pen_health_end)){
  1786. array_push($health_msg,'抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的健康码!');
  1787. }
  1788. }else{
  1789. array_push($health_msg,'健康码错误,识别不到时间!');
  1790. }
  1791. //$data['h_status'] = $h_status;
  1792. $data['h_msg'] = implode(';',$health_msg);
  1793. //$appoint_info->health_audit = $h_status == 1 ? 1 : 4;
  1794. $data['health_code'] = json_encode($health_code);
  1795. }
  1796. $data['health_result'] = json_encode($health_result);
  1797. $trip_code = $request->input('trip_code');
  1798. if(is_array($trip_code)){
  1799. //删除掉没有成功返回路径的图片
  1800. foreach ($trip_code as $k => $v){
  1801. if(!array_key_exists('response',$v)){
  1802. unset($trip_code[$k]);
  1803. }
  1804. }
  1805. }
  1806. $trip_result = $this->baiduService->trip_code(file_get_contents(base_path() . "/public" . $trip_code[0]['response']['path']));
  1807. $trip_msg = [];
  1808. $trip_status = 0;
  1809. if(!array_key_exists('error_msg',$trip_result) && !array_key_exists('error_code',$trip_result)){
  1810. if(array_key_exists('途经地',$trip_result['result'])){
  1811. $fangyi_area = explode("\r\n",config('aix.fangyi.fangyi_zhaokao.fangyi_zhaokao.risk_area'));
  1812. $result = array_intersect($fangyi_area,$trip_result['result']['途经地'][0]['word']);
  1813. if(count($result) > 0){
  1814. array_push($trip_msg,'抱歉,您的行程中包含系统设置中高风险地区!');
  1815. $trip_status = 0;
  1816. }
  1817. }
  1818. if(array_key_exists('风险性',$trip_result['result']) && $trip_result['result']['风险性']){
  1819. array_push($trip_msg,'抱歉,您的行程可能含有风险!');
  1820. $trip_status = 0;
  1821. }
  1822. if(array_key_exists('更新时间',$trip_result['result'])){
  1823. $time = strtotime($trip_result['result']['更新时间'][0]['word'][0]);
  1824. if($time > strtotime($recruit->pen_health_start) || $recruit < ($recruit->pen_health_end)){
  1825. array_push($trip_msg,'抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的行程码!');
  1826. $trip_status = 0;
  1827. }
  1828. }
  1829. $data['h_msg'] .= implode(';',$trip_msg);
  1830. }
  1831. $data['trip_result'] = json_encode($trip_result);
  1832. $data['trip_code'] = json_encode($trip_code);
  1833. $data['h_status'] = 0;
  1834. $appoint_info->health_audit = 4;
  1835. RecruitSupplement::create($data);
  1836. $appoint_info->save();
  1837. return ['status' => 1, 'msg' => '提交成功,请刷新查看审核结果', 'data' => ''];
  1838. }
  1839. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  1840. }
  1841. public function post_select(Request $request)
  1842. {
  1843. $user = $this->getUser();
  1844. if (!empty($user)) {
  1845. $uid = $user->id;
  1846. } else {
  1847. return redirect(route('login'));
  1848. }
  1849. $recruit_id = $request->input('recruit_id');
  1850. //$appoint_id = $request->input('appoint_id');
  1851. $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1852. if(!$info){
  1853. return $this->showMessage('抱歉,您无需择岗!', route('recruit.show',array('id',$recruit_id)), true, '上一页', '2');
  1854. }
  1855. //手动设置择岗时间段
  1856. $time = time();
  1857. if($time > 1663300800 || $time < 1663200000){
  1858. return $this->showMessage('抱歉,未到择岗时间!', route('recruit.show',array('id',$recruit_id)), true, '上一页', '2');
  1859. }
  1860. $option_list = [
  1861. [
  1862. 'id' => 6,
  1863. 'name' => '新塘街道'
  1864. ],
  1865. [
  1866. 'id' => 7,
  1867. 'name' => '陈埭镇'
  1868. ],
  1869. [
  1870. 'id' => 8,
  1871. 'name' => '池店镇'
  1872. ],
  1873. [
  1874. 'id' => 9,
  1875. 'name' => '安海镇'
  1876. ],
  1877. [
  1878. 'id' => 10,
  1879. 'name' => '磁灶镇'
  1880. ],
  1881. [
  1882. 'id' => 11,
  1883. 'name' => '内坑镇'
  1884. ],
  1885. [
  1886. 'id' => 13,
  1887. 'name' => '东石镇'
  1888. ],
  1889. [
  1890. 'id' => 14,
  1891. 'name' => '永和镇'
  1892. ],
  1893. [
  1894. 'id' => 15,
  1895. 'name' => '英林镇'
  1896. ],
  1897. [
  1898. 'id' => 16,
  1899. 'name' => '金井镇'
  1900. ],
  1901. [
  1902. 'id' => 17,
  1903. 'name' => '龙湖镇'
  1904. ],
  1905. [
  1906. 'id' => 18,
  1907. 'name' => '深沪镇'
  1908. ],
  1909. [
  1910. 'id' => 19,
  1911. 'name' => '西滨镇'
  1912. ]
  1913. ];
  1914. $select_list = [];
  1915. if($info->result){
  1916. $result = json_decode($info->result,true);
  1917. foreach ($result as $v){
  1918. $item['name'] = $v;
  1919. array_push($select_list,$item);
  1920. }
  1921. }
  1922. // $recruit_id = $request->input('recruit_id');
  1923. // $appoint_id = $request->input('appoint_id');
  1924. // $uid = $request->input('uid');
  1925. // $info = RecruitAppointSelect::where('uid',$uid)->first();
  1926. // if(!$info){
  1927. // $info = new \stdClass();
  1928. // $info->status = 0;
  1929. // $info->recruit_id = 8;
  1930. // $info->appoint_id = rand(0,999999);
  1931. // $info->uid = rand(0,999999);
  1932. // }else{
  1933. // $result = json_decode($info->result,true);
  1934. // foreach ($option_list as $k => $v){
  1935. // if(in_array($v['name'],$result)){
  1936. // $select_list[$k] = $v;
  1937. // unset($option_list[$k]);
  1938. // }
  1939. // }
  1940. // }
  1941. $view_data = ['info' => $info,'options_list' => json_encode($option_list),'select_list' => json_encode($select_list)];
  1942. return view('app.recruit.post_select',$view_data);
  1943. }
  1944. /**
  1945. * 放弃择岗
  1946. */
  1947. public function give_up_post(Request $request)
  1948. {
  1949. //以下为测试环境
  1950. // $recruit_id = $request->input('recruit_id');
  1951. // $appoint_id = $request->input('appoint_id');
  1952. // $uid = $request->input('uid');
  1953. // $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
  1954. // if($info){
  1955. // return ['status' => 0, 'msg' => "测试数据重复,请重新点击生成测试数据!"];
  1956. // }
  1957. // RecruitAppointSelect::create(['recruit_id'=>$recruit_id,'appoint_id'=>$appoint_id,'uid'=>$uid,'status'=>-1]);
  1958. // return ['status' => 1, 'msg' => "放弃择岗成功!"];
  1959. //以下为正式环境再放开
  1960. $user = $this->getUser();
  1961. if (!empty($user)) {
  1962. $uid = $user->id;
  1963. } else {
  1964. return redirect(route('login'));
  1965. }
  1966. $recruit_id = $request->input('recruit_id');
  1967. $appoint_id = $request->input('appoint_id');
  1968. $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
  1969. if($info == null){
  1970. return ['status' => 0, 'msg' => "抱歉,您无需择岗!"];
  1971. }
  1972. if($info->status != 0){
  1973. return ['status' => 0, 'msg' => "抱歉,您不是待择岗状态!"];
  1974. }
  1975. $info->status = -1;
  1976. $info->save();
  1977. return ['status' => 1, 'msg' => "放弃择岗成功!"];
  1978. }
  1979. public function comfirm_post(Request $request)
  1980. {
  1981. $user = $this->getUser();
  1982. if (!empty($user)) {
  1983. $uid = $user->id;
  1984. } else {
  1985. return redirect(route('login'));
  1986. }
  1987. $recruit_id = $request->input('recruit_id');
  1988. $appoint_id = $request->input('appoint_id');
  1989. $time = time();
  1990. if($time > 1663300800 || $time < 1663200000){
  1991. return $this->showMessage('抱歉,未到择岗时间!', route('recruit.show',array('id',$recruit_id)), true, '上一页', '2');
  1992. }
  1993. $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
  1994. if($info->result){
  1995. return ['status' => 0, 'msg' => "择岗数据已提交!"];
  1996. }
  1997. // $data = [
  1998. // 'recruit_id' => $recruit_id,
  1999. // 'appoint_id' => $recruit_id,
  2000. // 'uid' => $uid,
  2001. // 'status' => 1
  2002. // ];
  2003. $result = [];
  2004. $select = $request->input('select');
  2005. if(is_array($select) && count($select) > 0){
  2006. foreach ($select as $v) {
  2007. array_push($result,$v['name']);
  2008. }
  2009. }
  2010. $info->result = json_encode($result);
  2011. $info->status = 1;
  2012. $info->save();
  2013. return ['status' => 1, 'msg' => "提交择岗意愿成功,请耐心等待结果!"];
  2014. }
  2015. public function select_result(Request $request)
  2016. {
  2017. return view('app.recruit.select_result');
  2018. }
  2019. public function get_select_result(Request $request)
  2020. {
  2021. $redis = Cache::getRedis();
  2022. $quota = $redis->get('recruit_quota');
  2023. if(!$quota){
  2024. $quota = [
  2025. [
  2026. 'name' => '新塘街道',
  2027. 'value' => 13
  2028. ],
  2029. [
  2030. 'name' => '陈埭镇',
  2031. 'value' => 88
  2032. ],
  2033. [
  2034. 'name' => '池店镇',
  2035. 'value' => 10
  2036. ],
  2037. [
  2038. 'name' => '安海镇',
  2039. 'value' => 10
  2040. ],
  2041. [
  2042. 'name' => '磁灶镇',
  2043. 'value' => 21
  2044. ],
  2045. [
  2046. 'name' => '内坑镇',
  2047. 'value' => 22
  2048. ],
  2049. [
  2050. 'name' => '东石镇',
  2051. 'value' => 4
  2052. ],
  2053. [
  2054. 'name' => '永和镇',
  2055. 'value' => 27
  2056. ],
  2057. [
  2058. 'name' => '英林镇',
  2059. 'value' => 5
  2060. ],
  2061. [
  2062. 'name' => '金井镇',
  2063. 'value' => 13
  2064. ],
  2065. [
  2066. 'name' => '龙湖镇',
  2067. 'value' => 53
  2068. ],
  2069. [
  2070. 'name' => '深沪镇',
  2071. 'value' => 23
  2072. ],
  2073. [
  2074. 'name' => '西滨镇',
  2075. 'value' => 3
  2076. ]
  2077. ];
  2078. $redis->set('recruit_quota',json_encode($quota));
  2079. }else{
  2080. $quota = json_decode($quota,true);
  2081. }
  2082. $limit = $request->input('limit',1);
  2083. $list = DB::table('recruit_appoint_select as a')->leftJoin('recruit_appoint_info as b','a.appoint_id','=','b.id')->leftJoin('recruit_ticket as c','a.appoint_id','=','c.appoint_id')->whereRaw('a.select_result is null and a.batch=2 and a.status=1')->select(['b.realname','c.ex_number','a.result','a.select_result','a.id'])->orderBy('record','desc')->limit($limit)->get();
  2084. $return_data = [
  2085. 'list' => []
  2086. ];
  2087. $array_column = array_column($quota,'name');
  2088. foreach ($list as $k => $v){
  2089. $person_select_result = json_decode($v->result,true);
  2090. $flag = 0;//是否择岗成功
  2091. foreach ($person_select_result as $val){
  2092. //寻找下标
  2093. $index = array_search($val,$array_column);
  2094. if($quota[$index]['value'] > 0){
  2095. $quota_data = [
  2096. 'index' => $index,
  2097. 'old_value' => $quota[$index]['value']
  2098. ];
  2099. //有名额允许择岗
  2100. DB::table('recruit_appoint_select')->where('id',$v->id)->update(['select_result'=>$val,'status' => 1]);
  2101. $v->select_result = $val;
  2102. $quota[$index]['value']--;
  2103. $quota_data['new_value'] = $quota[$index]['value'];
  2104. $redis->set('recruit_quota',json_encode($quota));
  2105. $flag = 1;
  2106. break;
  2107. }
  2108. }
  2109. if(!$flag){
  2110. $v->select_result = '未匹配到志愿,本轮择岗不成功!';
  2111. DB::table('recruit_appoint_select')->where('id',$v->id)->update(['select_result'=>'未匹配到志愿,本轮择岗不成功!','status' => -2]);
  2112. }
  2113. array_push($return_data['list'],$v);
  2114. }
  2115. $return_data['quota'] = $quota_data;
  2116. return ['status' => 1, 'msg' => '择岗排序成功', 'data' => $return_data];
  2117. }
  2118. public function select_init(Request $request)
  2119. {
  2120. $count = DB::table('recruit_appoint_select')->whereRaw('select_result is null and batch = 2')->count();
  2121. $redis = Cache::getRedis();
  2122. $quota = $redis->get('recruit_quota');
  2123. if(!$quota){
  2124. $quota = [
  2125. [
  2126. 'name' => '新塘街道',
  2127. 'value' => 13
  2128. ],
  2129. [
  2130. 'name' => '陈埭镇',
  2131. 'value' => 88
  2132. ],
  2133. [
  2134. 'name' => '池店镇',
  2135. 'value' => 10
  2136. ],
  2137. [
  2138. 'name' => '安海镇',
  2139. 'value' => 10
  2140. ],
  2141. [
  2142. 'name' => '磁灶镇',
  2143. 'value' => 21
  2144. ],
  2145. [
  2146. 'name' => '内坑镇',
  2147. 'value' => 22
  2148. ],
  2149. [
  2150. 'name' => '东石镇',
  2151. 'value' => 4
  2152. ],
  2153. [
  2154. 'name' => '永和镇',
  2155. 'value' => 27
  2156. ],
  2157. [
  2158. 'name' => '英林镇',
  2159. 'value' => 5
  2160. ],
  2161. [
  2162. 'name' => '金井镇',
  2163. 'value' => 13
  2164. ],
  2165. [
  2166. 'name' => '龙湖镇',
  2167. 'value' => 53
  2168. ],
  2169. [
  2170. 'name' => '深沪镇',
  2171. 'value' => 23
  2172. ],
  2173. [
  2174. 'name' => '西滨镇',
  2175. 'value' => 3
  2176. ]
  2177. ];
  2178. $redis->set('recruit_quota',json_encode($quota));
  2179. }
  2180. $list = DB::table('recruit_appoint_select as a')->leftJoin('recruit_appoint_info as b','a.appoint_id','=','b.id')->leftJoin('recruit_ticket as c','a.appoint_id','=','c.appoint_id')->whereRaw('a.select_result is not null and a.batch=2')->select(['b.realname','c.ex_number','a.result','a.select_result','a.id'])->orderBy('record','desc')->get();
  2181. return ['status' => 1, 'msg' => '获取初始化信息成功', 'data' => ['count' => $count, 'quota' => $quota, 'list' => $list]];
  2182. }
  2183. public function interviewer_random(Request $request)
  2184. {
  2185. $model = $request->input('model',1);
  2186. $number1 = $request->input('number1',5);//考官人数
  2187. $number2 = $request->input('number2',1);//替补人数
  2188. $where[] = ['id','>',0];
  2189. switch ($model){
  2190. case '0':
  2191. $list = DB::table('recruit_interviewer')->get()->toArray();
  2192. shuffle($list);
  2193. $result = array_slice($list, 0, $number1+$number2);
  2194. break;
  2195. case '1':
  2196. $list = DB::table('recruit_interviewer')->get()->toArray();
  2197. shuffle($list);
  2198. $count = $number1;
  2199. for ($i = 0; $i < $count; $i++){
  2200. if(!$list[$i]->status){
  2201. $list[] = $list[$i];
  2202. unset($list[$i]);
  2203. $count++;
  2204. }
  2205. }
  2206. $result = array_slice($list, 0, $number1+$number2);
  2207. break;
  2208. case '2':
  2209. $list = DB::table('recruit_interviewer')->where('status',1)->get()->toArray();
  2210. shuffle($list);
  2211. $result = array_slice($list, 0, $number1+$number2);
  2212. break;
  2213. default:
  2214. $list = DB::table('recruit_interviewer')->get()->toArray();
  2215. shuffle($list);
  2216. for ($i = 0; $i < $number1; $i++){
  2217. dd($list[$i]);
  2218. if(!$list[$i]->status){
  2219. $list[] = $list[$i];
  2220. unset($list[$i]);
  2221. }
  2222. }
  2223. $result = array_slice($list, 0, $number1+$number2);
  2224. break;
  2225. }
  2226. $return_data = [
  2227. 'list' => $result,
  2228. 'number1' => $number1,
  2229. 'number2' => $number2
  2230. ];
  2231. return view('app.recruit.interviewer', $return_data);
  2232. }
  2233. public function supplement_info(Request $request)
  2234. {
  2235. $user = $this->getUser();
  2236. if (!empty($user)) {
  2237. $uid = $user->id;
  2238. } else {
  2239. return redirect(route('login'));
  2240. }
  2241. //招考id
  2242. $id = $request->input('id', 0);
  2243. if (!$id) {
  2244. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  2245. }
  2246. $recruit = Recruit::find($id);
  2247. if(!$recruit['status']){
  2248. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2249. }
  2250. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  2251. if(!$appoint_info){
  2252. return $this->showMessage('抱歉,您没有报名,无需补充信息!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2253. }
  2254. $supplement_info = DB::table("recruit_supplement_cunwu")->where('uid',$uid)->where('appoint_id',$appoint_info->id)->first();
  2255. if($supplement_info){
  2256. return $this->showMessage('您已登记信息,无需再次登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2257. }
  2258. $uids = [179049,179051,175896,177011,179015,179134,166830,179056,179110,179140,179040,179154,168701,149108,176405,176637,179182,179115,52845,179240,179036,170227,179286,179145,177121,169161,179282,179318,179173,179385,179287,175723,165156,179217,179085,179174,179441,179459,179448,179461,179476,170189,158658,162111,179504,177503,169950,173378,179571,179576,179548,175865,132228,168809,158464,150061,179594,169655,179311,168348,179131,179654,179664,179683,175855,179100,56968,179610,179146,179731,176717,179435,179669,175794,179487,176307,179806,179758,179555,179822,176249,179769,179815,179685,179856,179840,179828,179844,179376,169398,169530,170181,179799,179123,179652,179936,176102,179261,179957,179888,180033,180039,180050,180028,180064,180078,159819,180085,179987,177195,176790,175722,179933,176170,180122,176929,179872,180151,180123,176834,179547,179879,180196,170277,159623,179892,179904,180227,179952,180232,165930,179195,173624,180244,180277,180325,180321,180265,179871,179908,149297,179898,180407,180239,169158,175716,169910,180288,180452,162757,180309,180474,179266,164225,180465,169899,180098,175481,179306,180458,176454,180451,180507,180531,169591,180456,175467,180589,180587,180590,180601,179679,180597,180602,180604,175637,179830,165858,179835,180677,169304,180711,180234,180426,169691,176956,178303,170289,177028,179894,180311,176683,169720,150103,180705,176548,176655,180849,176101,180855,180808,180869,180348,180733,180889,180866,180399,180657,180920,180876,179701,152053,180208,175641,180831,169075,180980,180988,180991,180686,181016,181023,180974,152179,179284,181058,168483,177233,176619,181110,180809,180979,181122,180916,181142,180992,177427,181143,169886,147697,181173,181218,181041,181171,163107,180363,151296,169429,150164,181258,176891,56330,169740,181272,170078,177000,181317,180845,181303,180839,180983];//写死用户
  2259. if(!in_array($uid,$uids)){
  2260. return $this->showMessage('您无需登记信息!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2261. }
  2262. // $limit_time = 1661961599;
  2263. // $time = time();
  2264. // if( $time > $limit_time){
  2265. // return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2266. // }
  2267. $view_data = [];
  2268. //$view_data['info'] = json_encode($info);
  2269. $view_data['title'] = $recruit->company;
  2270. $view_data['id'] = $id;
  2271. return view('app.recruit.supplement_info',$view_data);
  2272. }
  2273. public function save_supplement_info(Request $request){
  2274. $user = $this->getUser();
  2275. if (!empty($user)) {
  2276. $uid = $user->id;
  2277. } else {
  2278. return redirect(route('login'));
  2279. }
  2280. //招考id
  2281. $id = $request->input('recruit_id', 0);
  2282. if (!$id) {
  2283. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2284. }
  2285. $recruit = Recruit::find($id);
  2286. if(!$recruit['status']){
  2287. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2288. }
  2289. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  2290. if(!$appoint_info){
  2291. return ['status' => 0, 'msg' => '抱歉,您没有报名,无需补充信息!', 'data' => ''];
  2292. }
  2293. if($request->input('marriage') == '已婚'){
  2294. if($request->input('spouse_card_type') == '' || $request->input('spouse_card') == '' || $request->input('spouse_realname') == '' || $request->input('spouse_mobile') == ''){
  2295. return ['status' => 0, 'msg' => '请完善配偶信息!', 'data' => ''];
  2296. }
  2297. }
  2298. $data = [
  2299. 'uid' => $uid,
  2300. 'appoint_id' => $appoint_info->id,
  2301. 'street' => $request->input('street'),
  2302. 'realname' => $request->input('realname'),
  2303. 'sex' => $request->input('sex'),
  2304. 'house' => $request->input('house'),
  2305. 'nation' => $request->input('nation'),
  2306. 'native' => $request->input('native'),
  2307. 'marriage' => $request->input('marriage'),
  2308. 'spouse_card_type' => $request->input('spouse_card_type'),
  2309. 'spouse_card' => $request->input('spouse_card'),
  2310. 'spouse_realname' => $request->input('spouse_realname'),
  2311. 'spouse_mobile' => $request->input('spouse_mobile'),
  2312. 'political' => $request->input('political'),
  2313. 'bank_card' => $request->input('bank_card'),
  2314. 'bank_open' => $request->input('bank_open'),
  2315. 'card' => $request->input('card'),
  2316. 'card_endtime' => $request->input('card_endtime'),
  2317. 'mobile' => $request->input('mobile'),
  2318. 'edu' => $request->input('education'),
  2319. 'pro' => $request->input('pro'),
  2320. 'address' => $request->input('address'),
  2321. 'funds' => $request->input('funds')
  2322. ];
  2323. DB::table('recruit_supplement_cunwu')->insert($data);
  2324. return ['status' => 1, 'msg' => '提交成功!', 'data' => ''];
  2325. }
  2326. }