IndexController.php 108 KB

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