IndexController.php 112 KB

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