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, ""))
.in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue());
} else {
queryWrapper.eq(TbCashierCart::getTableId, createOrderDTO.getTableId());
tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
.in(TbShopTable::getStatus, "idle", "using"));
if (tbShopTable == null) {
throw new BadRequestException("台桌未开台或不存在");
if (StrUtil.isNotBlank(createOrderDTO.getTableId())) {
tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
.in(TbShopTable::getStatus, "idle", "using"));
if (tbShopTable == null) {
throw new BadRequestException("台桌未开台或不存在");
}
queryWrapper.eq(TbCashierCart::getTableId, createOrderDTO.getTableId());
}else {
queryWrapper.isNull(TbCashierCart::getTableId);
}
queryWrapper.eq(TbCashierCart::getTableId, createOrderDTO.getTableId());
}
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");
}
cashierCartMapper.updateById(cashierCart);
@ -1384,7 +1387,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
// 推送耗材信息
pushConsMsg(orderInfo, cashierCarts);
if (!shopEatTypeInfoDTO.isTakeout()) {
if (!shopEatTypeInfoDTO.isTakeout() && StrUtil.isNotBlank(createOrderDTO.getTableId())) {
// 清空台桌信息
if (shopEatTypeInfoDTO.isDineInBefore()) {
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
@ -1414,8 +1417,10 @@ public class TbShopTableServiceImpl implements TbShopTableService {
}
String tableCartKey = RedisConstant.getTableCartKey(createOrderDTO.getTableId(), createOrderDTO.getShopId().toString());
redisTemplate.delete(tableCartKey);
if (StrUtil.isNotBlank(createOrderDTO.getTableId())) {
String tableCartKey = RedisConstant.getTableCartKey(createOrderDTO.getTableId(), createOrderDTO.getShopId().toString());
redisTemplate.delete(tableCartKey);
}
return orderInfo;
}, stringRedisTemplate, RedisConstant.getLockKey(RedisConstant.CREATE_ORDER, createOrderDTO.getShopId(),
createOrderDTO.getTableId(), createOrderDTO.getMasterId(), createOrderDTO.getUseType()));