| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525 | 
							- <?php
 
- namespace App\Admin\Controllers\Person;
 
- use App\Http\Controllers\Controller;
 
- use App\Models\Jobs;
 
- use App\Models\MemberInfo;
 
- use App\Models\PersonalJobsApply;
 
- use App\Models\Resume;
 
- use App\Models\Subsite;
 
- use App\Repositories\JobsRepository;
 
- use App\Repositories\PersonJobsApplyRepository;
 
- use Encore\Admin\Controllers\HasResourceActions;
 
- use Encore\Admin\Facades\Admin;
 
- use Encore\Admin\Form;
 
- use Encore\Admin\Grid;
 
- use Encore\Admin\Layout\Content;
 
- use Encore\Admin\Show;
 
- class JobsApplyController extends Controller
 
- {
 
-     use HasResourceActions;
 
-     /**
 
-      * Index interface.
 
-      *
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function index(Content $content)
 
-     {
 
-         return $content
 
-             ->header('申请职位')
 
-             ->description('列表')
 
-             ->body($this->grid());
 
-     }
 
-     /**
 
-      * Show interface.
 
-      *
 
-      * @param mixed $id
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function show($id, Content $content)
 
-     {
 
-         return $content
 
-             ->header('申请职位')
 
-             ->description('详细')
 
-             ->body($this->detail($id));
 
-     }
 
-     /**
 
-      * Edit interface.
 
-      *
 
-      * @param mixed $id
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function edit($id, Content $content)
 
-     {
 
-         return $content
 
-             ->header('申请职位')
 
-             ->description('编辑')
 
-             ->body($this->editForm($id)->edit($id));
 
-     }
 
-     /**
 
-      * Create interface.
 
-      *
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function create(Content $content)
 
-     {
 
-         return $content
 
-             ->header('申请职位')
 
-             ->description('创建')
 
-             ->body($this->createForm());
 
-     }
 
-     /**
 
-      * Make a grid builder.
 
-      *
 
-      * @return Grid
 
-      */
 
-     protected function grid()
 
-     {
 
-         $grid = new Grid(new PersonalJobsApply);
 
-         $grid->model()->when(get_subsite_id()>0, function ($query) {
 
-             $query->whereHas('resumes', function ($query) {
 
-                 $query->where('subsite_id', get_subsite_id());
 
-             });
 
-         })->orderBy('id', 'desc');
 
-         $grid->id('ID');
 
-         $grid->jobs_name('职位名称')->width(200);
 
-         $grid->company_name('公司名称')->width(200);
 
-         $grid->resume_name('简历名称')->width(150);
 
-         $grid->is_reply('反馈状态')->display(function ($is_reply) {
 
-             switch ($is_reply) {
 
-                 case 1:
 
-                     $is_reply = '企业未查看';
 
-                     break;
 
-                 case 2:
 
-                     $is_reply = '待反馈';
 
-                     break;
 
-                 case 3:
 
-                     $is_reply = '合适';
 
-                     break;
 
-                 case 4:
 
-                     $is_reply = '不合适';
 
-                     break;
 
-                 case 5:
 
-                     $is_reply = '待定';
 
-                     break;
 
-                 case 6:
 
-                     $is_reply = '未接通';
 
-                     break;
 
-                 default:
 
-                     $is_reply = '企业未查看';
 
-                     break;
 
-             }
 
-             return $is_reply;
 
-         });
 
-         $grid->column('members.subsite_id', '所属分站')->display(function ($subsite_id) {
 
-             if ($subsite_id) {
 
-                 $Subsite = Subsite::find($subsite_id);
 
-                 return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
 
-             }
 
-             return '总站';
 
-         })->width(150);
 
-         $grid->created_at('申请时间')->sortable();
 
-         $grid->updated_at('更新时间')->sortable();
 
-         $grid->actions(function ($actions) use ($grid) {
 
-             if (Admin::user()->can('person_apply_jobs_delete')) {
 
-                 $actions->disableDelete(false);
 
-             }
 
-         });
 
-         if (Admin::user()->can('person_apply_jobs_delete')) {
 
-             $grid->tools(function ($tools) {
 
-                 $tools->batch(function ($batch) {
 
-                     $batch->disableDelete(false);
 
-                 });
 
-             });
 
-             $grid->disableRowSelector(false);
 
-         }
 
-         $grid->filter(function ($filter) {
 
-             $filter->disableIdFilter();
 
-             $filter->where(function ($query) {
 
-                 switch ($this->input) {
 
-                     case 1:
 
-                         $query->whereRaw(" is_reply =".$this->input);
 
-                         break;
 
-                     case 2:
 
-                         $query->whereRaw(" is_reply =".$this->input);
 
-                         break;
 
-                     case 3:
 
-                         $query->whereRaw(" is_reply =".$this->input);
 
-                         break;
 
-                     case 4:
 
-                         $query->whereRaw(" is_reply =".$this->input);
 
-                         break;
 
-                     case 5:
 
-                         $query->whereRaw(" is_reply =".$this->input);
 
-                         break;
 
-                     case 6:
 
-                         $query->whereRaw(" is_reply =".$this->input);
 
-                         break;
 
-                 }
 
-             }, '申请反馈', 'inter')->select([
 
-                 1=>'企业未查看',
 
-                 2=>'待反馈',
 
-                 3=>'合适',
 
-                 4=>'不合适',
 
-                 5=>'待定',
 
-                 6=>'未接通',
 
-             ]);
 
-             $filter->where(function ($query) {
 
-                 switch ($this->input) {
 
-                     case 3:
 
-                         $date = date('Y-m-d H:i:s', strtotime('-3 day'));
 
-                         $query->whereRaw(" created_at >='".$date."'");
 
-                         break;
 
-                     case 7:
 
-                         $date = date('Y-m-d H:i:s', strtotime('-7 day'));
 
-                         $query->whereRaw(" created_at >='".$date."'");
 
-                         break;
 
-                     case 30:
 
-                         $date = date('Y-m-d H:i:s', strtotime('-30 day'));
 
-                         $query->whereRaw(" created_at >='".$date."'");
 
-                         break;
 
-                     case 180:
 
-                         $date = date('Y-m-d H:i:s', strtotime('-180 day'));
 
-                         $query->whereRaw(" created_at >='".$date."'");
 
-                         break;
 
-                     case 365:
 
-                         $date = date('Y-m-d H:i:s', strtotime('-365 day'));
 
-                         $query->whereRaw(" created_at >='".$date."'");
 
-                         break;
 
-                 }
 
-             }, '申请时间', 'apply')->select([
 
-                 3=>'三天内',
 
-                 7=>'一周内',
 
-                 30=>'一月内',
 
-                 180=>'半年内',
 
-                 365=>'一年内',
 
-             ]);
 
-             $filter->like('company_name', '公司名称');
 
-             $filter->like('resume_name', '简历名称 ');
 
-             $filter->equal('personal_uid', '个人会员ID ');
 
-             if(get_subsite_id()==0){
 
-                 $filter->equal('members.subsite_id', '所属分站')->select(array_column(get_all_subsite(), 'sitename', 'id'));
 
-             }
 
-         });
 
-         return $grid;
 
-     }
 
-     /**
 
-      * Make a show builder.
 
-      *
 
-      * @param mixed $id
 
-      * @return Show
 
-      */
 
-     protected function detail($id)
 
-     {
 
-         $show = new Show(PersonalJobsApply::findOrFail($id));
 
-         $show->id('ID');
 
-         $show->jobs_name('职位名称');
 
-         $show->company_name('公司名称');
 
-         $show->resume_name('简历名称');
 
-         $show->is_reply('反馈状态')->as(function ($is_reply) {
 
-             switch ($is_reply) {
 
-                 case 1:
 
-                     $is_reply = '企业未查看';
 
-                     break;
 
-                 case 2:
 
-                     $is_reply = '待反馈';
 
-                     break;
 
-                 case 3:
 
-                     $is_reply = '合适';
 
-                     break;
 
-                 case 4:
 
-                     $is_reply = '不合适';
 
-                     break;
 
-                 case 5:
 
-                     $is_reply = '待定';
 
-                     break;
 
-                 case 6:
 
-                     $is_reply = '未接通';
 
-                     break;
 
-                 default:
 
-                     $is_reply = '企业未查看';
 
-                     break;
 
-             }
 
-             return $is_reply;
 
-         });
 
-         $show->members('所属分站')->as(function ($members) {
 
-             if ($members->subsite_id) {
 
-                 $Subsite = Subsite::find($members->subsite_id);
 
-                 return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
 
-             }
 
-             return '总站';
 
-         });
 
-         $show->created_at('添加时间');
 
-         $show->updated_at('更新时间');
 
-         return $show;
 
-     }
 
-     /**
 
-      * Make a form builder.
 
-      *
 
-      * @return Form
 
-      */
 
-     protected function form()
 
-     {
 
-         $form = new Form(new PersonalJobsApply);
 
-         $form->display('id');
 
-         $form->display('created_at');
 
-         $form->display('updated_at');
 
-         return $form;
 
-     }
 
-     /**
 
-      * Make a form builder.
 
-      *
 
-      * @return Form
 
-      */
 
-     protected function editForm($id)
 
-     {
 
-         $form = new Form(new PersonalJobsApply);
 
-         $form->setAction(route('admin.personal.addPoints'));
 
-         $MembersHandsel = MembersHandsel::findOrFail($id);
 
-         $utype = $MembersHandsel->utype;
 
-         $points = MembersHandsel::find($id)->membersPoints()->where('utype', $utype)->first();
 
-         $form->display('points_num', '会员积分')->with(function () use ($points) {
 
-             return $points->points;
 
-         });
 
-         $form->radio('points_type', '操作积分')->options([1 => '增加', 2=> '减少'])->default(1);
 
-         $form->number('many_point', '增减积分')->default(0)->min(0);
 
-         $form->text('explain', '操作说明');
 
-         $form->switch('ismany', '是否收费?');
 
-         $form->number('amount', '收费金额')->default(0)->min(0);
 
-         $form->hidden('points_id')->default($points->id);
 
-         $form->footer(function ($footer) {
 
-             // 去掉`重置`按钮
 
-             $footer->disableReset();
 
-             // 去掉`查看`checkbox
 
-             $footer->disableViewCheck();
 
-             // 去掉`继续编辑`checkbox
 
-             $footer->disableEditingCheck();
 
-             // 去掉`继续创建`checkbox
 
-             $footer->disableCreatingCheck();
 
-         });
 
-         $form->tools(function (Form\Tools $tools) {
 
-             // 去掉`删除`按钮
 
-             $tools->disableDelete();
 
-         });
 
-         return $form;
 
-     }
 
-     protected function createForm()
 
-     {
 
-         $form = new Form(new PersonalJobsApply);
 
-         $form->display('id');
 
-         $form->display('created_at');
 
-         $form->display('updated_at');
 
-         return $form;
 
-     }
 
-     /**
 
-      * Store a newly created resource in storage.
 
-      *
 
-      * @return mixed
 
-      */
 
-     public function store()
 
-     {
 
-         return $this->createForm()->store();
 
-     }
 
-     /**
 
-      * Update the specified resource in storage.
 
-      *
 
-      * @param int $id
 
-      *
 
-      * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
 
-      */
 
-     public function update($id)
 
-     {
 
-         return $this->editForm()->update($id);
 
-     }
 
-     public function applyJobs(Content $content)
 
-     {
 
-         $id = request()->id;
 
-         $uid = request()->uid;
 
-         $resume = Resume::where(['id'=>$id])->first();
 
-         $member = MemberInfo::where(['uid'=>$uid])->first();
 
-         return $content
 
-             ->header('职位匹配')
 
-             ->description('列表')
 
-             ->body(view('admin.jobs.find_jobs')->with(['grid'=>$this->gridApply(),'resume'=>$resume,'member'=>$member]));
 
-     }
 
-     /**
 
-      * Make a grid builder.
 
-      *
 
-      * @return Grid
 
-      */
 
-     protected function gridApply()
 
-     {
 
-         $grid = new Grid(new Jobs);
 
-         $grid->model()->where('valid',1)->where('display',1)->whereIn('audit', getJobsStatus())->orderBy('id', 'desc');
 
-         $grid->id('ID');
 
-         $grid->jobs_name('职位名称');
 
-         $grid->company_name('公司名称');
 
-         $grid->audit('审核状态')->display(function ($audit) {
 
-             switch ($audit) {
 
-                 case 1:
 
-                     $audit = '<span style="color: #00a65a;">审核通过</span>';
 
-                     break;
 
-                 case 2:
 
-                     $audit = '<span>审核中</span>';
 
-                     break;
 
-                 case 3:
 
-                     $audit = '<span style="color: red;">审核未通过</span>';
 
-                     break;
 
-                 default:
 
-                     $audit = '<span>审核中</span>';
 
-                     break;
 
-             }
 
-             return $audit;
 
-         });
 
-         $grid->column('categoryScale.demand', '公司规模');
 
-         $grid->column('categoryTrade.demand', '所属行业');
 
-         $grid->column('categoryEducation.demand', '职位要求');
 
-         $grid->column('categoryWage.demand', '薪资待遇');
 
-         $grid->created_at('添加时间')->sortable();
 
-         $grid->updated_at('更新时间')->sortable();
 
-         $grid->disableCreateButton();
 
-         $grid->disableExport();
 
-         $grid->disableActions();
 
-         $grid->tools(function ($tools) {
 
-             $but = <<<EOT
 
- <div class="btn-group" data-toggle="buttons">
 
-     <label class="btn btn-google btn-sm" id="Apply" title="投递">
 
-         <i class="fa fa-audio-description"></i>
 
-         <input type="radio" class="user-gender">投递
 
-     </label>
 
- </div>
 
- EOT;
 
-             $tools->append($but);
 
-         });
 
-         $grid->filter(function ($filter) {
 
-             // 去掉默认的id过滤器
 
-             $filter->disableIdFilter();
 
-             $filter->column(1/2, function ($filter) {
 
-                 $filter->like('jobs_name', '职位名称');
 
-             });
 
-             $filter->column(1/2, function ($filter) {
 
-                 $filter->like('company_name', '公司名称');
 
-             });
 
-         });
 
-         return $grid;
 
-     }
 
-     public function applyCompanyJobs(PersonJobsApplyRepository $personJobsApplyRepository, JobsRepository $jobsRepository)
 
-     {
 
-         $jobs_id = request()->jobs_id;
 
-         $resume_id = request()->resume_id;
 
-         $resume_name = request()->resume_name;
 
-         $personal_uid = request()->personal_uid;
 
-         if (empty($jobs_id)) {
 
-             return json_encode(['code'=>0,'info'=>'职位信息不存在!']);
 
-         }
 
-         $resume = Resume::find($resume_id);
 
-         if (!$resume) {
 
-             return json_encode(['code'=>0,'info'=>'简历不存在!']);
 
-         }
 
-         $resume_display = config('aix.personal_set.per_set.show_set.resume_display');
 
-         if ($resume_display!=2) {
 
-             if ($resume->audit!=2) {
 
-                 return json_encode(['code'=>0,'info'=>'审核中或审核未通过的简历无法投递!']);
 
-             }
 
-         } else {
 
-             if ($resume->audit==0) {
 
-                 return json_encode(['code'=>0,'info'=>'审核未通过的简历无法投递!']);
 
-             }
 
-         }
 
-         if ($resume->display!=1) {
 
-             return json_encode(['code'=>0,'info'=>'简历已关闭,无法投递!']);
 
-         }
 
-         $defaultPre = config('aix.personal_set.per_set.per_set.apply_job_min_percent');
 
-         if ($defaultPre) {
 
-             if ($resume->complete_percent<$defaultPre) {
 
-                 return json_encode(['code'=>0,'info'=>'您的简历完整度小于'.$defaultPre.'%,无法投递!']);
 
-             }
 
-         }
 
-         $todayCount = $personJobsApplyRepository->getTodayCount($resume->uid);
 
-         if ($todayCount>=config('aix.personal_set.per_set.per_set.apply_jobs_max')) {
 
-             return json_encode(['code'=>0,'info'=>"您每天可以投递".config('aix.personal_set.per_set.per_set.apply_jobs_max')."个职位,今天已投递了{$todayCount}个"]);
 
-         }
 
-         $id = array_filter(explode(',', $jobs_id));
 
-         $displayJobs = $jobsRepository->getDisplayJobs($id, 2);
 
-         if (!empty($displayJobs)) {
 
-             $disJobs =  array_diff($id, array_column($displayJobs, 'id'));
 
-             if (empty($disJobs)) {
 
-                 return json_encode(['code'=>0,'info'=>'您投递的职位已关闭!']);
 
-             }
 
-             $id = $disJobs;
 
-         }
 
-         $jobsApply = $personJobsApplyRepository->personApplyByTime(
 
-             $id,
 
-             $resume->uid,
 
-             config('aix.personal_set.per_set.per_set.apply_job_space')
 
-         );
 
-         if (!empty($jobsApply)) {
 
-             $disApply = array_diff($id, array_column($jobsApply, 'jobs_id'));
 
-             if (empty($disApply)) {
 
-                 return json_encode(['code'=>0,'info'=>'您已经申请过这个职位了!']);
 
-             }
 
-             $id = $disApply;
 
-         }
 
-         $jobs = $jobsRepository->getJobs($id);
 
-         $arr = [];
 
-         foreach ($jobs as $key => $val) {
 
-             $arr[$key]['resume_id'] = $resume_id;
 
-             $arr[$key]['resume_name'] = $resume_name;
 
-             $arr[$key]['personal_uid'] = $personal_uid;
 
-             $arr[$key]['jobs_id'] = $val->id;
 
-             $arr[$key]['jobs_name'] = $val->jobs_name;
 
-             $arr[$key]['company_id'] = $val->company_id;
 
-             $arr[$key]['company_name'] = $val->company_name;
 
-             $arr[$key]['is_apply'] = 2;
 
-             $arr[$key]['created_at'] = date('Y-m-d H:i:s', time());
 
-             $arr[$key]['updated_at'] = date('Y-m-d H:i:s', time());
 
-         }
 
-         $res = PersonalJobsApply::insert($arr);
 
-         if ($res) {
 
-             return json_encode(['code'=>1,'info'=>'投递成功!']);
 
-         } else {
 
-             return json_encode(['code'=>0,'info'=>'投递失败!']);
 
-         }
 
-     }
 
- }
 
 
  |