package com.bizzan.bitrade.dao;

import java.math.BigDecimal;
import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.bizzan.bitrade.dao.base.BaseDao;
import com.bizzan.bitrade.entity.TransferRecord;
import com.bizzan.bitrade.vo.TransferRecordVo;

/**
 * @author 
 * @date 2020年02月27日
 */
public interface TransferRecordDao extends BaseDao<TransferRecord> {
	
	@Query(value="select new com.bizzan.bitrade.vo.TransferRecordVo(min(id),memberId,targetMemberId,sum(amount)) from TransferRecord where (memberId=:memberId or targetMemberId=:memberId) and status=3 group by memberId,targetMemberId")
	public List<TransferRecordVo> stat(@Param("memberId") Long memberId);
	
	@Query(value="select sum(m.amount) as allAmount from transfer_record m where m.status=3 and m.create_time between :startTime and :endTime",nativeQuery = true)
    BigDecimal sumTotalByTime(@Param("startTime") String startTime,@Param("endTime") String endTime);
}
