Commit 7bbda839 by 吕明尚

换房接口增加复验

parent 42c80f85
......@@ -138,7 +138,7 @@ public class SOrderController extends BaseController
//查询当前门店可更换房间列表
@GetMapping("/changeRoomList")
public AjaxResult changeRoomList(@PathVariable("id") Long id) {
public AjaxResult changeRoomList(Long id) {
return success(sOrderService.changeRoomList(id));
}
......@@ -147,7 +147,11 @@ public class SOrderController extends BaseController
*/
@PostMapping("/changeRoom")
public AjaxResult changeRoom(@RequestBody SOrderDto dto) {
return success(sOrderService.changeRoom(dto));
if (sOrderService.changeRoom(dto)) {
return success("更换房间成功");
} else {
return error("房间已被预定,更换房间失败");
}
}
......
......@@ -207,5 +207,5 @@ public interface ISOrderService extends IService<SOrder>
List<SRoomVo> changeRoomList(Long id);
String changeRoom(SOrderDto dto);
Boolean changeRoom(SOrderDto dto);
}
package share.system.service;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.Device;
import share.system.domain.SPack;
import share.system.domain.SRoom;
import share.system.domain.vo.MqttxVo;
import share.system.domain.vo.SRoomVo;
import java.util.List;
import java.util.Map;
/**
* 房间Service接口
*
......@@ -107,4 +106,6 @@ public interface ISRoomService extends IService<SRoom>
List<Map> queryRoomList();
List<SRoom> selectByStoreIds(List<Long> storeIds);
List<SRoomVo> convertDoListToVoList(List<SRoom> roomList);
}
......@@ -517,6 +517,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
LambdaQueryWrapper<SCleanRecords> cleanRecordsQueryWrapper = new LambdaQueryWrapper<>();
cleanRecordsQueryWrapper.in(SCleanRecords::getRoomId, roomIds);
cleanRecordsQueryWrapper.ne(SCleanRecords::getStatus, CleaningStatusEnum.CLEANED.getCode());
//七天内
cleanRecordsQueryWrapper.ge(SCleanRecords::getCreateTime, DateUtils.addDays(new Date(), -7));
List<SCleanRecords> sCleanRecords = isCleanRecordsService.list(cleanRecordsQueryWrapper);
if (CollectionUtils.isNotEmpty(sCleanRecords)) {
//去掉保洁中的房间
......@@ -531,11 +533,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
//查询剩余房间的订单时段是否被占用
LambdaQueryWrapper<SOrder> sOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
sOrderLambdaQueryWrapper.notIn(SOrder::getRefundStatus, RefundStatusEnum.getRefundedStatus());
sOrderLambdaQueryWrapper.in(SOrder::getStatus, OrderStatusEnum.getValidOrderStatus());
sOrderLambdaQueryWrapper.in(SOrder::getStatus, OrderStatusEnum.getUnfinishOrderStatus());
sOrderLambdaQueryWrapper.eq(SOrder::getIsDelete, YesNoEnum.no.getIndex());
sOrderLambdaQueryWrapper.eq(SOrder::getStoreId, sOrder.getStoreId());
sOrderLambdaQueryWrapper.in(SOrder::getRoomId, list.stream().map(SRoom::getId).collect(Collectors.toList()));
queryWrapper.apply("(IFNULL(start_date,pre_start_date) BETWEEN '"
sOrderLambdaQueryWrapper.apply("(IFNULL(start_date,pre_start_date) BETWEEN '"
+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, sOrder.getPreStartDate())
+ "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(sOrder.getPreEndDate(), Constants.ROOM_LOCK_DELAY_MINUTE)) + "' " +
"OR IFNULL(end_date,pre_end_date) BETWEEN '"
......@@ -547,16 +549,28 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
List<Long> orderRoomIds = Optional.ofNullable(orderList).orElse(new ArrayList<>()).parallelStream().map(SOrder::getRoomId).collect(Collectors.toList());
list = list.stream().filter(sRoom -> !orderRoomIds.contains(sRoom.getId())).collect(Collectors.toList());
}
return list.stream().map(sRoom -> {
SRoomVo sRoomVo = new SRoomVo();
BeanUtils.copyProperties(sRoom, sRoomVo);
return sRoomVo;
}).collect(Collectors.toList());
return roomService.convertDoListToVoList(list);
}
@Override
public String changeRoom(SOrderDto dto) {
public Boolean changeRoom(SOrderDto dto) {
SOrder sOrder = getById(dto.getId());
LambdaQueryWrapper<SOrder> sOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
sOrderLambdaQueryWrapper.notIn(SOrder::getRefundStatus, RefundStatusEnum.getRefundedStatus());
sOrderLambdaQueryWrapper.in(SOrder::getStatus, OrderStatusEnum.getUnfinishOrderStatus());
sOrderLambdaQueryWrapper.eq(SOrder::getIsDelete, YesNoEnum.no.getIndex());
sOrderLambdaQueryWrapper.eq(SOrder::getStoreId, sOrder.getStoreId());
sOrderLambdaQueryWrapper.eq(SOrder::getRoomId, dto.getRoomId());
sOrderLambdaQueryWrapper.apply("(IFNULL(start_date,pre_start_date) BETWEEN '"
+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, sOrder.getPreStartDate())
+ "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(sOrder.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(sOrder.getPreStartDate(), -Constants.ROOM_LOCK_DELAY_MINUTE))
+ "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, sOrder.getPreEndDate()) + "' )");
List<SOrder> orderList = list(sOrderLambdaQueryWrapper);
if (CollectionUtils.isNotEmpty(orderList)) {
return false;
}
// 判断原房间是否生成保洁
if (dto.getIsClean().equals(YesNoEnum.yes.getIndex())) {
//判断订单是否已经添加保洁记录
......@@ -577,10 +591,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
sRoom.setStatus(RoomStatusEnum.FREE.getValue());
roomService.updateById(sRoom);
}
//发送短信
sOrder.setRoomId(dto.getRoomId());
updateById(sOrder);
return null;
return updateById(sOrder);
}
/**
......
......@@ -407,7 +407,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
}
private List<SRoomVo> convertDoListToVoList(List<SRoom> roomList) {
public List<SRoomVo> convertDoListToVoList(List<SRoom> roomList) {
List<SRoomVo> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(roomList)) {
roomList.stream().forEach(o -> {
......
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