本文整理汇总了PHP中DateUtil::calcDayInWeek方法的典型用法代码示例。如果您正苦于以下问题:PHP DateUtil::calcDayInWeek方法的具体用法?PHP DateUtil::calcDayInWeek怎么用?PHP DateUtil::calcDayInWeek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateUtil
的用法示例。
在下文中一共展示了DateUtil::calcDayInWeek方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getValidAppointmentTime
/**
* 获得有效的预约时间
* 首先查询 指定日期 美容师休息表, 获得休息时间
* 再查询 指定日期 美容师 已接受预定的 时间
*
* @param $beautician_id 美容师ID
* @param $day 查询日期
*/
public function getValidAppointmentTime($beautician_id, $day)
{
if (!$beautician_id || !$day) {
ResponseUtil::failure('参数错误!');
}
$today = date('Y-m-d');
if ($day < $today) {
ResponseUtil::failure('错误的预约时间!');
}
// 查询美容师
$beautician = (new BeauticianModel())->readOne($beautician_id);
if (!$beautician) {
ResponseUtil::failure('美容师不存在!');
}
// 查询休息时间
$beauticianRest = (new CurdUtil(new BeauticianRestModel()))->readAll('beautician_rest_id desc', array('beautician_id' => $beautician_id, 'disabled' => 0, 'rest_day' => $day));
// 获得工作时间
$workTime = new WorkTimeUtil();
list($dayStart, $dayEnd) = $workTime->explode($workTime->getAllDay());
// 指定日期的所有预约时间段
$appointmentTimes = DateUtil::generateAppointmentTime($day, $dayStart, $dayEnd);
// 美容师制定日期休息时间段
// 当值为0时, 说明不能预约
if ($beauticianRest) {
foreach ($beauticianRest as $_beauticianRest) {
$beauticianRestAppointmentTimes = DateUtil::generateAppointmentTime($day, $_beauticianRest['start_time'], $_beauticianRest['end_time']);
foreach ($appointmentTimes as $k => $time) {
if (array_key_exists($k, $beauticianRestAppointmentTimes)) {
$appointmentTimes[$k] = 0;
}
}
}
}
// 获得制定日期已经预约的时间段,订单状态为已支付
$payedOrders = (new OrderModel())->getOrderByBeauticianIdAndAppointmentDay($beautician_id, $day);
if ($payedOrders) {
foreach ($payedOrders as $payedOrder) {
$orderAppointmentTime = DateUtil::generateAppointmentTime($payedOrder['appointment_day'], $payedOrder['appointment_start_time'], $payedOrder['appointment_end_time']);
foreach ($appointmentTimes as $k => $time) {
if (array_key_exists($k, $orderAppointmentTime)) {
$appointmentTimes[$k] = 0;
}
}
}
}
// 小于当前时间不能预约
if ($today == $day) {
$now = date('H:i');
foreach ($appointmentTimes as $k => $time) {
if ($k < $now) {
$appointmentTimes[$k] = 0;
}
}
}
// 查询线下预约
$offlineOrders = (new OfflineOrderModel())->getOrderByBeauticianIdAndAppointmentDay($beautician_id, $day);
if ($offlineOrders) {
foreach ($offlineOrders as $offlineOrder) {
$orderAppointmentTime = DateUtil::generateAppointmentTime($offlineOrder['appointment_day'], $offlineOrder['appointment_start_time'], $offlineOrder['appointment_end_time']);
foreach ($appointmentTimes as $k => $time) {
if (array_key_exists($k, $orderAppointmentTime)) {
$appointmentTimes[$k] = 0;
}
}
}
}
$beauticianWorkTime = (new WorkTimeUtil())->beauticianWorkTime;
$week = DateUtil::calcDayInWeek($day);
$workTimeType = $beauticianWorkTime[$beautician_id][$week];
// 判断早班,晚班
if ($workTimeType == BeauticianModel::ALL_DAY) {
} elseif ($workTimeType == BeauticianModel::MORNING_SHIFT) {
$morningShiftTimes = $workTime->explode($workTime->getMorningShift());
$workAppointmentTime = DateUtil::generateAppointmentTime($day, $morningShiftTimes[0], $morningShiftTimes[1]);
foreach ($appointmentTimes as $k => $time) {
if (!array_key_exists($k, $workAppointmentTime)) {
$appointmentTimes[$k] = 0;
}
}
} elseif ($workTimeType == BeauticianModel::NIGHT_SHIFT) {
$nightShiftTimes = $workTime->explode($workTime->getNightShift());
$workAppointmentTime = DateUtil::generateAppointmentTime($day, $nightShiftTimes[0], $nightShiftTimes[1]);
foreach ($appointmentTimes as $k => $time) {
if (!array_key_exists($k, $workAppointmentTime)) {
$appointmentTimes[$k] = 0;
}
}
} elseif ($workTimeType == BeauticianModel::MIDDAY_SHIFT) {
$middayShiftTimes = $workTime->explode($workTime->getMiddayShift());
$workAppointmentTime = DateUtil::generateAppointmentTime($day, $middayShiftTimes[0], $middayShiftTimes[1]);
foreach ($appointmentTimes as $k => $time) {
if (!array_key_exists($k, $workAppointmentTime)) {
//.........这里部分代码省略.........