package com.sqx.scheduler.reconciliation; import com.sqx.modules.coupon.service.TbCouponUserService; import com.sqx.modules.reconciliation.service.PlatformBillService; import com.sqx.scheduler.config.SchedulerLock; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.redisson.api.RLock; import org.redisson.api.RedissonClient; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** * 对账定时任务 * * @author : codingliang * @date : 2024-09-09 12:22 */ @Slf4j @Component @RequiredArgsConstructor public class BillsScheduler { private final PlatformBillService platformBillService; /** * 将所有超过失效时间的优惠券改为失效状态 * 每填0点2分30秒执行一次 */ @Async @Scheduled(cron = "30 2 0 * * ?", zone = "Asia/Shanghai") public void insertPlatformBill(){ int errorCount = 0 ; log.info("开始统计对账数据"); while (errorCount<3){ try { int count =platformBillService.insertPlatformBill(); if(count!=0){ break; } } catch (Exception e) { log.error("统计对账数据异常:{}", e.getMessage()); errorCount++; try { Thread.sleep(10000); } catch (InterruptedException ex) { throw new RuntimeException(ex); } } } log.info("统计对账数据结束"); } }