package com.izouma.dingdong.repo.merchant;

import com.izouma.dingdong.domain.merchant.Sales;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.time.LocalDate;
import java.util.List;

public interface SalesRepo extends JpaRepository<Sales, Long>, JpaSpecificationExecutor<Sales> {


    List<Sales> findAllByGoodsId(Long goodsId);

    //查找商品当天的销量
    Sales findByGoodsIdAndDay(Long goodsId, LocalDate day);

    //查找商户当天的销量
    Sales findByMerchantIdAndDay(Long merchantId, LocalDate day);

    //找出时间段内销量
    List<Sales> findAllByGoodsIdAndDayBetween(Long goodsId, LocalDate start, LocalDate end);

    List<Sales> findAllByDay(LocalDate day);

    //好评商品
    List<Sales> findAllByDayAndPopularityGreaterThanEqual(LocalDate day, Integer num);

    //人气商品
    List<Sales> findAllByDayAndPraiseGreaterThanEqual(LocalDate day, Integer num);

}