123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044 |
- <?php
- namespace 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\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;
- class IndexController extends WebBaseController
- {
- protected $recruitService;
- public function __construct(RecruitService $recruitService)
- {
- $this->recruitService = $recruitService;
- }
- /**
- * 招考列表页
- * @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){
- $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){
- $appoint_info->face_ticket = 1;
- }else{
- $appoint_info->face_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->realname = '';
- $appoint_info->card = '';
- $appoint_info->mobile = '';
- }
- $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 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']){
- 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(!$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){
- //如果已有该场次的报名记录,读取录入的数据集合
- $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(json_decode($special['material'])){
- $material = json_decode($special['material'],true);
- foreach ($material as $k => $v){
- if(array_key_exists('response',$v)){
- $material[$k]['url'] = $v['response']['path'];
- }
- }
- }else{
- $material = [];
- }
- $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)){
- $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)){
- $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)){
- $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{
- $post_number = 1;
- //如果没有,结合基础数据及模块表单信息,制作数据对象
- $user_info = RecruitAppointBasic::where('uid',$uid)->first();
- if(!$user_info){
- //没有基础信息跳转完善route('person.recruitInfo')
- return $this->showMessage('请先完善招考基础信息!', route('person.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];
- $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);
- }
- /**
- * 提交报名的处理程序
- * @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' => '抱歉,该招考报名通道已关闭,如有疑问,请联系客服!']);
- }
- $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');
- //身份证判断出生日期和性别
- $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['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)){
- $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)){
- $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)){
- $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)){
- $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{
- $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)){
- $detail = $request->input('detail');
- $detail['recruit_appoint_id'] = $result->id;
- RecruitAppointDetail::create($detail);
- }
- //如果有身份证明模块
- if(in_array('identification',$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)){
- $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)){
- $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;
- }
- 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' => ''];
- }
- 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)]);
- }
- public function recruit_info(Request $request)
- {
- $user = auth('web-member')->user();
- $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
- ]);
- }
- 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'=>'个人基础信息保存成功,快去报名吧!']);
- }
- }
- }
- 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){
- $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("Y-m-17",time()) . '_' . $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 . '_create.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');
- }
- }
- 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');
- }
- }
- 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){
- $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].'_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');
- }
- }
- }
|