diff --git a/Laravel/app/Services/Admin/YeWu/AppointmentService.php b/Laravel/app/Services/Admin/YeWu/AppointmentService.php index d73893f..d912fa6 100644 --- a/Laravel/app/Services/Admin/YeWu/AppointmentService.php +++ b/Laravel/app/Services/Admin/YeWu/AppointmentService.php @@ -90,14 +90,33 @@ class AppointmentService ->where(function ($query) use ($id_card_num, $encode_id_card_num) { $query->where('a.id_card_num', $id_card_num) ->orWhere('a.id_card_num', $encode_id_card_num); - }) - ->where(['a.type' => $type,'a.is_del'=>0, ['a.created_at', '>=', $firstDay], ['a.created_at', '<=', $lastDay]]); + }); + if($type==2){ $c=$c->whereIn('a.status', [1, 2]); } if($type==1){ + $month=config('app.globals.HealthyCardTimeRange'); + //如果是健康证体检,则先查寻是否有体检记录 + $cha_jkz=DB::table('examination_records')->where(['id_card_num'=>$encode_id_card_num])->orderBy('id','desc')->first(); + //,如果有判断是否快到期(先不判断是否体检通过),能否继续预约 + if(!!$cha_jkz){ + + $date = new DateTime($cha_jkz->created_at); + $date->modify('+'.$month.' months'); + $now = new DateTime(); + if ($date > $now) { + return \Yz::Return(false,'已体检过'); + } + } + //查询是否有预约记录 + $currentDate = date('Y-m-d'); + $firstDay = date('Y-m-d', strtotime('-'.$month.' months', strtotime($currentDate))); + // $firstDay = date('Y-01-01', strtotime($currentYear)); + $lastDay = date('Y-12-31', strtotime($currentYear)); $c=$c->whereIn('a.status', [2]); } + $c=$c->where(['a.type' => $type,'a.is_del'=>0, ['a.created_at', '>=', $firstDay], ['a.created_at', '<=', $lastDay]]); $c=$c->get(); if(count($c)){ diff --git a/Laravel/app/Services/mH5/OrganizationService.php b/Laravel/app/Services/mH5/OrganizationService.php index 11d9a60..b132d0b 100644 --- a/Laravel/app/Services/mH5/OrganizationService.php +++ b/Laravel/app/Services/mH5/OrganizationService.php @@ -1,6 +1,7 @@ where(['id_card_num'=>$cha_info[0]->id_card_num])->orderBy('id','desc')->first(); + //,如果有判断是否快到期(先不判断是否体检通过),能否继续预约 + if(!!$cha_jkz){ + $date = new DateTime($cha_jkz->created_at); + $date->modify('+'.$month.' months'); + $now = new DateTime(); + if ($date > $now) { + return \Yz::Return(false,'本年度已经体检过,请于:'. $date->format('Y-m-d H:i:s').'后再进行预约'); + } + } + //查询是否有预约记录 + $currentDate = date('Y-m-d'); + $firstDay = date('Y-m-d', strtotime('-'.$month.' months', strtotime($currentDate))); + // $firstDay = date('Y-01-01', strtotime($currentYear)); + $lastDay = date('Y-12-31', strtotime($currentYear)); + + } - $cha=DB::table('appointment_record')->where([['id_card_num','=',$cha_info[0]->id_card_num],['created_at','>',$firstDay],['created_at','<',$lastDay]])->whereIn('status',[1,2])->get(); + $cha=DB::table('appointment_record')->where([['id_card_num','=',$cha_info[0]->id_card_num],['is_del','=','0'],['created_at','>',$firstDay],['created_at','<',$lastDay]])->whereIn('status',[1,2])->get(); if(count($cha)) { return \Yz::Return(false,'本年度已经预约过,无法继续预约'); } diff --git a/Laravel/config/app.php b/Laravel/config/app.php index 55e9b7d..246de6c 100644 --- a/Laravel/config/app.php +++ b/Laravel/config/app.php @@ -14,6 +14,8 @@ return [ 'WxReturnCodeUrl_server'=>'https://www.yanzai.vip/common/mH5/#/getWxCode/', //获取code后引导返回到前端的地址 生产 'GongWeiBaseUrl'=>'http://114.242.58.53:8082/jkdacp/webservice/DPService?wsdl', //公卫接口地址,外网测试地址 + 'HealthyCardTimeRange'=>11,//健康证过期时间跨度 单位 月 + ], /*