IndexController.php 112 KB

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