IndexController.php 120 KB

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