123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813 |
- <?php
- /**
- * Created by PhpStorm.
- * User: wuzhenke
- * Date: 2019/1/24
- * Time: 17:26
- */
- namespace App\Services\Jobfair;
- use App\Models\Jobfair\JobfairBlacklist;
- use App\Repositories\CategoryRepository;
- use App\Repositories\Jobfair\JobfairBlackListRepository;
- use App\Repositories\Jobfair\JobfairCompanyRepository;
- use App\Repositories\Jobfair\JobfairFloorPlanRepository;
- use App\Repositories\Jobfair\JobfairFloorplanStandRepository;
- use App\Repositories\Jobfair\JobfairManagementRepository;
- use App\Repositories\Jobfair\JobfairPersonalJobsApplyRepository;
- use App\Repositories\Jobfair\JobfairPutJobRepository;
- use App\Repositories\Jobfair\JobfairRepository;
- use App\Repositories\MemberHandselRepository;
- use App\Repositories\MemberLogRepository;
- use App\Repositories\MemberPointRepository;
- use App\Repositories\MemberSetmealRepository;
- use App\Repositories\MembersSetmealLogRepository;
- use App\Repositories\ResumeRepository;
- use App\Services\Common\EmailService;
- use App\Services\SubsiteService;
- use Illuminate\Support\Facades\DB;
- use SimpleSoftwareIO\QrCode\Facades\QrCode;
- use App\Models\Subsite;
- use App\Repositories\Jobfairout\JobfairoutRepository;
- use App\Repositories\ArticleRepository;
- class JobfairService
- {
- protected $jobfairRepository;
- protected $jobfairFloorplanStandRepository;
- protected $jobfairCompanyRepository;
- protected $jobfairPutJobRepository;
- protected $jobfairFloorPlanRepository;
- protected $jobfairBlackListRepository;
- protected $memberSetmealRepository;
- protected $memberPointRepository;
- protected $memberHandselRepository;
- protected $membersSetmealLogRepository;
- protected $resumeRepository;
- protected $jobfairPersonalJobsApplyRepository;
- protected $jobfairManagementRepository;
- protected $subsiteService;
- protected $memberLogRepository;
- protected $jobfairoutRepository;
- protected $articleRepository;
- protected $emailService;
- /**
- * @var CategoryRepository
- */
- private $categoryRepository;
- /**
- * JobfairService constructor.
- * @param $jobfairRepository
- * @param $jobfairFloorplanStandRepository
- * @param $jobfairCompanyRepository
- * @param $jobfairPutJobRepository
- * @param $jobfairFloorPlanRepository
- * @param $jobfairBlackListRepository
- * @param $memberSetmealRepository
- * @param $memberPointRepository
- * @param $memberHandselRepository
- * @param $membersSetmealLogRepository
- * @param $resumeRepository
- * @param $jobfairPersonalJobsApplyRepository
- * @param $jobfairManagementRepository
- * @param $subsiteService
- * @param $articleRepository
- */
- public function __construct(
- JobfairRepository $jobfairRepository,
- SubsiteService $subsiteService,
- JobfairManagementRepository $jobfairManagementRepository,
- JobfairPersonalJobsApplyRepository $jobfairPersonalJobsApplyRepository,
- ResumeRepository $resumeRepository,
- MembersSetmealLogRepository $membersSetmealLogRepository,
- MemberHandselRepository $memberHandselRepository,
- MemberPointRepository $memberPointRepository,
- MemberSetmealRepository $memberSetmealRepository,
- JobfairBlackListRepository $jobfairBlackListRepository,
- JobfairPutJobRepository $jobfairPutJobRepository,
- JobfairCompanyRepository $jobfairCompanyRepository,
- JobfairFloorPlanRepository $jobfairFloorPlanRepository,
- JobfairFloorplanStandRepository $jobfairFloorplanStandRepository,
- MemberLogRepository $memberLogRepository,
- JobfairoutRepository $jobfairoutRepository,
- ArticleRepository $articleRepository,
- CategoryRepository $categoryRepository,
- EmailService $emailService
- ) {
- $this->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 .= '<a href="tel:'.$value.'" style=" text-decoration: none;color: #0180CF; ">'.$value .'</a><br/><br/>';
- }
- }
- //空余展位数
- $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<time()) {
- $jonfair_id[] = $val->id;
- }
- } else {
- if ($val->holddate_start<time()) {
- $jonfair_id[] = $val->id;
- }
- }
- }
- return $jonfair_id;
- }
- //首页招聘会列表
- public function getJobfairs($params)
- {
- $list = array();
- $where = array(
- array('display','=',1)
- );
- $limit = '';
- if (array_has($params, 'size')) {
- $limit = $params['size'];
- }
- $order = 'holddate_start DESC, if(holddate_end < unix_timestamp(now()),0,1) DESC ,holddate_start ASC';
- if (array_has($params, 'order')) {
- $order = $params['order'];
- }
- $res = $this->jobfairRepository->getJobfairs($where, $order, $limit);
- if ($res->isNotEmpty()) {
- $list = $res;
- }
- return $list;
- }
- //参会企业
- public function jobfairCompany($where,$limit = 20,$page = 1){
- $data = $this->jobfairCompanyRepository->getComPage($where,$limit,$page);
- if(!$data){
- return [];
- }
- return $data;
- }
- //所有职位
- public function jobfairJobs($where,$where1,$page = 20){
- return $this->jobfairPutJobRepository->getJobfairCompanyJobPage($where,$where1,$page);
- }
- //个人预约
- public function jobfairOrders($where,$limit = 20,$page = 1){
- return $this->jobfairPersonalJobsApplyRepository->getPersonApply($where,$limit,$page);
- }
- //面试邀请
- public function jobfairInterview($where,$limit = 20,$page = 1){
- return $this->jobfairPersonalJobsApplyRepository->applyJobsPage($where,$limit,$page);
- }
- public function userCode($user)
- {
- return QrCode::size(250)->generate(route('mobile.qrcode',['hashid'=>hashid_encode($user->id, $user->utype)]));
- }
- public function find($id)
- {
- return $this->jobfairRepository->find($id);
- }
- }
|