IndexController.php 104 KB

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