IndexController.php 102 KB

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