package com.ruoyi.web.modules.store.task;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.ruoyi.web.modules.store.service.IShopRatingRefreshService;

/**
 * 店铺综合评分日终统计：评分 = 有效评价星级之和 / 评价条数
 */
@Component
public class ShopRatingRefreshTask
{
    private static final Logger LOGGER = LoggerFactory.getLogger(ShopRatingRefreshTask.class);

    @Autowired
    private IShopRatingRefreshService shopRatingRefreshService;

    @Scheduled(cron = "0 59 23 * * ?")
    public void refreshShopRatings()
    {
        LOGGER.info("ShopRatingRefreshTask start");
        int affected = shopRatingRefreshService.refreshAllShopRatings();
        LOGGER.info("ShopRatingRefreshTask done, affectedRows={}", affected);
    }
}
