IndexController.php 124 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857
  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. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1447. if($appoint_info){
  1448. $check_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',2)->first();
  1449. if($check_ticket){
  1450. $time = time();
  1451. if(strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time){
  1452. RecruitTicket::where('appoint_id',$appoint_info->id)->update(['ex_status' => 1]);
  1453. $recruit = Recruit::where('id',$recruit_id)->first();
  1454. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1455. $name = $recruit->name_en;
  1456. $date = date("Y-m-d",strtotime($recruit->created_at));
  1457. $filename = date("Y-m-18",time()) . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1458. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/check/" . $filename . '.pdf';
  1459. if(file_exists($file)){
  1460. header('Content-Description: File Transfer');
  1461. header('Content-Type: application/octet-stream');
  1462. header('Content-Disposition: attachment; filename='.basename($file));
  1463. header('Content-Transfer-Encoding: binary');
  1464. header('Expires: 0');
  1465. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1466. header('Pragma: public');
  1467. header('Content-Length: ' . filesize($file));
  1468. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1469. flush();
  1470. readfile($file);
  1471. }
  1472. }else{
  1473. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1474. }
  1475. }else{
  1476. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1477. }
  1478. }else{
  1479. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1480. }
  1481. }
  1482. /**
  1483. * 面试准考证
  1484. * @param Request $request
  1485. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1486. */
  1487. public function face_ticket(Request $request)
  1488. {
  1489. $user = $this->getUser();
  1490. if (!empty($user)) {
  1491. $uid = $user->id;
  1492. } else {
  1493. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1494. }
  1495. $recruit_id = $request->input('recruit_id');
  1496. $recruit = Recruit::where('id',$recruit_id)->first();
  1497. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1498. if($appoint_info){
  1499. $face_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',3)->first();
  1500. if($face_ticket){
  1501. $health = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();
  1502. if((!$health || $health->h_status == 0) && $recruit->pen_epidemic){
  1503. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1504. }$time = time();
  1505. if(strtotime($face_ticket->ex_start) < $time && strtotime($face_ticket->ex_end) > $time){
  1506. RecruitTicket::where('id',$face_ticket->id)->update(['ex_status' => 1]);
  1507. $recruit = Recruit::where('id',$recruit_id)->first();
  1508. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1509. $name = $recruit->name_en;
  1510. $date = date("Y-m-d",strtotime($recruit->created_at));
  1511. //$filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1512. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1513. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';
  1514. if(file_exists($file)){
  1515. header('Content-Description: File Transfer');
  1516. header('Content-Type: application/octet-stream');
  1517. header('Content-Disposition: attachment; filename='.basename($file));
  1518. header('Content-Transfer-Encoding: binary');
  1519. header('Expires: 0');
  1520. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1521. header('Pragma: public');
  1522. header('Content-Length: ' . filesize($file));
  1523. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1524. flush();
  1525. readfile($file);
  1526. }
  1527. }else{
  1528. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1529. }
  1530. }else{
  1531. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1532. }
  1533. }else{
  1534. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1535. }
  1536. }
  1537. /**
  1538. * 复试准考证
  1539. * @param Request $request
  1540. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1541. */
  1542. public function reexamine_ticket(Request $request)
  1543. {
  1544. $user = $this->getUser();
  1545. if (!empty($user)) {
  1546. $uid = $user->id;
  1547. } else {
  1548. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1549. }
  1550. $recruit_id = $request->input('recruit_id');
  1551. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1552. if($appoint_info){
  1553. $reexamine_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',4)->first();
  1554. if($reexamine_ticket){
  1555. $time = time();
  1556. if(strtotime($reexamine_ticket->ex_start) < $time && strtotime($reexamine_ticket->ex_end) > $time){
  1557. RecruitTicket::where('id',$reexamine_ticket->id)->update(['ex_status' => 1]);
  1558. $recruit = Recruit::where('id',$recruit_id)->first();
  1559. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1560. $name = $recruit->name_en;
  1561. $date = date("Y-m-d",strtotime($recruit->created_at));
  1562. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1563. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/reexamine/" . $filename . '.pdf';
  1564. if(file_exists($file)){
  1565. header('Content-Description: File Transfer');
  1566. header('Content-Type: application/octet-stream');
  1567. header('Content-Disposition: attachment; filename='.basename($file));
  1568. header('Content-Transfer-Encoding: binary');
  1569. header('Expires: 0');
  1570. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1571. header('Pragma: public');
  1572. header('Content-Length: ' . filesize($file));
  1573. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1574. flush();
  1575. readfile($file);
  1576. }
  1577. }else{
  1578. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1579. }
  1580. }else{
  1581. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1582. }
  1583. }else{
  1584. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1585. }
  1586. }
  1587. /**
  1588. * 材料补登
  1589. * @param Request $request
  1590. */
  1591. public function material_supplement(Request $request)
  1592. {
  1593. $user = $this->getUser();
  1594. if (!empty($user)) {
  1595. $uid = $user->id;
  1596. } else {
  1597. return redirect(route('login'));
  1598. }
  1599. //招考id
  1600. $id = $request->input('id', 0);
  1601. if (!$id) {
  1602. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1603. }
  1604. $recruit = Recruit::find($id);
  1605. if(!$recruit['status'] && !$user->recruit_test){
  1606. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1607. }
  1608. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  1609. if(!$appoint_info){
  1610. return $this->showMessage('抱歉,您没有报名,无需考察审核!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1611. }
  1612. if($appoint_info->pen_audit != 1){
  1613. return $this->showMessage('抱歉,您未入闱,无需考察审核!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1614. }
  1615. $limit_time = 1662543000;
  1616. $time = time();
  1617. if( $time > $limit_time){
  1618. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1619. }
  1620. $info = RecruitSupplement::where('appoint_id',$appoint_info->id)->where('type','supplement')->first();
  1621. if(!$info){
  1622. $info = [
  1623. 'appoint_id' => $appoint_info->id,
  1624. 'identification' => '',
  1625. 'household_register' => '',
  1626. 'education_certification' => '',
  1627. //'family_planning' => '',
  1628. 'manage' => '',
  1629. 'status' => 3
  1630. ];
  1631. }else{
  1632. $info = $info->toArray();
  1633. if(json_decode($info['identification'])){
  1634. $identification = json_decode($info['identification'],true);
  1635. foreach ($identification as $k => $v){
  1636. if(array_key_exists('response',$v)){
  1637. $identification[$k]['url'] = $v['response']['path'];
  1638. }
  1639. }
  1640. }else{
  1641. $identification = [];
  1642. }
  1643. $info['identification'] = $identification;
  1644. if(json_decode($info['household_register'])){
  1645. $household_register = json_decode($info['household_register'],true);
  1646. foreach ($household_register as $k => $v){
  1647. if(array_key_exists('response',$v)){
  1648. $household_register[$k]['url'] = $v['response']['path'];
  1649. }
  1650. }
  1651. }else{
  1652. $household_register = [];
  1653. }
  1654. $info['household_register'] = $household_register;
  1655. if(json_decode($info['education_certification'])){
  1656. $education_certification = json_decode($info['education_certification'],true);
  1657. foreach ($education_certification as $k => $v){
  1658. if(array_key_exists('response',$v)){
  1659. $education_certification[$k]['url'] = $v['response']['path'];
  1660. }
  1661. }
  1662. }else{
  1663. $education_certification = [];
  1664. }
  1665. $info['education_certification'] = $education_certification;
  1666. if(json_decode($info['family_planning'])){
  1667. $family_planning = json_decode($info['family_planning'],true);
  1668. foreach ($family_planning as $k => $v){
  1669. if(array_key_exists('response',$v)){
  1670. $family_planning[$k]['url'] = $v['response']['path'];
  1671. }
  1672. }
  1673. }else{
  1674. $family_planning = [];
  1675. }
  1676. $info['family_planning'] = $family_planning;
  1677. if(json_decode($info['manage'])){
  1678. $manage = json_decode($info['manage'],true);
  1679. foreach ($manage as $k => $v){
  1680. if(array_key_exists('response',$v)){
  1681. $manage[$k]['url'] = $v['response']['path'];
  1682. }
  1683. }
  1684. }else{
  1685. $manage = [];
  1686. }
  1687. $info['manage'] = $manage;
  1688. }
  1689. $view_data['info'] = json_encode($info);
  1690. $view_data['title'] = $recruit->company;
  1691. return view('app.recruit.supplement',$view_data);
  1692. }
  1693. /**
  1694. * 健康信息登记
  1695. * @param Request $request
  1696. */
  1697. public function health_info(Request $request)
  1698. {
  1699. $user = $this->getUser();
  1700. if (!empty($user)) {
  1701. $uid = $user->id;
  1702. } else {
  1703. return redirect(route('login'));
  1704. }
  1705. //招考id
  1706. $id = $request->input('id', 0);
  1707. if (!$id) {
  1708. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1709. }
  1710. $recruit = Recruit::find($id);
  1711. if(!$recruit['status'] && !$user->recruit_test){
  1712. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1713. }
  1714. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  1715. if(!$appoint_info){
  1716. return $this->showMessage('抱歉,您没有报名,无需登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1717. }
  1718. if($appoint_info->audit != 3){
  1719. return $this->showMessage('抱歉,您无需登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1720. }
  1721. $time = time();
  1722. $type = $request->input('type',null);
  1723. $where = [];
  1724. if($type){
  1725. switch ($type){
  1726. case 'pen':
  1727. $start = strtotime($recruit->pen_health_start);
  1728. $end = strtotime($recruit->pen_health_end);
  1729. break;
  1730. case 'computer':
  1731. $start = strtotime($recruit->computer_health_start);
  1732. $end = strtotime($recruit->computer_health_end);
  1733. break;
  1734. case 'face':
  1735. $start = strtotime($recruit->face_health_start);
  1736. $end = strtotime($recruit->face_health_end);
  1737. break;
  1738. case 'reexamine':
  1739. $start = strtotime($recruit->reexamine_health_start);
  1740. $end = strtotime($recruit->reexamine_health_end);
  1741. break;
  1742. default:
  1743. $start = strtotime($recruit->supplement_start);
  1744. $end = strtotime($recruit->supplement_end);
  1745. break;
  1746. }
  1747. $where[] = ['type', '=', $type];
  1748. }else{
  1749. $start = strtotime($recruit->supplement_start);
  1750. $end = strtotime($recruit->supplement_end);
  1751. }
  1752. if($time > $end || $time < $start){
  1753. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1754. }
  1755. $where[] = ['appoint_id', '=', $appoint_info->id];
  1756. $info = RecruitSupplement::where($where)->first();
  1757. if(!$info){
  1758. $info = [
  1759. 'appoint_id' => $appoint_info->id,
  1760. 'health_code' => '',
  1761. 'trip_code' => '',
  1762. 'type' => $type
  1763. ];
  1764. }else{
  1765. $info = $info->toArray();
  1766. if(json_decode($info['health_code'])){
  1767. $health_code = json_decode($info['health_code'],true);
  1768. foreach ($health_code as $k => $v){
  1769. if(array_key_exists('response',$v)){
  1770. $health_code[$k]['url'] = $v['response']['path'];
  1771. }
  1772. }
  1773. }else{
  1774. $health_code = [];
  1775. }
  1776. $info['health_code'] = $health_code;
  1777. if(json_decode($info['trip_code'])){
  1778. $trip_code = json_decode($info['trip_code'],true);
  1779. foreach ($trip_code as $k => $v){
  1780. if(array_key_exists('response',$v)){
  1781. $trip_code[$k]['url'] = $v['response']['path'];
  1782. }
  1783. }
  1784. }else{
  1785. $trip_code = [];
  1786. }
  1787. $info['trip_code'] = $trip_code;
  1788. }
  1789. $view_data['info'] = json_encode($info);
  1790. $view_data['title'] = $recruit->company;
  1791. return view('app.recruit.health',$view_data);
  1792. }
  1793. public function save_supplement(Request $request)
  1794. {
  1795. $user = $this->getUser();
  1796. if (!empty($user)) {
  1797. $uid = $user->id;
  1798. } else {
  1799. return redirect(route('login'));
  1800. }
  1801. $limit_time = 1662543000;
  1802. $time = time();
  1803. if( $time > $limit_time){
  1804. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',18)), true, '上一页', '3');
  1805. }
  1806. $appoint_id = $request->input('appoint_id');
  1807. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',18)->where('id',$appoint_id)->first();
  1808. if(!$appoint_info){
  1809. return ['status' => 0, 'msg' => '抱歉,找不到您要补登的报名记录!'];
  1810. }
  1811. $info = RecruitSupplement::where('appoint_id',$appoint_id)->where('type','supplement')->first();
  1812. if($info){
  1813. if($info->status == 1){
  1814. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  1815. }
  1816. if($info->status == 0){
  1817. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  1818. }
  1819. //身份证明
  1820. $identification = $request->input('identification');
  1821. if(is_array($identification)){
  1822. //删除掉没有成功返回路径的图片
  1823. foreach ($identification as $k => $v){
  1824. if(!array_key_exists('response',$v)){
  1825. unset($identification[$k]);
  1826. }
  1827. }
  1828. }
  1829. $info->identification = json_encode($identification);
  1830. //户口簿
  1831. $household_register = $request->input('household_register');
  1832. if(is_array($household_register)){
  1833. //删除掉没有成功返回路径的图片
  1834. foreach ($household_register as $k => $v){
  1835. if(!array_key_exists('response',$v)){
  1836. unset($household_register[$k]);
  1837. }
  1838. }
  1839. }
  1840. $info->household_register = json_encode($household_register);
  1841. //学信网
  1842. $education_certification = $request->input('education_certification');
  1843. if(is_array($education_certification)){
  1844. //删除掉没有成功返回路径的图片
  1845. foreach ($education_certification as $k => $v){
  1846. if(!array_key_exists('response',$v)){
  1847. unset($education_certification[$k]);
  1848. }
  1849. }
  1850. }
  1851. $info->education_certification = json_encode($education_certification);
  1852. //计生
  1853. // $family_planning = $request->input('family_planning');
  1854. // if(is_array($family_planning)){
  1855. // //删除掉没有成功返回路径的图片
  1856. // foreach ($family_planning as $k => $v){
  1857. // if(!array_key_exists('response',$v)){
  1858. // unset($family_planning[$k]);
  1859. // }
  1860. // }
  1861. // }
  1862. // $info->family_planning = json_encode($family_planning);
  1863. //综治
  1864. $manage = $request->input('manage');
  1865. if(is_array($manage)){
  1866. //删除掉没有成功返回路径的图片
  1867. foreach ($manage as $k => $v){
  1868. if(!array_key_exists('response',$v)){
  1869. unset($manage[$k]);
  1870. }
  1871. }
  1872. }
  1873. $info->manage = json_encode($manage);
  1874. $info->status = 0;
  1875. $info->save();
  1876. $appoint_info->political_audit = 4;
  1877. $appoint_info->save();
  1878. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1879. }else{
  1880. $data['appoint_id'] = $appoint_id;
  1881. //身份证明
  1882. $identification = $request->input('identification');
  1883. if(is_array($identification)){
  1884. //删除掉没有成功返回路径的图片
  1885. foreach ($identification as $k => $v){
  1886. if(!array_key_exists('response',$v)){
  1887. unset($identification[$k]);
  1888. }
  1889. }
  1890. }
  1891. $data['identification'] = json_encode($identification);
  1892. //户口簿
  1893. $household_register = $request->input('household_register');
  1894. if(is_array($household_register)){
  1895. //删除掉没有成功返回路径的图片
  1896. foreach ($household_register as $k => $v){
  1897. if(!array_key_exists('response',$v)){
  1898. unset($household_register[$k]);
  1899. }
  1900. }
  1901. }
  1902. $data['household_register'] = json_encode($household_register);
  1903. //学信网
  1904. $education_certification = $request->input('education_certification');
  1905. if(is_array($education_certification)){
  1906. //删除掉没有成功返回路径的图片
  1907. foreach ($education_certification as $k => $v){
  1908. if(!array_key_exists('response',$v)){
  1909. unset($education_certification[$k]);
  1910. }
  1911. }
  1912. }
  1913. $data['education_certification'] = json_encode($education_certification);
  1914. //计生
  1915. // $family_planning = $request->input('family_planning');
  1916. // if(is_array($family_planning)){sp
  1917. // //删除掉没有成功返回路径的图片
  1918. // foreach ($family_planning as $k => $v){
  1919. // if(!array_key_exists('response',$v)){
  1920. // unset($family_planning[$k]);
  1921. // }
  1922. // }
  1923. // }
  1924. // $data['family_planning'] = json_encode($family_planning);
  1925. //综治
  1926. $manage = $request->input('manage');
  1927. if(is_array($manage)){
  1928. //删除掉没有成功返回路径的图片
  1929. foreach ($manage as $k => $v){
  1930. if(!array_key_exists('response',$v)){
  1931. unset($manage[$k]);
  1932. }
  1933. }
  1934. }
  1935. $data['manage'] = json_encode($manage);
  1936. $data['status'] = 0;
  1937. $data['type'] = 'supplement';
  1938. $result = RecruitSupplement::create($data);
  1939. $appoint_info->political_audit = 4;
  1940. $appoint_info->save();
  1941. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1942. }
  1943. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  1944. }
  1945. public function save_healthinfo(Request $request)
  1946. {
  1947. $user = $this->getUser();
  1948. if (!empty($user)) {
  1949. $uid = $user->id;
  1950. } else {
  1951. return redirect(route('login'));
  1952. }
  1953. $appoint_id = $request->input('appoint_id');
  1954. $type = $request->input('type');
  1955. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('id',$appoint_id)->first();
  1956. if(!$appoint_info){
  1957. return ['status' => 0, 'msg' => '抱歉,找不到您要登记的报名记录!'];
  1958. }
  1959. $recruit = Recruit::where('id',$appoint_info->recruit_id)->first();
  1960. $info = RecruitSupplement::where('appoint_id',$appoint_id)->where('type',$type)->first();
  1961. if($info){
  1962. if($info->h_status == 1){
  1963. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  1964. }
  1965. if($info->h_status == 0){
  1966. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  1967. }
  1968. $health_code = $request->input('health_code');
  1969. if(is_array($health_code)){
  1970. //删除掉没有成功返回路径的图片
  1971. foreach ($health_code as $k => $v){
  1972. if(!array_key_exists('response',$v)){
  1973. unset($health_code[$k]);
  1974. }
  1975. }
  1976. }
  1977. $info->health_code = json_encode($health_code);
  1978. $trip_code = $request->input('trip_code');
  1979. if(is_array($trip_code)){
  1980. //删除掉没有成功返回路径的图片
  1981. foreach ($trip_code as $k => $v){
  1982. if(!array_key_exists('response',$v)){
  1983. unset($trip_code[$k]);
  1984. }
  1985. }
  1986. }
  1987. $info->trip_code = json_encode($trip_code);
  1988. $info->h_status = 0;
  1989. $appoint_info->health_audit = 4;
  1990. $appoint_info->save();
  1991. $info->save();
  1992. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1993. }else{
  1994. $data['appoint_id'] = $appoint_id;
  1995. $data['type'] = $type;
  1996. $data['h_status'] = 0;
  1997. $appoint_info->health_audit = 4;
  1998. $health_code = $request->input('health_code');
  1999. if(is_array($health_code)){
  2000. //删除掉没有成功返回路径的图片
  2001. foreach ($health_code as $k => $v){
  2002. if(!array_key_exists('response',$v)){
  2003. unset($health_code[$k]);
  2004. }
  2005. }
  2006. }
  2007. $health_result = $this->baiduService->health_code(file_get_contents(base_path() . "/public" . $health_code[0]['response']['path']));
  2008. $health_msg = ['健康码自动审核通过'];
  2009. //$h_status = 1;
  2010. //$appoint_info->health_audit = 1;
  2011. if(!array_key_exists('error_msg',$health_result) && !array_key_exists('error_code',$health_result)){
  2012. if(array_key_exists('姓名',$health_result)){
  2013. if(stripos($health_result['姓名'][0]['word'],'*')>0){
  2014. return ['status' => 0, 'msg' => '请打开健康码的“眼睛开关”,显示完整个人信息'];
  2015. }
  2016. if($health_result['姓名'][0]['word'] != $appoint_info->realname){
  2017. array_push($health_msg,'抱歉,请上传您本人的健康码!');
  2018. }
  2019. }else{
  2020. array_push($health_msg,'健康码错误,识别不到姓名!');
  2021. }
  2022. if(array_key_exists('状态',$health_result)){
  2023. if($health_result['状态'][0]['word'] != '绿码'){
  2024. array_push($health_msg,'抱歉,您的健康码非绿码!');
  2025. }
  2026. }else{
  2027. array_push($health_msg,'健康码错误,识别不到状态!');
  2028. }
  2029. if(array_key_exists('更新时间',$health_result)){
  2030. $time = strtotime($health_result['更新时间'][0]['word']);
  2031. if($time < strtotime($recruit->pen_health_start) || $time > strtotime($recruit->pen_health_end)){
  2032. array_push($health_msg,'抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的健康码!');
  2033. }
  2034. }else{
  2035. array_push($health_msg,'健康码错误,识别不到时间!');
  2036. }
  2037. //$data['h_status'] = $h_status;
  2038. $data['h_msg'] = implode(';',$health_msg);
  2039. //$appoint_info->health_audit = $h_status == 1 ? 1 : 4;
  2040. $data['health_code'] = json_encode($health_code);
  2041. }
  2042. $data['health_result'] = json_encode($health_result);
  2043. $trip_code = $request->input('trip_code');
  2044. if(is_array($trip_code)){
  2045. //删除掉没有成功返回路径的图片
  2046. foreach ($trip_code as $k => $v){
  2047. if(!array_key_exists('response',$v)){
  2048. unset($trip_code[$k]);
  2049. }
  2050. }
  2051. }
  2052. $trip_result = $this->baiduService->trip_code(file_get_contents(base_path() . "/public" . $trip_code[0]['response']['path']));
  2053. $trip_msg = [];
  2054. $trip_status = 0;
  2055. if(!array_key_exists('error_msg',$trip_result) && !array_key_exists('error_code',$trip_result)){
  2056. if(array_key_exists('途经地',$trip_result['result'])){
  2057. $fangyi_area = explode("\r\n",config('aix.fangyi.fangyi_zhaokao.fangyi_zhaokao.risk_area'));
  2058. $result = array_intersect($fangyi_area,$trip_result['result']['途经地'][0]['word']);
  2059. if(count($result) > 0){
  2060. array_push($trip_msg,'抱歉,您的行程中包含系统设置中高风险地区!');
  2061. $trip_status = 0;
  2062. }
  2063. }
  2064. if(array_key_exists('风险性',$trip_result['result']) && $trip_result['result']['风险性']){
  2065. array_push($trip_msg,'抱歉,您的行程可能含有风险!');
  2066. $trip_status = 0;
  2067. }
  2068. if(array_key_exists('更新时间',$trip_result['result'])){
  2069. $time = strtotime($trip_result['result']['更新时间'][0]['word'][0]);
  2070. if($time > strtotime($recruit->pen_health_start) || $recruit < ($recruit->pen_health_end)){
  2071. array_push($trip_msg,'抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的行程码!');
  2072. $trip_status = 0;
  2073. }
  2074. }
  2075. $data['h_msg'] .= implode(';',$trip_msg);
  2076. }
  2077. $data['trip_result'] = json_encode($trip_result);
  2078. $data['trip_code'] = json_encode($trip_code);
  2079. $data['h_status'] = 0;
  2080. $appoint_info->health_audit = 4;
  2081. RecruitSupplement::create($data);
  2082. $appoint_info->save();
  2083. return ['status' => 1, 'msg' => '提交成功,请刷新查看审核结果', 'data' => ''];
  2084. }
  2085. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  2086. }
  2087. public function post_select(Request $request)
  2088. {
  2089. $user = $this->getUser();
  2090. if (!empty($user)) {
  2091. $uid = $user->id;
  2092. } else {
  2093. return redirect(route('login'));
  2094. }
  2095. $recruit_id = $request->input('recruit_id');
  2096. //$appoint_id = $request->input('appoint_id');
  2097. $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  2098. if(!$info){
  2099. return $this->showMessage('抱歉,您无需择岗!', route('recruit.show',array('id',$recruit_id)), true, '上一页', '2');
  2100. }
  2101. //手动设置择岗时间段
  2102. $time = time();
  2103. if($time > 1663300800 || $time < 1663200000){
  2104. return $this->showMessage('抱歉,未到择岗时间!', route('recruit.show',array('id',$recruit_id)), true, '上一页', '2');
  2105. }
  2106. $option_list = [
  2107. [
  2108. 'id' => 6,
  2109. 'name' => '新塘街道'
  2110. ],
  2111. [
  2112. 'id' => 7,
  2113. 'name' => '陈埭镇'
  2114. ],
  2115. [
  2116. 'id' => 8,
  2117. 'name' => '池店镇'
  2118. ],
  2119. [
  2120. 'id' => 9,
  2121. 'name' => '安海镇'
  2122. ],
  2123. [
  2124. 'id' => 10,
  2125. 'name' => '磁灶镇'
  2126. ],
  2127. [
  2128. 'id' => 11,
  2129. 'name' => '内坑镇'
  2130. ],
  2131. [
  2132. 'id' => 13,
  2133. 'name' => '东石镇'
  2134. ],
  2135. [
  2136. 'id' => 14,
  2137. 'name' => '永和镇'
  2138. ],
  2139. [
  2140. 'id' => 15,
  2141. 'name' => '英林镇'
  2142. ],
  2143. [
  2144. 'id' => 16,
  2145. 'name' => '金井镇'
  2146. ],
  2147. [
  2148. 'id' => 17,
  2149. 'name' => '龙湖镇'
  2150. ],
  2151. [
  2152. 'id' => 18,
  2153. 'name' => '深沪镇'
  2154. ],
  2155. [
  2156. 'id' => 19,
  2157. 'name' => '西滨镇'
  2158. ]
  2159. ];
  2160. $select_list = [];
  2161. if($info->result){
  2162. $result = json_decode($info->result,true);
  2163. foreach ($result as $v){
  2164. $item['name'] = $v;
  2165. array_push($select_list,$item);
  2166. }
  2167. }
  2168. // $recruit_id = $request->input('recruit_id');
  2169. // $appoint_id = $request->input('appoint_id');
  2170. // $uid = $request->input('uid');
  2171. // $info = RecruitAppointSelect::where('uid',$uid)->first();
  2172. // if(!$info){
  2173. // $info = new \stdClass();
  2174. // $info->status = 0;
  2175. // $info->recruit_id = 8;
  2176. // $info->appoint_id = rand(0,999999);
  2177. // $info->uid = rand(0,999999);
  2178. // }else{
  2179. // $result = json_decode($info->result,true);
  2180. // foreach ($option_list as $k => $v){
  2181. // if(in_array($v['name'],$result)){
  2182. // $select_list[$k] = $v;
  2183. // unset($option_list[$k]);
  2184. // }
  2185. // }
  2186. // }
  2187. $view_data = ['info' => $info,'options_list' => json_encode($option_list),'select_list' => json_encode($select_list)];
  2188. return view('app.recruit.post_select',$view_data);
  2189. }
  2190. /**
  2191. * 放弃择岗
  2192. */
  2193. public function give_up_post(Request $request)
  2194. {
  2195. //以下为测试环境
  2196. // $recruit_id = $request->input('recruit_id');
  2197. // $appoint_id = $request->input('appoint_id');
  2198. // $uid = $request->input('uid');
  2199. // $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
  2200. // if($info){
  2201. // return ['status' => 0, 'msg' => "测试数据重复,请重新点击生成测试数据!"];
  2202. // }
  2203. // RecruitAppointSelect::create(['recruit_id'=>$recruit_id,'appoint_id'=>$appoint_id,'uid'=>$uid,'status'=>-1]);
  2204. // return ['status' => 1, 'msg' => "放弃择岗成功!"];
  2205. //以下为正式环境再放开
  2206. $user = $this->getUser();
  2207. if (!empty($user)) {
  2208. $uid = $user->id;
  2209. } else {
  2210. return redirect(route('login'));
  2211. }
  2212. $recruit_id = $request->input('recruit_id');
  2213. $appoint_id = $request->input('appoint_id');
  2214. $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
  2215. if($info == null){
  2216. return ['status' => 0, 'msg' => "抱歉,您无需择岗!"];
  2217. }
  2218. if($info->status != 0){
  2219. return ['status' => 0, 'msg' => "抱歉,您不是待择岗状态!"];
  2220. }
  2221. $info->status = -1;
  2222. $info->save();
  2223. return ['status' => 1, 'msg' => "放弃择岗成功!"];
  2224. }
  2225. public function comfirm_post(Request $request)
  2226. {
  2227. $user = $this->getUser();
  2228. if (!empty($user)) {
  2229. $uid = $user->id;
  2230. } else {
  2231. return redirect(route('login'));
  2232. }
  2233. $recruit_id = $request->input('recruit_id');
  2234. $appoint_id = $request->input('appoint_id');
  2235. $time = time();
  2236. if($time > 1663300800 || $time < 1663200000){
  2237. return $this->showMessage('抱歉,未到择岗时间!', route('recruit.show',array('id',$recruit_id)), true, '上一页', '2');
  2238. }
  2239. $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
  2240. if($info->result){
  2241. return ['status' => 0, 'msg' => "择岗数据已提交!"];
  2242. }
  2243. // $data = [
  2244. // 'recruit_id' => $recruit_id,
  2245. // 'appoint_id' => $recruit_id,
  2246. // 'uid' => $uid,
  2247. // 'status' => 1
  2248. // ];
  2249. $result = [];
  2250. $select = $request->input('select');
  2251. if(is_array($select) && count($select) > 0){
  2252. foreach ($select as $v) {
  2253. array_push($result,$v['name']);
  2254. }
  2255. }
  2256. $info->result = json_encode($result);
  2257. $info->status = 1;
  2258. $info->save();
  2259. return ['status' => 1, 'msg' => "提交择岗意愿成功,请耐心等待结果!"];
  2260. }
  2261. public function select_result(Request $request)
  2262. {
  2263. return view('app.recruit.select_result');
  2264. }
  2265. public function get_select_result(Request $request)
  2266. {
  2267. $redis = Cache::getRedis();
  2268. $quota = $redis->get('recruit_quota');
  2269. if(!$quota){
  2270. $quota = [
  2271. [
  2272. 'name' => '新塘街道',
  2273. 'value' => 13
  2274. ],
  2275. [
  2276. 'name' => '陈埭镇',
  2277. 'value' => 88
  2278. ],
  2279. [
  2280. 'name' => '池店镇',
  2281. 'value' => 10
  2282. ],
  2283. [
  2284. 'name' => '安海镇',
  2285. 'value' => 10
  2286. ],
  2287. [
  2288. 'name' => '磁灶镇',
  2289. 'value' => 21
  2290. ],
  2291. [
  2292. 'name' => '内坑镇',
  2293. 'value' => 22
  2294. ],
  2295. [
  2296. 'name' => '东石镇',
  2297. 'value' => 4
  2298. ],
  2299. [
  2300. 'name' => '永和镇',
  2301. 'value' => 27
  2302. ],
  2303. [
  2304. 'name' => '英林镇',
  2305. 'value' => 5
  2306. ],
  2307. [
  2308. 'name' => '金井镇',
  2309. 'value' => 13
  2310. ],
  2311. [
  2312. 'name' => '龙湖镇',
  2313. 'value' => 53
  2314. ],
  2315. [
  2316. 'name' => '深沪镇',
  2317. 'value' => 23
  2318. ],
  2319. [
  2320. 'name' => '西滨镇',
  2321. 'value' => 3
  2322. ]
  2323. ];
  2324. $redis->set('recruit_quota',json_encode($quota));
  2325. }else{
  2326. $quota = json_decode($quota,true);
  2327. }
  2328. $limit = $request->input('limit',1);
  2329. $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();
  2330. $return_data = [
  2331. 'list' => []
  2332. ];
  2333. $array_column = array_column($quota,'name');
  2334. foreach ($list as $k => $v){
  2335. $person_select_result = json_decode($v->result,true);
  2336. $flag = 0;//是否择岗成功
  2337. foreach ($person_select_result as $val){
  2338. //寻找下标
  2339. $index = array_search($val,$array_column);
  2340. if($quota[$index]['value'] > 0){
  2341. $quota_data = [
  2342. 'index' => $index,
  2343. 'old_value' => $quota[$index]['value']
  2344. ];
  2345. //有名额允许择岗
  2346. DB::table('recruit_appoint_select')->where('id',$v->id)->update(['select_result'=>$val,'status' => 1]);
  2347. $v->select_result = $val;
  2348. $quota[$index]['value']--;
  2349. $quota_data['new_value'] = $quota[$index]['value'];
  2350. $redis->set('recruit_quota',json_encode($quota));
  2351. $flag = 1;
  2352. break;
  2353. }
  2354. }
  2355. if(!$flag){
  2356. $v->select_result = '未匹配到志愿,本轮择岗不成功!';
  2357. DB::table('recruit_appoint_select')->where('id',$v->id)->update(['select_result'=>'未匹配到志愿,本轮择岗不成功!','status' => -2]);
  2358. }
  2359. array_push($return_data['list'],$v);
  2360. }
  2361. $return_data['quota'] = $quota_data;
  2362. return ['status' => 1, 'msg' => '择岗排序成功', 'data' => $return_data];
  2363. }
  2364. public function select_init(Request $request)
  2365. {
  2366. $count = DB::table('recruit_appoint_select')->whereRaw('select_result is null and batch = 2')->count();
  2367. $redis = Cache::getRedis();
  2368. $quota = $redis->get('recruit_quota');
  2369. if(!$quota){
  2370. $quota = [
  2371. [
  2372. 'name' => '新塘街道',
  2373. 'value' => 13
  2374. ],
  2375. [
  2376. 'name' => '陈埭镇',
  2377. 'value' => 88
  2378. ],
  2379. [
  2380. 'name' => '池店镇',
  2381. 'value' => 10
  2382. ],
  2383. [
  2384. 'name' => '安海镇',
  2385. 'value' => 10
  2386. ],
  2387. [
  2388. 'name' => '磁灶镇',
  2389. 'value' => 21
  2390. ],
  2391. [
  2392. 'name' => '内坑镇',
  2393. 'value' => 22
  2394. ],
  2395. [
  2396. 'name' => '东石镇',
  2397. 'value' => 4
  2398. ],
  2399. [
  2400. 'name' => '永和镇',
  2401. 'value' => 27
  2402. ],
  2403. [
  2404. 'name' => '英林镇',
  2405. 'value' => 5
  2406. ],
  2407. [
  2408. 'name' => '金井镇',
  2409. 'value' => 13
  2410. ],
  2411. [
  2412. 'name' => '龙湖镇',
  2413. 'value' => 53
  2414. ],
  2415. [
  2416. 'name' => '深沪镇',
  2417. 'value' => 23
  2418. ],
  2419. [
  2420. 'name' => '西滨镇',
  2421. 'value' => 3
  2422. ]
  2423. ];
  2424. $redis->set('recruit_quota',json_encode($quota));
  2425. }
  2426. $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();
  2427. return ['status' => 1, 'msg' => '获取初始化信息成功', 'data' => ['count' => $count, 'quota' => $quota, 'list' => $list]];
  2428. }
  2429. public function interviewer_random(Request $request)
  2430. {
  2431. $model = $request->input('model',1);
  2432. $number1 = $request->input('number1',5);//考官人数
  2433. $number2 = $request->input('number2',1);//替补人数
  2434. $where[] = ['id','>',0];
  2435. switch ($model){
  2436. case '0':
  2437. $list = DB::table('recruit_interviewer')->get()->toArray();
  2438. shuffle($list);
  2439. $result = array_slice($list, 0, $number1+$number2);
  2440. break;
  2441. case '1':
  2442. $list = DB::table('recruit_interviewer')->get()->toArray();
  2443. shuffle($list);
  2444. $count = $number1;
  2445. for ($i = 0; $i < $count; $i++){
  2446. if(!$list[$i]->status){
  2447. $list[] = $list[$i];
  2448. unset($list[$i]);
  2449. $count++;
  2450. }
  2451. }
  2452. $result = array_slice($list, 0, $number1+$number2);
  2453. break;
  2454. case '2':
  2455. $list = DB::table('recruit_interviewer')->where('status',1)->get()->toArray();
  2456. shuffle($list);
  2457. $result = array_slice($list, 0, $number1+$number2);
  2458. break;
  2459. default:
  2460. $list = DB::table('recruit_interviewer')->get()->toArray();
  2461. shuffle($list);
  2462. for ($i = 0; $i < $number1; $i++){
  2463. dd($list[$i]);
  2464. if(!$list[$i]->status){
  2465. $list[] = $list[$i];
  2466. unset($list[$i]);
  2467. }
  2468. }
  2469. $result = array_slice($list, 0, $number1+$number2);
  2470. break;
  2471. }
  2472. $return_data = [
  2473. 'list' => $result,
  2474. 'number1' => $number1,
  2475. 'number2' => $number2
  2476. ];
  2477. return view('app.recruit.interviewer', $return_data);
  2478. }
  2479. public function supplement_info(Request $request)
  2480. {
  2481. $user = $this->getUser();
  2482. if (!empty($user)) {
  2483. $uid = $user->id;
  2484. } else {
  2485. return redirect(route('login'));
  2486. }
  2487. //招考id
  2488. $id = $request->input('id', 0);
  2489. if (!$id) {
  2490. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  2491. }
  2492. $recruit = Recruit::find($id);
  2493. if(!$recruit['status']){
  2494. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2495. }
  2496. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  2497. if(!$appoint_info){
  2498. return $this->showMessage('抱歉,您没有报名,无需补充信息!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2499. }
  2500. $supplement_info = DB::table("recruit_supplement_cunwu")->where('uid',$uid)->where('appoint_id',$appoint_info->id)->first();
  2501. if($supplement_info){
  2502. return $this->showMessage('您已登记信息,无需再次登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2503. }
  2504. $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];//写死用户
  2505. if(!in_array($uid,$uids)){
  2506. return $this->showMessage('您无需登记信息!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2507. }
  2508. // $limit_time = 1661961599;
  2509. // $time = time();
  2510. // if( $time > $limit_time){
  2511. // return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2512. // }
  2513. $view_data = [];
  2514. //$view_data['info'] = json_encode($info);
  2515. $view_data['title'] = $recruit->company;
  2516. $view_data['id'] = $id;
  2517. return view('app.recruit.supplement_info',$view_data);
  2518. }
  2519. public function save_supplement_info(Request $request){
  2520. $user = $this->getUser();
  2521. if (!empty($user)) {
  2522. $uid = $user->id;
  2523. } else {
  2524. return redirect(route('login'));
  2525. }
  2526. //招考id
  2527. $id = $request->input('recruit_id', 0);
  2528. if (!$id) {
  2529. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2530. }
  2531. $recruit = Recruit::find($id);
  2532. if(!$recruit['status']){
  2533. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2534. }
  2535. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  2536. if(!$appoint_info){
  2537. return ['status' => 0, 'msg' => '抱歉,您没有报名,无需补充信息!', 'data' => ''];
  2538. }
  2539. if($request->input('marriage') == '已婚'){
  2540. if($request->input('spouse_card_type') == '' || $request->input('spouse_card') == '' || $request->input('spouse_realname') == '' || $request->input('spouse_mobile') == ''){
  2541. return ['status' => 0, 'msg' => '请完善配偶信息!', 'data' => ''];
  2542. }
  2543. }
  2544. $data = [
  2545. 'uid' => $uid,
  2546. 'appoint_id' => $appoint_info->id,
  2547. 'street' => $request->input('street'),
  2548. 'realname' => $request->input('realname'),
  2549. 'sex' => $request->input('sex'),
  2550. 'house' => $request->input('house'),
  2551. 'nation' => $request->input('nation'),
  2552. 'native' => $request->input('native'),
  2553. 'marriage' => $request->input('marriage'),
  2554. 'spouse_card_type' => $request->input('spouse_card_type'),
  2555. 'spouse_card' => $request->input('spouse_card'),
  2556. 'spouse_realname' => $request->input('spouse_realname'),
  2557. 'spouse_mobile' => $request->input('spouse_mobile'),
  2558. 'political' => $request->input('political'),
  2559. 'bank_card' => $request->input('bank_card'),
  2560. 'bank_open' => $request->input('bank_open'),
  2561. 'card' => $request->input('card'),
  2562. 'card_endtime' => $request->input('card_endtime'),
  2563. 'mobile' => $request->input('mobile'),
  2564. 'edu' => $request->input('education'),
  2565. 'pro' => $request->input('pro'),
  2566. 'address' => $request->input('address'),
  2567. 'funds' => $request->input('funds')
  2568. ];
  2569. DB::table('recruit_supplement_cunwu')->insert($data);
  2570. return ['status' => 1, 'msg' => '提交成功!', 'data' => ''];
  2571. }
  2572. public function comfirm_pen(Request $request){
  2573. $user = $this->getUser();
  2574. if (!empty($user)) {
  2575. $uid = $user->id;
  2576. } else {
  2577. return redirect(route('login'));
  2578. }
  2579. //招考id
  2580. $id = $request->input('recruit_id', 0);
  2581. if (!$id) {
  2582. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2583. }
  2584. $recruit = Recruit::find($id);
  2585. if(!$recruit['status']){
  2586. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2587. }
  2588. if(!$recruit->pen_comfirm){
  2589. return ['status' => 0, 'msg' => '该项目无须确认笔试考试!', 'data' => ''];
  2590. }
  2591. $appoint_info = RecruitAppointInfo::where('recruit_id',$id)->where('uid',$uid)->first();
  2592. if(!$appoint_info){
  2593. return ['status' => 0, 'msg' => '找不到您的报名记录,请检查!', 'data' => ''];
  2594. }
  2595. if($appoint_info->audit != 3){
  2596. return ['status' => 0, 'msg' => '您的报名未审核通过,无需确认!', 'data' => ''];
  2597. }
  2598. $time = time();
  2599. if(strtotime($recruit->pen_comfirm_start) > $time || strtotime($recruit->pen_comfirm_end) < $time){
  2600. return ['status' => 0, 'msg' => '未在笔试确认时间段!', 'data' => ''];
  2601. }
  2602. if($appoint_info->pen_audit != -2){
  2603. return ['status' => 0, 'msg' => '您已确认参加笔试,无需再次确认!', 'data' => ''];
  2604. }
  2605. $appoint_info->update(['pen_audit' => -1]);
  2606. $log = [
  2607. 'type' => 3,
  2608. 'appoint_id'=> $appoint_info->id,
  2609. 'uid' => $uid,
  2610. 'log' => '用户确认参加笔试'
  2611. ];
  2612. RecruitAppointLog::create($log);
  2613. return ['status' => 1, 'msg' => '确认成功', 'data' => $appoint_info->id];
  2614. }
  2615. public function supplementary_entry(Request $request){
  2616. $user = $this->getUser();
  2617. if (!empty($user)) {
  2618. $uid = $user->id;
  2619. } else {
  2620. return redirect(route('login'));
  2621. }
  2622. //招考id
  2623. $id = $request->input('recruit_id', 0);
  2624. if (!$id) {
  2625. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2626. }
  2627. $recruit = Recruit::find($id);
  2628. if(!$recruit['status']){
  2629. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2630. }
  2631. $appoint_info = RecruitAppointInfo::where('recruit_id',$id)->where('uid',$uid)->first();
  2632. if(!$appoint_info){
  2633. return ['status' => 0, 'msg' => '找不到您的报名记录,请检查!', 'data' => ''];
  2634. }
  2635. $time = time();
  2636. if($time > 1680969600){
  2637. return ['status' => 0, 'msg' => '已停止补充报名!', 'data' => ''];
  2638. }
  2639. if($appoint_info->adjust_limit){
  2640. $appoint_info->update(['adjust' => 1]);
  2641. return ['status' => 1, 'msg' => '补充报名成功!', 'data' => ''];
  2642. }else{
  2643. return ['status' => 0, 'msg' => '您无需补充报名!', 'data' => ''];
  2644. }
  2645. }
  2646. }