Commit 3f3973a0 by ping.wu

after时间相等问题比较修改

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