jobfairRepository = $jobfairRepository;
$this->jobfairFloorplanStandRepository = $jobfairFloorplanStandRepository;
$this->jobfairCompanyRepository = $jobfairCompanyRepository;
$this->jobfairPutJobRepository = $jobfairPutJobRepository;
$this->jobfairFloorPlanRepository = $jobfairFloorPlanRepository;
$this->jobfairBlackListRepository = $jobfairBlackListRepository;
$this->memberSetmealRepository = $memberSetmealRepository;
$this->memberPointRepository = $memberPointRepository;
$this->memberHandselRepository = $memberHandselRepository;
$this->membersSetmealLogRepository = $membersSetmealLogRepository;
$this->resumeRepository = $resumeRepository;
$this->jobfairPersonalJobsApplyRepository = $jobfairPersonalJobsApplyRepository;
$this->jobfairManagementRepository = $jobfairManagementRepository;
$this->subsiteService = $subsiteService;
$this->memberLogRepository=$memberLogRepository;
$this->jobfairoutRepository = $jobfairoutRepository;
$this->articleRepository = $articleRepository;
$this->categoryRepository = $categoryRepository;
$this->emailService = $emailService;
}
/**近期招聘会
* @return array
*/
public function jobfairIndex($user)
{
$jobfairList = $this->jobfairRepository->getJobfairList($user->id);
foreach ($jobfairList as $key => $val) {
$val->predetermined_ok = 0;
if ($val->predetermined_status == 1 && $val->predetermined_start && $val->predetermined_start < time() && $val->predetermined_end && $val->predetermined_end > time()) {
$val->predetermined_ok = 1;
}
}
$week = ['日','一','二','三','四','五','六'];
return [
'jobfairList'=>$jobfairList,
'week'=>$week,
];
}
/**招聘会列表
* @param $request
* @return array
*/
public function index($request)
{
$typeList = $this->jobfairManagementRepository->orderBy('order_list', 'desc')->get();
$page = $request->page?$request->page:0;
$search_type = $request->search_type ? $request->search_type : '';
$key = $request->key ? $request->key : '';
$firstwhere = [
'display'=>1,
];
$firstJobfair = $this->jobfairRepository->firstJobfair($firstwhere);
if ($firstJobfair) {
if ($firstJobfair->predetermined_status == 1 && $firstJobfair->predetermined_start && $firstJobfair->predetermined_start < time() && $firstJobfair->predetermined_end && $firstJobfair->predetermined_end > time()) {
$firstJobfair->predetermined_ok = 1;
} else {
$firstJobfair->predetermined_ok = 0;
}
}
$jobfair_type = $request->type?$request->type:'';
$pageCount = 10;
$where['display']= 1;
if ($jobfair_type != -1) {
if($jobfair_type){
$where['jobfair_type'] = $jobfair_type;
}
$allJobfair = $this->jobfairRepository->allJobfair($where, $page, $pageCount,$search_type,$key);
}else{
$allJobfair = $this->jobfairoutRepository->allJobfair($where, $page, $pageCount);
}
if ($allJobfair) {
foreach ($allJobfair as $key => $val) {
if ($val->predetermined_status == 1 && $val->predetermined_start && $val->predetermined_start < time() && $val->predetermined_end && $val->predetermined_end > time()) {
$val->predetermined_ok = 1;
} else {
$val->predetermined_ok = 0;
}
}
}
$more = count($allJobfair) >= $pageCount ? true : false;
$weekarray=array("日","一","二","三","四","五","六");
if ($request->ajax()) {
return [
'firstJobfair'=> $firstJobfair,
'page' => $page,
'allJobfair'=> $allJobfair,
'typeList'=> $typeList,
'weekarray'=>$weekarray
];
}
//资讯快报
$news = $this->articleRepository->getArticles(['type_id'=>49],4);
//招聘会回顾
$jobfair_review = $this->articleRepository->getArticles(['type_id'=>50],4);
return [
'firstJobfair'=> $firstJobfair,
'page' => $page,
'allJobfair'=> $allJobfair,
'typeList'=> $typeList,
'more'=> $more,
'news'=> $news,
'jobfair_review'=> $jobfair_review,
'weekarray'=>$weekarray
];
}
/**招聘会详情
* @param $id
* @return array
*/
public function jobfairShow($id)
{
$map1 =[
'id'=>$id,
];
$jobfair = $this->jobfairRepository->findOne($map1);
if (!$jobfair) {
return ['status'=>0, 'msg'=>'查无此招聘会'];
}
if ($jobfair->predetermined_status == 1 && $jobfair->predetermined_start && $jobfair->predetermined_start < time() && $jobfair->predetermined_end && $jobfair->predetermined_end > time()) {
$jobfair->predetermined_ok =1;
} else {
$jobfair->predetermined_ok =0;
}
//总展位数
$where = [
'jobfair_id'=>$id,
];
$jobfair->standsTotal = $this->jobfairFloorplanStandRepository->standsTotal($where);
$jobfair->phone_html = '';
if($jobfair->phone){
foreach (explode(',',$jobfair->phone) as $value){
$jobfair->phone_html .= ''.$value .'
';
}
}
//空余展位数
$map = [
'jobfair_id'=>$id,
'type'=>1
];
$free_standsSurplus = $this->jobfairFloorplanStandRepository->standsTotal($map);
if ($free_standsSurplus->isEmpty()) {
$jobfair->standsSurplus = 0;
} else {
$free_standsSurplusCount = $free_standsSurplus->toArray();
$free_count = count($free_standsSurplusCount);
$positionArr = array_column($free_standsSurplusCount, 'id');
$listCount = $this->jobfairCompanyRepository->findPositionCount($positionArr);
if ($listCount->isNotEmpty()) {
$positionCount = $listCount->count();
foreach ($listCount as $key => $val) {
if ($val->audit == 3) {
$positionCount--;
}
}
} else {
$positionCount = 0;
}
$jobfair->standsSurplus = $free_count-$positionCount?$free_count-$positionCount:0;
}
$companyCount = $this->jobfairCompanyRepository->getComCount($id);
return [
'status'=>1,
'jobfair'=>$jobfair,
'companyCount'=>$companyCount,
];
}
/**招聘会企业
* @param $request
* @param $id
* @return JobfairCompanyRepository[]|array|\Illuminate\Database\Eloquent\Collection
*/
public function jobfairShowCom($request, $id)
{
$where = ['jobfair_companys.jobfair_id'=>$id,'jobfair_companys.audit'=>1];
$key = isset($request->key)?$request->key:0;
$offset = isset($request->page)?$request->page:0;
$limit = 20;
//参会总数(分组)
$companyCount = $this->jobfairCompanyRepository->getComCount($id);
//参会总数(未分组)
$comCount = $this->jobfairCompanyRepository->getCounts($id);
$jobfair = $this->jobfairRepository->findJobfair(['id'=>$id]);
if (!$jobfair) {
return ['status'=>0, 'msg'=>'查无此招聘会'];
}
//总展位数
$where1 = [
'jobfair_id'=>$id,
];
$jobfair->standsTotal = $this->jobfairFloorplanStandRepository->standsTotal($where1);
//空余展位数
$map = [
'jobfair_id'=>$id,
'type'=>1
];
if ($jobfair->predetermined_status == 1 && $jobfair->predetermined_start && $jobfair->predetermined_start < time() && $jobfair->predetermined_end && $jobfair->predetermined_end > time()) {
$jobfair->predetermined_ok =1;
} else {
$jobfair->predetermined_ok =0;
}
$free_standsSurplus = $this->jobfairFloorplanStandRepository->standsTotal($map);
if ($free_standsSurplus->isEmpty()) {
$jobfair->standsSurplus = 0;
} else {
$free_standsSurplusCount = $free_standsSurplus->toArray();
$free_count = count($free_standsSurplusCount);
$positionArr = array_column($free_standsSurplusCount, 'id');
$listCount = $this->jobfairCompanyRepository->findPositionCount($positionArr);
if ($listCount->isNotEmpty()) {
$positionCount = $listCount->count();
foreach ($listCount as $key => $val) {
if ($val->audit == 3) {
$positionCount--;
}
}
} else {
$positionCount = 0;
}
$jobfair->standsSurplus = $free_count-$positionCount?$free_count-$positionCount:0;
}
$jobfairCompany = $this->jobfairCompanyRepository->findCompany($where, $offset, $limit);
foreach ($jobfairCompany as $key => $val) {
$val->jobfairPutJob = $this->jobfairPutJobRepository->getJobfairJob($val->id, $id);
}
if ($request->ajax()) {
return [
'jobfairCompany'=>$jobfairCompany,
'jobfair'=>$jobfair,
];
}
$more = count($jobfairCompany) >= $limit ? true : false;
$jobsSum = $this->jobfairPutJobRepository->getNeedPerson($id);
$needPersonCount = isset($jobsSum['sum']) ? $jobsSum['sum'] : 0;
$jobsCount = $this->jobfairPutJobRepository->getJobsCount($id);
return [
'status'=>1,
'jobfair'=>$jobfair,
'jobfairCompany'=>$jobfairCompany,
'companyCount'=>$companyCount,
'more'=>$more,
'needPersonCount'=>$needPersonCount,
'jobsCount'=>$jobsCount,
'comCount'=>$comCount,
];
}
/**职位详情
* @param $jobfair_id
* @param $job_id
* @return array
*/
public function jobfairShowJob($id)
{
$jobInfo = $this->jobfairPutJobRepository->getOne(['id'=>$id]);
if (!$jobInfo) {
return ['status'=>0, 'msg'=>'查无此职位!'];
}
if ($jobInfo->jobs->ygxs == '363') {
$jobInfo->jobs->wage_cn = $jobInfo->jobs->wage_min . '元/小时';
}
$other_categories = $this->categoryRepository->getCategories();
//用工形式
$company_ygxs = array_get($other_categories, 'AIX_ygxs');
if ($company_ygxs) {
$ygxs_cn = array_get($company_ygxs, $jobInfo->jobs->ygxs);
if ($ygxs_cn) {
$jobInfo->ygxs_cn = $ygxs_cn['demand'];
} else {
$jobInfo->ygxs_cn = '不限';
}
}
//技能等级
$techlevels = array_get($other_categories, 'AIX_techlevel');
if ($techlevels) {
$techlevel_cn = array_get($techlevels, $jobInfo->jobs->techlevel);
if ($techlevel_cn) {
$jobInfo->techlevel_cn = $techlevel_cn['demand'];
} else {
$jobInfo->techlevel_cn = '不限';
}
}
//试用期
$syqs = array_get($other_categories, 'zs_syq');
if ($syqs) {
if (empty($jobInfo->jobs->syq)) {
$jobInfo->syq = 367;
$jobInfo->jobs->syq=367;
}
$syq_cn = array_get($syqs, $jobInfo->jobs->syq);
if ($syq_cn) {
$jobInfo->syq_cn = $syq_cn['demand'];
} else {
$jobInfo->syq_cn = '无';
}
}
//试用期工资:
if ($jobInfo->wage == -1) {
$jobInfo->syqxz_min_cn='面议';
} else {
$jobInfo->syqxz_min_cn=$jobInfo->jobs->syqxz_min.'元/月';
}
if ($jobInfo->jobfairs->holddate_end > time()) {
$jobInfo->jobs->predetermined_ok = 1;
} else {
$jobInfo->jobs->predetermined_ok = 0;
}
if ($jobInfo->jobs->subclass) {
$jobInfo->jobs->category_cn = get_job_category($jobInfo->jobs->subclass);
}
if ($jobInfo->jobs->tag_cn) {
$jobInfo->jobs->tag_cn = explode(',',$jobInfo->jobs->tag_cn);
}
return [
'status'=>1,
'jobInfo'=>$jobInfo,
];
}
/**在线预定页面
* @param $id
* @return array
*/
public function jobfairAppointment($id)
{
$jobfair = $this->jobfairRepository->findJobfair(['id'=>$id]);
if (!$jobfair) {
return ['status'=>0,'msg'=>"参数错误!"];
}
//总展位数
$where1 = [
'jobfair_id'=>$id,
];
$jobfair->standsTotal = $this->jobfairFloorplanStandRepository->standsTotal($where1);
//空余展位数
$map = [
'jobfair_id'=>$id,
'type'=>1
];
$free_standsSurplus = $this->jobfairFloorplanStandRepository->standsTotal($map);
if ($free_standsSurplus->isEmpty()) {
$jobfair->standsSurplus = 0;
} else {
$free_standsSurplusCount = $free_standsSurplus->toArray();
$free_count = count($free_standsSurplusCount);
$positionArr = array_column($free_standsSurplusCount, 'id');
$listCount = $this->jobfairCompanyRepository->findPositionCount($positionArr);
if ($listCount->isNotEmpty()) {
$positionCount = $listCount->count();
foreach ($listCount as $key => $val) {
if ($val->audit == 3) {
$positionCount--;
}
}
} else {
$positionCount = 0;
}
$jobfair->standsSurplus = $free_count-$positionCount?$free_count-$positionCount:0;
}
//招聘企业数
$companyList = $this->jobfairCompanyRepository->getComList(['jobfair_id'=>$id,'audit'=>1]);
if ($companyList->isEmpty()) {
$jobsCount = 0;
$needPersonCount = 0;
} else {
//招聘职位数
$companyIdArr = array_column($companyList->toArray(), 'company_id');
$jobsCount = $this->jobfairPutJobRepository->getJobsCount($id, $companyIdArr);
//需求人才数
$jobsSum = $this->jobfairPutJobRepository->getNeedPerson($id, $companyIdArr);
$needPersonCount = isset($jobsSum['sum']) ? $jobsSum['sum'] : 0;
}
if ($jobfair->predetermined_status == 1 && $jobfair->predetermined_start && $jobfair->predetermined_start < time() && $jobfair->predetermined_end && $jobfair->predetermined_end > time()) {
$jobfair->predetermined_ok =1;
} else {
$jobfair->predetermined_ok =0;
}
return [
'status'=>1,
'jobfair'=>$jobfair,
'companyList'=>$companyList,
'jobsCount'=>$jobsCount,
'needPersonCount'=>$needPersonCount,
];
}
public function jobfairAppointmentSave($jobfairInfo, $positionInfo, $user)
{
//招聘会是否允许订多个展位
//查看黑名单
$blackInfo = $this->jobfairBlackListRepository->getOne(['company_id'=>$user->id]);
if ($blackInfo && $blackInfo->status ==1 && $blackInfo->remove_time==0) {
return response()->json(['status'=>0, 'msg'=>"很抱歉,无法预定招聘会。您在招聘会黑名单内!"]);
}
if ($this->jobfairCompanyRepository->findWhere(['company_id'=>$user->id,'jobfair_id'=>$jobfairInfo->id,'position_id'=>$positionInfo->id,['audit', '<>', 3]])->isNotEmpty()) {
return response()->json(['status'=>0, 'msg'=>"您已预定过该展位,不能重复预定"]);
}
//允许预订 举办开始日期大于当前日期 预订结束时间大于当前时间 允许在线预订
if ($jobfairInfo->predetermined_status == 2) {
return response()->json(['status'=>0, 'msg'=>"很抱歉,招聘会已停止预定"]);
}
if (time() > $jobfairInfo->holddate_end) {
return response()->json(['status'=>0, 'msg'=>"很抱歉,招聘会已结束"]);
}
// if ($jobfairInfo->predetermined_status == 1 && ($jobfairInfo->predetermined_start && time() < $jobfairInfo->predetermined_start)) {
// return response()->json(['status'=>0, 'msg'=>"很抱歉,招聘会未到开始预定时间"]);
// }
// if ($jobfairInfo->predetermined_status == 1 && ($jobfairInfo->predetermined_end && time() > $jobfairInfo->predetermined_end)) {
// return response()->json(['status'=>0, 'msg'=>"很抱歉,招聘会已结束预定"]);
// }
if ($jobfairInfo->is_commonweal == 1) {
$num = $jobfairInfo->jobsfair_num;
$mySetmeal = $this->memberSetmealRepository->getSetmealByUid($user->id, 1);
if ($mySetmeal->jobfair_num < $num) {
return response()->json(['status' => 0, 'msg' => "很抱歉,您的会员招聘会场次不足。请先升级套餐!"]);
}
}
if ($jobfairInfo->is_commonweal == 2) {
$num = $jobfairInfo->predetermined_point;
$myPoints = $this->memberPointRepository->getComPointsById($user->id, 1);
if ($myPoints->points < $num) {
return response()->json(['status' => 0, 'msg' => "很抱歉,您的会员积分不足。请先积分充值!"]);
}
}
$insertData['company_id'] = $user->id;
$insertData['jobfair_id'] = $jobfairInfo->id;
$insertData['position_id'] = $positionInfo->id;
$insertData['pay_type'] = $jobfairInfo->is_commonweal;
$insertData['position'] = $positionInfo->name;
DB::beginTransaction();
try {
if (!$this->jobfairCompanyRepository->create($insertData)) {
throw new \Exception('招聘会预定失败!');
}
if ($jobfairInfo->is_commonweal != 3) {
$res = $this->payType($jobfairInfo->is_commonweal, $num, $user);
if (!$res['status']) {
throw new \Exception($res['msg']);
}
}
DB::commit();
$this->memberLogRepository->createLog($user,1033,[$insertData['jobfair_id'],$insertData['position_id']]);
return response()->json(['status'=>1, 'msg'=>"展位已保留,请关注审核结果并及时提交招聘会职位!",'data'=>['positionid'=>$positionInfo->id,'companyname'=>$user->companyname]]);
} catch (\Exception $e) {
DB::rollback();
return response()->json(['status'=>0, 'msg'=>$e->getMessage()]);
}
}
/**场次和积分预定招聘会
* @param $payType
* @param $num
* @param $user
* @return array
*/
public function payType($payType, $num, $user)
{
//消耗场次
$data = [];
if ($payType == 1) {
$mySetmeal = $this->memberSetmealRepository->getSetmealByUid($user->id, 1);
$data['jobfair_num'] = $mySetmeal->jobfair_num - $num?$mySetmeal->jobfair_num - $num:0;
if (!$this->memberSetmealRepository->updateSetmeal($data, $mySetmeal->id)) {
return ['status' => 0, 'msg' => '扣除招聘会场次失败!'];
} else {
$members_log['log_uid']=$user->id;
$members_log['log_utype']=1;
$members_log['log_username']=$user->username;
$log_leave=$mySetmeal->jobfair_num-1;
$members_log['log_leave'] = $log_leave<0?0:$log_leave;
$members_log['log_value'] = '扣除招聘会场次';
$members_log['log_source']='网页版';
if (!$this->membersSetmealLogRepository->addNew($members_log)) {
return ['status' => 0, 'msg' => '添加扣除招聘会场次记录失败!'];
} else {
return ['status' => 1,];
}
}
} else {
//消耗积分
if (!$this->memberPointRepository->reportDeal($user->id, $user->utype, 2, $num)) {
return ['status' => 0, 'msg' => '扣除积分失败!'];
} else {
$handsel['uid'] =$user->id;
$handsel['utype'] = 1;
$handsel['htype'] = 'yuyue_jobfair';
$handsel['htype_cn'] = '扣除招聘会积分';
$handsel['operate'] = 2;
$handsel['points'] = $num;
if (!$this->memberHandselRepository->addNew($handsel)) {
return ['status' => 0, 'msg' => '添加扣除积分记录失败!'];
} else {
return ['status' => 1,];
}
}
}
}
public function jobfairAppointmentJobs($request, $user)
{
$resume = $this->resumeRepository->getPersonInfo($user->id);
if (!$resume) {
return response()->json(['status'=>0,'type'=>0,'url'=>route('person.resumeAdd'), 'msg'=>"您还没有默认简历,请先去创建简历!"]);
}
$data['resume_id'] = $resume->id;
$data['personal_uid'] = $user->id;
$data['jobs_id'] = $request['jobsfair_job_id'];
$data['company_id'] = $request['company_uid'];
$data['jobfair_id'] = $request['jobfairid'];
$data['position_id'] = $request['position_id'];
$jobfair = $this->jobfairRepository->find($request['jobfairid']);
if ($jobfair->isEmpty || $jobfair->holddate_end < time()) {
return response()->json(['status'=>0, 'msg'=>"招聘会已停止"]);
}
if ($this->jobfairPersonalJobsApplyRepository->findWhere(['resume_id'=>$resume->id, 'jobs_id'=>$request['jobsfair_job_id'], 'company_id'=>$request['company_uid'], 'jobfair_id'=>$request['jobfairid'], 'position_id'=>$request['position_id']])->isNotEmpty()) {
return response()->json(['status'=>0, 'msg'=>"您已预约该职位,请勿重复预约!"]);
}
if ($this->jobfairPersonalJobsApplyRepository->create($data)) {
return response()->json(['status'=>1, 'msg'=>"职位预约成功!"]);
}
return response()->json(['status'=>0,'type'=>0 , 'msg'=>"职位预约失败!"]);
}
/**页面加载展位信息
* @param $request
* @return \Illuminate\Http\JsonResponse
*/
public function ajaxGetData($data)
{
$jobfair_id = isset($data['jobfair_id'])?$data['jobfair_id']:0;
$floorplan_id = isset($data['floorplan_id'])?$data['floorplan_id']:0;
//后台传值,不区分预留展位
$type = isset($data['type'])?$data['type']:0;
if (!$jobfair_id || !$floorplan_id) {
return response()->json(['status'=>0,'msg'=>"参数错误"]);
}
$jobfairFloorRes = $this->jobfairFloorPlanRepository->find($floorplan_id);
$jobfairFloorplanStandResult = $this->jobfairFloorplanStandRepository->findWhere(['jobfair_id'=>$jobfair_id, 'floorplan_id'=>$floorplan_id], ['id', 'name','type','left', 'top']);
if ($jobfairFloorplanStandResult) {
$jobfairFloorplanStandResult = $jobfairFloorplanStandResult->toArray();
}
if (!$jobfairFloorplanStandResult || !$jobfairFloorRes) {
return response()->json(['status'=>0,'msg'=>"参数错误"]);
}
if($type)
{
foreach ($jobfairFloorplanStandResult as $key => $val) {
$audit = $this->jobfairCompanyRepository->findCom(['position_id'=>$val['id'], 'jobfair_id'=>$jobfair_id,['audit','<>', 3]]);
if (!$audit) {
$jobfairFloorplanStandResult[$key]['status'] =1;
} else {
if ($audit->audit == 1) {
$jobfairFloorplanStandResult[$key]['status'] = 4;
$jobfairFloorplanStandResult[$key]['company'] = $audit;
} elseif ($audit->audit == 3) {
$jobfairFloorplanStandResult[$key]['status'] = 1;
} else {
$jobfairFloorplanStandResult[$key]['status'] = 3;
$jobfairFloorplanStandResult[$key]['company'] = $audit;
}
}
}
}else{
foreach ($jobfairFloorplanStandResult as $key => $val) {
if ($val['type'] == 2) {
$jobfairFloorplanStandResult[$key]['status'] = 2;
} else {
$audit = $this->jobfairCompanyRepository->findComApi(['position_id'=>$val['id'], 'jobfair_id'=>$jobfair_id,['audit','<>', 3]]);
if (!$audit) {
$jobfairFloorplanStandResult[$key]['status'] =1;
} else {
if($audit->companys){
unset($audit->companys->password);
}
if ($audit->audit == 1) {
$jobfairFloorplanStandResult[$key]['status'] = 4;
$jobfairFloorplanStandResult[$key]['company'] = $audit;
} elseif ($audit->audit == 3) {
$jobfairFloorplanStandResult[$key]['status'] = 1;
} else {
$jobfairFloorplanStandResult[$key]['status'] = 3;
$jobfairFloorplanStandResult[$key]['company'] = $audit;
}
}
}
}
}
return response()->json(['status'=>1,'imageUrl'=>upload_asset($jobfairFloorRes->bg_images),'value'=>$jobfairFloorplanStandResult]);
}
public function getJobfairBlacklistCompany()
{
$need_array = [];
$blacklistCompany = $this->jobfairCompanyRepository->getBlacklistCompany();
if (!$blacklistCompany->isEmpty()) {
foreach ($blacklistCompany as $key => $val) {
$need_array[] = $val->company_id;
}
}
$getManyBlackCompany = $this->jobfairCompanyRepository->getManyBlackCompany();
if (!$getManyBlackCompany->isEmpty()) {
foreach ($getManyBlackCompany as $key => $val) {
if ($val->count>=3) {
$need_array[] = $val->company_id;
}
}
}
$company_id = array_unique($need_array);
return $company_id;
}
public function getJobfairCompany()
{
return $this->jobfairBlackListRepository->threeMonthBlackCompany();
}
public function getJobfairOpen()
{
$jonfair_id = [];
$jobfair = $this->jobfairRepository->getJobfairOpen();
foreach ($jobfair as $key => $val) {
if ($val->predetermined_start) {
if ($val->predetermined_start>time()||$val->predetermined_end