IndexController.php 131 KB

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