IndexController.php 146 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176
  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. //dd($list);
  41. $return_data = [
  42. 'list' => $list,
  43. 'key' => $key,
  44. ];
  45. return view('app.recruit.index', $return_data);
  46. }
  47. /**
  48. * 招考详情页
  49. * @param Request $request
  50. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View|mixed|\think\response\Redirect|\think\response\View|void
  51. */
  52. public function show(Request $request)
  53. {
  54. $user = $this->getUser();
  55. if ($user) {
  56. $uid = $user->id;
  57. $utype = $user->utype;
  58. } else {
  59. $uid = 0;
  60. $utype = 0;
  61. }
  62. $id = $request->input('id', 0);
  63. if (empty($id)) {
  64. return $this->showMessage('抱歉,请输入指定的招考场次!', route('recruit.index.list'), true, '上一页', '2');
  65. }
  66. $recruit = Recruit::where('status',1)->find($id);
  67. if (empty($recruit)) {
  68. return redirect(route('/recruit/list'));
  69. }
  70. $info = Recruit::parse_info($recruit);
  71. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  72. if ($info->isApply && $appoint_info) {
  73. $first_post = RecruitAppointLog::where('type', 3)->where('uid', $uid)->orderBy('created_at', 'asc')->first();
  74. if ($first_post) {
  75. $info->isApply = 1;
  76. }
  77. }
  78. if ($appoint_info) {
  79. //20221115增加确认笔试功能
  80. if ($recruit->pen_comfirm) {
  81. if ($appoint_info->audit != 3) {//审核未通过,无需确认
  82. $appoint_info->pen_comfirm = 0;
  83. } else {
  84. $time = time();
  85. if (strtotime($recruit->pen_comfirm_start) > $time || strtotime($recruit->pen_comfirm_end) < $time) {
  86. $appoint_info->pen_comfirm = -1; //确认未开始
  87. } else {
  88. if ($appoint_info->pen_audit != -2) {
  89. $appoint_info->pen_comfirm = -2;//已确认无需再次确认
  90. } else {
  91. $appoint_info->pen_comfirm = 1;
  92. }
  93. }
  94. }
  95. } else {
  96. $appoint_info->pen_comfirm = 0;//无需确认
  97. }
  98. //笔试
  99. $pen_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 1)->first();
  100. if ($pen_ticket) {
  101. $pen_health = RecruitSupplement::where("appoint_id", $appoint_info->id)->where("type", "pen")->where('h_status', 1)->first();
  102. if (!$pen_health && $recruit->pen_epidemic) {
  103. $appoint_info->pen_ticket = -2;
  104. } else {
  105. $time = time();
  106. if (strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time) {
  107. $appoint_info->pen_ticket = 1;
  108. } else {
  109. $appoint_info->pen_ticket = -1;
  110. }
  111. }
  112. } else {
  113. $appoint_info->pen_ticket = 0;
  114. }
  115. //考核测试
  116. $check_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 2)->first();
  117. if ($check_ticket) {
  118. $time = time();
  119. if (strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time) {
  120. $appoint_info->check_ticket = 1;
  121. } else {
  122. $appoint_info->check_ticket = -1;
  123. }
  124. } else {
  125. $appoint_info->check_ticket = 0;
  126. }
  127. //20251017增加确认面试功能
  128. if ($recruit->face_comfirm) {
  129. if ($appoint_info->audit != 3) {//审核未通过,无需确认
  130. $appoint_info->face_comfirm = 0;
  131. } else {
  132. $time = time();
  133. if (strtotime($recruit->face_comfirm_start) > $time || strtotime($recruit->face_comfirm_end) < $time) {
  134. $appoint_info->face_comfirm = -1; //确认未开始
  135. } else {
  136. if ($appoint_info->face_audit != -2) {
  137. $appoint_info->face_comfirm = -2;//已确认无需再次确认
  138. } else {
  139. $appoint_info->face_comfirm = 1;
  140. }
  141. }
  142. }
  143. } else {
  144. $appoint_info->face_comfirm = 0;//无需确认
  145. }
  146. //面试
  147. $face_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 3)->first();
  148. if ($face_ticket && $appoint_info->face_audit == -1) {
  149. $face_health = RecruitSupplement::where("appoint_id", $appoint_info->id)->where("type", "face")->where('h_status', 1)->first();
  150. if (!$face_health && $recruit->face_epidemic) {
  151. $appoint_info->face_ticket = -2;
  152. $time = time();
  153. if (strtotime($recruit->face_health_start) < $time && strtotime($recruit->face_health_end) > $time) {
  154. $appoint_info->face_ticket = -2;
  155. } else {
  156. $appoint_info->face_ticket = -3;
  157. }
  158. } else {
  159. $time = time();
  160. if (strtotime($recruit->face_health_start) < $time && strtotime($recruit->face_health_end) > $time) {
  161. $appoint_info->face_ticket = 1;
  162. } else {
  163. $appoint_info->face_ticket = -1;
  164. }
  165. }
  166. } else {
  167. $appoint_info->face_ticket = 0;
  168. }
  169. //复试
  170. $reexamine_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 4)->first();
  171. if ($reexamine_ticket && $appoint_info->reexamine_audit == -1) {
  172. $reexamine_health = RecruitSupplement::where("appoint_id", $appoint_info->id)->where("type", "reexamine")->where('h_status', 1)->first();
  173. if (!$reexamine_health && $recruit->reexamine_epidemic) {
  174. $appoint_info->face_ticket = -2;
  175. $time = time();
  176. if (strtotime($recruit->reexamine_health_start) < $time && strtotime($recruit->reexamine_health_end) > $time) {
  177. $appoint_info->reexamine_ticket = -2;
  178. } else {
  179. $appoint_info->reexamine_ticket = -3;
  180. }
  181. } else {
  182. $time = time();
  183. if (strtotime($recruit->reexamine_health_start) < $time && strtotime($recruit->reexamine_health_end) > $time) {
  184. $appoint_info->reexamine_ticket = 1;
  185. } else {
  186. $appoint_info->reexamine_ticket = -1;
  187. }
  188. }
  189. } else {
  190. $appoint_info->reexamine_ticket = 0;
  191. }
  192. } else {
  193. $appoint_info = new \stdClass();
  194. $appoint_info->pen_comfirm = 0;
  195. $appoint_info->pen_audit = 0;
  196. $appoint_info->post_id = 0;
  197. $appoint_info->pen_ticket = 0;
  198. $appoint_info->computer_ticket = 0;
  199. $appoint_info->face_comfirm = 0;
  200. $appoint_info->face_ticket = 0;
  201. $appoint_info->check_ticket = 0;
  202. $appoint_info->reexamine_ticket = 0;
  203. $appoint_info->realname = '';
  204. $appoint_info->card = '';
  205. $appoint_info->mobile = '';
  206. $appoint_info->sex = 0;
  207. $appoint_info->adjust = 0;
  208. $appoint_info->adjust_limit = 0;
  209. }
  210. $notice = $request->input('notice', 0);
  211. if ($notice) {
  212. $public_notice_switch = 0;
  213. $public_notice = RecruitArticle::where('id', $notice)->where('released_at', '<', time())->first();
  214. if (!empty($info)) {
  215. $view_data = [
  216. 'recruit' => $recruit,
  217. 'info' => $info,
  218. 'uid' => $uid,
  219. 'utype' => $utype,
  220. 'public_notice' => $public_notice,
  221. 'public_notice_switch' => $public_notice_switch,
  222. 'appoint_info' => $appoint_info,
  223. ];
  224. return view('app.recruit.show')->with($view_data);
  225. } else {
  226. return back();
  227. }
  228. } else {
  229. $list = RecruitArticle::where('recruit_id', $id)->where('is_display', 1)->orderBy('created_at', 'desc')->where('released_at', '<', time())->get();
  230. $public_notice_switch = 1;//有补充公告的模式
  231. if (!empty($info)) {
  232. $view_data = [
  233. 'recruit' => $recruit,
  234. 'info' => $info,
  235. 'uid' => $uid,
  236. 'utype' => $utype,
  237. 'list' => $list,
  238. 'public_notice_switch' => $public_notice_switch,
  239. 'appoint_info' => $appoint_info,
  240. ];
  241. return view('app.recruit.show')->with($view_data);
  242. } else {
  243. return back();
  244. }
  245. }
  246. }
  247. /**
  248. * 上传文件的方法
  249. * @param Request $request
  250. * @return \Illuminate\Http\JsonResponse
  251. */
  252. public function upload(Request $request)
  253. {
  254. $user = $this->getUser();
  255. if ($user) {
  256. $uid = $user->id;
  257. $utype = $user->utype;
  258. } else {
  259. $uid = 0;
  260. $utype = 0;
  261. }
  262. $file = $request->file('file');
  263. if ($file->isValid()) { //判断文件是否存在
  264. //获取文件的扩展名
  265. $ext = $file->getClientOriginalExtension();
  266. if (!in_array(strtolower($ext), ['jpg', 'jpeg', 'png', 'doc', 'docx', 'pdf'])) {
  267. $res['status'] = 0;
  268. $res['msg'] = '文件格式不正确';
  269. } else {
  270. //获取文件的绝对路径
  271. $path = $file->getRealPath();
  272. $oldname = $file->getClientOriginalName();
  273. //定义文件名
  274. $filename = 'storage/recruit/' . uniqid() . mt_rand(10000, 99999) . '.' . $ext;
  275. //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置
  276. Storage::disk('public')->put($filename, file_get_contents($path));
  277. $res['status'] = 1;
  278. $res['filename'] = $oldname;
  279. $res['path'] = "/storage/" . $filename;
  280. $res['msg'] = '上传成功';
  281. }
  282. } else {
  283. $res['status'] = 0;
  284. $res['msg'] = '上传失败';
  285. }
  286. return response()->json($res);
  287. }
  288. /**
  289. * 查看报名人数统计
  290. * @param Request $request
  291. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View|mixed|\think\response\Redirect|\think\response\View|void
  292. */
  293. public function sign_up_count(Request $request)
  294. {
  295. $user = $this->getUser();
  296. if ($user) {
  297. $uid = $user->id;
  298. $utype = $user->utype;
  299. } else {
  300. $uid = 0;
  301. $utype = 0;
  302. }
  303. $id = $request->input('id', 0);
  304. $refresh = $request->input('refresh', '');
  305. if (empty($id)) {
  306. return $this->showMessage('抱歉,请输入指定的招考场次!', route('recruit.index.list'), true, '上一页', '2');
  307. }
  308. $recruit = Recruit::find($id);
  309. if (empty($recruit)) {
  310. return redirect(route('/recruit/list'));
  311. }
  312. if (!$recruit->show_report) {
  313. return $this->showMessage('抱歉,该场次不允许查看报名人数统计结果!', route('recruit.index.list'), true, '上一页', '2');
  314. }
  315. if (Cache::has("sign_up_count_{$recruit->id}") && $refresh != 'jjhc2019') {
  316. $cache_data = Cache::get("sign_up_count_{$recruit->id}");
  317. $list = $cache_data['list'];
  318. $time = $cache_data['time'];
  319. } else {
  320. $list = RecruitPost::where('recruit_id', $recruit->id)->where('status', 1)->get();
  321. if (!$list) {
  322. return $this->showMessage('抱歉,数据暂时未更新或更新出错!', route('recruit.index.list'), true, '上一页', '2');
  323. }
  324. foreach ($list as $k => $v) {
  325. $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();
  326. $list[$k]['checking'] = $res->checking;
  327. $list[$k]['fail'] = $res->fail;
  328. $list[$k]['success'] = $res->success;
  329. }
  330. $time = date('Y-m-d H:i', time());
  331. $cache_data = [
  332. 'list' => $list,
  333. 'time' => $time,
  334. ];
  335. Cache::put("sign_up_count_{$recruit->id}", $cache_data, 60);
  336. }
  337. $view_data = [
  338. 'list' => $list,
  339. 'time' => $time,
  340. 'title' => $recruit->company,
  341. ];
  342. return view('app.recruit.sign_up_count')->with($view_data);
  343. }
  344. /**
  345. * 报名功能页
  346. * @param Request $request
  347. * @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
  348. */
  349. public function sign_up(Request $request)
  350. {
  351. $user = $this->getUser();
  352. if (!empty($user)) {
  353. $uid = $user->id;
  354. } else {
  355. return redirect(route('login'));
  356. }
  357. //招考id
  358. $id = $request->input('id', 0);
  359. if (!$id) {
  360. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  361. }
  362. //招考信息
  363. $recruit = Recruit::find($id);
  364. if (!$recruit['status'] && !$user->recruit_test) {
  365. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  366. }
  367. if ($recruit['current'] != 1 && $recruit['current'] != 2) {
  368. return $this->showMessage('抱歉,该项目报名通道已关闭,如有疑问,请联系客服!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  369. }
  370. if($recruit['limit_times'] == 1){
  371. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  372. }else{
  373. $appoint_info_id = $request->input('appoint_info_id', 0);
  374. $appoint_info = null;
  375. if($appoint_info_id > 0){
  376. $appoint_info = RecruitAppointInfo::where('id', $appoint_info_id)->first();
  377. }
  378. }
  379. $time = time();
  380. $formDisabled = 0;
  381. $view_data['module'] = $forms = explode(',', $recruit['forms']);
  382. //查询报名表是否已有记录
  383. if ($appoint_info) {
  384. if (in_array('internship', $forms)) {
  385. //如果已有该场次的报名记录,读取录入的数据集合
  386. $user_info = $appoint_info;
  387. $user_info['sex'] = (string)$user_info['sex'];
  388. $user_info['adjust'] = (string)$user_info['adjust'];
  389. $user_info['edu_type'] = (string)$user_info['edu_type'];
  390. $user_info['family'] = json_decode($user_info['family']);
  391. $detail = RecruitAppointDetail::where('recruit_appoint_id', $user_info['id'])->first();
  392. if ($detail) {
  393. $user_info['detail'] = $detail->toArray();
  394. } else {
  395. $user_info['detail'] = [
  396. 'rewards_and_punishments' => '',
  397. 'introduce' => '',
  398. ];
  399. }
  400. if (json_decode($user_info['identification'])) {
  401. $identification = json_decode($user_info['identification'], true);
  402. foreach ($identification as $k => $v) {
  403. if (array_key_exists('response', $v)) {
  404. $identification[$k]['url'] = $v['response']['path'];
  405. }
  406. }
  407. } else {
  408. $identification = [];
  409. }
  410. $user_info['identification'] = $identification;
  411. if (json_decode($user_info['education_certification'])) {
  412. $education_certification = json_decode($user_info['education_certification'], true);
  413. foreach ($education_certification as $k => $v) {
  414. if (array_key_exists('response', $v)) {
  415. $education_certification[$k]['url'] = $v['response']['path'];
  416. }
  417. }
  418. } else {
  419. $education_certification = [];
  420. }
  421. $user_info['education_certification'] = $education_certification;
  422. if (json_decode($user_info['other_certification'])) {
  423. $other_certification = json_decode($user_info['other_certification'], true);
  424. foreach ($other_certification as $k => $v) {
  425. if (array_key_exists('response', $v)) {
  426. $other_certification[$k]['url'] = $v['response']['path'];
  427. }
  428. }
  429. } else {
  430. $other_certification = [];
  431. }
  432. $user_info['other_certification'] = $other_certification;
  433. if (json_decode($user_info['hj_certification'])) {
  434. $hj_certification = json_decode($user_info['hj_certification'], true);
  435. foreach ($hj_certification as $k => $v) {
  436. if (array_key_exists('response', $v)) {
  437. $hj_certification[$k]['url'] = $v['response']['path'];
  438. }
  439. }
  440. } else {
  441. $hj_certification = [];
  442. }
  443. $user_info['hj_certification'] = $hj_certification;
  444. if (json_decode($user_info['chengnuoshu'])) {
  445. $chengnuoshu = json_decode($user_info['chengnuoshu'], true);
  446. foreach ($chengnuoshu as $k => $v) {
  447. if (array_key_exists('response', $v)) {
  448. $chengnuoshu[$k]['url'] = $v['response']['path'];
  449. }
  450. }
  451. } else {
  452. $chengnuoshu = [];
  453. }
  454. $user_info['chengnuoshu'] = $chengnuoshu;
  455. if (json_decode($user_info['shixin'])) {
  456. $shixin = json_decode($user_info['shixin'], true);
  457. foreach ($shixin as $k => $v) {
  458. if (array_key_exists('response', $v)) {
  459. $shixin[$k]['url'] = $v['response']['path'];
  460. }
  461. }
  462. } else {
  463. $shixin = [];
  464. }
  465. $user_info['shixin'] = $shixin;
  466. if (json_decode($user_info['baokaoshengming'])) {
  467. $baokaoshengming = json_decode($user_info['baokaoshengming'], true);
  468. foreach ($baokaoshengming as $k => $v) {
  469. if (array_key_exists('response', $v)) {
  470. $baokaoshengming[$k]['url'] = $v['response']['path'];
  471. }
  472. }
  473. } else {
  474. $baokaoshengming = [];
  475. }
  476. $user_info['baokaoshengming'] = $baokaoshengming;
  477. //获取最新的报名审核信息
  478. $logs = RecruitAppointLog::where('appoint_id', $user_info->id)->where('step', 1)->where('type', 2)->orderBy('created_at', 'desc')->first();
  479. if ($logs) {
  480. $user_info['audit_log'] = $logs->log;
  481. } else {
  482. $user_info['audit_log'] = '';
  483. }
  484. } else {
  485. //如果已有该场次的报名记录,读取录入的数据集合
  486. $user_info = $appoint_info;
  487. $user_info['sex'] = (string)$user_info['sex'];
  488. $user_info['edu_type'] = (string)$user_info['edu_type'];
  489. $user_info['family'] = json_decode($user_info['family']);
  490. if (in_array('expand_special', $forms)) {
  491. $special = RecruitAppointExpandSpecial::where('recruit_appoint_id', $user_info['id'])->first();
  492. if ($special) {
  493. if (strpos($special['condition'], ',') !== false) {
  494. $special['condition'] = explode(',', $special['condition']);
  495. }
  496. $material = json_decode($special['material'], true);
  497. if (is_array($material)) {
  498. foreach ($material as $k => $v) {
  499. if (array_key_exists('response', $v)) {
  500. if (array_key_exists('path', $v['response'])) {
  501. $material[$k]['url'] = $v['response']['path'];
  502. }
  503. }
  504. }
  505. }
  506. } else {
  507. $material = [];
  508. $special = [
  509. 'point_apply' => '0',
  510. 'condition' => '',
  511. ];
  512. }
  513. $user_info['special'] = [
  514. 'point_apply' => (string)$special['point_apply'],
  515. 'condition' => $special['condition'],
  516. 'material' => $material,
  517. ];
  518. }
  519. if (in_array('detail', $forms)) {
  520. $detail = RecruitAppointDetail::where('recruit_appoint_id', $user_info['id'])->first();
  521. if ($detail) {
  522. $user_info['detail'] = $detail->toArray();
  523. } else {
  524. $user_info['detail'] = [
  525. 'train' => '',
  526. 'rewards_and_punishments' => '',
  527. 'introduce' => '',
  528. ];
  529. }
  530. }
  531. //如果有身份证明模块
  532. if (in_array('identification', $forms)) {
  533. if (json_decode($user_info['identification'])) {
  534. $identification = json_decode($user_info['identification'], true);
  535. foreach ($identification as $k => $v) {
  536. if (array_key_exists('response', $v)) {
  537. if (array_key_exists('path', $v['response'])) {
  538. $identification[$k]['url'] = $v['response']['path'];
  539. }
  540. }
  541. }
  542. } else {
  543. $identification = [];
  544. }
  545. $user_info['identification'] = $identification;
  546. }
  547. //如果有教育证明模块
  548. if (in_array('education_certification', $forms)) {
  549. if (json_decode($user_info['education_certification'])) {
  550. $education_certification = json_decode($user_info['education_certification'], true);
  551. foreach ($education_certification as $k => $v) {
  552. if (array_key_exists('response', $v)) {
  553. if (array_key_exists('path', $v['response'])) {
  554. $education_certification[$k]['url'] = $v['response']['path'];
  555. }
  556. }
  557. }
  558. } else {
  559. $education_certification = [];
  560. }
  561. $user_info['education_certification'] = $education_certification;
  562. }
  563. //如果有其他证明模块
  564. if (in_array('other_certification', $forms)) {
  565. if (json_decode($user_info['other_certification'])) {
  566. $other_certification = json_decode($user_info['other_certification'], true);
  567. foreach ($other_certification as $k => $v) {
  568. if (array_key_exists('response', $v)) {
  569. if (array_key_exists('path', $v['response'])) {
  570. $other_certification[$k]['url'] = $v['response']['path'];
  571. }
  572. }
  573. }
  574. } else {
  575. $other_certification = [];
  576. }
  577. $user_info['other_certification'] = $other_certification;
  578. }
  579. //如果有户籍证明模块
  580. if (in_array('hj_certification', $forms)) {
  581. if (json_decode($user_info['hj_certification'])) {
  582. $hj_certification = json_decode($user_info['hj_certification'], true);
  583. foreach ($hj_certification as $k => $v) {
  584. if (array_key_exists('response', $v)) {
  585. if (array_key_exists('path', $v['response'])) {
  586. $hj_certification[$k]['url'] = $v['response']['path'];
  587. }
  588. }
  589. }
  590. } else {
  591. $hj_certification = [];
  592. }
  593. $user_info['hj_certification'] = $hj_certification;
  594. }
  595. //如果有承诺书模块
  596. if (in_array('chengnuoshu', $forms)) {
  597. if (json_decode($user_info['chengnuoshu'])) {
  598. $chengnuoshu = json_decode($user_info['chengnuoshu'], true);
  599. foreach ($chengnuoshu as $k => $v) {
  600. if (array_key_exists('response', $v)) {
  601. if (array_key_exists('path', $v['response'])) {
  602. $chengnuoshu[$k]['url'] = $v['response']['path'];
  603. }
  604. }
  605. }
  606. } else {
  607. $chengnuoshu = [];
  608. }
  609. $user_info['chengnuoshu'] = $chengnuoshu;
  610. }
  611. //如果有失信被执行人模块
  612. if (in_array('shixin', $forms)) {
  613. if (json_decode($user_info['shixin'])) {
  614. $shixin = json_decode($user_info['shixin'], true);
  615. foreach ($shixin as $k => $v) {
  616. if (array_key_exists('response', $v)) {
  617. if (array_key_exists('path', $v['response'])) {
  618. $shixin[$k]['url'] = $v['response']['path'];
  619. }
  620. }
  621. }
  622. } else {
  623. $shixin = [];
  624. }
  625. $user_info['shixin'] = $shixin;
  626. }
  627. //如果有声明书模块
  628. if (in_array('baokaoshengming', $forms)) {
  629. if (json_decode($user_info['baokaoshengming'])) {
  630. $baokaoshengming = json_decode($user_info['baokaoshengming'], true);
  631. foreach ($baokaoshengming as $k => $v) {
  632. if (array_key_exists('response', $v)) {
  633. if (array_key_exists('path', $v['response'])) {
  634. $baokaoshengming[$k]['url'] = $v['response']['path'];
  635. }
  636. }
  637. }
  638. } else {
  639. $baokaoshengming = [];
  640. }
  641. $user_info['baokaoshengming'] = $baokaoshengming;
  642. }
  643. //获取最新的报名审核信息
  644. $logs = RecruitAppointLog::where('appoint_id', $user_info->id)->where('step', 1)->where('type', 2)->orderBy('created_at', 'desc')->first();
  645. if ($logs) {
  646. $user_info['audit_log'] = $logs->log;
  647. } else {
  648. $user_info['audit_log'] = '';
  649. }
  650. //获取提交报名的次数
  651. // $number = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',3)->count();
  652. // $post_number = $number+1;//todo
  653. }
  654. $appoint_info_id = $appoint_info->id;
  655. } else {
  656. //实习专场
  657. if (in_array('internship', $forms)) {
  658. $user_info = json_encode([
  659. 'id' => 0,
  660. 'recruit_id' => $id,
  661. 'operation' => 1,
  662. 'realname' => '',
  663. 'sex' => '1',
  664. 'birthday' => '',
  665. 'card' => '',
  666. 'nation' => '',
  667. 'native_place' => '',
  668. 'political_affiliation' => '',
  669. 'join_time' => '',
  670. 'house_register' => '',
  671. 'education' => '',
  672. 'school' => '',
  673. 'pro' => '',
  674. 'adjust' => '',
  675. 'mobile' => '',
  676. 'email' => '',
  677. 'address' => '',
  678. 'post_id' => '',
  679. 'concat_name' => '',
  680. 'concat_mobile' => '',
  681. 'resume' => '',
  682. 'avatar' => '',
  683. 'family' => [
  684. [
  685. 'relation' => '',
  686. 'realname' => '',
  687. 'birthday' => '',
  688. 'political_affiliation' => '',
  689. 'work' => '',
  690. ],
  691. ],
  692. 'detail' => [
  693. 'rewards_and_punishments' => '',
  694. 'introduce' => '',
  695. ],
  696. 'identification' => [],
  697. 'education_certification' => [],
  698. 'other_certification' => [],
  699. 'hj_certification' => [],
  700. 'chengnuoshu' => [],
  701. 'baokaoshengming' => [],
  702. 'shixin' => [],
  703. ]);
  704. } else {
  705. //如果没有,结合基础数据及模块表单信息,制作数据对象
  706. $user_info = RecruitAppointBasic::where('uid', $uid)->first();
  707. if (!$user_info) {
  708. //没有基础信息跳转完善route('person.recruitInfo')
  709. return $this->showMessage('请先完善招考基础信息!', route('recruit.recruitInfo', ['recruit_id', $id]), true, '上一页', '3');
  710. }
  711. $user_info['sex'] = (string)$user_info['sex'];
  712. $user_info['edu_type'] = (string)$user_info['edu_type'];
  713. $user_info['family'] = json_decode($user_info['family']);
  714. if (in_array('expand_special', $forms)) {
  715. $user_info['special'] = [
  716. 'point_apply' => '0',
  717. 'condition' => '',
  718. 'material' => [],
  719. ];
  720. }
  721. if (in_array('detail', $forms)) {
  722. $user_info['detail'] = [
  723. 'train' => '',
  724. 'rewards_and_punishments' => '',
  725. 'introduce' => '',
  726. ];
  727. }
  728. if (in_array('identification', $forms)) {
  729. $user_info['identification'] = [];
  730. }
  731. if (in_array('education_certification', $forms)) {
  732. $user_info['education_certification'] = [];
  733. }
  734. if (in_array('other_certification', $forms)) {
  735. $user_info['other_certification'] = [];
  736. }
  737. if (in_array('hj_certification', $forms)) {
  738. $user_info['hj_certification'] = [];
  739. }
  740. if (in_array('chengnuoshu', $forms)) {
  741. $user_info['chengnuoshu'] = [];
  742. }
  743. if (in_array('shixin', $forms)) {
  744. $user_info['shixin'] = [];
  745. }
  746. if (in_array('baokaoshengming', $forms)) {
  747. $user_info['baokaoshengming'] = [];
  748. }
  749. $user_info['recruit_id'] = $id;
  750. $user_info['operation'] = 1;
  751. }
  752. $appoint_info_id = 0;
  753. }
  754. //招考岗位
  755. $where_post[] = ['recruit_id', '=', $id];
  756. //$where_post[] = ['status', '=', 1];
  757. $recruit_post = RecruitPost::where($where_post)->get();
  758. $post = [];
  759. $post_limit = [];
  760. $post_special = [];
  761. foreach ($recruit_post as $value) {
  762. $item = [
  763. 'value' => $value['id'],
  764. 'label' => $value['code'] . " " . $value['name'],
  765. 'disabled' => $value['status'] == 1 ? false : true,
  766. ];
  767. $post_limit[$value['id']] = json_decode($value['limit']);
  768. $post_special[$value['id']] = json_decode($value['special']);
  769. array_push($post, $item);
  770. }
  771. $view_data['id'] = $id;
  772. $view_data['appoint_info'] = $user_info;
  773. $view_data['post'] = json_encode($post);
  774. // $view_data['post_number'] = $post_number;
  775. // $view_data['post_times'] = $recruit['post_times'];
  776. $view_data['post_limit'] = json_encode($post_limit);
  777. $view_data['post_special'] = json_encode($post_special);
  778. $view_data['formDisable'] = $formDisabled;
  779. $view_data['title'] = $recruit->company;
  780. $view_data['special_condition_type'] = $recruit->special_condition_type;
  781. $view_data['special_condition_value'] = json_decode($recruit->special_condition_value, true);
  782. return view('app.recruit.sign_up', $view_data);
  783. }
  784. public function preview(Request $request)
  785. {
  786. $modules = $request->input('modules');
  787. $view_data['module'] = $forms = explode(',', $modules);
  788. return view('app.recruit.preview', $view_data);
  789. }
  790. /**
  791. * 提交报名的处理程序
  792. * @param Request $request
  793. * @return array|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\think\response\Redirect|void
  794. */
  795. public function saveSignUp(Request $request)
  796. {
  797. $user = $this->getUser();
  798. if (!empty($user)) {
  799. $uid = $user->id;
  800. } else {
  801. return redirect(route('login'));
  802. }
  803. $recruit_id = $request->input('recruit_id', 0);
  804. if (!$recruit_id) {
  805. return response()->json(['status' => 0, 'msg' => '请选择项目!']);
  806. }
  807. $recruit = Recruit::find($recruit_id);
  808. // if(!$recruit['status']){
  809. // return response()->json(['status' => 0,'msg' => '抱歉,该项目状态不正确,请联系客服!']);
  810. // }
  811. if ($recruit['current'] != 1 && $recruit['current'] != 2) {
  812. return response()->json(['status' => 0, 'msg' => '抱歉,该项目报名通道已关闭,如有疑问,请联系客服!']);
  813. }
  814. $card = $request->input('card');
  815. $appointinfo_exist = RecruitAppointInfo::where('card', $card)->where('uid', '<>', $uid)->where('recruit_id', $recruit_id)->first();
  816. //兆丰建设两场公告二而一例外
  817. if ($recruit_id == 25 || $recruit_id == 26) {
  818. $special = RecruitAppointInfo::where('card', $card)->where('uid', '<>', $uid)->whereIn('recruit_id', [25, 26])->first();
  819. $appointinfo_exist = $appointinfo_exist & $special;
  820. }
  821. if ($appointinfo_exist) {
  822. return response()->json(['status' => 0, 'msg' => '您的证件已有其他账号的报名记录,请检查!']);
  823. }
  824. if($recruit['limit_times'] == 1){
  825. $time = time();
  826. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  827. if (($time < strtotime($recruit['apply_start']) || strtotime($recruit['apply_end']) < $time)) {//过了招考时间
  828. if (!$appoint_info) {
  829. return response()->json(['status' => 0, 'msg' => '抱歉,该项目已过报名时间!']);
  830. }
  831. if (($time < strtotime($recruit['audit_start']) || strtotime($recruit['audit_end']) < $time)) {//过了审核时间
  832. return response()->json(['status' => 0, 'msg' => '抱歉,该项目已过审核时间,无法继续报名!']);
  833. }
  834. //如果有报名记录,先查询首次报名是什么时候
  835. $first_post = RecruitAppointLog::where('appoint_id',$appoint_info->id)->where('type', 3)->where('uid', $uid)->orderBy('created_at', 'asc')->first();
  836. if (!$first_post) {//没有记录代表只是暂存
  837. return response()->json(['status' => 0, 'msg' => '抱歉,该项目已过报名时间1!']);
  838. }
  839. }
  840. }else{
  841. $time = time();
  842. $id = $request->input('id');
  843. if($id > 0){
  844. $appoint_info = RecruitAppointInfo::where('id', $id)->first();
  845. }else{
  846. $post_id = $request->input('post_id');
  847. $appoint_info_post = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->where('post_id',$post_id)->first();
  848. if($appoint_info_post){
  849. return response()->json(['status' => 0, 'msg' => '相同岗位已存在报名记录,请检查 !']);
  850. }
  851. $appoint_info_count = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->count();
  852. if($appoint_info_count >= $recruit['limit_times']){
  853. return response()->json(['status' => 0, 'msg' => '超过报名次数上限!']);
  854. }
  855. $appoint_info = null;
  856. }
  857. if (($time < strtotime($recruit['apply_start']) || strtotime($recruit['apply_end']) < $time)) {//过了招考时间
  858. if($id == 0){
  859. return response()->json(['status' => 0, 'msg' => '抱歉,该项目已过报名时间!']);
  860. }
  861. $first_post = RecruitAppointLog::where('appoint_id',$id)->where('type', 3)->where('uid', $uid)->orderBy('created_at', 'asc')->first();
  862. if (!$first_post) {//没有记录代表只是暂存
  863. return response()->json(['status' => 0, 'msg' => '抱歉,该项目已过报名时间!']);
  864. }
  865. }
  866. }
  867. $data = $request->only('realname', 'sex', 'birthday', 'avatar', 'nation', 'native_place', 'political_affiliation', 'titles', 'join_time', 'work', 'house_register', 'education', 'school', 'degree', 'pro', 'address', 'card_type', 'card', 'mobile', 'email', 'concat_name', 'concat_mobile', 'resume', 'post_id', 'adjust', 'remark', 'graduation');
  868. if (!array_key_exists('post_id', $data)) {
  869. return response()->json(['status' => 0, 'msg' => '请选择报考岗位']);
  870. }
  871. $post_info = RecruitPost::where('id', $data['post_id'])->where('recruit_id', $recruit_id)->first();
  872. if (!$post_info['status'] || $post_info['deleted_at'] != null) {
  873. return response()->json(['status' => 0, 'msg' => '该岗位已失效']);
  874. }
  875. //获取操作符,是暂存还是提交
  876. $operation = $request->input('operation');
  877. if ($operation == 1) {
  878. $data['audit'] = 0;//暂存
  879. } else {
  880. //基础信息的检查
  881. $rules = [
  882. 'realname' => 'required',
  883. 'sex' => 'required',
  884. 'birthday' => 'required',
  885. 'avatar' => 'required',
  886. 'nation' => 'required',
  887. 'native_place' => 'required',
  888. 'political_affiliation' => 'required',
  889. 'post_id' => 'required',
  890. 'house_register' => 'required',
  891. //'edu_type' => 'required',
  892. 'education' => 'required',
  893. 'school' => 'required',
  894. 'graduation' => 'required',
  895. 'address' => 'required',
  896. 'mobile' => 'required',
  897. 'email' => 'required',
  898. 'card_type' => 'required',
  899. 'card' => 'required',
  900. 'concat_name' => 'required',
  901. 'concat_mobile' => 'required',
  902. 'resume' => 'required',
  903. ];
  904. $messages = [
  905. 'realname.required' => '请填写姓名',
  906. 'sex.required' => '请填写性别',
  907. 'birthday.required' => '请填写出生日期',
  908. 'avatar.required' => '请上传彩色免冠照',
  909. 'nation.required' => '请填写民族',
  910. 'native_place.required' => '请填写籍贯',
  911. 'political_affiliation.required' => '请选择政治面貌',
  912. 'post_id.required' => '请选择报名岗位',
  913. 'house_register.required' => '请填写户籍所在地',
  914. //'edu_type.required' => '请选择教育类型',
  915. 'education.required' => '请输入学历',
  916. 'school.required' => '请输入毕业院校',
  917. 'graduation.required' => '请填写毕业时间',
  918. 'address.required' => '请填写通信地址',
  919. 'mobile.required' => '请填写手机号码',
  920. 'email.required' => '请填写电子邮箱',
  921. 'card_type.required' => '请选择证件类型',
  922. 'card.required' => '请填写身份证号码',
  923. 'resume.required' => '请填写个人简历',
  924. 'concat_name.required' => '请填写联系人姓名',
  925. 'concat_mobile.required' => '请填写联系人手机号码',
  926. ];
  927. $create_data = $request->all();
  928. $validator = Validator::make($create_data, $rules, $messages);
  929. if ($validator->fails()) {
  930. $msg = $validator->errors()->all();
  931. return response()->json(['status' => 0, 'msg' => $msg[0]]);
  932. }
  933. $data['audit'] = 1;//提交
  934. }
  935. if (strlen($data['card']) == 18) {
  936. //身份证判断出生日期和性别
  937. $year = substr($data['card'], 6, 4);
  938. $month = substr($data['card'], 10, 2);
  939. $day = substr($data['card'], 12, 2);
  940. if ($year . '-' . $month . '-' . $day != $data['birthday']) {
  941. $data['birthday'] = $year . '-' . $month . '-' . $day;
  942. }
  943. if (intval(substr($data['card'], 16, 1)) % 2 == 0) {
  944. $data['sex'] = 0;
  945. } else {
  946. $data['sex'] = 1;
  947. }
  948. }
  949. try {
  950. if (!empty($post_info['limit']) && json_decode($post_info['limit'])) {
  951. //岗位限制条件的判断
  952. $post_limit = json_decode($post_info['limit'], true);
  953. if (is_array($post_limit)) {
  954. foreach ($post_limit as $k => $v) {
  955. if ($k == 'birthday') {
  956. $value = str_replace('-', '', $data[$k]);
  957. } else {
  958. $value = $data[$k];
  959. }
  960. switch ($v['op']) {
  961. case '=':
  962. if ($value != $v['value']) {
  963. return response()->json(['status' => 0, 'msg' => $v['msg']]);
  964. }
  965. break;
  966. case '>':
  967. if ($value <= $v['value']) {
  968. return response()->json(['status' => 0, 'msg' => $v['msg']]);
  969. }
  970. break;
  971. case '>=':
  972. if ($value < $v['value']) {
  973. return response()->json(['status' => 0, 'msg' => $v['msg']]);
  974. }
  975. break;
  976. case '<':
  977. if ($value >= $v['value']) {
  978. return response()->json(['status' => 0, 'msg' => $v['msg']]);
  979. }
  980. break;
  981. case '<=':
  982. if ($value > $v['value']) {
  983. return response()->json(['status' => 0, 'msg' => $v['msg']]);
  984. }
  985. break;
  986. case '!=':
  987. if ($value == $v['value']) {
  988. return response()->json(['status' => 0, 'msg' => $v['msg']]);
  989. }
  990. break;
  991. case 'like':
  992. if (strpos($value, $v['value']) === false) {
  993. return response()->json(['status' => 0, 'msg' => $v['msg']]);
  994. }
  995. break;
  996. case 'in':
  997. if (strpos($v['value'], $value) === false) {
  998. return response()->json(['status' => 0, 'msg' => $v['msg']]);
  999. }
  1000. break;
  1001. }
  1002. }
  1003. }
  1004. }
  1005. } catch (\Exception $e) {
  1006. //error_log(serialize($data), 3, '/data/wwwroot/jucai/sms');
  1007. return ['status' => 0, 'msg' => '数据有误,请联系客服'];
  1008. }
  1009. //前置审核 判断完成,先将数据入报名信息基础表
  1010. //解析家庭成员数据
  1011. $familys = $request->input('family');
  1012. $family = [];
  1013. if (is_array($familys)) {
  1014. foreach ($familys as $value) {
  1015. if (!array_key_exists('relation', $value) || !array_key_exists('realname', $value) || !array_key_exists('birthday', $value) || !array_key_exists('political_affiliation', $value) || !array_key_exists('work', $value)) {
  1016. return ['status' => 0, 'msg' => '请填写完整的家庭成员信息'];
  1017. }
  1018. $item = [
  1019. 'relation' => $value['relation'],
  1020. 'realname' => $value['realname'],
  1021. 'birthday' => $value['birthday'],
  1022. 'political_affiliation' => $value['political_affiliation'],
  1023. 'work' => $value['work'],
  1024. ];
  1025. array_push($family, $item);
  1026. }
  1027. }
  1028. $forms = explode(',', $recruit['forms']);
  1029. if (in_array('expand_special', $forms)) {
  1030. $special = $request->input('special');
  1031. if ($special['point_apply'] && is_array($special['condition']) && count($special['condition']) == 0) {
  1032. return response()->json(['status' => 0, 'msg' => '加分条件不能为空']);
  1033. }
  1034. if ($special['point_apply'] && ($special['condition'] == '')) {
  1035. return response()->json(['status' => 0, 'msg' => '加分条件不能为空']);
  1036. }
  1037. }
  1038. $data['family'] = json_encode($family);
  1039. if ($appoint_info) {
  1040. //如果已有报名记录,进入修改阶段的处理流程
  1041. DB::beginTransaction();
  1042. try {
  1043. RecruitAppointInfo::where('id', $appoint_info->id)->update($data);
  1044. //分模块解析数据
  1045. //如果有加分模块
  1046. if (in_array('expand_special', $forms)) {
  1047. $special = $request->input('special');
  1048. if ($special['point_apply']) {//如果申请加分
  1049. if (!array_key_exists('material', $special)) {
  1050. return response()->json(['status' => 0, 'msg' => '加分佐证材料不能为空!']);
  1051. }
  1052. //删除掉没有成功返回路径的图片
  1053. if (is_array($special['material'])) {
  1054. foreach ($special['material'] as $k => $v) {
  1055. if (!array_key_exists('response', $v)) {
  1056. unset($special['material'][$k]);
  1057. }
  1058. }
  1059. }
  1060. switch ($recruit->special_condition_type) {
  1061. case 0:
  1062. $special['point'] = 0;
  1063. break;
  1064. case 1:
  1065. $special_rule = json_decode($recruit->special_condition_value, true);
  1066. $conditions = array_column($special_rule['list'], 'condition');
  1067. $special['point'] = 0;
  1068. if (array_key_exists('multi', $special_rule) && $special_rule['multi'] && is_array($special['condition'])) {
  1069. foreach ($special['condition'] as $v) {
  1070. $key = array_search($v, $conditions);
  1071. $rule_info = $special_rule['list'][$key];
  1072. $special['point'] += $rule_info['value'];
  1073. }
  1074. } else {
  1075. $key = array_search($special['condition'], $conditions);
  1076. $rule_info = $special_rule['list'][$key];
  1077. $special['point'] += $rule_info['value'];
  1078. }
  1079. break;
  1080. case 2:
  1081. $special_rule = json_decode($post_info['special'], true);
  1082. $conditions = array_column($special_rule['list'], 'condition');
  1083. $special['point'] = 0;
  1084. if (array_key_exists('multi', $special_rule) && $special_rule['multi'] && is_array($special['condition'])) {
  1085. foreach ($special['condition'] as $v) {
  1086. $key = array_search($v, $conditions);
  1087. $rule_info = $special_rule['list'][$key];
  1088. $special['point'] += $rule_info['value'];
  1089. }
  1090. } else {
  1091. $key = array_search($special['condition'], $conditions);
  1092. $rule_info = $special_rule['list'][$key];
  1093. $special['point'] += $rule_info['value'];
  1094. }
  1095. break;
  1096. }
  1097. if (is_array($special['condition'])) {
  1098. $special['condition'] = implode(',', $special['condition']);
  1099. }
  1100. $special['material'] = json_encode($special['material']);
  1101. $hasRecord = RecruitAppointExpandSpecial::where('recruit_appoint_id', $appoint_info->id)->first();
  1102. if ($hasRecord) {
  1103. RecruitAppointExpandSpecial::where('recruit_appoint_id', $appoint_info->id)->update($special);
  1104. } else {
  1105. $special['recruit_appoint_id'] = $appoint_info->id;
  1106. RecruitAppointExpandSpecial::create($special);
  1107. }
  1108. } else {
  1109. RecruitAppointExpandSpecial::where('recruit_appoint_id', $appoint_info->id)->update(['point_apply' => 0, 'condition' => '', 'point' => 0, 'material' => null]);
  1110. }
  1111. }
  1112. //如果有详情模块
  1113. if (in_array('detail', $forms) || in_array('internship', $forms)) {
  1114. $detail = $request->input('detail');
  1115. $hasRecord = RecruitAppointDetail::where('recruit_appoint_id', $appoint_info->id)->first();
  1116. if ($hasRecord) {
  1117. RecruitAppointDetail::where('recruit_appoint_id', $appoint_info->id)->update($detail);
  1118. } else {
  1119. $detail['recruit_appoint_id'] = $appoint_info->id;
  1120. RecruitAppointDetail::create($detail);
  1121. }
  1122. }
  1123. //如果有身份证明模块
  1124. if (in_array('identification', $forms) || in_array('internship', $forms)) {
  1125. $identification = $request->input('identification');
  1126. if (is_array($identification)) {
  1127. //删除掉没有成功返回路径的图片
  1128. foreach ($identification as $k => $v) {
  1129. if (!array_key_exists('response', $v)) {
  1130. unset($identification[$k]);
  1131. }
  1132. }
  1133. }
  1134. $appoint_info->identification = json_encode($identification);
  1135. $appoint_info->save();
  1136. }
  1137. //如果有教育证明模块
  1138. if (in_array('education_certification', $forms) || in_array('internship', $forms)) {
  1139. $education_certification = $request->input('education_certification');
  1140. if (is_array($education_certification)) {
  1141. //删除掉没有成功返回路径的图片
  1142. foreach ($education_certification as $k => $v) {
  1143. if (!array_key_exists('response', $v)) {
  1144. unset($education_certification[$k]);
  1145. }
  1146. }
  1147. }
  1148. $appoint_info->education_certification = json_encode($education_certification);
  1149. $appoint_info->save();
  1150. }
  1151. //如果有其他证明模块
  1152. if (in_array('other_certification', $forms) || in_array('internship', $forms)) {
  1153. $other_certification = $request->input('other_certification');
  1154. if (is_array($other_certification)) {
  1155. //删除掉没有成功返回路径的图片
  1156. foreach ($other_certification as $k => $v) {
  1157. if (!array_key_exists('response', $v)) {
  1158. unset($other_certification[$k]);
  1159. }
  1160. }
  1161. }
  1162. if ($other_certification) {
  1163. $appoint_info->other_certification = json_encode($other_certification);
  1164. $appoint_info->save();
  1165. }
  1166. }
  1167. //如果有其他证明模块
  1168. if (in_array('hj_certification', $forms)) {
  1169. $hj_certification = $request->input('hj_certification');
  1170. if (is_array($hj_certification)) {
  1171. //删除掉没有成功返回路径的图片
  1172. foreach ($hj_certification as $k => $v) {
  1173. if (!array_key_exists('response', $v)) {
  1174. unset($hj_certification[$k]);
  1175. }
  1176. }
  1177. }
  1178. if ($hj_certification) {
  1179. $appoint_info->hj_certification = json_encode($hj_certification);
  1180. $appoint_info->save();
  1181. }
  1182. }
  1183. //如果有承诺书模块
  1184. if (in_array('chengnuoshu', $forms)) {
  1185. $chengnuoshu = $request->input('chengnuoshu');
  1186. if (is_array($chengnuoshu)) {
  1187. //删除掉没有成功返回路径的图片
  1188. foreach ($chengnuoshu as $k => $v) {
  1189. if (!array_key_exists('response', $v)) {
  1190. unset($chengnuoshu[$k]);
  1191. }
  1192. }
  1193. }
  1194. if ($chengnuoshu) {
  1195. $appoint_info->chengnuoshu = json_encode($chengnuoshu);
  1196. $appoint_info->save();
  1197. }
  1198. }
  1199. //如果有失信被执行人模块
  1200. if (in_array('shixin', $forms)) {
  1201. $shixin = $request->input('shixin');
  1202. if (is_array($shixin)) {
  1203. //删除掉没有成功返回路径的图片
  1204. foreach ($shixin as $k => $v) {
  1205. if (!array_key_exists('response', $v)) {
  1206. unset($shixin[$k]);
  1207. }
  1208. }
  1209. }
  1210. if ($shixin) {
  1211. $appoint_info->shixin = json_encode($shixin);
  1212. $appoint_info->save();
  1213. }
  1214. }
  1215. //如果有声明书模块
  1216. if (in_array('baokaoshengming', $forms)) {
  1217. $baokaoshengming = $request->input('baokaoshengming');
  1218. if (is_array($baokaoshengming)) {
  1219. //删除掉没有成功返回路径的图片
  1220. foreach ($baokaoshengming as $k => $v) {
  1221. if (!array_key_exists('response', $v)) {
  1222. unset($baokaoshengming[$k]);
  1223. }
  1224. }
  1225. }
  1226. if ($baokaoshengming) {
  1227. $appoint_info->baokaoshengming = json_encode($baokaoshengming);
  1228. $appoint_info->save();
  1229. }
  1230. }
  1231. DB::commit();
  1232. if ($operation == 2) {
  1233. $log = [
  1234. 'type' => 3,
  1235. 'appoint_id' => $appoint_info->id,
  1236. 'uid' => $uid,
  1237. 'log' => '用户提交报名',
  1238. ];
  1239. RecruitAppointLog::create($log);
  1240. if (empty($recruit->qr_code)) {
  1241. return ['status' => 1, 'msg' => '提交成功', 'data' => $appoint_info->id, 'is_html' => 0];
  1242. } else {
  1243. return ['status' => 1, 'msg' => "<h3 style='text-align: center'>提交成功,添加工作人员企业微信了解后续信息</h3><p style='text-align: center'><img src='/storage/{$recruit->qr_code}' width='240' height='240' /></p>", 'data' => $appoint_info->id, 'is_html' => 1];
  1244. }
  1245. } else {
  1246. $log = [
  1247. 'type' => 4,
  1248. 'appoint_id' => $appoint_info->id,
  1249. 'uid' => $uid,
  1250. 'log' => '用户修改资料',
  1251. ];
  1252. RecruitAppointLog::create($log);
  1253. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $appoint_info->id];
  1254. }
  1255. } catch (\Exception $e) {
  1256. DB::rollback();
  1257. return ['status' => 0, 'msg' => $e->getMessage()];
  1258. }
  1259. } else {
  1260. //没有报名记录,进入增加阶段的处理流程
  1261. DB::beginTransaction();
  1262. try {
  1263. //20220726增加地区undefined选项处理
  1264. if ($index = stripos($data['native_place'], ',undefined')) {
  1265. $data['native_place'] = substr($data['native_place'], 0, $index);
  1266. }
  1267. if ($index = stripos($data['house_register'], ',undefined')) {
  1268. $data['house_register'] = substr($data['house_register'], 0, $index);
  1269. }
  1270. $data['uid'] = $uid;
  1271. $data['recruit_id'] = $recruit_id;
  1272. $result = RecruitAppointInfo::create($data);
  1273. //分模块解析数据
  1274. $forms = explode(',', $recruit['forms']);
  1275. //如果有加分模块
  1276. if (in_array('expand_special', $forms)) {
  1277. $special = $request->input('special');
  1278. if ($special['point_apply']) {
  1279. if (is_array($special['material'])) {
  1280. //删除掉没有成功返回路径的图片
  1281. foreach ($special['material'] as $k => $v) {
  1282. if (!array_key_exists('response', $v)) {
  1283. unset($special['material'][$k]);
  1284. }
  1285. }
  1286. }
  1287. switch ($recruit->special_condition_type) {
  1288. case 0:
  1289. $special['point'] = 0;
  1290. break;
  1291. case 1:
  1292. $special_rule = json_decode($recruit->special_condition_value, true);
  1293. $conditions = array_column($special_rule['list'], 'condition');
  1294. $special['point'] = 0;
  1295. if (array_key_exists('multi', $special_rule) && $special_rule['multi'] && is_array($special['condition'])) {
  1296. foreach ($special['condition'] as $v) {
  1297. $key = array_search($v, $conditions);
  1298. $rule_info = $special_rule['list'][$key];
  1299. $special['point'] += $rule_info['value'];
  1300. }
  1301. } else {
  1302. $key = array_search($special['condition'], $conditions);
  1303. $rule_info = $special_rule['list'][$key];
  1304. $special['point'] += $rule_info['value'];
  1305. }
  1306. break;
  1307. case 2:
  1308. $special_rule = json_decode($post_info['special'], true);
  1309. $conditions = array_column($special_rule['list'], 'condition');
  1310. $special['point'] = 0;
  1311. if (array_key_exists('multi', $special_rule) && $special_rule['multi'] && is_array($special['condition'])) {
  1312. foreach ($special['condition'] as $v) {
  1313. $key = array_search($v, $conditions);
  1314. $rule_info = $special_rule['list'][$key];
  1315. $special['point'] += $rule_info['value'];
  1316. }
  1317. } else {
  1318. $key = array_search($special['condition'], $conditions);
  1319. $rule_info = $special_rule['list'][$key];
  1320. $special['point'] += $rule_info['value'];
  1321. }
  1322. break;
  1323. }
  1324. if (is_array($special['condition'])) {
  1325. $special['condition'] = implode(',', $special['condition']);
  1326. }
  1327. $special['material'] = json_encode($special['material']);
  1328. $special['recruit_appoint_id'] = $result->id;
  1329. RecruitAppointExpandSpecial::create($special);
  1330. }
  1331. }
  1332. //如果有详情模块
  1333. if (in_array('detail', $forms) || in_array('internship', $forms)) {
  1334. $detail = $request->input('detail');
  1335. $detail['recruit_appoint_id'] = $result->id;
  1336. RecruitAppointDetail::create($detail);
  1337. }
  1338. //如果有身份证明模块
  1339. if (in_array('identification', $forms) || in_array('internship', $forms)) {
  1340. $identification = $request->input('identification');
  1341. if (is_array($identification)) {
  1342. //删除掉没有成功返回路径的图片
  1343. foreach ($identification as $k => $v) {
  1344. if (!array_key_exists('response', $v)) {
  1345. unset($identification[$k]);
  1346. }
  1347. }
  1348. }
  1349. $result->identification = json_encode($identification);
  1350. $result->save();
  1351. }
  1352. //如果有教育证明模块
  1353. if (in_array('education_certification', $forms) || in_array('internship', $forms)) {
  1354. $education_certification = $request->input('education_certification');
  1355. if (is_array($education_certification)) {
  1356. //删除掉没有成功返回路径的图片
  1357. foreach ($education_certification as $k => $v) {
  1358. if (!array_key_exists('response', $v)) {
  1359. unset($education_certification[$k]);
  1360. }
  1361. }
  1362. }
  1363. $result->education_certification = json_encode($education_certification);
  1364. $result->save();
  1365. }
  1366. //如果有其他证明模块
  1367. if (in_array('other_certification', $forms) || in_array('internship', $forms)) {
  1368. $other_certification = $request->input('other_certification');
  1369. if ($other_certification) {
  1370. if (is_array($other_certification)) {
  1371. //删除掉没有成功返回路径的图片
  1372. foreach ($other_certification as $k => $v) {
  1373. if (!array_key_exists('response', $v)) {
  1374. unset($other_certification[$k]);
  1375. }
  1376. }
  1377. }
  1378. $result->other_certification = json_encode($other_certification);
  1379. $result->save();
  1380. }
  1381. }
  1382. //如果有户籍证明模块
  1383. if (in_array('hj_certification', $forms)) {
  1384. $hj_certification = $request->input('hj_certification');
  1385. if ($hj_certification) {
  1386. if (is_array($hj_certification)) {
  1387. //删除掉没有成功返回路径的图片
  1388. foreach ($hj_certification as $k => $v) {
  1389. if (!array_key_exists('response', $v)) {
  1390. unset($hj_certification[$k]);
  1391. }
  1392. }
  1393. }
  1394. $result->hj_certification = json_encode($hj_certification);
  1395. $result->save();
  1396. }
  1397. }
  1398. //如果有承诺书模块
  1399. if (in_array('chengnuoshu', $forms)) {
  1400. $chengnuoshu = $request->input('chengnuoshu');
  1401. if ($chengnuoshu) {
  1402. if (is_array($chengnuoshu)) {
  1403. //删除掉没有成功返回路径的图片
  1404. foreach ($chengnuoshu as $k => $v) {
  1405. if (!array_key_exists('response', $v)) {
  1406. unset($chengnuoshu[$k]);
  1407. }
  1408. }
  1409. }
  1410. $result->chengnuoshu = json_encode($chengnuoshu);
  1411. $result->save();
  1412. }
  1413. }
  1414. //如果有失信被执行人模块
  1415. if (in_array('shixin', $forms)) {
  1416. $shixin = $request->input('shixin');
  1417. if ($shixin) {
  1418. if (is_array($shixin)) {
  1419. //删除掉没有成功返回路径的图片
  1420. foreach ($shixin as $k => $v) {
  1421. if (!array_key_exists('response', $v)) {
  1422. unset($shixin[$k]);
  1423. }
  1424. }
  1425. }
  1426. $result->shixin = json_encode($shixin);
  1427. $result->save();
  1428. }
  1429. }
  1430. //如果有声明书模块
  1431. if (in_array('baokaoshengming', $forms)) {
  1432. $baokaoshengming = $request->input('baokaoshengming');
  1433. if ($baokaoshengming) {
  1434. if (is_array($baokaoshengming)) {
  1435. //删除掉没有成功返回路径的图片
  1436. foreach ($baokaoshengming as $k => $v) {
  1437. if (!array_key_exists('response', $v)) {
  1438. unset($baokaoshengming[$k]);
  1439. }
  1440. }
  1441. }
  1442. $result->baokaoshengming = json_encode($baokaoshengming);
  1443. $result->save();
  1444. }
  1445. }
  1446. DB::commit();
  1447. if ($operation == 2) {
  1448. $log = [
  1449. 'type' => 3,
  1450. 'appoint_id' => $result->id,
  1451. 'uid' => $uid,
  1452. 'log' => '用户首次提交报名',
  1453. ];
  1454. RecruitAppointLog::create($log);
  1455. if (empty($recruit->qr_code)) {
  1456. return ['status' => 1, 'msg' => '提交成功', 'data' => $result->id, 'is_html' => 0];
  1457. } else {
  1458. return ['status' => 1, 'msg' => "<h3 style='text-align: center'>提交成功,添加工作人员企业微信了解后续信息</h3><p><img src='/storage/{$recruit->qr_code}' width='240' height='240' /></p>", 'data' => $result->id, 'is_html' => 1];
  1459. }
  1460. //return ['status' => 1, 'msg' => '提交成功', 'data' => $result->id];
  1461. } else {
  1462. $log = [
  1463. 'type' => 4,
  1464. 'appoint_id' => $result->id,
  1465. 'uid' => $uid,
  1466. 'log' => '用户暂存资料',
  1467. ];
  1468. RecruitAppointLog::create($log);
  1469. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $result->id];
  1470. }
  1471. } catch (\Exception $e) {
  1472. DB::rollback();
  1473. return ['status' => 0, 'msg' => $e->getMessage()];
  1474. }
  1475. }
  1476. }
  1477. /**
  1478. * 获得当前登录的用户
  1479. * @return \Illuminate\Contracts\Auth\Authenticatable|null
  1480. */
  1481. public function getUser()
  1482. {
  1483. if (auth('web-member')->check()) {
  1484. $user = auth('web-member')->user();
  1485. } else {
  1486. $user = null;
  1487. }
  1488. return $user;
  1489. }
  1490. /**
  1491. * 检查用户基本信息
  1492. * @return array
  1493. */
  1494. public function checkUserBasicInfo()
  1495. {
  1496. $user = $this->getUser();
  1497. if (!empty($user)) {
  1498. $uid = $user->id;
  1499. } else {
  1500. $arr = ['status' => 401, 'msg' => '请登录!'];
  1501. return $arr;
  1502. }
  1503. $info = RecruitAppointBasic::where('uid', $uid)->first();
  1504. if (empty($info)) {
  1505. $arr = ['status' => 401, 'msg' => '请先完善招考基本信息', 'url' => route('recruit.recruitInfo')];
  1506. return $arr;
  1507. }
  1508. return ['status' => 200, 'msg' => ''];
  1509. }
  1510. /**
  1511. * 个人中心招考页面
  1512. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  1513. */
  1514. public function person_recruit()
  1515. {
  1516. $user = auth('web-member')->user();
  1517. $list = RecruitAppointInfo::where('uid', $user->id)
  1518. ->join('recruit', 'recruit.id', '=', 'recruit_appoint_info.recruit_id', 'left')
  1519. ->join('recruit_post', 'recruit_post.id', '=', 'recruit_appoint_info.post_id', 'left')
  1520. ->select('recruit.name as recruit_name', 'recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name')
  1521. ->get();
  1522. return view('app.person.recruit')->with(['list' => $list, 'total' => count($list)]);
  1523. }
  1524. /**
  1525. * 招考信息基础页
  1526. * @param Request $request
  1527. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  1528. */
  1529. public function recruit_info(Request $request)
  1530. {
  1531. $user = auth('web-member')->user();
  1532. if (!empty($user)) {
  1533. $uid = $user->id;
  1534. } else {
  1535. return redirect(route('login'));
  1536. }
  1537. $info = RecruitAppointBasic::where('uid', $user->id)->first();
  1538. if (!$info) {
  1539. $info = [
  1540. 'realname' => '',
  1541. 'sex' => '0',
  1542. 'birthday' => '',
  1543. 'avatar' => '',
  1544. 'nation' => '',
  1545. 'native_place' => '',
  1546. 'political_affiliation' => '',
  1547. 'titles' => '',
  1548. 'work' => '',
  1549. 'house_register' => '',
  1550. 'join_time' => '',
  1551. 'edu_type' => '',
  1552. 'education' => '',
  1553. 'school' => '',
  1554. 'degree' => '',
  1555. 'pro' => '',
  1556. 'address' => '',
  1557. 'card' => '',
  1558. 'mobile' => '',
  1559. 'email' => '',
  1560. 'concat_name' => '',
  1561. 'concat_mobile' => '',
  1562. 'resume' => '',
  1563. 'family' => [
  1564. [
  1565. 'relation' => '',
  1566. 'realname' => '',
  1567. 'birthday' => '',
  1568. 'political_affiliation' => '',
  1569. 'work' => '',
  1570. ],
  1571. ],
  1572. 'is_push' => '1',
  1573. ];
  1574. } else {
  1575. $info->sex = (string)$info->sex;
  1576. $info->edu_type = (string)$info->edu_type;
  1577. $info->is_push = (string)$info->is_push;
  1578. $info->family = empty($info->family) ? [[
  1579. 'relation' => '',
  1580. 'realname' => '',
  1581. 'birthday' => '',
  1582. 'political_affiliation' => '',
  1583. 'work' => '',
  1584. ]] : json_decode($info->family);
  1585. }
  1586. $recruit_id = $request->input('recruit_id', 0);
  1587. return view('app.person.recruit_info', [
  1588. 'info' => json_encode($info),
  1589. 'recruit_id' => $recruit_id,
  1590. ]);
  1591. }
  1592. /**
  1593. * 保存招考信息
  1594. * @param RecruitValidatorRequest $request
  1595. * @return \Illuminate\Http\JsonResponse
  1596. */
  1597. public function saveRecruitInfo(RecruitValidatorRequest $request)
  1598. {
  1599. $user = auth('web-member')->user();
  1600. $basic = RecruitAppointBasic::where('uid', $user->id)->first();
  1601. $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');
  1602. if (count($data['family']) > 0) {
  1603. $data['family'] = json_encode($data['family']);
  1604. }
  1605. if ($basic) {
  1606. //更新基础信息
  1607. $res = RecruitAppointBasic::where('uid', $user->id)->update($data);
  1608. if (!$res) {
  1609. return response()->json(['status' => 0, 'msg' => '保存失败,请联系客服']);
  1610. } else {
  1611. return response()->json(['status' => 1, 'msg' => '个人基础信息保存成功,快去报名吧!']);
  1612. }
  1613. } else {
  1614. //新增基础信息
  1615. $data['uid'] = $user->id;
  1616. $res = RecruitAppointBasic::create($data);
  1617. if (!$res) {
  1618. return response()->json(['status' => 0, 'msg' => '保存失败,请联系客服']);
  1619. } else {
  1620. return response()->json(['status' => 1, 'msg' => '个人基础信息保存成功,快去报名吧!']);
  1621. }
  1622. }
  1623. }
  1624. /**
  1625. * 笔试准考证
  1626. * @param Request $request
  1627. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1628. */
  1629. public function pen_ticket(Request $request)
  1630. {
  1631. $user = $this->getUser();
  1632. if (!empty($user)) {
  1633. $uid = $user->id;
  1634. } else {
  1635. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1636. }
  1637. $recruit_id = $request->input('recruit_id');
  1638. $recruit = Recruit::where('id', $recruit_id)->first();
  1639. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  1640. if ($appoint_info) {
  1641. $pen_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 1)->first();
  1642. if ($pen_ticket) {
  1643. $health = RecruitSupplement::where('appoint_id', $appoint_info->id)->first();
  1644. if ((!$health || $health->h_status == 0) && $recruit->pen_epidemic) {
  1645. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1646. }
  1647. $time = time();
  1648. if (strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time) {
  1649. RecruitTicket::where('appoint_id', $appoint_info->id)->update(['ex_status' => 1]);
  1650. $post_data = RecruitPost::where('recruit_id', $recruit_id)->where('status', 1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1651. $name = $recruit->name_en;
  1652. $date = date("Y-m-d", strtotime($recruit->created_at));
  1653. //$filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1654. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1655. // return view('app.recruit.recruit_ticket', [
  1656. // 'title' => "{$filename}.docx",
  1657. // 'url' => "https://www.jucai.gov.cn/storage/recruit/ticket/word/{$date}/{$name}/pen/{$filename}.docx",
  1658. // ]);
  1659. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/pen/" . $filename . '.pdf';
  1660. if (file_exists($file)) {
  1661. header('Content-Description: File Transfer');
  1662. header('Content-Type: application/octet-stream');
  1663. header('Content-Disposition: attachment; filename=' . basename($file));
  1664. header('Content-Transfer-Encoding: binary');
  1665. header('Expires: 0');
  1666. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1667. header('Pragma: public');
  1668. header('Content-Length: ' . filesize($file));
  1669. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1670. flush();
  1671. readfile($file);
  1672. } else {
  1673. return $this->showMessage('准考证不存在,请联系管理员!', route('home'), true, '上一页', '3');
  1674. }
  1675. } else {
  1676. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1677. }
  1678. } else {
  1679. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1680. }
  1681. } else {
  1682. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1683. }
  1684. }
  1685. /**
  1686. * 审核准考证
  1687. * @param Request $request
  1688. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1689. */
  1690. public function check_ticket(Request $request)
  1691. {
  1692. $user = $this->getUser();
  1693. if (!empty($user)) {
  1694. $uid = $user->id;
  1695. } else {
  1696. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1697. }
  1698. $recruit_id = $request->input('recruit_id');
  1699. $recruit = Recruit::where('id', $recruit_id)->first();
  1700. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  1701. if ($appoint_info) {
  1702. $check_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 2)->first();
  1703. if ($check_ticket) {
  1704. $health = RecruitSupplement::where('appoint_id', $appoint_info->id)->first();
  1705. if ((!$health || $health->h_status == 0) && $recruit->pen_epidemic) {
  1706. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1707. }
  1708. $time = time();
  1709. if (strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time) {
  1710. RecruitTicket::where('id', $check_ticket->id)->update(['ex_status' => 1]);
  1711. $recruit = Recruit::where('id', $recruit_id)->first();
  1712. $post_data = RecruitPost::where('recruit_id', $recruit_id)->where('status', 1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1713. $name = $recruit->name_en;
  1714. $date = date("Y-m-d", strtotime($recruit->created_at));
  1715. //$filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1716. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1717. // return view('app.recruit.recruit_ticket', [
  1718. // 'title' => "{$filename}.docx",
  1719. // 'url' => "https://www.jucai.gov.cn/storage/recruit/ticket/word/{$date}/{$name}/computer/{$filename}.docx",
  1720. // ]);
  1721. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/computer/" . $filename . '.pdf';
  1722. if (file_exists($file)) {
  1723. header('Content-Description: File Transfer');
  1724. header('Content-Type: application/octet-stream');
  1725. header('Content-Disposition: attachment; filename=' . basename($file));
  1726. header('Content-Transfer-Encoding: binary');
  1727. header('Expires: 0');
  1728. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1729. header('Pragma: public');
  1730. header('Content-Length: ' . filesize($file));
  1731. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1732. flush();
  1733. readfile($file);
  1734. }
  1735. } else {
  1736. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1737. }
  1738. } else {
  1739. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1740. }
  1741. } else {
  1742. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1743. }
  1744. }
  1745. /**
  1746. * 面试准考证
  1747. * @param Request $request
  1748. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1749. */
  1750. public function face_ticket(Request $request)
  1751. {
  1752. $user = $this->getUser();
  1753. if (!empty($user)) {
  1754. $uid = $user->id;
  1755. } else {
  1756. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1757. }
  1758. $recruit_id = $request->input('recruit_id');
  1759. $recruit = Recruit::where('id', $recruit_id)->first();
  1760. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->orderBy('id','desc')->first();
  1761. if ($appoint_info) {
  1762. $face_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 3)->first();
  1763. if ($face_ticket) {
  1764. $health = RecruitSupplement::where('appoint_id', $appoint_info->id)->first();
  1765. if ((!$health || $health->h_status == 0) && $recruit->pen_epidemic) {
  1766. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1767. }
  1768. $time = time();
  1769. if (strtotime($face_ticket->ex_start) < $time && strtotime($face_ticket->ex_end) > $time) {
  1770. RecruitTicket::where('id', $face_ticket->id)->update(['ex_status' => 1]);
  1771. $recruit = Recruit::where('id', $recruit_id)->first();
  1772. $post_data = RecruitPost::where('recruit_id', $recruit_id)->where('status', 1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1773. $name = $recruit->name_en;
  1774. $date = date("Y-m-d", strtotime($recruit->created_at));
  1775. //$filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1776. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1777. // return view('app.recruit.recruit_ticket', [
  1778. // 'title' => "{$filename}.docx",
  1779. // 'url' => "https://www.jucai.gov.cn/storage/recruit/ticket/word/{$date}/{$name}/face/{$filename}.docx",
  1780. // ]);
  1781. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';
  1782. if (file_exists($file)) {
  1783. header('Content-Description: File Transfer');
  1784. header('Content-Type: application/octet-stream');
  1785. header('Content-Disposition: attachment; filename=' . basename($file));
  1786. header('Content-Transfer-Encoding: binary');
  1787. header('Expires: 0');
  1788. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1789. header('Pragma: public');
  1790. header('Content-Length: ' . filesize($file));
  1791. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1792. flush();
  1793. readfile($file);
  1794. }
  1795. } else {
  1796. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1797. }
  1798. } else {
  1799. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1800. }
  1801. } else {
  1802. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1803. }
  1804. }
  1805. /**
  1806. * 复试准考证
  1807. * @param Request $request
  1808. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1809. */
  1810. public function reexamine_ticket(Request $request)
  1811. {
  1812. $user = $this->getUser();
  1813. if (!empty($user)) {
  1814. $uid = $user->id;
  1815. } else {
  1816. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1817. }
  1818. $recruit_id = $request->input('recruit_id');
  1819. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  1820. if ($appoint_info) {
  1821. $reexamine_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 4)->first();
  1822. if ($reexamine_ticket) {
  1823. $time = time();
  1824. if (strtotime($reexamine_ticket->ex_start) < $time && strtotime($reexamine_ticket->ex_end) > $time) {
  1825. RecruitTicket::where('id', $reexamine_ticket->id)->update(['ex_status' => 1]);
  1826. $recruit = Recruit::where('id', $recruit_id)->first();
  1827. $post_data = RecruitPost::where('recruit_id', $recruit_id)->where('status', 1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1828. $name = $recruit->name_en;
  1829. $date = date("Y-m-d", strtotime($recruit->created_at));
  1830. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1831. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/reexamine/" . $filename . '.pdf';
  1832. if (file_exists($file)) {
  1833. header('Content-Description: File Transfer');
  1834. header('Content-Type: application/octet-stream');
  1835. header('Content-Disposition: attachment; filename=' . basename($file));
  1836. header('Content-Transfer-Encoding: binary');
  1837. header('Expires: 0');
  1838. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1839. header('Pragma: public');
  1840. header('Content-Length: ' . filesize($file));
  1841. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1842. flush();
  1843. readfile($file);
  1844. }
  1845. } else {
  1846. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1847. }
  1848. } else {
  1849. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1850. }
  1851. } else {
  1852. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1853. }
  1854. }
  1855. /**
  1856. * 材料补登
  1857. * @param Request $request
  1858. */
  1859. public function material_supplement(Request $request)
  1860. {
  1861. $user = $this->getUser();
  1862. if (!empty($user)) {
  1863. $uid = $user->id;
  1864. } else {
  1865. return redirect(route('login'));
  1866. }
  1867. //招考id
  1868. $id = $request->input('id', 0);
  1869. if (!$id) {
  1870. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1871. }
  1872. $recruit = Recruit::find($id);
  1873. if (!$recruit['status'] && !$user->recruit_test) {
  1874. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1875. }
  1876. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  1877. if (!$appoint_info) {
  1878. return $this->showMessage('抱歉,您没有报名,无需考察审核!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1879. }
  1880. if ($appoint_info->pen_audit != 1) {
  1881. return $this->showMessage('抱歉,您未入闱,无需考察审核!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1882. }
  1883. $limit_time = 1726824600;
  1884. $time = time();
  1885. if ($time > $limit_time) {
  1886. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1887. }
  1888. $info = RecruitSupplement::where('appoint_id', $appoint_info->id)->where('type', 'supplement')->first();
  1889. if (!$info) {
  1890. $info = [
  1891. 'appoint_id' => $appoint_info->id,
  1892. 'identification' => '',
  1893. //'household_register' => '',
  1894. //'education_certification' => '',
  1895. //'family_planning' => '',
  1896. 'chengxin' => '',
  1897. 'manage' => '',
  1898. 'status' => 3,
  1899. ];
  1900. } else {
  1901. $info = $info->toArray();
  1902. if (json_decode($info['identification'])) {
  1903. $identification = json_decode($info['identification'], true);
  1904. foreach ($identification as $k => $v) {
  1905. if (array_key_exists('response', $v)) {
  1906. $identification[$k]['url'] = $v['response']['path'];
  1907. }
  1908. }
  1909. } else {
  1910. $identification = [];
  1911. }
  1912. $info['identification'] = $identification;
  1913. if (json_decode($info['household_register'])) {
  1914. $household_register = json_decode($info['household_register'], true);
  1915. foreach ($household_register as $k => $v) {
  1916. if (array_key_exists('response', $v)) {
  1917. $household_register[$k]['url'] = $v['response']['path'];
  1918. }
  1919. }
  1920. } else {
  1921. $household_register = [];
  1922. }
  1923. $info['household_register'] = $household_register;
  1924. if (json_decode($info['education_certification'])) {
  1925. $education_certification = json_decode($info['education_certification'], true);
  1926. foreach ($education_certification as $k => $v) {
  1927. if (array_key_exists('response', $v)) {
  1928. $education_certification[$k]['url'] = $v['response']['path'];
  1929. }
  1930. }
  1931. } else {
  1932. $education_certification = [];
  1933. }
  1934. $info['education_certification'] = $education_certification;
  1935. if (json_decode($info['family_planning'])) {
  1936. $family_planning = json_decode($info['family_planning'], true);
  1937. foreach ($family_planning as $k => $v) {
  1938. if (array_key_exists('response', $v)) {
  1939. $family_planning[$k]['url'] = $v['response']['path'];
  1940. }
  1941. }
  1942. } else {
  1943. $family_planning = [];
  1944. }
  1945. $info['family_planning'] = $family_planning;
  1946. if (json_decode($info['chengxin'])) {
  1947. $chengxin = json_decode($info['chengxin'], true);
  1948. foreach ($chengxin as $k => $v) {
  1949. if (array_key_exists('response', $v)) {
  1950. $chengxin[$k]['url'] = $v['response']['path'];
  1951. }
  1952. }
  1953. } else {
  1954. $chengxin = [];
  1955. }
  1956. $info['chengxin'] = $chengxin;
  1957. if (json_decode($info['manage'])) {
  1958. $manage = json_decode($info['manage'], true);
  1959. foreach ($manage as $k => $v) {
  1960. if (array_key_exists('response', $v)) {
  1961. $manage[$k]['url'] = $v['response']['path'];
  1962. }
  1963. }
  1964. } else {
  1965. $manage = [];
  1966. }
  1967. $info['manage'] = $manage;
  1968. }
  1969. $view_data['info'] = json_encode($info);
  1970. $view_data['title'] = $recruit->company;
  1971. return view('app.recruit.supplement', $view_data);
  1972. }
  1973. /**
  1974. * 健康信息登记
  1975. * @param Request $request
  1976. */
  1977. public function health_info(Request $request)
  1978. {
  1979. $user = $this->getUser();
  1980. if (!empty($user)) {
  1981. $uid = $user->id;
  1982. } else {
  1983. return redirect(route('login'));
  1984. }
  1985. //招考id
  1986. $id = $request->input('id', 0);
  1987. if (!$id) {
  1988. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1989. }
  1990. $recruit = Recruit::find($id);
  1991. if (!$recruit['status'] && !$user->recruit_test) {
  1992. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1993. }
  1994. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  1995. if (!$appoint_info) {
  1996. return $this->showMessage('抱歉,您没有报名,无需登记!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1997. }
  1998. if ($appoint_info->audit != 3) {
  1999. return $this->showMessage('抱歉,您无需登记!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2000. }
  2001. $time = time();
  2002. $type = $request->input('type', null);
  2003. $where = [];
  2004. if ($type) {
  2005. switch ($type) {
  2006. case 'pen':
  2007. $start = strtotime($recruit->pen_health_start);
  2008. $end = strtotime($recruit->pen_health_end);
  2009. break;
  2010. case 'computer':
  2011. $start = strtotime($recruit->computer_health_start);
  2012. $end = strtotime($recruit->computer_health_end);
  2013. break;
  2014. case 'face':
  2015. $start = strtotime($recruit->face_health_start);
  2016. $end = strtotime($recruit->face_health_end);
  2017. break;
  2018. case 'reexamine':
  2019. $start = strtotime($recruit->reexamine_health_start);
  2020. $end = strtotime($recruit->reexamine_health_end);
  2021. break;
  2022. default:
  2023. $start = strtotime($recruit->supplement_start);
  2024. $end = strtotime($recruit->supplement_end);
  2025. break;
  2026. }
  2027. $where[] = ['type', '=', $type];
  2028. } else {
  2029. $start = strtotime($recruit->supplement_start);
  2030. $end = strtotime($recruit->supplement_end);
  2031. }
  2032. if ($time > $end || $time < $start) {
  2033. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2034. }
  2035. $where[] = ['appoint_id', '=', $appoint_info->id];
  2036. $info = RecruitSupplement::where($where)->first();
  2037. if (!$info) {
  2038. $info = [
  2039. 'appoint_id' => $appoint_info->id,
  2040. 'health_code' => '',
  2041. 'trip_code' => '',
  2042. 'type' => $type,
  2043. ];
  2044. } else {
  2045. $info = $info->toArray();
  2046. if (json_decode($info['health_code'])) {
  2047. $health_code = json_decode($info['health_code'], true);
  2048. foreach ($health_code as $k => $v) {
  2049. if (array_key_exists('response', $v)) {
  2050. $health_code[$k]['url'] = $v['response']['path'];
  2051. }
  2052. }
  2053. } else {
  2054. $health_code = [];
  2055. }
  2056. $info['health_code'] = $health_code;
  2057. if (json_decode($info['trip_code'])) {
  2058. $trip_code = json_decode($info['trip_code'], true);
  2059. foreach ($trip_code as $k => $v) {
  2060. if (array_key_exists('response', $v)) {
  2061. $trip_code[$k]['url'] = $v['response']['path'];
  2062. }
  2063. }
  2064. } else {
  2065. $trip_code = [];
  2066. }
  2067. $info['trip_code'] = $trip_code;
  2068. }
  2069. $view_data['info'] = json_encode($info);
  2070. $view_data['title'] = $recruit->company;
  2071. return view('app.recruit.health', $view_data);
  2072. }
  2073. public function save_supplement(Request $request)
  2074. {
  2075. $user = $this->getUser();
  2076. if (!empty($user)) {
  2077. $uid = $user->id;
  2078. } else {
  2079. return redirect(route('login'));
  2080. }
  2081. $limit_time = 1726824600;
  2082. $time = time();
  2083. if ($time > $limit_time) {
  2084. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show', ['id', 38]), true, '上一页', '3');
  2085. }
  2086. $appoint_id = $request->input('appoint_id');
  2087. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', 68)->where('id', $appoint_id)->first();
  2088. if (!$appoint_info) {
  2089. return ['status' => 0, 'msg' => '抱歉,找不到您要补登的报名记录!'];
  2090. }
  2091. $info = RecruitSupplement::where('appoint_id', $appoint_id)->where('type', 'supplement')->first();
  2092. if ($info) {
  2093. if ($info->status == 1) {
  2094. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  2095. }
  2096. if ($info->status == 0) {
  2097. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  2098. }
  2099. //身份证明
  2100. $identification = $request->input('identification');
  2101. if (is_array($identification)) {
  2102. //删除掉没有成功返回路径的图片
  2103. foreach ($identification as $k => $v) {
  2104. if (!array_key_exists('response', $v)) {
  2105. unset($identification[$k]);
  2106. }
  2107. }
  2108. }
  2109. $info->identification = json_encode($identification);
  2110. //户口簿
  2111. $household_register = $request->input('household_register');
  2112. if (is_array($household_register)) {
  2113. //删除掉没有成功返回路径的图片
  2114. foreach ($household_register as $k => $v) {
  2115. if (!array_key_exists('response', $v)) {
  2116. unset($household_register[$k]);
  2117. }
  2118. }
  2119. }
  2120. $info->household_register = json_encode($household_register);
  2121. //学信网
  2122. $education_certification = $request->input('education_certification');
  2123. if (is_array($education_certification)) {
  2124. //删除掉没有成功返回路径的图片
  2125. foreach ($education_certification as $k => $v) {
  2126. if (!array_key_exists('response', $v)) {
  2127. unset($education_certification[$k]);
  2128. }
  2129. }
  2130. }
  2131. $info->education_certification = json_encode($education_certification);
  2132. //计生
  2133. // $family_planning = $request->input('family_planning');
  2134. // if(is_array($family_planning)){
  2135. // //删除掉没有成功返回路径的图片
  2136. // foreach ($family_planning as $k => $v){
  2137. // if(!array_key_exists('response',$v)){
  2138. // unset($family_planning[$k]);
  2139. // }
  2140. // }
  2141. // }
  2142. // $info->family_planning = json_encode($family_planning);
  2143. //失信查询 情况
  2144. $chengxin = $request->input('chengxin');
  2145. if (is_array($chengxin)) {
  2146. //删除掉没有成功返回路径的图片
  2147. foreach ($chengxin as $k => $v) {
  2148. if (!array_key_exists('response', $v)) {
  2149. unset($chengxin[$k]);
  2150. }
  2151. }
  2152. }
  2153. $info->chengxin = json_encode($chengxin);
  2154. //综治
  2155. $manage = $request->input('manage');
  2156. if (is_array($manage)) {
  2157. //删除掉没有成功返回路径的图片
  2158. foreach ($manage as $k => $v) {
  2159. if (!array_key_exists('response', $v)) {
  2160. unset($manage[$k]);
  2161. }
  2162. }
  2163. }
  2164. $info->manage = json_encode($manage);
  2165. $info->status = 0;
  2166. $info->save();
  2167. $appoint_info->political_audit = 4;
  2168. $appoint_info->save();
  2169. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  2170. } else {
  2171. $data['appoint_id'] = $appoint_id;
  2172. //身份证明
  2173. $identification = $request->input('identification');
  2174. if (is_array($identification)) {
  2175. //删除掉没有成功返回路径的图片
  2176. foreach ($identification as $k => $v) {
  2177. if (!array_key_exists('response', $v)) {
  2178. unset($identification[$k]);
  2179. }
  2180. }
  2181. }
  2182. $data['identification'] = json_encode($identification);
  2183. //户口簿
  2184. $household_register = $request->input('household_register');
  2185. if (is_array($household_register)) {
  2186. //删除掉没有成功返回路径的图片
  2187. foreach ($household_register as $k => $v) {
  2188. if (!array_key_exists('response', $v)) {
  2189. unset($household_register[$k]);
  2190. }
  2191. }
  2192. }
  2193. $data['household_register'] = json_encode($household_register);
  2194. //学信网
  2195. $education_certification = $request->input('education_certification');
  2196. if (is_array($education_certification)) {
  2197. //删除掉没有成功返回路径的图片
  2198. foreach ($education_certification as $k => $v) {
  2199. if (!array_key_exists('response', $v)) {
  2200. unset($education_certification[$k]);
  2201. }
  2202. }
  2203. }
  2204. $data['education_certification'] = json_encode($education_certification);
  2205. //计生
  2206. // $family_planning = $request->input('family_planning');
  2207. // if(is_array($family_planning)){sp
  2208. // //删除掉没有成功返回路径的图片
  2209. // foreach ($family_planning as $k => $v){
  2210. // if(!array_key_exists('response',$v)){
  2211. // unset($family_planning[$k]);
  2212. // }
  2213. // }
  2214. // }
  2215. // $data['family_planning'] = json_encode($family_planning);
  2216. //失信查询 情况
  2217. $chengxin = $request->input('chengxin');
  2218. if (is_array($chengxin)) {
  2219. //删除掉没有成功返回路径的图片
  2220. foreach ($chengxin as $k => $v) {
  2221. if (!array_key_exists('response', $v)) {
  2222. unset($chengxin[$k]);
  2223. }
  2224. }
  2225. }
  2226. $data['chengxin'] = json_encode($chengxin);
  2227. //综治
  2228. $manage = $request->input('manage');
  2229. if (is_array($manage)) {
  2230. //删除掉没有成功返回路径的图片
  2231. foreach ($manage as $k => $v) {
  2232. if (!array_key_exists('response', $v)) {
  2233. unset($manage[$k]);
  2234. }
  2235. }
  2236. }
  2237. $data['manage'] = json_encode($manage);
  2238. $data['status'] = 0;
  2239. $data['type'] = 'supplement';
  2240. $result = RecruitSupplement::create($data);
  2241. $appoint_info->political_audit = 4;
  2242. $appoint_info->save();
  2243. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  2244. }
  2245. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  2246. }
  2247. public function save_healthinfo(Request $request)
  2248. {
  2249. $user = $this->getUser();
  2250. if (!empty($user)) {
  2251. $uid = $user->id;
  2252. } else {
  2253. return redirect(route('login'));
  2254. }
  2255. $appoint_id = $request->input('appoint_id');
  2256. $type = $request->input('type');
  2257. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('id', $appoint_id)->first();
  2258. if (!$appoint_info) {
  2259. return ['status' => 0, 'msg' => '抱歉,找不到您要登记的报名记录!'];
  2260. }
  2261. $recruit = Recruit::where('id', $appoint_info->recruit_id)->first();
  2262. $info = RecruitSupplement::where('appoint_id', $appoint_id)->where('type', $type)->first();
  2263. if ($info) {
  2264. if ($info->h_status == 1) {
  2265. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  2266. }
  2267. if ($info->h_status == 0) {
  2268. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  2269. }
  2270. $health_code = $request->input('health_code');
  2271. if (is_array($health_code)) {
  2272. //删除掉没有成功返回路径的图片
  2273. foreach ($health_code as $k => $v) {
  2274. if (!array_key_exists('response', $v)) {
  2275. unset($health_code[$k]);
  2276. }
  2277. }
  2278. }
  2279. $info->health_code = json_encode($health_code);
  2280. $trip_code = $request->input('trip_code');
  2281. if (is_array($trip_code)) {
  2282. //删除掉没有成功返回路径的图片
  2283. foreach ($trip_code as $k => $v) {
  2284. if (!array_key_exists('response', $v)) {
  2285. unset($trip_code[$k]);
  2286. }
  2287. }
  2288. }
  2289. $info->trip_code = json_encode($trip_code);
  2290. $info->h_status = 0;
  2291. $appoint_info->health_audit = 4;
  2292. $appoint_info->save();
  2293. $info->save();
  2294. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  2295. } else {
  2296. $data['appoint_id'] = $appoint_id;
  2297. $data['type'] = $type;
  2298. $data['h_status'] = 0;
  2299. $appoint_info->health_audit = 4;
  2300. $health_code = $request->input('health_code');
  2301. if (is_array($health_code)) {
  2302. //删除掉没有成功返回路径的图片
  2303. foreach ($health_code as $k => $v) {
  2304. if (!array_key_exists('response', $v)) {
  2305. unset($health_code[$k]);
  2306. }
  2307. }
  2308. }
  2309. $health_result = $this->baiduService->health_code(file_get_contents(base_path() . "/public" . $health_code[0]['response']['path']));
  2310. $health_msg = ['健康码自动审核通过'];
  2311. //$h_status = 1;
  2312. //$appoint_info->health_audit = 1;
  2313. if (!array_key_exists('error_msg', $health_result) && !array_key_exists('error_code', $health_result)) {
  2314. if (array_key_exists('姓名', $health_result)) {
  2315. if (stripos($health_result['姓名'][0]['word'], '*') > 0) {
  2316. return ['status' => 0, 'msg' => '请打开健康码的“眼睛开关”,显示完整个人信息'];
  2317. }
  2318. if ($health_result['姓名'][0]['word'] != $appoint_info->realname) {
  2319. array_push($health_msg, '抱歉,请上传您本人的健康码!');
  2320. }
  2321. } else {
  2322. array_push($health_msg, '健康码错误,识别不到姓名!');
  2323. }
  2324. if (array_key_exists('状态', $health_result)) {
  2325. if ($health_result['状态'][0]['word'] != '绿码') {
  2326. array_push($health_msg, '抱歉,您的健康码非绿码!');
  2327. }
  2328. } else {
  2329. array_push($health_msg, '健康码错误,识别不到状态!');
  2330. }
  2331. if (array_key_exists('更新时间', $health_result)) {
  2332. $time = strtotime($health_result['更新时间'][0]['word']);
  2333. if ($time < strtotime($recruit->pen_health_start) || $time > strtotime($recruit->pen_health_end)) {
  2334. array_push($health_msg, '抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的健康码!');
  2335. }
  2336. } else {
  2337. array_push($health_msg, '健康码错误,识别不到时间!');
  2338. }
  2339. //$data['h_status'] = $h_status;
  2340. $data['h_msg'] = implode(';', $health_msg);
  2341. //$appoint_info->health_audit = $h_status == 1 ? 1 : 4;
  2342. $data['health_code'] = json_encode($health_code);
  2343. }
  2344. $data['health_result'] = json_encode($health_result);
  2345. $trip_code = $request->input('trip_code');
  2346. if (is_array($trip_code)) {
  2347. //删除掉没有成功返回路径的图片
  2348. foreach ($trip_code as $k => $v) {
  2349. if (!array_key_exists('response', $v)) {
  2350. unset($trip_code[$k]);
  2351. }
  2352. }
  2353. }
  2354. $trip_result = $this->baiduService->trip_code(file_get_contents(base_path() . "/public" . $trip_code[0]['response']['path']));
  2355. $trip_msg = [];
  2356. $trip_status = 0;
  2357. if (!array_key_exists('error_msg', $trip_result) && !array_key_exists('error_code', $trip_result)) {
  2358. if (array_key_exists('途经地', $trip_result['result'])) {
  2359. $fangyi_area = explode("\r\n", config('aix.fangyi.fangyi_zhaokao.fangyi_zhaokao.risk_area'));
  2360. $result = array_intersect($fangyi_area, $trip_result['result']['途经地'][0]['word']);
  2361. if (count($result) > 0) {
  2362. array_push($trip_msg, '抱歉,您的行程中包含系统设置中高风险地区!');
  2363. $trip_status = 0;
  2364. }
  2365. }
  2366. if (array_key_exists('风险性', $trip_result['result']) && $trip_result['result']['风险性']) {
  2367. array_push($trip_msg, '抱歉,您的行程可能含有风险!');
  2368. $trip_status = 0;
  2369. }
  2370. if (array_key_exists('更新时间', $trip_result['result'])) {
  2371. $time = strtotime($trip_result['result']['更新时间'][0]['word'][0]);
  2372. if ($time > strtotime($recruit->pen_health_start) || $recruit < ($recruit->pen_health_end)) {
  2373. array_push($trip_msg, '抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的行程码!');
  2374. $trip_status = 0;
  2375. }
  2376. }
  2377. $data['h_msg'] .= implode(';', $trip_msg);
  2378. }
  2379. $data['trip_result'] = json_encode($trip_result);
  2380. $data['trip_code'] = json_encode($trip_code);
  2381. $data['h_status'] = 0;
  2382. $appoint_info->health_audit = 4;
  2383. RecruitSupplement::create($data);
  2384. $appoint_info->save();
  2385. return ['status' => 1, 'msg' => '提交成功,请刷新查看审核结果', 'data' => ''];
  2386. }
  2387. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  2388. }
  2389. public function post_select(Request $request)
  2390. {
  2391. $user = $this->getUser();
  2392. if (!empty($user)) {
  2393. $uid = $user->id;
  2394. } else {
  2395. return redirect(route('login'));
  2396. }
  2397. $recruit_id = $request->input('recruit_id');
  2398. //$appoint_id = $request->input('appoint_id');
  2399. $info = RecruitAppointSelect::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  2400. if (!$info) {
  2401. return $this->showMessage('抱歉,您无需择岗!', route('recruit.show', ['id', $recruit_id]), true, '上一页', '2');
  2402. }
  2403. //手动设置择岗时间段
  2404. $time = time();
  2405. if ($time > 1727150400 || $time < 1727053200) {
  2406. //if($time > 1694491200){
  2407. return $this->showMessage('抱歉,未到择岗时间!', route('recruit.show', ['id', $recruit_id]), true, '上一页', '2');
  2408. }
  2409. $option_list = [
  2410. [
  2411. 'id' => 1,
  2412. 'name' => '陈埭镇',
  2413. ],
  2414. [
  2415. 'id' => 2,
  2416. 'name' => '金井镇',
  2417. ],
  2418. [
  2419. 'id' => 3,
  2420. 'name' => '深沪镇'
  2421. ]
  2422. ];
  2423. $select_list = [];
  2424. if ($info->result) {
  2425. $result = json_decode($info->result, true);
  2426. foreach ($result as $v) {
  2427. $item['name'] = $v;
  2428. array_push($select_list, $item);
  2429. }
  2430. }
  2431. // $recruit_id = $request->input('recruit_id');
  2432. // $appoint_id = $request->input('appoint_id');
  2433. // $uid = $request->input('uid');
  2434. // $info = RecruitAppointSelect::where('uid',$uid)->first();
  2435. // if(!$info){
  2436. // $info = new \stdClass();
  2437. // $info->status = 0;
  2438. // $info->recruit_id = 8;
  2439. // $info->appoint_id = rand(0,999999);
  2440. // $info->uid = rand(0,999999);
  2441. // }else{
  2442. // $result = json_decode($info->result,true);
  2443. // foreach ($option_list as $k => $v){
  2444. // if(in_array($v['name'],$result)){
  2445. // $select_list[$k] = $v;
  2446. // unset($option_list[$k]);
  2447. // }
  2448. // }
  2449. // }
  2450. $view_data = ['info' => $info, 'options_list' => json_encode($option_list), 'select_list' => json_encode($select_list)];
  2451. return view('app.recruit.post_select', $view_data);
  2452. }
  2453. /**
  2454. * 放弃择岗
  2455. */
  2456. public function give_up_post(Request $request)
  2457. {
  2458. //以下为测试环境
  2459. // $recruit_id = $request->input('recruit_id');
  2460. // $appoint_id = $request->input('appoint_id');
  2461. // $uid = $request->input('uid');
  2462. // $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
  2463. // if($info){
  2464. // return ['status' => 0, 'msg' => "测试数据重复,请重新点击生成测试数据!"];
  2465. // }
  2466. // RecruitAppointSelect::create(['recruit_id'=>$recruit_id,'appoint_id'=>$appoint_id,'uid'=>$uid,'status'=>-1]);
  2467. // return ['status' => 1, 'msg' => "放弃择岗成功!"];
  2468. //以下为正式环境再放开
  2469. $user = $this->getUser();
  2470. if (!empty($user)) {
  2471. $uid = $user->id;
  2472. } else {
  2473. return redirect(route('login'));
  2474. }
  2475. $recruit_id = $request->input('recruit_id');
  2476. $appoint_id = $request->input('appoint_id');
  2477. $info = RecruitAppointSelect::where('uid', $uid)->where('recruit_id', $recruit_id)->where('appoint_id', $appoint_id)->first();
  2478. if ($info == null) {
  2479. return ['status' => 0, 'msg' => "抱歉,您无需择岗!"];
  2480. }
  2481. if ($info->status != 0) {
  2482. return ['status' => 0, 'msg' => "抱歉,您不是待择岗状态!"];
  2483. }
  2484. $info->status = -1;
  2485. $info->save();
  2486. return ['status' => 1, 'msg' => "放弃择岗成功!"];
  2487. }
  2488. public function comfirm_post(Request $request)
  2489. {
  2490. $user = $this->getUser();
  2491. if (!empty($user)) {
  2492. $uid = $user->id;
  2493. } else {
  2494. return redirect(route('login'));
  2495. }
  2496. $recruit_id = $request->input('recruit_id');
  2497. $appoint_id = $request->input('appoint_id');
  2498. $time = time();
  2499. if ($time > 1727150400 || $time < 1727053200) {
  2500. return ['status' => 0, 'msg' => "抱歉,未到择岗时间!"];
  2501. }
  2502. $info = RecruitAppointSelect::where('uid', $uid)->where('recruit_id', $recruit_id)->where('appoint_id', $appoint_id)->first();
  2503. if ($info->result) {
  2504. return ['status' => 0, 'msg' => "择岗数据已提交!"];
  2505. }
  2506. // $data = [
  2507. // 'recruit_id' => $recruit_id,
  2508. // 'appoint_id' => $recruit_id,
  2509. // 'uid' => $uid,
  2510. // 'status' => 1
  2511. // ];
  2512. $result = [];
  2513. $select = $request->input('select');
  2514. if (is_array($select) && count($select) > 0) {
  2515. foreach ($select as $v) {
  2516. array_push($result, $v['name']);
  2517. }
  2518. }
  2519. $info->result = json_encode($result);
  2520. $info->status = 1;
  2521. $info->save();
  2522. return ['status' => 1, 'msg' => "提交择岗意愿成功,请耐心等待结果!"];
  2523. }
  2524. public function select_result(Request $request)
  2525. {
  2526. $redis = Cache::getRedis();
  2527. $redis->set('recruit_quota_batch5', '');
  2528. return view('app.recruit.select_result');
  2529. }
  2530. public function get_select_result(Request $request)
  2531. {
  2532. $redis = Cache::getRedis();
  2533. $quot_batch5 = $redis->get('recruit_quota_batch5');
  2534. if (!$quot_batch5) {
  2535. $quot_batch5 = [
  2536. [
  2537. 'name' => '陈埭镇',
  2538. 'value' => 21,
  2539. ],
  2540. [
  2541. 'name' => '金井镇',
  2542. 'value' => 3
  2543. ],
  2544. [
  2545. 'name' => '深沪镇',
  2546. 'value' => 2
  2547. ]
  2548. ];
  2549. $redis->set('recruit_quotaA', json_encode($quot_batch5));
  2550. } else {
  2551. $quot_batch5 = json_decode($quot_batch5, true);
  2552. }
  2553. $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=5 and a.result is not null')->select(['b.realname', 'c.ex_number', 'a.result', 'a.select_result', 'a.id', 'a.record', 'a.record2', 'a.record3'])->orderBy('record', 'desc')->orderBy('record2', 'desc')->orderBy('record3', 'desc')->limit(2)->get()->toArray();
  2554. $return_data = [
  2555. 'list' => [],
  2556. ];
  2557. $array_column = array_column($quot_batch5, 'name');
  2558. if (count($list) > 1) {
  2559. $current = $list[0];
  2560. $next = $list[1];
  2561. } else {
  2562. $current = $list[0];
  2563. $next = false;
  2564. }
  2565. $person_select_result = json_decode($current->result, true);
  2566. $flag = 0;//是否择岗成功
  2567. foreach ($person_select_result as $val) {
  2568. //寻找下标
  2569. $index = array_search($val, $array_column);
  2570. if ($quot_batch5[$index]['value']) {
  2571. if ($next && $current->record == $next->record && $current->record2 == $next->record2 && $current->record3 == $next->record3 && $quot_batch5[$index]['value'] == 1) {
  2572. //如果当前处理人员不是最后一个,且分数与下一名人员三个维度完全一样的话并且该人员欲择的岗位仅剩一位,则特殊处理
  2573. //查找同样分数人同样志愿
  2574. $next_select_result = json_decode($next->result, true);
  2575. //寻找下标
  2576. $current_index = array_search($val, $person_select_result);
  2577. $next_index = array_search($val, $next_select_result);
  2578. if ($current_index > $next_index) {
  2579. //如果当前人员对当前镇街的意向排序大于下一人,调换两个指针,先排序下一个人
  2580. $current = $next;
  2581. }
  2582. }
  2583. $quota_data = [
  2584. 'index' => $index,
  2585. 'old_value' => $quot_batch5[$index]['value'],
  2586. ];
  2587. //有名额允许择岗
  2588. DB::table('recruit_appoint_select')->where('id', $current->id)->update(['select_result' => $val, 'status' => 1]);
  2589. $current->select_result = $val;
  2590. $quot_batch5[$index]['value']--;
  2591. $quota_data['new_value'] = $quot_batch5[$index]['value'];
  2592. $redis->set('recruit_quota_batch4', json_encode($quot_batch5));
  2593. $flag = 1;
  2594. break;
  2595. }
  2596. }
  2597. if (!$flag) {
  2598. $quota_data = [
  2599. 'index' => $index,
  2600. 'old_value' => $quot_batch5[$index]['value'],
  2601. ];
  2602. $current->select_result = '未匹配到志愿,本轮择岗不成功!';
  2603. DB::table('recruit_appoint_select')->where('id', $current->id)->update(['select_result' => '未匹配到志愿,本轮择岗不成功!', 'status' => -2]);
  2604. }
  2605. $return_data['quota'] = $quota_data;
  2606. return ['status' => 1, 'msg' => '择岗排序成功', 'data' => $return_data];
  2607. }
  2608. public function select_init(Request $request)
  2609. {
  2610. $count = DB::table('recruit_appoint_select')->whereRaw('select_result is null and batch = 5 and type = 1 and result is not null')->count();
  2611. $redis = Cache::getRedis();
  2612. $quot_batch5 = $redis->get('recruit_quota_batch4');
  2613. if (!$quot_batch5) {
  2614. $quot_batch5 = [
  2615. [
  2616. 'name' => '陈埭镇',
  2617. 'value' => 21,
  2618. ],
  2619. [
  2620. 'name' => '金井镇',
  2621. 'value' => 3
  2622. ],
  2623. [
  2624. 'name' => '深沪镇',
  2625. 'value' => 2
  2626. ]
  2627. ];
  2628. $redis->set('recruit_quota_batch5', json_encode($quot_batch5));
  2629. }
  2630. $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=5 and type = 1')->select(['b.realname', 'c.ex_number', 'a.result', 'a.select_result', 'a.id'])->orderBy('record', 'desc')->get();
  2631. return ['status' => 1, 'msg' => '获取初始化信息成功', 'data' => ['count' => $count, 'quota' => $quot_batch5, 'list' => $list]];
  2632. }
  2633. public function interviewer_random(Request $request)
  2634. {
  2635. $model = $request->input('model', 1);
  2636. $number1 = $request->input('number1', 5);//考官人数
  2637. $number2 = $request->input('number2', 1);//替补人数
  2638. $where[] = ['id', '>', 0];
  2639. switch ($model) {
  2640. case '0':
  2641. $list = DB::table('recruit_interviewer')->get()->toArray();
  2642. shuffle($list);
  2643. $result = array_slice($list, 0, $number1 + $number2);
  2644. break;
  2645. case '1':
  2646. $list = DB::table('recruit_interviewer')->get()->toArray();
  2647. shuffle($list);
  2648. $count = $number1;
  2649. for ($i = 0; $i < $count; $i++) {
  2650. if (!$list[$i]->status) {
  2651. $list[] = $list[$i];
  2652. unset($list[$i]);
  2653. $count++;
  2654. }
  2655. }
  2656. $result = array_slice($list, 0, $number1 + $number2);
  2657. break;
  2658. case '2':
  2659. $list = DB::table('recruit_interviewer')->where('status', 1)->get()->toArray();
  2660. shuffle($list);
  2661. $result = array_slice($list, 0, $number1 + $number2);
  2662. break;
  2663. default:
  2664. $list = DB::table('recruit_interviewer')->get()->toArray();
  2665. shuffle($list);
  2666. for ($i = 0; $i < $number1; $i++) {
  2667. dd($list[$i]);
  2668. if (!$list[$i]->status) {
  2669. $list[] = $list[$i];
  2670. unset($list[$i]);
  2671. }
  2672. }
  2673. $result = array_slice($list, 0, $number1 + $number2);
  2674. break;
  2675. }
  2676. $return_data = [
  2677. 'list' => $result,
  2678. 'number1' => $number1,
  2679. 'number2' => $number2,
  2680. ];
  2681. return view('app.recruit.interviewer', $return_data);
  2682. }
  2683. public function supplement_info(Request $request)
  2684. {
  2685. $user = $this->getUser();
  2686. if (!empty($user)) {
  2687. $uid = $user->id;
  2688. } else {
  2689. return redirect(route('login'));
  2690. }
  2691. //招考id
  2692. $id = $request->input('id', 0);
  2693. if (!$id) {
  2694. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  2695. }
  2696. $recruit = Recruit::find($id);
  2697. if (!$recruit['status']) {
  2698. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2699. }
  2700. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  2701. if (!$appoint_info) {
  2702. return $this->showMessage('抱歉,您没有报名,无需补充信息!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2703. }
  2704. $supplement_info = DB::table("recruit_supplement_cunwu")->where('uid', $uid)->where('appoint_id', $appoint_info->id)->first();
  2705. if ($supplement_info) {
  2706. return $this->showMessage('您已登记信息,无需再次登记!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2707. }
  2708. $uids = [167780,168696,56609,168696,164951,169813,161935,169412,169307,169628,169331,170471,161935,170718,175771,175856,169628,56609,168696,176871,169412,169813,177014,161935,152626,176994,176703,176432,170471,177272,179103,179206,179165,179873,179863,179715,180131,161935,180616,170718,180766,175856,180810,169412,177272,167988,181121,181175,168696,182354,56609,184859,161935,176994,169813,169412,187369,159298,169628,181175,187450,167988,187572,187578,187573,179863,187753,187577,152626,187875,187815,149975,187821,180131,187934,176871,168696,186519,170718,188160,176994,169813,161935,180616,188342,188411,177014,188455,188450,177272,184859,168696,181121,189428,189446,189410,182354,182354,184859,184859,187572,190509,161935,170718,184859,182354,191077,187450,191077,169813,191538,191954,191396,152626,182354,192121,189446,192223,192271,170718,170718,192769,192798,192674,192774,192800,180131,179863,169412,192560,186519,56609,170471,188160,168696,159298,187572,192868,169628,192874,192775,192892,181175,167988,192914,192922,192925,159772,192930,192945,192752,192652,188411,192958,179715,192959,192834,192987,192739,192392,152626,188450,193038,192542,192452,193055,192788,187369,193072,176703,193079,193069,193084,192803,192668,187875,193103,187578,191396,175771,193113,193135,193132,191077,193151,191954,187381,193130,193169,188035,179103,176432,182354,180766,189410,192855,179165,175642,193202,193141,193248,193239,193244,193252,192978,192888,187753,185725,143917,177272,187821,193326,193334,193331,187573,180616,193350,192813,193357,192926,193212,187815,193361,193158,193150,176994,193389,184118,176896,193408,192811,189446,193416,193423,170718,187934,192955,169307,180810,193428,149975,187577,186473,192720,175856,161935,187935,159058,193526,187450,192271,169813,193570,193578,193225,193594,193606,181121,169331,193616,184859,190509,193640,192751,193574,167780,193695,192133,193714,192523,193718,193717,193720,189428,179873,177014,188342,193742,188455,176871,191538,193787,192223,193789,185725,182354,186519,193135];//写死用户
  2709. if (!in_array($uid, $uids)) {
  2710. return $this->showMessage('您无需登记信息!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2711. }
  2712. // $limit_time = 1661961599;
  2713. // $time = time();
  2714. // if( $time > $limit_time){
  2715. // return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2716. // }
  2717. $view_data = [];
  2718. //$view_data['info'] = json_encode($info);
  2719. $view_data['title'] = $recruit->company;
  2720. $view_data['id'] = $id;
  2721. return view('app.recruit.supplement_info', $view_data);
  2722. }
  2723. public function save_supplement_info(Request $request)
  2724. {
  2725. $user = $this->getUser();
  2726. if (!empty($user)) {
  2727. $uid = $user->id;
  2728. } else {
  2729. return redirect(route('login'));
  2730. }
  2731. //招考id
  2732. $id = $request->input('recruit_id', 0);
  2733. if (!$id) {
  2734. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2735. }
  2736. $recruit = Recruit::find($id);
  2737. if (!$recruit['status']) {
  2738. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2739. }
  2740. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  2741. if (!$appoint_info) {
  2742. return ['status' => 0, 'msg' => '抱歉,您没有报名,无需补充信息!', 'data' => ''];
  2743. }
  2744. if ($request->input('marriage') == '已婚') {
  2745. if ($request->input('spouse_card_type') == '' || $request->input('spouse_card') == '' || $request->input('spouse_realname') == '' || $request->input('spouse_mobile') == '') {
  2746. return ['status' => 0, 'msg' => '请完善配偶信息!', 'data' => ''];
  2747. }
  2748. }
  2749. $data = [
  2750. 'uid' => $uid,
  2751. 'appoint_id' => $appoint_info->id,
  2752. 'street' => $request->input('street'),
  2753. 'realname' => $request->input('realname'),
  2754. 'sex' => $request->input('sex'),
  2755. 'house' => $request->input('house'),
  2756. 'nation' => $request->input('nation'),
  2757. 'native' => $request->input('native'),
  2758. 'marriage' => $request->input('marriage'),
  2759. 'spouse_card_type' => $request->input('spouse_card_type'),
  2760. 'spouse_card' => $request->input('spouse_card'),
  2761. 'spouse_realname' => $request->input('spouse_realname'),
  2762. 'spouse_mobile' => $request->input('spouse_mobile'),
  2763. 'political' => $request->input('political'),
  2764. 'bank_card' => $request->input('bank_card'),
  2765. 'bank_open' => $request->input('bank_open'),
  2766. 'card' => $request->input('card'),
  2767. 'card_endtime' => $request->input('card_endtime'),
  2768. 'mobile' => $request->input('mobile'),
  2769. 'edu' => $request->input('education'),
  2770. 'pro' => $request->input('pro'),
  2771. 'address' => $request->input('address'),
  2772. 'funds' => $request->input('funds'),
  2773. ];
  2774. DB::table('recruit_supplement_cunwu')->insert($data);
  2775. return ['status' => 1, 'msg' => '提交成功!', 'data' => ''];
  2776. }
  2777. public function comfirm_pen(Request $request)
  2778. {
  2779. $user = $this->getUser();
  2780. if (!empty($user)) {
  2781. $uid = $user->id;
  2782. } else {
  2783. return redirect(route('login'));
  2784. }
  2785. //招考id
  2786. $id = $request->input('recruit_id', 0);
  2787. if (!$id) {
  2788. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2789. }
  2790. $recruit = Recruit::find($id);
  2791. if (!$recruit['status']) {
  2792. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2793. }
  2794. if (!$recruit->pen_comfirm) {
  2795. return ['status' => 0, 'msg' => '该项目无须确认笔试考试!', 'data' => ''];
  2796. }
  2797. $appoint_info = RecruitAppointInfo::where('recruit_id', $id)->where('uid', $uid)->first();
  2798. if (!$appoint_info) {
  2799. return ['status' => 0, 'msg' => '找不到您的报名记录,请检查!', 'data' => ''];
  2800. }
  2801. if ($appoint_info->audit != 3) {
  2802. return ['status' => 0, 'msg' => '您的报名未审核通过,无需确认!', 'data' => ''];
  2803. }
  2804. $time = time();
  2805. if (strtotime($recruit->pen_comfirm_start) > $time || strtotime($recruit->pen_comfirm_end) < $time) {
  2806. return ['status' => 0, 'msg' => '未在笔试确认时间段!', 'data' => ''];
  2807. }
  2808. if ($appoint_info->pen_audit != -2) {
  2809. return ['status' => 0, 'msg' => '您已确认参加笔试,无需再次确认!', 'data' => ''];
  2810. }
  2811. $appoint_info->update(['pen_audit' => -1]);
  2812. $log = [
  2813. 'type' => 3,
  2814. 'appoint_id' => $appoint_info->id,
  2815. 'uid' => $uid,
  2816. 'log' => '用户确认参加笔试',
  2817. ];
  2818. RecruitAppointLog::create($log);
  2819. return ['status' => 1, 'msg' => '确认成功', 'data' => $appoint_info->id];
  2820. }
  2821. public function comfirm_face(Request $request)
  2822. {
  2823. $user = $this->getUser();
  2824. if (!empty($user)) {
  2825. $uid = $user->id;
  2826. } else {
  2827. return redirect(route('login'));
  2828. }
  2829. //招考id
  2830. $id = $request->input('recruit_id', 0);
  2831. if (!$id) {
  2832. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2833. }
  2834. $recruit = Recruit::find($id);
  2835. if (!$recruit['status']) {
  2836. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2837. }
  2838. if (!$recruit->face_comfirm) {
  2839. return ['status' => 0, 'msg' => '该项目无须确认面试考试!', 'data' => ''];
  2840. }
  2841. $appoint_info = RecruitAppointInfo::where('recruit_id', $id)->where('uid', $uid)->first();
  2842. if (!$appoint_info) {
  2843. return ['status' => 0, 'msg' => '找不到您的报名记录,请检查!', 'data' => ''];
  2844. }
  2845. if ($appoint_info->audit != 3) {
  2846. return ['status' => 0, 'msg' => '您的报名未审核通过,无需确认!', 'data' => ''];
  2847. }
  2848. $time = time();
  2849. if (strtotime($recruit->face_comfirm_start) > $time || strtotime($recruit->face_comfirm_end) < $time) {
  2850. return ['status' => 0, 'msg' => '未在笔试确认时间段!', 'data' => ''];
  2851. }
  2852. if ($appoint_info->face_audit != -2) {
  2853. return ['status' => 0, 'msg' => '您已确认参加面试,无需再次确认!', 'data' => ''];
  2854. }
  2855. $appoint_info->update(['face_audit' => -1]);
  2856. $log = [
  2857. 'type' => 3,
  2858. 'appoint_id' => $appoint_info->id,
  2859. 'uid' => $uid,
  2860. 'log' => '用户确认参加面试',
  2861. ];
  2862. RecruitAppointLog::create($log);
  2863. return ['status' => 1, 'msg' => '确认成功', 'data' => $appoint_info->id];
  2864. }
  2865. public function supplementary_entry(Request $request)
  2866. {
  2867. $user = $this->getUser();
  2868. if (!empty($user)) {
  2869. $uid = $user->id;
  2870. } else {
  2871. return redirect(route('login'));
  2872. }
  2873. //招考id
  2874. $id = $request->input('recruit_id', 0);
  2875. if (!$id) {
  2876. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2877. }
  2878. $recruit = Recruit::find($id);
  2879. if (!$recruit['status']) {
  2880. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2881. }
  2882. $appoint_info = RecruitAppointInfo::where('recruit_id', $id)->where('uid', $uid)->first();
  2883. if (!$appoint_info) {
  2884. return ['status' => 0, 'msg' => '找不到您的报名记录,请检查!', 'data' => ''];
  2885. }
  2886. $time = time();
  2887. if ($time > 1680969600) {
  2888. return ['status' => 0, 'msg' => '已停止补充报名!', 'data' => ''];
  2889. }
  2890. if ($appoint_info->adjust_limit) {
  2891. $appoint_info->update(['adjust' => 1]);
  2892. return ['status' => 1, 'msg' => '补充报名成功!', 'data' => ''];
  2893. } else {
  2894. return ['status' => 0, 'msg' => '您无需补充报名!', 'data' => ''];
  2895. }
  2896. }
  2897. public function show_sign_limit(Request $request){
  2898. $user = $this->getUser();
  2899. if (!empty($user)) {
  2900. $uid = $user->id;
  2901. } else {
  2902. return redirect(route('login'));
  2903. }
  2904. //招考id
  2905. $id = $request->input('recruit_id', 0);
  2906. if (!$id) {
  2907. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2908. }
  2909. $recruit = Recruit::find($id);
  2910. if (!$recruit['status']) {
  2911. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2912. }
  2913. $list = RecruitAppointInfo::where('uid', $user->id)
  2914. ->join('recruit', 'recruit.id', '=', 'recruit_appoint_info.recruit_id', 'left')
  2915. ->join('recruit_post', 'recruit_post.id', '=', 'recruit_appoint_info.post_id', 'left')
  2916. ->select('recruit.name as recruit_name', 'recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name')
  2917. ->where('recruit_appoint_info.recruit_id','=',$id)
  2918. ->get();
  2919. $html = view('app.recruit.show_sign_limit')->with(['list' => $list , 'total' => count($list)])->render();
  2920. return response()->json(['code' => 1, 'data' => $html]);
  2921. }
  2922. }