package com.ssj.dao.sys.give;

import com.ssj.bean.sys.codeexchange.CodeExchange;
import com.ssj.bean.sys.give.GiveRecord;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Mount Liu
 * @date 2019/5/9
 */
@Repository
public interface GiveRecordDao extends JpaRepository<GiveRecord, String> {

    Page<GiveRecord> findAll(Specification<GiveRecord> specification, Pageable page);

    /**
     * 查找会员赠送记录
     *
     * @param vipId
     * @return
     */
    GiveRecord findTopByVipId(String vipId);

    /**
     * 查找相应赠送方式下的赠送记录
     * @param vipId
     * @param giveWay
     * @return
     */
    GiveRecord findTopByVipIdAndGiveWay(String vipId,int giveWay);

    List<GiveRecord> findByVacationLimitIdAndVipIdAndGiveWayAndInvalidAndVipServiceId(String vacationLimitId, String vipId, int giveWay, int invalid, String vipServiceId);

    List<GiveRecord> findByVacationLimitIdAndGiveWayAndInvalidAndVipServiceId(String vacationLimitId, int giveWay, int invalid, String vipServiceId);

}
