IndexController.php 124 KB

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