定时任务 - 定时关闭超期未支付订单
生活随笔
收集整理的這篇文章主要介紹了
定时任务 - 定时关闭超期未支付订单
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
/*** 關閉超時未支付訂單*/
public void closeOrder();
@Transactional(propagation = Propagation.REQUIRED)
@Override
public void closeOrder() {// 查詢所有未付款訂單,判斷時間是否超時(1天),超時則關閉交易OrderStatus queryOrder = new OrderStatus();queryOrder.setOrderStatus(OrderStatusEnum.WAIT_PAY.type);List<OrderStatus> list = orderStatusMapper.select(queryOrder);for (OrderStatus os : list) {// 獲得訂單創(chuàng)建時間Date createdTime = os.getCreatedTime();// 和當前時間進行對比int days = DateUtil.daysBetween(createdTime, new Date());if (days >= 1) {// 超過1天,關閉訂單doCloseOrder(os.getOrderId());}}
}
@Transactional(propagation = Propagation.REQUIRED)
void doCloseOrder(String orderId) {OrderStatus close = new OrderStatus();close.setOrderId(orderId);close.setOrderStatus(OrderStatusEnum.CLOSE.type);close.setCloseTime(new Date());orderStatusMapper.updateByPrimaryKeySelective(close);
}
?
總結
以上是生活随笔為你收集整理的定时任务 - 定时关闭超期未支付订单的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 定时任务 - 构建定时任务task
- 下一篇: 定时任务 - 定时任务弊端与优化方案