package edu.whut.trigger.job;
import com.alibaba.fastjson.JSON;
import edu.whut.domain.trade.service.ITradeSettlementOrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.util.Map;

/**
 * 拼团完结回调通知任务；拼团回调任务表，实际公司场景会定时清理数据结转，不会有太多数据挤压
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class GroupBuyNotifyJob {

    private final ITradeSettlementOrderService tradeSettlementOrderService;

    //每30秒执行一次
    @Scheduled(cron = "0/30 * * * * ?")
    public void exec() {
        try {
            Map<String, Integer> result = tradeSettlementOrderService. execSettlementNotifyJob();
            log.info("定时任务，回调通知拼团完结任务 result:{}", JSON.toJSONString(result));
        } catch (Exception e) {
            log.error("定时任务，回调通知拼团完结任务失败", e);
        }
    }

}
