=? and a.date<=? '; array_push($canshu,$arr['searchInfo']['dateRange'][0],$arr['searchInfo']['dateRange'][1]); } if($arr['group']==7){ $cha=DB::table('medical_institution')->where(['link_user_id'=>$arr['userid']])->get(); $sql=$sql .' and a.org_id=?'; array_push($canshu, $cha[0]->id); }else{ if($arr['searchInfo']['orgId']){ $sql=$sql .' and a.org_id=?'; array_push($canshu, $arr['searchInfo']['orgId']); } } array_push($canshu,($arr['page']-1)*$arr['pageSize'],$arr['pageSize']); $query=DB::select("select a.*,b.org_name from appointment_record as a LEFT JOIN medical_institution as b on a.org_id=b.id ".$sql." order by a.id desc limit ?,?",$canshu); $count=DB::select("select count(*) as c from appointment_record as a ".$sql,$canshu); return \Yz::Return(true,'',['list'=>$query,'count'=>$count[0]->c]); } //检测是否有登记预约记录 public function CheckAppointment($id_card_num,$type){ if(strlen($id_card_num)>0){ date_default_timezone_set('PRC'); $currentYear = date('Y'); $firstDay = date('Y-01-01', strtotime($currentYear)); $lastDay = date('Y-12-31', strtotime($currentYear)); //查询预约登记表 if($type==2 and $this->isOver65($id_card_num)===false){ return \Yz::echoError1("年龄不满足条件"); } $c=DB::table('appointment_record as a') ->leftJoin('medical_institution as b', 'a.org_id', '=', 'b.id') ->select(['a.id','a.org_id','a.id_card_num','a.created_at as insertime','b.org_name']) ->where(['a.id_card_num'=>$id_card_num,'a.type'=>$type,['a.created_at','>=',$firstDay],['a.created_at','<=',$lastDay]])->whereIn('a.status',[1,2])->get(); if(count($c)){ $result['status']=false; $result['msg']='已体检过'; $result['info']=$c; }else{ $result['status']=true; $result['msg']='可以继续,本年度无免费体检记录'; $result['info']=$c; } }else{ $result['status']=false; $result['msg']='用户证件号未传'; } return $result; } function isOver65($idCard) { // 从身份证号中提取出生日期 $birthYear = substr($idCard, 6, 4); $birthMonth = substr($idCard, 10, 2); $birthDay = substr($idCard, 12, 2); // 将出生日期转换为日期对象 $birthdate = new DateTime($birthYear . '-' . $birthMonth . '-' . $birthDay); // 获取当前日期 $currentDate = new DateTime(); // 计算年龄差 $ageDiff = $birthdate->diff($currentDate)->y; // 判断年龄是否大于65岁 if ($ageDiff > 65) { return true; } else { return false; } } }