IndexController.php 112 KB

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