jobfairoutRepository = $jobfairoutRepository;
        $this->jobfairoutCompanyRepository = $jobfairoutCompanyRepository;
        $this->jobfairoutPutJobRepository = $jobfairoutPutJobRepository;
        $this->memberSetmealRepository = $memberSetmealRepository;
        $this->memberPointRepository = $memberPointRepository;
        $this->jobfairoutSchoolRepository = $jobfairoutSchoolRepository;
        $this->jobfairService = $jobfairService;
    }
    /**近期招聘会
     * @return array
     */
    public function jobfairIndex($user)
    {
        $jobfairList = $this->jobfairoutRepository->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 $id
     * @return array
     */
    public function jobfairShow($id,$user)
    {
        $map1 =['id'=>$id];
        $jobfair = $this->jobfairoutRepository->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;
        }
        $jobfair->phone_html = '';
        if($jobfair->phone){
            foreach (explode(',',$jobfair->phone) as $value){
                $jobfair->phone_html .= ''.$value .'
';
            }
        }
        //空余展位数
        $map = [
            'jobfair_id'=>$id, ['audit','<>',3]
        ];
        $companyCount = $this->jobfairoutCompanyRepository->getComCount($map);
        $jobfair->countSurplus = $jobfair->number - $companyCount;
        //判断是否预定过
        if($user){
            $jobfair->is_appointment = $this->jobfairoutCompanyRepository->jobfairAppointment(['jobfair_id'=>$id,['audit','<>',3],'company_id'=>$user->id]);
        }else{
            $jobfair->is_appointment = false;
        }
        //学校列表
        $schools = [];
        if($jobfair->school_id){
            $schools = $this->jobfairoutSchoolRepository->getSchool(explode(',',$jobfair->school_id));
        }
        return [
            'status'=>1,
            'jobfair'=>$jobfair,
            'schools'=>$schools,
        ];
    }
    /**招聘会企业
     * @param $request
     * @param $id
     * @return array
     */
    public function jobfairShowCom($request, $id,$user)
    {
        $jobfair = $this->jobfairoutRepository->findJobfair(['id'=>$id]);
        if (!$jobfair) {
            return ['status'=>0, 'msg'=>'查无此招聘会'];
        }
        $map = [
            'jobfair_id'=>$id, ['audit','<>',3]
        ];
        $companyCount = $this->jobfairoutCompanyRepository->getComCount($map);
        $jobfair->countSurplus = $jobfair->number - $companyCount;
        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;
        }
        //判断是否预定过
        if($user){
            $jobfair->is_appointment = $this->jobfairoutCompanyRepository->jobfairAppointment(['jobfair_id'=>$id,['audit','<>',3],'company_id'=>$user->id]);
        }else{
            $jobfair->is_appointment = false;
        }
        $where = ['jobfair_id'=>$id,'audit'=>1];
        $offset = isset($request->page)?$request->page:0;
        $limit = 20;
        $jobfairCompany = $this->jobfairoutCompanyRepository->findCompany($where, $offset, $limit);
        foreach ($jobfairCompany as $key => $val) {
            $where = [
                'jobfair_id'=>$id,
                'company_id'=>$val->company_id,
            ];
            $val->jobfairPutJob = $this->jobfairoutPutJobRepository->getJobfairJob($where);
        }
        if ($request->ajax()) {
            return  $jobfairCompany;
        }
        $more = count($jobfairCompany) >= $limit ? true : false;
        $jobsSum = $this->jobfairoutPutJobRepository->getNeedPerson($id);
        $needPersonCount = isset($jobsSum['sum']) ? $jobsSum['sum'] : 0;
        //学校列表
        $schools = [];
        if($jobfair->school_id){
            $schools = $this->jobfairoutSchoolRepository->getSchool(explode(',',$jobfair->school_id));
        }
        return [
            'status'=>1,
            'jobfair'=>$jobfair,
            'jobfairCompany'=>$jobfairCompany,
            'companyCount'=>$companyCount,
            'more'=>$more,
            'schools'=>$schools,
            'needPersonCount'=>$needPersonCount,
        ];
    }
    public function jobfairAppointmentSave($jobfairInfo, $user)
    {
        //允许预订 举办开始日期大于当前日期  预订结束时间大于当前时间  允许在线预订
        if ($jobfairInfo->predetermined_status == 2) {
            return response()->json(['status'=>0, 'msg'=>"很抱歉,招聘会已停止预定"]);
        }
        if (time() > $jobfairInfo->holddate_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['pay_type'] = $jobfairInfo->is_commonweal;
        DB::beginTransaction();
        try {
            if (!$this->jobfairoutCompanyRepository->create($insertData)) {
                throw new \Exception('招聘会预定失败!');
            }
            if ($jobfairInfo->is_commonweal != 3) {
                $res = $this->jobfairService->payType($jobfairInfo->is_commonweal, $num, $user);
                if (!$res['status']) {
                    throw new \Exception($res['msg']);
                }
            }
            DB::commit();
            return response()->json(['status'=>1, 'msg'=>"注意:恭喜您,预定成功,请到定展记录里填写  单位信息、职位信息、参会人",'data'=>['companyname'=>$user->companyname]]);
        } catch (\Exception $e) {
            DB::rollback();
            return response()->json(['status'=>0, 'msg'=>$e->getMessage()]);
        }
    }
    /**职位详情
     * @param $jobfair_id
     * @param $job_id
     * @return array
     */
    public function jobfairShowJob($id)
    {
        $jobInfo = $this->jobfairoutPutJobRepository->getOne(['id'=>$id]);
        if (!$jobInfo) {
            return ['status'=>0, 'msg'=>'查无此职位!'];
        }
        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,
        ];
    }
    public function getJobfairOpen()
    {
        $jonfair_id = [];
        $jobfair = $this->jobfairoutRepository->getJobfairOpen();
        foreach ($jobfair as $key => $val) {
            if ($val->predetermined_start) {
                if ($val->predetermined_start>time()||$val->predetermined_end