mitao
2024-05-27 c26092c422c4b72fa5d51a38f6de1b48ab1ccd87
ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/async/AsyncMethodService.java
@@ -13,13 +13,14 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
 * @author mitao
 * @date 2024/5/24
 */
@Component
@Service
@Slf4j
@RequiredArgsConstructor
public class AsyncMethodService {
@@ -28,6 +29,7 @@
    private final SysUserClient sysUserClient;
    @Async
    @Transactional(rollbackFor = Exception.class)
    public void seckillScheduleTask(GoodsSeckill goodsSeckill) {
        LocalDateTime startTime = goodsSeckill.getStartTime();
        LocalDateTime endTime = goodsSeckill.getEndTime();
@@ -50,6 +52,7 @@
    }
    @Async
    @Transactional(rollbackFor = Exception.class)
    public void groupPurchaseScheduleTask(GoodsGroupPurchase groupPurchase) {
        LocalDateTime startTime = groupPurchase.getStartTime();
        LocalDateTime endTime = groupPurchase.getEndTime();
@@ -109,12 +112,12 @@
    private void handleStartDelayTask(Long id, DelayTaskEnum delayTaskEnum, LocalDateTime startTime,
            Long timeout) {
        String startTaskKey = delayTaskEnum.getCode() + "-" + id;
        //查询延时任务
        DelayTask startDelayTask = sysUserClient.getDelayTask(
                startTaskKey).getData();
        redisService.setCacheObject(
                startTaskKey,
                startTime, timeout, TimeUnit.SECONDS);
        //查询延时任务
        DelayTask startDelayTask = sysUserClient.getDelayTask(
                startTaskKey).getData();
        if (StringUtils.isNull(startDelayTask)) {
            startDelayTask = new DelayTask();
            startDelayTask.setDelFlag(0);