package com.uas.platform.b2b.dao;

import com.uas.platform.b2b.model.MakeAccept;
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 MakeAcceptDao extends JpaSpecificationExecutor<MakeAccept>, JpaRepository<MakeAccept, Long> {
	/**
	 * 按所属企业及编号查找委外验收单
	 * @param enUU
	 * @param code
	 * @return
	 */
	public List<MakeAccept> findByEnUUAndCode(long enUU,String code);
	
	/**
	 * 卖家根据卖家UU号和下载状态获取需要下载的客户委外验收入库单
	 * @return
	 */
	public List<MakeAccept> findByVendUUAndSendStatus(Long vendUU, Short sendStatus);
	
	/**
	 * 按卖家UU、反过账状态查找
	 * @param vendUU
	 * @param nonPosting
	 * @return
	 */
	public List<MakeAccept> findByVendUUAndNonPosting(Long vendUU, Short nonPosting);
	
	/**
	 * 根据供应商UU号获取客户委外验收单数量
	 * @param vendUU
	 * @return
	 */
	@Query("select count(p) from MakeAccept p where p.vendUU = :vendUU")
	public long countByVendUU(@Param("vendUU")Long vendUU);

	/**
	 * 通过企业UU和erpId获取对应的B2Bid
	 *
	 * @param enUU 企业UU
	 * @param erpId erpId
	 * @return
	 */
    List<MakeAccept> findByEnUUAndErpId(Long enUU, Long erpId);
}
