package com.ssj.dao.weixin.order.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.ssj.bean.weixin.order.domain.PayB2C;


@Repository
public interface PayB2CDao extends JpaRepository<PayB2C, String> {
		
	  @Query(nativeQuery = true, value = " select  count(1) from  tb_pay_business_to_user  where order_no =?1 ")
	  public Integer  getOrderNoCount(String orderNo);
	  
	  
	  @Query(nativeQuery = true, value = " select  * from tb_pay_business_to_user  where pay_status =2  and  create_time  BETWEEN ?1 AND ?2  ")
	  public List<PayB2C> getYesterdayPayB2C(String startDate,String endDate);
	  @Query(nativeQuery = true, value = " select  * from tb_pay_business_to_user  where pay_status =?2  and type=?1  ")
	  public List<PayB2C> timedRefund(int type,int status);
	  
	  @Query(nativeQuery = true, value = " select  * from tb_pay_business_to_user  where pay_status =?2  and type=?1 and  date(create_time)  BETWEEN  DATE_SUB(CURDATE(), INTERVAL 14 DAY)    and  DATE_SUB(CURDATE(), INTERVAL 7 DAY)  ")
	  public List<PayB2C> timedLast7daysRefund(int type,int status);
	  @Query(nativeQuery = true, value = " select  * from tb_pay_business_to_user  where pay_status =?2  and type=?1 and  date_format(create_time, '%Y-%m') = date_format(curdate(),'%Y-%m') and amount >0   ")
	  public List<PayB2C> lastMonthPay(int type,int status);
	  
	  
}
