package com.hfkj.dao;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.Map;

/**
 * mapper扩展类
 */
public interface BsUserSpreadAccountRecordMapperExt {

    @Select("select count(1) from bs_user_spread_account_record where user_id = #{userId} and DATE(create_time) = DATE(NOW()) and source_type = 2")
    Integer withdrawChance(@Param("userId") Long userId);

    @Select("<script>" +
            " select sum(transaction_amount) from bs_user_spread_account_record where status = 1" +
            " <if test='param.userId != null'> and user_id = #{param.userId} </if>" +
            " <if test='param.userPhone != null'> and user_phone like concat('%',#{param.userPhone},'%') </if>" +
            " <if test='param.type != null'> and type = #{param.type} </if>" +
            " <if test='param.sourceType != null'> and source_type = #{param.sourceType} </if>" +
            " <if test='param.createTimeS != null'> <![CDATA[ and create_time >= #{param.createTimeS} ]]> </if> " +
            " <if test='param.createTimeE != null'> <![CDATA[ and create_time <= #{param.createTimeE} ]]> </if>" +
            "</script>")
    BigDecimal countRecordAmount(@Param("param") Map<String,Object> param);
}
