From 4f7004736a970a17d807e939b531c3455a749600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Wed, 27 Nov 2024 16:04:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=82=E8=B4=A6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=9B=B8=E5=85=B3=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/TbShopTableBookingService.java | 3 +++ .../impl/TbShopTableBookingServiceImpl.java | 27 ++++++++++++------- .../cn/ysk/cashier/quartz/task/TestTask.java | 6 +++++ 3 files changed, 26 insertions(+), 10 deletions(-) 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)