IndexController.php 114 KB

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