package com.hfkj.dao;

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

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

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

    @Select("<script>" +
            " select " +
            " case WHEN sum(trade_actual_amount) is not null then sum(trade_actual_amount) else 0 end tradePrice," +
            " count(1) count" +
            " from bs_trade_order " +
            " where 1 = 1" +
            " <if test='param.agentId != null'> and agent_id = #{param.agentId}</if>" +
            " <if test='param.salesmanId != null'> and salesman_id = #{param.salesmanId} </if>" +
            " <if test='param.merId != null'> and mer_id = #{param.merId} </if>" +
            " <if test='param.storeId != null'> and store_id = #{param.storeId} </if>" +
            " <if test='param.storeName != null'> and store_name CONCAT('%', #{param.storeName} , '%') </if>" +
            " <if test='param.payMode != null'> and pay_mode = #{param.payMode}</if>" +
            " <if test='param.outTradeNo != null'> and out_trade_no like CONCAT('%', #{param.outTradeNo} , '%')</if>" +
            " <if test='param.accTradeNo != null'> and acc_trade_no = #{param.accTradeNo}</if>" +
            " <if test='param.payTimeS != null'> <![CDATA[  and pay_time >= #{param.payTimeS} ]]>  </if>" +
            " <if test='param.payTimeE != null'> <![CDATA[  and pay_time <= #{param.payTimeE} ]]>  </if>" +
            " <if test='param.status != null'> and status = #{param.status}</if>" +
            "</script>")
    Map<String,Object> countTradeOrderPrice(@Param("param") Map<String, Object> param);

}
