Commit e68edc51 by 吕明尚

房间列表使用中的房间增加订单结束时间

parent c69e98f5
......@@ -168,24 +168,26 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
if (ObjectUtil.isNotEmpty(sOrder.getStatus())) {
OrderStatusEnum orderStatusEnum = OrderStatusEnum.getEnumByCode(sOrder.getStatus());
switch (orderStatusEnum) {
case CANCEL:
queryWrapper.in(SOrder::getStatus, new ArrayList<Integer>() {{
add(OrderStatusEnum.CANCEL.getCode());
add(OrderStatusEnum.REFUNDING.getCode());
add(OrderStatusEnum.REFUNDED.getCode());
}});
break;
case UNUSED:
case INUSE:
case USED:
queryWrapper.eq(SOrder::getStatus, sOrder.getStatus());
break;
default:
break;
if (orderStatusEnum != null) {
switch (orderStatusEnum) {
case CANCEL:
queryWrapper.in(SOrder::getStatus, new ArrayList<Integer>() {{
add(OrderStatusEnum.CANCEL.getCode());
add(OrderStatusEnum.REFUNDING.getCode());
add(OrderStatusEnum.REFUNDED.getCode());
}});
break;
case UNUSED:
case INUSE:
case USED:
queryWrapper.eq(SOrder::getStatus, sOrder.getStatus());
break;
default:
break;
}
}
}
queryWrapper.orderByDesc(true, SOrder::getCreateTime);
queryWrapper.orderByDesc(SOrder::getCreateTime);
List<SOrder> orders = baseMapper.selectList(queryWrapper);
return convertDosToVos(orders);
}
......@@ -368,7 +370,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
SOrder sOrder = getInfoException(request.getOrderNo());
SOrder oldSOrder = new SOrder();
BeanUtils.copyProperties(sOrder, oldSOrder);
if (sOrder == null) {
if (ObjectUtils.isEmpty(sOrder)) {
throw new BaseException("订单不存在");
}
Date date = cn.hutool.core.date.DateUtil.offsetDay(cn.hutool.core.date.DateUtil.date(), -30);
......@@ -522,7 +524,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
List<SCleanRecords> sCleanRecords = isCleanRecordsService.list(cleanRecordsQueryWrapper);
if (CollectionUtils.isNotEmpty(sCleanRecords)) {
//去掉保洁中的房间
List<Long> cleanRoomIds = Optional.ofNullable(sCleanRecords).orElse(new ArrayList<>()).parallelStream().map(SCleanRecords::getRoomId).collect(Collectors.toList());
List<Long> cleanRoomIds = Optional.of(sCleanRecords).orElse(new ArrayList<>()).parallelStream().map(SCleanRecords::getRoomId).collect(Collectors.toList());
//获取不在保洁的房间
list = list.stream().filter(sRoom -> !cleanRoomIds.contains(sRoom.getId())).collect(Collectors.toList());
}
......@@ -546,7 +548,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
List<SOrder> orderList = list(sOrderLambdaQueryWrapper);
if (CollectionUtils.isNotEmpty(orderList)) {
//去掉被占用的房间
List<Long> orderRoomIds = Optional.ofNullable(orderList).orElse(new ArrayList<>()).parallelStream().map(SOrder::getRoomId).collect(Collectors.toList());
List<Long> orderRoomIds = Optional.of(orderList).orElse(new ArrayList<>()).parallelStream().map(SOrder::getRoomId).collect(Collectors.toList());
list = list.stream().filter(sRoom -> !orderRoomIds.contains(sRoom.getId())).collect(Collectors.toList());
}
return roomService.convertDoListToVoList(list);
......@@ -577,11 +579,13 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
SCleanRecords cleanRecords = isCleanRecordsService.lastCleanByRoomId(sOrder.getRoomId());
if (ObjectUtil.isEmpty(cleanRecords) || cleanRecords.getStatus().equals(CleaningStatusEnum.CLEANED.getCode())) {
//房间添加保洁记录
boolean b = isCleanRecordsService.addSCleanRecords(sOrder.getStoreId(), sOrder.getRoomId());
isCleanRecordsService.addSCleanRecords(sOrder.getStoreId(), sOrder.getRoomId());
}
}
//判断极端条件,在订单换房时原订单在自动开始的订单中变为订单开始状态
boolean inuse = redisUtils.exists(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo());
//原订单是否使用中
if (sOrder.getStatus().equals(OrderStatusEnum.INUSE.getCode())) {
if (sOrder.getStatus().equals(OrderStatusEnum.INUSE.getCode()) | inuse) {
// 使用中订单断电, 延时3分钟断电
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(),
OpTypeEnum.CUT_ELECTRIC.getCode(), false, 0);
......
......@@ -128,6 +128,11 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
List<SPack> packList = packService.selectPackListByIds(packIdList);
List<RoomStatusVo> roomStatusVoList = roomStatusService.listRoomStatus(store.getId(),roomList);
Map<Long,List<RoomStatusVo>> roomStatusMap = Optional.ofNullable(roomStatusVoList).orElse(new ArrayList<>()).stream().collect(Collectors.groupingBy(RoomStatusVo::getRoomId));
LambdaQueryWrapper<SOrder> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SOrder::getStoreId, store.getId());
wrapper.in(SOrder::getRoomId, roomIds);
wrapper.eq(SOrder::getStatus, OrderStatusEnum.INUSE.getCode());
List<SOrder> list = orderService.list(wrapper);
roomList.stream().forEach(sRoom -> {
SRoomVo vo = new SRoomVo();
BeanUtils.copyProperties(sRoom, vo);
......@@ -150,6 +155,13 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
});
vo.setPackList(packs);
}
if (CollectionUtils.isNotEmpty(list)) {
list.forEach(order -> {
if (order.getRoomId().compareTo(vo.getId()) == 0) {
vo.setRecordsTime(order.getEndDate());
}
});
}
voList.add(vo);
});
}
......
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