IndexController.php 113 KB

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