StoreTime 和 OrderTime 处理问题
假设商店在 15:00 开门,但顾客只能在 16:00 之后下订单(取决于商店开门时间),代码确实按预期工作下面
$nowtime = $this->HourMinuteToDecimal(date('H:i'));
$OrderTime = $this->HourMinuteToDecimal('16:00');
$storeOpeningTime = $this->HourMinuteToDecimal($data[$key]['opentime']);
if ($nowtime >= $OrderTime && ($OrderTime >= $storeOpeningTime)) {
$data[$key]['open'] = 1;
} else {
$data[$key]['open'] = 0;
}
public function HourMinuteToDecimal($hour_minute) {
$t = explode(':', $hour_minute);
return $t[0] * 60 + $t[1];
}
有一个问题,如果商店开门时间是 18:00 怎么办但默认订单时间是 16:00,如何解决这些问题?在此情况下,客户只能在18:00之后下订单。
一般规则:顾客只能在16:00(订单时间)之后下订单,但首先取决于商店营业时间。
Let say Stores Open at 15:00 but customers can only make orders after 16:00 (depending on the Stores Opening time), code does work below as expected
$nowtime = $this->HourMinuteToDecimal(date('H:i'));
$OrderTime = $this->HourMinuteToDecimal('16:00');
$storeOpeningTime = $this->HourMinuteToDecimal($data[$key]['opentime']);
if ($nowtime >= $OrderTime && ($OrderTime >= $storeOpeningTime)) {
$data[$key]['open'] = 1;
} else {
$data[$key]['open'] = 0;
}
public function HourMinuteToDecimal($hour_minute) {
$t = explode(':', $hour_minute);
return $t[0] * 60 + $t[1];
}
There is a problem, what if a Store-Open-Time is 18:00 but default Order-Time is 16:00, How to fix these solution? Customer can only place order after 18:00 in that case.
General Rule: Customer can only place order after 16:00 (Order-Time) but depending on the Store Open Time first.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
订单是在 OrderTime 和 StoreOpeningTime 之后进行的,因此这意味着相关时间是这两个时间中最晚的一个。
Orders are taken after OrderTime and StoreOpeningTime, so that means the relevant time is the latest one of those two.