IndexController.php 139 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024
  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::where('status',1)->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. return view('app.recruit.recruit_ticket', [
  1601. 'title' => "{$filename}.docx",
  1602. 'url' => "/storage/recruit/ticket/word/{$date}/{$name}/pen/{$filename}.docx",
  1603. ]);
  1604. $file = base_path() . "/storage/recruit/ticket/pdf/{$date}/{$name}/pen/" . $filename . '.pdf';
  1605. if (file_exists($file)) {
  1606. header('Content-Description: File Transfer');
  1607. header('Content-Type: application/octet-stream');
  1608. header('Content-Disposition: attachment; filename=' . basename($file));
  1609. header('Content-Transfer-Encoding: binary');
  1610. header('Expires: 0');
  1611. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1612. header('Pragma: public');
  1613. header('Content-Length: ' . filesize($file));
  1614. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1615. flush();
  1616. readfile($file);
  1617. } else {
  1618. return $this->showMessage('准考证不存在,请联系管理员!', route('home'), true, '上一页', '3');
  1619. }
  1620. } else {
  1621. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1622. }
  1623. } else {
  1624. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1625. }
  1626. } else {
  1627. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1628. }
  1629. }
  1630. /**
  1631. * 审核准考证
  1632. * @param Request $request
  1633. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1634. */
  1635. public function check_ticket(Request $request)
  1636. {
  1637. $user = $this->getUser();
  1638. if (!empty($user)) {
  1639. $uid = $user->id;
  1640. } else {
  1641. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1642. }
  1643. $recruit_id = $request->input('recruit_id');
  1644. $recruit = Recruit::where('id', $recruit_id)->first();
  1645. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  1646. if ($appoint_info) {
  1647. $check_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 2)->first();
  1648. if ($check_ticket) {
  1649. $health = RecruitSupplement::where('appoint_id', $appoint_info->id)->first();
  1650. if ((!$health || $health->h_status == 0) && $recruit->pen_epidemic) {
  1651. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1652. }
  1653. $time = time();
  1654. if (strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time) {
  1655. RecruitTicket::where('id', $check_ticket->id)->update(['ex_status' => 1]);
  1656. $recruit = Recruit::where('id', $recruit_id)->first();
  1657. $post_data = RecruitPost::where('recruit_id', $recruit_id)->where('status', 1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1658. $name = $recruit->name_en;
  1659. $date = date("Y-m-d", strtotime($recruit->created_at));
  1660. //$filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1661. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1662. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/computer/" . $filename . '.pdf';
  1663. if (file_exists($file)) {
  1664. header('Content-Description: File Transfer');
  1665. header('Content-Type: application/octet-stream');
  1666. header('Content-Disposition: attachment; filename=' . basename($file));
  1667. header('Content-Transfer-Encoding: binary');
  1668. header('Expires: 0');
  1669. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1670. header('Pragma: public');
  1671. header('Content-Length: ' . filesize($file));
  1672. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1673. flush();
  1674. readfile($file);
  1675. }
  1676. } else {
  1677. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1678. }
  1679. } else {
  1680. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1681. }
  1682. } else {
  1683. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1684. }
  1685. }
  1686. /**
  1687. * 面试准考证
  1688. * @param Request $request
  1689. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1690. */
  1691. public function face_ticket(Request $request)
  1692. {
  1693. $user = $this->getUser();
  1694. if (!empty($user)) {
  1695. $uid = $user->id;
  1696. } else {
  1697. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1698. }
  1699. $recruit_id = $request->input('recruit_id');
  1700. $recruit = Recruit::where('id', $recruit_id)->first();
  1701. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  1702. if ($appoint_info) {
  1703. $face_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 3)->first();
  1704. if ($face_ticket) {
  1705. $health = RecruitSupplement::where('appoint_id', $appoint_info->id)->first();
  1706. if ((!$health || $health->h_status == 0) && $recruit->pen_epidemic) {
  1707. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1708. }
  1709. $time = time();
  1710. if (strtotime($face_ticket->ex_start) < $time && strtotime($face_ticket->ex_end) > $time) {
  1711. RecruitTicket::where('id', $face_ticket->id)->update(['ex_status' => 1]);
  1712. $recruit = Recruit::where('id', $recruit_id)->first();
  1713. $post_data = RecruitPost::where('recruit_id', $recruit_id)->where('status', 1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1714. $name = $recruit->name_en;
  1715. $date = date("Y-m-d", strtotime($recruit->created_at));
  1716. //$filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1717. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1718. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';
  1719. if (file_exists($file)) {
  1720. header('Content-Description: File Transfer');
  1721. header('Content-Type: application/octet-stream');
  1722. header('Content-Disposition: attachment; filename=' . basename($file));
  1723. header('Content-Transfer-Encoding: binary');
  1724. header('Expires: 0');
  1725. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1726. header('Pragma: public');
  1727. header('Content-Length: ' . filesize($file));
  1728. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1729. flush();
  1730. readfile($file);
  1731. }
  1732. } else {
  1733. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1734. }
  1735. } else {
  1736. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1737. }
  1738. } else {
  1739. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1740. }
  1741. }
  1742. /**
  1743. * 复试准考证
  1744. * @param Request $request
  1745. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1746. */
  1747. public function reexamine_ticket(Request $request)
  1748. {
  1749. $user = $this->getUser();
  1750. if (!empty($user)) {
  1751. $uid = $user->id;
  1752. } else {
  1753. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1754. }
  1755. $recruit_id = $request->input('recruit_id');
  1756. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  1757. if ($appoint_info) {
  1758. $reexamine_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 4)->first();
  1759. if ($reexamine_ticket) {
  1760. $time = time();
  1761. if (strtotime($reexamine_ticket->ex_start) < $time && strtotime($reexamine_ticket->ex_end) > $time) {
  1762. RecruitTicket::where('id', $reexamine_ticket->id)->update(['ex_status' => 1]);
  1763. $recruit = Recruit::where('id', $recruit_id)->first();
  1764. $post_data = RecruitPost::where('recruit_id', $recruit_id)->where('status', 1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1765. $name = $recruit->name_en;
  1766. $date = date("Y-m-d", strtotime($recruit->created_at));
  1767. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1768. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/reexamine/" . $filename . '.pdf';
  1769. if (file_exists($file)) {
  1770. header('Content-Description: File Transfer');
  1771. header('Content-Type: application/octet-stream');
  1772. header('Content-Disposition: attachment; filename=' . basename($file));
  1773. header('Content-Transfer-Encoding: binary');
  1774. header('Expires: 0');
  1775. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1776. header('Pragma: public');
  1777. header('Content-Length: ' . filesize($file));
  1778. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1779. flush();
  1780. readfile($file);
  1781. }
  1782. } else {
  1783. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1784. }
  1785. } else {
  1786. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1787. }
  1788. } else {
  1789. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1790. }
  1791. }
  1792. /**
  1793. * 材料补登
  1794. * @param Request $request
  1795. */
  1796. public function material_supplement(Request $request)
  1797. {
  1798. $user = $this->getUser();
  1799. if (!empty($user)) {
  1800. $uid = $user->id;
  1801. } else {
  1802. return redirect(route('login'));
  1803. }
  1804. //招考id
  1805. $id = $request->input('id', 0);
  1806. if (!$id) {
  1807. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1808. }
  1809. $recruit = Recruit::find($id);
  1810. if (!$recruit['status'] && !$user->recruit_test) {
  1811. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1812. }
  1813. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  1814. if (!$appoint_info) {
  1815. return $this->showMessage('抱歉,您没有报名,无需考察审核!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1816. }
  1817. if ($appoint_info->pen_audit != 1) {
  1818. return $this->showMessage('抱歉,您未入闱,无需考察审核!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1819. }
  1820. $limit_time = 1726824600;
  1821. $time = time();
  1822. if ($time > $limit_time) {
  1823. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1824. }
  1825. $info = RecruitSupplement::where('appoint_id', $appoint_info->id)->where('type', 'supplement')->first();
  1826. if (!$info) {
  1827. $info = [
  1828. 'appoint_id' => $appoint_info->id,
  1829. 'identification' => '',
  1830. //'household_register' => '',
  1831. //'education_certification' => '',
  1832. //'family_planning' => '',
  1833. 'chengxin' => '',
  1834. 'manage' => '',
  1835. 'status' => 3,
  1836. ];
  1837. } else {
  1838. $info = $info->toArray();
  1839. if (json_decode($info['identification'])) {
  1840. $identification = json_decode($info['identification'], true);
  1841. foreach ($identification as $k => $v) {
  1842. if (array_key_exists('response', $v)) {
  1843. $identification[$k]['url'] = $v['response']['path'];
  1844. }
  1845. }
  1846. } else {
  1847. $identification = [];
  1848. }
  1849. $info['identification'] = $identification;
  1850. if (json_decode($info['household_register'])) {
  1851. $household_register = json_decode($info['household_register'], true);
  1852. foreach ($household_register as $k => $v) {
  1853. if (array_key_exists('response', $v)) {
  1854. $household_register[$k]['url'] = $v['response']['path'];
  1855. }
  1856. }
  1857. } else {
  1858. $household_register = [];
  1859. }
  1860. $info['household_register'] = $household_register;
  1861. if (json_decode($info['education_certification'])) {
  1862. $education_certification = json_decode($info['education_certification'], true);
  1863. foreach ($education_certification as $k => $v) {
  1864. if (array_key_exists('response', $v)) {
  1865. $education_certification[$k]['url'] = $v['response']['path'];
  1866. }
  1867. }
  1868. } else {
  1869. $education_certification = [];
  1870. }
  1871. $info['education_certification'] = $education_certification;
  1872. if (json_decode($info['family_planning'])) {
  1873. $family_planning = json_decode($info['family_planning'], true);
  1874. foreach ($family_planning as $k => $v) {
  1875. if (array_key_exists('response', $v)) {
  1876. $family_planning[$k]['url'] = $v['response']['path'];
  1877. }
  1878. }
  1879. } else {
  1880. $family_planning = [];
  1881. }
  1882. $info['family_planning'] = $family_planning;
  1883. if (json_decode($info['chengxin'])) {
  1884. $chengxin = json_decode($info['chengxin'], true);
  1885. foreach ($chengxin as $k => $v) {
  1886. if (array_key_exists('response', $v)) {
  1887. $chengxin[$k]['url'] = $v['response']['path'];
  1888. }
  1889. }
  1890. } else {
  1891. $chengxin = [];
  1892. }
  1893. $info['chengxin'] = $chengxin;
  1894. if (json_decode($info['manage'])) {
  1895. $manage = json_decode($info['manage'], true);
  1896. foreach ($manage as $k => $v) {
  1897. if (array_key_exists('response', $v)) {
  1898. $manage[$k]['url'] = $v['response']['path'];
  1899. }
  1900. }
  1901. } else {
  1902. $manage = [];
  1903. }
  1904. $info['manage'] = $manage;
  1905. }
  1906. $view_data['info'] = json_encode($info);
  1907. $view_data['title'] = $recruit->company;
  1908. return view('app.recruit.supplement', $view_data);
  1909. }
  1910. /**
  1911. * 健康信息登记
  1912. * @param Request $request
  1913. */
  1914. public function health_info(Request $request)
  1915. {
  1916. $user = $this->getUser();
  1917. if (!empty($user)) {
  1918. $uid = $user->id;
  1919. } else {
  1920. return redirect(route('login'));
  1921. }
  1922. //招考id
  1923. $id = $request->input('id', 0);
  1924. if (!$id) {
  1925. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1926. }
  1927. $recruit = Recruit::find($id);
  1928. if (!$recruit['status'] && !$user->recruit_test) {
  1929. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1930. }
  1931. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  1932. if (!$appoint_info) {
  1933. return $this->showMessage('抱歉,您没有报名,无需登记!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1934. }
  1935. if ($appoint_info->audit != 3) {
  1936. return $this->showMessage('抱歉,您无需登记!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1937. }
  1938. $time = time();
  1939. $type = $request->input('type', null);
  1940. $where = [];
  1941. if ($type) {
  1942. switch ($type) {
  1943. case 'pen':
  1944. $start = strtotime($recruit->pen_health_start);
  1945. $end = strtotime($recruit->pen_health_end);
  1946. break;
  1947. case 'computer':
  1948. $start = strtotime($recruit->computer_health_start);
  1949. $end = strtotime($recruit->computer_health_end);
  1950. break;
  1951. case 'face':
  1952. $start = strtotime($recruit->face_health_start);
  1953. $end = strtotime($recruit->face_health_end);
  1954. break;
  1955. case 'reexamine':
  1956. $start = strtotime($recruit->reexamine_health_start);
  1957. $end = strtotime($recruit->reexamine_health_end);
  1958. break;
  1959. default:
  1960. $start = strtotime($recruit->supplement_start);
  1961. $end = strtotime($recruit->supplement_end);
  1962. break;
  1963. }
  1964. $where[] = ['type', '=', $type];
  1965. } else {
  1966. $start = strtotime($recruit->supplement_start);
  1967. $end = strtotime($recruit->supplement_end);
  1968. }
  1969. if ($time > $end || $time < $start) {
  1970. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1971. }
  1972. $where[] = ['appoint_id', '=', $appoint_info->id];
  1973. $info = RecruitSupplement::where($where)->first();
  1974. if (!$info) {
  1975. $info = [
  1976. 'appoint_id' => $appoint_info->id,
  1977. 'health_code' => '',
  1978. 'trip_code' => '',
  1979. 'type' => $type,
  1980. ];
  1981. } else {
  1982. $info = $info->toArray();
  1983. if (json_decode($info['health_code'])) {
  1984. $health_code = json_decode($info['health_code'], true);
  1985. foreach ($health_code as $k => $v) {
  1986. if (array_key_exists('response', $v)) {
  1987. $health_code[$k]['url'] = $v['response']['path'];
  1988. }
  1989. }
  1990. } else {
  1991. $health_code = [];
  1992. }
  1993. $info['health_code'] = $health_code;
  1994. if (json_decode($info['trip_code'])) {
  1995. $trip_code = json_decode($info['trip_code'], true);
  1996. foreach ($trip_code as $k => $v) {
  1997. if (array_key_exists('response', $v)) {
  1998. $trip_code[$k]['url'] = $v['response']['path'];
  1999. }
  2000. }
  2001. } else {
  2002. $trip_code = [];
  2003. }
  2004. $info['trip_code'] = $trip_code;
  2005. }
  2006. $view_data['info'] = json_encode($info);
  2007. $view_data['title'] = $recruit->company;
  2008. return view('app.recruit.health', $view_data);
  2009. }
  2010. public function save_supplement(Request $request)
  2011. {
  2012. $user = $this->getUser();
  2013. if (!empty($user)) {
  2014. $uid = $user->id;
  2015. } else {
  2016. return redirect(route('login'));
  2017. }
  2018. $limit_time = 1726824600;
  2019. $time = time();
  2020. if ($time > $limit_time) {
  2021. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show', ['id', 38]), true, '上一页', '3');
  2022. }
  2023. $appoint_id = $request->input('appoint_id');
  2024. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', 68)->where('id', $appoint_id)->first();
  2025. if (!$appoint_info) {
  2026. return ['status' => 0, 'msg' => '抱歉,找不到您要补登的报名记录!'];
  2027. }
  2028. $info = RecruitSupplement::where('appoint_id', $appoint_id)->where('type', 'supplement')->first();
  2029. if ($info) {
  2030. if ($info->status == 1) {
  2031. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  2032. }
  2033. if ($info->status == 0) {
  2034. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  2035. }
  2036. //身份证明
  2037. $identification = $request->input('identification');
  2038. if (is_array($identification)) {
  2039. //删除掉没有成功返回路径的图片
  2040. foreach ($identification as $k => $v) {
  2041. if (!array_key_exists('response', $v)) {
  2042. unset($identification[$k]);
  2043. }
  2044. }
  2045. }
  2046. $info->identification = json_encode($identification);
  2047. //户口簿
  2048. $household_register = $request->input('household_register');
  2049. if (is_array($household_register)) {
  2050. //删除掉没有成功返回路径的图片
  2051. foreach ($household_register as $k => $v) {
  2052. if (!array_key_exists('response', $v)) {
  2053. unset($household_register[$k]);
  2054. }
  2055. }
  2056. }
  2057. $info->household_register = json_encode($household_register);
  2058. //学信网
  2059. $education_certification = $request->input('education_certification');
  2060. if (is_array($education_certification)) {
  2061. //删除掉没有成功返回路径的图片
  2062. foreach ($education_certification as $k => $v) {
  2063. if (!array_key_exists('response', $v)) {
  2064. unset($education_certification[$k]);
  2065. }
  2066. }
  2067. }
  2068. $info->education_certification = json_encode($education_certification);
  2069. //计生
  2070. // $family_planning = $request->input('family_planning');
  2071. // if(is_array($family_planning)){
  2072. // //删除掉没有成功返回路径的图片
  2073. // foreach ($family_planning as $k => $v){
  2074. // if(!array_key_exists('response',$v)){
  2075. // unset($family_planning[$k]);
  2076. // }
  2077. // }
  2078. // }
  2079. // $info->family_planning = json_encode($family_planning);
  2080. //失信查询 情况
  2081. $chengxin = $request->input('chengxin');
  2082. if (is_array($chengxin)) {
  2083. //删除掉没有成功返回路径的图片
  2084. foreach ($chengxin as $k => $v) {
  2085. if (!array_key_exists('response', $v)) {
  2086. unset($chengxin[$k]);
  2087. }
  2088. }
  2089. }
  2090. $info->chengxin = json_encode($chengxin);
  2091. //综治
  2092. $manage = $request->input('manage');
  2093. if (is_array($manage)) {
  2094. //删除掉没有成功返回路径的图片
  2095. foreach ($manage as $k => $v) {
  2096. if (!array_key_exists('response', $v)) {
  2097. unset($manage[$k]);
  2098. }
  2099. }
  2100. }
  2101. $info->manage = json_encode($manage);
  2102. $info->status = 0;
  2103. $info->save();
  2104. $appoint_info->political_audit = 4;
  2105. $appoint_info->save();
  2106. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  2107. } else {
  2108. $data['appoint_id'] = $appoint_id;
  2109. //身份证明
  2110. $identification = $request->input('identification');
  2111. if (is_array($identification)) {
  2112. //删除掉没有成功返回路径的图片
  2113. foreach ($identification as $k => $v) {
  2114. if (!array_key_exists('response', $v)) {
  2115. unset($identification[$k]);
  2116. }
  2117. }
  2118. }
  2119. $data['identification'] = json_encode($identification);
  2120. //户口簿
  2121. $household_register = $request->input('household_register');
  2122. if (is_array($household_register)) {
  2123. //删除掉没有成功返回路径的图片
  2124. foreach ($household_register as $k => $v) {
  2125. if (!array_key_exists('response', $v)) {
  2126. unset($household_register[$k]);
  2127. }
  2128. }
  2129. }
  2130. $data['household_register'] = json_encode($household_register);
  2131. //学信网
  2132. $education_certification = $request->input('education_certification');
  2133. if (is_array($education_certification)) {
  2134. //删除掉没有成功返回路径的图片
  2135. foreach ($education_certification as $k => $v) {
  2136. if (!array_key_exists('response', $v)) {
  2137. unset($education_certification[$k]);
  2138. }
  2139. }
  2140. }
  2141. $data['education_certification'] = json_encode($education_certification);
  2142. //计生
  2143. // $family_planning = $request->input('family_planning');
  2144. // if(is_array($family_planning)){sp
  2145. // //删除掉没有成功返回路径的图片
  2146. // foreach ($family_planning as $k => $v){
  2147. // if(!array_key_exists('response',$v)){
  2148. // unset($family_planning[$k]);
  2149. // }
  2150. // }
  2151. // }
  2152. // $data['family_planning'] = json_encode($family_planning);
  2153. //失信查询 情况
  2154. $chengxin = $request->input('chengxin');
  2155. if (is_array($chengxin)) {
  2156. //删除掉没有成功返回路径的图片
  2157. foreach ($chengxin as $k => $v) {
  2158. if (!array_key_exists('response', $v)) {
  2159. unset($chengxin[$k]);
  2160. }
  2161. }
  2162. }
  2163. $data['chengxin'] = json_encode($chengxin);
  2164. //综治
  2165. $manage = $request->input('manage');
  2166. if (is_array($manage)) {
  2167. //删除掉没有成功返回路径的图片
  2168. foreach ($manage as $k => $v) {
  2169. if (!array_key_exists('response', $v)) {
  2170. unset($manage[$k]);
  2171. }
  2172. }
  2173. }
  2174. $data['manage'] = json_encode($manage);
  2175. $data['status'] = 0;
  2176. $data['type'] = 'supplement';
  2177. $result = RecruitSupplement::create($data);
  2178. $appoint_info->political_audit = 4;
  2179. $appoint_info->save();
  2180. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  2181. }
  2182. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  2183. }
  2184. public function save_healthinfo(Request $request)
  2185. {
  2186. $user = $this->getUser();
  2187. if (!empty($user)) {
  2188. $uid = $user->id;
  2189. } else {
  2190. return redirect(route('login'));
  2191. }
  2192. $appoint_id = $request->input('appoint_id');
  2193. $type = $request->input('type');
  2194. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('id', $appoint_id)->first();
  2195. if (!$appoint_info) {
  2196. return ['status' => 0, 'msg' => '抱歉,找不到您要登记的报名记录!'];
  2197. }
  2198. $recruit = Recruit::where('id', $appoint_info->recruit_id)->first();
  2199. $info = RecruitSupplement::where('appoint_id', $appoint_id)->where('type', $type)->first();
  2200. if ($info) {
  2201. if ($info->h_status == 1) {
  2202. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  2203. }
  2204. if ($info->h_status == 0) {
  2205. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  2206. }
  2207. $health_code = $request->input('health_code');
  2208. if (is_array($health_code)) {
  2209. //删除掉没有成功返回路径的图片
  2210. foreach ($health_code as $k => $v) {
  2211. if (!array_key_exists('response', $v)) {
  2212. unset($health_code[$k]);
  2213. }
  2214. }
  2215. }
  2216. $info->health_code = json_encode($health_code);
  2217. $trip_code = $request->input('trip_code');
  2218. if (is_array($trip_code)) {
  2219. //删除掉没有成功返回路径的图片
  2220. foreach ($trip_code as $k => $v) {
  2221. if (!array_key_exists('response', $v)) {
  2222. unset($trip_code[$k]);
  2223. }
  2224. }
  2225. }
  2226. $info->trip_code = json_encode($trip_code);
  2227. $info->h_status = 0;
  2228. $appoint_info->health_audit = 4;
  2229. $appoint_info->save();
  2230. $info->save();
  2231. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  2232. } else {
  2233. $data['appoint_id'] = $appoint_id;
  2234. $data['type'] = $type;
  2235. $data['h_status'] = 0;
  2236. $appoint_info->health_audit = 4;
  2237. $health_code = $request->input('health_code');
  2238. if (is_array($health_code)) {
  2239. //删除掉没有成功返回路径的图片
  2240. foreach ($health_code as $k => $v) {
  2241. if (!array_key_exists('response', $v)) {
  2242. unset($health_code[$k]);
  2243. }
  2244. }
  2245. }
  2246. $health_result = $this->baiduService->health_code(file_get_contents(base_path() . "/public" . $health_code[0]['response']['path']));
  2247. $health_msg = ['健康码自动审核通过'];
  2248. //$h_status = 1;
  2249. //$appoint_info->health_audit = 1;
  2250. if (!array_key_exists('error_msg', $health_result) && !array_key_exists('error_code', $health_result)) {
  2251. if (array_key_exists('姓名', $health_result)) {
  2252. if (stripos($health_result['姓名'][0]['word'], '*') > 0) {
  2253. return ['status' => 0, 'msg' => '请打开健康码的“眼睛开关”,显示完整个人信息'];
  2254. }
  2255. if ($health_result['姓名'][0]['word'] != $appoint_info->realname) {
  2256. array_push($health_msg, '抱歉,请上传您本人的健康码!');
  2257. }
  2258. } else {
  2259. array_push($health_msg, '健康码错误,识别不到姓名!');
  2260. }
  2261. if (array_key_exists('状态', $health_result)) {
  2262. if ($health_result['状态'][0]['word'] != '绿码') {
  2263. array_push($health_msg, '抱歉,您的健康码非绿码!');
  2264. }
  2265. } else {
  2266. array_push($health_msg, '健康码错误,识别不到状态!');
  2267. }
  2268. if (array_key_exists('更新时间', $health_result)) {
  2269. $time = strtotime($health_result['更新时间'][0]['word']);
  2270. if ($time < strtotime($recruit->pen_health_start) || $time > strtotime($recruit->pen_health_end)) {
  2271. array_push($health_msg, '抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的健康码!');
  2272. }
  2273. } else {
  2274. array_push($health_msg, '健康码错误,识别不到时间!');
  2275. }
  2276. //$data['h_status'] = $h_status;
  2277. $data['h_msg'] = implode(';', $health_msg);
  2278. //$appoint_info->health_audit = $h_status == 1 ? 1 : 4;
  2279. $data['health_code'] = json_encode($health_code);
  2280. }
  2281. $data['health_result'] = json_encode($health_result);
  2282. $trip_code = $request->input('trip_code');
  2283. if (is_array($trip_code)) {
  2284. //删除掉没有成功返回路径的图片
  2285. foreach ($trip_code as $k => $v) {
  2286. if (!array_key_exists('response', $v)) {
  2287. unset($trip_code[$k]);
  2288. }
  2289. }
  2290. }
  2291. $trip_result = $this->baiduService->trip_code(file_get_contents(base_path() . "/public" . $trip_code[0]['response']['path']));
  2292. $trip_msg = [];
  2293. $trip_status = 0;
  2294. if (!array_key_exists('error_msg', $trip_result) && !array_key_exists('error_code', $trip_result)) {
  2295. if (array_key_exists('途经地', $trip_result['result'])) {
  2296. $fangyi_area = explode("\r\n", config('aix.fangyi.fangyi_zhaokao.fangyi_zhaokao.risk_area'));
  2297. $result = array_intersect($fangyi_area, $trip_result['result']['途经地'][0]['word']);
  2298. if (count($result) > 0) {
  2299. array_push($trip_msg, '抱歉,您的行程中包含系统设置中高风险地区!');
  2300. $trip_status = 0;
  2301. }
  2302. }
  2303. if (array_key_exists('风险性', $trip_result['result']) && $trip_result['result']['风险性']) {
  2304. array_push($trip_msg, '抱歉,您的行程可能含有风险!');
  2305. $trip_status = 0;
  2306. }
  2307. if (array_key_exists('更新时间', $trip_result['result'])) {
  2308. $time = strtotime($trip_result['result']['更新时间'][0]['word'][0]);
  2309. if ($time > strtotime($recruit->pen_health_start) || $recruit < ($recruit->pen_health_end)) {
  2310. array_push($trip_msg, '抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的行程码!');
  2311. $trip_status = 0;
  2312. }
  2313. }
  2314. $data['h_msg'] .= implode(';', $trip_msg);
  2315. }
  2316. $data['trip_result'] = json_encode($trip_result);
  2317. $data['trip_code'] = json_encode($trip_code);
  2318. $data['h_status'] = 0;
  2319. $appoint_info->health_audit = 4;
  2320. RecruitSupplement::create($data);
  2321. $appoint_info->save();
  2322. return ['status' => 1, 'msg' => '提交成功,请刷新查看审核结果', 'data' => ''];
  2323. }
  2324. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  2325. }
  2326. public function post_select(Request $request)
  2327. {
  2328. $user = $this->getUser();
  2329. if (!empty($user)) {
  2330. $uid = $user->id;
  2331. } else {
  2332. return redirect(route('login'));
  2333. }
  2334. $recruit_id = $request->input('recruit_id');
  2335. //$appoint_id = $request->input('appoint_id');
  2336. $info = RecruitAppointSelect::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  2337. if (!$info) {
  2338. return $this->showMessage('抱歉,您无需择岗!', route('recruit.show', ['id', $recruit_id]), true, '上一页', '2');
  2339. }
  2340. //手动设置择岗时间段
  2341. $time = time();
  2342. if ($time > 1727150400 || $time < 1727053200) {
  2343. //if($time > 1694491200){
  2344. return $this->showMessage('抱歉,未到择岗时间!', route('recruit.show', ['id', $recruit_id]), true, '上一页', '2');
  2345. }
  2346. $option_list = [
  2347. [
  2348. 'id' => 1,
  2349. 'name' => '陈埭镇',
  2350. ],
  2351. [
  2352. 'id' => 2,
  2353. 'name' => '金井镇',
  2354. ],
  2355. [
  2356. 'id' => 3,
  2357. 'name' => '深沪镇'
  2358. ]
  2359. ];
  2360. $select_list = [];
  2361. if ($info->result) {
  2362. $result = json_decode($info->result, true);
  2363. foreach ($result as $v) {
  2364. $item['name'] = $v;
  2365. array_push($select_list, $item);
  2366. }
  2367. }
  2368. // $recruit_id = $request->input('recruit_id');
  2369. // $appoint_id = $request->input('appoint_id');
  2370. // $uid = $request->input('uid');
  2371. // $info = RecruitAppointSelect::where('uid',$uid)->first();
  2372. // if(!$info){
  2373. // $info = new \stdClass();
  2374. // $info->status = 0;
  2375. // $info->recruit_id = 8;
  2376. // $info->appoint_id = rand(0,999999);
  2377. // $info->uid = rand(0,999999);
  2378. // }else{
  2379. // $result = json_decode($info->result,true);
  2380. // foreach ($option_list as $k => $v){
  2381. // if(in_array($v['name'],$result)){
  2382. // $select_list[$k] = $v;
  2383. // unset($option_list[$k]);
  2384. // }
  2385. // }
  2386. // }
  2387. $view_data = ['info' => $info, 'options_list' => json_encode($option_list), 'select_list' => json_encode($select_list)];
  2388. return view('app.recruit.post_select', $view_data);
  2389. }
  2390. /**
  2391. * 放弃择岗
  2392. */
  2393. public function give_up_post(Request $request)
  2394. {
  2395. //以下为测试环境
  2396. // $recruit_id = $request->input('recruit_id');
  2397. // $appoint_id = $request->input('appoint_id');
  2398. // $uid = $request->input('uid');
  2399. // $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
  2400. // if($info){
  2401. // return ['status' => 0, 'msg' => "测试数据重复,请重新点击生成测试数据!"];
  2402. // }
  2403. // RecruitAppointSelect::create(['recruit_id'=>$recruit_id,'appoint_id'=>$appoint_id,'uid'=>$uid,'status'=>-1]);
  2404. // return ['status' => 1, 'msg' => "放弃择岗成功!"];
  2405. //以下为正式环境再放开
  2406. $user = $this->getUser();
  2407. if (!empty($user)) {
  2408. $uid = $user->id;
  2409. } else {
  2410. return redirect(route('login'));
  2411. }
  2412. $recruit_id = $request->input('recruit_id');
  2413. $appoint_id = $request->input('appoint_id');
  2414. $info = RecruitAppointSelect::where('uid', $uid)->where('recruit_id', $recruit_id)->where('appoint_id', $appoint_id)->first();
  2415. if ($info == null) {
  2416. return ['status' => 0, 'msg' => "抱歉,您无需择岗!"];
  2417. }
  2418. if ($info->status != 0) {
  2419. return ['status' => 0, 'msg' => "抱歉,您不是待择岗状态!"];
  2420. }
  2421. $info->status = -1;
  2422. $info->save();
  2423. return ['status' => 1, 'msg' => "放弃择岗成功!"];
  2424. }
  2425. public function comfirm_post(Request $request)
  2426. {
  2427. $user = $this->getUser();
  2428. if (!empty($user)) {
  2429. $uid = $user->id;
  2430. } else {
  2431. return redirect(route('login'));
  2432. }
  2433. $recruit_id = $request->input('recruit_id');
  2434. $appoint_id = $request->input('appoint_id');
  2435. $time = time();
  2436. if ($time > 1727150400 || $time < 1727053200) {
  2437. return ['status' => 0, 'msg' => "抱歉,未到择岗时间!"];
  2438. }
  2439. $info = RecruitAppointSelect::where('uid', $uid)->where('recruit_id', $recruit_id)->where('appoint_id', $appoint_id)->first();
  2440. if ($info->result) {
  2441. return ['status' => 0, 'msg' => "择岗数据已提交!"];
  2442. }
  2443. // $data = [
  2444. // 'recruit_id' => $recruit_id,
  2445. // 'appoint_id' => $recruit_id,
  2446. // 'uid' => $uid,
  2447. // 'status' => 1
  2448. // ];
  2449. $result = [];
  2450. $select = $request->input('select');
  2451. if (is_array($select) && count($select) > 0) {
  2452. foreach ($select as $v) {
  2453. array_push($result, $v['name']);
  2454. }
  2455. }
  2456. $info->result = json_encode($result);
  2457. $info->status = 1;
  2458. $info->save();
  2459. return ['status' => 1, 'msg' => "提交择岗意愿成功,请耐心等待结果!"];
  2460. }
  2461. public function select_result(Request $request)
  2462. {
  2463. $redis = Cache::getRedis();
  2464. $redis->set('recruit_quota_batch5', '');
  2465. return view('app.recruit.select_result');
  2466. }
  2467. public function get_select_result(Request $request)
  2468. {
  2469. $redis = Cache::getRedis();
  2470. $quot_batch5 = $redis->get('recruit_quota_batch5');
  2471. if (!$quot_batch5) {
  2472. $quot_batch5 = [
  2473. [
  2474. 'name' => '陈埭镇',
  2475. 'value' => 21,
  2476. ],
  2477. [
  2478. 'name' => '金井镇',
  2479. 'value' => 3
  2480. ],
  2481. [
  2482. 'name' => '深沪镇',
  2483. 'value' => 2
  2484. ]
  2485. ];
  2486. $redis->set('recruit_quotaA', json_encode($quot_batch5));
  2487. } else {
  2488. $quot_batch5 = json_decode($quot_batch5, true);
  2489. }
  2490. $list = DB::table('recruit_appoint_select as a')->leftJoin('recruit_appoint_info as b', 'a.appoint_id', '=', 'b.id')->leftJoin('recruit_ticket as c', 'a.appoint_id', '=', 'c.appoint_id')->whereRaw('a.select_result is null and a.batch=5 and a.result is not null')->select(['b.realname', 'c.ex_number', 'a.result', 'a.select_result', 'a.id', 'a.record', 'a.record2', 'a.record3'])->orderBy('record', 'desc')->orderBy('record2', 'desc')->orderBy('record3', 'desc')->limit(2)->get()->toArray();
  2491. $return_data = [
  2492. 'list' => [],
  2493. ];
  2494. $array_column = array_column($quot_batch5, 'name');
  2495. if (count($list) > 1) {
  2496. $current = $list[0];
  2497. $next = $list[1];
  2498. } else {
  2499. $current = $list[0];
  2500. $next = false;
  2501. }
  2502. $person_select_result = json_decode($current->result, true);
  2503. $flag = 0;//是否择岗成功
  2504. foreach ($person_select_result as $val) {
  2505. //寻找下标
  2506. $index = array_search($val, $array_column);
  2507. if ($quot_batch5[$index]['value']) {
  2508. if ($next && $current->record == $next->record && $current->record2 == $next->record2 && $current->record3 == $next->record3 && $quot_batch5[$index]['value'] == 1) {
  2509. //如果当前处理人员不是最后一个,且分数与下一名人员三个维度完全一样的话并且该人员欲择的岗位仅剩一位,则特殊处理
  2510. //查找同样分数人同样志愿
  2511. $next_select_result = json_decode($next->result, true);
  2512. //寻找下标
  2513. $current_index = array_search($val, $person_select_result);
  2514. $next_index = array_search($val, $next_select_result);
  2515. if ($current_index > $next_index) {
  2516. //如果当前人员对当前镇街的意向排序大于下一人,调换两个指针,先排序下一个人
  2517. $current = $next;
  2518. }
  2519. }
  2520. $quota_data = [
  2521. 'index' => $index,
  2522. 'old_value' => $quot_batch5[$index]['value'],
  2523. ];
  2524. //有名额允许择岗
  2525. DB::table('recruit_appoint_select')->where('id', $current->id)->update(['select_result' => $val, 'status' => 1]);
  2526. $current->select_result = $val;
  2527. $quot_batch5[$index]['value']--;
  2528. $quota_data['new_value'] = $quot_batch5[$index]['value'];
  2529. $redis->set('recruit_quota_batch4', json_encode($quot_batch5));
  2530. $flag = 1;
  2531. break;
  2532. }
  2533. }
  2534. if (!$flag) {
  2535. $quota_data = [
  2536. 'index' => $index,
  2537. 'old_value' => $quot_batch5[$index]['value'],
  2538. ];
  2539. $current->select_result = '未匹配到志愿,本轮择岗不成功!';
  2540. DB::table('recruit_appoint_select')->where('id', $current->id)->update(['select_result' => '未匹配到志愿,本轮择岗不成功!', 'status' => -2]);
  2541. }
  2542. $return_data['quota'] = $quota_data;
  2543. return ['status' => 1, 'msg' => '择岗排序成功', 'data' => $return_data];
  2544. }
  2545. public function select_init(Request $request)
  2546. {
  2547. $count = DB::table('recruit_appoint_select')->whereRaw('select_result is null and batch = 5 and type = 1 and result is not null')->count();
  2548. $redis = Cache::getRedis();
  2549. $quot_batch5 = $redis->get('recruit_quota_batch4');
  2550. if (!$quot_batch5) {
  2551. $quot_batch5 = [
  2552. [
  2553. 'name' => '陈埭镇',
  2554. 'value' => 21,
  2555. ],
  2556. [
  2557. 'name' => '金井镇',
  2558. 'value' => 3
  2559. ],
  2560. [
  2561. 'name' => '深沪镇',
  2562. 'value' => 2
  2563. ]
  2564. ];
  2565. $redis->set('recruit_quota_batch5', json_encode($quot_batch5));
  2566. }
  2567. $list = DB::table('recruit_appoint_select as a')->leftJoin('recruit_appoint_info as b', 'a.appoint_id', '=', 'b.id')->leftJoin('recruit_ticket as c', 'a.appoint_id', '=', 'c.appoint_id')->whereRaw('a.select_result is not null and a.batch=5 and type = 1')->select(['b.realname', 'c.ex_number', 'a.result', 'a.select_result', 'a.id'])->orderBy('record', 'desc')->get();
  2568. return ['status' => 1, 'msg' => '获取初始化信息成功', 'data' => ['count' => $count, 'quota' => $quot_batch5, 'list' => $list]];
  2569. }
  2570. public function interviewer_random(Request $request)
  2571. {
  2572. $model = $request->input('model', 1);
  2573. $number1 = $request->input('number1', 5);//考官人数
  2574. $number2 = $request->input('number2', 1);//替补人数
  2575. $where[] = ['id', '>', 0];
  2576. switch ($model) {
  2577. case '0':
  2578. $list = DB::table('recruit_interviewer')->get()->toArray();
  2579. shuffle($list);
  2580. $result = array_slice($list, 0, $number1 + $number2);
  2581. break;
  2582. case '1':
  2583. $list = DB::table('recruit_interviewer')->get()->toArray();
  2584. shuffle($list);
  2585. $count = $number1;
  2586. for ($i = 0; $i < $count; $i++) {
  2587. if (!$list[$i]->status) {
  2588. $list[] = $list[$i];
  2589. unset($list[$i]);
  2590. $count++;
  2591. }
  2592. }
  2593. $result = array_slice($list, 0, $number1 + $number2);
  2594. break;
  2595. case '2':
  2596. $list = DB::table('recruit_interviewer')->where('status', 1)->get()->toArray();
  2597. shuffle($list);
  2598. $result = array_slice($list, 0, $number1 + $number2);
  2599. break;
  2600. default:
  2601. $list = DB::table('recruit_interviewer')->get()->toArray();
  2602. shuffle($list);
  2603. for ($i = 0; $i < $number1; $i++) {
  2604. dd($list[$i]);
  2605. if (!$list[$i]->status) {
  2606. $list[] = $list[$i];
  2607. unset($list[$i]);
  2608. }
  2609. }
  2610. $result = array_slice($list, 0, $number1 + $number2);
  2611. break;
  2612. }
  2613. $return_data = [
  2614. 'list' => $result,
  2615. 'number1' => $number1,
  2616. 'number2' => $number2,
  2617. ];
  2618. return view('app.recruit.interviewer', $return_data);
  2619. }
  2620. public function supplement_info(Request $request)
  2621. {
  2622. $user = $this->getUser();
  2623. if (!empty($user)) {
  2624. $uid = $user->id;
  2625. } else {
  2626. return redirect(route('login'));
  2627. }
  2628. //招考id
  2629. $id = $request->input('id', 0);
  2630. if (!$id) {
  2631. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  2632. }
  2633. $recruit = Recruit::find($id);
  2634. if (!$recruit['status']) {
  2635. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2636. }
  2637. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  2638. if (!$appoint_info) {
  2639. return $this->showMessage('抱歉,您没有报名,无需补充信息!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2640. }
  2641. $supplement_info = DB::table("recruit_supplement_cunwu")->where('uid', $uid)->where('appoint_id', $appoint_info->id)->first();
  2642. if ($supplement_info) {
  2643. return $this->showMessage('您已登记信息,无需再次登记!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2644. }
  2645. $uids = [167780,168696,56609,168696,164951,169813,161935,169412,169307,169628,169331,170471,161935,170718,175771,175856,169628,56609,168696,176871,169412,169813,177014,161935,152626,176994,176703,176432,170471,177272,179103,179206,179165,179873,179863,179715,180131,161935,180616,170718,180766,175856,180810,169412,177272,167988,181121,181175,168696,182354,56609,184859,161935,176994,169813,169412,187369,159298,169628,181175,187450,167988,187572,187578,187573,179863,187753,187577,152626,187875,187815,149975,187821,180131,187934,176871,168696,186519,170718,188160,176994,169813,161935,180616,188342,188411,177014,188455,188450,177272,184859,168696,181121,189428,189446,189410,182354,182354,184859,184859,187572,190509,161935,170718,184859,182354,191077,187450,191077,169813,191538,191954,191396,152626,182354,192121,189446,192223,192271,170718,170718,192769,192798,192674,192774,192800,180131,179863,169412,192560,186519,56609,170471,188160,168696,159298,187572,192868,169628,192874,192775,192892,181175,167988,192914,192922,192925,159772,192930,192945,192752,192652,188411,192958,179715,192959,192834,192987,192739,192392,152626,188450,193038,192542,192452,193055,192788,187369,193072,176703,193079,193069,193084,192803,192668,187875,193103,187578,191396,175771,193113,193135,193132,191077,193151,191954,187381,193130,193169,188035,179103,176432,182354,180766,189410,192855,179165,175642,193202,193141,193248,193239,193244,193252,192978,192888,187753,185725,143917,177272,187821,193326,193334,193331,187573,180616,193350,192813,193357,192926,193212,187815,193361,193158,193150,176994,193389,184118,176896,193408,192811,189446,193416,193423,170718,187934,192955,169307,180810,193428,149975,187577,186473,192720,175856,161935,187935,159058,193526,187450,192271,169813,193570,193578,193225,193594,193606,181121,169331,193616,184859,190509,193640,192751,193574,167780,193695,192133,193714,192523,193718,193717,193720,189428,179873,177014,188342,193742,188455,176871,191538,193787,192223,193789,185725,182354,186519,193135];//写死用户
  2646. if (!in_array($uid, $uids)) {
  2647. return $this->showMessage('您无需登记信息!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2648. }
  2649. // $limit_time = 1661961599;
  2650. // $time = time();
  2651. // if( $time > $limit_time){
  2652. // return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2653. // }
  2654. $view_data = [];
  2655. //$view_data['info'] = json_encode($info);
  2656. $view_data['title'] = $recruit->company;
  2657. $view_data['id'] = $id;
  2658. return view('app.recruit.supplement_info', $view_data);
  2659. }
  2660. public function save_supplement_info(Request $request)
  2661. {
  2662. $user = $this->getUser();
  2663. if (!empty($user)) {
  2664. $uid = $user->id;
  2665. } else {
  2666. return redirect(route('login'));
  2667. }
  2668. //招考id
  2669. $id = $request->input('recruit_id', 0);
  2670. if (!$id) {
  2671. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2672. }
  2673. $recruit = Recruit::find($id);
  2674. if (!$recruit['status']) {
  2675. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2676. }
  2677. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  2678. if (!$appoint_info) {
  2679. return ['status' => 0, 'msg' => '抱歉,您没有报名,无需补充信息!', 'data' => ''];
  2680. }
  2681. if ($request->input('marriage') == '已婚') {
  2682. if ($request->input('spouse_card_type') == '' || $request->input('spouse_card') == '' || $request->input('spouse_realname') == '' || $request->input('spouse_mobile') == '') {
  2683. return ['status' => 0, 'msg' => '请完善配偶信息!', 'data' => ''];
  2684. }
  2685. }
  2686. $data = [
  2687. 'uid' => $uid,
  2688. 'appoint_id' => $appoint_info->id,
  2689. 'street' => $request->input('street'),
  2690. 'realname' => $request->input('realname'),
  2691. 'sex' => $request->input('sex'),
  2692. 'house' => $request->input('house'),
  2693. 'nation' => $request->input('nation'),
  2694. 'native' => $request->input('native'),
  2695. 'marriage' => $request->input('marriage'),
  2696. 'spouse_card_type' => $request->input('spouse_card_type'),
  2697. 'spouse_card' => $request->input('spouse_card'),
  2698. 'spouse_realname' => $request->input('spouse_realname'),
  2699. 'spouse_mobile' => $request->input('spouse_mobile'),
  2700. 'political' => $request->input('political'),
  2701. 'bank_card' => $request->input('bank_card'),
  2702. 'bank_open' => $request->input('bank_open'),
  2703. 'card' => $request->input('card'),
  2704. 'card_endtime' => $request->input('card_endtime'),
  2705. 'mobile' => $request->input('mobile'),
  2706. 'edu' => $request->input('education'),
  2707. 'pro' => $request->input('pro'),
  2708. 'address' => $request->input('address'),
  2709. 'funds' => $request->input('funds'),
  2710. ];
  2711. DB::table('recruit_supplement_cunwu')->insert($data);
  2712. return ['status' => 1, 'msg' => '提交成功!', 'data' => ''];
  2713. }
  2714. public function comfirm_pen(Request $request)
  2715. {
  2716. $user = $this->getUser();
  2717. if (!empty($user)) {
  2718. $uid = $user->id;
  2719. } else {
  2720. return redirect(route('login'));
  2721. }
  2722. //招考id
  2723. $id = $request->input('recruit_id', 0);
  2724. if (!$id) {
  2725. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2726. }
  2727. $recruit = Recruit::find($id);
  2728. if (!$recruit['status']) {
  2729. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2730. }
  2731. if (!$recruit->pen_comfirm) {
  2732. return ['status' => 0, 'msg' => '该项目无须确认笔试考试!', 'data' => ''];
  2733. }
  2734. $appoint_info = RecruitAppointInfo::where('recruit_id', $id)->where('uid', $uid)->first();
  2735. if (!$appoint_info) {
  2736. return ['status' => 0, 'msg' => '找不到您的报名记录,请检查!', 'data' => ''];
  2737. }
  2738. if ($appoint_info->audit != 3) {
  2739. return ['status' => 0, 'msg' => '您的报名未审核通过,无需确认!', 'data' => ''];
  2740. }
  2741. $time = time();
  2742. if (strtotime($recruit->pen_comfirm_start) > $time || strtotime($recruit->pen_comfirm_end) < $time) {
  2743. return ['status' => 0, 'msg' => '未在笔试确认时间段!', 'data' => ''];
  2744. }
  2745. if ($appoint_info->pen_audit != -2) {
  2746. return ['status' => 0, 'msg' => '您已确认参加笔试,无需再次确认!', 'data' => ''];
  2747. }
  2748. $appoint_info->update(['pen_audit' => -1]);
  2749. $log = [
  2750. 'type' => 3,
  2751. 'appoint_id' => $appoint_info->id,
  2752. 'uid' => $uid,
  2753. 'log' => '用户确认参加笔试',
  2754. ];
  2755. RecruitAppointLog::create($log);
  2756. return ['status' => 1, 'msg' => '确认成功', 'data' => $appoint_info->id];
  2757. }
  2758. public function supplementary_entry(Request $request)
  2759. {
  2760. $user = $this->getUser();
  2761. if (!empty($user)) {
  2762. $uid = $user->id;
  2763. } else {
  2764. return redirect(route('login'));
  2765. }
  2766. //招考id
  2767. $id = $request->input('recruit_id', 0);
  2768. if (!$id) {
  2769. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2770. }
  2771. $recruit = Recruit::find($id);
  2772. if (!$recruit['status']) {
  2773. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2774. }
  2775. $appoint_info = RecruitAppointInfo::where('recruit_id', $id)->where('uid', $uid)->first();
  2776. if (!$appoint_info) {
  2777. return ['status' => 0, 'msg' => '找不到您的报名记录,请检查!', 'data' => ''];
  2778. }
  2779. $time = time();
  2780. if ($time > 1680969600) {
  2781. return ['status' => 0, 'msg' => '已停止补充报名!', 'data' => ''];
  2782. }
  2783. if ($appoint_info->adjust_limit) {
  2784. $appoint_info->update(['adjust' => 1]);
  2785. return ['status' => 1, 'msg' => '补充报名成功!', 'data' => ''];
  2786. } else {
  2787. return ['status' => 0, 'msg' => '您无需补充报名!', 'data' => ''];
  2788. }
  2789. }
  2790. }