IndexController.php 112 KB

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