IndexController.php 120 KB

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