package com.hfkj.schedule;

import com.github.pagehelper.PageInfo;
import com.hfkj.entity.BsStoreDiscountActivity;
import com.hfkj.service.BsStoreDiscountActivityService;
import com.hfkj.sysenum.StoreDiscountActivityStatusEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @className: StoreDiscountActivity
 * @author: HuRui
 * @date: 2022/12/4
 **/
@Configuration
public class StoreDiscountActivity {

    private static final Logger log = LoggerFactory.getLogger(StoreDiscountActivity.class);

    @Resource
    private BsStoreDiscountActivityService storeDiscountActivityService;

    @Scheduled(cron="0 0/1 * * * ?")   //每1分钟执行一次
    public void integralRebateOrder() {
        Map<String, Object> param = new HashMap<>();
        param.put("status", StoreDiscountActivityStatusEnum.status2.getNumber());
        param.put("endTimeE", System.currentTimeMillis());
        List<BsStoreDiscountActivity> list = storeDiscountActivityService.getActivityList(param);
        for (BsStoreDiscountActivity discountActivity : list) {
            discountActivity.setStatus(StoreDiscountActivityStatusEnum.status3.getNumber());
            storeDiscountActivityService.editActivity(discountActivity);
        }
    }

}
