fix: 无台桌下单报错修复

This commit is contained in:
SongZhang 2024-10-25 17:36:40 +08:00
parent 0f097f7d86
commit 42563c3ce0
1 changed files with 17 additions and 12 deletions

View File

@ -1122,15 +1122,18 @@ public class TbShopTableServiceImpl implements TbShopTableService {
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, "")) queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
.in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue()); .in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue());
} else { } else {
queryWrapper.eq(TbCashierCart::getTableId, createOrderDTO.getTableId()); if (StrUtil.isNotBlank(createOrderDTO.getTableId())) {
tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>() .eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId()) .in(TbShopTable::getStatus, "idle", "using"));
.in(TbShopTable::getStatus, "idle", "using")); if (tbShopTable == null) {
if (tbShopTable == null) { throw new BadRequestException("台桌未开台或不存在");
throw new BadRequestException("台桌未开台或不存在"); }
queryWrapper.eq(TbCashierCart::getTableId, createOrderDTO.getTableId());
}else {
queryWrapper.isNull(TbCashierCart::getTableId);
} }
queryWrapper.eq(TbCashierCart::getTableId, createOrderDTO.getTableId());
} }
List<TbCashierCart> allCashierCarts = cashierCartMapper List<TbCashierCart> allCashierCarts = cashierCartMapper
@ -1350,7 +1353,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
} }
// 先付费模式结束购物车状态 // 先付费模式结束购物车状态
if (shopEatTypeInfoDTO.isDineInBefore() || shopEatTypeInfoDTO.isTakeout()) { if (shopEatTypeInfoDTO.isDineInBefore() || shopEatTypeInfoDTO.isTakeout() || StrUtil.isBlank(createOrderDTO.getTableId())) {
cashierCart.setStatus("final"); cashierCart.setStatus("final");
} }
cashierCartMapper.updateById(cashierCart); cashierCartMapper.updateById(cashierCart);
@ -1384,7 +1387,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
// 推送耗材信息 // 推送耗材信息
pushConsMsg(orderInfo, cashierCarts); pushConsMsg(orderInfo, cashierCarts);
if (!shopEatTypeInfoDTO.isTakeout()) { if (!shopEatTypeInfoDTO.isTakeout() && StrUtil.isNotBlank(createOrderDTO.getTableId())) {
// 清空台桌信息 // 清空台桌信息
if (shopEatTypeInfoDTO.isDineInBefore()) { if (shopEatTypeInfoDTO.isDineInBefore()) {
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>() mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
@ -1414,8 +1417,10 @@ public class TbShopTableServiceImpl implements TbShopTableService {
} }
String tableCartKey = RedisConstant.getTableCartKey(createOrderDTO.getTableId(), createOrderDTO.getShopId().toString()); if (StrUtil.isNotBlank(createOrderDTO.getTableId())) {
redisTemplate.delete(tableCartKey); String tableCartKey = RedisConstant.getTableCartKey(createOrderDTO.getTableId(), createOrderDTO.getShopId().toString());
redisTemplate.delete(tableCartKey);
}
return orderInfo; return orderInfo;
}, stringRedisTemplate, RedisConstant.getLockKey(RedisConstant.CREATE_ORDER, createOrderDTO.getShopId(), }, stringRedisTemplate, RedisConstant.getLockKey(RedisConstant.CREATE_ORDER, createOrderDTO.getShopId(),
createOrderDTO.getTableId(), createOrderDTO.getMasterId(), createOrderDTO.getUseType())); createOrderDTO.getTableId(), createOrderDTO.getMasterId(), createOrderDTO.getUseType()));