IndexController.php 108 KB

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