From 79fad663125feb483dfdcc0da103e5b859847fd4 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 25 Aug 2025 14:35:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E6=94=AF=E4=BB=98=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=20=E5=88=A0=E9=99=A4=20=E9=97=B4=E9=9A=94=20=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=20=E7=BC=93=E5=86=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sqx/modules/job/task/OrderTask.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/sqx/modules/job/task/OrderTask.java b/src/main/java/com/sqx/modules/job/task/OrderTask.java index 6e1c55e3..4805e346 100644 --- a/src/main/java/com/sqx/modules/job/task/OrderTask.java +++ b/src/main/java/com/sqx/modules/job/task/OrderTask.java @@ -40,7 +40,10 @@ public class OrderTask { @Resource private CommonInfoService commonRepository; - @Scheduled(cron = "0 7/5 * * * ? ") + final static int COUNT = 100; + final static int SLEEP_TIME = 300; + + @Scheduled(cron = "0 0/5 * * * ? ") public void record() { String value = commonRepository.findOne(939).getValue(); if (!"1".equals(value)) { @@ -64,15 +67,15 @@ public class OrderTask { if (orderCount == 0) { return; } - int orderPage = orderCount / 500; - if (orderCount % 500 != 0) { + int orderPage = orderCount / COUNT; + if (orderCount % COUNT != 0) { orderPage++; } log.info("未支付订单order删除开始,{}", orderPage); for (int i = 0; i < orderPage; i++) { - queryWrapper.last(" limit 500"); + queryWrapper.last(" limit " + COUNT); ordersService.remove(queryWrapper); - ThreadUtil.sleep(300); + ThreadUtil.sleep(SLEEP_TIME); } log.info("未支付订单order删除结束"); } @@ -86,15 +89,15 @@ public class OrderTask { if (payCount == 0) { return; } - int payPage = payCount / 500; - if (payCount % 500 != 0) { + int payPage = payCount / COUNT; + if (payCount % COUNT != 0) { payPage++; } log.info("未支付订单detail删除开始,{}", payPage); for (int i = 0; i < payPage; i++) { - queryWrapper2.last(" limit 500"); + queryWrapper2.last(" limit " + COUNT); payDetailsDao.delete(queryWrapper2); - ThreadUtil.sleep(300); + ThreadUtil.sleep(SLEEP_TIME); } log.info("未支付订单detail删除结束"); }