Commit 3f3973a0 by ping.wu

after时间相等问题比较修改

parent b338ec89
...@@ -240,58 +240,60 @@ public class CheckOrder { ...@@ -240,58 +240,60 @@ public class CheckOrder {
return pushOrderTime; return pushOrderTime;
} }
public void checkOrderExpectTime(CreateOrderVo createOrderVo,StoreResponse.BizVO storeResponseDto,Date takeMealDateTime){ public void checkOrderExpectTime(CreateOrderVo createOrderVo, StoreResponse.BizVO storeResponseDto, Date takeMealDateTime) {
if(takeMealDateTime == null){ if (takeMealDateTime == null) {
return; return;
} }
//获取门店当天营业时间 //获取门店当天营业时间
Date todayEndDate =null; Date todayEndDate = null;
List<String> todayBusinessTimes = storeCenterService.getTodayBusinessTime(Integer.parseInt(storeResponseDto.getBusinessType()), storeResponseDto.getBusinessHoursDay()); List<String> todayBusinessTimes = storeCenterService.getTodayBusinessTime(Integer.parseInt(storeResponseDto.getBusinessType()), storeResponseDto.getBusinessHoursDay());
if(CollectionUtils.isEmpty(todayBusinessTimes)){ if (CollectionUtils.isEmpty(todayBusinessTimes)) {
throw new ServiceException(ResponseResult.STORE_BUSINESS_HOUR_ERROR); throw new ServiceException(ResponseResult.STORE_BUSINESS_HOUR_ERROR);
} }
BusinessDate businessDate = getStoreBusinessDate(todayBusinessTimes.get(todayBusinessTimes.size()-1),true); BusinessDate businessDate = getStoreBusinessDate(todayBusinessTimes.get(todayBusinessTimes.size() - 1), true);
todayEndDate = businessDate.getEndDate(); todayEndDate = businessDate.getEndDate();
//在当天营业时间内 //在当天营业时间内
boolean expectTimeInTodayBusinessTime = true; boolean expectTimeInTodayBusinessTime = true;
Date date = new Date(); Date date = new Date();
Date newDate = DateUtil.convert2Date(date,DateUtil.FORMAT_yyyyMMdd_date); Date newDate = DateUtil.convert2Date(date, DateUtil.FORMAT_yyyyMMdd_date);
newDate = DateUtil.addDays(newDate,1); newDate = DateUtil.addDays(newDate, 1);
//隔天预约(在明日凌晨之后且在门店营业结束之后) //隔天预约(在明日凌晨之后且在门店营业结束之后)
if(takeMealDateTime.after(newDate) && takeMealDateTime.after(todayEndDate)){ if (takeMealDateTime.after(todayEndDate) && takeMealDateTime.after(newDate)) {
expectTimeInTodayBusinessTime =false; expectTimeInTodayBusinessTime = false;
} }
if(expectTimeInTodayBusinessTime){ if (expectTimeInTodayBusinessTime) {
boolean inTodayBusinessTime = true; boolean inTodayBusinessTime = true;
for (String todayTime : todayBusinessTimes){ for (String todayTime : todayBusinessTimes) {
//每段营业时间校验 //每段营业时间校验
BusinessDate businessDate2 = getStoreBusinessDate(todayTime,true); BusinessDate businessDate2 = getStoreBusinessDate(todayTime, true);
if (takeMealDateTime.after(businessDate2.getStartDate()) && takeMealDateTime.before(businessDate2.getEndDate())) { if (takeMealDateTime.getTime() >= businessDate2.getStartDate().getTime()
&& takeMealDateTime.getTime() <= businessDate2.getEndDate().getTime()) {
inTodayBusinessTime = false; inTodayBusinessTime = false;
break; break;
} }
} }
if(inTodayBusinessTime){ if (inTodayBusinessTime) {
throw new ServiceException(ResponseResult.ORDER_TAKEMEALTIME_INVAILD); throw new ServiceException(ResponseResult.ORDER_TAKEMEALTIME_INVAILD);
} }
} }
//隔天预约 //隔天预约
if(!expectTimeInTodayBusinessTime){ if (!expectTimeInTodayBusinessTime) {
List<String> nextDayBusinessTimes = storeCenterService.getNextDayBusinessTime(Integer.parseInt(storeResponseDto.getBusinessType()), storeResponseDto.getBusinessHoursDay()); List<String> nextDayBusinessTimes = storeCenterService.getNextDayBusinessTime(Integer.parseInt(storeResponseDto.getBusinessType()), storeResponseDto.getBusinessHoursDay());
boolean inNextDayBusinessTime = true; boolean inNextDayBusinessTime = true;
for (String nextDayTime : nextDayBusinessTimes){ for (String nextDayTime : nextDayBusinessTimes) {
BusinessDate storeNextBusinessDate = getStoreBusinessDate(nextDayTime,false); BusinessDate storeNextBusinessDate = getStoreBusinessDate(nextDayTime, false);
if (takeMealDateTime.after(storeNextBusinessDate.getStartDate()) && takeMealDateTime.before(storeNextBusinessDate.getEndDate())) { if (takeMealDateTime.getTime() >= storeNextBusinessDate.getStartDate().getTime()
&& takeMealDateTime.getTime() <= storeNextBusinessDate.getEndDate().getTime()) {
inNextDayBusinessTime = false; inNextDayBusinessTime = false;
break; break;
} }
} }
if(inNextDayBusinessTime){ if (inNextDayBusinessTime) {
throw new ServiceException(ResponseResult.ORDER_TAKEMEALTIME_INVALID); throw new ServiceException(ResponseResult.ORDER_TAKEMEALTIME_INVALID);
} }
} }
if(CreateOrderType.TAKE_OUT.getCode().equals(createOrderVo.getOrderType())){ if (CreateOrderType.TAKE_OUT.getCode().equals(createOrderVo.getOrderType())) {
String deliveryStr = storeResponseDto.getDeliveryHoursDay().replace("-", ",") String deliveryStr = storeResponseDto.getDeliveryHoursDay().replace("-", ",")
.replace("_", ","); .replace("_", ",");
String[] deliverys = deliveryStr.split(","); String[] deliverys = deliveryStr.split(",");
...@@ -313,13 +315,13 @@ public class CheckOrder { ...@@ -313,13 +315,13 @@ public class CheckOrder {
throw new ServiceException(ResponseResult.ORDER_CREATE_TIME_NOT_DELIVERY); throw new ServiceException(ResponseResult.ORDER_CREATE_TIME_NOT_DELIVERY);
} }
// 校验预约配送时间 // 校验预约配送时间
if (expectTimeInTodayBusinessTime && (takeMealDateTime.before(deliveryStartDate) || takeMealDateTime.after(deliveryEndDate))) { if (expectTimeInTodayBusinessTime && (takeMealDateTime.before(deliveryStartDate) || takeMealDateTime.after(deliveryEndDate))) {
throw new ServiceException(ResponseResult.ORDER_CREATE_TIME_NOT_DELIVERY); throw new ServiceException(ResponseResult.ORDER_CREATE_TIME_NOT_DELIVERY);
} }
Date nextDeliveryStartDate = DateUtil.addDays(deliveryStartDate,1); Date nextDeliveryStartDate = DateUtil.addDays(deliveryStartDate, 1);
Date nextDeliveryEndDate = DateUtil.addDays(deliveryEndDate,1); Date nextDeliveryEndDate = DateUtil.addDays(deliveryEndDate, 1);
// 隔日预约外卖校验预约配送时间 // 隔日预约外卖校验预约配送时间
if (!expectTimeInTodayBusinessTime && (takeMealDateTime.before(nextDeliveryStartDate) || takeMealDateTime.after(nextDeliveryEndDate))) { if (!expectTimeInTodayBusinessTime && (takeMealDateTime.before(nextDeliveryStartDate) || takeMealDateTime.after(nextDeliveryEndDate))) {
throw new ServiceException(ResponseResult.ORDER_CREATE_TIME_NOT_DELIVERY); throw new ServiceException(ResponseResult.ORDER_CREATE_TIME_NOT_DELIVERY);
} }
} }
......
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