memberInfoService = $memberInfoService; $this->memberService = $memberService; $this->registerService = $registerService; $this->memberInfoRepository = $memberInfoRepository; $this->jobfairPersonSignedRepository = $jobfairPersonSignedRepository; $this->jobfairRepository = $jobfairRepository; $this->jobfairCompanyRepository = $jobfairCompanyRepository; $this->taskRepository = $taskRepository; $this->memberHandselRepository = $memberHandselRepository; $this->memberPointRepository = $memberPointRepository; $this->companyRepository = $companyRepository; } public function idcard(Request $request) { $error = $this->idcardValidator($request); if($error){ $data = [ 'code'=>0, 'message'=> $error, ]; return response()->json($data); } $idcard = $request->idcard; $info = []; $where = [ ['holddate_start', '<', strtotime("+60 minute")], ['holddate_end', '>', strtotime("-60 minute")], ['display', '=', 1], ['subsite_id', '=', get_subsite_id()], ]; $jobfair = $this->jobfairRepository->getOneOpenJobfair($where); if($jobfair) { $info['jobfairid'] = $jobfair->id; }else { $data = [ 'code'=>0, 'message'=> '暂无举办中的招聘会', ]; return response()->json($data); } $type = $request->input('type','in'); $info['type'] = $type == 'in' ? 1 : 2; $info['name'] = $request->input('name',''); $info['en_name'] = $request->input('en_name',''); $info['nation'] = $request->input('nation',''); $info['address'] = $request->input('address',''); $info['effect_start_time'] = $request->input('effect_start_time',''); $info['effect_end_time'] = $request->input('effect_end_time',''); if(!$info['effect_start_time']){ unset( $info['effect_start_time']); } if(!$info['effect_end_time']){ unset( $info['effect_end_time']); } $info['government'] = $request->input('government',''); $info['idcard'] = $idcard; $member_info = $this->memberInfoService->getInfo(['id_card' => $idcard]); if($member_info){ $info['uid'] = $member_info->uid; $info['utype'] = $member_info->members->utype; //判断该身份之前是否有进入场,有则修改uid $updateDate = ['uid'=> $info['uid']]; $this->jobfairPersonSignedRepository->updateDate(['idcard'=>$info['idcard']],$updateDate); } $info1 = $this->subIdcard($idcard); $info = array_merge($info,$info1); $info['sign_type'] = 1; $this->jobfairPersonSignedRepository->createInfo($info); $data = [ 'code'=>1, 'message'=>[ 'type'=>1, 'name'=>$info['name'], 'id'=>$idcard, ], ]; return response()->json($data); } public function qrcode(Request $request) { $error = $this->qrcodeValidator($request); if($error){ $data = [ 'code'=>0, 'message'=> $error, ]; return response()->json($data); } $where = [ ['holddate_start', '<', strtotime("+60 minute")], ['holddate_end', '>', strtotime("-60 minute")], ['display', '=', 1], ['subsite_id', '=', get_subsite_id()], ]; $jobfair = $this->jobfairRepository->getOneOpenJobfair($where); if($jobfair) { $info['jobfairid'] = $jobfair->id; }else { $data = [ 'code'=>0, 'message'=> '暂无举办中的招聘会', ]; return response()->json($data); } $type = $request->input('type','in'); $info['type'] = $type == 'in' ? 1 : 2; $qrcode = $request->qrcode; $hash_id = substr($qrcode,strrpos($qrcode,'/')+1); $res = hashid_decode($hash_id); if(!$res){ $data = [ 'code'=>0, 'message'=> '二维码错误', ]; return response()->json($data); } $info['uid'] = $res['id']; $info['utype'] = $res['utype']; if($res['utype'] == 1) { $company = $this->companyRepository->getCompanyInfo(['id'=>$res['id']]); $info['name'] = $company->companyname; $list = $this->jobfairCompanyRepository->findWhere(['jobfair_id'=>$info['jobfairid'],'company_id'=>$res['id']]); if($info['type'] ==1&&$list->isNotEmpty()){ foreach ($list as $value) { $time = date('H:i:s',$jobfair->holddate_start); $date = date('Y-m-d',time()); $timestamp = strtotime($date.' '.$time); if($timestamp >= strtotime("-30 minute")){ $info['status'] = 0; $this->jobfairCompanyRepository->update(['type'=>4,'signed_time'=>time()],$value->id); }elseif($timestamp < strtotime("-30 minute")){ $info['status'] = 1; if($value->type != 4) { $this->jobfairCompanyRepository->update(['type'=>1,'signed_time'=>time()],$value->id); } $this->jobfairCompanyRepository->update($date,$value->id); } } } $info['address'] = $company->address; $message = [ 'type'=>'2', 'name'=>$company->companyname, 'id'=>$company->organization_code, ]; Cache::put($hash_id, time(),120); }else { $memberInfo = $this->memberInfoService->getInfo(['uid' => $info['uid']]); if($memberInfo){ $info['name'] = $memberInfo->realname; $info['idcard'] = $memberInfo->id_card; $info['sex'] = $memberInfo->sex; $info['address'] = $memberInfo->householdaddress_cn; $info1 = $this->subIdcard($info['idcard'] ); $info = array_merge($info,$info1); $message= [ 'type'=>'1', 'name'=>$memberInfo->realname, 'id'=>$memberInfo->id_card, ]; //判断该身份之前是否有进入场,有则修改uid $updateDate = ['uid'=> $info['uid']]; $this->jobfairPersonSignedRepository->updateDate(['idcard'=>$info['idcard']],$updateDate); Cache::put($hash_id, time(),120); }else{ $data = [ 'code'=>0, 'message'=> '请先完善个人信息', ]; return response()->json($data); } } $info['sign_type'] = 2; $this->jobfairPersonSignedRepository->createInfo($info); $data = [ 'code'=>1, 'message'=> $message, ]; return response()->json($data); } public function idcardValidator($request) { $error = ''; // if(!$request->type){ // $error = 'type不能为空'; // return $error; // } // if(!in_array($request->type,['in','out'])){ // $error = 'type值错误'; // return $error; // } if(!$request->idcard){ $error = '身份证不能为空'; return $error; } if(!isCreditNo($request->idcard)){ $error = '身份证格式不正确'; return $error; } } public function qrcodeValidator($request) { $error = ''; // if(!$request->type){ // $error = 'type不能为空'; // return $error; // } // if(!in_array($request->type,['in','out'])){ // $error = 'type值错误'; // return $error; // } if(!$request->qrcode){ $error = 'qrcode不能为空'; return $error; } } //根据身份证截取信息 protected function subIdcard($idcard) { $data = []; $sexInt = (int)substr($idcard, 16, 1); $data['sex'] = $sexInt % 2 == 0 ? '2' : '1'; $data['birthday'] = substr($idcard,6,4); return $data; } /** * Unicode字符转换成utf8字符 * @param [type] $unicode_str Unicode字符 * @return [type] Utf-8字符 */ protected function unicode_to_utf8($unicode_str) { $utf8_str = ''; $code = intval(hexdec($unicode_str)); //这里注意转换出来的code一定得是整形,这样才会正确的按位操作 $ord_1 = decbin(0xe0 | ($code >> 12)); $ord_2 = decbin(0x80 | (($code >> 6) & 0x3f)); $ord_3 = decbin(0x80 | ($code & 0x3f)); $utf8_str = chr(bindec($ord_1)) . chr(bindec($ord_2)) . chr(bindec($ord_3)); return $utf8_str; } public function findJobfair() { $where = [ ['holddate_start', '<', strtotime("+60 minute")], ['holddate_end', '>', strtotime("-60 minute")], ['display', '=', 1], ['subsite_id', '=', get_subsite_id()], ]; $jobfair = $this->jobfairRepository->getOneOpenJobfair($where); if($jobfair) { $data = [ 'code'=>1, 'message'=> $jobfair, ]; return response()->json($data); }else { $data = [ 'code'=>0, 'message'=> '暂无举办中的招聘会', ]; return response()->json($data); } } }