<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.roadm.mapper.SummaryMapper">

    <resultMap type="ErrCodeSummary" id="ErrCodeSummaryResultMap">
        <id column="id" property="task_id" />
        <result column="sp_id" property="sp_id" />
        <result column="sp_name" property="sp_name" />
        <result column="createtime" property="createTime" />
        <result column="sp_saler" property="sp_saler" />

    </resultMap>

    <!--         group by sp.id, sp.sp_name,tk.channelid,tk.sign,tk.errcode -->
    <select id="listPageSpErrCodeTotal" parameterType="ErrCodeSummary"
        resultMap="ErrCodeSummaryResultMap">
        select a.*,sec.reason from
        (select sum(tk.allnumber) allnumber,
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            sp.id sp_id, sp.sp_name,
        </if>
        <if test="byChannelId != null and byChannelId == &quot;1&quot;">
            tk.channelid,
        </if>
        <if test="bySign != null and bySign == &quot;1&quot;">
            tk.sign,
        </if>
        <if test="byProvince != null and byProvince == &quot;1&quot;">
            tk.province,
        </if>
        <if test="byDay != null and byDay == &quot;1&quot;">
            DATE_FORMAT(tk.stat_time,'%Y-%m-%d') as stat_time,
        </if>
        <if test="byOperator != null and byOperator == &quot;1&quot;">
            tk.otype,
        </if>
        tk.errcode
        from sms_sp_info sp left join sms_errcode_summary tk
        on tk.spid = sp.id
        left join sms_send_channel_info ssci on tk.channelid = ssci.id
        left join mms_send_channel_info msci on tk.channelid = msci.id

        <where>
        <if test="sp_name != null and sp_name != ''">
                and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="salerList != null and salerList.size() > 0">
            and sp.sp_saler in
            <foreach collection="salerList" item="item" open="(" separator="," close=")">
                '${item}'
            </foreach>
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler =#{sp_saler}
        </if>
        <if test="sp_id!=null and sp_id>0">
            and tk.spid=#{sp_id}
        </if>
        <if test="channelid !=null and channelid >=0">
            and tk.channelid=#{channelid}
        </if>
        <if test="channel_name !=null and channel_name !=''">
            and ( ssci.CHANNEL_NAME like CONCAT('%', #{channel_name}, '%') or msci.CHANNEL_NAME like CONCAT('%', #{channel_name}, '%'))
        </if>
        <if test="errcode !=null and errcode !=''">
            and tk.errcode =#{errcode}
        </if>
        <if test="sign !=null and sign !=''">
            and tk.sign like CONCAT('%', #{sign}, '%')
        </if>
        <if test="province !=null and province !=''">
            and tk.province =#{province}
        </if>
        <if test="code !=null  and code ==&quot;1&quot;">
            and  tk.errcode = 'DELIVRD'
        </if>
        <if test="code !=null and code == &quot;2&quot;">
            and  tk.errcode != 'DELIVRD'
        </if>

        <if test="sp_type!=null and sp_type>0">
            and sp.sp_type =#{sp_type}
        </if>
        <if test="createTime!=null and createTime!=''">
            and tk.stat_time&gt;=str_to_date(#{createTime},'%Y-%m-%d')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and
            tk.stat_time&lt;DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
        <if test="operateOtypeSelect != null and operateOtypeSelect != ''">
            and tk.otype = #{operateOtypeSelect} <!-- tk.otype是数据库表中运营商字段 -->
        </if>
        </where>
        group by tk.errcode
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            ,sp.id
        </if>
        <if test="byChannelId != null and byChannelId == &quot;1&quot;">
            ,tk.channelid
        </if>
        <if test="bySign != null and bySign == &quot;1&quot;">
            , tk.sign
        </if>
        <if test="byProvince != null and byProvince == &quot;1&quot;">
            , tk.province
        </if>
        <if test="byDay != null and byDay == &quot;1&quot;">
            ,tk.stat_time
        </if>
        <if test="byOperator != null and byOperator == &quot;1&quot;">
            , tk.otype
        </if>
        ) a left join
        (SELECT errcode , GROUP_CONCAT(reason SEPARATOR';') reason FROM sms_err_code GROUP BY errcode) sec
        on a.errcode = sec.errcode
        order by a.allnumber desc

    </select>

    <!--  group by sp.id, sp.sp_name,tk.channelid,tk.sign,tk.errcode -->
    <select id="exportErrCodeTotalList" parameterType="ErrCodeSummary"
        resultType="Map">
        select a.*,sec.reason from
        (
        select sum(tk.allnumber) allnumber,
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            sp.id sp_id, sp.sp_name,
        </if>
        <if test="byChannelId != null and byChannelId == &quot;1&quot;">
            tk.channelid,
            COALESCE(ssci.CHANNEL_NAME, msci.CHANNEL_NAME, '') as channel_name,
        </if>
        <if test="bySign != null and bySign == &quot;1&quot;">
            tk.sign,
        </if>
        <if test="byProvince != null and byProvince == &quot;1&quot;">
            tk.province,
        </if>
        <if test="byDay != null and byDay == &quot;1&quot;">
            DATE_FORMAT(tk.stat_time,'%Y-%m-%d') as stat_time,
        </if>
        <if test="byOperator != null and byOperator == &quot;1&quot;">
            tk.otype,
        </if>
        tk.errcode
        from sms_sp_info sp left join sms_errcode_summary tk on tk.spid = sp.id
        left join sms_send_channel_info ssci on tk.channelid = ssci.id
        left join mms_send_channel_info msci on tk.channelid = msci.id
        where 1=1
        <if test="sp_name != null and sp_name != ''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="sp_id != null and sp_id > 0">
            and tk.spid=#{sp_id}
        </if>
        <if test="channelid != null and channelid >= 0">
            and tk.channelid=#{channelid}
        </if>
        <if test="errcode != null and errcode != ''">
            and tk.errcode =#{errcode}
        </if>
        <if test="sign != null and sign != ''">
            and tk.sign =#{sign}
        </if>
        <if test="sp_saler != null and sp_saler != ''">
            and sp.sp_saler =#{sp_saler}
        </if>
        <if test="sp_type != null and sp_type > 0">
            and sp.sp_type =#{sp_type}
        </if>
        <if test="createTime != null and createTime != ''">
            and tk.stat_time&gt;=str_to_date(#{createTime},'%Y-%m-%d')
        </if>
        <if test="code !=null  and code ==&quot;1&quot;">
            and  tk.errcode = 'DELIVRD'
        </if>
        <if test="code !=null and code == &quot;2&quot;">
            and  tk.errcode != 'DELIVRD'
        </if>
        <if test="createTime1 != null and createTime1 != ''">
            and
            tk.stat_time&lt;DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
        <if test="province != null and province != ''">
            and tk.province =#{province}
        </if>
        <if test="operateOtypeSelect != null and operateOtypeSelect != ''">
            and tk.otype = #{operateOtypeSelect}
        </if>
        group by tk.errcode
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            ,sp.id
        </if>
        <if test="byChannelId != null and byChannelId == &quot;1&quot;">
            ,tk.channelid
        </if>
        <if test="bySign != null and bySign == &quot;1&quot;">
            , tk.sign
        </if>
        <if test="byProvince != null and byProvince == &quot;1&quot;">
            , tk.province
        </if>
        <if test="byDay != null and byDay == &quot;1&quot;">
            ,tk.stat_time
        </if>
        <if test="byOperator != null and byOperator == &quot;1&quot;">
            ,tk.otype
        </if>
        ) a left join
        (SELECT errcode , GROUP_CONCAT(reason SEPARATOR';') reason FROM sms_err_code GROUP BY errcode) sec
        on a.errcode = sec.errcode
        order by a.allnumber desc
    </select>


    <select id="listSpTaskErrCodeCount" parameterType="ErrCodeSummary"
        resultMap="ErrCodeSummaryResultMap">
        select
        sum(IFNULL(tk.allnumber,0)) allnumber
        from sms_errcode_summary tk, sms_sp_info sp
        where tk.spid = sp.id

         <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="sp_id!=null and sp_id>0">
            and tk.spid=#{sp_id}
        </if>
        <if test="code !=null  and code ==&quot;1&quot;">
            and  tk.errcode = 'DELIVRD'
        </if>
        <if test="code !=null and code == &quot;2&quot;">
            and  tk.errcode != 'DELIVRD'
        </if>
        <if test="channelid !=null and channelid >= 0">
            and tk.channelid=#{channelid}
        </if>
        <if test="errcode !=null and errcode !=''">
            and tk.errcode =#{errcode}
        </if>
        <if test="sign !=null and sign !=''">
            and tk.sign like CONCAT('%',#{sign},'%')
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler =#{sp_saler}
        </if>
        <if test="sp_type!=null and sp_type>0">
            and sp.sp_type =#{sp_type}
        </if>
        <if test="createTime!=null and createTime!=''">
            and tk.stat_time&gt;=str_to_date(#{createTime},'%Y-%m-%d')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and
            tk.stat_time&lt;DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
        <if test="operateOtypeSelect != null and operateOtypeSelect != ''">
            and tk.otype = #{operateOtypeSelect}
        </if>
    </select>

    <select id="listPageAgainErrCode" resultMap="ErrCodeSummaryResultMap">
        select
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            sp.id sp_id, sp.sp_name,
        </if>
        sum(tk.allnumber) allnumber,
        <if test="byChannelId != null and byChannelId == &quot;1&quot;">
            tk.channelid,
        </if>
        <if test="bySign != null and bySign == &quot;1&quot;">
            tk.sign,
        </if>
        tk.errcode
        from sms_sp_info sp left join  sms_resend_errcode_summary tk
        on tk.spid = sp.id
        where 1=1
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="sp_id!=null and sp_id>0">
            and tk.spid=#{sp_id}
        </if>
        <if test="channelid !=null and channelid >=0">
            and tk.channelid=#{channelid}
        </if>
        <if test="errcode !=null and errcode !=''">
            and tk.errcode =#{errcode}
        </if>
        <if test="sign !=null and sign !=''">
            and tk.sign =#{sign}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler =#{sp_saler}
        </if>
        <if test="sp_type!=null and sp_type>0">
            and sp.sp_type =#{sp_type}
        </if>
        <if test="createTime!=null and createTime!=''">
            and tk.stat_time&gt;=str_to_date(#{createTime},'%Y-%m-%d')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and tk.stat_time&lt;DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
        group by tk.errcode
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            ,sp.id
        </if>
        <if test="byChannelId != null and byChannelId == &quot;1&quot;">
            ,tk.channelid
        </if>
        <if test="bySign != null and bySign == &quot;1&quot;">
            , tk.sign
        </if>
        order by sum(tk.allnumber) desc
    </select>

    <select id="listAgainErrorCodeCount" resultMap="ErrCodeSummaryResultMap">
        select
        sum(IFNULL(tk.allnumber,0)) allnumber
        from sms_resend_errcode_summary tk, sms_sp_info sp
        where tk.spid = sp.id

        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="sp_id!=null and sp_id>0">
            and tk.spid=#{sp_id}
        </if>

        <if test="channelid !=null and channelid >=0">
            and tk.channelid=#{channelid}
        </if>
        <if test="errcode !=null and errcode !=''">
            and tk.errcode =#{errcode}
        </if>
        <if test="sign !=null and sign !=''">
            and tk.sign =#{sign}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler =#{sp_saler}
        </if>
        <if test="sp_type!=null and sp_type>0">
            and sp.sp_type =#{sp_type}
        </if>

        <if test="createTime!=null and createTime!=''">
            and tk.stat_time&gt;=str_to_date(#{createTime},'%Y-%m-%d')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and
            tk.stat_time&lt;DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>

    </select>

    <select id="exportAgainErrCodeTotalList" resultType="java.util.Map">
        select
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            sp.id sp_id,
            sp.sp_name,
        </if>
        sum(tk.allnumber) allnumber,
        <if test="byChannelId != null and byChannelId == &quot;1&quot;">
            tk.channelid,
        </if>
        <if test="bySign != null and bySign == &quot;1&quot;">
            tk.sign,
        </if>
        tk.errcode
        from sms_sp_info sp, sms_resend_errcode_summary tk
        where  tk.spid = sp.id
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="sp_id!=null and sp_id>0">
            and tk.spid=#{sp_id}
        </if>
        <if test="channelid !=null and channelid >=0">
            and tk.channelid=#{channelid}
        </if>
        <if test="errcode !=null and errcode !=''">
            and tk.errcode =#{errcode}
        </if>
        <if test="sign !=null and sign !=''">
            and tk.sign =#{sign}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler =#{sp_saler}
        </if>
        <if test="sp_type!=null and sp_type>0">
            and sp.sp_type =#{sp_type}
        </if>
        <if test="createTime!=null and createTime!=''">
            and tk.stat_time&gt;=str_to_date(#{createTime},'%Y-%m-%d')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and tk.stat_time&lt;DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
        group by tk.errcode
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            ,sp.id
        </if>
        <if test="byChannelId != null and byChannelId == &quot;1&quot;">
            ,tk.channelid
        </if>
        <if test="bySign != null and bySign == &quot;1&quot;">
            , tk.sign
        </if>
        order by sum(tk.allnumber) desc
    </select>

    <select id="listPageProvinceSignList" resultType="cn.roadm.bo.ProvinceSignEntity">
        select  sps.sign,
        <if test='bySpId != null and bySpId == "1"'>
            sps.sp_id spId, sp.sp_name spName,
        </if>
        <if test='byProvince != null and byProvince == "1"'>
             sps.province,
        </if>
        <if test='byStatTime != null and byStatTime == "1"'>
            sps.stat_time statTime,
        </if>
        sum(IFNULL(sps.submit_succ, 0)) submitSucc,
        sum(IFNULL(sps.submit_fail, 0)) submitFail,
        sum(IFNULL(sps.arrive_succ, 0)) arriveSucc,
        sum(IFNULL(sps.arrive_fail, 0)) arriveFail
        from sms_province_sign sps left join sms_sp_info sp on sps.sp_id = sp.id
        <where>
            <if test="spId != null">
                sps.sp_id = #{spId}
            </if>
            <if test="spName != null and spName != ''">
                and sp.sp_name like CONCAT('%',#{spName},'%')
            </if>
            <if test="province != null and province != ''">
                and sps.province like CONCAT('%',#{province},'%')
            </if>
            <if test="sign != null and sign != ''">
                and sps.sign like CONCAT('%',#{sign},'%')
            </if>
            <if test="startTime != null and startTime != ''">
                and sps.stat_time &gt;= #{startTime}
            </if>
            <if test="endTime != null and endTime != ''">
                and sps.stat_time &lt;= #{endTime}
            </if>
        </where>
        group by
        <if test='bySpId != null and bySpId == "1"'>
            spId, spName,
        </if>
        <if test='byProvince != null and byProvince == "1"'>
            sps.province,
        </if>
        <if test='byStatTime != null and byStatTime == "1"'>
            sps.stat_time,
        </if>
        sps.sign
        order by submitSucc desc
        <if test='byStatTime != null and byStatTime == "1"'>, sps.stat_time desc</if>
    </select>

    <select id="getProvinceSignTotal" resultType="cn.roadm.bo.ProvinceSignEntity">
        select  sum(IFNULL(sps.submit_succ, 0)) submitSucc,
                sum(IFNULL(sps.submit_fail, 0)) submitFail,
                sum(IFNULL(sps.arrive_succ, 0)) arriveSucc,
                sum(IFNULL(sps.arrive_fail, 0)) arriveFail
        from sms_province_sign sps left join sms_sp_info sp on sps.sp_id = sp.id
        <where>
            <if test="spId != null">
                sps.sp_id = #{spId}
            </if>
            <if test="spName != null and spName != ''">
                and sp.sp_name like CONCAT('%',#{spName},'%')
            </if>
            <if test="province != null and province != ''">
                and sps.province like CONCAT('%',#{province},'%')
            </if>
            <if test="sign != null and sign != ''">
                and sps.sign like CONCAT('%',#{sign},'%')
            </if>
            <if test="startTime != null and startTime != ''">
                and sps.stat_time &gt;= #{startTime}
            </if>
            <if test="endTime != null and endTime != ''">
                and sps.stat_time &lt;= #{endTime}
            </if>
        </where>
    </select>

    <select id="exportPageProvinceSignList" resultType="java.util.Map">
        select  sps.sign,
        <if test='bySpId != null and bySpId == "1"'>
            sps.sp_id spId, sp.sp_name spName,
        </if>
        <if test='byProvince != null and byProvince == "1"'>
            sps.province,
        </if>
        <if test='byStatTime != null and byStatTime == "1"'>
            sps.stat_time statTime,
        </if>
        IFNULL(sum(sps.submit_succ), 0) submitSucc,
        IFNULL(sum(sps.submit_fail), 0) submitFail,
        IFNULL(sum(sps.arrive_succ), 0) arriveSucc,
        IFNULL(sum(sps.arrive_fail), 0) arriveFail,
        IFNULL(sum(sps.submit_succ), 0)+IFNULL(sum(sps.submit_fail), 0) submitNum,
        IFNULL(sum(sps.arrive_succ), 0)+IFNULL(sum(sps.arrive_fail), 0) arriveNum,
        IFNULL(sum(sps.submit_succ), 0)+IFNULL(sum(sps.submit_fail), 0)-IFNULL(sum(sps.arrive_succ), 0)-IFNULL(sum(sps.arrive_fail), 0) unknownNum,
        Round(IFNULL(sum( sps.arrive_succ ), 0 )/  IFNULL (sum( sps.submit_succ), 0)* 100, 2 ) gateWaySucessRate,
        Round(IFNULL(sum( sps.arrive_succ), 0 ) / (IFNULL(sum( sps.submit_succ), 0 ) + IFNULL(sum(sps.submit_fail), 0))* 100, 2 ) sucessRate
        from sms_province_sign sps left join sms_sp_info sp on sps.sp_id = sp.id
        <where>
            <if test="spId != null">
                sps.sp_id = #{spId}
            </if>
            <if test="spName != null and spName != ''">
                and sp.sp_name like CONCAT('%',#{spName},'%')
            </if>
            <if test="province != null and province != ''">
                and sps.province like CONCAT('%',#{province},'%')
            </if>
            <if test="sign != null and sign != ''">
                and sps.sign like CONCAT('%',#{sign},'%')
            </if>
            <if test="startTime != null and startTime != ''">
                and sps.stat_time &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and sps.stat_time &lt;= str_to_date(#{endTime},'%Y-%m-%d')
            </if>
        </where>
        group by
        <if test='bySpId != null and bySpId == "1"'>
            sps.sp_id,
        </if>
        <if test='byProvince != null and byProvince == "1"'>
            sps.province,
        </if>
        <if test='byStatTime != null and byStatTime == "1"'>
            sps.stat_time,
        </if>
        sps.sign
        order by submitSucc desc, MAX(sps.stat_time) desc
    </select>

    <!--彩信错误码统计-->
    <select id="listPageMmsAgainErrCode" resultMap="ErrCodeSummaryResultMap">
        select
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            sp.id sp_id, sp.sp_name,
        </if>
        sum(tk.allnumber) allnumber,
        <if test="byChannelId != null and byChannelId == &quot;1&quot;">
            tk.channelid,
        </if>
        <if test="bySign != null and bySign == &quot;1&quot;">
            tk.sign,
        </if>
        tk.errcode
        from sms_sp_info sp left join mms_resend_errcode_summary tk
        on tk.spid = sp.id
        where 1=1
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="sp_id!=null and sp_id>0">
            and tk.spid=#{sp_id}
        </if>
        <if test="channelid !=null and channelid >=0">
            and tk.channelid=#{channelid}
        </if>
        <if test="errcode !=null and errcode !=''">
            and tk.errcode =#{errcode}
        </if>
        <if test="sign !=null and sign !=''">
            and tk.sign =#{sign}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler =#{sp_saler}
        </if>
        <if test="sp_type!=null and sp_type>0">
            and sp.sp_type =#{sp_type}
        </if>
        <if test="createTime!=null and createTime!=''">
            and tk.stat_time&gt;=str_to_date(#{createTime},'%Y-%m-%d')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and tk.stat_time&lt;DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
        group by tk.errcode
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            ,sp.id
        </if>
        <if test="byChannelId != null and byChannelId == &quot;1&quot;">
            ,tk.channelid
        </if>
        <if test="bySign != null and bySign == &quot;1&quot;">
            , tk.sign
        </if>
        order by sum(tk.allnumber) desc
    </select>

    <!--彩信错误码占比-->
    <select id="listMmsAgainErrorCodeCount" resultMap="ErrCodeSummaryResultMap">
        select
        sum(IFNULL(tk.allnumber,0)) allnumber
        from mms_resend_errcode_summary tk, sms_sp_info sp
        where tk.spid = sp.id

        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="sp_id!=null and sp_id>0">
            and tk.spid=#{sp_id}
        </if>

        <if test="channelid !=null and channelid >=0">
            and tk.channelid=#{channelid}
        </if>
        <if test="errcode !=null and errcode !=''">
            and tk.errcode =#{errcode}
        </if>
        <if test="sign !=null and sign !=''">
            and tk.sign =#{sign}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler =#{sp_saler}
        </if>
        <if test="sp_type!=null and sp_type>0">
            and sp.sp_type =#{sp_type}
        </if>

        <if test="createTime!=null and createTime!=''">
            and tk.stat_time&gt;=str_to_date(#{createTime},'%Y-%m-%d')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and
            tk.stat_time&lt;DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>

    </select>
</mapper>
