Commit 2b2e8d88 by 徐康

创建订单时间check修改

parent 3762e3c7
......@@ -68,6 +68,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.awt.geom.Point2D;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
......@@ -218,6 +220,9 @@ public class CheckMCCafeOrder {
String takeMealFlag = createOrderVo.getTakeMealFlag();
String takeMealTime = createOrderVo.getTakeMealTime();
String expectTime = createOrderVo.getExpectTime();
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.setLenient(false);
//立即送达
if("0".equals(takeMealFlag)) {
......@@ -226,10 +231,10 @@ public class CheckMCCafeOrder {
throw new ServiceException(ResponseResult.STORE_ITEM_CHECK_CLOSE);
}
// 校验下单时间是否在营业时间内
checkOrderExpectTime(storeResponseDto, new Date());
checkOrderExpectTime(storeResponseDto, now);
// 外卖单选择立即送达的话,下单时间必须在店铺外卖时间内
if(createOrderVo.getOrderType().compareTo(CreateOrderType.TAKE_OUT.getCode()) == 0) {
checkTakeOutTime(storeResponseDto, new Date());
checkTakeOutTime(storeResponseDto, now);
}
}
//有预约时间的自提单
......@@ -246,10 +251,15 @@ public class CheckMCCafeOrder {
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.setTime(now);
calendar.add(Calendar.MINUTE, minute);
Date takeMealDateTime = calendar.getTime();
//当顾客指定送达时间小于当前时间,订单记录类型为即时单
if (takeMealDateTime != null && takeMealDateTime.before(now)) {
takeMealDateTime = null;
}
if(takeMealDateTime != null){
//校验营业时间
checkOrderExpectTime(storeResponseDto, takeMealDateTime);
......@@ -261,7 +271,22 @@ public class CheckMCCafeOrder {
}
//有预约时间的外卖单
else if(CreateOrderType.TAKE_OUT.getCode().equals(createOrderVo.getOrderType()) && StringUtils.isNotBlank(expectTime)) {
Date takeOutDateTime = DateUtil.convert2Date(createOrderVo.getExpectTime(), "yyyy-MM-dd HH:mm:ss");
Date takeOutDateTime = null;
try {
takeOutDateTime = sdf.parse(createOrderVo.getExpectTime());
} catch (ParseException e) {
throw new ServiceException(ResponseResult.ORDER_TAKE_OUT_TIME_ERROR);
}
//当顾客指定送达时间小于当前时间,订单记录类型为即时单
if (takeOutDateTime != null && takeOutDateTime.before(now)) {
takeOutDateTime = null;
}
//当顾客指定送达时间小于当前时间+提前预约时间时,订单记录类型为即时单
if (takeOutDateTime != null && storeResponseDto.getServiceTime() != null
&& takeOutDateTime.before(DateUtil.addMinutes(now, storeResponseDto.getServiceTime()))) {
takeOutDateTime = null;
}
if(takeOutDateTime != null) {
//校验营业时间
checkOrderExpectTime(storeResponseDto, takeOutDateTime);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment