未支付订单 删除 间隔 以及 缓冲
This commit is contained in:
parent
97e20cae9b
commit
79fad66312
|
|
@ -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删除结束");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue