IndexController.php 105 KB

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