package com.uas.platform.b2b.dao;

import com.uas.platform.b2b.model.PurchaseApCheck;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PurchaseApCheckDao extends JpaSpecificationExecutor<PurchaseApCheck>, JpaRepository<PurchaseApCheck, Long> {

	/**
	 * 卖家根据客户UU号和下载状态获取需要下载的应收对账单
	 * 
	 * @return
	 */
	public List<PurchaseApCheck> findByCustUuAndStatusAndCheckStatus(Long enUu, Short status, String checkStatus);

	/**
	 * 获得每种单据状态的未读数量
	 *
	 * @Param ids 未读单据id
	 * @return
	 */
	@Query("select count(p), p.checkStatus from PurchaseApCheck p where p.id in :ids group by p.checkStatus")
	List<Object[]> getUnreadCountEveryStatus(@Param("ids") List<Long> ids);
}
