Commit 412e8cf5 by 吕明尚

订单开门增加订单状态判断,续单换房生成保洁增加原房间订单判断,退款生成保洁增加预定单的查询条件

parent b1e633ed
......@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.constant.Constants;
......@@ -88,6 +89,9 @@ public class OpenInterfaceServiceImpl implements OpenInterfaceService {
if (Objects.isNull(sOrder)) {
throw new BaseException("订单不存在!");
}
if (!ArrayUtils.contains(OrderStatusEnum.getUnfinishOrderStatus(), sOrder.getStatus())) {
throw new BaseException("订单状态已更新,请刷新后重试!");
}
SRoomVo sRoomVo = roomService.selectSRoomById(sOrder.getRoomId());
if (Objects.isNull(sRoomVo)) {
throw new BaseException("房间不存在!");
......
......@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptGetConsumedReponseEntity;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -451,8 +452,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
//查询预定的结束时间是否在续单的开始时间之后和开始时间加一分钟前
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SOrder::getRoomId, oldSOrder.getRoomId());
queryWrapper.eq(SOrder::getRefundStatus, RefundStatusEnum.UNREFUND.getCode());
//修改preStartDate的秒为59
preStartDate = DateUtil.addSecond(preStartDate, 59);
queryWrapper.between(SOrder::getEndDate, DateUtil.addMin(preStartDate, -15), preStartDate);
SOrder one = getOne(queryWrapper);
if (!ObjectUtils.isEmpty(one)) {
if (one.getStatus().equals(OrderStatusEnum.USED.getCode())) {
if (one.getEndDate().getTime() > new Date().getTime()) {
Map<String, String> map = new HashMap<>();
......@@ -473,6 +478,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
redisUtil.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + one.getOrderNo(), jsonObject.toString());
}
}
}
// 如果订单使用中,房间修改状态
if (oldSOrder.getStatus().equals(OrderStatusEnum.INUSE.getCode())) {
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
......@@ -602,14 +608,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (CollectionUtils.isNotEmpty(orderList)) {
return false;
}
List<SOrder> orders = list(new LambdaQueryWrapper<SOrder>()
.eq(SOrder::getRoomId, oldSOrder.getRoomId())
.eq(SOrder::getStatus, OrderStatusEnum.INUSE.getCode())
.ne(SOrder::getOrderNo, oldSOrder.getOrderNo()));
// 判断原房间是否生成保洁
if (dto.getIsClean().equals(YesNoEnum.yes.getIndex())) {
//判断订单是否已经添加保洁记录
SCleanRecords cleanRecords = isCleanRecordsService.lastCleanByRoomId(oldSOrder.getRoomId());
if (CollectionUtils.isEmpty(list(new LambdaQueryWrapper<SOrder>()
.eq(SOrder::getRoomId, oldSOrder.getRoomId())
.eq(SOrder::getStatus, OrderStatusEnum.INUSE.getCode())
.ne(SOrder::getOrderNo, oldSOrder.getOrderNo()))) &&
if (CollectionUtils.isEmpty(orders) &&
(ObjectUtil.isEmpty(cleanRecords) || cleanRecords.getStatus().equals(CleaningStatusEnum.CLEANED.getCode()))) {
//房间添加保洁记录
isCleanRecordsService.addSCleanRecords(oldSOrder.getStoreId(), oldSOrder.getRoomId());
......@@ -625,9 +632,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
OpTypeEnum.CUT_ELECTRIC.getCode(), false, 0, DeviceOpSourceEnum.DEVICE_SOURCE_20.getCode());
//修改原房间状态
SRoom sRoom = new SRoom();
if (CollectionUtils.isEmpty(orders)) {
sRoom.setId(oldSOrder.getRoomId());
sRoom.setStatus(RoomStatusEnum.FREE.getValue());
roomService.updateById(sRoom);
}
//修改新房间状态
sRoom.setId(dto.getRoomId());
sRoom.setStatus(RoomStatusEnum.HOLD.getValue());
......@@ -1582,6 +1591,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (Objects.isNull(sOrder)) {
throw new BaseException("订单不存在!");
}
if (!ArrayUtils.contains(OrderStatusEnum.getUnfinishOrderStatus(), sOrder.getStatus())) {
throw new BaseException("订单状态已更新,请刷新后重试!");
}
SRoomVo sRoomVo = roomService.selectSRoomById(sOrder.getRoomId());
if (Objects.isNull(sRoomVo)) {
throw new BaseException("房间不存在!");
......
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