|
|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
<?php
|
|
|
|
|
namespace App\Services\mH5;
|
|
|
|
|
use App\Services\Admin\YeWu\AppointmentService;
|
|
|
|
|
use DateTime;
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
use App\Services\mH5\PersonService;
|
|
|
|
|
class OrganizationService
|
|
|
|
|
@ -81,8 +82,28 @@ class OrganizationService
|
|
|
|
|
$currentYear = date('Y');
|
|
|
|
|
$firstDay = date('Y-01-01', strtotime($currentYear));
|
|
|
|
|
$lastDay = date('Y-12-31', strtotime($currentYear));
|
|
|
|
|
if($type==1){
|
|
|
|
|
$month=config('app.globals.HealthyCardTimeRange');
|
|
|
|
|
//如果是健康证体检,则先查寻是否有体检记录
|
|
|
|
|
$cha_jkz=DB::table('examination_records')->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,'本年度已经预约过,无法继续预约');
|
|
|
|
|
}
|
|
|
|
|
|