package com.sonic.lion.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sonic.lion.domain.entity.BuffRewardRecord;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

public interface BuffRewardRecordDao extends BaseMapper<BuffRewardRecord> {

    /**
     * 查询 本月累计充值buff 数
     *
     * @param firstday
     * @param lastDay
     * @return
     */
    @Select("SELECT IFNULL(SUM(buff),0)-IFNULL(SUM(gift_amount),0) FROM account_buff_bill WHERE uid =#{uid}  AND biz_type = 600  AND in_or_out =1  AND create_time BETWEEN #{begin} AND #{end} ")
    Long queryTotalChargeAmount(@Param("uid")Long uid, @Param("begin") LocalDateTime firstday, @Param("end") LocalDateTime lastDay);
}
