Cui Zhi Feng
2024-09-25 118623071a97b66f21c29e2bc02b8f15855ede5d
src/main/java/com/mzl/flower/schedule/ScheduleService.java
@@ -12,10 +12,11 @@
import com.mzl.flower.mapper.partner.PartnerMapper;
import com.mzl.flower.mapper.payment.OrderMapper;
import com.mzl.flower.service.coupon.CouponRecordService;
import com.mzl.flower.service.coupon.CouponTemplateService2;
import com.mzl.flower.service.flower.FlowerCategoryService;
import com.mzl.flower.service.flower.FlowerService;
import com.mzl.flower.service.menber.impl.GrowthValueDealService;
import com.mzl.flower.service.payment.*;
import com.mzl.flower.thread.FlowerCategoryPriceThread;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,9 +38,6 @@
    @Autowired
    private PartnerMapper partnerMapper;
    @Autowired
    private FlowerService flowerService;
    @Autowired
    private OrderMapper orderMapper;
@@ -71,23 +69,16 @@
    @Autowired
    private MemberGrowthRecordMapper memberGrowthRecordMapper;
    @Scheduled(cron = "1 0/30 * * * ?")
    @Autowired
    private CouponTemplateService2 couponTemplateService2;
    @Autowired
    private FlowerCategoryPriceThread thread;
    @Scheduled(cron = "1 1 0/2 * * ?")
    public void calculateAvePrice() {
        log.info("均价计算开始:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
        List<FlowerCategory> cLs = categoryMapper.selectList(new QueryWrapper<FlowerCategory>()
                .isNotNull("parent_id"));
        if(cLs != null && cLs.size() > 0){
            List<Partner> ls = partnerMapper.selectList(new QueryWrapper<Partner>().eq("status", "P"));
            for(FlowerCategory c : cLs){
                flowerService.calculateCategoryDaily(c.getId(), null);
                if(ls != null && ls.size() > 0){
                    for(Partner p : ls){
                        flowerService.calculateCategoryDaily(c.getId(), p.getId());
                    }
                }
            }
        }
        thread.run();
        log.info("均价计算结束:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
    }
@@ -240,4 +231,26 @@
    }
    @Scheduled(cron = "0 0/5 * * * ?")
    public void expireActivityCouponTemplateAll() {
        log.info("优惠券模版过期下架开始:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
        // 下架有所的过期的优惠券
        couponTemplateService2.expireActivityCouponTemplateAll();
        log.info("优惠券模版过期下架开始:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
    }
    @Scheduled(cron = "0 0/5 * * * ?")
    public void expireCouponRecordAll() {
        log.info("优惠券记录过期开始:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
        // 下架有所的过期的优惠券
        couponRecordService.expireCouponRecordAll();
        log.info("优惠券记录过期开始:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
    }
}