package com.hfkj.dao;

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

import java.util.Map;

/**
 * mapper扩展类
 */
public interface BsGasOrderMapperExt {
    
    @Select("<script>" +
            " SELECT" +
            " count( 1 ) totalCount," +
            " case when sum( gas_refuel_price ) then sum( gas_refuel_price ) else 0 end totalRefuelPrice, " +
            " case when sum( gas_oil_liters ) then sum( gas_oil_liters ) else 0 end totalOilLiters," +
            " case when sum( actual_pay_price ) then sum( actual_pay_price ) else 0 end totalActualPayPrice " +
            " FROM" +
            " bs_gas_order" +
            " where 1 = 1" +
            " <if test='param.merChainBrandId != null'> and mer_chain_brand_id = #{param.merChainBrandId} </if>" +
            " <if test='param.merId != null'> and mer_id = #{param.merId} </if>" +
            " <if test='param.merNo != null'> and mer_no = #{param.merNo} </if>" +
            " <if test='param.merName != null'> and mer_name like concat('%',#{param.merName},'%') </if>" +
            " <if test='param.orderNo != null'> and order_no like concat('%',#{param.orderNo},'%') </if>" +
            " <if test='param.orderChildNo != null'> and order_child_no like concat('%',#{param.orderChildNo},'%') </if>" +
            " <if test='param.channelType != null'> and channel_type = #{param.channelType} </if>" +
            " <if test='param.channelOrderNo != null'> and channel_order_no like concat('%',#{param.channelOrderNo},'%') </if>" +
            " <if test='param.payType != null'> and pay_type = #{param.payType} </if>" +
            " <if test='param.paySerialNo != null'> and pay_serial_no like concat('%',#{param.paySerialNo},'%') </if>" +
            " <if test='param.userPhone != null'> and user_phone = #{param.userPhone} </if>" +
            " <if test='param.gasOilType != null'> and gas_oil_type = #{param.gasOilType} </if>" +
            " <if test='param.gasStaffId != null'> and gas_staff_id = #{param.gasStaffId} </if>" +
            " <if test='param.gasStaffName != null'> and gas_staff_name like concat('%',#{param.gasStaffName},'%') </if>" +
            " <if test='param.agentId != null'> and agent_id = #{param.agentId} </if>" +
            " <if test='param.agentStaffId != null'> and agent_staff_id = #{param.agentStaffId} </if>" +
            " <if test='param.status != null'> and status = #{param.status} </if>" +
            " <if test='param.abnormal != null'> and abnormal = #{param.abnormal} </if>" +
            " <if test='param.gasClassGroupId != null'> and gas_class_group_id = #{param.gasClassGroupId} </if>" +
            " <if test='param.gasClassGroupTaskId != null'> and gas_class_group_task_id = #{param.gasClassGroupTaskId} </if>" +
            " <if test='param.gasOilNo != null'> and gas_oil_no = #{param.gasOilNo} </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>" +
            " <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.refundTimeS != null'><![CDATA[ and refund_time >= #{param.refundTimeS} ]]></if>" +
            " <if test='param.refundTimeE != null'><![CDATA[ and refund_time <= #{param.refundTimeE} ]]></if>" +
            "</script>")
    Map<String,Object> selectGasOrderCount(@Param("param") Map<String,Object> param);
}
