自动取消超时的积分商品兑换订单

This commit is contained in:
谭凯凯 2024-11-20 13:59:04 +08:00 committed by Tankaikai
parent aae4ecc9f7
commit d9f6969bcc
3 changed files with 20 additions and 4 deletions

View File

@ -24,4 +24,6 @@ public interface TbPointsExchangeRecordService extends IService<TbPointsExchange
void refund(TbPointsExchangeRecord record);
Map<String, Object> total(Map<String, Object> params);
void authCancel();
}

View File

@ -243,4 +243,14 @@ public class TbPointsExchangeRecordServiceImpl extends ServiceImpl<TbPointsExcha
return result;
}
@Override
public void authCancel() {
baseMapper.update(Wrappers.<TbPointsExchangeRecord>lambdaUpdate()
.set(TbPointsExchangeRecord::getStatus, "cancel")
.set(TbPointsExchangeRecord::getCancelOrRefundTime, new Date())
.set(TbPointsExchangeRecord::getCancelOrRefundReason, "超时未支付,系统自动取消订单")
.eq(TbPointsExchangeRecord::getStatus, "unpaid")
.last("and TIMESTAMPDIFF(MINUTE, create_time, NOW()) >= 5"));
}
}

View File

@ -1,6 +1,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.pojo.order.TbCashierCart;
import cn.ysk.cashier.pojo.product.TbProductStockDetail;
import cn.ysk.cashier.repository.order.StockCountRepository;
@ -9,21 +10,17 @@ import cn.ysk.cashier.repository.product.TbProductSkuRepository;
import cn.ysk.cashier.service.order.TbCashierCartService;
import cn.ysk.cashier.service.order.TbOrderInfoService;
import cn.ysk.cashier.service.shop.TbShopStorageService;
import cn.ysk.cashier.utils.CacheKey;
import cn.ysk.cashier.utils.DateUtil;
import cn.ysk.cashier.utils.QueryHelp;
import cn.ysk.cashier.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.Predicate;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* 测试用
@ -47,6 +44,8 @@ public class TestTask {
private RedisUtils redisUtils;
@Autowired
private EntityManager entityManager;
@Autowired
private TbPointsExchangeRecordService tbPointsExchangeRecordService;
private final TbCashierCartService tbCashierCartService;
private final TbOrderInfoService orderInfoService;
@ -101,6 +100,11 @@ public class TestTask {
orderInfoService.cancelOrder();
}
public void cancelPointsExchangeOrder(){
log.info("积分商品订单取消定时任务执行");
tbPointsExchangeRecordService.authCancel();
}
@Transactional(rollbackFor = Exception.class)
public void countStock(String str) {
String startTime = "";