IndexController.php 109 KB

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