package com.ssj.dao.weixin.sales.dao;

import com.ssj.bean.weixin.sales.domain.LibOrderRefunds;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/** 
 * @author  ZhangCaibao 
 * @version 2017年4月24日 上午11:13:35 
 * 类说明 
 */
@Repository
public interface LibOrderRefundsDao  extends JpaRepository<LibOrderRefunds, String>{

	@Query(nativeQuery = true, value = " select * from   tb_lib_order_refunds  where lib_id = ?1 and initiate_user_id = ?2 and step = ?3 and order_details_id = ?4 and stat_void = 1 ")
	public LibOrderRefunds findByLibIdCount(String libId,String initiateUserId,Integer step,String orderDetailsId);
	
	
	@Query(nativeQuery = true, value = "update tb_lib_order_refunds set stat_void = ?2  where order_details_id = ?1 ")
	@Modifying
	public void updateStatVoid(String orderDetailsId,Integer statVoid);

	
	@Query(nativeQuery=true,value="SELECT t.* from tb_lib_order_refunds t where t.order_details_id = ?1 and t.stat_void=?2 ")
	LibOrderRefunds findRefundByDetailId(String orderDetailsId, int istatVoid);

	public LibOrderRefunds findByOrderDetailsIdAndStatVoid (String lsId, int state);
}
