IndexController.php 102 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428
  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 = $info->result;
  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->status = 1;
  2015. $info->save();
  2016. return ['status' => 1, 'msg' => "提交择岗意愿成功,请耐心等待结果!"];
  2017. }
  2018. public function select_result(Request $request)
  2019. {
  2020. return view('app.recruit.select_result');
  2021. }
  2022. public function get_select_result(Request $request)
  2023. {
  2024. $redis = Cache::getRedis();
  2025. $quota = $redis->get('recruit_quota');
  2026. if(!$quota){
  2027. $quota = [
  2028. [
  2029. 'name' => '青阳街道',
  2030. 'value' => 29,
  2031. ],
  2032. [
  2033. 'name' => '梅岭街道',
  2034. 'value' => 41
  2035. ],
  2036. [
  2037. 'name' => '西园街道',
  2038. 'value' => 16
  2039. ],
  2040. [
  2041. 'name' => '罗山街道',
  2042. 'value' => 30
  2043. ],
  2044. [
  2045. 'name' => '灵源街道',
  2046. 'value' => 18
  2047. ],
  2048. [
  2049. 'name' => '新塘街道',
  2050. 'value' => 29
  2051. ],
  2052. [
  2053. 'name' => '陈埭镇',
  2054. 'value' => 112
  2055. ],
  2056. [
  2057. 'name' => '池店镇',
  2058. 'value' => 80
  2059. ],
  2060. [
  2061. 'name' => '安海镇',
  2062. 'value' => 86
  2063. ],
  2064. [
  2065. 'name' => '磁灶镇',
  2066. 'value' => 46
  2067. ],
  2068. [
  2069. 'name' => '内坑镇',
  2070. 'value' => 38
  2071. ],
  2072. [
  2073. 'name' => '紫帽镇',
  2074. 'value' => 9
  2075. ],
  2076. [
  2077. 'name' => '东石镇',
  2078. 'value' => 29
  2079. ],
  2080. [
  2081. 'name' => '永和镇',
  2082. 'value' => 43
  2083. ],
  2084. [
  2085. 'name' => '英林镇',
  2086. 'value' => 25
  2087. ],
  2088. [
  2089. 'name' => '金井镇',
  2090. 'value' => 28
  2091. ],
  2092. [
  2093. 'name' => '龙湖镇',
  2094. 'value' => 63
  2095. ],
  2096. [
  2097. 'name' => '深沪镇',
  2098. 'value' => 29
  2099. ],
  2100. [
  2101. 'name' => '西滨镇',
  2102. 'value' => 9
  2103. ]
  2104. ];
  2105. $redis->set('recruit_quota',json_encode($quota));
  2106. }else{
  2107. $quota = json_decode($quota,true);
  2108. }
  2109. $limit = $request->input('limit',1);
  2110. $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();
  2111. $return_data = [
  2112. 'list' => []
  2113. ];
  2114. $array_column = array_column($quota,'name');
  2115. foreach ($list as $k => $v){
  2116. $person_select_result = json_decode($v->result,true);
  2117. $flag = 0;//是否择岗成功
  2118. foreach ($person_select_result as $val){
  2119. //寻找下标
  2120. $index = array_search($val,$array_column);
  2121. if($quota[$index]['value'] > 0){
  2122. $quota_data = [
  2123. 'index' => $index,
  2124. 'old_value' => $quota[$index]['value']
  2125. ];
  2126. //有名额允许择岗
  2127. DB::table('recruit_appoint_select')->where('id',$v->id)->update(['select_result'=>$val,'status' => 1]);
  2128. $v->select_result = $val;
  2129. $quota[$index]['value']--;
  2130. $quota_data['new_value'] = $quota[$index]['value'];
  2131. $redis->set('recruit_quota',json_encode($quota));
  2132. $flag = 1;
  2133. break;
  2134. }
  2135. }
  2136. if(!$flag){
  2137. $v->select_result = '未匹配到志愿,本轮择岗不成功!';
  2138. DB::table('recruit_appoint_select')->where('id',$v->id)->update(['select_result'=>'未匹配到志愿,本轮择岗不成功!','status' => -2]);
  2139. }
  2140. array_push($return_data['list'],$v);
  2141. }
  2142. $return_data['quota'] = $quota_data;
  2143. return ['status' => 1, 'msg' => '择岗排序成功', 'data' => $return_data];
  2144. }
  2145. public function select_init(Request $request)
  2146. {
  2147. $count = DB::table('recruit_appoint_select')->whereRaw('select_result is null')->count();
  2148. $redis = Cache::getRedis();
  2149. $quota = $redis->get('recruit_quota');
  2150. if(!$quota){
  2151. $quota = [
  2152. [
  2153. 'name' => '青阳街道',
  2154. 'value' => 29,
  2155. ],
  2156. [
  2157. 'name' => '梅岭街道',
  2158. 'value' => 41
  2159. ],
  2160. [
  2161. 'name' => '西园街道',
  2162. 'value' => 16
  2163. ],
  2164. [
  2165. 'name' => '罗山街道',
  2166. 'value' => 30
  2167. ],
  2168. [
  2169. 'name' => '灵源街道',
  2170. 'value' => 18
  2171. ],
  2172. [
  2173. 'name' => '新塘街道',
  2174. 'value' => 29
  2175. ],
  2176. [
  2177. 'name' => '陈埭镇',
  2178. 'value' => 112
  2179. ],
  2180. [
  2181. 'name' => '池店镇',
  2182. 'value' => 80
  2183. ],
  2184. [
  2185. 'name' => '安海镇',
  2186. 'value' => 86
  2187. ],
  2188. [
  2189. 'name' => '磁灶镇',
  2190. 'value' => 46
  2191. ],
  2192. [
  2193. 'name' => '内坑镇',
  2194. 'value' => 38
  2195. ],
  2196. [
  2197. 'name' => '紫帽镇',
  2198. 'value' => 9
  2199. ],
  2200. [
  2201. 'name' => '东石镇',
  2202. 'value' => 29
  2203. ],
  2204. [
  2205. 'name' => '永和镇',
  2206. 'value' => 43
  2207. ],
  2208. [
  2209. 'name' => '英林镇',
  2210. 'value' => 25
  2211. ],
  2212. [
  2213. 'name' => '金井镇',
  2214. 'value' => 28
  2215. ],
  2216. [
  2217. 'name' => '龙湖镇',
  2218. 'value' => 63
  2219. ],
  2220. [
  2221. 'name' => '深沪镇',
  2222. 'value' => 29
  2223. ],
  2224. [
  2225. 'name' => '西滨镇',
  2226. 'value' => 9
  2227. ]
  2228. ];
  2229. $redis->set('recruit_quota',json_encode($quota));
  2230. }
  2231. $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();
  2232. return ['status' => 1, 'msg' => '获取初始化信息成功', 'data' => ['count' => $count, 'quota' => $quota, 'list' => $list]];
  2233. }
  2234. public function interviewer_random(Request $request)
  2235. {
  2236. $model = $request->input('model',1);
  2237. $number1 = $request->input('number1',5);//考官人数
  2238. $number2 = $request->input('number2',1);//替补人数
  2239. $where[] = ['id','>',0];
  2240. switch ($model){
  2241. case '0':
  2242. $list = DB::table('recruit_interviewer')->get()->toArray();
  2243. shuffle($list);
  2244. $result = array_slice($list, 0, $number1+$number2);
  2245. break;
  2246. case '1':
  2247. $list = DB::table('recruit_interviewer')->get()->toArray();
  2248. shuffle($list);
  2249. $count = $number1;
  2250. for ($i = 0; $i < $count; $i++){
  2251. if(!$list[$i]->status){
  2252. $list[] = $list[$i];
  2253. unset($list[$i]);
  2254. $count++;
  2255. }
  2256. }
  2257. $result = array_slice($list, 0, $number1+$number2);
  2258. break;
  2259. case '2':
  2260. $list = DB::table('recruit_interviewer')->where('status',1)->get()->toArray();
  2261. shuffle($list);
  2262. $result = array_slice($list, 0, $number1+$number2);
  2263. break;
  2264. default:
  2265. $list = DB::table('recruit_interviewer')->get()->toArray();
  2266. shuffle($list);
  2267. for ($i = 0; $i < $number1; $i++){
  2268. dd($list[$i]);
  2269. if(!$list[$i]->status){
  2270. $list[] = $list[$i];
  2271. unset($list[$i]);
  2272. }
  2273. }
  2274. $result = array_slice($list, 0, $number1+$number2);
  2275. break;
  2276. }
  2277. $return_data = [
  2278. 'list' => $result,
  2279. 'number1' => $number1,
  2280. 'number2' => $number2
  2281. ];
  2282. return view('app.recruit.interviewer', $return_data);
  2283. }
  2284. }