diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbCashierCartMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbCashierCartMapper.java index acc9612..bf2fb70 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbCashierCartMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbCashierCartMapper.java @@ -75,4 +75,7 @@ public interface TbCashierCartMapper { @Select("select count(*) from tb_cashier_cart where shop_id=#{shopId} and `status`='create' and table_id=#{qrcode} and order_id is not null") int countTable(@Param("qrcode") String qrcode, @Param("shopId") Integer shopId); + + @Select("select count(*) from tb_order_detail where shop_id=#{shopId} and `status`='create' and table_id=#{qrcode} and order_id is not null") + int countTableByDetail(@Param("qrcode") String qrcode, @Param("shopId") Integer shopId); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ShopInfoService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ShopInfoService.java index c831e1f..e0edb0e 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ShopInfoService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ShopInfoService.java @@ -70,7 +70,9 @@ public class ShopInfoService { if (StrUtil.isBlank(tbShopTableVO.getQrcode())) { tbShopTableVO.setStatus("closed"); - }else if (tbCashierCartMapper.countTable(tbShopTableVO.getQrcode(), tbShopTableVO.getShopId()) < 1) { + }else if (tbCashierCartMapper.countTable(tbShopTableVO.getQrcode(), tbShopTableVO.getShopId()) < 1 || + tbCashierCartMapper.countTableByDetail(tbShopTableVO.getQrcode(), tbShopTableVO.getShopId()) < 1 + ) { tbShopTableVO.setStatus("idle"); mpShopTableMapper.update(null, new LambdaUpdateWrapper() .eq(TbShopTable::getQrcode, tbShopTableVO.getQrcode())