IndexController.php 113 KB

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