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 BsUserSpreadAccountMapperExt {


    @Select("<script>" +
            " select " +
            " case when sum(transaction_amount) is not null then sum(transaction_amount) else 0 end amount" +
            " from bs_user_spread_account_record " +
            " where status = 1 " +
            " and user_id = #{param.userId} " +
            " <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 countSpreadAmount(@Param("param") Map<String,Object> param);
}
