package com.bizzan.bitrade.dao;

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

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import com.bizzan.bitrade.dao.base.BaseDao;
import com.bizzan.bitrade.entity.GameRecord;

public interface GameRecordDao extends BaseDao<GameRecord> {

	@Transactional
    @Modifying
    @Query("update GameRecord record set record.rewardStatus = 1 where record.id = :id")
	int updateRewardStatus(@Param("id") long id);
	
	@Query(value="select sum(m.amount) as allAmount from game_record m where m.create_time between :startTime and  :endTime and m.member_id in (:ids)",nativeQuery = true)
    BigDecimal sumAmountByMemberIdsAndTime(@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("ids") List<Long> ids);
}
