IndexController.php 112 KB

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