未支付订单 删除 每天1点13

This commit is contained in:
wangw 2025-08-25 15:11:31 +08:00
parent 79fad66312
commit 7ec0f673be
1 changed files with 5 additions and 24 deletions

View File

@ -40,10 +40,7 @@ public class OrderTask {
@Resource
private CommonInfoService commonRepository;
final static int COUNT = 100;
final static int SLEEP_TIME = 300;
@Scheduled(cron = "0 0/5 * * * ? ")
@Scheduled(cron = "0 13 1 * * ? ")
public void record() {
String value = commonRepository.findOne(939).getValue();
if (!"1".equals(value)) {
@ -67,16 +64,8 @@ public class OrderTask {
if (orderCount == 0) {
return;
}
int orderPage = orderCount / COUNT;
if (orderCount % COUNT != 0) {
orderPage++;
}
log.info("未支付订单order删除开始,{}", orderPage);
for (int i = 0; i < orderPage; i++) {
queryWrapper.last(" limit " + COUNT);
ordersService.remove(queryWrapper);
ThreadUtil.sleep(SLEEP_TIME);
}
log.info("未支付订单order删除开始,{}", orderCount);
ordersService.remove(queryWrapper);
log.info("未支付订单order删除结束");
}
@ -89,16 +78,8 @@ public class OrderTask {
if (payCount == 0) {
return;
}
int payPage = payCount / COUNT;
if (payCount % COUNT != 0) {
payPage++;
}
log.info("未支付订单detail删除开始,{}", payPage);
for (int i = 0; i < payPage; i++) {
queryWrapper2.last(" limit " + COUNT);
payDetailsDao.delete(queryWrapper2);
ThreadUtil.sleep(SLEEP_TIME);
}
log.info("未支付订单detail删除开始,{}", payCount);
payDetailsDao.delete(queryWrapper2);
log.info("未支付订单detail删除结束");
}
}