diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java index 1af95615..28d95c8d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java @@ -38,4 +38,7 @@ public interface TbShopTableBookingService extends IService Map summary(Integer shopId,String[] phoneNos); + void batchTimeout(); + + void autoCancel(); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java index 34af88e8..a5980aba 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java @@ -254,7 +254,7 @@ public class TbShopTableBookingServiceImpl extends ServiceImpl item.getShopTableId().equals(dto.getId())).findFirst().orElse(null)); + dto.setBookingInfo(list.stream().filter(item -> item.getShopTableId().equals(dto.getId()) && item.getStatus() != -1).findFirst().orElse(null)); } return result; } @@ -274,14 +274,21 @@ public class TbShopTableBookingServiceImpl extends ServiceImpllambdaUpdate() + .set(TbShopTableBooking::getStatus, 999) + .eq(TbShopTableBooking::getStatus, 20) + .last("and TIMESTAMPDIFF(MINUTE, booking_time, NOW()) >= timeout_minute")); } + + @Override + public void autoCancel() { + // 15分钟后自动取消 + baseMapper.update(Wrappers.lambdaUpdate() + .set(TbShopTableBooking::getStatus, -1) + .eq(TbShopTableBooking::getStatus, 999) + .last("and TIMESTAMPDIFF(MINUTE, booking_time, NOW()) >= timeout_minute+15")); + } + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java b/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java index 1e36b4d9..10459180 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java @@ -2,6 +2,7 @@ package cn.ysk.cashier.quartz.task; import cn.ysk.cashier.dto.product.StockCountDTO; import cn.ysk.cashier.mybatis.service.TbPointsExchangeRecordService; +import cn.ysk.cashier.mybatis.service.TbShopTableBookingService; import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.pojo.product.TbProductStockDetail; import cn.ysk.cashier.repository.order.StockCountRepository; @@ -46,6 +47,7 @@ public class TestTask { private EntityManager entityManager; @Autowired private TbPointsExchangeRecordService tbPointsExchangeRecordService; + private TbShopTableBookingService tbShopTableBookingService; private final TbCashierCartService tbCashierCartService; private final TbOrderInfoService orderInfoService; @@ -103,6 +105,10 @@ public class TestTask { public void cancelPointsExchangeOrder(){ log.info("积分商品订单取消定时任务执行"); tbPointsExchangeRecordService.authCancel(); + log.info("预定订单超时定时任务执行"); + tbShopTableBookingService.batchTimeout(); + log.info("预定订单取消定时任务执行"); + tbShopTableBookingService.autoCancel(); } @Transactional(rollbackFor = Exception.class)