<?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="com.hzs.third.sms.mapper.TSmsRecordMapper">

    <!-- 查询列表 -->
    <select id="queryList" resultType="com.hzs.common.domain.third.sms.ext.TSmsRecordExt">
        select tsr.*, tst.template_code, tst.template_name
        from T_SMS_RECORD tsr
        inner join T_SMS_TEMPLATE tst
        on tst.pk_id = tsr.pk_sms_template
        where tsr.del_flag = 0
        and tst.del_flag = 0
        and tsr.pk_country = #{pkCountry}
        <if test="param.phone != null and param.phone != ''">
            and tsr.phone = #{param.phone}
        </if>
        <if test="param.templateName != null and param.templateName != ''">
            and tst.template_name like #{param.templateName} || '%'
        </if>
        <if test="param.sendType != null">
            and tsr.send_type = #{param.sendType}
        </if>
        <if test="param.sendStatus != null">
            and tsr.send_status = #{param.sendStatus}
        </if>
        <if test="param.modifiedTime != null">
            and tsr.modified_time >= #{param.modifiedTime[0]}
            and #{param.modifiedTime[1]} >= tsr.modified_time
        </if>
        order by tsr.CREATION_TIME desc
    </select>

</mapper>
