companyService = $companyService; $this->companyImgService= $companyImgService; $this->auditReasonsRepository = $auditReasonsRepository; $this->emailService = $emailService; $this->smsService = $smsService; $this->jobsService = $jobsService; $this->taskService = $taskService; $this->searchService = $searchService; $this->recommend_limit = 10; $this->recommend_need_limit = 50; $this->companyConsultantService = $companyConsultantService; $this->memberLogRepository=$memberLogRepository; $this->organizationService = $organizationService; $this->serviceService = $serviceService; $this->dispensingService = $dispensingService; } //会员中心 public function index() { $user = auth('web-company')->user(); $res = $this->companyService->index($user); $jobs_total = $this->jobsService->jobsTotal($user->id); if (Cache::has('recommend_click_resumes_'.get_subsite_id())) { Cache::forget('recommend_click_resumes_'.get_subsite_id()); } //用于匹配简历的职位 $recommend_rst = $this->getRecommendResumes($this->recommend_limit); //获取推荐简历 $res['recommend_resumes'] = $recommend_rst['resumes']; $res['match_job'] = $recommend_rst['match_job']; $res['jobsCount'] = $jobs_total; $res['has_job'] = $recommend_rst['has_job']; $res['consultant'] = $this->companyConsultantService->getCompanyConsultant(auth('web-company')->user()); return view('app.company.company_index', $res); } public function ajaxSms() { $res = $this->companyService->ajaxSms(auth('web-company')->user()); if($res['id']){ $html = view('app.company.ajax.ajax_sms',['info'=>$res['message']])->render(); $res['message'] = $html; return response()->json($res); } return response()->json($res); } public function getRecommendResumes($limit = 10) { $need_limit = $this->recommend_need_limit; $list = array(); $user = auth('web-company')->user(); $has_job = 1; $recommend_order = $this->companyService->getRecommendorder($user); $recommend_where = $this->companyService->getRecommendWhere($user); if ($recommend_where) { //添加30天的时间限制 $recommend_where['and'][] = ['updated_at','>=', date('Y-m-d H:i:s', strtotime(date("Y-m-d", strtotime("-30 day"))))]; $recommend_resume_lists = $this->searchService->getRecommends($user, 'Resume', $recommend_where, $recommend_order, '', $limit); $rids = $recommend_resume_lists->pluck('id')->toArray(); if ($recommend_resume_lists->total() >= $limit) { $list = array_slice($recommend_resume_lists->items(), 0, $limit); } else { //获取点击量高的简历 $click_where = $this->companyService->getRecommendResumeWhere(array()); $click_resumes = $this->searchService->search('Resume', $click_where, $recommend_order, '', $need_limit); $click_resumes = $click_resumes->items(); Cache::forever('recommend_click_resumes_'.get_subsite_id(), $click_resumes); //去除已有简历 if ($click_resumes && $rids) { foreach ($click_resumes as $k => $v) { if (in_array($v->id, $rids)) { unset($click_resumes[$k]); } } } $recommend_resumes = $recommend_resume_lists->items(); $recommend_total = $recommend_resume_lists->total(); $need_resumes = array_slice($click_resumes, 0, $need_limit - $recommend_total); $all_resumes = array_merge($recommend_resumes, $need_resumes); $list = array_slice($all_resumes, 0, $limit); } } else { //没有可匹配的职位 $has_job = 0; } return array( 'resumes' => $list, 'match_job' => array(), 'has_job' => $has_job ); } public function ajaxGetRecommendResumes(Request $request) { $limit = $this->recommend_limit; $need_limit = $this->recommend_need_limit; $page = $request->input('page'); $has_job = 1; $user = auth('web-company')->user(); $order_by = $this->companyService->getRecommendorder($user); $list = array(); $recommend_where = $this->companyService->getRecommendWhere($user); if ($recommend_where) { $recommend_where['and'][] = ['updated_at','>=', date('Y-m-d H:i:s', strtotime(date("Y-m-d", strtotime("-30 day"))))]; $recommend_resume_lists = $this->searchService->getRecommends($user, 'Resume', $recommend_where, $order_by, '', $need_limit, 1); $rids = $recommend_resume_lists->pluck('id')->toArray(); $next_page = (int)$page + 1; if ($recommend_resume_lists->total() >= $next_page*$limit) { $list = array_slice($recommend_resume_lists->items(), $page*$limit, $limit); } else { $click_resumes = Cache::get('recommend_click_resumes_'.get_subsite_id()); if ($click_resumes === null) { $click_resumes = $this->searchService->getClickResumes($order_by, array(), $need_limit); Cache::forever('recommend_click_resumes_'.get_subsite_id(), $click_resumes); } if ($click_resumes && $rids) { foreach ($click_resumes as $k => $v) { if (in_array($v->id, $rids)) { unset($click_resumes[$k]); } } } $recommend_resumes = $recommend_resume_lists->items(); $recommend_total = $recommend_resume_lists->total(); $need_resumes = array_slice($click_resumes, 0, $need_limit - $recommend_total); $all_resumes = array_merge($recommend_resumes, $need_resumes); $list = array_slice($all_resumes, $page*$limit, $limit); if (!$list) { $list = array_slice($all_resumes, 0, $limit); $next_page = 1; } } } else { $has_job = 0; } $match_job =0; $recommend_rst['resumes'] = $list; $recommend_rst['has_job'] = $has_job; $html = view('app.company.ajax.ajax_resume_list', $recommend_rst)->render(); $return_data = array( 'status'=>1, 'html' => $html,'match_job'=>$match_job,'page'=>$next_page); return response()->json($return_data); } public function ajaxGetStatistics(Request $request) { $user = auth('web-company')->user(); return $this->companyService->ajaxGetStatistics($request->all(), $user); } /** *企业会员中心首页一键刷新职位 */ public function jobsRefreshAll() { $user = auth('web-company')->user(); return $this->jobsService->jobsRefreshAll($user); } /**企业信息 * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @throws \App\Exceptions\ResponseException */ public function companyInfo() { $user = auth('web-company')->user(); $companyInfo = $this->companyService->companyInfo($user); return view('app.company.company_info', $companyInfo); } /** * @param CompanyValidatorRequest $request * @return \Illuminate\Http\JsonResponse * @throws \Throwable */ public function companySave(CompanyValidatorRequest $request) { $data = $request->except('_method', '_token'); $res = $this->companyService->companySave($data, auth('web-company')->user()); return response()->json($res); } /**修改企业手机==企业中心 * @param Request $request * @return \Illuminate\Http\JsonResponse * @throws \Throwable */ public function modifyMobile(Request $request) { $user = auth('web-company')->user(); if ($request->method() == 'GET') { $mobile = $this->companyService->authMobile($user); return response()->json(['status'=>1,'data'=>view('app.company.ajax.ajax_auth_mobile', $mobile)->render()]); } return $this->companyService->verifyCode($request->mobile, $user); } /** * @保存企业logo * @param Request $request * @return \Illuminate\Http\JsonResponse * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function attach(Request $request) { $user = auth('web-company')->user(); return $this->companyService->saveLogo($request->all(), $user); } /**删除企业Logo * @param Request $request * @return \Illuminate\Http\JsonResponse * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function logoDel() { $user = auth('web-company')->user(); return $this->companyService->logoDel($user); } /**企业风采 * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function companyImg() { $user = auth('web-company')->user(); $res = $this->companyImgService->list($user->id); return view('app.company.company_img', ['imgList'=>$res]); } /** * 保存企业风采 * @param Request $request * @return mixed * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function saveImg(Request $request) { $user = auth('web-company')->user(); return $this->companyImgService->saveImg($request->image, $user); } /** * 修改备注模态框 * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @throws \Throwable */ public function remark(Request $request) { $res = $this->companyImgService->companyImg($request->id); return $res; } /** * 保存备注 * @param CompanyValidatorRequest $request * @return \Illuminate\Http\JsonResponse */ public function saveRemark(CompanyValidatorRequest $request) { $user = auth('web-company')->user(); return $this->companyImgService->saveRemark($request,$user); } /** * 删除企业风采 * @param $id * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\View\View */ public function delImg($id, Request $request) { if ($request->type) { $user = auth('web-company')->user(); return $this->companyImgService->delImg($id,$user); } $tip='被删除后将无法恢复,您确定要删除该风采照片吗?'; return view('app.company.ajax.ajax_warning', ['tip'=>$tip]); } /** * 企业认证 * @param $anew * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @throws \App\Exceptions\ResponseException */ public function companyAuth($anew = '') { $user = auth('web-company')->user(); $companyInfo = $this->companyService->getInfoById($user); $companyInfo->reason = $this->auditReasonsRepository->getAuditReasons(auth('web-company')->user()->id, 8); if ($anew=='anew') { $companyInfo->audit = 0; } return view('app.company.company_auth', ['companyInfo'=>$companyInfo, 'anew'=>$anew]); } public function certificate(Request $request) { $user = auth('web-company')->user(); return $this->companyService->certificate($request->certificate_img_up, $user); } /** * 账户安全 * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @throws \App\Exceptions\ResponseException */ public function companySecurity() { $user = auth('web-company')->user(); $companyInfo = $this->companyService->companySecurity($user); return view('app.company.company_security', $companyInfo); } /**企业登录日志 * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @throws \App\Exceptions\ResponseException */ public function loginLog() { $user = auth('web-company')->user(); $loginLog = $this->companyService->companyLoginLog($user); $companyInfo = $user; $companyInfo['loginLog'] = $loginLog; return view('app.company.login_log', ['companyInfo'=>$companyInfo]); } /**我的消息 * @param $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function companyPms(Request $request) { $user = auth('web-company')->user(); $data = $request->all(); $res = $this->companyService->comPms($data, $user); return view('app.company.company_pms', $res); } public function pmsRead(Request $request) { $id = $request->id; return $this->companyService->pmsRead($id); } public function msgSend() { $res = $this->companyService->msgSend(auth('web-company')->user(), request()->all()); if ($res) { $this->taskService->doTask(32); return $this->sendSuccessResponse($res); } else { return $this->sendErrorResponse('回复失败!'); } } public function msgDelete() { if (request()->method()=='POST') { $res = $this->companyService->msgDelete(request()->all()); if ($res) { return $this->sendSuccessResponse('删除成功!'); } else { return $this->sendErrorResponse('删除失败!'); } } else { return view('app.person.ajax.resume_delete', ['tpis'=>'删除后将无法恢复,您确定要删除选择的咨询消息吗?']); } } public function companyPmsDel(Request $request) { if ($request->method()== 'POST') { $user = auth('web-company')->user(); return $this->companyService->companyPmsDel($request,$user); } $tip = "被删除后将无法恢复,您确定要删除选中的系统消息吗?"; return response()->json(['status'=>1,'data'=>['html'=>view('app.company.ajax.ajax_warning', ['tip'=>$tip])->render()]]); } public function companyPmsCheck(Request $request) { return $this->companyService->companyPmsCheck($request); } /** * */ public function companyPmsConsult() { $res = $this->companyService->companyPmsConsult(auth('web-company')->user()); return view('app.company.company_pmsconsult', ['content'=>$res]); } /** * 修改用户名 * */ public function modifyUsername() { $user = auth('web-company')->user(); $res = $this->companyService->modifyUserName($user); return view('app.company.ajax.username', $res); } /** 修改用户名 * @param CompanyValidatorRequest $request * @return CompanyController|\Illuminate\Http\JsonResponse * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function saveUsername(CompanyValidatorRequest $request) { $user = auth('web-company')->user(); if (!$this->companyService->saveUsername($request->username, $user)) { return $this->sendErrorResponse('用户名修改失败!'); } return $this->sendSuccessResponse('用户名修改成功!'); } /**修改密码 * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function modifyPwd() { return view('app.company.ajax.ajax_modify_pwd'); } /**修改密码======保存密码 * @param CompanyValidatorRequest $request * @return CompanyController|\Illuminate\Http\JsonResponse * @throws \App\Exceptions\ResponseException * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function savePwd(CompanyValidatorRequest $request) { $user = auth('web-company')->user(); if (!$this->companyService->savePwd($user, $request->oldpassword, $request->password, $request->password1)) { return $this->sendErrorResponse('密码修改失败!'); } if ($user->mobile) { $this->smsService->sendSms($user->mobile, Smser::TEMPLATE_SMS_EDITPWD, ['sitename'=>subsite_config('aix.system.site.site.site_name'),'newpassword'=>$request->password]); } return $this->sendSuccessResponse('密码修改成功!'); } /** * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @手机认证弹窗 */ public function authMobile() { $user = auth('web-company')->user(); $mobile = $this->companyService->authMobile($user); return view('app.company.ajax.ajax_auth_mobile', $mobile); } /** * @param CompanyValidatorRequest $request * @return \Illuminate\Http\JsonResponse * @throws \App\Exceptions\ResponseException */ public function verifyCode(CompanyValidatorRequest $request) { $mobile = $request->mobile; $id = $request->id; if (!$this->companyService->checkMobileAudit($id, $mobile)->isEmpty()) { return response()->json(['status'=>0, 'msg'=>'手机已验证']); } $this->smsService->sendAuthSms($mobile, smser::TEMPLATE_AUTH_CHECK); return response()->json(['status'=>1]); } public function mobileAudit(CompanyValidatorRequest $request) { $user = auth('web-company')->user(); $mobile = $request->mobile; $verifyCode = $request->verifycode; $res = $this->smsService->checkAuthSms($mobile, smser::TEMPLATE_AUTH_CHECK, $verifyCode); if (!$res) { return response()->json(['status'=>0,'msg'=>'验证码错误']); } $res = $this->companyService->verifyCode($mobile, $user); if ($res['status']==1) { $this->memberLogRepository->createLog($user,8002,""); if (isset($res['data'])) { return response()->json(['status'=>1,'msg'=>'手机认证成功','data'=>['mobile'=>$mobile, 'points'=>$res['data']['points']]]); } else { return response()->json(['status'=>1,'msg'=>'手机认证成功','data'=>['mobile'=>$mobile]]); } } else { return response()->json(['status'=>0,'msg'=>'手机认证失败']); } } /**邮箱认证 * @return \Illuminate\Http\JsonResponse * @throws \Throwable */ public function authEmail() { $user = auth('web-company')->user(); if (!$email = $this->companyService->authEmail($user)) { return response()->json(['status'=>0,'msg'=>'参数错误!']); } return response()->json(['status'=>1,'msg'=>'查询成功!','data'=>view('app.company.ajax.ajax_auth_email', $email)->render()]); } /**认证Email 及修改状态 * @param CompanyValidatorRequest $request * @return \Illuminate\Http\JsonResponse */ public function emailSend(CompanyValidatorRequest $request) { $email = $request->email; $id = $request->id; if (!$this->companyService->checkEmailAudit($id, $email)->isEmpty()) { return response()->json(['status'=>0, 'msg'=>'email已验证!']); } $user = auth('web-company')->user(); $this->memberLogRepository->createLog($user,8001,""); $this->emailService->setAuthTag('company') ->setCallback('App\Services\Company\CompanyService', 'sendAuthEmailHook', [$email, auth('web-company')->user()]) ->sendAuthMail($email, EmailService::TEMPLATE_VALIDATION); return response()->json(['status'=>1]); } /**签到 * @return \Illuminate\Http\JsonResponse */ public function sign() { $user = auth('web-company')->user(); $res = $this->companyService->signIn($user); return response()->json(['status'=>$res['code'],'msg'=>$res['msg'],'data'=>$res['info']]); } public function ajaxResumeSearch(Request $request) { $key = $request->input('key', ''); $search_type = $request->input('search_type', 'precise'); return response()->json(['status'=>1,'data'=>route(url_rewrite('AIX_resumelist'), ['key'=>$key, 'search_type'=>$search_type])]); } public function unBindThird(Request $request) { $alias = $request->alias; $user = auth('web-company')->user(); return $this->companyService->unBindThird($alias, $user); } //企业联系人信息 public function contact(Request $request) { $user = auth('web-company')->user(); $contacts = $this->companyService->companyContact($user, 10); $return_data = array( 'contacts' => $contacts ); return view('app.company.company_contact', $return_data); } //企业联系人信息ajax请求 public function ContactAjax(){ $user = auth('web-company')->user(); $contacts = $this->companyService->companyContact($user, 10); return response()->json($contacts); } public function showContact(Request $request) { $id = $request->input('id'); $rst = $this->companyService->getContactInfo($id, auth('web-company')->user()); if (array_has($rst, 'status') && $rst['status'] == 1) { $contact = $rst['contact']; $landline_tel = dealContactPhone($contact->landline_tel); $html = view('app.company.ajax.show_contact', ['contact'=>$contact, 'landline_tel'=>$landline_tel])->render(); $return_data = array( 'status'=>1, 'data' => $html); return response()->json($return_data); } else { return response()->json($rst); } } public function deleteContact(Request $request) { $id = $request->input('id'); $ids = is_array($id)?$id:explode(",", $id); return $this->companyService->companyContactDel($ids, auth('web-company')->user()); } public function editContact(Request $request) { if ($request->method() == 'POST') { $user = auth('web-company')->user(); $id = $request->input('id'); $data = $request->except('_token', '_method'); $rst = $this->companyService->updateContact($data,$user); if ($rst) { $return_data = array('status'=>1, 'msg'=>'修改成功'); } else { $return_data = array('status'=>0, 'msg'=>'修改失败'); } return response()->json($return_data); } else { $id = $request->input('id'); $rst = $this->companyService->getContactInfo($id, auth('web-company')->user()); if (array_has($rst, 'status') == 1) { $return_data = ['contact' => $rst['contact']]; $html = view('app.company.ajax.add_contact', $return_data)->render(); $return_data = array( 'status'=>1, 'data' => $html); return response()->json($return_data); } else { return $rst; } } } public function addContact(Request $request) { if ($request->method() == 'POST') { $contact = $request->input('contact', ''); $telephone = $request->input('telephone', ''); $tel_first = $request->input('tel_first', ''); $tel_next = $request->input('tel_next', ''); $tel_last = $request->input('tel_last', ''); $email = $request->input('email', ''); $qq = $request->input('qq', ''); $address = $request->input('address', ''); if (!$contact) { $return_data = array( 'status'=>0, 'msg' => '请输入联系人信息'); } //座机和手机号至少填写一项 if (!$email) { $return_data = array( 'status'=>0, 'msg' => '请输入联系邮箱'); } if (!$address) { $return_data = array( 'status'=>0, 'msg' => '请输入联系地址'); } if (!empty($tel_first) && !empty($tel_next)){ $landline_tel=$tel_first."-".$tel_next; if (!empty($tel_last)){ $landline_tel.="-".$tel_last; } }else{ $landline_tel=""; } $set_data = array( 'company_id' => (int)auth('web-company')->user()->id, 'contact' => $contact, 'telephone' => $telephone, 'landline_tel' => $landline_tel, 'email' => $email, 'qq' => $qq, 'address' => $address ); $rst = $this->companyService->addContact($set_data); if ($rst) { $return_data = array('status'=>1, 'msg'=>'添加成功'); } else { $return_data = array('status'=>0, 'msg'=>'添加失败'); } return response()->json($return_data); } else { $return_data = ['contact'=>'']; $html = view('app.company.ajax.add_contact', $return_data)->render(); $return_data = array( 'status'=>1, 'data' => $html); return response()->json($return_data); } } public function myCode(Request $requset) { $id = $requset->id?$requset->id:0; $user = $this->getLoginUser(); if ($user->id!=$id) { return response()->json(['status'=>0,'img'=>'企业不存在!']); } return response()->json(['status'=>1,'img'=>get_qrcode_html(route('mobile.firm.com.wzp.index',['id'=>$id]))]); } //服务广场 public function square() { return view('app.company.company_square'); } public function share() { $service_list = $this->serviceService->list(); return view('app.company.company_share',['service_list'=>$service_list]); } public function dispensing() { return view('app.company.company_dispensing'); } public function dispensingList() { $user = auth('web-company')->user(); $dispensingList = $this->dispensingService->list($user); return view('app.company.company_dispensingList',['dispensing'=>$dispensingList]); } public function dispensingAdd(Request $request) { $data = $request->except('_method', '_token'); return $this->dispensingService->save($data,auth('web-company')->user()); } public function dispensingEdit(Request $request) { if(request()->method()=='POST'){ $data = $request->except('_method', '_token'); return $this->dispensingService->save($data,auth('web-company')->user()); }else{ $id = $request->input('id'); $user = auth('web-company')->user(); $where['id'] = $id; $where['uid'] = $user->id; $dispensingInfo = $this->dispensingService->dispensingInfo($where); if(!$dispensingInfo){ return $this->showMessage('没有这个需求!', route('com.dispensingList'), true); } return view('app.company.company_dispensingEdit',['dispensing'=>$dispensingInfo]); } } public function dispensingDel(Request $request) { $id = $request->id; $user = auth('web-company')->user(); return $this->dispensingService->dispensingDel($id, $user); } }