| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492 | <?phpnamespace App\Http\Controllers\Web\Recruit;use App\Http\Controllers\Web\WebBaseController;use App\Models\RecruitAppointLog;use App\Models\RecruitTicket;use App\Validators\RecruitValidatorRequest;use Illuminate\Http\Request;use App\Models\Recruit;use App\Services\Recruit\RecruitService;use App\Models\RecruitAppointBasic;use App\Models\RecruitSupplement;use App\Models\RecruitPost;use App\Models\RecruitAppointInfo;use think\Route;use Illuminate\Support\Facades\Validator;use Illuminate\Support\Facades\DB;use App\Models\RecruitAppointExpandSpecial;use App\Models\RecruitAppointDetail;use App\Models\RecruitArticle;use Illuminate\Support\Facades\Cache;use App\Services\Common\BaiduService;use App\Models\RecruitAppointSelect;class IndexController extends WebBaseController{    protected $recruitService,$baiduService;    public function __construct(RecruitService $recruitService,BaiduService $baiduService)    {        $this->recruitService = $recruitService;        $this->baiduService = $baiduService;    }    /**     * 招考列表页     * @param Request $request     * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View     */    public function index(Request $request)    {        $key = $request->input('key');        $list = $this->recruitService->getRecruit($key, 10);        $return_data = [            'list' => $list,            'key'  => $key,        ];        return view('app.recruit.index', $return_data);    }    /**     * 招考详情页     * @param Request $request     * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View|mixed|\think\response\Redirect|\think\response\View|void     */    public function show(Request $request)    {        $user = $this->getUser();        if($user){            $uid = $user->id;            $utype = $user->utype;        }else{            $uid = 0;            $utype = 0;        }        $id = $request->input('id', 0);        if (empty($id)) {            return $this->showMessage('抱歉,请输入指定的招考场次!', route('recruit.list'), true, '上一页', '2');        }        $recruit = Recruit::find($id);        if (empty($recruit)) {            return redirect(route('/recruit/list'));        }        $info = Recruit::parse_info($recruit);        $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();        if(!$info->isApply && $appoint_info){            $first_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->orderBy('created_at','asc')->first();            if($first_post){                $info->isApply = 1;            }        }        if($appoint_info){            //笔试            $pen_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',1)->first();            if($pen_ticket){                $pen_health = RecruitSupplement::where("appoint_id",$appoint_info->id)->where("type","pen")->where('h_status',1)->first();                if(!$pen_health){                    $appoint_info->pen_ticket = -2;                }else{                    $time = time();                    if(strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time){                        $appoint_info->pen_ticket = 1;                    }else{                        $appoint_info->pen_ticket = -1;                    }                }            }else{                $appoint_info->pen_ticket = 0;            }            //考核测试            $check_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',2)->first();            if($check_ticket){                $time = time();                if(strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time){                    $appoint_info->check_ticket = 1;                }else{                    $appoint_info->check_ticket = -1;                }            }else{                $appoint_info->check_ticket = 0;            }            //面试            $face_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',3)->first();            if($face_ticket && $appoint_info->face_audit == -1){                $face_health = RecruitSupplement::where("appoint_id",$appoint_info->id)->where("type","face")->where('h_status',1)->first();                if(!$face_health){                    $appoint_info->face_ticket = -2;                }else{                    $appoint_info->face_ticket = 1;                }            }else{                $appoint_info->face_ticket = 0;            }            //复试            $reexamine_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',4)->first();            if($reexamine_ticket && $appoint_info->reexamine_audit == -1){                $appoint_info->reexamine_ticket = 1;            }else{                $appoint_info->reexamine_ticket = 0;            }        }else{            $appoint_info = new \stdClass();            $appoint_info->pen_audit = 0;            $appoint_info->post_id = 0;            $appoint_info->pen_ticket = 0;            $appoint_info->computer_ticket = 0;            $appoint_info->face_ticket = 0;            $appoint_info->check_ticket = 0;            $appoint_info->reexamine_ticket = 0;            $appoint_info->realname = '';            $appoint_info->card = '';            $appoint_info->mobile = '';            $appoint_info->sex = 0;        }        $notice = $request->input('notice',0);        if($notice){            $public_notice_switch = 0;            $public_notice = RecruitArticle::where('id',$notice)->where('released_at','<',time())->first();            if (!empty($info)) {                $view_data = [                    'recruit' => $recruit,                    'info' => $info,                    'uid' => $uid,                    'utype' => $utype,                    'public_notice' => $public_notice,                    'public_notice_switch' => $public_notice_switch,                    'appoint_info' => $appoint_info                ];                return view('app.recruit.show')->with($view_data);            } else {                return back();            }        }else{            $list = RecruitArticle::where('recruit_id',$id)->orderBy('created_at','desc')->where('released_at','<',time())->get();            $public_notice_switch = 1;//有补充公告的模式            if (!empty($info)) {                $view_data = [                    'recruit' => $recruit,                    'info' => $info,                    'uid' => $uid,                    'utype' => $utype,                    'list' => $list,                    'public_notice_switch' => $public_notice_switch,                    'appoint_info' => $appoint_info                ];                return view('app.recruit.show')->with($view_data);            } else {                return back();            }        }    }    /**     * 上传文件的方法     * @param Request $request     * @return \Illuminate\Http\JsonResponse     */    public function upload(Request $request)    {        $user = $this->getUser();        if($user){            $uid = $user->id;            $utype = $user->utype;        }else{            $uid = 0;            $utype = 0;        }        $file = $request->file('file');        if ($file->isValid()) { //判断文件是否存在            //获取文件的扩展名            $ext = $file->getClientOriginalExtension();            if (!in_array(strtolower($ext), ['jpg', 'jpeg', 'png', 'doc', 'docx', 'pdf'])) {                $res['status'] = 0;                $res['msg']    = '文件格式不正确';            } else {                //获取文件的绝对路径                $path = $file->getRealPath();                $oldname = $file->getClientOriginalName();                //定义文件名                $filename = 'storage/recruit/' . uniqid() . mt_rand(10000, 99999) . '.' . $ext;                //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置                Storage::disk('public')->put($filename, file_get_contents($path));                $res['status']   = 1;                $res['filename'] = $oldname;                $res['path']     = "/storage/" . $filename;                $res['msg']      = '上传成功';            }        } else {            $res['status'] = 0;            $res['msg']    = '上传失败';        }        return response()->json($res);    }    /**     * 查看报名人数统计     * @param Request $request     * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View|mixed|\think\response\Redirect|\think\response\View|void     */    public function sign_up_count(Request $request)    {        $user = $this->getUser();        if($user){            $uid = $user->id;            $utype = $user->utype;        }else{            $uid = 0;            $utype = 0;        }        $id = $request->input('id', 0);        $refresh = $request->input('refresh', '');        if (empty($id)) {            return $this->showMessage('抱歉,请输入指定的招考场次!', route('recruit.list'), true, '上一页', '2');        }        $recruit = Recruit::find($id);        if (empty($recruit)) {            return redirect(route('/recruit/list'));        }        if(!$recruit->show_report){            return $this->showMessage('抱歉,该场次不允许查看报名人数统计结果!', route('recruit.list'), true, '上一页', '2');        }        if(Cache::has("sign_up_count_{$recruit->id}") && $refresh != 'jjhc2019') {            $cache_data = Cache::get("sign_up_count_{$recruit->id}");            $list = $cache_data['list'];            $time = $cache_data['time'];        }else{            $list = RecruitPost::where('recruit_id',$recruit->id)->where('status',1)->get();            if(!$list){                return $this->showMessage('抱歉,数据暂时未更新或更新出错!', route('recruit.list'), true, '上一页', '2');            }            foreach ($list as $k => $v){                $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();                $list[$k]['checking'] = $res->checking;                $list[$k]['fail'] = $res->fail;                $list[$k]['success'] = $res->success;            }            $time = date('Y-m-d H:i',time());            $cache_data = [                'list' => $list,                'time' => $time            ];            Cache::put("sign_up_count_{$recruit->id}",$cache_data,60);        }        $view_data = [            'list'  => $list,            'time' => $time        ];        return view('app.recruit.sign_up_count')->with($view_data);    }    /**     *  报名功能页     * @param Request $request     * @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     */    public function sign_up(Request $request)    {        $user = $this->getUser();        if (!empty($user)) {            $uid = $user->id;        } else {            return redirect(route('login'));        }        //招考id        $id = $request->input('id', 0);        if (!$id) {            return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');        }        //招考信息        $recruit = Recruit::find($id);        if(!$recruit['status'] && !$user->recruit_test){            return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');        }        if($recruit['current'] != 1){            return $this->showMessage('抱歉,该项目报名通道已关闭,如有疑问,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');        }        $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();        $time = time();        $formDisabled = 0;        if(($time < strtotime($recruit['apply_start']) || strtotime($recruit['apply_end']) < $time)){//过了招考时间            if(!in_array($uid,[161027,59041])){                if(!$appoint_info){                    return $this->showMessage('抱歉,该项目已过报名时间或尚未开始!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');                }                if($appoint_info){                    //如果有报名记录,先查询首次报名是什么时候                    $first_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->where('appoint_id',$appoint_info->id)->orderBy('created_at','asc')->first();                    if(!$first_post){//没有记录代表只是暂存                        return $this->showMessage('抱歉,该项目已过报名时间或尚未开始!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');                    }//                $has_late_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->where('created_at','>',$recruit['apply_end'])->first();//查找在过了报名时间后,有报名记录,且仍是审核失败的报名记录,看其是否在报名时间后是否有再次提交的记录//                if($has_late_post){//                    $formDisabled = 1;//                }else{//                    $formDisabled = 0;//                }                }            }        }        $view_data['module'] = $forms = explode(',', $recruit['forms']);        //查询报名表是否已有记录        if($appoint_info){            if(in_array('internship',$forms)) {                //如果已有该场次的报名记录,读取录入的数据集合                $user_info = $appoint_info;                $user_info['sex'] = (string)$user_info['sex'];                $user_info['adjust'] = (string)$user_info['adjust'];                $user_info['edu_type'] = (string)$user_info['edu_type'];                $user_info['family'] = json_decode($user_info['family']);                $detail = RecruitAppointDetail::where('recruit_appoint_id',$user_info['id'])->first();                if($detail){                    $user_info['detail'] = $detail->toArray();                }else{                    $user_info['detail'] = [                        'rewards_and_punishments' => '',                        'introduce' => ''                    ];                }                if(json_decode($user_info['identification'])){                    $identification = json_decode($user_info['identification'],true);                    foreach ($identification as $k => $v){                        if(array_key_exists('response',$v)){                            $identification[$k]['url'] = $v['response']['path'];                        }                    }                }else{                    $identification = [];                }                $user_info['identification'] = $identification;                if(json_decode($user_info['education_certification'])){                    $education_certification = json_decode($user_info['education_certification'],true);                    foreach ($education_certification as $k => $v){                        if(array_key_exists('response',$v)){                            $education_certification[$k]['url'] = $v['response']['path'];                        }                    }                }else{                    $education_certification = [];                }                $user_info['education_certification'] = $education_certification;                if(json_decode($user_info['other_certification'])){                    $other_certification = json_decode($user_info['other_certification'],true);                    foreach ($other_certification as $k => $v){                        if(array_key_exists('response',$v)){                            $other_certification[$k]['url'] = $v['response']['path'];                        }                    }                }else{                    $other_certification = [];                }                $user_info['other_certification'] = $other_certification;                //获取最新的报名审核信息                $logs = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',2)->orderBy('created_at','desc')->first();                if($logs){                    $user_info['audit_log'] = $logs->log;                }else{                    $user_info['audit_log'] = '';                }            }else{                //如果已有该场次的报名记录,读取录入的数据集合                $user_info = $appoint_info;                $user_info['sex'] = (string)$user_info['sex'];                $user_info['edu_type'] = (string)$user_info['edu_type'];                $user_info['family'] = json_decode($user_info['family']);                if(in_array('expand_special',$forms)){                    $special = RecruitAppointExpandSpecial::where('recruit_appoint_id',$user_info['id'])->first();                    if($special){                        $material = json_decode($special['material'],true);                        if(is_array($material)){                            foreach ($material as $k => $v){                                if(array_key_exists('response',$v)){                                    if(array_key_exists('path',$v['response'])){                                        $material[$k]['url'] = $v['response']['path'];                                    }                                }                            }                        }                    }else{                        $material = [];                        $special = [                            'point_apply' => '0',                            'condition' => ''                        ];                    }                    $user_info['special'] = [                        'point_apply'   =>  (string)$special['point_apply'],                        'condition'     =>  $special['condition'],                        'material'      =>  $material                    ];                }                if(in_array('detail',$forms)){                    $detail = RecruitAppointDetail::where('recruit_appoint_id',$user_info['id'])->first();                    if($detail){                        $user_info['detail'] = $detail->toArray();                    }else{                        $user_info['detail'] = [                            'train' =>  '',                            'rewards_and_punishments' => '',                            'introduce' => ''                        ];                    }                }                //如果有身份证明模块                if(in_array('identification',$forms)){                    if(json_decode($user_info['identification'])){                        $identification = json_decode($user_info['identification'],true);                        foreach ($identification as $k => $v){                            if(array_key_exists('response',$v)){                                if(array_key_exists('path',$v['response'])){                                    $identification[$k]['url'] = $v['response']['path'];                                }                            }                        }                    }else{                        $identification = [];                    }                    $user_info['identification'] = $identification;                }                //如果有教育证明模块                if(in_array('education_certification',$forms)){                    if(json_decode($user_info['education_certification'])){                        $education_certification = json_decode($user_info['education_certification'],true);                        foreach ($education_certification as $k => $v){                            if(array_key_exists('response',$v)){                                if(array_key_exists('path',$v['response'])){                                    $education_certification[$k]['url'] = $v['response']['path'];                                }                            }                        }                    }else{                        $education_certification = [];                    }                    $user_info['education_certification'] = $education_certification;                }                //如果有其他证明模块                if(in_array('other_certification',$forms)){                    if(json_decode($user_info['other_certification'])){                        $other_certification = json_decode($user_info['other_certification'],true);                        foreach ($other_certification as $k => $v){                            if(array_key_exists('response',$v)){                                if(array_key_exists('path',$v['response'])){                                    $other_certification[$k]['url'] = $v['response']['path'];                                }                            }                        }                    }else{                        $other_certification = [];                    }                    $user_info['other_certification'] = $other_certification;                }                //获取最新的报名审核信息                $logs = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',2)->orderBy('created_at','desc')->first();                if($logs){                    $user_info['audit_log'] = $logs->log;                }else{                    $user_info['audit_log'] = '';                }                //获取提交报名的次数//                $number = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',3)->count();//                $post_number = $number+1;//todo            }        }        else{            //实习专场            if(in_array('internship',$forms)){                $user_info = json_encode([                    'recruit_id' => $id,                    'operation' => 1,                    'realname' => '',                    'sex' => '1',                    'birthday' => '',                    'card' => '',                    'nation' => '',                    'native_place' => '',                    'political_affiliation' => '',                    'join_time' => '',                    'house_register' => '',                    'education' => '',                    'school' => '',                    'pro' => '',                    'adjust' => '',                    'mobile' => '',                    'email' => '',                    'address' => '',                    'post_id' => '',                    'concat_name' => '',                    'concat_mobile' => '',                    'resume' => '',                    'avatar' => '',                    'family' => [                        [                            'relation' => '',                            'realname' => '',                            'birthday' => '',                            'political_affiliation' => '',                            'work' => ''                        ]                    ],                    'detail' => [                        'rewards_and_punishments'   =>  '',                        'introduce'                 =>  ''                    ],                    'identification' => [],                    'education_certification' => [],                    'other_certification' => []                ]);            }else{                //如果没有,结合基础数据及模块表单信息,制作数据对象                $user_info = RecruitAppointBasic::where('uid',$uid)->first();                if(!$user_info){                    //没有基础信息跳转完善route('person.recruitInfo')                    return $this->showMessage('请先完善招考基础信息!', route('recruit.recruitInfo',array('recruit_id',$id)), true, '上一页', '3');                }                $user_info['sex'] = (string)$user_info['sex'];                $user_info['edu_type'] = (string)$user_info['edu_type'];                $user_info['family'] = json_decode($user_info['family']);                if(in_array('expand_special',$forms)){                    $user_info['special'] = [                        'point_apply'   =>  '0',                        'condition'     =>  '',                        'material'      =>  []                    ];                }                if(in_array('detail',$forms)){                    $user_info['detail'] = [                        'train'                     =>  '',                        'rewards_and_punishments'   =>  '',                        'introduce'                 =>  ''                    ];                }                if(in_array('identification',$forms)){                    $user_info['identification'] = [];                }                if(in_array('education_certification',$forms)){                    $user_info['education_certification'] = [];                }                if(in_array('other_certification',$forms)){                    $user_info['other_certification'] = [];                }                $user_info['recruit_id'] = $id;                $user_info['operation'] = 1;            }        }        //招考岗位        $where_post[] = ['recruit_id', '=', $id];        $where_post[] = ['status', '=', 1];        $recruit_post = RecruitPost::where($where_post)->get();        $post = [];        $post_limit = [];        foreach ($recruit_post as $value){            $item = [                'value' =>  $value['id'],                'label' =>  $value['code'] . " " . $value['name']            ];            $post_limit[$value['id']] = json_decode($value['limit']);            array_push($post,$item);        }        $view_data['appoint_info'] = $user_info;        $view_data['post'] = json_encode($post);//        $view_data['post_number'] = $post_number;//        $view_data['post_times'] = $recruit['post_times'];        $view_data['post_limit'] = json_encode($post_limit);        $view_data['formDisable'] = $formDisabled;        $view_data['title'] = $recruit->company;        return view('app.recruit.sign_up',$view_data);    }    public function preview(Request $request)    {        $modules = $request->input('modules');        $view_data['module'] = $forms = explode(',', $modules);        return view('app.recruit.preview',$view_data);    }    /**     * 提交报名的处理程序     * @param Request $request     * @return array|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\think\response\Redirect|void     */    public function saveSignUp(Request $request)    {        $user = $this->getUser();        if (!empty($user)) {            $uid = $user->id;        } else {            return redirect(route('login'));        }        $recruit_id = $request->input('recruit_id', 0);        if (!$recruit_id) {            return response()->json(['status' => 0,'msg' => '请选择项目!']);        }        $recruit = Recruit::find($recruit_id);        if(!$recruit['status']){            return response()->json(['status' => 0,'msg' => '抱歉,该项目状态不正确,请联系客服!']);        }        if($recruit['current'] != 1){            return response()->json(['status' => 0,'msg' => '抱歉,该项目报名通道已关闭,如有疑问,请联系客服!']);        }        $card = $request->input('card');        $appointinfo_exist = RecruitAppointInfo::where('card',$card)->where('uid','<>',$uid)->where('recruit_id',$recruit_id)->first();        if($appointinfo_exist){            return response()->json(['status' => 0,'msg' => '您的证件已有其他账号的报名记录,请检查!']);        }        $time = time();        $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();        if(($time < strtotime($recruit['apply_start']) || strtotime($recruit['apply_end']) < $time)){//过了招考时间            if($appoint_info){                //如果有报名记录,先查询首次报名是什么时候                $first_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->orderBy('created_at','asc')->first();                if(!$first_post){//没有记录代表只是暂存                    return response()->json(['status' => 0,'msg' => '抱歉,该项目已过报名时间!']);                }            }            if(!$appoint_info){                return response()->json(['status' => 0,'msg' => '抱歉,该项目已过报名时间!']);            }        }        //基础信息的检查        $rules = [            'realname' => 'required',            'sex' => 'required',            'birthday' => 'required',            'avatar' => 'required',            'nation' => 'required',            'native_place' => 'required',            'political_affiliation' => 'required',            'post_id'   =>  'required',            'house_register' => 'required',            //'edu_type' => 'required',            'education' => 'required',            'school' => 'required',            'address' => 'required',            'mobile' => 'required',            'email' => 'required',            'card' => 'required',            'concat_name' => 'required',            'concat_mobile' => 'required',            'resume' => 'required'        ];        $messages = [            'realname.required' => '请填写姓名',            'sex.required' => '请填写性别',            'birthday.required' => '请填写出生日期',            'avatar.required' => '请上传彩色免冠照',            'nation.required' => '请填写民族',            'native_place.required' => '请填写籍贯',            'political_affiliation.required' => '请选择政治面貌',            'post_id.required' => '请选择报名岗位',            'house_register.required' => '请填写户籍所在地',            //'edu_type.required' => '请选择教育类型',            'education.required' => '请输入学历',            'school.required' => '请输入毕业院校',            'address.required' => '请填写通信地址',            'mobile.required' => '请填写手机号码',            'email.required' => '请填写电子邮箱',            'card.required' => '请填写身份证号码',            'resume.required' => '请填写个人简历',            'concat_name.required' => '请填写联系人姓名',            'concat_mobile.required' => '请填写联系人手机号码'        ];        $create_data = $request->all();        $validator = Validator::make($create_data,$rules,$messages);        if ($validator->fails()) {            $msg = $validator->errors()->all();            return response()->json(['status' => 0,'msg' => $msg[0]]);        }else{            $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');            //身份证判断出生日期和性别            $year = substr($data['card'],6,4);            $month = substr($data['card'],10,2);            $day = substr($data['card'],12,2);            if($year.'-'.$month.'-'.$day != $data['birthday']){                $data['birthday'] = $year.'-'.$month.'-'.$day;            }            if(intval(substr($data['card'],16,1)) % 2 == 0){                $data['sex'] = 0;            }else{                $data['sex'] = 1;            }            $post_info = RecruitPost::where('id',$data['post_id'])->where('recruit_id',$recruit_id)->first();            if(!$post_info['status'] || $post_info['deleted_at'] != null){                return response()->json(['status' => 0,'msg' => '该岗位已失效']);            }            //获取操作符,是暂存还是提交            $operation = $request->input('operation');            if($operation == 1){                $data['audit'] = 0;//暂存            }else{                $data['audit'] = 1;//提交            }            if(!empty($post_info['limit']) && json_decode($post_info['limit'])){                //岗位限制条件的判断                $post_limit = json_decode($post_info['limit'],true);                if(is_array($post_limit)){                    foreach($post_limit as $k => $v){                        if($k == 'birthday'){                            $value = str_replace('-','',$data[$k]);                        }else{                            $value = $data[$k];                        }                        switch ($v['op']){                            case '=':                                if($value != $v['value']){                                    return response()->json(['status' => 0,'msg' => $v['msg']]);                                }                                break;                            case '>':                                if($value <= $v['value']){                                    return response()->json(['status' => 0,'msg' => $v['msg']]);                                }                                break;                            case '>=':                                if($value < $v['value']){                                    return response()->json(['status' => 0,'msg' => $v['msg']]);                                }                                break;                            case '<':                                if($value >= $v['value']){                                    return response()->json(['status' => 0,'msg' => $v['msg']]);                                }                                break;                            case '<=':                                if($value > $v['value']){                                    return response()->json(['status' => 0,'msg' => $v['msg']]);                                }                                break;                            case '!=':                                if($value == $v['value']){                                    return response()->json(['status' => 0,'msg' => $v['msg']]);                                }                                break;                            case 'like':                                if(strpos($value,$v['value']) === false){                                    return response()->json(['status' => 0,'msg' => $v['msg']]);                                }                                break;                            case 'in':                                if(strpos($v['value'],$value) === false){                                    return response()->json(['status' => 0,'msg' => $v['msg']]);                                }                                break;                        }                    }                }            }            //前置审核 判断完成,先将数据入报名信息基础表            //解析家庭成员数据            $familys = $request->input('family');            $family = [];            if(is_array($familys)){                foreach ($familys as $value){                    $item = [                        'relation'  =>  $value['relation'],                        'realname'  =>  $value['realname'],                        'birthday'  =>  $value['birthday'],                        'political_affiliation' =>  $value['political_affiliation'],                        'work'  =>  $value['work']                    ];                    array_push($family,$item);                }            }            $data['family'] = json_encode($family);            if($appoint_info){                //如果已有报名记录,进入修改阶段的处理流程                DB::beginTransaction();                try{                    RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->update($data);                    //分模块解析数据                    $forms = explode(',', $recruit['forms']);                    //如果有加分模块                    if(in_array('expand_special',$forms)){                        $special = $request->input('special');                        if($special['point_apply']){                            //删除掉没有成功返回路径的图片                            if(is_array($special['material'])){                                foreach ($special['material'] as $k => $v){                                    if(!array_key_exists('response',$v)){                                        unset($special['material'][$k]);                                    }                                }                            }                            $special['material'] = json_encode($special['material']);                        }else{                            $special['condition'] = '';                            $special['material'] = json_encode([]);                        }                        $hasRecord = RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint_info->id)->first();                        if($hasRecord){                            RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint_info->id)->update($special);                        }else{                            $special['recruit_appoint_id'] = $appoint_info->id;                            RecruitAppointExpandSpecial::create($special);                        }                    }                    //如果有详情模块                    if(in_array('detail',$forms) || in_array('internship',$forms)){                        $detail = $request->input('detail');                        $hasRecord = RecruitAppointDetail::where('recruit_appoint_id',$appoint_info->id)->first();                        if($hasRecord){                            RecruitAppointDetail::where('recruit_appoint_id',$appoint_info->id)->update($detail);                        }else{                            $detail['recruit_appoint_id'] = $appoint_info->id;                            RecruitAppointDetail::create($detail);                        }                    }                    //如果有身份证明模块                    if(in_array('identification',$forms) || in_array('internship',$forms)){                        $identification = $request->input('identification');                        if(is_array($identification)){                            //删除掉没有成功返回路径的图片                            foreach ($identification as $k => $v){                                if(!array_key_exists('response',$v)){                                    unset($identification[$k]);                                }                            }                        }                        $appoint_info->identification = json_encode($identification);                        $appoint_info->save();                    }                    //如果有教育证明模块                    if(in_array('education_certification',$forms) || in_array('internship',$forms)){                        $education_certification = $request->input('education_certification');                        if(is_array($education_certification)){                            //删除掉没有成功返回路径的图片                            foreach ($education_certification as $k => $v){                                if(!array_key_exists('response',$v)){                                    unset($education_certification[$k]);                                }                            }                        }                        $appoint_info->education_certification = json_encode($education_certification);                        $appoint_info->save();                    }                    //如果有其他证明模块                    if(in_array('other_certification',$forms) || in_array('internship',$forms)){                        $other_certification = $request->input('other_certification');                        if(is_array($other_certification)){                            //删除掉没有成功返回路径的图片                            foreach ($other_certification as $k => $v){                                if(!array_key_exists('response',$v)){                                    unset($other_certification[$k]);                                }                            }                        }                        if($other_certification){                            $appoint_info->other_certification = json_encode($other_certification);                            $appoint_info->save();                        }                    }                    DB::commit();                    if($operation == 2){                        $log = [                            'type'      =>  3,                            'appoint_id'=>  $appoint_info->id,                            'uid'       =>  $uid,                            'log'       =>  '用户提交报名'                        ];                        RecruitAppointLog::create($log);                        return ['status' => 1, 'msg' => '提交成功', 'data' => $appoint_info->id];                    }else{                        return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $appoint_info->id];                    }                } catch (\Exception $e){                    DB::rollback();                    return ['status' => 0, 'msg' => $e->getMessage()];                }            }else{                //没有报名记录,进入增加阶段的处理流程                DB::beginTransaction();                try{                    //20220726增加地区undefined选项处理                    if($index = stripos($data['native_place'],',undefined')){                        $data['native_place'] = substr($data['native_place'],0,$index);                    }                    if($index = stripos($data['house_register'],',undefined')){                        $data['house_register'] = substr($data['house_register'],0,$index);                    }                    $data['uid'] = $uid;                    $data['recruit_id'] = $recruit_id;                    $result = RecruitAppointInfo::create($data);                    //分模块解析数据                    $forms = explode(',', $recruit['forms']);                    //如果有加分模块                    if(in_array('expand_special',$forms)){                        $special = $request->input('special');                        if($special['point_apply']){                            if(is_array($special['material'])){                                //删除掉没有成功返回路径的图片                                foreach ($special['material'] as $k => $v){                                    if(!array_key_exists('response',$v)){                                        unset($special['material'][$k]);                                    }                                }                            }                            $special['material'] = json_encode($special['material']);                        }                        $special['recruit_appoint_id'] = $result->id;                        RecruitAppointExpandSpecial::create($special);                    }                    //如果有详情模块                    if(in_array('detail',$forms)  || in_array('internship',$forms)){                        $detail = $request->input('detail');                        $detail['recruit_appoint_id'] = $result->id;                        RecruitAppointDetail::create($detail);                    }                    //如果有身份证明模块                    if(in_array('identification',$forms)  || in_array('internship',$forms)){                        $identification = $request->input('identification');                        if(is_array($identification)){                            //删除掉没有成功返回路径的图片                            foreach ($identification as $k => $v){                                if(!array_key_exists('response',$v)){                                    unset($identification[$k]);                                }                            }                        }                        $result->identification = json_encode($identification);                        $result->save();                    }                    //如果有教育证明模块                    if(in_array('education_certification',$forms)  || in_array('internship',$forms)){                        $education_certification = $request->input('education_certification');                        if(is_array($education_certification)){                            //删除掉没有成功返回路径的图片                            foreach ($education_certification as $k => $v){                                if(!array_key_exists('response',$v)){                                    unset($education_certification[$k]);                                }                            }                        }                        $result->education_certification = json_encode($education_certification);                        $result->save();                    }                    //如果有其他证明模块                    if(in_array('other_certification',$forms)  || in_array('internship',$forms)){                        $other_certification = $request->input('other_certification');                        if($other_certification){                            if(is_array($other_certification)){                                //删除掉没有成功返回路径的图片                                foreach ($other_certification as $k => $v){                                    if(!array_key_exists('response',$v)){                                        unset($other_certification[$k]);                                    }                                }                            }                            $result->other_certification = json_encode($other_certification);                            $result->save();                        }                    }                    DB::commit();                    if($operation == 2){                        $log = [                            'type'      =>  3,                            'appoint_id'=>  $result->id,                            'uid'       =>  $uid,                            'log'       =>  '用户首次提交报名'                        ];                        RecruitAppointLog::create($log);                        return ['status' => 1, 'msg' => '提交成功', 'data' => $result->id];                    }else{                        return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $result->id];                    }                } catch (\Exception $e){                    DB::rollback();                    return ['status' => 0, 'msg' => $e->getMessage()];                }            }        }    }    /**     * 获得当前登录的用户     * @return \Illuminate\Contracts\Auth\Authenticatable|null     */    public function getUser()    {        if (auth('web-member')->check()) {            $user = auth('web-member')->user();        } else {            $user = null;        }        return $user;    }    /**     * 检查用户基本信息     * @return array     */    public function checkUserBasicInfo()    {        $user = $this->getUser();        if (!empty($user)) {            $uid = $user->id;        } else {            $arr = ['status' => 401, 'msg'=>'请登录!'];            return $arr;        }        $info = RecruitAppointBasic::where('uid',$uid)->first();        if (empty($info)){            $arr = ['status'=>401,'msg'=>'请先完善招考基本信息','url'=> route('recruit.recruitInfo')];            return $arr;        }        return ['status' => 200, 'msg' => ''];    }    /**     * 个人中心招考页面     * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View     */    public function person_recruit()    {        $user = auth('web-member')->user();        $list = RecruitAppointInfo::where('uid',$user->id)            ->join('recruit', 'recruit.id', '=', 'recruit_appoint_info.recruit_id', 'left')            ->join('recruit_post', 'recruit_post.id', '=', 'recruit_appoint_info.post_id', 'left')            ->select('recruit.name as recruit_name','recruit_appoint_info.*','recruit_post.code','recruit_post.name')            ->get();        return view('app.person.recruit')->with(['list' => $list,'total' => count($list)]);    }    /**     * 招考信息基础页     * @param Request $request     * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View     */    public function recruit_info(Request $request)    {        $user = auth('web-member')->user();        if (!empty($user)) {            $uid = $user->id;        } else {            return redirect(route('login'));        }        $info = RecruitAppointBasic::where('uid',$user->id)->first();        if(!$info){            $info = [                'realname' => '',                'sex' => '0',                'birthday' => '',                'avatar' => '',                'nation' => '',                'native_place' => '',                'political_affiliation' => '',                'titles' => '',                'work' => '',                'house_register' => '',                'join_time' => '',                'edu_type' => '',                'education' => '',                'school' => '',                'degree' => '',                'pro' => '',                'address' => '',                'card' => '',                'mobile' => '',                'email' => '',                'concat_name' => '',                'concat_mobile' => '',                'resume' => '',                'family' => [                    [                        'relation' => '',                        'realname' => '',                        'birthday' => '',                        'political_affiliation' => '',                        'work' => ''                    ]                ],                'is_push' => '1'            ];        }else{            $info->sex = (string)$info->sex;            $info->edu_type = (string)$info->edu_type;            $info->is_push = (string)$info->is_push;            $info->family = empty($info->family) ? [[                                                        'relation' => '',                                                        'realname' => '',                                                        'birthday' => '',                                                        'political_affiliation' => '',                                                        'work' => ''                                                    ]] : json_decode($info->family);        }        $recruit_id = $request->input('recruit_id',0);        return view('app.person.recruit_info',[            'info'      =>  json_encode($info),            'recruit_id'=>  $recruit_id        ]);    }    /**     * 保存招考信息     * @param RecruitValidatorRequest $request     * @return \Illuminate\Http\JsonResponse     */    public function saveRecruitInfo(RecruitValidatorRequest $request)    {        $user = auth('web-member')->user();        $basic = RecruitAppointBasic::where('uid',$user->id)->first();        $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');        if(count($data['family']) > 0){            $data['family'] = json_encode($data['family']);        }        if($basic){            //更新基础信息            $res = RecruitAppointBasic::where('uid',$user->id)->update($data);            if (!$res) {                return response()->json(['status'=>0,'msg'=>'保存失败,请联系客服']);            }else{                return response()->json(['status'=>1,'msg'=>'个人基础信息保存成功,快去报名吧!']);            }        }else{            //新增基础信息            $data['uid'] = $user->id;            $res = RecruitAppointBasic::create($data);            if (!$res) {                return response()->json(['status'=>0,'msg'=>'保存失败,请联系客服']);            }else{                return response()->json(['status'=>1,'msg'=>'个人基础信息保存成功,快去报名吧!']);            }        }    }    /**     * 笔试准考证     * @param Request $request     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View     */    public function pen_ticket(Request $request)    {        $user = $this->getUser();        if (!empty($user)) {            $uid = $user->id;        } else {            return $this->showMessage('请登录!', route('home'), true, '上一页', '3');        }        $recruit_id = $request->input('recruit_id');        $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();        if($appoint_info){            $pen_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',1)->first();            if($pen_ticket){                $health = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();                if(!$health || $health->h_status == 0){                    return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');                }                $time = time();                if(strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time){                    RecruitTicket::where('appoint_id',$appoint_info->id)->update(['ex_status' => 1]);                    $recruit = Recruit::where('id',$recruit_id)->first();                    $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');                    $name = $recruit->name_en;                    $date = date("Y-m-d",strtotime($recruit->created_at));                    $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];                    $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/pen/" . $filename . '.pdf';                    if(file_exists($file)){                        header('Content-Description: File Transfer');                        header('Content-Type: application/octet-stream');                        header('Content-Disposition: attachment; filename='.basename($file));                        header('Content-Transfer-Encoding: binary');                        header('Expires: 0');                        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');                        header('Pragma: public');                        header('Content-Length: ' . filesize($file));                        ob_clean();   //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a                        flush();                        readfile($file);                    }                }else{                    return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');                }            }else{                return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');            }        }else{            return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');        }    }    /**     * 审核准考证     * @param Request $request     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View     */    public function check_ticket(Request $request)    {        $user = $this->getUser();        if (!empty($user)) {            $uid = $user->id;        } else {            return $this->showMessage('请登录!', route('home'), true, '上一页', '3');        }        $recruit_id = $request->input('recruit_id');        $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();        if($appoint_info){            $check_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',2)->first();            if($check_ticket){                $time = time();                if(strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time){                    RecruitTicket::where('appoint_id',$appoint_info->id)->update(['ex_status' => 1]);                    $recruit = Recruit::where('id',$recruit_id)->first();                    $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');                    $name = $recruit->name_en;                    $date = date("Y-m-d",strtotime($recruit->created_at));                    $filename = date("Y-m-18",time()) . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];                    $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/check/" . $filename . '.pdf';                    if(file_exists($file)){                        header('Content-Description: File Transfer');                        header('Content-Type: application/octet-stream');                        header('Content-Disposition: attachment; filename='.basename($file));                        header('Content-Transfer-Encoding: binary');                        header('Expires: 0');                        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');                        header('Pragma: public');                        header('Content-Length: ' . filesize($file));                        ob_clean();   //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a                        flush();                        readfile($file);                    }                }else{                    return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');                }            }else{                return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');            }        }else{            return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');        }    }    /**     * 面试准考证     * @param Request $request     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View     */    public function face_ticket(Request $request)    {        $user = $this->getUser();        if (!empty($user)) {            $uid = $user->id;        } else {            return $this->showMessage('请登录!', route('home'), true, '上一页', '3');        }        $recruit_id = $request->input('recruit_id');        $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();        if($appoint_info){            $face_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',3)->first();            if($face_ticket){                $health = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();                if(!$health || $health->h_status == 0){                    return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');                }                $time = time();                if(strtotime($face_ticket->ex_start) < $time && strtotime($face_ticket->ex_end) > $time){                    RecruitTicket::where('id',$face_ticket->id)->update(['ex_status' => 1]);                    $recruit = Recruit::where('id',$recruit_id)->first();                    $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');                    $name = $recruit->name_en;                    $date = date("Y-m-d",strtotime($recruit->created_at));                    $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];                    $file = base_path() . "/storage/app/public/recruit/ticket/word/{$date}/{$name}/face/" . $filename . '.docx';                    if(file_exists($file)){                        header('Content-Description: File Transfer');                        header('Content-Type: application/octet-stream');                        header('Content-Disposition: attachment; filename='.basename($file));                        header('Content-Transfer-Encoding: binary');                        header('Expires: 0');                        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');                        header('Pragma: public');                        header('Content-Length: ' . filesize($file));                        ob_clean();   //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a                        flush();                        readfile($file);                    }                }else{                    return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');                }            }else{                return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');            }        }else{            return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');        }    }    /**     * 复试准考证     * @param Request $request     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View     */    public function reexamine_ticket(Request $request)    {        $user = $this->getUser();        if (!empty($user)) {            $uid = $user->id;        } else {            return $this->showMessage('请登录!', route('home'), true, '上一页', '3');        }        $recruit_id = $request->input('recruit_id');        $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();        if($appoint_info){            $reexamine_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',4)->first();            if($reexamine_ticket){                $time = time();                if(strtotime($reexamine_ticket->ex_start) < $time && strtotime($reexamine_ticket->ex_end) > $time){                    RecruitTicket::where('id',$reexamine_ticket->id)->update(['ex_status' => 1]);                    $recruit = Recruit::where('id',$recruit_id)->first();                    $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');                    $name = $recruit->name_en;                    $date = date("Y-m-d",strtotime($recruit->created_at));                    $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id].'_create';                    $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';                    if(file_exists($file)){                        header('Content-Description: File Transfer');                        header('Content-Type: application/octet-stream');                        header('Content-Disposition: attachment; filename='.basename($file));                        header('Content-Transfer-Encoding: binary');                        header('Expires: 0');                        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');                        header('Pragma: public');                        header('Content-Length: ' . filesize($file));                        ob_clean();   //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a                        flush();                        readfile($file);                    }                }else{                    return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');                }            }else{                return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');            }        }else{            return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');        }    }    /**     * 材料补登     * @param Request $request     */    public function material_supplement(Request $request)    {        $user = $this->getUser();        if (!empty($user)) {            $uid = $user->id;        } else {            return redirect(route('login'));        }        //招考id        $id = $request->input('id', 0);        if (!$id) {            return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');        }        $recruit = Recruit::find($id);        if(!$recruit['status'] && !$user->recruit_test){            return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');        }        $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();        if(!$appoint_info){            return $this->showMessage('抱歉,您没有报名,无需考察审核!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');        }        if($appoint_info->pen_audit != 1){            return $this->showMessage('抱歉,您未入闱,无需考察审核!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');        }        $limit_time = 1662543000;        $time = time();        if( $time > $limit_time){            return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');        }        $info = RecruitSupplement::where('appoint_id',$appoint_info->id)->where('type','supplement')->first();        if(!$info){            $info = [                'appoint_id' => $appoint_info->id,                'identification' => '',                'household_register' => '',                'education_certification' => '',                //'family_planning' => '',                'manage' => '',                'status' => 3            ];        }else{            $info = $info->toArray();            if(json_decode($info['identification'])){                $identification = json_decode($info['identification'],true);                foreach ($identification as $k => $v){                    if(array_key_exists('response',$v)){                        $identification[$k]['url'] = $v['response']['path'];                    }                }            }else{                $identification = [];            }            $info['identification'] = $identification;            if(json_decode($info['household_register'])){                $household_register = json_decode($info['household_register'],true);                foreach ($household_register as $k => $v){                    if(array_key_exists('response',$v)){                        $household_register[$k]['url'] = $v['response']['path'];                    }                }            }else{                $household_register = [];            }            $info['household_register'] = $household_register;            if(json_decode($info['education_certification'])){                $education_certification = json_decode($info['education_certification'],true);                foreach ($education_certification as $k => $v){                    if(array_key_exists('response',$v)){                        $education_certification[$k]['url'] = $v['response']['path'];                    }                }            }else{                $education_certification = [];            }            $info['education_certification'] = $education_certification;            if(json_decode($info['family_planning'])){                $family_planning = json_decode($info['family_planning'],true);                foreach ($family_planning as $k => $v){                    if(array_key_exists('response',$v)){                        $family_planning[$k]['url'] = $v['response']['path'];                    }                }            }else{                $family_planning = [];            }            $info['family_planning'] = $family_planning;            if(json_decode($info['manage'])){                $manage = json_decode($info['manage'],true);                foreach ($manage as $k => $v){                    if(array_key_exists('response',$v)){                        $manage[$k]['url'] = $v['response']['path'];                    }                }            }else{                $manage = [];            }            $info['manage'] = $manage;        }        $view_data['info'] = json_encode($info);        $view_data['title'] = $recruit->company;        return view('app.recruit.supplement',$view_data);    }    /**     * 健康信息登记     * @param Request $request     */    public function health_info(Request $request)    {        $user = $this->getUser();        if (!empty($user)) {            $uid = $user->id;        } else {            return redirect(route('login'));        }        //招考id        $id = $request->input('id', 0);        if (!$id) {            return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');        }        $recruit = Recruit::find($id);        if(!$recruit['status'] && !$user->recruit_test){            return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');        }        $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();        if(!$appoint_info){            return $this->showMessage('抱歉,您没有报名,无需登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');        }        if($appoint_info->audit != 3){            return $this->showMessage('抱歉,您无需登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');        }        $time = time();        $type = $request->input('type',null);        $where = [];        if($type){            switch ($type){                case 'pen':                    $start = strtotime($recruit->pen_health_start);                    $end = strtotime($recruit->pen_health_end);                    break;                case 'computer':                    $start = strtotime($recruit->computer_health_start);                    $end = strtotime($recruit->computer_health_end);                    break;                case 'face':                    $start = strtotime($recruit->face_health_start);                    $end = strtotime($recruit->face_health_end);                    break;                default:                    $start = strtotime($recruit->supplement_start);                    $end = strtotime($recruit->supplement_end);                    break;            }            $where[] = ['type', '=', $type];        }else{            $start = strtotime($recruit->supplement_start);            $end = strtotime($recruit->supplement_end);        }        if($time > $end || $time < $start){            return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');        }        $where[] = ['appoint_id', '=', $appoint_info->id];        $info = RecruitSupplement::where($where)->first();        if(!$info){            $info = [                'appoint_id' => $appoint_info->id,                'health_code' => '',                'trip_code' => '',                'type' => $type            ];        }else{            $info = $info->toArray();            if(json_decode($info['health_code'])){                $health_code = json_decode($info['health_code'],true);                foreach ($health_code as $k => $v){                    if(array_key_exists('response',$v)){                        $health_code[$k]['url'] = $v['response']['path'];                    }                }            }else{                $health_code = [];            }            $info['health_code'] = $health_code;            if(json_decode($info['trip_code'])){                $trip_code = json_decode($info['trip_code'],true);                foreach ($trip_code as $k => $v){                    if(array_key_exists('response',$v)){                        $trip_code[$k]['url'] = $v['response']['path'];                    }                }            }else{                $trip_code = [];            }            $info['trip_code'] = $trip_code;        }        $view_data['info'] = json_encode($info);        $view_data['title'] = $recruit->company;        return view('app.recruit.health',$view_data);    }    public function save_supplement(Request $request)    {        $user = $this->getUser();        if (!empty($user)) {            $uid = $user->id;        } else {            return redirect(route('login'));        }        $limit_time = 1662543000;        $time = time();        if( $time > $limit_time){            return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',18)), true, '上一页', '3');        }        $appoint_id = $request->input('appoint_id');        $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',18)->where('id',$appoint_id)->first();        if(!$appoint_info){            return ['status' => 0, 'msg' => '抱歉,找不到您要补登的报名记录!'];        }        $info = RecruitSupplement::where('appoint_id',$appoint_id)->where('type','supplement')->first();        if($info){            if($info->status == 1){                return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];            }            if($info->status == 0){                return ['status' => 0, 'msg' => '材料审核中,不允许修改'];            }            //身份证明            $identification = $request->input('identification');            if(is_array($identification)){                //删除掉没有成功返回路径的图片                foreach ($identification as $k => $v){                    if(!array_key_exists('response',$v)){                        unset($identification[$k]);                    }                }            }            $info->identification = json_encode($identification);            //户口簿            $household_register = $request->input('household_register');            if(is_array($household_register)){                //删除掉没有成功返回路径的图片                foreach ($household_register as $k => $v){                    if(!array_key_exists('response',$v)){                        unset($household_register[$k]);                    }                }            }            $info->household_register = json_encode($household_register);            //学信网            $education_certification = $request->input('education_certification');            if(is_array($education_certification)){                //删除掉没有成功返回路径的图片                foreach ($education_certification as $k => $v){                    if(!array_key_exists('response',$v)){                        unset($education_certification[$k]);                    }                }            }            $info->education_certification = json_encode($education_certification);            //计生//            $family_planning = $request->input('family_planning');//            if(is_array($family_planning)){//                //删除掉没有成功返回路径的图片//                foreach ($family_planning as $k => $v){//                    if(!array_key_exists('response',$v)){//                        unset($family_planning[$k]);//                    }//                }//            }//            $info->family_planning = json_encode($family_planning);            //综治            $manage = $request->input('manage');            if(is_array($manage)){                //删除掉没有成功返回路径的图片                foreach ($manage as $k => $v){                    if(!array_key_exists('response',$v)){                        unset($manage[$k]);                    }                }            }            $info->manage = json_encode($manage);            $info->status = 0;            $info->save();            $appoint_info->political_audit = 4;            $appoint_info->save();            return ['status' => 1, 'msg' => '提交成功', 'data' => ''];        }else{            $data['appoint_id'] = $appoint_id;            //身份证明            $identification = $request->input('identification');            if(is_array($identification)){                //删除掉没有成功返回路径的图片                foreach ($identification as $k => $v){                    if(!array_key_exists('response',$v)){                        unset($identification[$k]);                    }                }            }            $data['identification'] = json_encode($identification);            //户口簿            $household_register = $request->input('household_register');            if(is_array($household_register)){                //删除掉没有成功返回路径的图片                foreach ($household_register as $k => $v){                    if(!array_key_exists('response',$v)){                        unset($household_register[$k]);                    }                }            }            $data['household_register'] = json_encode($household_register);            //学信网            $education_certification = $request->input('education_certification');            if(is_array($education_certification)){                //删除掉没有成功返回路径的图片                foreach ($education_certification as $k => $v){                    if(!array_key_exists('response',$v)){                        unset($education_certification[$k]);                    }                }            }            $data['education_certification'] = json_encode($education_certification);            //计生//            $family_planning = $request->input('family_planning');//            if(is_array($family_planning)){sp//                //删除掉没有成功返回路径的图片//                foreach ($family_planning as $k => $v){//                    if(!array_key_exists('response',$v)){//                        unset($family_planning[$k]);//                    }//                }//            }//            $data['family_planning'] = json_encode($family_planning);            //综治            $manage = $request->input('manage');            if(is_array($manage)){                //删除掉没有成功返回路径的图片                foreach ($manage as $k => $v){                    if(!array_key_exists('response',$v)){                        unset($manage[$k]);                    }                }            }            $data['manage'] = json_encode($manage);            $data['status'] = 0;            $data['type'] = 'supplement';            $result = RecruitSupplement::create($data);            $appoint_info->political_audit = 4;            $appoint_info->save();            return ['status' => 1, 'msg' => '提交成功', 'data' => ''];        }        return ['status' => 0, 'msg' => 'test', 'data' => ''];    }    public function save_healthinfo(Request $request)    {        $user = $this->getUser();        if (!empty($user)) {            $uid = $user->id;        } else {            return redirect(route('login'));        }        $appoint_id = $request->input('appoint_id');        $type = $request->input('type');        $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('id',$appoint_id)->first();        if(!$appoint_info){            return ['status' => 0, 'msg' => '抱歉,找不到您要登记的报名记录!'];        }        $recruit = Recruit::where('id',$appoint_info->recruit_id)->first();        $info = RecruitSupplement::where('appoint_id',$appoint_id)->where('type',$type)->first();        if($info){            if($info->h_status == 1){                return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];            }            if($info->h_status == 0){                return ['status' => 0, 'msg' => '材料审核中,不允许修改'];            }            $health_code = $request->input('health_code');            if(is_array($health_code)){                //删除掉没有成功返回路径的图片                foreach ($health_code as $k => $v){                    if(!array_key_exists('response',$v)){                        unset($health_code[$k]);                    }                }            }            $info->health_code = json_encode($health_code);            $trip_code = $request->input('trip_code');            if(is_array($trip_code)){                //删除掉没有成功返回路径的图片                foreach ($trip_code as $k => $v){                    if(!array_key_exists('response',$v)){                        unset($trip_code[$k]);                    }                }            }            $info->trip_code = json_encode($trip_code);            $info->h_status = 0;            $appoint_info->health_audit = 4;            $appoint_info->save();            $info->save();            return ['status' => 1, 'msg' => '提交成功', 'data' => ''];        }else{            $data['appoint_id'] = $appoint_id;            $data['type'] = $type;            $data['h_status'] = 0;            $appoint_info->health_audit = 4;            $health_code = $request->input('health_code');            if(is_array($health_code)){                //删除掉没有成功返回路径的图片                foreach ($health_code as $k => $v){                    if(!array_key_exists('response',$v)){                        unset($health_code[$k]);                    }                }            }            $health_result = $this->baiduService->health_code(file_get_contents(base_path() . "/public" . $health_code[0]['response']['path']));            $health_msg = ['健康码自动审核通过'];            //$h_status = 1;            //$appoint_info->health_audit = 1;            if(!array_key_exists('error_msg',$health_result) && !array_key_exists('error_code',$health_result)){                if(array_key_exists('姓名',$health_result)){                    if(stripos($health_result['姓名'][0]['word'],'*')>0){                        return ['status' => 0, 'msg' => '请打开健康码的“眼睛开关”,显示完整个人信息'];                    }                    if($health_result['姓名'][0]['word'] != $appoint_info->realname){                        array_push($health_msg,'抱歉,请上传您本人的健康码!');                    }                }else{                    array_push($health_msg,'健康码错误,识别不到姓名!');                }                if(array_key_exists('状态',$health_result)){                    if($health_result['状态'][0]['word'] != '绿码'){                        array_push($health_msg,'抱歉,您的健康码非绿码!');                    }                }else{                    array_push($health_msg,'健康码错误,识别不到状态!');                }                if(array_key_exists('更新时间',$health_result)){                    $time = strtotime($health_result['更新时间'][0]['word']);                    if($time < strtotime($recruit->pen_health_start) || $time > strtotime($recruit->pen_health_end)){                        array_push($health_msg,'抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的健康码!');                    }                }else{                    array_push($health_msg,'健康码错误,识别不到时间!');                }                //$data['h_status'] = $h_status;                $data['h_msg'] = implode(';',$health_msg);                //$appoint_info->health_audit = $h_status == 1 ? 1 : 4;                $data['health_code'] = json_encode($health_code);            }            $data['health_result'] = json_encode($health_result);            $trip_code = $request->input('trip_code');            if(is_array($trip_code)){                //删除掉没有成功返回路径的图片                foreach ($trip_code as $k => $v){                    if(!array_key_exists('response',$v)){                        unset($trip_code[$k]);                    }                }            }            $trip_result = $this->baiduService->trip_code(file_get_contents(base_path() . "/public" . $trip_code[0]['response']['path']));            $trip_msg = [];            $trip_status = 0;            if(!array_key_exists('error_msg',$trip_result) && !array_key_exists('error_code',$trip_result)){                if(array_key_exists('途经地',$trip_result['result'])){                    $fangyi_area = explode("\r\n",config('aix.fangyi.fangyi_zhaokao.fangyi_zhaokao.risk_area'));                    $result = array_intersect($fangyi_area,$trip_result['result']['途经地'][0]['word']);                    if(count($result) > 0){                        array_push($trip_msg,'抱歉,您的行程中包含系统设置中高风险地区!');                        $trip_status = 0;                    }                }                if(array_key_exists('风险性',$trip_result['result']) && $trip_result['result']['风险性']){                    array_push($trip_msg,'抱歉,您的行程可能含有风险!');                    $trip_status = 0;                }                if(array_key_exists('更新时间',$trip_result['result'])){                    $time = strtotime($trip_result['result']['更新时间'][0]['word'][0]);                    if($time > strtotime($recruit->pen_health_start) || $recruit < ($recruit->pen_health_end)){                        array_push($trip_msg,'抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的行程码!');                        $trip_status = 0;                    }                }                $data['h_msg'] .= implode(';',$trip_msg);            }            $data['trip_result'] = json_encode($trip_result);            $data['trip_code'] = json_encode($trip_code);            $data['h_status'] = 0;            $appoint_info->health_audit = 4;            RecruitSupplement::create($data);            $appoint_info->save();            return ['status' => 1, 'msg' => '提交成功,请刷新查看审核结果', 'data' => ''];        }        return ['status' => 0, 'msg' => 'test', 'data' => ''];    }    public function post_select(Request $request)    {        $user = $this->getUser();        if (!empty($user)) {            $uid = $user->id;        } else {            return redirect(route('login'));        }        $recruit_id = $request->input('recruit_id');        //$appoint_id = $request->input('appoint_id');        $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->first();        if(!$info){            return $this->showMessage('抱歉,您无需择岗!', route('recruit.show',array('id',$recruit_id)), true, '上一页', '2');        }        //手动设置择岗时间段        $time = time();        if($time > 1663300800 || $time < 1663200000){            return $this->showMessage('抱歉,未到择岗时间!', route('recruit.show',array('id',$recruit_id)), true, '上一页', '2');        }        $option_list = [            [                'id' => 6,                'name' => '新塘街道'            ],            [                'id' => 7,                'name' => '陈埭镇'            ],            [                'id' => 8,                'name' => '池店镇'            ],            [                'id' => 9,                'name' => '安海镇'            ],            [                'id' => 10,                'name' => '磁灶镇'            ],            [                'id' => 11,                'name' => '内坑镇'            ],            [                'id' => 13,                'name' => '东石镇'            ],            [                'id' => 14,                'name' => '永和镇'            ],            [                'id' => 15,                'name' => '英林镇'            ],            [                'id' => 16,                'name' => '金井镇'            ],            [                'id' => 17,                'name' => '龙湖镇'            ],            [                'id' => 18,                'name' => '深沪镇'            ],            [                'id' => 19,                'name' => '西滨镇'            ]        ];        $select_list = [];        if($info->result){            $result = json_decode($info->result,true);            foreach ($result as $v){                $item['name'] = $v;                array_push($select_list,$item);            }        }//        $recruit_id = $request->input('recruit_id');//        $appoint_id = $request->input('appoint_id');//        $uid = $request->input('uid');//        $info = RecruitAppointSelect::where('uid',$uid)->first();//        if(!$info){//            $info = new \stdClass();//            $info->status = 0;//            $info->recruit_id = 8;//            $info->appoint_id = rand(0,999999);//            $info->uid = rand(0,999999);//        }else{//            $result = json_decode($info->result,true);//            foreach ($option_list as $k => $v){//                if(in_array($v['name'],$result)){//                    $select_list[$k] = $v;//                    unset($option_list[$k]);//                }//            }//        }        $view_data = ['info' => $info,'options_list' => json_encode($option_list),'select_list' => json_encode($select_list)];        return view('app.recruit.post_select',$view_data);    }    /**     * 放弃择岗     */    public function give_up_post(Request $request)    {        //以下为测试环境//        $recruit_id = $request->input('recruit_id');//        $appoint_id = $request->input('appoint_id');//        $uid = $request->input('uid');//        $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();//        if($info){//            return ['status' => 0, 'msg' => "测试数据重复,请重新点击生成测试数据!"];//        }//        RecruitAppointSelect::create(['recruit_id'=>$recruit_id,'appoint_id'=>$appoint_id,'uid'=>$uid,'status'=>-1]);//        return ['status' => 1, 'msg' => "放弃择岗成功!"];        //以下为正式环境再放开        $user = $this->getUser();        if (!empty($user)) {            $uid = $user->id;        } else {            return redirect(route('login'));        }        $recruit_id = $request->input('recruit_id');        $appoint_id = $request->input('appoint_id');        $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();        if($info == null){            return ['status' => 0, 'msg' => "抱歉,您无需择岗!"];        }        if($info->status != 0){            return ['status' => 0, 'msg' => "抱歉,您不是待择岗状态!"];        }        $info->status = -1;        $info->save();        return ['status' => 1, 'msg' => "放弃择岗成功!"];    }    public function comfirm_post(Request $request)    {        $user = $this->getUser();        if (!empty($user)) {            $uid = $user->id;        } else {            return redirect(route('login'));        }        $recruit_id = $request->input('recruit_id');        $appoint_id = $request->input('appoint_id');        $time = time();        if($time > 1663300800 || $time < 1663200000){            return $this->showMessage('抱歉,未到择岗时间!', route('recruit.show',array('id',$recruit_id)), true, '上一页', '2');        }        $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();        if($info->result){            return ['status' => 0, 'msg' => "择岗数据已提交!"];        }//        $data = [//            'recruit_id' => $recruit_id,//            'appoint_id' => $recruit_id,//            'uid' => $uid,//            'status' => 1//        ];        $result = [];        $select = $request->input('select');        if(is_array($select) && count($select) > 0){            foreach ($select as $v) {                array_push($result,$v['name']);            }        }        $info->result = json_encode($result);        $info->status = 1;        $info->save();        return ['status' => 1, 'msg' => "提交择岗意愿成功,请耐心等待结果!"];    }    public function select_result(Request $request)    {        return view('app.recruit.select_result');    }    public function get_select_result(Request $request)    {        $redis = Cache::getRedis();        $quota = $redis->get('recruit_quota');        if(!$quota){            $quota = [                [                    'name' => '新塘街道',                    'value' => 13                ],                [                    'name' => '陈埭镇',                    'value' => 88                ],                [                    'name' => '池店镇',                    'value' => 10                ],                [                    'name' => '安海镇',                    'value' => 10                ],                [                    'name' => '磁灶镇',                    'value' => 21                ],                [                    'name' => '内坑镇',                    'value' => 22                ],                [                    'name' => '东石镇',                    'value' => 4                ],                [                    'name' => '永和镇',                    'value' => 27                ],                [                    'name' => '英林镇',                    'value' => 5                ],                [                    'name' => '金井镇',                    'value' => 13                ],                [                    'name' => '龙湖镇',                    'value' => 53                ],                [                    'name' => '深沪镇',                    'value' => 23                ],                [                    'name' => '西滨镇',                    'value' => 3                ]            ];            $redis->set('recruit_quota',json_encode($quota));        }else{            $quota = json_decode($quota,true);        }        $limit = $request->input('limit',1);        $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')->select(['b.realname','c.ex_number','a.result','a.select_result','a.id'])->orderBy('record','desc')->limit($limit)->get();        $return_data = [            'list' => []        ];        $array_column = array_column($quota,'name');        foreach ($list as $k => $v){            $person_select_result = json_decode($v->result,true);            $flag = 0;//是否择岗成功            foreach ($person_select_result as $val){                //寻找下标                $index = array_search($val,$array_column);                if($quota[$index]['value'] > 0){                    $quota_data = [                        'index' => $index,                        'old_value' => $quota[$index]['value']                    ];                    //有名额允许择岗                    DB::table('recruit_appoint_select')->where('id',$v->id)->update(['select_result'=>$val,'status' => 1]);                    $v->select_result = $val;                    $quota[$index]['value']--;                    $quota_data['new_value'] = $quota[$index]['value'];                    $redis->set('recruit_quota',json_encode($quota));                    $flag = 1;                    break;                }            }            if(!$flag){                $v->select_result = '未匹配到志愿,本轮择岗不成功!';                DB::table('recruit_appoint_select')->where('id',$v->id)->update(['select_result'=>'未匹配到志愿,本轮择岗不成功!','status' => -2]);            }            array_push($return_data['list'],$v);        }        $return_data['quota'] = $quota_data;        return ['status' => 1, 'msg' => '择岗排序成功', 'data' => $return_data];    }    public function select_init(Request $request)    {        $count = DB::table('recruit_appoint_select')->whereRaw('select_result is null')->count();        $redis = Cache::getRedis();        $quota = $redis->get('recruit_quota');        if(!$quota){            $quota = [                [                    'name' => '新塘街道',                    'value' => 13                ],                [                    'name' => '陈埭镇',                    'value' => 88                ],                [                    'name' => '池店镇',                    'value' => 10                ],                [                    'name' => '安海镇',                    'value' => 10                ],                [                    'name' => '磁灶镇',                    'value' => 21                ],                [                    'name' => '内坑镇',                    'value' => 22                ],                [                    'name' => '东石镇',                    'value' => 4                ],                [                    'name' => '永和镇',                    'value' => 27                ],                [                    'name' => '英林镇',                    'value' => 5                ],                [                    'name' => '金井镇',                    'value' => 13                ],                [                    'name' => '龙湖镇',                    'value' => 53                ],                [                    'name' => '深沪镇',                    'value' => 23                ],                [                    'name' => '西滨镇',                    'value' => 3                ]            ];            $redis->set('recruit_quota',json_encode($quota));        }        $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();        return ['status' => 1, 'msg' => '获取初始化信息成功', 'data' => ['count' => $count, 'quota' => $quota, 'list' => $list]];    }    public function interviewer_random(Request $request)    {        $model = $request->input('model',1);        $number1 = $request->input('number1',5);//考官人数        $number2 = $request->input('number2',1);//替补人数        $where[] = ['id','>',0];        switch ($model){            case '0':                $list = DB::table('recruit_interviewer')->get()->toArray();                shuffle($list);                $result = array_slice($list, 0, $number1+$number2);                break;            case '1':                $list = DB::table('recruit_interviewer')->get()->toArray();                shuffle($list);                $count = $number1;                for ($i = 0; $i < $count; $i++){                    if(!$list[$i]->status){                        $list[] = $list[$i];                        unset($list[$i]);                        $count++;                    }                }                $result = array_slice($list, 0, $number1+$number2);                break;            case '2':                $list = DB::table('recruit_interviewer')->where('status',1)->get()->toArray();                shuffle($list);                $result = array_slice($list, 0, $number1+$number2);                break;            default:                $list = DB::table('recruit_interviewer')->get()->toArray();                shuffle($list);                for ($i = 0; $i < $number1; $i++){                    dd($list[$i]);                    if(!$list[$i]->status){                        $list[] = $list[$i];                        unset($list[$i]);                    }                }                $result = array_slice($list, 0, $number1+$number2);                break;        }        $return_data = [            'list' => $result,            'number1'  => $number1,            'number2' => $number2        ];        return view('app.recruit.interviewer', $return_data);    }    public function supplement_info(Request $request)    {        $user = $this->getUser();        if (!empty($user)) {            $uid = $user->id;        } else {            return redirect(route('login'));        }        //招考id        $id = $request->input('id', 0);        if (!$id) {            return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');        }        $recruit = Recruit::find($id);        if(!$recruit['status']){            return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');        }        $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();        if(!$appoint_info){            return $this->showMessage('抱歉,您没有报名,无需补充信息!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');        }        $supplement_info = DB::table("recruit_supplement_cunwu")->where('uid',$uid)->where('appoint_id',$appoint_info->id)->first();        if($supplement_info){            return $this->showMessage('您已登记信息,无需再次登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');        }        $uids = [180131,170456,180420,181219,176611,165056,179319,180017,181038,157997,56037,180716,165577,143359,160996,160992,169181,169756,177332,180009,180372,177010,180873,176816,179710,176473,180772,161237,179647,179820,169538,180952,161312,179180,179860,179153,181167,180338,176012,179725,169290,179831,180763,179789,179452,180727,180116,179035,179604,180012,170097,180343,179377,177494,179979,179849,165925,179437,166707,179903,175913,180909,180768,179346,168537,179062,56587,176341,181109,179488,179631,152152,181333,179239,179824,180351,179197,179420,169267,179599,179911,179558,180438,179113,180092,177444,176080,180439,152003,179906,171437,180934,179229,180115,179271,181271,179212,180922,180342,149615,56397,180928,180100,118705,169907,180081,180388,179124,179827,180079,180447,176989,176141,180668,167931,179837,177161,180408,179150,168267,176552,166974,179355,179537,179455,176402,170155,180579,179858,179065,148962,180530,179236,180025,179093,179494,176367,179905,170269,179314,168987,179913,175409,170282,179214,170222,148841,180973,180308,179740,179559,168476,169446,169482,180807,57454,179724,180780,179563,179427,180355,169888,180525,176041,181304,180931,180467,179064,179765,176318,179843,180160,149459,177465,180364,177501,176309,180320,180341,176892,169700,179633,179073,176306,157884,180967,146658,177113,175640,100717,175856,179082,179363,179324,179812,180511,176860,169063,175583,180660,180575,179334,169678,176879,180181,164932,179839,169203,179988,179585,179535,179202,180444,179117,180670,176908,176050,179445,180307,180970,176441,179359,169258,181192,180837,179818,179429,176289,180665,180038,100819,179735,180760,179263,179162,179842,180552,179116,175692,180781,179921,56408,180662,179364,175655,175664,179221,149402,180628,181075,176099,180383,179900,180272,179736,175831,179618,180632,179732,179070,176047,158563,179176,176840,179602,180300,179974,163067,176920,179224,157975,176363,180332,175686,179430,180540,179951,180811,176530,148778,163040,168141,179681,157966,181087,180104,176501,179280,179342,176945,179798,181057,179702,179518,179094,178397,180682,167478,159637,177278,176618,170435,180071,175696,165565,180419,169206,151445,158475,179515,179619,169498,180518,164967,180824,181348,170434,180034,150318,179348,180919,169192,177470,180183,181033,175700,180413,180520,180890,176054,150705,179166,175711,176292,180577,180502,180312,180354,180592,180117,180722,176957,179086,180741,170582,179522,181243,180367,162858,180281,179976,176756,181203,180585,179907,180955,170581,173221,169387,169885,179143,180658,180335,173361,179053,181019,179791,179159,181295,179686,177143,181098,176320,179332,179867,180108,169745,180220,176422,180521,180504,169162,181352,176089,176706,180751,179570,169645,176471,179829,176425,176492,179083,179926,179438,181238,165513,179817,181197,179047,169577,180984,180789,176220,176251,180409,175683,181111,175728,179326,180201,179776,175929,179663,179220,157887,179509,179451,181027,180193,179935,176105,177219,179345,179415,179587,180871,179550,179838,179098,159792,179938,179586,179092,177148,177367,181255,181220,169567,175924,180901,179278,158774,170314,173276,179253,179532,176740,176897,57739,181236,179120,169238,179142,177236,179033,180441,175988,176336,181200,180975,180738,179864,178808,179493,179434,179235,180402,179584,180297,177094,179749,180317,176777,180777,180833,180489,176001,167507,181010,181067,180584,180600,177108,179302,180206,180228,176469,180872,176804,181066,180820,181346,179426,168773,180074,177062,176434,179141,180411,175564,169682,179826,181199,179320,179303,180134,57130,180598,179998,177086,175910,176515,176862,181170,179204,180764,180120,176418,169004,158752,179614,176466,179947,151188,181091,179328,180231,180090,177315,175893,180999,179890,179963,179716,180466,175772,181222,179277,180328,179551,177071,177044,177307,180787,179641,179401,175673,176013,181049,180371,176884,165782,179227,179944,175985,179090,180275,180015,180216,168005,180483,161561,180829,180326,179447,162298,179111,175953,170429,179675,180118,180037,56388,170185,56158,180113,181008,175699,168947,180708,177284,180847,181073,179874,180908,179836,177021,177339,179063,179636,180109,175706,180395,165082,180554,180432,179884,180152,176914,150652,179392,180204,170270,179691,162547,137427,181168,180759,179330,181039,180268,169867,176855,180233,179121,180276,180850,180503,176063,178222,180205,180446,179108,176997,179496,180868,176640,179689,179556,181261,179684,179249,180618,162067,180290,175899,169193,180857,167728,179194,180635,177184,181162,169940,176104,179190,180260,176507,180680,180798,179876,179327];//写死用户        if(!in_array($uid,$uids)){            return $this->showMessage('您无需登记信息!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');        }//        $limit_time = 1661961599;//        $time = time();//        if( $time > $limit_time){//            return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');//        }        $view_data = [];        //$view_data['info'] = json_encode($info);        $view_data['title'] = $recruit->company;        $view_data['id'] = $id;        return view('app.recruit.supplement_info',$view_data);    }    public function save_supplement_info(Request $request){        $user = $this->getUser();        if (!empty($user)) {            $uid = $user->id;        } else {            return redirect(route('login'));        }        //招考id        $id = $request->input('recruit_id', 0);        if (!$id) {            return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];        }        $recruit = Recruit::find($id);        if(!$recruit['status']){            return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];        }        $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();        if(!$appoint_info){            return ['status' => 0, 'msg' => '抱歉,您没有报名,无需补充信息!', 'data' => ''];        }        if($request->input('marriage') == '已婚'){            if($request->input('spouse_card_type') == '' || $request->input('spouse_card') == '' || $request->input('spouse_realname') == '' || $request->input('spouse_mobile') == ''){                return ['status' => 0, 'msg' => '请完善配偶信息!', 'data' => ''];            }        }        $data = [            'uid' => $uid,            'appoint_id' => $appoint_info->id,            'street' => $request->input('street'),            'realname' => $request->input('realname'),            'sex' => $request->input('sex'),            'house' => $request->input('house'),            'nation' => $request->input('nation'),            'native' => $request->input('native'),            'marriage' => $request->input('marriage'),            'spouse_card_type' => $request->input('spouse_card_type'),            'spouse_card' => $request->input('spouse_card'),            'spouse_realname' => $request->input('spouse_realname'),            'spouse_mobile' => $request->input('spouse_mobile'),            'political' => $request->input('political'),            'bank_card' => $request->input('bank_card'),            'bank_open' => $request->input('bank_open'),            'card' => $request->input('card'),            'card_endtime' => $request->input('card_endtime'),            'mobile' => $request->input('mobile'),            'edu' => $request->input('education'),            'pro' => $request->input('pro'),            'address' => $request->input('address'),            'funds' => $request->input('funds')        ];        DB::table('recruit_supplement_cunwu')->insert($data);        return ['status' => 1, 'msg' => '提交成功!', 'data' => ''];    }}
 |