IndexController.php 145 KB

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