IndexController.php 111 KB

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