fix: 全部退菜清空购物车

This commit is contained in:
张松
2024-12-20 09:39:35 +08:00
parent 79a7e3043a
commit 616115c93c

View File

@@ -926,9 +926,26 @@ public class TbShopTableServiceImpl implements TbShopTableService {
.multiply(removeCartDTO.getNum()));
}
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(cashierCart.getShopId(), cashierCart.getTableId());
checkTakeOutEmptyAndClear(cashierCart, shopEatTypeInfoDTO);
}
/**
* 检查订单购物车是否为空并删除订单
*/
private void checkTakeOutEmptyAndClear(TbCashierCart cashierCart, ShopEatTypeInfoDTO shopEatTypeInfoDTO) {
if (!TableConstant.OrderInfo.UseType.TAKEOUT.equalsVals(cashierCart.getUseType())) {
return;
}
List<TbCashierCart> cashierCarts = mpCashierCartService.selectByShopEatTypeAndOrderId(shopEatTypeInfoDTO, cashierCart.getMasterId(), cashierCart.getOrderId() == null ? null : cashierCart.getOrderId(), false, TableConstant.OrderInfo.Status.CREATE);
if (cashierCarts.isEmpty() && cashierCart.getOrderId() != null) {
mpOrderDetailService.remove(new LambdaQueryWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getOrderId, cashierCart.getOrderId()));
mpOrderInfoService.removeById(cashierCart.getOrderId());
}
}
@Override
public void clearCart(ClearCartDTO clearCartDTO) {
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(clearCartDTO.getShopId(), clearCartDTO.getTableId(), clearCartDTO.getUseType());
@@ -3403,7 +3420,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
for (TbCashierCart allCart : allCarts) {
if (switchTableDTO.getCartIds().contains(allCart.getId())) {
cashierCarts.add(allCart);
}else if (TableConstant.CART_SEAT_ID.equals(allCart.getProductId())) {
} else if (TableConstant.CART_SEAT_ID.equals(allCart.getProductId())) {
seatCart = allCart;
}
}