package com.cirle.scientific.dao;

import com.cirle.scientific.po.SalesCollectionMain;
import com.cirle.scientific.po.SalesOrdersMain;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface CollectionDao extends PagingAndSortingRepository<SalesCollectionMain, Long>, JpaSpecificationExecutor<SalesCollectionMain> {
    @Query(value = "SELECT * FROM qkj_integral_collection WHERE mem_card = ?1 AND type_id = ?2 AND type = ?3",nativeQuery = true)
    List<SalesCollectionMain> getCollectionInfo(String memCard, String typeId, Integer type);

    @Query(value = "SELECT * FROM qkj_integral_collection WHERE mem_card = ?1 AND type = ?2 ORDER BY collection_time DESC LIMIT ?3,?4",nativeQuery = true)
    List<SalesCollectionMain> findMyCollectionListAllByType(String memCard , Integer type, Integer start, Integer size);

    @Query(value = "SELECT * FROM qkj_integral_collection WHERE mem_card = ?1 ORDER BY collection_time DESC LIMIT ?2,?3",nativeQuery = true)
    List<SalesCollectionMain> findMyCollectionListAll(String memCard , Integer start, Integer size);

}
