Commit 7c60e97f by wuwenlong

room status opt;

parent 7d413306
......@@ -31,6 +31,9 @@ public enum RefundStatusEnum {
public static Integer[] getNotRefundStatus(){
return new Integer[]{UNREFUND.getCode(), APPLY.getCode(), REJECT.getCode()};
}
public static Integer[] getRefundedStatus(){
return new Integer[]{INREFUND.getCode(), REFUNDED.getCode()};
}
public Integer getCode(){
return code;
......
......@@ -136,9 +136,10 @@ public class RoomStatusServiceImpl implements RoomStatusService {
Date orderStartDate = Objects.nonNull(order.getStartDate())?order.getStartDate():order.getPreStartDate();
Date orderEndDate = Objects.nonNull(order.getEndDate())?order.getEndDate():order.getPreEndDate();
//如果当前用户已登陆,并且在已下单的房间下单,不计算当前订单的保洁时间
//否则结束时间+30分钟保洁时间
//否则开始时间-30分钟保洁时间,结束时间+30分钟保洁时间
if(Objects.isNull(user)||Objects.isNull(user.getId())||order.getConsumerId().compareTo(user.getId())!=0){
orderEndDate = DateUtils.addMinutes(orderEndDate,Constants.ROOM_LOCK_DELAY_MINUTE);
orderStartDate = DateUtils.addMinutes(orderEndDate,-Constants.ROOM_LOCK_DELAY_MINUTE);
}
if (DateUtils.addSeconds(timeHourDate, 59 * 60 + 59).compareTo(orderStartDate) >= 0 && timeHourDate.compareTo(orderEndDate) < 0) {
......
......@@ -239,7 +239,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SOrder::getStoreId, storeId);
queryWrapper.eq(SOrder::getRoomId, roomId);
queryWrapper.in(SOrder::getRefundStatus, RefundStatusEnum.getNotRefundStatus());
queryWrapper.notIn(SOrder::getRefundStatus, RefundStatusEnum.getRefundedStatus());
queryWrapper.in(SOrder::getStatus, new ArrayList<Integer>(){{
add(OrderStatusEnum.UNUSED.getCode());
add(OrderStatusEnum.INUSE.getCode());
}});
queryWrapper.eq(SOrder::getPayStatus, YesNoEnum.yes.getIndex());
String nowDayStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, day);
String nextDayStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.addDays(day, 1));
queryWrapper.apply("(DATE_FORMAT(IFNULL(start_date,pre_start_date), '%Y-%m-%d') = '" + nowDayStr + "'" +
......@@ -298,17 +303,22 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
private void checkOrderDate(CreateOrderRequest request) {
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.notIn(SOrder::getRefundStatus, RefundStatusEnum.getNotRefundStatus());
//订单开始时间在 【预定开始时间 和 预定结束时间+30分保洁】区间内
//订单结束时间在 【预定开始时间-30分钟保洁 和 预定结束时间】区间内
queryWrapper.apply("IFNULL(start_date,pre_start_date) BETWEEN '"
+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, request.getPreStartDate())
+ "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(request.getPreEndDate(), Constants.ROOM_LOCK_DELAY_MINUTE)) + "' " +
"OR IFNULL(end_date,pre_end_date) BETWEEN '"
+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(request.getPreStartDate(), -Constants.ROOM_LOCK_DELAY_MINUTE))
+ "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, request.getPreEndDate()) + "' ");
queryWrapper.notIn(SOrder::getRefundStatus, RefundStatusEnum.getRefundedStatus());
queryWrapper.in(SOrder::getStatus, new ArrayList<Integer>(){{
add(OrderStatusEnum.UNUSED.getCode());
add(OrderStatusEnum.INUSE.getCode());
}});
queryWrapper.eq(SOrder::getPayStatus, YesNoEnum.yes.getIndex());
switch (OrderTypeEnum.getEnumByCode(request.getOrderType())) {
case RESERVER://预定
//订单开始时间在 【预定开始时间 和 预定结束时间+30分保洁】区间内
//订单结束时间在 【预定开始时间-30分钟保洁 和 预定结束时间】区间内
queryWrapper.apply("IFNULL(start_date,pre_start_date) BETWEEN '"
+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, request.getPreStartDate())
+ "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(request.getPreEndDate(), Constants.ROOM_LOCK_DELAY_MINUTE)) + "' " +
"OR IFNULL(end_date,pre_end_date) BETWEEN '"
+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(request.getPreStartDate(), -Constants.ROOM_LOCK_DELAY_MINUTE))
+ "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, request.getPreEndDate()) + "' ");
break;
case RENEW://续费
if (StringUtils.isBlank(request.getPreOrderNo())) {
......@@ -316,6 +326,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
//排除上笔订单
queryWrapper.ne(SOrder::getOrderNo, request.getPreOrderNo());
//订单结束时间在 【预定开始时间-30分钟保洁 和 预定结束时间】区间内
queryWrapper.apply("IFNULL(end_date,pre_end_date) BETWEEN '"
+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(request.getPreStartDate(), -Constants.ROOM_LOCK_DELAY_MINUTE))
+ "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, request.getPreEndDate()) + "' ");
break;
default:
throw new BaseException("订单类型异常!");
......@@ -486,7 +500,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
public List<SOrder> validOrder() {
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SOrder::getStatus, OrderStatusEnum.UNUSED.getCode());
queryWrapper.in(SOrder::getRefundStatus, RefundStatusEnum.getNotRefundStatus());
queryWrapper.eq(SOrder::getPayStatus, YesNoEnum.yes.getIndex());
queryWrapper.notIn(SOrder::getRefundStatus, RefundStatusEnum.getRefundedStatus());
List<SOrder> result = list(queryWrapper);
return result;
}
......
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