IndexController.php 117 KB

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