Commit 9b36552f by YG8999

房间下架验证是否存在待使用和使用中订单

parent 7f2e6a0e
package share.common.enums;
/**
* @className: share.common.enums.RoomStatEnum
* @description: 门店房间上下架
* @author: lwj
* @create: 2024-02-28 13:46
*/
public enum RoomStatEnum {
GROUNDING(1,"上架"),
UNDERCARRIAGE(2,"下架"),
MAINTENANCE(3,"维护");
private Integer value;
private String name;
RoomStatEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
public Integer getValue() {
return value;
}
public String getName() {
return name;
}
}
......@@ -96,6 +96,12 @@ public class SRoomVo extends BaseEntity
private String packIds;
/**
* 房间上下架(1-上架,2-下架,3-维护)
*/
@Excel(name = "房间上下架")
private Integer roomStat;
/**
* 套餐列表
*/
private List<SPack> packList;
......
......@@ -9,20 +9,19 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.util.ObjectUtils;
import share.common.enums.DeviceType;
import share.common.enums.PositionEnum;
import share.common.enums.RoleTypeEnum;
import share.common.enums.YesNoEnum;
import share.common.enums.*;
import share.common.exception.base.BaseException;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.utils.SecurityUtils;
import share.system.domain.*;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.MqttxVo;
import share.system.domain.vo.RoomStatusVo;
import share.system.domain.vo.SRoomVo;
import share.system.mapper.DeviceMapper;
import share.system.mapper.SOrderMapper;
import share.system.mapper.SRoomMapper;
import share.system.mapper.SStoreConsumerMapper;
import share.system.service.*;
......@@ -49,7 +48,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
@Autowired
private DeviceService deviceService;
@Autowired
private MqttxService mqttxService;
private ISOrderService orderService;
@Autowired
private DeviceOpService deviceOpService;
@Autowired
......@@ -174,6 +173,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
int i = 0;
try {
sRoom.setCreateTime(DateUtils.getNowDate());
sRoom.setCreateBy(SecurityUtils.getUsername());
i = baseMapper.insertSRoom(sRoom);
//判断套餐ID
if (!sRoom.getPackIds().isEmpty()) {
......@@ -189,6 +189,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
SRoomPack.setPackId(o);
SRoomPack.setRoomId(sRoom.getId());
SRoomPack.setCreateTime(DateUtils.getNowDate());
SRoomPack.setCreateBy(SecurityUtils.getUsername());
SRoomPackList.add(SRoomPack);
});
roomPackService.saveBatch(SRoomPackList);
......@@ -207,6 +208,19 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
*/
@Override
public int updateSRoom(SRoom sRoom) {
SRoom room = baseMapper.selectSRoomById(sRoom.getId());
if (RoomStatEnum.UNDERCARRIAGE.getValue().equals(sRoom.getRoomStat()) &&
!sRoom.getRoomStat().equals(room.getRoomStat())) {
// 房间下架验证是否存在使用中、待使用的订单
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper();
queryWrapper.eq(SOrder::getRoomId, sRoom.getId());
queryWrapper.in(SOrder::getStatus, OrderStatusEnum.UNUSED.getCode(), OrderStatusEnum.INUSE.getCode());
queryWrapper.eq(SOrder::getPayStatus, PayStatusEnum.PAID.getCode());
List<SOrder> list = orderService.list(queryWrapper);
if (list.size() > 0) {
throw new RuntimeException("门店房间存在待使用或使用中订单,不允许下架!");
}
}
//判断套餐ID
if (!StrUtil.isEmpty(sRoom.getPackIds())) {
//判断套餐ID
......@@ -223,6 +237,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
SRoomPack.setPackId(o);
SRoomPack.setRoomId(sRoom.getId());
SRoomPack.setCreateTime(DateUtils.getNowDate());
SRoomPack.setCreateBy(SecurityUtils.getUsername());
SRoomPackList.add(SRoomPack);
});
roomPackService.saveBatch(SRoomPackList);
......@@ -231,6 +246,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
roomPackService.deleteRoomPackByRoomId(sRoom.getId());
}
sRoom.setUpdateTime(DateUtils.getNowDate());
sRoom.setUpdateBy(SecurityUtils.getUsername());
return baseMapper.updateSRoom(sRoom);
}
......
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