<?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.PaInfoMapper">

    <resultMap type="PaInfo" id="PaInfoResultMap">
        <id column="id" property="p_id" />
        <result column="pa_dec" property="pa_desc" />
        <result column="submit_count" property="submit_count" />
        <result column="submitresp_succ" property="submitresp_succ" />
        <result column="submitresp_fail" property="submitresp_fail" />
        <result column="timeout_count" property="timeout_count" />
        <result column="report_count" property="report_count" />
        <result column="report_succ" property="report_succ" />
        <result column="report_fail" property="report_fail" />
        <result column="createtime" property="createtime" />
        <result column="time" property="time" />
        <result column="query_time" property="queryTime" />
        <result column="ping_time" property="pingTime" />
        <result column="auto_change" property="autoChange" />
    </resultMap>

    <resultMap type="PaInfo" id="exportPaListResultMap">
        <id column="id" property="p_id" />
        <result column="pa_dec" property="pa_desc" />
        <result column="submit_count" property="submit_count" />
        <result column="submitresp_succ" property="submitresp_succ" />
        <result column="submitresp_fail" property="submitresp_fail" />
        <result column="timeout_count" property="timeout_count" />
        <result column="report_count" property="report_count" />
        <result column="report_succ" property="report_succ" />
        <result column="report_fail" property="report_fail" />
        <result column="createtime" property="createtime" />
        <result column="query_time" property="queryTime" />
        <result column="ping_time" property="pingTime" />
        <result column="auto_change" property="autoChange" />
    </resultMap>

    <resultMap type="PaInfo" id="PaMinuteResultMap">
        <id column="id" property="p_id" />
        <result column="pa_dec" property="pa_desc" />
        <result column="submit_count" property="submit_count" />
        <result column="submitresp_succ" property="submitresp_succ" />
        <result column="submitresp_fail" property="submitresp_fail" />
        <result column="timeout_count" property="timeout_count" />
        <result column="report_count" property="report_count" />
        <result column="report_succ" property="report_succ" />
        <result column="report_fail" property="report_fail" />
        <result column="time" property="time" />
    </resultMap>

    <resultMap type="PaInfo" id="PaPropertyMap">
        <id column="id" property="p_id" />
        <result column="pa_dec" property="pa_desc" />
        <result column="pa_name" property="pa_name" />
        <result column="costprice" property="costprice" />
        <result column="status" property="status" />
    </resultMap>



    <resultMap type="PaInfo" id="exportPaMonthListResultMap">
        <id column="id" property="p_id" />
        <result column="pa_dec" property="pa_desc" />
        <result column="submit_count" property="submit_count" />
        <result column="submitresp_succ" property="submitresp_succ" />
        <result column="submitresp_fail" property="submitresp_fail" />
        <result column="timeout_count" property="timeout_count" />
        <result column="report_count" property="report_count" />
        <result column="report_succ" property="report_succ" />
        <result column="report_fail" property="report_fail" />
        <result column="createtime" property="createtime" />
    </resultMap>

    <resultMap type="ChannelLimit" id="channelLimitResultMap">
        <id column="id" property="id" />
        <result column="channelid" property="channelid" />
        <result column="oneday" property="oneday" />
        <result column="threeday" property="threeday" />
        <result column="nday" property="nday" />
        <result column="ntimes" property="ntimes" />
        <result column="label" property="label" />
        <result column="createtime" property="createtime" />
    </resultMap>
    <resultMap type="TaskInfo" id="taskResultMap">
        <id column="id" property="task_id" />
        <result column="content" property="content" />
        <result column="createtime" property="createTime" />
        <result column="total" property="total" />
        <result column="allnumber" property="allnumber" />
        <result column="mobilenumber" property="mobilenumber" />
        <result column="unicomnumber" property="unicomnumber" />
        <result column="telecomnumer" property="telecomnumber" />
        <result column="succ" property="succ" />
        <result column="fail" property="fail" />
        <result column="arrive_succ" property="arrive_succ" />
        <result column="arrive_fail" property="arrive_fail" />
        <result column="task_type" property="task_type" />
        <result column="status" property="status" />
        <result column="endtime" property="endTime" />
        <result column="send_type" property="send_type" />
        <result column="sp_id" property="sp_id" />
        <result column="unRecMsgnum" property="unRecMsgnum" />
        <result column="sp_name" property="sp_name" />
        <result column="time" property="time" />
        <result column="difference" property="difference" />
        <result column="stat_time" property="stat_time"/>

    </resultMap>

    <!--   sum(IFNULL(pt.resendsubmit_succ,0)) resendsubmit_succ,
        sum(IFNULL(pt.resendsubmit_fail,0)) resendsubmit_fail,
        sum(IFNULL(pt.resendarrive_succ,0)) resendarrive_succ,
        sum(IFNULL(pt.resendarrive_fail,0)) resendarrive_fail,
        sum(IFNULL(pt.beresendsubmit_succ,0)) beresendsubmit_succ,
        sum(IFNULL(pt.beresendsubmit_fail,0)) beresendsubmit_fail,
        sum(IFNULL(pt.beresendarrive_succ,0)) beresendarrive_succ,
        sum(IFNULL(pt.beresendarrive_fail,0)) beresendarrive_fail -->
    <select id="exportPaMonthList" parameterType="PaInfo"
        resultType="Map">
        select g.ID,
        g.CHANNEL_NAME pa_dec,
        date_format(pt.total_time, '%Y-%m') createtime,
        sum(IFNULL(pt.submitresp_succ,0))+sum(IFNULL(pt.submitresp_fail,0)) submit_count,
        sum(IFNULL(pt.submitresp_succ,0)) submitresp_succ,
        sum(IFNULL(pt.submitresp_fail,0)) submitresp_fail,
        sum(IFNULL(pt.timeout_count,0)) timeout_count ,
        sum(IFNULL(pt.report_succ,0))+sum(IFNULL(pt.report_fail,0)) report_count ,
        sum(IFNULL(pt.report_succ,0)) report_succ,
        sum(IFNULL(pt.submitresp_succ,0))+sum(IFNULL(pt.submitresp_fail,0))-sum(IFNULL(pt.report_succ,0))-sum(IFNULL(pt.report_fail,0)) unRecMsgnum,
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            pt.SP_ID, sp.SP_NAME,
        </if>
        <if test="byotype != null and byotype == &quot;1&quot;">
            pt.otype,
        </if>
        sum(IFNULL(pt.report_fail,0)) report_fail
        from pa_day_count pt, (select id,CHANNEL_NAME,business_manager from sms_send_channel_info union select id,CHANNEL_NAME,business_manager from mms_send_channel_info) g, sms_sp_info sp
        where pt.channelid = g.id and pt.sp_id = sp.id
        <if test="p_id!=null and p_id>=0">
            and g.id =#{p_id}
        </if>
        <if test="pa_desc!=null and pa_desc!=''">
            and g.CHANNEL_NAME   like CONCAT('%',#{pa_desc},'%')
        </if>
        <if test="business_manager != null and business_manager != '' and business_manager != 'undefined'">
            and g.business_manager = #{business_manager}
        </if>
        <if test="managerId != null and managerId != ''">
            and g.business_manager in (select ifnull(business,'') from business_manager where managerId = #{managerId}) and g.business_manager != ''
        </if>
        <if test="month!=null and month!=''">
            and date_format(pt.total_time,'%Y-%m')=#{month}
        </if>
        <if test="sp_id!=null and sp_id!=''">
            and pt.SP_ID=#{sp_id}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and sp.SP_NAME like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="otype!=null and otype!=''">
            and pt.otype = #{otype}
        </if>
        group by date_format(pt.total_time, '%Y-%m'), g.id, g.CHANNEL_NAME
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            , pt.SP_ID, sp.sp_name
        </if>
        <if test="byotype!=null and byotype == &quot;1&quot;">
            , pt.otype
        </if>
    </select>

    <select id="exportMMSPaMonthList" parameterType="PaInfo"
        resultType="Map">
        select g.ID,
        g.CHANNEL_NAME pa_dec,
        date_format(pt.total_time, '%Y-%m') createtime,
        sum(IFNULL(pt.submitresp_succ,0))+sum(IFNULL(pt.submitresp_fail,0)) submit_count,
        sum(IFNULL(pt.submitresp_succ,0)) submitresp_succ,
        sum(IFNULL(pt.submitresp_fail,0)) submitresp_fail,
        sum(IFNULL(pt.timeout_count,0)) timeout_count ,
        sum(IFNULL(pt.report_succ,0))+sum(IFNULL(pt.report_fail,0)) report_count ,
        sum(IFNULL(pt.report_succ,0)) report_succ,
        sum(IFNULL(pt.submitresp_succ,0))+sum(IFNULL(pt.submitresp_fail,0))-sum(IFNULL(pt.report_succ,0))-sum(IFNULL(pt.report_fail,0)) unRecMsgnum,
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            pt.SP_ID, sp.SP_NAME,
        </if>
        sum(IFNULL(pt.report_fail,0)) report_fail
        from pa_day_count pt, mms_send_channel_info g, sms_sp_info sp
        where pt.channelid = g.id and pt.sp_id = sp.id and pt.channelid>0
        <if test="p_id!=null and p_id>=0">
            and g.id =#{p_id}
        </if>
        <if test="pa_desc!=null and pa_desc!=''">
            and g.CHANNEL_NAME   like CONCAT('%',#{pa_desc},'%')
        </if>
        <if test="business_manager != null and business_manager != '' and business_manager != 'undefined'">
            and g.business_manager = #{business_manager}
        </if>
        <if test="managerId != null and managerId != ''">
            and g.business_manager in (select ifnull(business,'') from business_manager where managerId = #{managerId}) and g.business_manager != ''
        </if>
        <if test="month!=null and month!=''">
            and date_format(pt.total_time,'%Y-%m')=#{month}
        </if>
        <if test="sp_id!=null and sp_id!=''">
            and pt.SP_ID=#{sp_id}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and sp.SP_NAME like CONCAT('%',#{sp_name},'%')
        </if>
        group by date_format(pt.total_time, '%Y-%m'), g.id, g.CHANNEL_NAME
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            , pt.SP_ID, sp.sp_name
        </if>
    </select>

    <!--  sum( IFNULL(pt.resendsubmit_succ,0) ) resendsubmit_succ,
        sum( IFNULL(pt.resendsubmit_fail,0) ) resendsubmit_fail,
        sum( IFNULL(pt.resendarrive_succ,0) ) resendarrive_succ,
        sum( IFNULL(pt.resendarrive_fail,0) ) resendarrive_fail,
        sum( IFNULL(pt.beresendsubmit_succ,0) ) beresendsubmit_succ,
        sum( IFNULL(pt.beresendsubmit_fail,0) ) beresendsubmit_fail,
        sum( IFNULL(pt.beresendarrive_succ,0) ) beresendarrive_succ,
        sum( IFNULL(pt.beresendarrive_fail,0) ) beresendarrive_fail -->
    <select id="exportPaList" parameterType="PaInfo" resultType="Map">
        select
        g.ID pa_id,
        g.CHANNEL_NAME pa_dec,
        sum( IFNULL(pt.submitresp_succ,0) )+ sum( IFNULL(pt.submitresp_fail,0) ) submit_count,
        sum( IFNULL(pt.submitresp_succ,0) ) submitresp_succ,
        sum( IFNULL(pt.submitresp_fail,0) ) submitresp_fail,
        sum( pt.timeout_count ) timeout_count,
        sum( IFNULL(pt.report_succ,0) )+ sum( IFNULL(pt.report_fail,0) ) report_count,
        sum( IFNULL(pt.report_succ,0) ) report_succ,
        sum( IFNULL(pt.report_fail,0) ) report_fail,
        sum( IFNULL(pt.submitresp_succ,0) )+ sum( IFNULL(pt.submitresp_fail,0) )- sum( IFNULL(pt.report_succ,0) )- sum( IFNULL(pt.report_fail,0) ) unRecMsgnum,
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            pt.sp_id as SP_ID, sp.sp_name as SP_NAME,
        </if>
        <if test="byProvince != null and byProvince == &quot;1&quot;">
            pt.province as PROVINCE,
        </if>
        date_format( pt.total_time, '%Y-%m-%d' ) createtime
        from pa_day_count pt, sms_send_channel_info g, sms_sp_info sp
        where pt.channelid = g.id and pt.SP_ID = sp.id
        <if test="p_id!=null and p_id>=0">
            and g.id =#{p_id}
        </if>
        <if test="pa_desc!=null and pa_desc!=''">
            and g.CHANNEL_NAME like CONCAT('%',#{pa_desc},'%')
        </if>
        <if test="business_manager != null and business_manager != '' and business_manager != 'undefined'">
            and g.business_manager = #{business_manager}
        </if>
        <if test="managerId != null and managerId != ''">
            and g.business_manager in (select ifnull(business,'') from business_manager where managerId = #{managerId}) and g.business_manager != ''
        </if>
        <if test="createtime!=null and createtime!=''">
            and pt.total_time &gt;=str_to_date(#{createtime},'%Y-%m-%d')
        </if>
        <if test="endtime!=null and endtime!=''">
            and pt.total_time &lt;=str_to_date(#{endtime},'%Y-%m-%d')
        </if>
        <if test="createtime==null or createtime==''">
            and pt.total_time &gt;=sysdate()-2
        </if>
        <if test="sp_id!=null and sp_id!=''">
            and pt.SP_ID=#{sp_id}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and sp.SP_NAME like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="province_select != null and province_select != ''">
            and pt.province = #{province_select}
        </if>
        group by date_format(pt.total_time, '%Y-%m-%d'), g.id,g.CHANNEL_NAME
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            , pt.sp_id, sp.sp_name
        </if>
        <if test="byProvince != null and byProvince == &quot;1&quot;">
            , pt.province
        </if>
        order by date_format(pt.total_time, '%Y-%m-%d' )
    </select>
    <select id="exportMMSPaList" parameterType="PaInfo" resultType="Map">
        select
        g.ID pa_id,
        g.CHANNEL_NAME pa_dec,
        sum( IFNULL(pt.submitresp_succ,0) )+ sum( IFNULL(pt.submitresp_fail,0) ) submit_count,
        sum( IFNULL(pt.submitresp_succ,0) ) submitresp_succ,
        sum( IFNULL(pt.submitresp_fail,0) ) submitresp_fail,
        sum( pt.timeout_count ) timeout_count,
        sum( IFNULL(pt.report_succ,0) )+ sum( IFNULL(pt.report_fail,0) ) report_count,
        sum( IFNULL(pt.report_succ,0) ) report_succ,
        sum( IFNULL(pt.report_fail,0) ) report_fail,
        sum( IFNULL(pt.submitresp_succ,0) )+ sum( IFNULL(pt.submitresp_fail,0) )- sum( IFNULL(pt.report_succ,0) )- sum( IFNULL(pt.report_fail,0) ) unRecMsgnum,
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            pt.sp_id as SP_ID, sp.sp_name as SP_NAME,
        </if>
        <if test="byProvince != null and byProvince == &quot;1&quot;">
            pt.province as PROVINCE,
        </if>
        date_format( pt.total_time, '%Y-%m-%d' ) createtime
        from pa_day_count pt, mms_send_channel_info g, sms_sp_info sp
        where pt.channelid = g.id and pt.SP_ID = sp.id and pt.channelid>0
        <if test="p_id!=null and p_id>=0">
            and g.id =#{p_id}
        </if>
        <if test="pa_desc!=null and pa_desc!=''">
            and g.CHANNEL_NAME like CONCAT('%',#{pa_desc},'%')
        </if>
        <if test="business_manager != null and business_manager != '' and business_manager != 'undefined'">
            and g.business_manager = #{business_manager}
        </if>
        <if test="managerId != null and managerId != ''">
            and g.business_manager in (select ifnull(business,'') from business_manager where managerId = #{managerId}) and g.business_manager != ''
        </if>
        <if test="createtime!=null and createtime!=''">
            and pt.total_time &gt;=str_to_date(#{createtime},'%Y-%m-%d')
        </if>
        <if test="endtime!=null and endtime!=''">
            and pt.total_time &lt;=str_to_date(#{endtime},'%Y-%m-%d')
        </if>
        <if test="createtime==null or createtime==''">
            and pt.total_time &gt;=sysdate()-2
        </if>
        <if test="sp_id!=null and sp_id!=''">
            and pt.SP_ID=#{sp_id}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and sp.SP_NAME like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="province_select != null and province_select != ''">
            and pt.province = #{province_select}
        </if>
        group by date_format(pt.total_time, '%Y-%m-%d'), g.id,g.CHANNEL_NAME
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            , pt.sp_id, sp.sp_name
        </if>
        <if test="byProvince != null and byProvince == &quot;1&quot;">
            , pt.province
        </if>
        order by date_format(pt.total_time, '%Y-%m-%d' )
    </select>

    <!--  sum(pt.resendsubmit_succ) resendsubmit_succ,
        sum(pt.resendsubmit_fail) resendsubmit_fail,
        sum(pt.resendarrive_succ) resendarrive_succ,
        sum(pt.resendarrive_fail) resendarrive_fail,
        sum(pt.beresendsubmit_succ) beresendsubmit_succ,
        sum(pt.beresendsubmit_fail) beresendsubmit_fail,
        sum(pt.beresendarrive_succ) beresendarrive_succ,
        sum(pt.beresendarrive_fail) beresendarrive_fail -->
    <select id="listPagePaInfo" parameterType="PaInfo" resultMap="PaInfoResultMap">
        select
        g.id p_id,
        g.CHANNEL_NAME pa_dec,
        sum(pt.submit_count) submit_count,
        sum(pt.submitresp_succ) submitresp_succ,
        sum(pt.submitresp_fail) submitresp_fail,
        sum(pt.timeout_count) timeout_count,
        sum(pt.report_count) report_count,
        sum(pt.report_succ) report_succ,
        sum(pt.report_fail) report_fail,
        date_format(pt.total_time,'%Y-%m-%d') createtime,
        sum(pt.submit_count)-sum(pt.report_count) unRecMsgnum,
        <if test="bySpId != null and bySpId == &quot;1&quot;">
             pt.sp_id, sp.sp_name,
        </if>
        <if test="byProvince != null and byProvince == &quot;1&quot;">
             pt.province,
        </if>
        g.business_manager
        from pa_day_count pt, sms_send_channel_info g, sms_sp_info sp
       where pt.channelid = g.id and pt.sp_id = sp.id

        <if test="pa_desc!=null and pa_desc!=''">
            and g.CHANNEL_NAME like CONCAT('%',#{pa_desc},'%')
        </if>

         <if test="p_id!=null and p_id>=0">
            and g.id =#{p_id}
        </if>
        <if test="business_manager != null and business_manager != '' and business_manager != 'undefined'">
            and g.business_manager = #{business_manager}
        </if>
        <if test="managerId != null and managerId != ''">
            and g.business_manager in (select business from business_manager where managerId = #{managerId})
        </if>
        <if test="createtime!=null and createtime!=''">
            and pt.total_time &gt;=str_to_date(#{createtime},'%Y-%m-%d')
        </if>
        <if test="endtime!=null and endtime!=''">
            and pt.total_time &lt;DATE_ADD(str_to_date(#{endtime},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
        <if test="createtime==null or createtime==''">
            and pt.total_time &gt;=sysdate()-2
        </if>
        <if test="sp_id != null and sp_id != ''">
            and pt.SP_ID = #{sp_id}
        </if>
        <if test="sp_name != null and sp_name != ''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="province_select != null and province_select != ''">
            and pt.province = #{province_select}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler like CONCAT('%', #{sp_saler}, '%')
        </if>
        <if test="salerList!=null and salerList.size()>0">
            and sp.sp_saler in
            <foreach collection="salerList" index="index"  item="item" open="(" separator="," close=")">
                '${item}'
            </foreach>
        </if>
        group by date_format(pt.total_time, '%Y-%m-%d'), g.id,g.CHANNEL_NAME,g.business_manager
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            , pt.sp_id, sp.sp_name
        </if>
        <if test="byProvince != null and byProvince == &quot;1&quot;">
            , pt.province
        </if>
        order by date_format(pt.total_time, '%Y-%m-%d')
    </select>
    <select id="listPageMMSPaInfo" parameterType="PaInfo" resultMap="PaInfoResultMap">
        select
        g.id p_id,
        g.CHANNEL_NAME pa_dec,
        sum(pt.submit_count) submit_count,
        sum(pt.submitresp_succ) submitresp_succ,
        sum(pt.submitresp_fail) submitresp_fail,
        sum(pt.timeout_count) timeout_count,
        sum(pt.report_count) report_count,
        sum(pt.report_succ) report_succ,
        sum(pt.report_fail) report_fail,
        date_format(pt.total_time,'%Y-%m-%d') createtime,
        sum(pt.submit_count)-sum(pt.report_count) unRecMsgnum,
        <if test="bySpId != null and bySpId == &quot;1&quot;">
             pt.sp_id, sp.sp_name,
        </if>
        <if test="byProvince != null and byProvince == &quot;1&quot;">
             pt.province,
        </if>
        g.business_manager
        from pa_day_count pt, mms_send_channel_info g, sms_sp_info sp
       where pt.channelid = g.id and pt.sp_id = sp.id and pt.channelid>0

        <if test="pa_desc!=null and pa_desc!=''">
            and g.CHANNEL_NAME like CONCAT('%',#{pa_desc},'%')
        </if>

         <if test="p_id!=null and p_id>=0">
            and g.id =#{p_id}
        </if>
        <if test="business_manager != null and business_manager != '' and business_manager != 'undefined'">
            and g.business_manager = #{business_manager}
        </if>
        <if test="managerId != null and managerId != ''">
            and g.business_manager in (select business from business_manager where managerId = #{managerId})
        </if>
        <if test="createtime!=null and createtime!=''">
            and pt.total_time &gt;=str_to_date(#{createtime},'%Y-%m-%d')
        </if>
        <if test="endtime!=null and endtime!=''">
            and pt.total_time &lt;DATE_ADD(str_to_date(#{endtime},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
        <if test="createtime==null or createtime==''">
            and pt.total_time &gt;=sysdate()-2
        </if>
        <if test="sp_id != null and sp_id != ''">
            and pt.SP_ID = #{sp_id}
        </if>
        <if test="sp_name != null and sp_name != ''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="province_select != null and province_select != ''">
            and pt.province = #{province_select}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler like CONCAT('%', #{sp_saler}, '%')
        </if>
        <if test="salerList!=null and salerList.size()>0">
            and sp.sp_saler in
            <foreach collection="salerList" index="index"  item="item" open="(" separator="," close=")">
                '${item}'
            </foreach>
        </if>
        group by date_format(pt.total_time, '%Y-%m-%d'), g.id,g.CHANNEL_NAME,g.business_manager
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            , pt.sp_id, sp.sp_name
        </if>
        <if test="byProvince != null and byProvince == &quot;1&quot;">
            , pt.province
        </if>
        order by date_format(pt.total_time, '%Y-%m-%d')
    </select>

    <!--   sum(pt.resendsubmit_succ) resendsubmit_succ,
        sum(pt.resendsubmit_fail) resendsubmit_fail,
        sum(pt.resendarrive_succ) resendarrive_succ,
        sum(pt.resendarrive_fail) resendarrive_fail,
        sum(pt.beresendsubmit_succ) beresendsubmit_succ,
        sum(pt.beresendsubmit_fail) beresendsubmit_fail,
        sum(pt.beresendarrive_succ) beresendarrive_succ,
        sum(pt.beresendarrive_fail) beresendarrive_fail -->
    <select id="listPagePaMonthList" parameterType="PaInfo"
        resultMap="PaInfoResultMap">
        select
        g.id p_id,
        g.CHANNEL_NAME pa_dec,
        date_format(pt.total_time, '%Y-%m') month,
        sum(pt.submit_count) submit_count,
        sum(pt.submitresp_succ) submitresp_succ,
        sum(pt.submitresp_fail) submitresp_fail,
        sum(pt.timeout_count) timeout_count ,
        sum(pt.report_count) report_count ,
        sum(pt.report_succ) report_succ,
        sum(pt.report_fail) report_fail,
        sum(pt.submit_count)-sum(pt.report_count) unRecMsgnum,
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            pt.sp_id, sp.sp_name,
        </if>
        <if test="byotype != null and byotype == &quot;1&quot;">
            pt.otype,
        </if>
        g.business_manager
        from pa_day_count pt, sms_send_channel_info g, sms_sp_info sp
      where pt.channelid = g.id and pt.sp_id = sp.id
        <if test="p_id!=null and p_id>=0">
            and g.id =#{p_id}
        </if>
        <if test="pa_desc!=null and pa_desc!=''">
            and g.CHANNEL_NAME like CONCAT('%',#{pa_desc},'%')
        </if>
        <if test="managerId != null and managerId != ''">
            and g.business_manager in (select business from business_manager where managerId = #{managerId})
        </if>
        <if test="business_manager != null and business_manager != ''">
            and g.business_manager = #{business_manager}
        </if>
        <if test="month!=null and month!=''">
            and date_format(pt.total_time,'%Y-%m')=#{month}
        </if>
        <if test="sp_id != null and sp_id != ''">
            and pt.SP_ID = #{sp_id}
        </if>
        <if test="otype!=null and otype!=''">
            and pt.otype = #{otype}
        </if>
        <if test="sp_name != null and sp_name != ''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler like CONCAT('%', #{sp_saler}, '%')
        </if>
        <if test="salerList!=null and salerList.size()>0">
            and sp.sp_saler in
            <foreach collection="salerList" index="index"  item="item" open="(" separator="," close=")">
                '${item}'
            </foreach>
        </if>
        group by date_format(pt.total_time, '%Y-%m'), g.id, g.CHANNEL_NAME,g.business_manager
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            , pt.sp_id, sp.sp_name
        </if>
        <if test="byotype!=null and byotype == &quot;1&quot;">
            , pt.otype
        </if>
        order by sum(pt.submitresp_succ) desc
    </select>

     <select id="listPageMMSPaMonthList" parameterType="PaInfo"
        resultMap="PaInfoResultMap">
        select
        g.id p_id,
        g.CHANNEL_NAME pa_dec,
        date_format(pt.total_time, '%Y-%m') month,
        sum(pt.submit_count) submit_count,
        sum(pt.submitresp_succ) submitresp_succ,
        sum(pt.submitresp_fail) submitresp_fail,
        sum(pt.timeout_count) timeout_count ,
        sum(pt.report_count) report_count ,
        sum(pt.report_succ) report_succ,
        sum(pt.report_fail) report_fail,
        sum(pt.submit_count)-sum(pt.report_count) unRecMsgnum,
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            pt.sp_id, sp.sp_name,
        </if>
        g.business_manager
        from pa_day_count pt, mms_send_channel_info g, sms_sp_info sp
      where pt.channelid = g.id and pt.sp_id = sp.id and pt.channelid>0
        <if test="p_id!=null and p_id>=0">
            and g.id =#{p_id}
        </if>
        <if test="pa_desc!=null and pa_desc!=''">
            and g.CHANNEL_NAME like CONCAT('%',#{pa_desc},'%')
        </if>
        <if test="managerId != null and managerId != ''">
            and g.business_manager in (select business from business_manager where managerId = #{managerId})
        </if>
        <if test="business_manager != null and business_manager != ''">
            and g.business_manager = #{business_manager}
        </if>
        <if test="month!=null and month!=''">
            and date_format(pt.total_time,'%Y-%m')=#{month}
        </if>
        <if test="sp_id != null and sp_id != ''">
            and pt.SP_ID = #{sp_id}
        </if>
        <if test="sp_name != null and sp_name != ''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler like CONCAT('%', #{sp_saler}, '%')
        </if>
        <if test="salerList!=null and salerList.size()>0">
            and sp.sp_saler in
            <foreach collection="salerList" index="index"  item="item" open="(" separator="," close=")">
                '${item}'
            </foreach>
        </if>
        group by date_format(pt.total_time, '%Y-%m'), g.id, g.CHANNEL_NAME,g.business_manager
        <if test="bySpId != null and bySpId == &quot;1&quot;">
            , pt.sp_id, sp.sp_name
        </if>
        order by sum(pt.submitresp_succ) desc
    </select>

    <select id="listPagePaPropertyMan" parameterType="PaInfo"
        resultMap="PaPropertyMap">
        select p.p_id, p.pa_name, p.pa_dec, p.costprice, p.status from
        pa_config p
        <where>
            <if test="pa_desc!=null and pa_desc!=''">
                p.pa_dec  like CONCAT('%',#{pa_desc},'%')
            </if>
            <if test="status!=null">
                and p.status =#{status}
            </if>
        </where>
        order by p.pa_dec
    </select>

    <select id="getPaPropertyById" parameterType="PaInfo" resultMap="PaPropertyMap">
        select p.p_id, p.pa_name, p.pa_dec, p.costprice, p.status from
        pa_config p
        <where>
            <if test="p_id!=null">
                p.p_id =#{p_id}
            </if>
        </where>
    </select>

    <select id="listPagePaMinuteInfo" parameterType="PaInfo"
        resultMap="PaMinuteResultMap">
        select pt.id,
       g.CHANNEL_NAME pa_dec,
        pt.submit_count,
        pt.submitresp_succ,
        pt.submitresp_fail,
        pt.timeout_count,
        pt.report_count,
        pt.report_succ,
        pt.report_fail,
        pt.createtime time
        from pa_minute_count pt, sms_send_channel_info g
         where pt.channelid = g.id

        <if test="pa_desc!=null and pa_desc!=''">
            and g.CHANNEL_NAME  like CONCAT('%',#{pa_desc},'%')
        </if>
        <if test="createtime!=null and createtime!=''">
            and pt.createtime &gt;=  #{createtime}
        </if>
        <if test="endtime!=null and endtime!=''">
            and pt.createtime &lt;= #{endtime}
        </if>
        <if test="createtime==null or createtime==''">
            and pt.createtime &gt;=sysdate()- 500
        </if>
        order by pt.createtime desc
    </select>

    <update id="updatePaStatus" parameterType="PaInfo">
        update pa_config set
        status=#{status},modify_time=now() where p_id=#{p_id}
    </update>


    <update id="updatePaProty" parameterType="PaInfo">
        update pa_config set
        pa_name=#{pa_name,jdbcType=VARCHAR},
        pa_dec=#{pa_desc,jdbcType=VARCHAR},
        costprice=#{costprice}
        where
        p_id=#{p_id}
    </update>

    <insert id="insertPaProty"  useGeneratedKeys="true" keyProperty="p_id" parameterType="PaInfo">
        insert into pa_config
        (pa_name,pa_dec,costprice) values
        (#{pa_name},#{pa_desc,jdbcType=VARCHAR},#{costprice})
    </insert>

    <select id="listPagePaConfig" parameterType="PaConfig" resultType="PaConfig">
        select a.id,a.is_support_international, a.is_support_unicom,a.is_support_telecom,a.is_support_mobile,p.carrier, a.channel_name name,a.unicom_prefix,a.mobile_prefix,a.telecom_prefix,p.loginname, p.password, a.mobile_prefix accessnumber, p.ip, p.port,
               p.service_id, p.carrier_sp_id, p.fee_type, p.fee_code, p.price,p.version, p.carrier_speed,
               p.socket_conn, p.src_note_id, p.local_listen_port, p.carrier_sp_sign, p.signflag, a.pa_url,a.status,a.protocol_type,a.batchsize,a.template_id,a.template_parameter,a.attract_limit as attractLimit,a.link_properties as linkProperties,a.sign_template_limit as signTemplateLimit,a.sign_channel_enable as signChannelEnable
									from sms_send_channel_info a left JOIN sms_carrier_channel_info p ON a.id = p.id
        	where 1=1
            <if test="name != null">
                and a.channel_name like CONCAT('%',#{name},'%')
            </if>
            <if test="id != null">
                and a.id = #{id}
            </if>
            <if test="status != null and status != -1">
                and a.status = #{status}
            </if>
            <if test="linkProperties != null and linkProperties != ''">
                and a.link_properties = #{linkProperties}
            </if>

            <if test="ip != null">
                and p.ip like CONCAT('%',#{ip},'%')
            </if>
            <if test="loginname != null">
                and p.loginname like CONCAT('%',#{loginname},'%')
            </if>

        order by a.id desc
    </select>

    <select id="getPaConfigId" parameterType="PaConfig" resultType="PaConfig">
        select a.* from ((select id,channel_name as name,status from sms_send_channel_info WHERE  protocol_type &lt; 20 order by id desc) UNION ALL (select id,channel_name as name,status from mms_send_channel_info WHERE id > 0 order by id desc)) a  where 1=1
        <if test="name != null">
            and a.name like CONCAT('%',#{name},'%')
        </if>
        <if test="id != null">
            and a.id = #{id}
        </if>
    </select>

      <select id="listPaConfig" parameterType="PaConfig" resultType="PaConfig">
        select a.id, a.is_support_international,a.is_support_unicom,a.is_support_telecom,a.is_support_mobile,p.carrier, a.channel_name name,a.unicom_prefix,a.mobile_prefix,a.telecom_prefix,p.loginname, p.password, a.mobile_prefix accessnumber, p.ip, p.port,
               p.service_id, p.carrier_sp_id, p.fee_type, p.fee_code, p.price,p.version, p.carrier_speed,
               p.socket_conn, p.src_note_id, p.local_listen_port, p.carrier_sp_sign, p.signflag, a.pa_url,a.status,a.protocol_type,a.batchsize,a.template_id,a.template_parameter,a.connect_status,a.cooperate_company as cooperateCompany,a.attract_limit as attractLimit,a.link_properties as linkProperties,a.sign_template_limit as signTemplateLimit,a.sign_channel_enable as signChannelEnable
          from sms_send_channel_info a left JOIN sms_carrier_channel_info p ON a.id = p.id
									where 1=1
              <if test="mms == null">
                  and a.protocol_type &lt; 20
              </if>
            <if test="name != null">
                and a.channel_name like CONCAT('%',#{name},'%')
            </if>
            <if test="status != null and status != -1">
                and a.status = #{status}
            </if>

            <if test="ip != null">
                and p.ip like CONCAT('%',#{ip},'%')
            </if>
            <if test="loginname != null">
                and p.loginname like CONCAT('%',#{loginname},'%')
            </if>

            <if test="is_support_mobile !=null and is_support_mobile !=''">
            	and a.is_support_mobile=#{is_support_mobile}
            </if>
            <if test="is_support_unicom !=null and is_support_unicom !=''">
            	and a.is_support_unicom=#{is_support_unicom}
            </if>
            <if test="is_support_telecom !=null and is_support_telecom !=''">
            	and a.is_support_telecom=#{is_support_telecom}
            </if>
          <if test="managerId != null and managerId != ''">
              and a.business_manager in (select ifnull(business,0) from business_manager where managerId =  #{managerId}) and a.business_manager != ''
          </if>
          <if test="businessManager != null and businessManager != ''">
              and a.business_manager = #{businessManager}
          </if>
        order by a.id desc
    </select>
    <select id="queryChannelList" resultType="PaConfig" parameterType="PaConfig">
        select a.id, a.is_support_international,a.is_support_unicom,a.is_support_telecom,a.is_support_mobile,p.carrier, a.channel_name name,a.unicom_prefix,a.mobile_prefix,a.telecom_prefix,p.loginname, p.password, a.mobile_prefix accessnumber, p.ip, p.port,
        p.service_id, p.carrier_sp_id, p.fee_type, p.fee_code, p.price,p.version, p.carrier_speed,
        p.socket_conn, p.src_note_id, p.local_listen_port, p.carrier_sp_sign, p.signflag, a.pa_url,a.status,a.protocol_type,a.batchsize,a.template_id,a.template_parameter,a.connect_status,a.attract_limit as attractLimit,a.link_properties as linkProperties,a.sign_template_limit as signTemplateLimit,a.sign_channel_enable as signChannelEnable
        from sms_send_channel_info a left JOIN sms_carrier_channel_info p ON a.id = p.id
        <where>
            a.protocol_type is not null
            <if test="status != null and status != -1">
                and a.status = #{status}
            </if>
        </where>
        order by a.id desc
    </select>

     <select id="listPagePaConfigNoHttp" parameterType="PaConfig" resultType="PaConfig">
        select distinct a.id,a.is_support_international, a.is_support_unicom,a.is_support_telecom,a.is_support_mobile,p.carrier, a.channel_name name,a.unicom_prefix,a.mobile_prefix,a.telecom_prefix,p.loginname, p.password, a.mobile_prefix accessnumber, p.ip, p.port,
               p.service_id, p.carrier_sp_id, p.fee_type, p.fee_code, a.price,p.version, p.carrier_speed,
               p.socket_conn,p.conn_speed ,p.src_note_id, p.local_listen_port, p.carrier_sp_sign, a.pa_url,a.status,a.desc,
               a.protocol_type,a.batchsize,a.template_id,a.template_parameter,a.connect_status,a.business_manager businessManager,su.NAME as businessName, DATE_FORMAT(a.update_time,'%Y-%m-%d %H:%i:%s') as updateTime,a.attract_limit as attractLimit,a.link_properties as linkProperties
			from sms_send_channel_info a left join business_manager bm on bm.business = a.business_manager
            left JOIN sms_carrier_channel_info p ON a.id = p.id
            left join sms_user_info su on su.USER_NAME = a.business_manager
			where 1=1 and a.protocol_type != 4
            <if test="name != null">
                and a.channel_name like CONCAT('%', #{name}, '%')
            </if>
             <if test="id != null">
                and a.id = #{id}
            </if>
            <if test="status != null and status != -1">
                and a.status = #{status}
            </if>
            <if test="protocol_type != null and protocol_type != ''">
                and a.protocol_type = #{protocol_type}
            </if>
            <if test="businessManager != null and businessManager != '' and businessManager != 'undefined'">
                and a.business_manager = #{businessManager}
            </if>
            <if test="managerId != null and managerId != ''">
                and bm.managerId = #{managerId}
            </if>
         <if test="is_support_international != null and is_support_international != ''">
             and a.is_support_international = #{is_support_international}
         </if>

         <if test="ip != null">
             and p.ip like CONCAT('%',#{ip},'%')
            </if>
            <if test="loginname != null">
                and p.loginname like CONCAT('%',#{loginname},'%')
            </if>
            <if test="linkProperties != null and linkProperties != ''">
                and a.link_properties = #{linkProperties}
            </if>

         <if test="sort == 'asc'">
             <if test="col == 'price'">
                 order by a.price asc
             </if>
         </if>
         <if test="sort == 'desc'">
             <if test="col == 'price'">
                 order by a.price desc
             </if>
         </if>
         <if test="sort == null or sort == ''">
             order by a.id desc
         </if>

    </select>

     <select id="listChannelTemplate"  resultType="ChannelTemplate">
        select a.id,a.name,a.parametervalue,a.descp from sms_channel_template a
    </select>

    <select id="getPaConfigById" parameterType="PaConfig" resultType="PaConfig">
        select a.id,a.is_support_international, a.is_support_unicom,a.is_support_telecom,a.is_support_mobile, p.carrier, a.channel_name name, p.loginname, p.password, a.mobile_prefix accessnumber, p.ip, p.port,
               p.service_id, p.carrier_sp_id, p.fee_type, p.fee_code, a.price,p.version, p.carrier_speed,a.inter_price_group interPriceGroup,
               p.socket_conn, p.src_note_id, p.local_listen_port, p.carrier_sp_sign, p.signflag, a.status,a.query_time as queryTime,
               a.ping_time as pingTime , a.auto_change as autoChange,a.pa_url,a.protocol_type,a.batchsize,a.template_id,a.template_parameter,a.access_key,a.http_response,a.spid
               ,a.max_expand,a.is_only_expand,p.fee_terminal_id,p.fee_usertype,p.conn_speed,p.overspeed_resend,a.server_id,a.business_manager businessManager,a.cooperate_company cooperateCompany,a.province,a.provinceNetPrice,a.`desc`,a.autoExtend,a.supplier_id,
               cs.supplier_name,a.pro_group_price_id,a.mmsContentFormat,a.access_province,a.access_city,a.access_company,p.windowSize,p.windowSizeFlag,a.sign_port,a.use_extend_type as useExtendType,a.attract_limit as attractLimit,a.link_properties as linkProperties,a.auto_test_phone as autoTestPhone,a.sign_template_limit as signTemplateLimit,a.sign_channel_enable as signChannelEnable,a.inter_mdn_0
        from sms_send_channel_info a left JOIN sms_carrier_channel_info p ON a.id = p.id left join channel_supplier cs on cs.id=a.supplier_id
        <where>
            <if test="id != null">
                a.id = #{id}
            </if>
        </where>
    </select>

     <select id="getPaConfigByIPUserName" parameterType="PaConfig" resultType="Integer">
        select count(1)
        from sms_send_channel_info a left JOIN sms_carrier_channel_info p ON a.id = p.id
        <where>
        1=1
            <if test="ip != null">
                and p.ip = #{ip}
            </if>
            <if test="loginname != null">
               and p.loginname = #{loginname}
            </if>
            <if test="port != null">
               and p.port = #{port}
            </if>
        </where>
    </select>

    <update id="updatePaConfigStatus" parameterType="PaConfig">
        update sms_send_channel_info
        set status = #{status} ,modify_time = now()
        where id = #{id}
    </update>

    <update id="updatePaConfigIp" parameterType="PaConfig">
        update sms_carrier_channel_info
        set ip = #{ip}
        where id = #{id}
    </update>

    <update id="updatePaChangeIp" parameterType="PaConfig">
        update sms_send_channel_info
        <set>
            query_time = #{queryTime},
            ping_time = #{pingTime},
            auto_change = #{autoChange}
        </set>
        where id = #{id}
    </update>

	<update id="updatePaConfig" parameterType="PaConfig">
		update sms_carrier_channel_info
		<set>
			conn_speed = #{conn_speed, jdbcType=INTEGER},
            <if test = "protocol_type != null">
                carrier = #{protocol_type, jdbcType=INTEGER},
            </if>
            <if test = "name != null">
                name = #{name, jdbcType=VARCHAR},
            </if>
            <if test = "loginname != null">
                loginname = #{loginname, jdbcType=VARCHAR},
            </if>
            <if test = "password != null">
                password = #{password, jdbcType=VARCHAR},
            </if>
            <if test = "accessnumber != null">
                accessnumber = #{accessnumber, jdbcType=VARCHAR},
            </if>
            <if test = "ip != null">
                ip = #{ip, jdbcType=VARCHAR},
            </if>
            <if test = "port != null">
                port = #{port, jdbcType=VARCHAR},
            </if>
            <if test = "service_id != null">
                service_id = #{service_id, jdbcType=VARCHAR},
            </if>
            <if test = "carrier_sp_id != null">
                carrier_sp_id = #{carrier_sp_id, jdbcType=VARCHAR},
            </if>

            <if test = "fee_type != null">
                fee_type = #{fee_type, jdbcType=VARCHAR},
            </if>
            <if test = "fee_code != null">
                fee_code = #{fee_code, jdbcType=VARCHAR},
            </if>
            <if test = "price != null">
                price = #{price, jdbcType=DOUBLE},
            </if>
            <if test = "version != null">
                version = #{version, jdbcType=VARCHAR},
            </if>
            <if test = "carrier_speed != null">
                carrier_speed = #{carrier_speed, jdbcType=VARCHAR},
            </if>
            <if test = "socket_conn != null">
                socket_conn = #{socket_conn, jdbcType=INTEGER},
            </if>
            <if test = "src_note_id != null">
                src_note_id = #{src_note_id, jdbcType=VARCHAR},
            </if>
            <if test = "local_listen_port != null">
                local_listen_port = #{local_listen_port, jdbcType=VARCHAR},
            </if>
            <if test = "carrier_sp_sign != null">
                carrier_sp_sign = #{carrier_sp_sign, jdbcType=VARCHAR},
            </if>
            <if test = "status != null">
                status = #{status, jdbcType=INTEGER},
            </if>
            <if test = "signflag != null">
                signflag = #{signflag, jdbcType=INTEGER},
            </if>
            <if test = "fee_terminal_id != null">
                fee_terminal_id = #{fee_terminal_id, jdbcType=VARCHAR},
            </if>
            <if test = "fee_usertype != null">
                fee_usertype = #{fee_usertype, jdbcType=INTEGER},
            </if>
            <if test = "fee_usertype == null">
                fee_usertype = null,
            </if>

            <if test = "overspeed_resend != null">
                overspeed_resend = #{overspeed_resend, jdbcType=INTEGER},
            </if>
            <if test = "windowSize != null">
                windowSize = #{windowSize, jdbcType=INTEGER},
            </if>
            <if test = "windowSizeFlag != null">
                windowSizeFlag = #{windowSizeFlag, jdbcType=VARCHAR},
            </if>
		</set>
		where 1=1
		<if test="id != null">
			and id = #{id, jdbcType=INTEGER}
		</if>
    </update>

	<insert id="insertPaConfig" useGeneratedKeys="true" keyProperty="id" parameterType="PaConfig">
		insert into sms_carrier_channel_info
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test = "id != null">
                id,
            </if>
			<if test = "protocol_type != null">
                carrier,
            </if>
            <if test = "name != null">
                name,
            </if>
            <if test = "loginname != null">
                loginname,
            </if>
            <if test = "password != null">
                password,
            </if>
            <if test = "accessnumber != null">
                accessnumber,
            </if>
            <if test = "ip != null">
                ip,
            </if>
            <if test = "port != null">
                port,
            </if>
            <if test = "service_id != null">
                service_id,
            </if>
            <if test = "carrier_sp_id != null">
                carrier_sp_id,
            </if>

            <if test = "fee_type != null">
                fee_type,
            </if>
            <if test = "fee_code != null">
                fee_code,
            </if>
            <if test = "price != null">
                price,
            </if>
            <if test = "version != null">
                version,
            </if>
            <if test = "carrier_speed != null">
                carrier_speed,
            </if>
            <if test = "socket_conn != null">
                socket_conn,
            </if>
            <if test = "src_note_id != null">
                src_note_id,
            </if>
            <if test = "local_listen_port != null">
                local_listen_port,
            </if>
            <if test = "carrier_sp_sign != null">
                carrier_sp_sign,
            </if>
            <if test = "status != null">
                status,
            </if>
            <if test = "signflag != null">
                signflag,
            </if>
            <if test = "fee_terminal_id != null">
                fee_terminal_id,
            </if>
            <if test = "fee_usertype != null">
                fee_usertype,
            </if>
            <if test = "conn_speed != null">
                conn_speed,
            </if>
            <if test = "overspeed_resend != null">
                overspeed_resend,
            </if>
            <if test = "windowSize != null">
                windowSize,
            </if>
            <if test = "windowSizeFlag != null">
                windowSizeFlag,
            </if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test = "id != null">
                #{id, jdbcType=INTEGER},
            </if>
			<if test = "protocol_type != null">
                #{protocol_type, jdbcType=INTEGER},
            </if>
            <if test = "name != null">
                #{name, jdbcType=VARCHAR},
            </if>
            <if test = "loginname != null">
                #{loginname, jdbcType=VARCHAR},
            </if>
            <if test = "password != null">
                #{password, jdbcType=VARCHAR},
            </if>
            <if test = "accessnumber != null">
                #{accessnumber, jdbcType=VARCHAR},
            </if>
            <if test = "ip != null">
                #{ip, jdbcType=VARCHAR},
            </if>
            <if test = "port != null">
                #{port, jdbcType=VARCHAR},
            </if>
            <if test = "service_id != null">
                #{service_id, jdbcType=VARCHAR},
            </if>
            <if test = "carrier_sp_id != null">
                #{carrier_sp_id, jdbcType=VARCHAR},
            </if>

            <if test = "fee_type != null">
                #{fee_type, jdbcType=VARCHAR},
            </if>
            <if test = "fee_code != null">
                #{fee_code, jdbcType=VARCHAR},
            </if>
            <if test = "price != null">
                #{price, jdbcType=DOUBLE},
            </if>
            <if test = "version != null">
                #{version, jdbcType=VARCHAR},
            </if>
            <if test = "carrier_speed != null">
                #{carrier_speed, jdbcType=VARCHAR},
            </if>
            <if test = "socket_conn != null">
                #{socket_conn, jdbcType=INTEGER},
            </if>
            <if test = "src_note_id != null">
                #{src_note_id, jdbcType=VARCHAR},
            </if>
            <if test = "local_listen_port != null">
                #{local_listen_port, jdbcType=VARCHAR},
            </if>
            <if test = "carrier_sp_sign != null">
                #{carrier_sp_sign, jdbcType=VARCHAR},
            </if>
            <if test = "status != null">
                #{status, jdbcType=INTEGER},
            </if>
             <if test = "signflag != null">
                #{signflag, jdbcType=INTEGER},
            </if>
            <if test = "fee_terminal_id != null">
                #{fee_terminal_id, jdbcType=VARCHAR},
            </if>
            <if test = "fee_usertype != null">
                #{fee_usertype, jdbcType=INTEGER},
            </if>
             <if test = "conn_speed != null">
                #{conn_speed, jdbcType=INTEGER},
            </if>
             <if test = "overspeed_resend != null">
                #{overspeed_resend, jdbcType=INTEGER},
            </if>
            <if test = "windowSize != null">
                #{windowSize, jdbcType=INTEGER},
            </if>
            <if test = "windowSizeFlag != null">
                #{windowSizeFlag, jdbcType=VARCHAR},
            </if>
		</trim>
    </insert>

    <select id="queryChannelBackupIp" parameterType="int" resultType="cn.roadm.bo.BackupIp">
         select id,pa_id as paId,backup_ip as backupIp,create_time as createTime,sort
          from sms_channel_backup_ip where pa_id = #{paId} order by sort
    </select>

    <delete id="deleteBackupIpById" parameterType="int">
         delete from sms_channel_backup_ip where id = #{id}
    </delete>

    <insert id="saveChannelBackupIp" parameterType="cn.roadm.bo.BackupIp">
       insert into sms_channel_backup_ip (pa_id,backup_ip,create_time,sort) values
       (#{paId,jdbcType=INTEGER},#{backupIp,jdbcType=VARCHAR},#{createTime},#{sort,jdbcType=INTEGER})
    </insert>

    <update id="updateBackIpById" parameterType="cn.roadm.bo.BackupIp">
        update sms_channel_backup_ip set backup_ip = #{backupIp} ,create_time = #{createTime}
        where id = #{id}
    </update>



	 <update id="updateChannelPaConfig" parameterType="PaConfig">
    	update sms_send_channel_info
		<set>
            <if test = "name != null">
                channel_name = #{name, jdbcType=VARCHAR},
            </if>

                is_support_unicom = #{is_support_unicom, jdbcType=VARCHAR},


                is_support_mobile = #{is_support_mobile, jdbcType=VARCHAR},


                is_support_telecom = #{is_support_telecom, jdbcType=VARCHAR},

                is_support_international = #{is_support_international, jdbcType=VARCHAR},
                pro_group_price_id=#{pro_group_price_id, jdbcType=INTEGER},
                attract_limit = #{attractLimit, jdbcType=INTEGER},
                link_properties = #{linkProperties, jdbcType=INTEGER},
                sign_template_limit = #{signTemplateLimit, jdbcType=INTEGER},
                sign_channel_enable = #{signChannelEnable, jdbcType=INTEGER},
                inter_mdn_0 = #{inter_mdn_0, jdbcType=INTEGER},
            <if test = "mobile_prefix != null">
                mobile_prefix = #{mobile_prefix, jdbcType=VARCHAR},
            </if>
            <if test = "unicom_prefix != null">
                unicom_prefix = #{unicom_prefix, jdbcType=VARCHAR},
            </if>
            <if test = "telecom_prefix != null">
                telecom_prefix = #{telecom_prefix, jdbcType=VARCHAR},
            </if>
            <if test = "is_mobile_extend != null">
                is_mobile_extend = #{is_mobile_extend, jdbcType=VARCHAR},
            </if>
            <if test = "is_unicom_extend != null">
                is_unicom_extend = #{is_unicom_extend, jdbcType=VARCHAR},
            </if>
            <if test = "is_telecom_extend != null">
                is_telecom_extend = #{is_telecom_extend, jdbcType=VARCHAR},
            </if>
            <if test = "ch_desc != null">
                ch_desc = #{ch_desc, jdbcType=VARCHAR},
            </if>
            <if test = "iscollect != null">
                iscollect = #{iscollect, jdbcType=DOUBLE},
            </if>

            <if test = "status != null">
                status = #{status, jdbcType=INTEGER},
            </if>
            <if test = "protocol_type != null">
                protocol_type = #{protocol_type, jdbcType=INTEGER},
            </if>
             <if test = "access_key != null">
                access_key= #{access_key, jdbcType=VARCHAR},
            </if>
            <if test = "batchsize != null">
                batchsize = #{batchsize, jdbcType=INTEGER},
            </if>
            <if test = "http_response != null">
                http_response= #{http_response, jdbcType=VARCHAR},
            </if>
            <if test = "spid != null">
                spid= #{spid, jdbcType=VARCHAR},
            </if>
            <if test = "max_expand != null">
                max_expand = #{max_expand, jdbcType=VARCHAR},
            </if>
            <if test = "is_only_expand != null">
                is_only_expand = #{is_only_expand, jdbcType=INTEGER},
            </if>
            <if test = "server_id != null">
                server_id = #{server_id, jdbcType=INTEGER},
            </if>
            <if test="businessManager != null and businessManager != ''">
                business_manager=#{businessManager, jdbcType=VARCHAR},
            </if>
            <if test = "mmsContentFormat != null and mmsContentFormat != ''">
                mmsContentFormat=#{mmsContentFormat, jdbcType=VARCHAR},
            </if>
            <if test = "supplier_id != null and supplier_id != ''">
                supplier_id=#{supplier_id},
            </if>
            <if test = "price != null and price != ''">
                price=#{price},
            </if>
            <if test = "interPriceGroup != null and interPriceGroup != ''">
                inter_price_group=#{interPriceGroup},
            </if>
            <if test = "cooperateCompany != null and cooperateCompany!=''">
                cooperate_company = #{cooperateCompany, jdbcType=VARCHAR},
            </if>
            modify_time =sysdate(),
		</set>
		where 1=1
		<if test="id != null">
			and id = #{id, jdbcType=BIGINT}
		</if>
    </update>

   <update id="updateMmsChannelPaConfig" parameterType="PaConfig">
    	update mms_send_channel_info
		<set>
            <if test = "name != null">
                channel_name = #{name, jdbcType=VARCHAR},
            </if>
				price=#{price, jdbcType=VARCHAR},
                is_support_unicom = #{is_support_unicom, jdbcType=VARCHAR},


                is_support_mobile = #{is_support_mobile, jdbcType=VARCHAR},


                is_support_telecom = #{is_support_telecom, jdbcType=VARCHAR},

                <!-- is_support_international = #{is_support_international, jdbcType=VARCHAR}, -->

            <if test = "mobile_prefix != null">
                mobile_prefix = #{mobile_prefix, jdbcType=VARCHAR},
            </if>
            <if test = "unicom_prefix != null">
                unicom_prefix = #{unicom_prefix, jdbcType=VARCHAR},
            </if>
            <if test = "telecom_prefix != null">
                telecom_prefix = #{telecom_prefix, jdbcType=VARCHAR},
            </if>
            <if test = "is_mobile_extend != null">
                is_mobile_extend = #{is_mobile_extend, jdbcType=VARCHAR},
            </if>
            <if test = "is_unicom_extend != null">
                is_unicom_extend = #{is_unicom_extend, jdbcType=VARCHAR},
            </if>
            <if test = "is_telecom_extend != null">
                is_telecom_extend = #{is_telecom_extend, jdbcType=VARCHAR},
            </if>
            <if test = "ch_desc != null">
                ch_desc = #{ch_desc, jdbcType=VARCHAR},
            </if>
            <if test = "iscollect != null">
                iscollect = #{iscollect, jdbcType=DOUBLE},
            </if>

            <if test = "pa_url != null">
                pa_url = #{pa_url, jdbcType=VARCHAR},
            </if>
            <if test = "status != null">
                status = #{status, jdbcType=INTEGER},
            </if>
            <if test = "protocol_type != null">
                protocol_type = #{protocol_type, jdbcType=INTEGER},
            </if>
             <if test = "access_key != null">
                access_key= #{access_key, jdbcType=VARCHAR},
            </if>
            <if test = "batchsize != null">
                batchsize = #{batchsize, jdbcType=INTEGER},
            </if>
            <if test = "http_response != null">
                http_response= #{http_response, jdbcType=VARCHAR},
            </if>
            <if test = "accessnumber != null">
                accessnumber= #{accessnumber, jdbcType=VARCHAR},
            </if>
            <if test="desc!=null and desc!=''">
            	`desc`=#{desc,jdbcType=VARCHAR},
            </if>
            <if test = "cooperateCompany != null and cooperateCompany!=''">
                cooperate_company = #{cooperateCompany, jdbcType=VARCHAR},
            </if>
            <if test="supplier_id!=null">
                supplier_id=#{supplier_id, jdbcType=INTEGER},
            </if>
            <if test = "attractLimit != null">
                attract_limit = #{attractLimit, jdbcType=INTEGER},
            </if>
            <if test = "linkProperties != null">
                link_properties = #{linkProperties, jdbcType=INTEGER},
            </if>

          <!--   modify_time =sysdate(), -->
		</set>
		where 1=1
		<if test="id != null">
			and id = #{id, jdbcType=BIGINT}
		</if>
    </update>

	<!-- 插入pa配置，先插入到主表，取到id后，再插入到附表-->
	<insert id="insertChannelPaConfig" useGeneratedKeys="true" keyProperty="id" parameterType="PaConfig">
		insert into sms_send_channel_info
		<trim prefix="(" suffix=")" suffixOverrides=",">

            <if test = "name != null">
                channel_name,
            </if>
            <if test = "is_support_unicom != null">
                is_support_unicom,
            </if>
            <if test = "is_support_mobile != null">
                is_support_mobile,
            </if>
            <if test = "is_support_telecom != null">
                is_support_telecom,
            </if>
            <if test = "is_support_international != null">
                is_support_international,
            </if>
            <if test = "mobile_prefix != null">
                mobile_prefix,
            </if>
            <if test = "unicom_prefix != null">
                unicom_prefix,
            </if>
            <if test = "telecom_prefix != null">
                telecom_prefix,
            </if>
            <if test = "is_mobile_extend != null">
                is_mobile_extend,
            </if>
            <if test = "is_unicom_extend != null">
                is_unicom_extend,
            </if>
            <if test = "is_telecom_extend != null">
                is_telecom_extend,
            </if>
            <if test = "ch_desc != null">
                ch_desc,
            </if>
            <if test = "iscollect != null">
                iscollect,
            </if>

            <if test = "pa_url != null">
                pa_url,
            </if>
            <if test = "pm_id != null">
                pm_id,
            </if>
            <if test = "status != null">
                status,
            </if>
            <if test = "protocol_type != null">
                protocol_type,
            </if>
            <if test = "access_key != null">
                access_key,
            </if>
            <if test = "batchsize != null">
                batchsize,
            </if>
            <if test = "http_response != null">
                http_response,
            </if>
            <if test = "spid != null">
                spid,
            </if>
            <if test = "max_expand != null">
                max_expand ,
            </if>
             <if test = "is_only_expand != null">
                is_only_expand ,
            </if>
             <if test = "server_id != null">
                server_id ,
            </if>
             <if test = "businessManager != null and businessManager!=''">
                business_manager ,
            </if>
            <if test="interPriceGroup != null and interPriceGroup != -1">
            	inter_price_group,
            </if>
            <if test="price!=null and price!=''">
                price,
            </if>
            <if test="desc!=null and desc!=''">
            	`desc`,
            </if>
            <if test='province!="1"'>
            	province,
            </if>
            <if test="provinceNetPrice!=null and provinceNetPrice!=''">
            	provinceNetPrice,
            </if>
            <if test="supplier_id!=null and supplier_id!=''">
            	supplier_id,
            </if>
            <if test="pro_group_price_id!=null and pro_group_price_id!=''">
            	pro_group_price_id,
            </if>
            <if test = "mmsContentFormat != null">
                `mmsContentFormat`,
            </if>
            <if test = "cooperateCompany != null and cooperateCompany!=''">
                cooperate_company,
            </if>
            <if test = "attractLimit != null">
                attract_limit,
            </if>
            <if test = "linkProperties != null">
                link_properties,
            </if>
            <if test = "autoTestPhone != null">
                auto_test_phone,
            </if>
            <if test = "signTemplateLimit != null">
                sign_template_limit,
            </if>
            <if test = "signChannelEnable != null">
                sign_channel_enable,
            </if>
            <if test = "inter_mdn_0 != null">
                inter_mdn_0,
            </if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">

            <if test = "name != null">
                 #{name, jdbcType=VARCHAR},
            </if>
            <if test = "is_support_unicom != null">
                #{is_support_unicom, jdbcType=VARCHAR},
            </if>
            <if test = "is_support_mobile != null">
                #{is_support_mobile, jdbcType=VARCHAR},
            </if>
            <if test = "is_support_telecom != null">
                #{is_support_telecom, jdbcType=VARCHAR},
            </if>
            <if test = "is_support_international != null">
                #{is_support_international, jdbcType=VARCHAR},
            </if>
            <if test = "mobile_prefix != null">
                #{mobile_prefix, jdbcType=VARCHAR},
            </if>
            <if test = "unicom_prefix != null">
                #{unicom_prefix, jdbcType=VARCHAR},
            </if>
            <if test = "telecom_prefix != null">
                #{telecom_prefix, jdbcType=VARCHAR},
            </if>
            <if test = "is_mobile_extend != null">
                #{is_mobile_extend, jdbcType=VARCHAR},
            </if>
            <if test = "is_unicom_extend != null">
                #{is_unicom_extend, jdbcType=VARCHAR},
            </if>
            <if test = "is_telecom_extend != null">
                #{is_telecom_extend, jdbcType=VARCHAR},
            </if>
            <if test = "ch_desc != null">
                #{ch_desc, jdbcType=VARCHAR},
            </if>
            <if test = "iscollect != null">
                #{iscollect, jdbcType=VARCHAR},
            </if>

            <if test = "pa_url != null">
                #{pa_url, jdbcType=VARCHAR},
            </if>
            <if test = "pm_id != null">
                #{pm_id, jdbcType=INTEGER},
            </if>
            <if test = "status != null">
                #{status, jdbcType=INTEGER},
            </if>
            <if test = "protocol_type != null">
                #{protocol_type, jdbcType=INTEGER},
            </if>
            <if test = "access_key != null">
                #{access_key, jdbcType=VARCHAR},
            </if>
            <if test = "batchsize != null">
                #{batchsize, jdbcType=INTEGER},
            </if>
            <if test = "http_response != null">
                #{http_response, jdbcType=VARCHAR},
            </if>
             <if test = "spid != null">
                #{spid, jdbcType=VARCHAR},
            </if>
            <if test = "max_expand != null">
            	#{max_expand, jdbcType=VARCHAR},
            </if>
            <if test = "is_only_expand != null">
            	#{is_only_expand, jdbcType=VARCHAR},
            </if>

            <if test = "server_id != null">
            	#{server_id, jdbcType=INTEGER},
            </if>
            <if test = "businessManager != null and businessManager!=''">
                #{businessManager} ,
            </if>
             <if test="price!=null and price!=''">
            	#{price},
            </if>
            <if test="interPriceGroup != null and interPriceGroup != -1">
                #{interPriceGroup},
            </if>
            <if test="desc!=null and desc!=''">
            	#{desc},
            </if>
            <if test='province!="1"'>
            	#{province},
            </if>
            <if test="provinceNetPrice!=null and provinceNetPrice!=''">
            	#{provinceNetPrice},
            </if>
            <if test="supplier_id!=null and supplier_id!=''">
            	#{supplier_id},
            </if>
            <if test="pro_group_price_id!=null and pro_group_price_id!=''">
            	#{pro_group_price_id},
            </if>
            <if test = "mmsContentFormat != null">
                #{mmsContentFormat},
            </if>
            <if test = "cooperateCompany != null and cooperateCompany!=''">
                #{cooperateCompany},
            </if>
            <if test = "attractLimit != null">
                #{attractLimit},
            </if>
            <if test = "linkProperties != null">
                #{linkProperties},
            </if>
            <if test = "autoTestPhone != null">
                #{autoTestPhone},
            </if>
            <if test = "signTemplateLimit != null">
                #{signTemplateLimit},
            </if>
            <if test = "signChannelEnable != null">
                #{signChannelEnable},
            </if>
            <if test = "inter_mdn_0 != null">
                #{inter_mdn_0},
            </if>
		</trim>
	</insert>


	<!-- 插入pa配置，先插入到主表，取到id后，再插入到附表-->
	<insert id="insertMmsChannelPaConfig" useGeneratedKeys="true" keyProperty="id" parameterType="PaConfig">
		insert into mms_send_channel_info
		<trim prefix="(" suffix=")" suffixOverrides=",">
            <if test = "id != null">
                id,
            </if>
            <if test = "name != null">
                channel_name,
            </if>
            <if test = "is_support_unicom != null">
                is_support_unicom,
            </if>
            <if test = "is_support_mobile != null">
                is_support_mobile,
            </if>
            <if test = "is_support_telecom != null">
                is_support_telecom,
            </if>
            <if test = "is_support_international != null">
                is_support_international,
            </if>
            <if test = "mobile_prefix != null">
                mobile_prefix,
            </if>
            <if test = "unicom_prefix != null">
                unicom_prefix,
            </if>
            <if test = "telecom_prefix != null">
                telecom_prefix,
            </if>
            <if test = "is_mobile_extend != null">
                is_mobile_extend,
            </if>
            <if test = "is_unicom_extend != null">
                is_unicom_extend,
            </if>
            <if test = "is_telecom_extend != null">
                is_telecom_extend,
            </if>
            <if test = "ch_desc != null">
                ch_desc,
            </if>
            <if test = "iscollect != null">
                iscollect,
            </if>

            <if test = "pa_url != null">
                pa_url,
            </if>

            <if test = "status != null">
                status,
            </if>
            <if test = "protocol_type != null">
                protocol_type,
            </if>
            <if test = "access_key != null">
                access_key,
            </if>
            <if test = "batchsize != null">
                batchsize,
            </if>
            <if test = "http_response != null">
                http_response,
            </if>
           <if test = "accessnumber != null">
                accessnumber,
            </if>
            <if test = "desc != null">
                `desc`,
            </if>
            <if test = "price != null">
                `price`,
            </if>
            <if test = "cooperateCompany != null">
                cooperate_company,
            </if>
            <if test = "attractLimit != null">
                attract_limit,
            </if>
            <if test = "linkProperties != null">
                link_properties,
            </if>


		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test = "id != null">
                #{id},
            </if>
            <if test = "name != null">
                 #{name, jdbcType=VARCHAR},
            </if>
            <if test = "is_support_unicom != null">
                #{is_support_unicom, jdbcType=VARCHAR},
            </if>
            <if test = "is_support_mobile != null">
                #{is_support_mobile, jdbcType=VARCHAR},
            </if>
            <if test = "is_support_telecom != null">
                #{is_support_telecom, jdbcType=VARCHAR},
            </if>
            <if test = "is_support_international != null">
                #{is_support_international, jdbcType=VARCHAR},
            </if>
            <if test = "mobile_prefix != null">
                #{mobile_prefix, jdbcType=VARCHAR},
            </if>
            <if test = "unicom_prefix != null">
                #{unicom_prefix, jdbcType=VARCHAR},
            </if>
            <if test = "telecom_prefix != null">
                #{telecom_prefix, jdbcType=VARCHAR},
            </if>
            <if test = "is_mobile_extend != null">
                #{is_mobile_extend, jdbcType=VARCHAR},
            </if>
            <if test = "is_unicom_extend != null">
                #{is_unicom_extend, jdbcType=VARCHAR},
            </if>
            <if test = "is_telecom_extend != null">
                #{is_telecom_extend, jdbcType=VARCHAR},
            </if>
            <if test = "ch_desc != null">
                #{ch_desc, jdbcType=VARCHAR},
            </if>
            <if test = "iscollect != null">
                #{iscollect, jdbcType=VARCHAR},
            </if>

            <if test = "pa_url != null">
                #{pa_url, jdbcType=VARCHAR},
            </if>

            <if test = "status != null">
                #{status, jdbcType=INTEGER},
            </if>
            <if test = "protocol_type != null">
                #{protocol_type, jdbcType=INTEGER},
            </if>
            <if test = "access_key != null">
                #{access_key, jdbcType=VARCHAR},
            </if>
            <if test = "batchsize != null">
                #{batchsize, jdbcType=INTEGER},
            </if>
            <if test = "http_response != null">
                #{http_response, jdbcType=VARCHAR},
            </if>
           <if test = "accessnumber != null">
                #{accessnumber, jdbcType=VARCHAR},
            </if>
            <if test = "desc != null">
                #{desc, jdbcType=VARCHAR},
            </if>
            <if test = "price != null">
                #{price, jdbcType=VARCHAR},
            </if>
            <if test = "cooperateCompany != null">
                #{cooperateCompany, jdbcType=VARCHAR},
            </if>
            <if test = "attractLimit != null">
                #{attractLimit, jdbcType=INTEGER},
            </if>
            <if test = "linkProperties != null">
                #{linkProperties, jdbcType=INTEGER},
            </if>
		</trim>
	</insert>

	<update id="updateChannelPaConfigStatus" parameterType="PaConfig">
        update sms_send_channel_info
        set status = #{status},modify_time=now()
        where id = #{id}
    </update>

    <select id="OnepmUrl">
    	select value from sms_pc_config where configkey = #{key}
    </select>

<!--new -->

    <select id="listPagePaGroupConfig" parameterType="PaGroupConfig" resultType="PaGroupConfig">
        select * from sms_channel_group g
        <where>
                g.status = '1'
            <if test="network != null and network != ''">
                and g.network = #{network}
            </if>
            <if test="name != null and name!=''">
                and g.name like CONCAT('%', #{name}, '%')
            </if>
            <if test="channels!=null and channels!=''">
            	and CONCAT(',',channels, ',') like CONCAT('%,',#{channels}, ',%')
            </if>
        </where>
        order by g.id desc
    </select>

      <select id="listPaGroupConfig" parameterType="PaGroupConfig" resultType="PaGroupConfig">
        select * from sms_channel_group g
        <where>
                g.status = '1'
            <if test="network != null and network != ''">
                and g.network = #{network}
            </if>
            <if test="name != null and name!=''">
                and g.name like CONCAT('%', #{name}, '%')
            </if>
             <if test="channels!=null and channels!=''">
            	and CONCAT(',',channels, ',') like CONCAT('%,',#{channels}, ',%')
            </if>
        </where>
        order by g.id desc
    </select>

    <select id="getPaGroupConfig" parameterType="PaGroupConfig" resultType="PaGroupConfig">
        select * from sms_channel_group g
        <where>
            g.status = '1'
            <if test="network != null and network != ''">
                and g.network = #{network}
            </if>
            <if test="networks != null and networks != ''">
                and g.network in
                 <foreach collection="networks" item="item" open="(" close=")" separator=",">
                     #{item}
                 </foreach>
            </if>
            <if test="channels!=null and channels!=''">
                and find_in_set(#{channels},channels)
            </if>
        </where>
        order by g.id desc
    </select>

    <insert id="insertPaGroupConfig" useGeneratedKeys="true" keyProperty="id" parameterType="PaGroupConfig">
        insert into sms_channel_group
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test = "id != null">
                id,
            </if>
            <if test = "network != '' and network!=null">
                network,
            </if>
            <if test = "name != null and name!= ''">
                name,
            </if>
            <if test = "platform != null and platform != ''">
                platform,
            </if>
            <if test = "biz != null and biz != ''">
                biz,
            </if>
            <if test = "strategy != null and strategy != ''">
                strategy,
            </if>
            <if test = "channels != null and channels != ''">
                channels,
            </if>
             <if test = "weight != null and weight != ''">
                weight,
            </if>
            <if test = "overstocks != null and overstocks != ''">
                overstocks,
            </if>
             modifyTime,
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test = "id != null">
                #{id, jdbcType=INTEGER},
            </if>
            <if test = "network != null and network != ''">
                #{network, jdbcType=VARCHAR},
            </if>
            <if test = "name != null and name != ''">
                #{name, jdbcType=VARCHAR},
            </if>
            <if test = "platform != null and platform != ''">
                #{platform, jdbcType=VARCHAR},
            </if>
            <if test = "biz != null and biz != ''">
                #{biz, jdbcType=VARCHAR},
            </if>
            <if test = "strategy != null and strategy != ''">
                #{strategy, jdbcType=VARCHAR},
            </if>
            <if test = "channels != null and channels != ''">
                #{channels, jdbcType=VARCHAR},
            </if>
             <if test = "weight != null and weight != ''">
                #{weight, jdbcType=VARCHAR},
            </if>
            <if test = "overstocks != null and overstocks != ''">
                #{overstocks, jdbcType=VARCHAR},
            </if>
            sysdate(),
        </trim>
    </insert>

    <select id="getPaGroupConfigById" parameterType="int" resultType="PaGroupConfig">
        select * from sms_channel_group g where g.id = #{id}
    </select>

    <update id="updatePaGroupConfig" parameterType="PaGroupConfig">
        update sms_channel_group
        <set>
            <if test = "name != null and name != ''">
                name = #{name, jdbcType=VARCHAR},
            </if>
            <if test = "network != null and network != ''">
                network = #{network, jdbcType=VARCHAR},
            </if>
            <if test = "platform != null and platform != ''">
                platform = #{platform, jdbcType=VARCHAR},
            </if>
            <if test = "biz != null and biz != ''">
                biz = #{biz, jdbcType=VARCHAR},
            </if>
            <if test = "strategy != null and strategy != ''">
                strategy = #{strategy, jdbcType=VARCHAR},
            </if>
            <if test = "status != null and status != ''">
                status = #{status, jdbcType=INTEGER},
            </if>
            <if test = "channels != null and status != ''">
                channels = #{channels, jdbcType=VARCHAR},
            </if>
             <if test = "weight != null and weight != ''">
                weight = #{weight, jdbcType=VARCHAR},
            </if>
            overstocks = #{overstocks, jdbcType=VARCHAR},
            modifyTime = sysdate(),
        </set>
        where id = #{id, jdbcType=INTEGER}
    </update>

    <!--企业通道配置-->
    <insert id="insertSpChannelConfig" useGeneratedKeys="true" keyProperty="id" parameterType="SpChannelConfig">
    insert into sms_sp_channel_config
    <trim prefix="(" suffix=")" suffixOverrides=",">
        <if test = "network != '' and network!=null">
            network,
        </if>
        <if test = "type != '' and type!=null">
            type,
        </if>
        <if test = "spId != '' and spId!=null">
            spId,
        </if>
        <if test = "mobile != '' and mobile!=null">
            mobile,
        </if>
        <if test = "unicom != '' and unicom!=null">
            unicom,
        </if>
        <if test = "telecom != '' and telecom!=null">
            telecom,
        </if>
        <if test = "mobileGroup != '' and mobileGroup!=null">
            mobileGroup,
        </if>
        <if test = "unicomGroup != '' and unicomGroup!=null">
            unicomGroup,
        </if>
        <if test = "telecomGroup != '' and telecomGroup!=null">
            telecomGroup,
        </if>
        <if test = "internation != '' and internation">
            internation,
        </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
        <if test = "network != null and network != ''">
            #{network, network=VARCHAR},
        </if>
        <if test = "type != null and type != ''">
            #{type, type=VARCHAR},
        </if>
        <if test = "spId != null and spId != ''">
            #{spId, spId=VARCHAR},
        </if>
        <if test = "mobile != null and mobile != '' ">
            #{mobile, mobile=VARCHAR},
        </if>
        <if test = "unicom != null and unicom != '' " >
            #{unicom, unicom=VARCHAR},
        </if>
        <if test = "telecom != null and telecom != '' ">
            #{telecom, telecom=VARCHAR},
        </if>
        <if test = "mobileGroup != null and  mobileGroup != ''">
            #{mobileGroup, mobileGroup=VARCHAR},
        </if>
        <if test = "unicomGroup != null and unicomGroup != ''">
            #{unicomGroup, unicomGroup=VARCHAR},
        </if>
        <if test = "telecomGroup != null and telecomGroup != ''">
            #{telecomGroup, telecomGroup=VARCHAR},
        </if>
        <if test = "internation != null and internation != '' ">
            #{internation, internation=VARCHAR},
        </if>

    </trim>
</insert>

    <update id="updateSpChannelConfig" parameterType="SpChannelConfig">
        update sms_sp_channel_config
        <set>
            <if test = "network != null">
                network = #{network, network=VARCHAR},
            </if>
            <if test = "type != null">
                type = #{type, type=VARCHAR},
            </if>
            <if test = "spId != null">
                spId = #{spId, spId=VARCHAR},
            </if>
            <if test = "mobile != null">
                mobile = #{mobile, mobile=VARCHAR},
            </if>
            <if test = "unicom != null">
                unicom = #{unicom, unicom=VARCHAR},
            </if>
            <if test = "telecom != null">
                telecom = #{telecom, telecom=VARCHAR},
            </if>
            <if test = "mobileGroup != null">
                mobileGroup = #{mobileGroup, mobileGroup=VARCHAR},
            </if>
            <if test = "unicomGroup != null">
                unicomGroup = #{unicomGroup, unicomGroup=VARCHAR},
            </if>
            <if test = "telecomGroup != null">
                telecomGroup = #{telecomGroup, telecomGroup=VARCHAR},
            </if>
            <if test = "internation != null">
                internation = #{internation, telecomGroup=VARCHAR},
            </if>
        </set>
        where id = #{id, jdbcType=INTEGER}
    </update>

    <select id="getSpChannelConfigById" parameterType="int" resultType="SpChannelConfig">
        select * from sms_sp_channel_config g where g.spId = #{spId}
    </select>
    <delete id="deleteChannelGroupConfig" parameterType="int">
        delete from sms_sp_channel_config where spId = #{spId}
    </delete>
    <select id="getGroupPaByPa" parameterType="int" resultType="PaGroupConfig">
    	select channels from sms_channel_group where channels like CONCAT('%',#{paId},'%')
    </select>
     <select id="getSpChannelProvinceConfig" parameterType="SpChannelProvinceConfig" resultType="SpChannelProvinceConfig">
        select mobilechannel,unicomchannel,telecomchannel,province,spId,id from sms_channel_province_config
        <where>
            <if test = "spId != null and spId != ''">
                and spId = #{spId}
            </if>
            <if test = "province != null">
                and province=#{province}
            </if>
            <if test = "mobilechannel != null">
                and mobilechannel=#{mobilechannel}
            </if>
            <if test = "unicomchannel != null">
                and unicomchannel=#{unicomchannel}
            </if>
            <if test = "telecomchannel != null">
                and telecomchannel=#{telecomchannel}
            </if>
        </where>
    </select>

    <select id="getSpMmsChannelProvinceConfig" parameterType="SpMmsChannelProvinceConfig" resultType="SpMmsChannelProvinceConfig">
        select mobilechannel,unicomchannel,telecomchannel,province,spId,id from mms_channel_province_config
        <where>
            <if test = "spId != null and spId != ''">
                and spId = #{spId}
            </if>
            <if test = "province != null">
                and province=#{province}
            </if>
            <if test = "mobilechannel != null">
                and mobilechannel=#{mobilechannel}
            </if>
            <if test = "unicomchannel != null">
                and unicomchannel=#{unicomchannel}
            </if>
            <if test = "telecomchannel != null">
                and telecomchannel=#{telecomchannel}
            </if>
        </where>
    </select>

    <insert id="insertSpChannelProvinceConfig" useGeneratedKeys="true" keyProperty="id" parameterType="SpChannelProvinceConfig">
	    insert into sms_channel_province_config(mobilechannel,unicomchannel,telecomchannel,province,spId)
	    values( #{mobilechannel}, #{unicomchannel},#{telecomchannel},#{province},#{spId} )
    </insert>

    <insert id="insertSpMmsChannelProvinceConfig" useGeneratedKeys="true" keyProperty="id" parameterType="SpChannelProvinceConfig">
        insert into mms_channel_province_config(mobilechannel,unicomchannel,telecomchannel,province,spId)
        values( #{mobilechannel}, #{unicomchannel},#{telecomchannel},#{province},#{spId} )
    </insert>
    <update id="updateSpChannelProvinceConfig" parameterType="SpChannelProvinceConfig">
	    update  sms_channel_province_config
        <set>
            <if test = "mobilechannel != null">
                mobilechannel=#{mobilechannel},
            </if>
            <if test = "unicomchannel != null">
                unicomchannel=#{unicomchannel},
            </if>
            <if test = "telecomchannel != null">
                telecomchannel=#{telecomchannel},
            </if>
        </set>
	    where spId = #{spId} and province=#{province}
    </update>
    <delete id="deleteSpChannelProvinceConfig" parameterType="SpChannelProvinceConfig">
    	delete from sms_channel_province_config where id=#{id};
    </delete>

    <select id="listPageReportCodeMap" parameterType="ReportCodeMap" resultType="ReportCodeMap">
        select * from sms_report_code_map
        <where>
        	1=1
            <if test="spId != null and spId != ''">
                and spid = #{spId}
            </if>
            <if test="channelId != null and channelId != ''">
                and channelId = #{channelId}
            </if>
            <if test="sourceCode != null and sourceCode != ''">
                and sourceCode = #{sourceCode}
            </if>
            <if test="destCode != null and destCode != ''">
                and destCode = #{destCode}
            </if>
        </where>
        order by id desc
    </select>

    <insert id="insertReportCodeMap" useGeneratedKeys="true" keyProperty="id" parameterType="ReportCodeMap">
	    insert into sms_report_code_map(spid,channelid,sourcecode,destcode)
	    values( #{spId}, #{channelId},#{sourceCode},#{destCode} )
    </insert>
     <delete id="deleteReportCodeMap" parameterType="int">
        delete from sms_report_code_map where id = #{id}
    </delete>

    <!-- sum(pt.resendsubmit_succ) resendsubmit_succ,
        sum(pt.resendsubmit_fail) resendsubmit_fail,
        sum(pt.resendarrive_succ) resendarrive_succ,
        sum(pt.resendarrive_fail) resendarrive_fail,
        sum(pt.beresendsubmit_succ) beresendsubmit_succ,
        sum(pt.beresendsubmit_fail) beresendsubmit_fail,
        sum(pt.beresendarrive_succ) beresendarrive_succ,
        sum(pt.beresendarrive_fail) beresendarrive_fail -->
   <select id="getlistPaInfCount" parameterType="PaInfo" resultMap="PaInfoResultMap">
        select
   		sum(pt.submitresp_succ) submitresp_succ,
        sum(pt.submitresp_fail) submitresp_fail,
        sum(pt.report_succ) report_succ,
        sum(pt.submit_count)-sum(pt.report_count) unRecMsgnum,
        sum(pt.report_fail) report_fail
        from pa_day_count pt, sms_send_channel_info g, sms_sp_info sp
       where pt.channelid = g.id and pt.SP_ID = sp.id
        <if test="p_id!=null and p_id>=0">
            and g.id =#{p_id}
        </if>
        <if test="pa_desc!=null and pa_desc!=''">
            and g.CHANNEL_NAME like CONCAT('%',#{pa_desc},'%')
        </if>
       <if test="managerId != null and managerId != ''">
           and g.business_manager in (select ifnull(business,'') from business_manager where managerId = #{managerId}) and g.business_manager != ''
       </if>
       <if test="business_manager != null and business_manager != ''">
           and g.business_manager = #{business_manager}
       </if>
        <if test="createtime!=null and createtime!=''">
            and pt.total_time &gt;=str_to_date(#{createtime},'%Y-%m-%d')
        </if>
        <if test="endtime!=null and endtime!=''">
            and pt.total_time &lt;DATE_ADD(str_to_date(#{endtime},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
        <if test="createtime==null or createtime==''">
            and pt.total_time &gt;=sysdate()-2
        </if>
       <if test="sp_id != null and sp_id != ''">
           and pt.SP_ID = #{sp_id}
       </if>
       <if test="sp_name != null and sp_name != ''">
           and sp.sp_name like CONCAT('%', #{sp_name}, '%')
       </if>
       <if test="sp_saler!=null and sp_saler!=''">
           and sp.sp_saler like CONCAT('%', #{sp_saler}, '%')
       </if>
       <if test="province_select != null and province_select != ''">
            and pt.province = #{province_select}
        </if>
       <if test="salerList!=null and salerList.size()>0">
           and sp.sp_saler in
           <foreach collection="salerList" index="index"  item="item" open="(" separator="," close=")">
               '${item}'
           </foreach>
       </if>

    </select>
    <select id="getlistMMSPaInfCount" parameterType="PaInfo" resultMap="PaInfoResultMap">
        select
   		sum(pt.submitresp_succ) submitresp_succ,
        sum(pt.submitresp_fail) submitresp_fail,
        sum(pt.report_succ) report_succ,
        sum(pt.submit_count)-sum(pt.report_count) unRecMsgnum,
        sum(pt.report_fail) report_fail
        from pa_day_count pt, mms_send_channel_info g, sms_sp_info sp
       where pt.channelid = g.id and pt.SP_ID = sp.id and pt.channelid>0
        <if test="p_id!=null and p_id>=0">
            and g.id =#{p_id}
        </if>
        <if test="pa_desc!=null and pa_desc!=''">
            and g.CHANNEL_NAME like CONCAT('%',#{pa_desc},'%')
        </if>
       <if test="managerId != null and managerId != ''">
           and g.business_manager in (select ifnull(business,'') from business_manager where managerId = #{managerId}) and g.business_manager != ''
       </if>
       <if test="business_manager != null and business_manager != ''">
           and g.business_manager = #{business_manager}
       </if>
        <if test="createtime!=null and createtime!=''">
            and pt.total_time &gt;=str_to_date(#{createtime},'%Y-%m-%d')
        </if>
        <if test="endtime!=null and endtime!=''">
            and pt.total_time &lt;DATE_ADD(str_to_date(#{endtime},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
        <if test="createtime==null or createtime==''">
            and pt.total_time &gt;=sysdate()-2
        </if>
       <if test="sp_id != null and sp_id != ''">
           and pt.SP_ID = #{sp_id}
       </if>
       <if test="sp_name != null and sp_name != ''">
           and sp.sp_name like CONCAT('%', #{sp_name}, '%')
       </if>
       <if test="sp_saler!=null and sp_saler!=''">
           and sp.sp_saler like CONCAT('%', #{sp_saler}, '%')
       </if>
        <if test="province_select != null and province_select != ''">
            and pt.province = #{province_select}
        </if>
       <if test="salerList!=null and salerList.size()>0">
           and sp.sp_saler in
           <foreach collection="salerList" index="index"  item="item" open="(" separator="," close=")">
               '${item}'
           </foreach>
       </if>

    </select>

    <!--    sum(pt.resendsubmit_succ) resendsubmit_succ,
        sum(pt.resendsubmit_fail) resendsubmit_fail,
        sum(pt.resendarrive_succ) resendarrive_succ,
        sum(pt.resendarrive_fail) resendarrive_fail,
        sum(pt.beresendsubmit_succ) beresendsubmit_succ,
        sum(pt.beresendsubmit_fail) beresendsubmit_fail,
        sum(pt.beresendarrive_succ) beresendarrive_succ,
        sum(pt.beresendarrive_fail) beresendarrive_fail -->
    <select id="getlistPaMonthListCount" parameterType="PaInfo"
        resultMap="PaInfoResultMap">
        select
        sum(pt.submitresp_succ) submitresp_succ,
        sum(pt.submitresp_fail) submitresp_fail,
        sum(pt.report_succ) report_succ,
        sum(pt.submit_count)-sum(pt.report_count) unRecMsgnum,
        sum(pt.report_fail) report_fail
        from pa_day_count pt, sms_send_channel_info g,sms_sp_info sp
      where pt.channelid = g.id and pt.SP_ID = sp.id
	<if test="p_id!=null and p_id>=0">
            and g.id =#{p_id}
        </if>
        <if test="pa_desc!=null and pa_desc!=''">
            and g.CHANNEL_NAME like CONCAT('%',#{pa_desc},'%')
        </if>
        <if test="managerId != null and managerId != ''">
            and g.business_manager in (select ifnull(business,0) from business_manager where managerId = #{managerId}) and g.business_manager != ''
        </if>
        <if test="business_manager != null and business_manager != ''">
            and g.business_manager = #{business_manager}
        </if>
        <if test="month!=null and month!=''">
            and date_format(pt.total_time,'%Y-%m')=#{month}
        </if>
        <if test="sp_id != null and sp_id != ''">
            and pt.SP_ID = #{sp_id}
        </if>
        <if test="otype!=null and otype!=''">
            and pt.otype = #{otype}
        </if>
        <if test="sp_name != null and sp_name != ''">
            and sp.sp_name like CONCAT('%', #{sp_name}, '%')
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler like CONCAT('%', #{sp_saler}, '%')
        </if>
        <if test="salerList!=null and salerList.size()>0">
            and sp.sp_saler in
            <foreach collection="salerList" index="index"  item="item" open="(" separator="," close=")">
                '${item}'
            </foreach>
        </if>
    </select>

    <select id="getlistMMSPaMonthListCount" parameterType="PaInfo"
        resultMap="PaInfoResultMap">
        select
        sum(pt.submitresp_succ) submitresp_succ,
        sum(pt.submitresp_fail) submitresp_fail,
        sum(pt.report_succ) report_succ,
        sum(pt.submit_count)-sum(pt.report_count) unRecMsgnum,
        sum(pt.report_fail) report_fail
        from pa_day_count pt, mms_send_channel_info g,sms_sp_info sp
      where pt.channelid = g.id and pt.SP_ID = sp.id and pt.channelid>0
	<if test="p_id!=null and p_id>=0">
            and g.id =#{p_id}
        </if>
        <if test="pa_desc!=null and pa_desc!=''">
            and g.CHANNEL_NAME like CONCAT('%',#{pa_desc},'%')
        </if>
        <if test="managerId != null and managerId != ''">
            and g.business_manager in (select ifnull(business,0) from business_manager where managerId = #{managerId}) and g.business_manager != ''
        </if>
        <if test="business_manager != null and business_manager != ''">
            and g.business_manager = #{business_manager}
        </if>
        <if test="month!=null and month!=''">
            and date_format(pt.total_time,'%Y-%m')=#{month}
        </if>
        <if test="sp_id != null and sp_id != ''">
            and pt.SP_ID = #{sp_id}
        </if>
        <if test="sp_name != null and sp_name != ''">
            and sp.sp_name like CONCAT('%', #{sp_name}, '%')
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler like CONCAT('%', #{sp_saler}, '%')
        </if>
        <if test="salerList!=null and salerList.size()>0">
            and sp.sp_saler in
            <foreach collection="salerList" index="index"  item="item" open="(" separator="," close=")">
                '${item}'
            </foreach>
        </if>
    </select>

   <select id="getChannelLimitById" parameterType="int" resultMap="channelLimitResultMap">
        select
       	a.id,
       	a.channelid,
       	a.oneday,
       	a.threeday,
       	a.nday,
       	a.hy_oneday,
       	a.hy_threeday,
       	a.hy_nday,
       	a.hy_ntimes,
        a.label,
       	a.createtime,
       	a.ntimes,a.begin_send_time,a.end_send_time,
       	a.wordnumber,a.new_channelid,a.dayLimit,
       a.send_time_type as sendTimeType, a.day_limit_type as dayLimitType, a.limit_channel as limitChannel
        from sms_channel_mdn_limit a
        where  a.channelid =#{channelid}
        limit 1
    </select>
    <update id="updateChannelLimit" parameterType="ChannelLimit">
        update sms_channel_mdn_limit
        set oneday=#{oneday},threeday=#{threeday},nday=#{nday},ntimes=#{ntimes},channelid=#{channelid}
        ,begin_send_time=#{begin_send_time, jdbcType=VARCHAR},end_send_time=#{end_send_time, jdbcType=VARCHAR},
		wordnumber=#{wordnumber},new_channelid=#{new_channelid},dayLimit=#{dayLimit},send_time_type=#{sendTimeType},
        day_limit_type=#{dayLimitType},limit_channel=#{limitChannel},label=#{label},hy_oneday=#{hy_oneday},
        hy_threeday=#{hy_threeday},hy_nday=#{hy_nday},hy_ntimes=#{hy_ntimes}
        where
        id = #{id}
    </update>
   <insert id="insertChannelLimit"  useGeneratedKeys="true" keyProperty="id" parameterType="ChannelLimit" >
        insert into sms_channel_mdn_limit (channelid,oneday,threeday,nday,ntimes,createtime,begin_send_time,end_send_time,wordnumber,new_channelid, dayLimit,
       send_time_type, day_limit_type, limit_channel,label,hy_oneday,hy_threeday,hy_nday,hy_ntimes)
        values (#{channelid},#{oneday},#{threeday},#{nday},#{ntimes},sysdate(),#{begin_send_time, jdbcType=VARCHAR},#{end_send_time, jdbcType=VARCHAR},
        #{wordnumber},#{new_channelid}, #{dayLimit}, #{sendTimeType}, #{dayLimitType}, #{limitChannel},#{label},#{hy_oneday},#{hy_threeday},#{hy_nday},#{hy_ntimes})
    </insert>


    <update id="updateSpChannelConfigMobilePrefix" parameterType="PaConfig">
    	update sms_sp_channel_config
        <set>
        	mobile =  concat(substring_index(mobile,',',1),',',#{mobile_prefix},',',substring_index(mobile,',',-1))
        </set>
        where substring_index(mobile,',',1)  = #{id}
        and #{mobile_prefix} is not null and #{mobile_prefix} != '';
    </update>
	<update id="updateSpChannelConfigUnicomPrefix" parameterType="PaConfig">
	  	update sms_sp_channel_config
        <set>
        	unicom =  concat(substring_index(unicom,',',1),',',#{unicom_prefix},',',substring_index(unicom,',',-1))
        </set>
        where substring_index(unicom,',',1)  = #{id}
        and #{unicom_prefix} is not null and #{unicom_prefix} != '';
	</update>
	<update id="updateSpChannelConfigTelecomPrefix" parameterType="PaConfig">
	 	update sms_sp_channel_config
        <set>
        	telecom =  concat(substring_index(telecom,',',1),',',#{telecom_prefix},',',substring_index(telecom,',',-1))
        </set>
        where substring_index(telecom,',',1)  = #{id}
        and #{telecom_prefix} is not null and #{telecom_prefix} != '';
	</update>

    <update id="updateSpInfoMobilePrefix" parameterType="PaConfig">
        update sms_sp_info
        <set>
            mobile_prefix = #{mobile_prefix},mobile_num= concat(#{mobile_prefix},IFNULL(mobile_suffix,''))
        </set>
        where  id in (SELECT spId from sms_sp_channel_config where substring_index(mobile,',',1)  = #{id})
        and #{mobile_prefix} is not null and #{mobile_prefix} != '';

    </update>
    <update id="updateSpInfoUnicomPrefix" parameterType="PaConfig">
   		update sms_sp_info
        <set>
            unicom_prefix = #{unicom_prefix},unicom_num= concat(#{unicom_prefix},IFNULL(unicom_suffix,''))
        </set>
        where  id in (SELECT spId from sms_sp_channel_config where substring_index(unicom,',',1)  = #{id})
        and #{unicom_prefix} is not null and #{unicom_prefix} != '';

    </update>
    <update id="updateSpInfoTelecomPrefix" parameterType="PaConfig">
        update sms_sp_info
        <set>
            telecom_prefix = #{telecom_prefix},telecom_num= concat(#{telecom_prefix},IFNULL(telecom_suffix,''))
        </set>
        where  id in (SELECT spId from sms_sp_channel_config where substring_index(telecom,',',1)  = #{id})
        and #{telecom_prefix} is not null and #{telecom_prefix} != '';

    </update>



    <select id="listPagePaHttpConfig" parameterType="PaConfig" resultType="PaConfig">
        select distinct a.id,a.is_support_international, a.is_support_unicom,a.is_support_telecom,a.is_support_mobile, a.channel_name name,a.unicom_prefix,a.mobile_prefix,a.telecom_prefix, a.mobile_prefix accessnumber,
                a.pa_url,a.status,a.protocol_type,a.batchsize,a.template_id,a.template_parameter,a.connect_status,a.attract_limit as attractLimit,a.link_properties as linkProperties,a.inter_mdn_0,
                p.templateCode,p.channelTemplatevar,a.business_manager businessManager,a.price,a.desc,a.inter_price_group interPriceGroup, su.NAME as businessName, DATE_FORMAT(a.update_time, '%Y-%m-%d %H:%i:%s') as updateTime
		from sms_send_channel_info a left join business_manager bm on bm.business = business_manager left join http_channel_template_config p on a.id = p.channelid
        left join sms_user_info su on su.USER_NAME = a.business_manager
		where a.protocol_type = 4
            <if test="name != null">
                and a.channel_name like CONCAT('%', #{name}, '%')
            </if>
            <if test="id != null">
                and a.id = #{id}
            </if>
            <if test="status != null and status != -1">
                and a.status = #{status}
            </if>
            <if test="linkProperties != null and linkProperties != -1">
                and a.link_properties = #{linkProperties}
            </if>
            <if test="businessManager != null and businessManager != '' and businessManager != 'undefined'">
                and a.business_manager = #{businessManager}
            </if>
            <if test="managerId != null and managerId != ''">
            and bm.managerId = #{managerId}
            </if>

        <if test="is_support_international != null and is_support_international != ''">
            and a.is_support_international = #{is_support_international}
        </if>

            <if test="ip != null">
                and p.ip like CONCAT('%',#{ip},'%')
            </if>
            <if test="loginname != null">
                and p.loginname like CONCAT('%',#{loginname},'%')
            </if>
        order by a.id desc
    </select>
    <select id="listHttpChannelTemplate"  resultType="HttpChannelTemplate">
        select a.id,a.templateCode,a.templateName,a.templateDefaultVar,a.templateVar,a.supplier,a.version from http_channel_template a

        where a.status = 0
    </select>

     <select id="listHttpMmsChannelTemplate"  resultType="HttpChannelTemplate">
        select a.id,a.templateCode,a.templateName,a.templateDefaultVar,a.templateVar,a.supplier,a.version from mms_http_channel_template a

        where a.status = 0
    </select>
   <select id="getHttpChannelTemplate"  resultType="HttpChannelTemplate" parameterType="PaConfig">
        select a.id,a.templateCode,a.templateName,a.templateDefaultVar,a.templateVar,a.supplier,a.version from http_channel_template a

        where a.templateCode =#{templateCode}
    </select>
       <select id="getHttpChannelTemplateMms"  resultType="HttpChannelTemplate" parameterType="PaConfig">
        select a.id,a.templateCode,a.templateName,a.templateDefaultVar,a.templateVar,a.supplier,a.version from mms_http_channel_template a

        where a.templateCode =#{templateCode}
    </select>
    <select id="listPagePaHttpTemplate" parameterType="HttpChannelTemplate" resultType="HttpChannelTemplate">
         select a.id,a.templateCode,a.templateName,a.templateDefaultVar,a.templateVar,a.supplier,a.version,a.createtime
         ,a.downloadUrl
          from http_channel_template a
		where a.status = 0
            <if test="templateName != null and templateName != ''">
                and a.templateName like CONCAT('%', #{templateName}, '%')
            </if>
            <!-- <if test="templateVar != null and templateVar != ''">
                and a.templateVar like CONCAT('%', #{templateVar}, '%')
            </if> -->
            <if test="templateDefaultVar !=null and templateDefaultVar != ''">
                and a.templateDefaultVar like CONCAT('%', #{templateDefaultVar}, '%')
            </if>
            <if test="supplier != null and supplier != ''">
                and a.supplier like CONCAT('%', #{supplier}, '%')
            </if>
            <if test="templateCode != null and templateCode != '' ">
                and a.templateCode = #{templateCode}
            </if>
            <if test="version != null and version != ''">
            	and a.version like CONCAT('%', #{version}, '%')
            </if>
            <if test="searchTemplateVarArr != null and searchTemplateVarArr != ''">
		        <foreach collection="searchTemplateVarArr"  separator=" " item="searchTemplateVar">
		              and a.templateVar like CONCAT('%', '${searchTemplateVar}', '%')
		        </foreach>
            </if>
             <!-- <if test="createtime!=null and createtime!=''">
	            and a.createtime &gt;=str_to_date(#{createtime},'%Y-%m-%d')
	        </if>
	        <if test="createtime1!=null and createtime1!=''">
	            and a.createtime &lt;=DATE_ADD(str_to_date(#{createtime1},'%Y-%m-%d'),INTERVAL 1 DAY)
	        </if>  -->
        order by a.id desc
    </select>
     <insert id="insertHttpTemplateConfig" parameterType="PaConfig">
       insert into http_channel_template_config (channelid,templateCode,channelTemplatevar,createtime) values
       (#{id,jdbcType=INTEGER},#{templateCode,jdbcType=VARCHAR},#{channelTemplatevar,jdbcType=VARCHAR},sysdate())
    </insert>
    <insert id="insertMmsHttpTemplateConfig" parameterType="PaConfig">
       insert into mms_http_channel_template_config (channelid,templateCode,channelTemplatevar,createtime) values
       (#{id,jdbcType=INTEGER},#{templateCode,jdbcType=VARCHAR},#{channelTemplatevar,jdbcType=VARCHAR},sysdate())
    </insert>

     <select id="getPaHttpConfigById" parameterType="PaConfig" resultType="PaConfig">
        select a.id,a.is_support_international, a.is_support_unicom,a.is_support_telecom,a.is_support_mobile,  a.channel_name name, a.mobile_prefix accessnumber,
               a.status,a.query_time as queryTime,
               a.ping_time as pingTime , a.auto_change as autoChange,a.pa_url,a.protocol_type,a.batchsize,a.template_id,a.template_parameter,a.access_key,a.http_response,a.spid,
                p.templateCode,p.channelTemplatevar,a.max_expand,a.is_only_expand,a.server_id,a.business_manager businessManager,a.cooperate_company cooperateCompany,a.price,a.desc,a.inter_price_group interPriceGroup,
                a.province,a.provinceNetPrice,a.supplier_id,cs.supplier_name,pro_group_price_id,a.attract_limit as attractLimit,a.link_properties as linkProperties,a.sign_template_limit as signTemplateLimit,a.sign_channel_enable as signChannelEnable
        from sms_send_channel_info a left join http_channel_template_config p  on a.id = p.channelid left join channel_supplier cs on cs.id=a.supplier_id
        where  a.id = #{id}
               limit 1
    </select>
    <select id="getMmsPaHttpConfigById" parameterType="PaConfig" resultType="PaConfig">

        select a.id, a.is_support_unicom,a.is_support_telecom,a.is_support_mobile,  a.is_support_international,  a.channel_name name, a.mobile_prefix accessnumber,
               a.status,a.cooperate_company cooperateCompany,a.supplier_id,
                a.pa_url,a.protocol_type,a.batchsize,a.access_key,a.http_response,
                p.templateCode,p.channelTemplatevar,b.templateDefaultVar ,`desc`,a.price,
                a.attract_limit as attractLimit,a.link_properties as linkProperties
        from mms_send_channel_info a left join mms_http_channel_template_config p  on a.id = p.channelid
        left join mms_http_channel_template b on p.templateCode = b.templateCode
        where  a.id = #{id}
               limit 1
    </select>

     <update id="updateHttpTemplateConfig" parameterType="PaConfig">
        update http_channel_template_config set
        templateCode=#{templateCode},channelTemplatevar=#{channelTemplatevar}
         where channelid=#{id}
    </update>
    <update id="updateMmsHttpTemplateConfig" parameterType="PaConfig">
        update mms_http_channel_template_config set
        templateCode=#{templateCode},channelTemplatevar=#{channelTemplatevar}
         where channelid=#{id}
    </update>

	<select id="getSystemIp"  resultType="String">
        select a.value from sms_system_config a
        where a.config_key = 'ip'
               limit 1
    </select>

    <select id="listPaConfigForAccessnumber" parameterType="PaConfig" resultType="PaConfig">
         select a.id,a.is_support_international, a.is_support_unicom,a.is_support_telecom,a.is_support_mobile,p.carrier, a.channel_name name,a.unicom_prefix,a.mobile_prefix,a.telecom_prefix,p.loginname, p.password, a.mobile_prefix accessnumber, p.ip, p.port,
               p.service_id, p.carrier_sp_id, p.fee_type, p.fee_code, p.price,p.version, p.carrier_speed,
               p.socket_conn, p.src_note_id, p.local_listen_port, p.carrier_sp_sign, a.pa_url,a.status,a.protocol_type,a.batchsize,a.template_id,a.template_parameter,a.connect_status,a.attract_limit as attractLimit,a.link_properties as linkProperties
									from sms_send_channel_info a left JOIN sms_carrier_channel_info p ON a.id = p.id
									where 1=1
            <if test="status != null and status != -1">
                and a.status = #{status}
            </if>
        order by a.id desc
    </select>

     <select id="getPaHttpChannelInfoById" parameterType="PaConfig" resultType="PaConfig">
        select a.id,a.is_support_international, a.is_support_unicom,a.is_support_telecom,a.is_support_mobile,  a.channel_name name, a.mobile_prefix accessnumber,
               a.status,a.query_time as queryTime,
               a.ping_time as pingTime , a.auto_change as autoChange,a.pa_url,a.protocol_type,a.batchsize,a.template_id,a.template_parameter,a.access_key,a.http_response,a.spid,
                p.templateCode,p.channelTemplatevar,b.templateDefaultVar
        from sms_send_channel_info a ,http_channel_template_config p ,http_channel_template b
        where a.id = p.channelid and p.templateCode=b.templateCode
               and  a.id = #{id}
               limit 1
    </select>

     <select id="getPaHttpChannelConfigByChannelId" parameterType="PaConfig" resultType="PaConfig">
        select p.templateCode,p.channelTemplatevar

        from http_channel_template_config p
        where  p.channelid=#{id}
               limit 1
    </select>
    <select id="getMmsPaHttpChannelConfigByChannelId" parameterType="PaConfig" resultType="PaConfig">
        select p.templateCode,p.channelTemplatevar

        from mms_http_channel_template_config p
        where  p.channelid=#{id}
               limit 1
    </select>

     <select id="sendStatisticsInMinuteListPaConfig" parameterType="PaConfig" resultType="PaConfig">
        select a.id, a.is_support_international,a.is_support_unicom,a.is_support_telecom,a.is_support_mobile,p.carrier, a.channel_name name,a.unicom_prefix,a.mobile_prefix,a.telecom_prefix,p.loginname, p.password, a.mobile_prefix accessnumber, p.ip, p.port,
               p.service_id, p.carrier_sp_id, p.fee_type, p.fee_code, p.price,p.version, p.carrier_speed,
               p.socket_conn, p.src_note_id, p.local_listen_port, p.carrier_sp_sign, a.pa_url,a.status,a.protocol_type,a.batchsize,a.template_id,a.template_parameter,a.connect_status,a.attract_limit as attractLimit,a.link_properties as linkProperties
									from sms_send_channel_info a left JOIN sms_carrier_channel_info p ON a.id = p.id
									where 1=1
            <if test="id!=null and id>=0">
	            and a.id =#{id}
	        </if>
            <if test="name != null and name != ''">
                and a.channel_name like CONCAT('%', #{name}, '%')
            </if>

            <if test="status != null and status != -1">
                and a.status = #{status}
            </if>

            <if test="ip != null">
                and p.ip like CONCAT('%',#{ip},'%')
            </if>
            <if test="loginname != null">
                and p.loginname like CONCAT('%',#{loginname},'%')
            </if>

        order by a.id desc
    </select>


   <select id="listSalerDetail" parameterType="PaInfo" resultMap="PaInfoResultMap">
		SELECT
		s.id p_id,s.sp_saler,DATE_FORMAT(sd.createtime,'%Y-%m')
		createtime,SUM(sd.arrive_num) report_succ,SUM(sd.saleprice)
		saleprice,SUM(sd.costprice) costprice,SUM(sd.saleprice-sd.costprice)
		profit,SUM(sd.saleprice-sd.costprice)/SUM(sd.saleprice) profit1,
		sum(sd.totalcost) totalcost,sum(sd.total) total1,sum(sd.totalsale)
		totalsale,sum(sd.totalsale-sd.totalcost) totalprofit,
		sum(sd.totalsale-sd.totalcost)/sum(sd.totalsale) totalprofit1
		FROM
		sms_sp_day_fee sd,
		sms_sp_info s
		WHERE s.id = sd.sp_id
		<if test="month!=null and month!=''">
			and date_format(sd.createtime,'%Y-%m')=#{month}
		</if>
		<if test="sp_saler!=null and sp_saler!=''">
			and s.sp_saler = #{sp_saler}
		</if>
		GROUP BY s.sp_saler
	</select>

	<select id="exportsalerDetailList" parameterType="PaInfo"
		resultType="Map">
		SELECT
		s.id p_id,s.sp_saler,DATE_FORMAT(sd.createtime,'%Y-%m')
		createtime,SUM(sd.arrive_num) report_succ,SUM(sd.saleprice)
		saleprice,SUM(sd.costprice) costprice,SUM(sd.saleprice-sd.costprice)
		profit,SUM(sd.saleprice-sd.costprice)/SUM(sd.saleprice) profit1,
		sum(sd.totalcost) totalcost,sum(sd.total) total1,sum(sd.totalsale)
		totalsale,sum(sd.totalsale-sd.totalcost) totalprofit,
		sum(sd.totalsale-sd.totalcost)/sum(sd.totalsale) totalprofit1
		FROM
		sms_sp_day_fee sd,
		sms_sp_info s
		WHERE s.id = sd.sp_id
		<if test="month!=null and month!=''">
			and date_format(sd.createtime,'%Y-%m')=#{month}
		</if>
		<if test="sp_saler!=null and sp_saler!=''">
			and s.sp_saler = #{sp_saler}
		</if>
		GROUP BY s.sp_saler
	</select>

	<select id="getGroupChannelsAndWeight" parameterType="String"
		resultType="Map">
		SELECT channels,weight,
		DATE_FORMAT(modifyTime,'%Y-%m-%d %H:%i:%S') modifyTime
		 from sms_channel_group
		where id = #{groupId} AND `status` = '1'  LIMIT 1
	</select>

	<select id="listPageChannelBatchChange" parameterType="ChannelBatchChange"
		resultType="ChannelBatchChange">
		SELECT id,otype,username,condition_key,src_channel,dst_channel,DATE_FORMAT(createtime,'%Y-%m-%d %H:%i:%S') createtime,status,remark,condition_value,spnum,select_size
		 from sms_channel_batch_change
			where status>=0
		<if test="createtime!=null and createtime!=''">
            and createtime&gt;=str_to_date(#{createtime},'%Y-%m-%d')
        </if>
        <if test="createtime1!=null and createtime1!=''">
            and
            createtime&lt;DATE_ADD(str_to_date(#{createtime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
         <if test="src_channel_n !=null and src_channel_n !=''">
            and src_channel=#{src_channel_n}
        </if>
         <if test="dst_channel_n!=null and dst_channel_n!=''">
            and dst_channel=#{dst_channel_n}
        </if>
		order by id desc
	</select>

	 <select id="getChannelBatchChange" parameterType="ChannelBatchChange" resultType="ChannelBatchChange">
	    select
	    id,otype,src_channel,dst_channel
	    from sms_channel_batch_change
         where id=#{id}
         and status=1
         limit 1
    </select>

	<select id="listPageChannelBatchChangeSp" parameterType="ChannelBatchChangeRecord"
		resultType="ChannelBatchChangeRecord">
		SELECT id,spId,batchId,status,remark
		 from sms_channel_batch_change_record
			where batchid=#{batchId}
         <if test="spId!=null and spId>0">
            and spid=#{spId}
        </if>
        <if test="status!=null and status>=0">
            and status=#{status}
        </if>
	</select>

	<select id="getAllChannelBatchChangeSp" parameterType="ChannelBatchChange"
		resultType="ChannelBatchChangeRecord">
		SELECT b.sp_Id spId,b.CHANNELID channelId
		 from sms_channel_batch_change_record a,sms_chennel_config b
			where a.spid=b.sp_id and a.batchid=#{id} and b.opertor_type=#{otype}
        	and a.status=0 GROUP BY a.spid,b.CHANNELID
	</select>


	 <select id="getChannelSpInfo" parameterType="ChannelConfig" resultType="string">
	    select
	    cg.sp_id
	    from sms_chennel_config cg
         where channelid=#{channelId}
        and cg.opertor_type = #{opertor_type}
    </select>

    <select id="getSpChannelSpInfo" parameterType="ChannelConfig" resultType="string">
        select
            cg.sp_id
        from sms_sp_channel_config cg
        <where>
            <if test="mobile!=null and mobile!=''">
                and  find_in_set(#{mobile},mobile)
            </if>
            <if test="unicom!=null and unicom!=''">
                and  find_in_set(#{unicom},unicom)
            </if>
            <if test="telecom!=null and telecom!=''">
                and  find_in_set(#{telecom},telecom)
            </if>
            and find_in_set(#{network},network)
         </where>

    </select>

    <update id="updateSpChannelSpInfo" parameterType="cn.roadm.bo.spChannelDTO">
        update sms_sp_channel_config cg
        <set>
            <if test="mobile!=null and mobile!=''">
                mobile = REPLACE(mobile,#{oldMobile},#{mobile}),
            </if>
            <if test="unicom!=null and unicom!=''">
                unicom = REPLACE(unicom,#{oldUnicom},#{unicom}),
            </if>
            <if test="telecom!=null and telecom!=''">
                telecom = REPLACE(telecom,#{oldTelecom},#{telecom}),
            </if>
            <if test="mobileGroup!=null and mobileGroup!=''">
                mobileGroup = REPLACE(mobileGroup,#{oldMobileGroup},#{mobileGroup}),
            </if>
            <if test="unicomGroup!=null and unicomGroup!=''">
                unicomGroup = REPLACE(unicomGroup,#{oldUnicomGroup},#{unicomGroup}),
            </if>
            <if test="telecomGroup!=null and telecomGroup!=''">
                telecomGroup = REPLACE(telecomGroup,#{oldTelecomGroup},#{telecomGroup}),
            </if>
        </set>
        where cg.spid = #{spId} and find_in_set(#{network},network)

    </update>

    <insert id="insertChannelBatchChange"  useGeneratedKeys="true" keyProperty="id" parameterType="ChannelBatchChange">
       insert into sms_channel_batch_change (otype,username,condition_key,src_channel,dst_channel,status,remark,condition_value,createtime) values
       (#{otype,jdbcType=INTEGER},#{username,jdbcType=VARCHAR},#{condition_key,jdbcType=VARCHAR},#{src_channel},#{dst_channel},#{status},#{remark},#{condition_value},sysdate())
    </insert>

    <update id="updateSpTelcomAccessNum" parameterType="ChannelBatchChangeRecord">
        update sms_sp_info set
        telecom_prefix=#{dst_channel_num},telecom_num=concat(${dst_channel_num},IFNULL(telecom_suffix,''))
         where id=#{spId}
    </update>

     <update id="updateSpUnicomAccessNum" parameterType="ChannelBatchChangeRecord">
        update sms_sp_info set
        unicom_prefix=#{dst_channel_num},unicom_num=concat(${dst_channel_num},IFNULL(unicom_suffix,''))
         where id=#{spId}
    </update>

     <update id="updateSpMobileAccessNum" parameterType="ChannelBatchChangeRecord">
        update sms_sp_info set
        mobile_prefix=#{dst_channel_num},mobile_num=concat(${dst_channel_num},IFNULL(mobile_suffix,''))
         where id=#{spId}
    </update>

    <update id="updateChannelConfig" parameterType="ChannelBatchChangeRecord">
	    update  sms_chennel_config
	    set  channelid=#{channelId} where sp_id = #{spId} and opertor_type=#{otype}
    </update>
    <insert id="insertChannelBatchChangeRecord" useGeneratedKeys="true" keyProperty="id" parameterType="ChannelBatchChangeRecord">
       insert into sms_channel_batch_change_record (spid,batchid,status) values
       (#{spId,jdbcType=VARCHAR},#{batchId,jdbcType=VARCHAR},0)
    </insert>
    <insert id="insertChannelBatchChangeDiversionRecord" useGeneratedKeys="true" keyProperty="id" parameterType="ChannelBatchChangeRecord">
        insert into sms_channel_batch_change_diversion_record (spid,batchid,status,`type`,provincial_group,content,prefecture_group) values
            (#{spId,jdbcType=VARCHAR},#{batchId,jdbcType=VARCHAR},0,#{type},#{provincial_group,jdbcType=VARCHAR},#{content,jdbcType=VARCHAR},#{prefecture_group,jdbcType=VARCHAR})
    </insert>
    <select id="getAllChannelBatchChangeDiversionRecord" parameterType="integer"
            resultType="ChannelBatchChangeRecord">
        SELECT id,spid spId,batchid,status,`type`,provincial_group,content,prefecture_group
        from sms_channel_batch_change_diversion_record a
        where a.batchid=#{batchId}
          and a.status=0 ORDER BY spid
    </select>
    <update id="updateChannelBatchChangeDiversionRecord" parameterType="ChannelBatchChangeRecord">
        update  sms_channel_batch_change_diversion_record
        set status=#{status},remark=#{remark} where batchid = #{batchId} and spid=#{spId} and id=#{id}
    </update>
     <update id="updateChannelBatchChangeRecord" parameterType="ChannelBatchChangeRecord">
	    update  sms_channel_batch_change_record
	    set status=#{status},remark=#{remark} where batchid = #{batchId} and spid=#{spId}
    </update>

    <update id="updateChannelBatchChange" parameterType="ChannelBatchChange">
	    update  sms_channel_batch_change
	    set  status=#{status}
	    <if test="spnum!=null and spnum>0">
	        ,spnum=#{spnum}
	    </if>
        <if test="select_size!=null">
            ,select_size=#{select_size}
        </if>
	    where id = #{id}
    </update>

    <select id="getChannelReduceTest" resultType="cn.roadm.bo.ChannelReduceTest">
    	select id,test_content testContent,test_channel_ids testChannelIds,
		scan_time scanTime,open_flag openFlag,alarm_type alarmType,email,phone,null_phone_telecom nullPhoneTelecom,
		null_phone_unicom nullPhoneUnicom,null_phone_cmcc nullPhoneCmcc,delay_time delayTime,alarm_content alarmContent,
        historyTestFlag,historyInterval,historyDay,historyChannelIds,errorCodes,readyChannelIds,
        mobile_flag,mobile_channel_id,mobile_error_code,mobile_limit,
        unicom_flag,unicom_channel_id,unicom_error_code,unicom_limit,
        telecom_flag,telecom_channel_id,telecom_error_code,telecom_limit,historyAlarmContent,
            mibilePullChannel, unicomPullChannel, telcomPullChannel
        from channel_reduce_config limit 1
    </select>

    <insert id="insertChannelReduceTest" useGeneratedKeys="true" keyProperty="id" parameterType="cn.roadm.bo.ChannelReduceTest">
    	INSERT INTO `channel_reduce_config` (`test_content`, `test_channel_ids`, `scan_time`, `alarm_type`,
    	 `open_flag`,`email`, `phone`,`null_phone_telecom`,`null_phone_unicom`,`null_phone_cmcc`,`delay_time`,
        `alarm_content`, historyTestFlag, historyChannelIds, historyDay, historyInterval,
        errorCodes, mobile_flag, mobile_channel_id, mobile_error_code, mobile_limit, unicom_flag, unicom_channel_id, unicom_error_code, unicom_limit,
        telecom_flag, telecom_channel_id, telecom_error_code, telecom_limit, historyAlarmContent, mibilePullChannel, unicomPullChannel, telcomPullChannel)
        VALUES (#{testContent}, #{testChannelIds}, #{scanTime}, #{alarmType},
    	  #{openFlag},#{email},#{phone},#{nullPhoneTelecom},#{nullPhoneUnicom},#{nullPhoneCmcc},#{delayTime},#{alarmContent},
        #{historyTestFlag},#{historyChannelIds},#{historyDay},#{historyInterval},#{errorCodes},#{mobile_flag},#{mobile_channel_id},#{mobile_error_code},#{mobile_limit},
        #{unicom_flag},#{unicom_channel_id},#{unicom_error_code}, #{unicom_limit},#{telecom_flag},#{telecom_channel_id},#{telecom_error_code},#{telecom_limit},#{historyAlarmContent}
        ,#{mibilePullChannel}, #{unicomPullChannel}, #{telcomPullChannel})
    </insert>

    <!-- `test_content`=#{testContent}, `test_channel_ids`=#{testChannelIds},
    	`choice_phone`=#{choicePhone}, `scan_time`=#{scanTime},
    	 `alarm_type`=#{alarmType}, `email`=#{email}, `phone`=#{phone},`null_phone_telecom`=#{nullPhoneTelecom},
    	 `null_phone_unicom`=#{nullPhoneUnicom} ,null_phone_cmcc=#{nullPhoneCmcc},`phone_num`=#{phoneNum},
    	 `channelid_cmcc`=#{channelidCmcc},`channelid_unicom`=#{channelidUnicom},`channelid_telecom`=#{channelidTelecom},
    	 `errorcode_cmcc`=#{errorcodeCmcc},`errorcode_unicom`=#{errorcodeUnicom},`errorcode_telecom`=#{errorcodeTelecom},
    	 delay_time=#{delayTime},alarm_content=#{alarmContent} where id=#{id} -->
    <update id="updateChannelReduceTest">
    	 update `channel_reduce_config`
        <set>
            <if test="openFlag != null">
                open_flag=#{openFlag},
            </if>
            <if test="testChannelIds != null and testChannelIds != ''">
                test_channel_ids=#{testChannelIds},
            </if>
            <if test="nullPhoneCmcc != null and nullPhoneCmcc != ''">
                null_phone_cmcc=#{nullPhoneCmcc},
            </if>
            <if test="nullPhoneUnicom != null and nullPhoneUnicom != ''">
                null_phone_unicom=#{nullPhoneUnicom},
            </if>
            <if test="nullPhoneTelecom != null and nullPhoneTelecom != ''">
                null_phone_telecom=#{nullPhoneTelecom},
            </if>
            <if test="scanTime != null and scanTime != ''">
                scan_time=#{scanTime},
            </if>
            <if test="delayTime != null">
                delay_time=#{delayTime},
            </if>
            <if test="historyTestFlag != null">
                historyTestFlag=#{historyTestFlag},
            </if>
            <if test="historyChannelIds != null and historyChannelIds != ''">
                historyChannelIds=#{historyChannelIds},
            </if>
            <if test="errorCodes != null and errorCodes != ''">
                errorCodes=#{errorCodes},
            </if>
            <if test="historyDay != null">
                historyDay=#{historyDay},
            </if>
            <if test="readyChannelIds != null and readyChannelIds != ''">
                readyChannelIds=#{readyChannelIds},
            </if>
            <if test="historyInterval != null and historyInterval != ''">
                historyInterval=#{historyInterval},
            </if>
            <if test="alarmType != null">
                alarm_type=#{alarmType},
            </if>
            <if test="phone != null and phone != ''">
                phone=#{phone},
            </if>
            <if test="email != null and email != ''">
                email=#{email},
            </if>
            <if test="alarmContent != null and alarmContent != ''">
                alarm_content=#{alarmContent},
            </if>
            <if test="testContent != null and testContent != ''">
                test_content=#{testContent},
            </if>
            <if test="mobile_flag != null">
                mobile_flag = #{mobile_flag},
            </if>
            <if test="mobile_channel_id != null and mobile_channel_id != ''">
                mobile_channel_id = #{mobile_channel_id},
            </if>
            <if test="mobile_error_code != null and mobile_error_code != ''">
                mobile_error_code = #{mobile_error_code},
            </if>
            <if test="mobile_limit != null">
                mobile_limit = #{mobile_limit},
            </if>
            <if test="unicom_flag != null ">
                unicom_flag = #{unicom_flag},
            </if>
            <if test="unicom_channel_id != null and unicom_channel_id != ''">
                unicom_channel_id = #{unicom_channel_id},
            </if>
            <if test="unicom_error_code != null and unicom_error_code != ''">
                unicom_error_code = #{unicom_error_code},
            </if>
            <if test="unicom_limit != null">
                unicom_limit = #{unicom_limit},
            </if>
            <if test="telecom_flag != null ">
                telecom_flag = #{telecom_flag},
            </if>
            <if test="telecom_channel_id != null and telecom_channel_id != ''">
                telecom_channel_id = #{telecom_channel_id},
            </if>
            <if test="telecom_error_code != null and telecom_error_code != ''">
                telecom_error_code = #{telecom_error_code},
            </if>
            <if test="telecom_limit != null">
                telecom_limit = #{telecom_limit},
            </if>
            <if test="historyAlarmContent != null and historyAlarmContent != ''">
                historyAlarmContent = #{historyAlarmContent},
            </if>
            <if test="mibilePullChannel != null and mibilePullChannel != ''">
                mibilePullChannel = #{mibilePullChannel},
            </if>
            <if test="unicom_channel_id != null and unicom_channel_id != ''">
                unicomPullChannel = #{unicomPullChannel},
            </if>
            <if test="telcomPullChannel != null and telcomPullChannel != ''">
                telcomPullChannel = #{telcomPullChannel}
            </if>
        </set>
        where id=#{id}
    </update>

    <select id="getChannelRealEmptyConfig" resultType="cn.roadm.bo.ChannelRealEmptyConfig">
        select id, master_switch masterSwitch, real_channel_id realChannelId,
        empty_channel_id emptyChannelId, empty_error_code emptyErrorCode,
        effective_real_channel_id effectiveRealChannelId, ineffective_real_channel_id ineffectiveRealChannelId,
        effective_empty_channel_id effectiveEmptyChannelId, ineffective_empty_channel_id ineffectiveEmptyChannelId,
        effective_time_type effectiveTimeType, effective_time_unit effectiveTimeUnit, effective_time_value effectiveTimeValue
        from channel_real_empty_config limit 1
    </select>

    <insert id="insertChannelRealEmptyConfig" useGeneratedKeys="true" keyProperty="id" parameterType="cn.roadm.bo.ChannelRealEmptyConfig">
        INSERT INTO `channel_real_empty_config` (
        `master_switch`, `real_channel_id`, `empty_channel_id`,
        `empty_error_code`, `effective_real_channel_id`, `ineffective_real_channel_id`,
        `effective_empty_channel_id`, `ineffective_empty_channel_id`, `effective_time_type`,
        `effective_time_unit`, `effective_time_value`)
        VALUES (
        #{masterSwitch}, #{realChannelId}, #{emptyChannelId},
        #{emptyErrorCode}, #{effectiveRealChannelId}, #{ineffectiveRealChannelId},
        #{effectiveEmptyChannelId}, #{ineffectiveEmptyChannelId}, #{effectiveTimeType},
        #{effectiveTimeUnit}, #{effectiveTimeValue})
    </insert>

    <update id="updateChannelRealEmptyConfig">
        update `channel_real_empty_config`
        <set>
            <if test="masterSwitch != null">
                master_switch=#{masterSwitch},
            </if>
            <if test="realChannelId != null">
                real_channel_id=#{realChannelId},
            </if>
            <if test="emptyChannelId != null">
                empty_channel_id=#{emptyChannelId},
            </if>
            <if test="emptyErrorCode != null">
                empty_error_code=#{emptyErrorCode},
            </if>
            <if test="effectiveRealChannelId != null">
                effective_real_channel_id=#{effectiveRealChannelId},
            </if>
            <if test="ineffectiveRealChannelId != null">
                ineffective_real_channel_id=#{ineffectiveRealChannelId},
            </if>
            <if test="effectiveEmptyChannelId != null">
                effective_empty_channel_id=#{effectiveEmptyChannelId},
            </if>
            <if test="ineffectiveEmptyChannelId != null">
                ineffective_empty_channel_id=#{ineffectiveEmptyChannelId},
            </if>
            <if test="effectiveTimeType != null">
                effective_time_type=#{effectiveTimeType},
            </if>
            <if test="effectiveTimeUnit != null">
                effective_time_unit=#{effectiveTimeUnit},
            </if>
            <if test="effectiveTimeValue != null">
                effective_time_value=#{effectiveTimeValue}
            </if>
        </set>
        where id=#{id}
    </update>

   <select id="listPageChannelWord" resultType="cn.roadm.bo.ChannelWord">
   		select scw.id,scw.content,scw.createid,DATE_FORMAT(scw.create_time,'%Y-%m-%d %H:%i:%s') createTime,scw.channelid,us.user_name userName
   		from sms_channel_word scw left join sms_user_info us on scw.createid =us.id
   		<where>
   			<if test="content!=null and content!=''">
   				and scw.content like CONCAT('%',#{content},'%')
   			</if>
   			<if test="channelid!=null and channelid>=0">
   				and scw.channelid=#{channelid}
   			</if>
   		</where>
       order by scw.create_time desc
   </select>

   <insert id="addChannelWord" useGeneratedKeys="true" keyProperty="id" parameterType="cn.roadm.bo.ChannelWord">
   		insert into sms_channel_word(content,createid,create_time,channelid) VALUES(#{content},#{createid},now(),#{channelid})
   </insert>

   <update id="updateChannelWord">
   		update sms_channel_word set content=#{content},channelid=#{channelid} where id=#{id}
   </update>

   <delete id="delChannelWord">
   		delete from sms_channel_word where id=#{id}
   </delete>
    <select id="getChannelWordById" resultType="cn.roadm.bo.ChannelWord">
   		select id,content,channelid from sms_channel_word where id=#{id}
   </select>

   <select id="getChannelWordByContent" resultType="int">
   		select COUNT(1) from sms_channel_word where content=#{content} and channelid=#{channelid}
   </select>
   <select id="getChannelWordByChannelid" resultType="cn.roadm.bo.ChannelWord">
   		select content,channelid from sms_channel_word where channelid=#{channelid}
   </select>
   <insert id="addChannelWordBatch" useGeneratedKeys="true" keyProperty="id"  parameterType="java.util.List">
   		insert into sms_channel_word(content,createid,create_time,channelid) VALUES
   		<foreach collection="list" item="item"  index="index"  separator="," >
   			(#{item.content},#{item.createid},now(),#{item.channelid})
   		</foreach>
   </insert>
    <select id="getAllChannelWord" resultType="cn.roadm.bo.ChannelWord">
   		select content,channelid,us.user_name userName,DATE_FORMAT(scw.create_time,'%Y-%m-%d %H:%i:%s') createTime
   		from sms_channel_word scw left join sms_user_info us on scw.createid =us.id
   		<where>
   			<if test="content!=null and content!=''">
   				and scw.content like CONCAT('%',#{content},'%')
   			</if>
   			<if test="channelid!=null and channelid>=0">
   				and scw.channelid=#{channelid}
   			</if>
   		</where>
   </select>

   <select id="getChannelWord" resultType="cn.roadm.bo.ChannelWord">
   		select content,channelid,us.user_name userName,DATE_FORMAT(scw.create_time,'%Y-%m-%d %H:%i:%s') createTime
   		from sms_channel_word scw left join sms_user_info us on scw.createid =us.id
   </select>

    <select id="listPageProvinceGroup" resultType="cn.roadm.bo.SmsProvinceGroup">
    	select id,name,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`status`,`desc` from sms_province_group
    	<where>
    		status=1
    		<if test="name!=null and name!=''">
    			and name like CONCAT('%',#{name},'%')
    		</if>
    	</where>
    </select>


    <select id="listPageMmsProvinceGroup" resultType="cn.roadm.bo.MmsProvinceGroup">
        select id,name,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`status`,`desc` from mms_province_group
        <where>
            status=1
            <if test="name!=null and name!=''">
                and name like CONCAT('%',#{name},'%')
            </if>
        </where>
    </select>

    <select id="getProvinceGroupConfig" resultType="cn.roadm.bo.SmsProvinceGroup">
    	select id,group_id,mobilechannel,unicomchannel,telecomchannel,province from sms_province_group_config where group_id=#{group_id}
    </select>

    <select id="getMmsProvinceGroupConfig" resultType="cn.roadm.bo.MmsProvinceGroup">
        select id,group_id,mobilechannel,unicomchannel,telecomchannel,province from mms_province_group_config where group_id=#{group_id}
    </select>

    <select id="getProvinceGroupConfigByProvince" resultType="cn.roadm.bo.SmsProvinceGroup">
        select id,group_id,mobilechannel,unicomchannel,telecomchannel,province from sms_province_group_config where group_id=#{group_id} and province=#{province}
    </select>

    <select id="getProvinceGroupConfigByChannel" parameterType="cn.roadm.bo.SmsProvinceGroup" resultType="cn.roadm.bo.SmsProvinceGroup">
        select ss.id as spid ,sc.id,sc.mobilechannel,sc.unicomchannel,sc.telecomchannel,sc.group_id,sc.province from sms_province_group_config sc,sms_sp_info ss
        <where>
            ss.pro_group_id = sc.group_id
            <if test = "mobilechannel != null">
                and sc.mobilechannel=#{mobilechannel}
            </if>
            <if test = "unicomchannel != null">
                and sc.unicomchannel=#{unicomchannel}
            </if>
            <if test = "telecomchannel != null">
                and sc.telecomchannel=#{telecomchannel}
            </if>
            <if test = "group_id != null">
                and sc.group_id=#{group_id}
            </if>
            <if test = "province != null and province != ''">
                and sc.province=#{province}
            </if>
        </where>


    </select>

    <select id="getKeywordProvinceGroupConfigByChannel" parameterType="cn.roadm.bo.SmsProvinceGroup" resultType="cn.roadm.bo.SmsProvinceGroup">
        select sk.spid,sk.id,sc.mobilechannel,sc.unicomchannel,sc.telecomchannel,sc.group_id,sc.province from sms_province_group_config sc, sms_keyword_bypass sk
        <where>
            sk.province_group_id = sc.group_id
            <if test = "mobilechannel != null">
                and sc.mobilechannel=#{mobilechannel}
            </if>
            <if test = "unicomchannel != null">
                and sc.unicomchannel=#{unicomchannel}
            </if>
            <if test = "telecomchannel != null">
                and sc.telecomchannel=#{telecomchannel}
            </if>
            <if test = "group_id != null">
                and sc.group_id=#{group_id}
            </if>
            <if test = "province != null and province != ''">
                and sc.province=#{province}
            </if>
        </where>

    </select>


    <select id="getKeywordCityGroupConfigByChannel" parameterType="cn.roadm.bo.SmsCityGroup" resultType="cn.roadm.bo.SmsCityGroup">
        select sk.spid ,sk.id,sc.mobilechannel,sc.unicomchannel,sc.telecomchannel,sc.group_id,sc.city from sms_city_group_config sc, sms_keyword_bypass sk
        <where>
            sk.city_group_id = sc.group_id
            <if test = "mobilechannel != null">
                and sc.mobilechannel=#{mobilechannel}
            </if>
            <if test = "unicomchannel != null">
                and sc.unicomchannel=#{unicomchannel}
            </if>
            <if test = "telecomchannel != null">
                and sc.telecomchannel=#{telecomchannel}
            </if>
            <if test = "group_id != null">
                and sc.group_id=#{group_id}
            </if>
            <if test = "city != null and city != ''">
                and sc.city=#{city}
            </if>
        </where>

    </select>

    <select id="getCityGroupConfigByCity" resultType="cn.roadm.bo.SmsCityGroup">
        select id,group_id,mobilechannel,unicomchannel,telecomchannel,city from sms_city_group_config where group_id=#{group_id} and city=#{city}
    </select>

    <select id="getCityGroupConfig" resultType="cn.roadm.bo.SmsCityGroup">
        select id,group_id,mobilechannel,unicomchannel,telecomchannel,city from sms_city_group_config where group_id=#{group_id}
    </select>

    <update id="delProcinceGroup" parameterType="cn.roadm.bo.SmsProvinceGroup">
    	update sms_province_group set status=0 where id=#{id}
    </update>

    <update id="delMmsProcinceGroup" parameterType="cn.roadm.bo.MmsProvinceGroup">
        update mms_province_group set status=0 where id=#{id}
    </update>

    <update id="delCityGroup" parameterType="cn.roadm.bo.SmsProvinceGroup">
        update sms_city_group set status=0 where id=#{id}
    </update>

    <insert id="insertProcinceGroup" useGeneratedKeys="true" keyProperty="id"  parameterType="cn.roadm.bo.SmsProvinceGroup">
    	insert into sms_province_group(name,createtime,status) values(#{name},now(),1)
    </insert>

    <insert id="insertMmsProcinceGroup" useGeneratedKeys="true" keyProperty="id"  parameterType="cn.roadm.bo.MmsProvinceGroup">
        insert into mms_province_group(name,createtime,status) values(#{name},now(),1)
    </insert>

    <insert id="insertChannelProvinceGroup" useGeneratedKeys="true" keyProperty="groupId" parameterType="cn.roadm.bo.SpChannelProvinceGroupData">
        insert into sms_province_group(name, createtime, status) values (#{groupName}, now(), 1)
    </insert>
    <insert id="insertChannelMmsProvinceGroup" useGeneratedKeys="true" keyProperty="groupId" parameterType="cn.roadm.bo.SpChannelProvinceGroupData">
        insert into mms_province_group(name, createtime, status) values (#{groupName}, now(), 1)
    </insert>
    <insert id="insertChannelCityGroup" useGeneratedKeys="true" keyProperty="groupId" parameterType="cn.roadm.bo.SpChannelProvinceGroupData">
        insert into sms_city_group(name, createtime, status) values (#{groupName}, now(), 1)
    </insert>

    <insert id="insertChannelProvinceGroupData" useGeneratedKeys="true" keyProperty="id" parameterType="cn.roadm.bo.SpChannelProvinceConfig">
        insert into sms_province_group_config (group_id,mobilechannel,unicomchannel,telecomchannel,province) values
            <foreach collection="list" item="item" separator=",">
                (#{item.groupId}, #{item.mobilechannel}, #{item.unicomchannel}, #{item.telecomchannel}, #{item.province})
            </foreach>
    </insert>
    <insert id="insertChannelMmsProvinceGroupData" useGeneratedKeys="true" keyProperty="id" parameterType="cn.roadm.bo.SpChannelProvinceConfig">
        insert into mms_province_group_config (group_id,mobilechannel,unicomchannel,telecomchannel,province) values
        <foreach collection="list" item="item" separator=",">
            (#{item.groupId}, #{item.mobilechannel}, #{item.unicomchannel}, #{item.telecomchannel}, #{item.province})
        </foreach>
    </insert>
    <insert id="insertChannelCityGroupData" useGeneratedKeys="true" keyProperty="id" parameterType="cn.roadm.bo.SpChannelProvinceConfig">
        insert into sms_city_group_config (group_id,mobilechannel,unicomchannel,telecomchannel,city) values
            <foreach collection="list" item="item" separator=",">
                (#{item.groupId}, #{item.mobilechannel}, #{item.unicomchannel}, #{item.telecomchannel}, #{item.city})
            </foreach>
    </insert>
    <delete id="deleteChannelProvinceGroup" parameterType="cn.roadm.bo.SpChannelProvinceGroupData">
        delete from sms_province_group_config where group_id = #{groupId}
    </delete>
    <delete id="deleteChannelMmsProvinceGroup" parameterType="cn.roadm.bo.SpChannelProvinceGroupData">
        delete from mms_province_group_config where group_id = #{groupId}
    </delete>
    <delete id="deleteChannelCityGroup" parameterType="cn.roadm.bo.SpChannelProvinceGroupData">
        delete from sms_city_group_config where group_id = #{groupId}
    </delete>

    <insert id="insertProcinceGroupConfig" useGeneratedKeys="true" keyProperty="id"  parameterType="cn.roadm.bo.SmsProvinceGroup">
    	insert into sms_province_group_config(group_id,mobilechannel,unicomchannel,telecomchannel,province)
    	values(#{group_id},#{mobilechannel},#{unicomchannel},#{telecomchannel},#{province})
    </insert>

    <insert id="insertMmsProcinceGroupConfig" useGeneratedKeys="true" keyProperty="id"  parameterType="cn.roadm.bo.MmsProvinceGroup">
        insert into mms_province_group_config(group_id,mobilechannel,unicomchannel,telecomchannel,province)
        values(#{group_id},#{mobilechannel},#{unicomchannel},#{telecomchannel},#{province})
    </insert>
    <delete id="delProcinceGroupConfig">
    	delete from sms_province_group_config where id=#{id}
    </delete>
    <update id="updateProGroConfig" parameterType="cn.roadm.bo.SmsProvinceGroup">
    	update sms_province_group_config set mobilechannel=#{mobilechannel},unicomchannel=#{unicomchannel},
    	telecomchannel=#{telecomchannel} where id=#{id}
    </update>
    <update id="updateMmsProGroConfig" parameterType="cn.roadm.bo.MmsProvinceGroup">
        update mms_province_group_config set mobilechannel=#{mobilechannel},unicomchannel=#{unicomchannel},
                                             telecomchannel=#{telecomchannel} where id=#{id}
    </update>

    <update id="updateProGroConfigByGroupId" parameterType="cn.roadm.bo.SmsProvinceGroup">
        update sms_province_group_config
        <set>
            <if test = "mobilechannel != null">
                mobilechannel=#{mobilechannel},
            </if>
            <if test = "unicomchannel != null">
                unicomchannel=#{unicomchannel},
            </if>
            <if test = "telecomchannel != null">
                telecomchannel=#{telecomchannel},
            </if>
        </set>
        where group_id=#{group_id} and province = #{province}
    </update>

    <update id="updateCityGroConfig" parameterType="cn.roadm.bo.SmsCityGroup">
        update sms_city_group_config
        <set>
            <if test = "mobilechannel != null">
                mobilechannel=#{mobilechannel},
            </if>
            <if test = "unicomchannel != null">
                unicomchannel=#{unicomchannel},
            </if>
            <if test = "telecomchannel != null">
                telecomchannel=#{telecomchannel},
            </if>
        </set>
        where group_id=#{group_id} and city = #{city}
    </update>

     <select id="getProvinceGroupById" resultType="cn.roadm.bo.SmsProvinceGroup">
    	select id,name,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`status` from sms_province_group
    	<where>
    		status=1 and id=#{id}
    	</where>
    </select>
    <select id="getMmsProvinceGroupById" resultType="cn.roadm.bo.MmsProvinceGroup">
        select id,name,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`status` from mms_province_group
        <where>
            status=1 and id=#{id}
        </where>
    </select>
    <select id="getMmsProvinceGroupAll" resultType="cn.roadm.bo.MmsProvinceGroup">
        select id,name,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`status` from mms_province_group
        <where>
            status=1
        </where>
    </select>
     <select id="getProvinceGroupAll" resultType="cn.roadm.bo.SmsProvinceGroup">
    	select id,name,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`status` from sms_province_group
    	<where>
    		status=1
    	</where>
    </select>
    <select id="getCityGroupAll" resultType="cn.roadm.bo.SmsCityGroup">
    	select id,name,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`status` from sms_city_group
    	<where>
    		status=1
    	</where>
    </select>
    <update id="updateProGro" parameterType="cn.roadm.bo.SmsProvinceGroup">
    	update sms_province_group set name=#{name} where id=#{group_id}
    </update>
    <update id="updateMmsProGro" parameterType="cn.roadm.bo.MmsProvinceGroup">
        update mms_province_group set name=#{name} where id=#{group_id}
    </update>
    <update id="updateSpInfoProvinceg" parameterType="spInfo">
    	update sms_sp_info set is_open_province_group=#{isOpenProvinceGroup},pro_group_id=#{proGroupId} where id=#{spid}
    </update>
    <update id="updateSpInfoMmsProvinceg" parameterType="spInfo">
        update sms_sp_info set is_open_mms_province_group=#{isOpenMmsProvinceGroup},mms_pro_group_id=#{mmsProvinceGroupId} where id=#{spid}
    </update>

    <select id="listPageSmsPhoneChannel" parameterType="SmsPhoneChannel" resultType="SmsPhoneChannel">
    	select id,spid,mdn,channel,oldtype,newtype,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`status` from sms_phone_channel
    	<where>
    		<if test="spid!=null and spid>=0">
    			and spid=#{spid}
    		</if>
    		<if test="mdn!=null and mdn!=''">
    			and mdn=#{mdn}
    		</if>
    		<if test="channel!=null and channel!='' and channel!='-1'">
    			and channel=#{channel}
    		</if>
    		<if test="status!=null and status!=''">
    			and status=#{status}
    		</if>
    	</where>
    </select>

    <select id="listPageMmsPhoneChannel" parameterType="MmsPhoneChannel" resultType="MmsPhoneChannel">
        select id,spid,mdn,channel,oldtype,newtype,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`status` from mms_phone_channel
        <where>
            <if test="spid!=null and spid>=0">
                and spid=#{spid}
            </if>
            <if test="mdn!=null and mdn!=''">
                and mdn=#{mdn}
            </if>
            <if test="channel!=null and channel!='' and channel!='-1'">
                and channel=#{channel}
            </if>
            <if test="status!=null and status!=''">
                and status=#{status}
            </if>
        </where>
    </select>

    <select id="listSmsPhoneChannel" parameterType="SmsPhoneChannel" resultType="SmsPhoneChannel">
        select id,spid,mdn,channel,oldtype,newtype,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`status` from sms_phone_channel
        <where>
            <if test="spid!=null and spid>=0">
                and spid=#{spid}
            </if>
            <if test="mdn!=null and mdn!=''">
                and mdn=#{mdn}
            </if>
            <if test="channel!=null and channel!='' and channel!='-1'">
                and channel=#{channel}
            </if>
            <if test="status!=null and status!=''">
                and status=#{status}
            </if>
        </where>
    </select>

     <select id="getSmsPhoneChannelById" resultType="SmsPhoneChannel">
    	select id,spid,mdn,channel,oldtype,newtype,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`status` from sms_phone_channel
    	where id=#{id}

    </select>

    <select id="getMmsPhoneChannelById" resultType="MmsPhoneChannel">
        select id,spid,mdn,channel,oldtype,newtype,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`status` from mms_phone_channel
        where id=#{id}

    </select>
    <insert id="insertSmsPhoneChannel" useGeneratedKeys="true" keyProperty="id"  parameterType="SmsPhoneChannel">
    	insert into sms_phone_channel(spid,mdn,channel,oldtype,newtype,createtime,`status`) values(#{spid},#{mdn},#{channel},#{oldtype},
    	#{newtype},now(),#{status})
    </insert>
    <insert id="insertMmsPhoneChannel" useGeneratedKeys="true" keyProperty="id"  parameterType="MmsPhoneChannel">
        insert into mms_phone_channel(spid,mdn,channel,oldtype,newtype,createtime,`status`) values(#{spid},#{mdn},#{channel},#{oldtype},
                                                                                                   #{newtype},now(),#{status})
    </insert>

    <update id="updateSmsPhoneChannelByMdn" parameterType="SmsPhoneChannel">
        update sms_phone_channel
        <set>
            <if test="channel!=null and channel!=''">
                channel=#{channel},
            </if>
        </set>
        where mdn=#{mdn}
    </update>

    <update id="updateSmsPhoneChannel" parameterType="SmsPhoneChannel">
    	update sms_phone_channel
    	<set>
    		<if test="spid!=null and spid!=''">
    		spid=#{spid},
	    	</if>
	    	<if test="mdn!=null and mdn!=''">
	    		mdn=#{mdn},
	    	</if>
	    	<if test="channel!=null and channel!=''">
	    		channel=#{channel},
	    	</if>
	    	<if test="newtype!=null and newtype!=''">
	    		newtype=#{newtype},
	    	</if>
	    	<if test="oldtype!=null and oldtype!=''">
	    		oldtype=#{oldtype},
	    	</if>
	    		`status`=#{status}
    	</set>
    	<where>
    		<if test="id!=null and id>0">
    	 		and id=#{id}
    		</if>
	    	<if test="starttime!=null and starttime!=''">
	    		and createtime &gt; #{starttime}
	    	</if>
	    	<if test="endtime!=null and endtime!=''">
	    		and createtime &lt; #{endtime}
	    	</if>
    	</where>
    </update>
    <update id="updateMmsPhoneChannel" parameterType="MmsPhoneChannel">
        update mms_phone_channel
        <set>
            <if test="spid!=null and spid!=''">
                spid=#{spid},
            </if>
            <if test="mdn!=null and mdn!=''">
                mdn=#{mdn},
            </if>
            <if test="channel!=null and channel!=''">
                channel=#{channel},
            </if>
            <if test="newtype!=null and newtype!=''">
                newtype=#{newtype},
            </if>
            <if test="oldtype!=null and oldtype!=''">
                oldtype=#{oldtype},
            </if>
            `status`=#{status}
        </set>
        <where>
            <if test="id!=null and id>0">
                and id=#{id}
            </if>
            <if test="starttime!=null and starttime!=''">
                and createtime &gt; #{starttime}
            </if>
            <if test="endtime!=null and endtime!=''">
                and createtime &lt; #{endtime}
            </if>
        </where>
    </update>
    <delete id="delSmsPhoneChannel">
    	delete from sms_phone_channel where id=#{id}
    </delete>
    <delete id="delMmsPhoneChannel">
        delete from mms_phone_channel where id=#{id}
    </delete>


      <select id="listPageSpMontiorSum" parameterType="TaskInfo"
        resultMap="taskResultMap">
        select sp.id sp_id,
        sp.sp_name,
        sum(tk.allnumber) allnumber,
        sum(tk.succ) succ,
        sum(IFNULL(tk.fail,0)) fail,
        sum(tk.arrive_succ) arrive_succ,
        <!-- sum(tk.allnumber-asa.total-tk.arrive_succ-tk.arrive_fail) unRecMsgnum, -->
        sum(tk.arrive_fail) arrive_fail,
        tk.stat_time
        from sms_sp_info sp left join  sms_sp_montior_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="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 sp.id, sp.sp_name
        <if test="is_summary!=1">
        	,tk.stat_time
        </if>
        order by sum(tk.allnumber) desc

    </select>


     <select id="listSpMontiorSumCount" parameterType="TaskInfo"
        resultMap="taskResultMap">
        select
        sum(IFNULL(tk.allnumber,0)) allnumber,
        sum(IFNULL(tk.succ,0)) succ,
        sum(IFNULL(tk.fail,0)) fail,
        sum(IFNULL(tk.arrive_succ,0)) arrive_succ,
        <!-- sum(IFNULL(tk.allnumber-tk.arrive_succ-tk.arrive_fail,0)) unRecMsgnum, -->
        sum(IFNULL(tk.allnumber,0))-sum(IFNULL(tk.arrive_succ,0))-sum(IFNULL(tk.arrive_fail,0)) unRecMsgnum,
        sum(IFNULL(tk.arrive_fail,0)) arrive_fail
        from sms_sp_montior_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="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="listPageChannelPrice" resultType="cn.roadm.bo.PriceRecord">
    	select id,channelid,price,DATE_FORMAT(createtime, '%Y-%m-%d') createtime,provinceNetPrice,province from sms_channel_price
    	<where>
    		<if test="channelid!=null and channelid!=''">
    			and channelid=#{channelid}
    		</if>
    		<if test="createtime!=null and createtime!=''">
    			and createtime &gt;= #{createtime}
    		</if>
    		<if test="createtime1!=null and createtime1!=''">
    			and createtime &lt;= #{createtime1}
    		</if>
    	</where>
    </select>

    <select id="listPageSpPrice" resultType="cn.roadm.bo.PriceRecord">
    	SELECT
				sg.*,
				if(sp.noProfit>0,ifnull( scp.price, 0 )* sg.succ,ifnull( spp.price, 0 )* sg.succ) income,
				if(sp.noProfit>0,ifnull( scp.price, 0 )* sg.unkonw,ifnull( spp.price, 0 )* sg.unkonw) un_income,
				scp.price cprice,
				spp.price sprice,
				ifnull( scp.price, 0 )* sg.succ cost,
				ifnull( scp.price, 0 )* sg.unkonw un_cost,
				scp.province,
				spp.id sppid,
				scp.id scpid,
				ssc.channel_name,
				sp.sp_name,
				sp.sp_type,
				date_format(sg.stat_time,'%Y-%m-%d') createtime
			FROM
				(
				SELECT
					sum(
					ifnull( sps.arrive_succ, 0 )) succ,
					sum(ifnull( sps.submit_succ, 0 )) +
					sum(ifnull( sps.submit_fail, 0 )) -
					sum(ifnull( sps.arrive_fail, 0 )) -
					sum(ifnull( sps.arrive_succ, 0 )) unkonw,
					sps.spid,
					sps.channelid,
					sps.stat_time
				FROM
					sms_sp_province_summary sps
				<where>
		    		<if test="spid!=null and spid!=''">
		    			and spid=#{spid}
		    		</if>
		    		<if test="createtime!=null and createtime!=''">
		    			and sps.stat_time &gt;= #{createtime}
		    		</if>
		    		<if test="createtime1!=null and createtime1!=''">
		    			and sps.stat_time &lt; DATE_ADD(str_to_date(#{createtime1},'%Y-%m-%d %H:%i:%s'),INTERVAL 1 DAY)
		    		</if>
		    		<if test="channelid!='' and channelid!=null">
		    			and sps.channelid=#{channelid}
		    		</if>
		    		and sps.spid>1
		    	</where>

				GROUP BY
					sps.spid,
					sps.channelid,
					sps.stat_time

				having sum(ifnull( sps.arrive_succ, 0 ))+sum(ifnull( sps.submit_succ, 0 )) +
					sum(ifnull( sps.submit_fail, 0 )) -
					sum(ifnull( sps.arrive_fail, 0 )) -
					sum(ifnull( sps.arrive_succ, 0 )) >= 0

				) sg left join sms_sp_price spp on
				spp.spid = sg.spid and sg.stat_time =spp.createtime
				left join sms_channel_price scp on
				scp.channelid = sg.channelid and sg.stat_time = scp.createtime
				left join sms_sp_info sp on sg.spid=sp.id left join sms_send_channel_info ssc on sg.channelid=ssc.id
				where scp.province is null
				UNION All
				SELECT
				sg.*,
				if(sp.noProfit>0,ifnull( scp.price, 0 )* sg.succ,ifnull( spp.price, 0 )* sg.succ) income,
				if(sp.noProfit>0,ifnull( scp.price, 0 )* sg.unkonw,ifnull( spp.price, 0 )* sg.unkonw) un_income,
				scp.price cprice,
				spp.price sprice,
				ifnull( scp.price, 0 )* sg.succ cost,
				ifnull( scp.price, 0 )* sg.unkonw un_cost,
				scp.province,
				spp.id sppid,
				scp.id scpid,
				ssc.channel_name,
				sp.sp_name,
				sp.sp_type,
				date_format(sg.stat_time,'%Y-%m-%d') createtime
			FROM
				(
				SELECT
					sum(
					ifnull( sps.arrive_succ, 0 )) succ,
					sum(ifnull( sps.submit_succ, 0 )) +
					sum(ifnull( sps.submit_fail, 0 )) -
					sum(ifnull( sps.arrive_fail, 0 )) -
					sum(ifnull( sps.arrive_succ, 0 )) unkonw,
					sps.spid,
					sps.channelid,
					sps.stat_time
				FROM
					sms_sp_province_summary sps
				<where>
		    		<if test="spid!=null and spid!=''">
		    			and spid=#{spid}
		    		</if>
		    		<if test="createtime!=null and createtime!=''">
		    			and sps.stat_time &gt;= #{createtime}
		    		</if>
		    		<if test="createtime1!=null and createtime1!=''">
		    			and sps.stat_time &lt; DATE_ADD(str_to_date(#{createtime1},'%Y-%m-%d %H:%i:%s'),INTERVAL 1 DAY)
		    		</if>
		    		<if test="channelid!='' and channelid!=null">
		    			and sps.channelid=#{channelid}
		    		</if>
		    		and sps.spid>1
		    	</where>

				GROUP BY
					sps.spid,
					sps.channelid,
					sps.stat_time

				having sum(ifnull( sps.arrive_succ, 0 ))+sum(ifnull( sps.submit_succ, 0 )) +
					sum(ifnull( sps.submit_fail, 0 )) -
					sum(ifnull( sps.arrive_fail, 0 )) -
					sum(ifnull( sps.arrive_succ, 0 )) >= 0

				) sg left join sms_sp_price spp on
				spp.spid = sg.spid and sg.stat_time =spp.createtime
				left join sms_channel_price scp on
				scp.channelid = sg.channelid and sg.stat_time = scp.createtime
				left join sms_sp_info sp on sg.spid=sp.id left join sms_send_channel_info ssc on sg.channelid=ssc.id
				where scp.province is not null

    </select>

    <select id="getByCountSpPrice" resultType="int">
    	select count(1) from sms_sp_price where spid=#{spid} and createtime = #{createtime}
    </select>

     <select id="getByCountChannelPrice" resultType="int">
    	select count(1) from sms_channel_price where channelid=#{channelid} and createtime = #{createtime}
    </select>

     <select id="getSpPriceById" resultType="cn.roadm.bo.PriceRecord">
    	select id,spid,price,DATE_FORMAT(createtime, '%Y-%m-%d') createtime,provinceNetPrice from
    	sms_sp_price where id=#{id}
    </select>

     <select id="getChannelPriceById" resultType="cn.roadm.bo.PriceRecord">
    	select id,channelid,price,DATE_FORMAT(createtime, '%Y-%m-%d') createtime,province,provinceNetPrice from sms_channel_price where id=#{id}
    </select>

    <update id="updateSpPrice" parameterType="cn.roadm.bo.PriceRecord">
    	update sms_sp_price set price=#{price,jdbcType=INTEGER}*10000,provinceNetPrice=#{provinceNetPrice,jdbcType=INTEGER}*10000 where id=#{id}
    </update>

     <update id="updateChannelPriceRecord" parameterType="cn.roadm.bo.PriceRecord">
    	update sms_channel_price set price=#{price,jdbcType=INTEGER}*10000,provinceNetPrice=#{provinceNetPrice,jdbcType=INTEGER}*10000 where id=#{id}
    </update>
    <insert id="insertSpPriceRecord" parameterType="cn.roadm.bo.PriceRecord">
    	insert into sms_sp_price(spid,createtime,price,provinceNetPrice)
    	 values(#{spid},#{createtime},#{price,jdbcType=INTEGER}*10000,#{provinceNetPrice,jdbcType=INTEGER}*10000)
    </insert>
    <insert id="insertChannelPriceRecord" parameterType="cn.roadm.bo.PriceRecord">
    	insert into sms_channel_price(channelid,createtime,price,provinceNetPrice)
    	 values(#{channelid},#{createtime},#{price,jdbcType=INTEGER}*10000,#{provinceNetPrice,jdbcType=INTEGER}*10000)
    </insert>

    <select id="getSpChannelProvinceCount" parameterType="cn.roadm.bo.SpChannelProvinceConfig"
            resultType="java.lang.Integer">
        select count(1) from sms_channel_province_config where SPID = #{spId} and PROVINCE = #{province}
    </select>

    <update id="updateSpChannelProvinceConfigById" parameterType="cn.roadm.bo.SpChannelProvinceConfig">
        update  sms_channel_province_config
        set province=#{province},mobilechannel=#{mobilechannel},unicomchannel=#{unicomchannel},telecomchannel=#{telecomchannel} where spId = #{spId} and id=#{id}
    </update>

    <update id="updateSpChannelProvinceGroupName" parameterType="cn.roadm.bo.SpChannelProvinceGroupData">
        update sms_province_group set name=#{groupName} where id=#{groupId}
    </update>

    <update id="updateSpChannelMmsProvinceGroupName" parameterType="cn.roadm.bo.SpChannelProvinceGroupData">
        update mms_province_group set name=#{groupName} where id=#{groupId}
    </update>

    <update id="updateSpChannelCityGroupName" parameterType="cn.roadm.bo.SpChannelProvinceGroupData">
        update sms_province_group set name=#{groupName} where id=#{groupId}
    </update>

    <delete id="deleteSpChannelAllProvinceConfig" parameterType="cn.roadm.bo.SpChannelProvinceAddData">
        delete from sms_channel_province_config where SPID = #{spId}
    </delete>

    <delete id="deleteSpMmsChannelAllProvinceConfig" parameterType="cn.roadm.bo.SpChannelProvinceAddData">
        delete from mms_channel_province_config where SPID = #{spId}
    </delete>

    <update id="bitchUpdatePriceBySp" parameterType="cn.roadm.bo.BitchUpdatePriceVO">
        update sms_sp_price
        <trim prefix="set" suffixOverrides=",">
            <if test="price != null">
                price= #{price,jdbcType=INTEGER}*10000,
            </if>
            <if test="provinceNetPrice != null">
                provinceNetPrice= #{provinceNetPrice,jdbcType=INTEGER}*10000
            </if>
        </trim>
        <where>
            <if test="startTime != null and startTime != ''">
                and createtime &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and createtime &lt;= DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
            and spid in
            <foreach collection="list" item="item" separator="," open="(" close=")">
                #{item}
            </foreach>
        </where>
    </update>

    <update id="bitchUpdatePriceBySpNew" parameterType="cn.roadm.bo.BitchUpdatePriceVO">
        update sms_sp_province_summary
        <trim prefix="set" suffixOverrides=",">
            <if test="price != null">
                sp_price= #{price,jdbcType=INTEGER}*10000,
            </if>
        </trim>
        <where>
            <if test="startTime != null and startTime != ''">
                and stat_time &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and stat_time &lt; DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
            <if test="otype!=null and otype>0 and nettype!=1">
            	and otype=#{otype}
            </if>
             <if test="nettype >=0">
                and ifnull(nettype,0)=#{nettype}
            </if>
            and spid in
            <foreach collection="list" item="item" separator="," open="(" close=")">
                #{item}
            </foreach>
        </where>
    </update>

    <update id="bitchUpdateMmsPriceBySpNew" parameterType="cn.roadm.bo.BitchUpdatePriceVO">
        update mms_sp_province_summary
        <trim prefix="set" suffixOverrides=",">
            <if test="price != null">
                sp_price= #{price,jdbcType=INTEGER}*10000,
            </if>
        </trim>
        <where>
            <if test="startTime != null and startTime != ''">
                and stat_time &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and stat_time &lt; DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
            <if test="otype!=null and otype>0 and nettype!=1">
            	and otype=#{otype}
            </if>
             <if test="nettype >=0">
                and ifnull(nettype,0)=#{nettype}
            </if>
            and spid in
            <foreach collection="list" item="item" separator="," open="(" close=")">
                #{item}
            </foreach>
        </where>
    </update>

    <update id="updatePriceBySpNew" parameterType="cn.roadm.bo.BitchUpdatePriceVO">
        update sms_sp_province_summary
        <trim prefix="set" suffixOverrides=",">
            <if test="price != null">
                sp_price= #{price,jdbcType=INTEGER}*10000,
            </if>
            <if test="nettype >=0">
                nettype=#{nettype}
            </if>
        </trim>
        <where>
        	spid =#{spid}
            <if test="startTime != null and startTime != ''">
                and stat_time &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and stat_time &lt; DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
             <if test="nettype ==1">
                and province=#{province}
            </if>
        </where>
    </update>

    <update id="updateMmsPriceBySpNew" parameterType="cn.roadm.bo.BitchUpdatePriceVO">
        update mms_sp_province_summary
        <trim prefix="set" suffixOverrides=",">
            <if test="price != null">
                sp_price= #{price,jdbcType=INTEGER}*10000,
            </if>
            <if test="nettype >=0">
                nettype=#{nettype}
            </if>
        </trim>
        <where>
        	spid =#{spid}
            <if test="startTime != null and startTime != ''">
                and stat_time &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and stat_time &lt; DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
             <if test="nettype ==1">
                and province=#{province}
            </if>
        </where>
    </update>

    <update id="bitchUpdatePriceByChannel" parameterType="cn.roadm.bo.BitchUpdatePriceVO">
        update sms_channel_price
        <trim prefix="set" suffixOverrides=",">
            <if test="price != null">
                price= #{price,jdbcType=INTEGER}*10000,
            </if>
            <if test="provinceNetPrice != null">
                provinceNetPrice= #{provinceNetPrice,jdbcType=INTEGER}*10000
            </if>
        </trim>
        <where>
            <if test="startTime != null and startTime != ''">
                and createtime &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and createtime &lt;= DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
            <if test="otype!=null and otype>0  and nettype!=1">
            	and otype=#{otype}
            </if>
            and channelid in
            <foreach collection="list" item="item" separator="," open="(" close=")">
                #{item}
            </foreach>
        </where>
    </update>

    <update id="bitchUpdatePriceByChannelNew" parameterType="cn.roadm.bo.BitchUpdatePriceVO">
        update sms_sp_province_summary
        <trim prefix="set" suffixOverrides=",">
            <if test="price != null">
                channel_price= #{price,jdbcType=INTEGER}*10000,
            </if>

        </trim>
        <where>
            <if test="startTime != null and startTime != ''">
                and stat_time &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and stat_time &lt;DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
           <if test="nettype >=0">
                and ifnull(nettype,0)=#{nettype}
            </if>
            <if test="otype!=null and otype>0">
            	and otype=#{otype}
            </if>
            and channelid in
            <foreach collection="list" item="item" separator="," open="(" close=")">
                #{item}
            </foreach>
        </where>
    </update>

    <update id="bitchUpdateMmsPriceByChannelNew" parameterType="cn.roadm.bo.BitchUpdatePriceVO">
        update mms_sp_province_summary
        <trim prefix="set" suffixOverrides=",">
            <if test="price != null">
                channel_price= #{price,jdbcType=INTEGER}*10000,
            </if>

        </trim>
        <where>
            <if test="startTime != null and startTime != ''">
                and stat_time &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and stat_time &lt;DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
           <if test="nettype >=0">
                and ifnull(nettype,0)=#{nettype}
            </if>
            <if test="otype!=null and otype>0">
            	and otype=#{otype}
            </if>
            and channelid in
            <foreach collection="list" item="item" separator="," open="(" close=")">
                #{item}
            </foreach>
        </where>
    </update>

    <update id="updatePriceByChannelNew" parameterType="cn.roadm.bo.BitchUpdatePriceVO">
        update sms_sp_province_summary
        <trim prefix="set" suffixOverrides=",">
            <if test="price != null">
                channel_price= #{price,jdbcType=INTEGER}*10000,
            </if>
 			<if test="nettype >=0">
                nettype=#{nettype}
            </if>
        </trim>
        <where>
       		channelid =#{channelid}
            <if test="startTime != null and startTime != ''">
                and stat_time &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and stat_time &lt;DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
           <if test="nettype ==1">
                and province=#{province}
            </if>

        </where>
    </update>

    <update id="updateMmsPriceByChannelNew" parameterType="cn.roadm.bo.BitchUpdatePriceVO">
        update mms_sp_province_summary
        <trim prefix="set" suffixOverrides=",">
            <if test="price != null">
                channel_price= #{price,jdbcType=INTEGER}*10000,
            </if>
 			<if test="nettype >=0">
                nettype=#{nettype}
            </if>
        </trim>
        <where>
       		channelid =#{channelid}
            <if test="startTime != null and startTime != ''">
                and stat_time &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and stat_time &lt;DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
           <if test="nettype ==1">
                and province=#{province}
            </if>

        </where>
    </update>

    <update id="bitchUpdateCommissionPrice">
        update sms_sp_info set commission_price = #{commissionPrice} * 10000  <where>
        id in
        <foreach collection="list" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
    </where>
    </update>

    <select id="listPageQueryChannelTestAlarmList" resultType="cn.roadm.bo.ChannelReduceAlarmRecord">
        select id,taskid as taskId,DATE_FORMAT(sendTime,'%Y-%m-%d %H:%i:%s') as sendTime,status,ischeck as isCheck,error_phones as errorPhones,
        DATE_FORMAT(checkTime,'%Y-%m-%d %H:%i:%s') as checkTime,channelId,type from channel_reduce_record
        <where>
            <if test="id != null and id > 0">
                id = #{id}
            </if>
            <if test="type != null">
                and type = #{type}
            </if>
            <if test="startTime != null and startTime != ''">
                and checkTime &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and checkTime &lt;= DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
        </where>
        order by sendTime desc
    </select>

    <select id="listPageChannelTemplate" resultType="ChannelTemplate">
    	select id,template_id,channelid,content,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`name`,status,reason,local_template from channel_template
    	<where>
    		<if test="template_id!=null and template_id!=''">
    			and template_id=#{template_id}
    		</if>
    		<if test="channelid!=null and channelid!=''">
    			and channelid=#{channelid}
    		</if>
    		<if test="content!=null and content!=''">
    			and content like concat('%',#{content},'%')
    		</if>
    		<if test="local_template!=null and local_template!=''">
    			and content like concat('%',#{content},'%')
    		</if>
    		<if test="name!=null and name!=''">
    			and name like concat('%',#{name},'%')
    		</if>
    		<if test="startTime != null and startTime != ''">
                and createtime &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="status!=null and status!=''">
            	and status=#{status}
            </if>
            <if test="endTime != null and endTime != ''">
                and createtime &lt;= DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
    	</where>
    	order by createtime desc
    </select>

    <select id="listPageChanelSignId" resultType="ChanelSignId">
    	select id,signid,channelid,sign,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime from channel_sign_id
    	<where>
    		<if test="signid!=null and signid!=''">
    			and signid=#{signid}
    		</if>
    		<if test="sign!=null and sign!=''">
    			and sign like concat ('%',#{sign},'%')
    		</if>
    		<if test="channelid!=null and channelid!=''">
    			and channelid=#{channelid}
    		</if>
    		<if test="startTime != null and startTime != ''">
                and createtime &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and createtime &lt;= DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
    	</where>
    	order by createtime desc
    </select>

    <select id="listPageSmsChanelSignId" resultType="ChanelSignId">
    	select id,signid,channelid,sign,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime from sms_channel_sign_id
    	<where>
    		<if test="signid!=null and signid!=''">
    			and signid=#{signid}
    		</if>
    		<if test="sign!=null and sign!=''">
    			and sign like concat ('%',#{sign},'%')
    		</if>
    		<if test="channelid!=null and channelid!=''">
    			and channelid=#{channelid}
    		</if>
    		<if test="startTime != null and startTime != ''">
                and createtime &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and createtime &lt;= DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
    	</where>
    	order by createtime desc
    </select>

    <select id="listPageChannelAimId" resultType="cn.roadm.bo.ChannelAimId">
    	select id,channel_id as channelId,aim_content as aimContent,aim_id as aimId,mms_template_id as mmsTemplateId,
        DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`type` from channel_aim_id
    	<where>
    		<if test="aimId!=null and aimId!=''">
    			and aim_id=#{aimId}
    		</if>
    		<if test="aimContent!=null and aimContent!=''">
    			and aim_content like concat ('%',#{aimContent},'%')
    		</if>
    		<if test="channelId!=null and channelId!=''">
    			and channel_id=#{channelId}
    		</if>
    		<if test="mmsTemplateId != null and mmsTemplateId != ''">
                and mms_template_id =#{mmsTemplateId}
            </if>
            <if test="type != null and type != ''">
                and `type` = #{type}
            </if>
    	</where>
    	order by createtime desc
    </select>

    <select id="listPageChannelHuiluoConfig" resultType="cn.roadm.bo.ChannelHuiluoConfig">
    	select id,
        channel_id as channelId,
        chatbot as chatbot,
        template_id as templateId,
        sms_template_id as smsTemplateId,
        aim_template_id as aimTemplateId,
        mms_template_id as mmsTemplateId,
        DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,
        `type`
        from channel_huiluo_config
    	<where>
    		<if test="aimTemplateId!=null and aimTemplateId!=''">
    			and aim_template_id=#{aimTemplateId}
    		</if>
    		<if test="channelId!=null and channelId!=''">
    			and channel_id=#{channelId}
    		</if>
    		<if test="mmsTemplateId != null and mmsTemplateId != ''">
                and mms_template_id =#{mmsTemplateId}
            </if>
            <if test="templateId != null and templateId != ''">
                and template_id =#{templateId}
            </if>
            <if test="smsTemplateId != null and smsTemplateId != ''">
                and sms_template_id =#{smsTemplateId}
            </if>
            <if test="type != null and type != ''">
                and `type` = #{type}
            </if>
            <if test="chatbot != null and chatbot != ''">
                and chatbot like concat ('%',#{chatbot},'%')
            </if>
    	</where>
    	order by createtime desc
    </select>

    <update id="updateChannelHuiluoConfig">
        update channel_huiluo_config set chatbot = #{chatbot},channel_id = #{channelId},template_id = #{templateId},sms_template_id = #{smsTemplateId},
        aim_template_id = #{aimTemplateId},mms_template_id = #{mmsTemplateId} where id=#{id}
    </update>

    <select id="getChannelHuiluoConfigByTemplateId" resultType="cn.roadm.bo.ChannelHuiluoConfig">
        select id,
        channel_id as channelId,
        template_id as templateId,
        sms_template_id as smsTemplateId,
        aim_template_id as aimTemplateId,
        mms_template_id as mmsTemplateId,
        chatbot as chatbot,
        DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,
        `type`
        from channel_huiluo_config where template_id =#{templateId}
    </select>

    <select id="getChannelHuiluoConfigById" resultType="cn.roadm.bo.ChannelHuiluoConfig">
        select id,
        channel_id as channelId,
        template_id as templateId,
        sms_template_id as smsTemplateId,
        aim_template_id as aimTemplateId,
        mms_template_id as mmsTemplateId,
        chatbot as chatbot,
        DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,
        `type`
        from channel_huiluo_config where id =#{id}
    </select>

    <insert id="insertChannelHuiluoConfig">
        insert into channel_huiluo_config (chatbot,channel_id,template_id,sms_template_id,aim_template_id,mms_template_id,createtime,type)
        value(#{chatbot},#{channelId},#{templateId},#{smsTemplateId},#{aimTemplateId},#{mmsTemplateId},now(),#{type})
    </insert>


    <select id="listPageChanelChatbot" resultType="cn.roadm.bo.ChannelSignChatbot">
        select id,channelid,sign,chatbot,csptoken,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime ,status from mms_channel_sign_chatbot
        <where>
            <if test="sign!=null and sign!=''">
                and sign like concat ('%',#{sign},'%')
            </if>
            <if test="chatbot!=null and chatbot!=''">
                and chatbot like concat ('%',#{chatbot},'%')
            </if>
            <if test="channelid!=null and channelid!=''">
                and channelid=#{channelid}
            </if>
            <if test="startTime != null and startTime != ''">
                and createtime &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and createtime &lt;= DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
        </where>
        order by createtime desc
    </select>

    <select id="listPageChanelChatbot2" resultType="cn.roadm.bo.ChannelSignChatbot">
        select id,channelid,sign,chatbot,csptoken,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,status from sms_channel_sign_chatbot
        <where>
            <if test="sign!=null and sign!=''">
                and sign like concat ('%',#{sign},'%')
            </if>
            <if test="chatbot!=null and chatbot!=''">
                and chatbot like concat ('%',#{chatbot},'%')
            </if>
            <if test="channelid!=null and channelid!=''">
                and channelid=#{channelid}
            </if>
            <if test="startTime != null and startTime != ''">
                and createtime &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and createtime &lt;= DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
        </where>
        order by createtime desc
    </select>

    <select id="listChanelChatbot2" resultType="cn.roadm.bo.ChannelSignChatbot">
        select id,channelid,sign,chatbot,csptoken,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,status from sms_channel_sign_chatbot
        <where>
            <if test="sign!=null and sign!=''">
                and sign like concat ('%',#{sign},'%')
            </if>
            <if test="chatbot!=null and chatbot!=''">
                and chatbot like concat ('%',#{chatbot},'%')
            </if>
            <if test="channelid!=null and channelid!=''">
                and channelid=#{channelid}
            </if>
            <if test="startTime != null and startTime != ''">
                and createtime &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and createtime &lt;= DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
        </where>
        order by createtime desc
    </select>

    <select id="listPageChanelTelecomChatbot" resultType="cn.roadm.bo.ChannelSignChatbot">
        select id,channelid,sign,chatbot,appId,appKey,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,status from sms_channel_sign_telecom_unicom_chatbot
        <where>
            <if test="sign!=null and sign!=''">
                and sign like concat ('%',#{sign},'%')
            </if>
            <if test="chatbot!=null and chatbot!=''">
                and chatbot like concat ('%',#{chatbot},'%')
            </if>
            <if test="channelid!=null and channelid!=''">
                and channelid=#{channelid}
            </if>
            <if test="startTime != null and startTime != ''">
                and createtime &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and createtime &lt;= DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>

        </where>
        order by createtime desc
    </select>

    <select id="listChanelTelecomChatbot" resultType="cn.roadm.bo.ChannelSignChatbot">
        select id,channelid,sign,chatbot,appId,appKey,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,status from sms_channel_sign_telecom_unicom_chatbot
        <where>
            <if test="sign!=null and sign!=''">
                and sign like concat ('%',#{sign},'%')
            </if>
            <if test="chatbot!=null and chatbot!=''">
                and chatbot like concat ('%',#{chatbot},'%')
            </if>
            <if test="channelid!=null and channelid!=''">
                and channelid=#{channelid}
            </if>
            <if test="startTime != null and startTime != ''">
                and createtime &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and createtime &lt;= DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>

        </where>
        order by createtime desc
    </select>

    <select id="listPageChanelTelecomChatbotMms" resultType="cn.roadm.bo.ChannelSignChatbot">
        select id,channelid,sign,chatbot,appId,appKey,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,status from mms_channel_sign_telecom_unicom_chatbot
        <where>
            <if test="sign!=null and sign!=''">
                and sign like concat ('%',#{sign},'%')
            </if>
            <if test="chatbot!=null and chatbot!=''">
                and chatbot like concat ('%',#{chatbot},'%')
            </if>
            <if test="channelid!=null and channelid!=''">
                and channelid=#{channelid}
            </if>
            <if test="startTime != null and startTime != ''">
                and createtime &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and createtime &lt;= DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>

        </where>
        order by createtime desc
    </select>

    <select id="getChannelTemplateById" resultType="ChannelTemplate">
    	select id,template_id,channelid,content,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`name` from channel_template where id =#{id}
    </select>

     <select id="getChannelTemplateByTid" resultType="ChannelTemplate">
    	select id,template_id,channelid,content,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`name` from channel_template where channelid =#{channelid} and template_id=#{template_id} and id!=#{id} limit 1
    </select>

    <insert id="insertChannelTemplate">
    	insert into channel_template(template_id,channelid,content,createtime,`name`)
    	values(#{template_id},#{channelid},#{content},now(),#{name})
    </insert>

    <update id="updateChannelTemplate" >
    	update channel_template set template_id=#{template_id},channelid=#{channelid},content=#{content},name=#{name}
    	where id=#{id}
    </update>

    <delete id="delChannelTenplate">
    	delete from channel_template where id =#{id}
    </delete>

    <select id="getMmsSignIdById" resultType="ChanelSignId">
    	select id,signid,channelid,sign,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime from channel_sign_id where id =#{id}
    </select>

    <select id="getSmsSignIdById" resultType="ChanelSignId">
    	select id,signid,channelid,sign,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime from sms_channel_sign_id where id =#{id}
    </select>

    <select id="getMmsAimIdById" resultType="cn.roadm.bo.ChannelAimId">
    	select  id,channel_id as channelId,aim_content as aimContent,aim_id as aimId,mms_template_id as mmsTemplateId,
        DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`type` from channel_aim_id where id =#{id}
    </select>

    <select id="getMmsAimIdByMmsTempId" resultType="cn.roadm.bo.ChannelAimId">
    	select  id,channel_id as channelId,aim_content as aimContent,aim_id as aimId,mms_template_id as mmsTemplateId,
        DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`type` from channel_aim_id where mms_template_id =#{mmsTemplateId} and channel_id = #{channelId}
    </select>

    <select id="getMmsSignIdBySign" resultType="ChanelSignId">
    	select id,signid,channelid,sign,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime from channel_sign_id where channelid=#{channelid} and sign=#{sign}
    	<if test="id!=null and id!=''">
    	 	and id!=#{id}
    	</if>
    	limit 1
    </select>

    <select id="getMmsSignIdBySignId" resultType="ChanelSignId">
    	select id,signid,channelid,sign,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime from channel_sign_id
        where channelid=#{channelid} and signid=#{signid}
    	limit 1
    </select>

    <select id="getSmsSignIdBySignId" resultType="ChanelSignId">
    	select id,signid,channelid,sign,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime from sms_channel_sign_id
        where channelid=#{channelid} and signid=#{signid}
    	limit 1
    </select>

    <select id="getMmsSignIdBySignIdAndSign" resultType="ChanelSignId">
    	select id,signid,channelid,sign,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime from channel_sign_id
        where channelid=#{channelid} and signid=#{signid} and sign = #{sign}
    	limit 1
    </select>

    <select id="getMmsSignIdExceptId" resultType="ChanelSignId">
    	select id,signid,channelid,sign,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime from channel_sign_id
        where channelid=#{channelid} and signid=#{signid}
        <if test="id!=null">
            and id != #{id}
        </if>
    	limit 1
    </select>

    <select id="getSmsSignIdExceptId" resultType="ChanelSignId">
    	select id,signid,channelid,sign,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime from sms_channel_sign_id
        where channelid=#{channelid} and signid=#{signid}
        <if test="id!=null">
            and id != #{id}
        </if>
    	limit 1
    </select>

    <insert id="insertMmsSignId">
    	insert into channel_sign_id(signid,channelid,sign,createtime)
    	values(#{signid},#{channelid},#{sign},now())
    </insert>

    <insert id="insertSmsSignId">
    	insert into sms_channel_sign_id(signid,channelid,sign,createtime)
    	values(#{signid},#{channelid},#{sign},now())
    </insert>

    <insert id="insertMmsAimId">
    	insert into channel_aim_id(channel_id,aim_content,aim_id,mms_template_id,createtime,`type` )
    	values(#{channelId},#{aimContent},#{aimId},#{mmsTemplateId},now(),#{type})
    </insert>

    <update id="updateSignId" >
    	update channel_sign_id set signid=#{signid},channelid=#{channelid},sign=#{sign}
    	where id=#{id}
    </update>

    <update id="updateSmsSignId" >
    	update sms_channel_sign_id set signid=#{signid},channelid=#{channelid},sign=#{sign}
    	where id=#{id}
    </update>

    <update id="updateAimId" >
        update channel_aim_id set channel_id = #{channelId},aim_content = #{aimContent},aim_id =#{aimId},mms_template_id = #{mmsTemplateId}
    	where id=#{id}
    </update>

    <select id="getMmsChatbotById" resultType="cn.roadm.bo.ChannelSignChatbot">
        select id,sign,channelid,chatbot,csptoken,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime from mms_channel_sign_chatbot where id =#{id}
    </select>

    <select id="getSmsChatbotById" resultType="cn.roadm.bo.ChannelSignChatbot">
        select id,sign,channelid,chatbot,csptoken,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime from sms_channel_sign_chatbot where id =#{id}
    </select>

    <select id="getSmsTelecomChatbotById" resultType="cn.roadm.bo.ChannelSignChatbot">
        select id,sign,channelid,chatbot,appId,appKey,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime from sms_channel_sign_telecom_unicom_chatbot where id =#{id}
    </select>

    <select id="getMmsTelecomChatbotById" resultType="cn.roadm.bo.ChannelSignChatbot">
        select id,sign,channelid,chatbot,appId,appKey,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime from mms_channel_sign_telecom_unicom_chatbot where id =#{id}
    </select>

    <select id="getSmsCspAimPrivateKey" resultType="string">
        SELECT b.aim_privatekey from csp_chatbot a right join csp_agent b on a.agent_id = b.id where a.chatbotId =#{chatbotId}

    </select>

    <select id="getMmsChatbotBySign" resultType="cn.roadm.bo.ChannelSignChatbot">
        select id,sign,channelid,chatbot,csptoken,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime from mms_channel_sign_chatbot where channelid=#{channelid} and sign=#{sign}
        <if test="id!=null and id!=''">
            and id!=#{id}
        </if>
    </select>

    <select id="getSmsChatbotBySign" resultType="cn.roadm.bo.ChannelSignChatbot">
        select id,sign,channelid,chatbot,csptoken,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,status from sms_channel_sign_chatbot where channelid=#{channelid} and sign=#{sign}
        <if test="id!=null and id!=''">
            and id!=#{id}
        </if>
    </select>

    <select id="getSmsTelecomChatbotBySign" resultType="cn.roadm.bo.ChannelSignChatbot">
        select id,sign,channelid,chatbot,appId,appKey,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,status from sms_channel_sign_telecom_unicom_chatbot where channelid=#{channelid} and sign=#{sign}
        <if test="id!=null and id!=''">
            and id!=#{id}
        </if>
    </select>

    <insert id="insertMmsChatbot">
    	insert into mms_channel_sign_chatbot(chatbot,channelid,csptoken,sign,createtime)
    	values(#{chatbot},#{channelid},#{csptoken},#{sign},now())
    </insert>

    <insert id="insertSmsChatbot">
    	insert into sms_channel_sign_chatbot(chatbot,channelid,sign,csptoken,createtime,status)
    	values(#{chatbot},#{channelid},#{sign},#{csptoken},now(),#{status})
    </insert>

    <insert id="insertSmsTelecomChatbot">
    	insert into sms_channel_sign_telecom_unicom_chatbot(chatbot,channelid,sign,appId,appKey,createtime,status)
    	values(#{chatbot},#{channelid},#{sign},#{appId},#{appKey},now(),#{status})
    </insert>

    <insert id="insertMmsTelecomChatbot">
    	insert into mms_channel_sign_telecom_unicom_chatbot(chatbot,channelid,sign,appId,appKey,createtime)
    	values(#{chatbot},#{channelid},#{sign},#{appId},#{appKey},now())
    </insert>

    <update id="updateChatbot" >
    	update mms_channel_sign_chatbot set chatbot=#{chatbot},channelid=#{channelid},sign=#{sign},csptoken=#{csptoken}
    	where id=#{id}
    </update>

    <update id="updateChatbot2" >
    	update sms_channel_sign_chatbot set chatbot=#{chatbot},channelid=#{channelid},sign=#{sign},csptoken=#{csptoken}
    	where id=#{id}
    </update>

    <update id="updateTelecomChatbot" >
    	update sms_channel_sign_telecom_unicom_chatbot set chatbot=#{chatbot},channelid=#{channelid},
        sign=#{sign},appId=#{appId},appKey=#{appKey}
    	where id=#{id}
    </update>

    <update id="updateTelecomChatbotMms" >
    	update mms_channel_sign_telecom_unicom_chatbot set chatbot=#{chatbot},channelid=#{channelid},
        sign=#{sign},appId=#{appId},appKey=#{appKey}
    	where id=#{id}
    </update>

    <delete id="delChannelSignId">
    	delete from channel_sign_id where id =#{id}
    </delete>

    <delete id="delSmsChannelSignId">
    	delete from sms_channel_sign_id where id =#{id}
    </delete>

    <delete id="delChannelAimId">
    	delete from channel_aim_id where id =#{id}
    </delete>

    <delete id="delChannelHuiluoConfig">
    	delete from channel_huiluo_config where id =#{id}
    </delete>

    <delete id="delChannelChatbot">
        delete from mms_channel_sign_chatbot where id =#{id}
    </delete>

    <delete id="delChannelChatbot2">
        delete from sms_channel_sign_chatbot where id =#{id}
    </delete>

    <delete id="delChannelTelecomChatbot">
        delete from sms_channel_sign_telecom_unicom_chatbot where id =#{id}
    </delete>

    <delete id="delChannelTelecomChatbotMms">
        delete from mms_channel_sign_telecom_unicom_chatbot where id =#{id}
    </delete>

    <select id="getCityGroupById" resultType="cn.roadm.bo.SmsCityGroup">
        select id,name,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') as createtime,`status` from sms_city_group
        <where>
            status=1 and id=#{id}
        </where>
    </select>

    <select id="getPaConfigByBusiness" resultType="cn.roadm.bo.PaConfig">
        select a.id, a.is_support_international,a.is_support_unicom,a.is_support_telecom,a.is_support_mobile,p.carrier, a.channel_name name,a.unicom_prefix,a.mobile_prefix,a.telecom_prefix,p.loginname, p.password, a.mobile_prefix accessnumber, p.ip, p.port,
        p.service_id, p.carrier_sp_id, p.fee_type, p.fee_code, p.price,p.version, p.carrier_speed,
        p.socket_conn, p.src_note_id, p.local_listen_port, p.carrier_sp_sign, p.signflag, a.pa_url,a.status,a.protocol_type,a.batchsize,a.template_id,a.template_parameter,a.connect_status
        from sms_send_channel_info a left JOIN sms_carrier_channel_info p ON a.id = p.id
        <where>
            <if test="managerId != null and managerId != ''">
                a.business_manager in (select ifnull(business,0) from business_manager where managerId =  #{managerId}) and a.business_manager != ''
            </if>
            <if test="businessManager != null and businessManager != ''">
                and a.business_manager = #{businessManager}
            </if>
            <if test="queryChannelNetworkType != null and queryChannelNetworkType == 0">
                and a.protocol_type != '4'
            </if>
            <if test="queryChannelNetworkType != null and queryChannelNetworkType == 1">
                and a.protocol_type = '4'
            </if>
        </where>
        order by a.id desc
    </select>

    <select id="getMMSPaConfigByBusiness" resultType="cn.roadm.bo.PaConfig">
        select a.id,  a.channel_name name,a.business_manager businessManager
        from mms_send_channel_info a
        <where>
        	a.id>0
            <if test="managerId != null and managerId != ''">
                and a.business_manager in (select ifnull(business,0) from business_manager where managerId =  #{managerId}) and a.business_manager != ''
            </if>
            <if test="businessManager != null and businessManager != ''">
                and a.business_manager = #{businessManager}
            </if>
        </where>
        order by a.id desc
    </select>

    <select id="listPageChannelHistoryPrice" parameterType="ChannelHistoryPrice" resultType="ChannelHistoryPrice">
    	select hp.id,hp.channelid,hp.channel_price,hp.otype,hp.province, DATE_FORMAT(hp.createtime, '%Y-%m-%d %H:%i:%s') createtime,
    	DATE_FORMAT(hp.effecttime, '%Y-%m-%d') effecttime,hp.user,hp.status,sc.channel_name
    	from channel_history_price hp,sms_send_channel_info sc
    	<where>
    		hp.channelid=sc.id
    		<if test="channelid!=null and channelid>-1">
    			and hp.channelid=#{channelid}
    		</if>
    		<if test="otype!=null and otype>0">
    			and hp.otype=#{otype}
    		</if>
    		<if test="otype!=null and otype==0">
    			and (otype =0 or otype is null)
    		</if>
    		<if test="status!=null and status>=0">
    			and hp.status=#{status}
    		</if>
    		<if test="channel_name!=null and channel_name!=''">
    			and sc.channel_name like concat('%',#{channel_name},'%')
    		</if>
    		<if test="createTime!=null and createTime!=''">
    			and hp.createtime &gt;= #{createTime}
    		</if>
    		<if test="createTime1!=null and createTime1!=''">
    			and hp.createtime &lt;= #{createTime1}
    		</if>
            <if test="managerId != null and managerId != ''">
                and sc.business_manager in (select ifnull(business,0) from business_manager where managerId =  #{managerId}) and a.business_manager != ''
            </if>
            <if test="businessManager != null and businessManager != ''">
                and sc.business_manager = #{businessManager}
            </if>
    		order by hp.createtime desc
    	</where>
    </select>

    <select id="listPageMmsChannelHistoryPrice" parameterType="ChannelHistoryPrice" resultType="ChannelHistoryPrice">
    	select hp.id,hp.channelid,hp.channel_price,hp.otype,hp.province, DATE_FORMAT(hp.createtime, '%Y-%m-%d %H:%i:%s') createtime,
    	DATE_FORMAT(hp.effecttime, '%Y-%m-%d') effecttime,hp.user,hp.status,sc.channel_name
    	from channel_history_price hp,mms_send_channel_info sc
    	<where>
    		hp.channelid=sc.id
    		<if test="channelid!=null and channelid>-1">
    			and hp.channelid=#{channelid}
    		</if>
    		<if test="otype!=null and otype>0">
    			and hp.otype=#{otype}
    		</if>
    		<if test="otype!=null and otype==0">
    			and (otype =0 or otype is null)
    		</if>
    		<if test="status!=null and status>=0">
    			and hp.status=#{status}
    		</if>
    		<if test="channel_name!=null and channel_name!=''">
    			and sc.channel_name like concat('%',#{channel_name},'%')
    		</if>
    		<if test="createTime!=null and createTime!=''">
    			and hp.createtime &gt;= #{createTime}
    		</if>
    		<if test="createTime1!=null and createTime1!=''">
    			and hp.createtime &lt;= #{createTime1}
    		</if>
            <if test="managerId != null and managerId != ''">
                and sc.business_manager in (select ifnull(business,0) from business_manager where managerId =  #{managerId}) and a.business_manager != ''
            </if>
            <if test="businessManager != null and businessManager != ''">
                and sc.business_manager = #{businessManager}
            </if>
    		order by hp.createtime desc
    	</where>
    </select>

    <select id="exportChannelHistoryPrice" parameterType="ChannelHistoryPrice" resultType="Map">
    	select hp.id,hp.channelid,hp.channel_price,
    	(case
    	when hp.otype=1 then '联通'
    	when hp.otype=2 then '移动'
    	when hp.otype=3 then '电信'
    	else '全国'
    	 end) otype,
    	hp.province, DATE_FORMAT(hp.createtime, '%Y-%m-%d %H:%i:%s') createtime,
    	DATE_FORMAT(IFNULL(hp.effecttime,hp.createtime), '%Y-%m-%d') effecttime,hp.user,hp.status,sc.channel_name
    	from channel_history_price hp,sms_send_channel_info sc
    	<where>
    		hp.channelid=sc.id
    		<if test="channelid!=null and channelid>-1">
    			and hp.channelid=#{channelid}
    		</if>
    		<if test="otype!=null and otype>0">
    			and hp.otype=#{otype}
    		</if>
    		<if test="otype!=null and otype==0">
    			and (otype =0 or otype is null)
    		</if>
    		<if test="status!=null and status>=0">
    			and hp.status=#{status}
    		</if>
    		<if test="channel_name!=null and channel_name!=''">
    			and sc.channel_name like concat('%',#{channel_name},'%')
    		</if>
    		<if test="createTime!=null and createTime!=''">
    			and hp.createtime &gt;= #{createTime}
    		</if>
    		<if test="createTime1!=null and createTime1!=''">
    			and hp.createtime &lt;= #{createTime1}
    		</if>
            <if test="managerId != null and managerId != ''">
                and sc.business_manager in (select ifnull(business,0) from business_manager where managerId =  #{managerId}) and a.business_manager != ''
            </if>
            <if test="businessManager != null and businessManager != ''">
                and sc.business_manager = #{businessManager}
            </if>
    		order by hp.createtime desc
    	</where>
    </select>

    <insert id="insertChannelHistoryPrice">
    	insert into channel_history_price(channelid,channel_price,otype,province,createtime,effecttime,user,status)
    	values(#{channelid},#{channel_price,jdbcType=INTEGER}*10000,#{otype},#{province},date_format(now(),'%Y-%m-%d %H:%i:%s'),#{effecttime},#{user},#{status})
    </insert>
    <select id="getChannelPriceHistoryById" resultType="ChannelHistoryPrice">
    	select id,channelid,channel_price,createtime,effecttime,otype,status,province from channel_history_price where id=#{id}
    </select>
    <update id="updateChannelPriceHistory">
    	update channel_history_price set status=4 where status=0 and effecttime is true and channelid=#{channelid}
    	<if test="province!=null and province!=''">
    		and province=#{province}
    	</if>
    </update>
    <update id="updatePriceHistory">
    	update channel_history_price set effecttime=#{effecttime},channel_price=#{channel_price,jdbcType=INTEGER}*10000,province=#{province},otype=#{otype},user=#{user} where id=#{id}
    </update>

    <update id="updatePriceHistoryStatus">
    	update channel_history_price set status=#{status},effecttime=ifnull(effecttime,DATE_FORMAT(now(), '%Y-%m-%d')),user=#{user} where id=#{id}
    </update>
        <update id="updateNowPrice">
    	update sms_sp_province_summary set channel_price=#{channel_price,jdbcType=INTEGER}*10000,nettype=#{nettype} where channelid=#{channelid} and stat_time =date_format(now(),'%Y-%m-%d')
    	<if test="province!=null and province!=''">
    		and province=#{province}
    	</if>
    	<if test="otype!=null and otype!=''">
    		otype=#{otype}
    	</if>
    </update>
   <update id="updateChannelPriceByChannelid">
    	update sms_send_channel_info set price=#{channel_price},provinceNetPrice=#{provinceNetPrice},province=#{province} where id=#{channelid}
    </update>

     <select id="getChannelPriceByChannelid" resultType="ChannelHistoryPrice">
    	select id channelid,price channel_price,province,provinceNetPrice from sms_send_channel_info where id=#{channelid}
    </select>

    <select id="getMmsChannelPriceByChannelid" resultType="ChannelHistoryPrice">
    	select id channelid,price channel_price from mms_send_channel_info where id=#{channelid}
    </select>

    <update id="updateMmsChannelPriceByChannelid">
    	update mms_send_channel_info set price=#{channel_price} where id=#{channelid}
    </update>

    <select id="getChannelPriceOtype" resultType="ChannelHistoryPrice">
    	select * from channel_price where channelid=#{channelid}
    </select>

    <insert id="insertChannelPriceOtype">
    	insert channel_price(channelid,unicom_price,mobile_price,telecom_price) values(#{channelid},#{unicom_price}*10000,#{mobile_price}*10000,#{telecom_price}*10000)
    </insert>

    <update id="updateChannelPriceOtype">
    	update channel_price set unicom_price=#{unicom_price}*10000,mobile_price=#{mobile_price}*10000,telecom_price=#{telecom_price}*10000 where channelid=#{channelid}
    </update>

    <delete id="delChannelPriceOtype">
    	delete from channel_price where channelid=#{channelid}
    </delete>

    <select id="listPageChannelAttributeList" resultType="cn.roadm.bo.ChannelAttributeBO">
        select id, channel_id as channelId,channel_name as channelName, send_type as sendType,
               is_custom as isCustom, otype, charge_mode as chargeMode, is_limit as isLimit,
               shueld_region as shueldRegion, channel_limit as channelLimit,
               is_province as isProvince, send_time as sendTime, call_mdn as callMdn, ext_length as extLength,
               is_p2p as isP2p, is_upstream as isUpstream,
               max_length as maxLength, max_charcode as maxCharcode, remark,
               create_time as createTime, state, is_net_transfer as isNetTransfer,
               province, city, tBaseSpId, mdn_company_name as mdnCompanyName,
               export_template as exportTemplate, operator_gateway as operatorGateway,
               equipment_room_location as equipmentRoomLocation,
               channel_report_ip as channelReportIp
               from channel_attribute
        <where>
            state = 0
            <if test="channelId!=null and channelId!=''">
                 and channel_id like concat('%',#{channelId},'%')
            </if>
            <if test="channelName!=null and channelName!=''">
                and channel_name like concat('%',#{channelName},'%')
            </if>
            <if test="startTime != null and startTime != ''">
                and create_time &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>

            <if test="endTime != null and endTime != ''">
                and create_time &lt;= DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'), INTERVAL 1 DAY)
            </if>
        </where>
        order by create_time desc
    </select>

    <insert id="addChannelAttribute">
        insert into channel_attribute (channel_id,channel_name, send_type, is_custom, otype,
        charge_mode, is_limit, shueld_region, channel_limit, is_province,
        send_time, call_mdn, ext_length, is_p2p, is_upstream,
        max_length, max_charcode, remark, create_time, state, is_net_transfer,
        province, city, tBaseSpId, mdn_company_name, export_template,
        operator_gateway, equipment_room_location, channel_report_ip)
            values (#{channelId},#{channelName}, #{sendType}, #{isCustom}, #{otype},
        #{chargeMode}, #{isLimit}, #{shueldRegion}, #{channelLimit}, #{isProvince},
        #{sendTime}, #{callMdn}, #{extLength}, #{isP2p}, #{isUpstream},
        #{maxLength}, #{maxCharcode}, #{remark}, now(), 0, #{isNetTransfer},
        #{province}, #{city}, #{tBaseSpId}, #{mdnCompanyName}, #{exportTemplate},
        #{operatorGateway},#{equipmentRoomLocation}, #{channelReportIp})
    </insert>

    <select id="getChannelAttributeById" resultType="cn.roadm.bo.ChannelAttributeBO">
        select id, channel_id as channelId,channel_name as channelName, send_type as sendType,
               is_custom as isCustom, otype, charge_mode as chargeMode, is_limit as isLimit,
               shueld_region as shueldRegion, channel_limit as channelLimit,
               is_province as isProvince, send_time as sendTime, call_mdn as callMdn, ext_length as extLength,
               is_p2p as isP2p, is_upstream as isUpstream,
               max_length as maxLength, max_charcode as maxCharcode, remark,
               create_time as createTime, state, is_net_transfer as isNetTransfer,
               province, city, tBaseSpId, mdn_company_name as mdnCompanyName,
               export_template as exportTemplate, operator_gateway as operatorGateway,
               equipment_room_location as equipmentRoomLocation,
               channel_report_ip as channelReportIp
               from channel_attribute
        where id=#{id} and state = 0 limit 1
    </select>

    <update id="editChannelAttribute">
        update channel_attribute set channel_id = #{channelId}, channel_name = #{channelName}, send_type=#{sendType}, is_custom=#{isCustom},
        otype=#{otype}, charge_mode=#{chargeMode}, is_limit=#{isLimit},
        shueld_region=#{shueldRegion}, channel_limit=#{channelLimit},
        is_province=#{isProvince}, send_time=#{sendTime}, call_mdn=#{callMdn}, ext_length=#{extLength},
        is_p2p=#{isP2p}, is_upstream=#{isUpstream},
        max_length=#{maxLength}, max_charcode=#{maxCharcode}, remark=#{remark}, is_net_transfer=#{isNetTransfer},
        province=#{province}, city=#{city}, tBaseSpId=#{tBaseSpId}, mdn_company_name=#{mdnCompanyName},
        export_template=#{exportTemplate}, operator_gateway=#{operatorGateway}, equipment_room_location=#{equipmentRoomLocation},
        channel_report_ip=#{channelReportIp}
        where id=#{id}
    </update>

    <update id="deleteChannelAttribute">
        update channel_attribute set state=1 where id=#{id}
    </update>
    <select id="listPageSignExtend" resultType="SignExtend">
    	select se.id,se.spid,se.channelid,se.is_report,se.sign,se.extendnum,sp.sp_name,sc.CHANNEL_NAME,DATE_FORMAT(se.createtime, '%Y-%m-%d %H:%i:%s') createtime,sc.mobile_prefix callmdn from
    	 sp_sign_extend se left join sms_sp_info sp on se.spid=sp.id
    	 left join sms_send_channel_info sc on se.channelid=sc.id
    	<where>
    		<if test="spid!=null and spid!=''">
    			and se.spid=#{spid}
    		</if>
    		<if test="sp_name!=null and sp_name!=''">
    			and sp.sp_name like concat('%',#{sp_name},'%')
    		</if>
    		<if test="channelid!=null and channelid!=''">
    			and se.channelid=#{channelid}
    		</if>
    		<if test="sign!=null and sign!=''">
    			and se.sign=#{sign}
    		</if>
    		<if test="createtime1!=null and createtime1!=''">
    			and se.createtime &gt;= #{createtime1}
    		</if>
    		<if test="createtime2!=null and createtime2!=''">
    			and se.createtime &lt;= #{createtime2}
    		</if>
    		<if test="callmdn!=null and callmdn!=''">
    			and se.callmdn like concat (#{callmdn},'%')
    		</if>
    		<if test="extendnum!=null and extendnum!=''">
    			and se.extendnum like concat (#{extendnum},'%')
    		</if>
    		<if test="is_report!=null and is_report>0">
    			and se.is_report=#{is_report}
    		</if>
    		<if test="is_report!=null and is_report==0">
    			and ifnull(se.is_report,0)=0
    		</if>
    	</where>
    	ORDER BY se.id DESC
    </select>

    <insert id="insertSignExtend" parameterType="SignExtend">
    	insert into sp_sign_extend (spid,channelid,sign,extendnum,callmdn,is_report,createtime)
    	values(#{spid},#{channelid},#{sign},#{extendnum},#{callmdn},#{is_report},now())
    </insert>

    <update id="updateSignExtend">
    	update sp_sign_extend set is_report=#{is_report}
    	<where>
    		<if test="spid!=null and spid>0">
    			and ifnull(spid,0)=#{spid}
    		</if>
    		<if test="channelid!= null and channelid!=''">
    			and channelid=#{channelid}
    		</if>
    		<if test="sign!=null and sign!=''">
    			and sign=#{sign}
    		</if>
    		<if test="createtime1!=null and createtime1!=''">
    			and createtime &gt;= #{createtime1}
    		</if>
    		<if test="createtime2!=null and createtime2!=''">
    			and createtime &lt;= #{createtime2}
    		</if>
    		<if test="callmdn!=null and callmdn!=''">
    			and callmdn like concat (#{callmdn},'%')
    		</if>
    		<if test="extendnum!=null and extendnum!=''">
    			and extendnum like concat (#{extendnum},'%')
    		</if>
    	</where>
    </update>

    <update id="updateExportSignExtend">
    	update sp_sign_extend_export set is_report=#{is_report}
    	<where>
    		<if test="spid!=null and spid>0">
    			and ifnull(spid,0)=#{spid}
    		</if>
    		<if test="channelid!= null and channelid!=''">
    			and channelid=#{channelid}
    		</if>
    		<if test="sign!=null and sign!=''">
    			and sign=#{sign}
    		</if>
    		<if test="createtime1!=null and createtime1!=''">
    			and createtime &gt;= #{createtime1}
    		</if>
    		<if test="createtime2!=null and createtime2!=''">
    			and createtime &lt;= #{createtime2}
    		</if>
    		<if test="callmdn!=null and callmdn!=''">
    			and callmdn like concat (#{callmdn},'%')
    		</if>
    		<if test="extendnum!=null and extendnum!=''">
    			and extendnum like concat (#{extendnum},'%')
    		</if>
    	</where>
    </update>

    <select id="getSignExtend" resultType="SignExtend">
    	select se.id,se.spid,se.channelid,se.sign,se.extendnum,sp.sp_name,sc.CHANNEL_NAME,DATE_FORMAT(se.createtime, '%Y-%m-%d %H:%i:%s') createtime,sc.mobile_prefix callmdn,LEFT(se.callmdn, 20) callmdnext from
    	 sp_sign_extend se left join sms_sp_info sp on se.spid=sp.id
    	 left join sms_send_channel_info sc on se.channelid=sc.id
    	 <where>
    	 	<if test="spid!=null and spid!=''">
    			and se.spid=#{spid}
    		</if>
    		<if test="sp_name!=null and sp_name!=''">
    			and sp.sp_name like concat('%',#{sp_name},'%')
    		</if>
    		<if test="channelid!=null and channelid!=''">
    			and se.channelid=#{channelid}
    		</if>
    		<if test="is_report!=null and is_report!=''">
    			and se.is_report=#{is_report}
    		</if>
    		<if test="sign!=null and sign!=''">
    			and se.sign=#{sign}
    		</if>
    		<if test="createtime1!=null and createtime1!=''">
    			and se.createtime &gt;= #{createtime1}
    		</if>
    		<if test="createtime2!=null and createtime2!=''">
    			and se.createtime &lt;= #{createtime2}
    		</if>
    		<if test="callmdn!=null and callmdn!=''">
    			and se.callmdn like concat (#{callmdn},'%')
    		</if>
    		<if test="extendnum!=null and extendnum!=''">
    			and se.extendnum like concat (#{extendnum},'%')
    		</if>
    		<if test="endId != null">
                and se.id &lt;  #{endId}
            </if>
    	 </where>
            ORDER BY se.id DESC
    	<if test="exportExcelSize != null ">
            limit #{exportExcelSize}
        </if>
    </select>

    <select id="getSignExtendCount" resultType="int">
    	select count(se.id) from
    	 sp_sign_extend se left join sms_sp_info sp on se.spid=sp.id
    	 left join sms_send_channel_info sc on se.channelid=sc.id
    	 <where>
    	 	<if test="spid!=null and spid!=''">
    			and se.spid=#{spid}
    		</if>
    		<if test="sp_name!=null and sp_name!=''">
    			and sp.sp_name like concat('%',#{sp_name},'%')
    		</if>
    		<if test="channelid!=null and channelid!=''">
    			and se.channelid=#{channelid}
    		</if>
    		<if test="is_report!=null and is_report!=''">
    			and se.is_report=#{is_report}
    		</if>
    		<if test="sign!=null and sign!=''">
    			and se.sign=#{sign}
    		</if>
    		<if test="createtime1!=null and createtime1!=''">
    			and se.createtime &gt;= #{createtime1}
    		</if>
    		<if test="createtime2!=null and createtime2!=''">
    			and se.createtime &lt;= #{createtime2}
    		</if>
    		<if test="callmdn!=null and callmdn!=''">
    			and se.callmdn like concat (#{callmdn},'%')
    		</if>
    		<if test="extendnum!=null and extendnum!=''">
    			and se.extendnum=#{extendnum}
    		</if>
    	 </where>
    </select>

    <select id="getSpSignDetails" resultType="cn.roadm.bo.SmsSignDetails">
    	select LEFT(se.callmdn, 20) callmdn,se.sign,ss.id,ss.port_sp_name,ss.port_sp_code,ss.legal_person,ss.card_type,ss.card,ss.app_name,ss.handledby,
    	ss.handledbyCard
	 from sp_sign_extend se left join sp_sign_details ss on ss.sign=se.sign COLLATE utf8mb4_general_ci where se.id in(select MAX(id) from sp_sign_extend where LEFT(callmdn, 20) in
    	  <foreach item="item" collection="list" separator="," open="(" close=")" index="index">
    	   #{item}
          </foreach>
          and channelid=#{channelid} and ifnull(is_report,0)=#{is_report}
    	  group by LEFT(callmdn, 20) )
     </select>
    <select id="getSpSignDetailsAll" resultType="cn.roadm.bo.SmsSignDetails">
    	select LEFT(se.callmdn, 20) callmdn,se.sign,ss.id,ss.port_sp_name,ss.port_sp_code,ss.legal_person,ss.card_type,ss.card,ss.app_name,ss.handledby,
    	ss.handledbyCard
	 from sp_sign_extend se left join sp_sign_details ss on ss.sign=se.sign COLLATE utf8mb4_general_ci where LEFT(callmdn, 20) in
    	 <foreach item="item" collection="list" separator="," open="(" close=")" index="index">
    	   #{item}
          </foreach>
          and channelid=#{channelid} and ifnull(is_report,0)=#{is_report}
    </select>

    <select id="getSpSignDetailsBySign" resultType="cn.roadm.bo.SmsSignDetails">
    	select * from sp_sign_details sign in
    	<foreach item="item" collection="list" separator="," open="(" close=")" index="index">
    	   #{item}
        </foreach>
    </select>

    <select id="exportSignExtendCompany" resultType="cn.roadm.bo.SmsSignDetails">
    	SELECT
    	se.id,
		se.spid,
		LEFT(se.callmdn, 20) callmdnext,
		se.sign,
		se.sign app_name,
		sc.mobile_prefix callmdn,
		sc.access_province,
		sc.access_city,
		ifnull(sd.port_sp_name,sep.full_name) AS full_name,
    	ifnull(sd.port_sp_code,sep.invoice_code) AS invoice_code,
    	ifnull(sd.legal_person,sep.company_user) AS company_user,
    	ifnull(sd.card,sep.company_id_card) AS company_id_card,
    	ifnull(sd.handledby,sep.company_user_2) AS company_user_2,
    	ifnull(sd.handledbyCard,sep.company_id_card_2) AS company_id_card_2,
		sc.access_company
		FROM
		<if test="isrepeat==1">
			sp_sign_extend_export se
		</if>
		<if test="isrepeat==0">
			sp_sign_extend se
		</if>
		LEFT JOIN sms_sp_info sp ON se.spid = sp.id
		LEFT JOIN sms_enterprise sep ON sp.eid = sep.id
		LEFT JOIN sms_send_channel_info sc ON se.channelid = sc.id
		LEFT JOIN sp_sign_details sd on se.sign=sd.sign COLLATE utf8mb4_general_ci
		<where>
			<if test="isbaobei==1">
				ifnull(se.is_report,0)=0
			</if>
			<if test="spid!=null and spid!=''">
    			and se.spid=#{spid}
    		</if>
    		<if test="sp_name!=null and sp_name!=''">
    			and sp.sp_name like concat('%',#{sp_name},'%')
    		</if>
    		<if test="channelid!=null and channelid!=''">
    			and se.channelid=#{channelid}
    		</if>

    		<if test="sign!=null and sign!=''">
    			and se.sign=#{sign}
    		</if>
    		<if test="createtime1!=null and createtime1!=''">
    			and se.createtime &gt;= #{createtime1}
    		</if>
    		<if test="createtime2!=null and createtime2!=''">
    			and se.createtime &lt;= #{createtime2}
    		</if>
    		<if test="callmdn!=null and callmdn!=''">
    			and se.callmdn like concat (#{callmdn},'%')
    		</if>
    		<if test="extendnum!=null and extendnum!=''">
    			and se.extendnum=#{extendnum}
    		</if>
			<if test="endId != null">
	            and se.id &lt;  #{endId}
	        </if>
	    </where>
            ORDER BY se.id DESC
    	<if test="exportExcelSize != null ">
            limit #{exportExcelSize}
        </if>
    </select>


    <select id="listPageSignExtendDetail" resultType="cn.roadm.bo.SmsSignDetails">
    	select * from sp_sign_details
    	<where>
    		<if test="sign!=null and sign!=''">
    			and sign like concat('%',#{sign},'%')
    		</if>
    		<if test="createtime1!=null and createtime1!=''">
    			and createtime &gt;= #{createtime1}
    		</if>
    		<if test="createtime2!=null and createtime2!=''">
    			and createtime &lt;= DATE_ADD(str_to_date(#{createtime2},'%Y-%m-%d'), INTERVAL 1 DAY)
    		</if>
    	</where>
    	ORDER BY id DESC
    </select>

    <select id="getSignDetail" resultType="cn.roadm.bo.SmsSignDetails">
    	select * from sp_sign_details where id=#{id}
    </select>

    <insert id="insertSignDetail">
    	insert into sp_sign_details(sign,port_sp_name,port_sp_code,legal_person,card_type,card,app_name,createtime,handledby,handledbyCard,handledby_card_type)
    	 values(#{sign},#{port_sp_name},#{port_sp_code},#{legal_person},#{card_type},#{card},#{sign},now(),#{handledby},#{handledbyCard},#{handledby_card_type})
    </insert>

    <update id="updateSignDetail">
    	update sp_sign_details set
    	sign=#{sign},
    	port_sp_name=#{port_sp_name},
    	port_sp_code=#{port_sp_code},
    	legal_person=#{legal_person},
    	card=#{card},
    	app_name=#{sign},
    	handledby=#{handledby},
    	handledbyCard=#{handledbyCard},
        card_type=#{card_type},
    	handledby_card_type=#{handledby_card_type}
    	where id=#{id}
    </update>

    <select id="getSignDetailBySign" resultType="cn.roadm.bo.SmsSignDetails">
    	select * from sp_sign_details where sign=#{sign}
    </select>

    <select id="listPageSmsTemplate" resultType="ChannelTemplate">
    	select id,content,title,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,`desc`,example from sms_template_local
    	<where>
    		<if test="content!=null and content!=''">
    			and content like concat('%',#{content},'%')
    		</if>
    		<if test="title!=null and title!=''">
    			and title like concat('%',#{title},'%')
    		</if>
    		<if test="id!=null and id!=''">
    			and id=#{id}
    		</if>
    		<if test="startTime != null and startTime != ''">
                and createtime &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and createtime &lt;= DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
    	</where>
    	order by createtime desc
    </select>
    <select id="getLocalTemplateById" resultType="ChannelTemplate">
    	select * from sms_template_local where id=#{id}
    </select>
    <select id="getSmsAllRemoteId"
        resultType="Map">
        select tr.channelid,tr.template_id,tr.name from channel_template tr
    </select>

    <select id="getChannelTemplateByLocalId" resultType="ChannelTemplate">
    	select * from channel_template
    	<where>
    		<if test="channelid !=null and channelid >=0">
	            and channelid=#{channelid}
	        </if>
	        <if test="local_template !=null and local_template >0">
	            and local_template=#{local_template}
	        </if>
    	</where>
    	limit 1
    </select>

    <insert id="insertTemplateRemote" parameterType="ChannelTemplate" useGeneratedKeys="true" keyProperty="id">
		insert into channel_template(channelid,createtime,status,template_id,local_template,name,content)
		values(#{channelid},now(),#{status},#{template_id},#{local_template},#{name},#{content});
	</insert>

	<update id="updateTemplateRemote" parameterType="ChannelTemplate">
		update channel_template set template_id=#{template_id} where local_template=#{local_template} and channelid=#{channelid}
	</update>

	<delete id="delTemplateByLocalId">
		DELETE from sms_template_local where id =#{id}
	</delete>

	<select id="listPageSupplier" resultType="cn.roadm.bo.ChannelSupplier">
		select id,supplier_name,business,DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') create_time from channel_supplier
		<where>
		    <if test="id != null and id!=''">
                and id = #{id}
            </if>
			<if test="supplier_name!=null and supplier_name!=''">
				and supplier_name like CONCAT('%',#{supplier_name},'%')
			</if>
			<if test="startTime != null and startTime != ''">
                and create_time &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and create_time &lt;= DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
            <if test="business!=null and business!=''">
                and business = #{business}
            </if>
		</where>
	</select>

	<select id="getAllSuppliser" resultType="cn.roadm.bo.ChannelSupplier">
		select  id,supplier_name from channel_supplier
	</select>
	<select id="supplierGetOne" resultType="cn.roadm.bo.ChannelSupplier">
		select id,supplier_name,business from channel_supplier
		<where>
			<if test="id!=null and id!=''">
				and id=#{id}
			</if>
			<if test="supplier_name!=null and supplier_name!=''">
				and supplier_name=#{supplier_name}
			</if>
            <if test="business!=null and business!=''">
                and business=#{business}
            </if>
		</where>
		limit 1
	</select>
    <insert id="insertChannelSupplier">
    	insert into channel_supplier(supplier_name,create_time,business) values(#{supplier_name},now(),#{business})
    </insert>

    <update id="updateChannelSupplier">
    	update channel_supplier set supplier_name=#{supplier_name},business=#{business} where id=#{id}
    </update>
 	<delete id="deleteChannelSupplier">
 		delete from channel_supplier where id=#{id}
 	</delete>

    <select id="selectSpProvinceGroupBySpId" resultType="cn.roadm.bo.SmsProvinceGroup">
        select pro_group_id as group_id from sms_sp_info where id = #{spId}
    </select>

    <insert id="insertSpChannelProvinceConfigBitch">
        insert into sms_channel_province_config(mobilechannel,unicomchannel,telecomchannel,province,spId)
        values
        <foreach collection="list" item="item" index="index" separator=",">
           (#{item.mobilechannel},#{item.unicomchannel},#{item.telecomchannel},#{item.province},#{item.spId})
        </foreach>
    </insert>

    <delete id="removeSpChannelProvinceConfigBySpId">
        delete from sms_channel_province_config where spId in
        <foreach collection="list" item="item" index="index" separator="," open="(" close=")">
            #{item}
        </foreach>
    </delete>

    <update id="updateSpProvinceGroupBySpId">
        update sms_sp_info set pro_group_id = #{group_id} where id in
        <foreach collection="targetSpId" item="item" index="index" separator="," open="(" close=")">
            #{item}
        </foreach>
    </update>

    <select id="selectSpEnableProvince" resultType="java.lang.Integer">
        select is_open_province from  sms_sp_info where id = #{sid} limit 1;
    </select>

    <update id="updateOtherProvinceEnable">
        update sms_sp_info set is_open_province = #{state} where id in
        <foreach collection="targetSpId" open="(" close=")" item="item" separator=",">
            #{item}
        </foreach>
    </update>

    <select id="selectOneSpProvinceGroupBySpId" resultType="java.util.Map">
        select is_open_province_group as isOpenProvinceGroup, pro_group_id as provinceGroupId from sms_sp_info
        where id = #{sid}
    </select>

    <update id="updateProvinceConfigGroupOther">
        update sms_sp_info set is_open_province_group = #{result.isOpenProvinceGroup},pro_group_id = #{result.provinceGroupId}
        where id in
        <foreach collection="targetSpId" separator="," item="item" index="index" open="(" close=")">
            #{item}
        </foreach>
    </update>

    <select id="getChannelBlackByChannelId" resultType="cn.roadm.bo.ChannelBlack">
    	select * from channel_black
    	<where>
    		channelid = #{channelid}
    	</where>
    	limit 1
    </select>

    <insert id="insertChannelBlack" >
    	insert channel_black(channelid,hySpId,hyNoSpId,hyFlag,hyBlack,yxSpId,yxNoSpId,yxFlag,yxBlack,yx_send_province,
    	yx_send_city,yx_unsend_province,yx_unsend_city,hy_send_province,hy_send_city,hy_unsend_province,hy_unsend_city)
    	 values(#{channelid},#{hySpId},#{hyNoSpId},#{hyFlag},#{hyBlack},#{yxSpId},#{yxNoSpId},#{yxFlag},#{yxBlack},
    	 #{yx_send_province},#{yx_send_city},#{yx_unsend_province},#{yx_unsend_city},#{hy_send_province},#{hy_send_city},
    	 #{hy_unsend_province},#{hy_unsend_city})
    </insert>

    <update id="updateChannelBlackByChannelId">
    	update channel_black set hySpId=#{hySpId},hyNoSpId=#{hyNoSpId},hyFlag=#{hyFlag},hyBlack=#{hyBlack},yxSpId=#{yxSpId},
    	yxNoSpId=#{yxNoSpId},yxFlag=#{yxFlag},yxBlack=#{yxBlack},yx_send_province=#{yx_send_province},yx_send_city=#{yx_send_city},
    	yx_unsend_province=#{yx_unsend_province},yx_unsend_city=#{yx_unsend_city},hy_send_province=#{hy_send_province},hy_send_city=#{hy_send_city},
    	hy_unsend_province=#{hy_unsend_province},hy_unsend_city=#{hy_unsend_city}
    	 where channelid=#{channelid}
    </update>

    <select id="listChannelBaseInfo" resultType="cn.roadm.bo.ChannelInfo">
        select id, channel_name from sms_send_channel_info where STATUS = 1
    </select>

    <select id="listMmsChannelBaseInfo" resultType="cn.roadm.bo.ChannelInfo">
        select id, channel_name from mms_send_channel_info where STATUS = 1
    </select>

    <!--签名企业详情新增addSignDetail-->
    <insert id="addSignDetail">
        insert sp_sign_details (sign,port_sp_name,port_sp_code,legal_person,card_type,card,app_name,createtime,handledby,handledbyCard,handledby_card_type,owner_channel)
        values(#{sign},#{port_sp_name},#{port_sp_code},#{legal_person},#{card_type},#{card},#{sign},#{createtime},#{handledby},#{handledbyCard},#{handledby_card_type},#{owner_channel})
    </insert>

    <!--签名企业详情删除根据id-->
    <delete id="deleteSignDetailById">
        delete from sp_sign_details where id = #{id}
    </delete>

    <!--将删除的签名企业详情表备份-->
    <insert id="insertSignDetailDelete">
        insert sp_sign_details_delete (id,sign,port_sp_name,port_sp_code,legal_person,card_type,card,app_name,createtime,handledby,handledbyCard)
        values(#{id},#{sign},#{port_sp_name},#{port_sp_code},#{legal_person},#{card_type},#{card},#{app_name},#{createtime},#{handledby},#{handledbyCard})
    </insert>


    <!--通道子扩展号列表-->
    <select id="listPageChannelExtend" resultType="cn.roadm.bo.ChannelExtend">
        select id,channelid,callmdn,createtime,uid
        from sms_channel_extend_limit
        <where>
            <if test="channelid!=null and channelid!=''">
                and channelid = #{channelid}
            </if>
            <if test="callmdn!=null and callmdn!=''">
                and callmdn like  CONCAT('%',#{callmdn},'%')
            </if>
        </where>
    </select>

    <!--通道子扩展新增-->
    <insert id="addChannelExtend">
        insert sms_channel_extend_limit
        (channelid,callmdn,createtime,uid)
        values(#{channelid},#{callmdn},#{createtime},#{uid})
    </insert>

    <!--根据id获取通道子扩展-->
    <select id="getChannelExtendById" parameterType="int" resultType="cn.roadm.bo.ChannelExtend">
        select id,channelid,callmdn,createtime,uid
        from sms_channel_extend_limit
        where id = #{id}
    </select>

    <!--修改通道子扩展-->
    <update id="updateChannelExtend" parameterType="cn.roadm.bo.ChannelExtend">
        update sms_channel_extend_limit
        set channelid=#{channelid},callmdn=#{callmdn}
        where id=#{id}
    </update>

    <!--根据id删除子扩展-->
    <delete id="delChannelExtendById" parameterType="int">
        delete from sms_channel_extend_limit where id = #{id}
    </delete>

    <!--获取通道单价-->
    <select id="getPaChannelPriceById" resultType="String">
        select price from sms_send_channel_info where id = #{id}
    </select>


    <!--批量导入（新增）-->
    <insert  id="addSmsPhoneChannelBatch"  useGeneratedKeys="true" keyProperty="id" parameterType="java.util.List">
        insert into sms_phone_channel (spid,mdn,channel,oldtype,newtype,createtime,status)
        values
        <foreach collection="list" item="smsPhone"  index="index"  separator=","  >
            (#{smsPhone.spid},#{smsPhone.mdn,jdbcType=VARCHAR},#{smsPhone.channel,jdbcType=VARCHAR},
             #{smsPhone.oldtype,jdbcType=VARCHAR},#{smsPhone.newtype,jdbcType=VARCHAR},
            sysdate(),#{smsPhone.status,jdbcType=VARCHAR})
        </foreach>
    </insert>


    <!--批量导入（新增）-->
    <insert  id="addMmsPhoneChannelBatch"  useGeneratedKeys="true" keyProperty="id" parameterType="java.util.List">
        insert into mms_phone_channel (spid,mdn,channel,oldtype,newtype,createtime,status)
        values
        <foreach collection="list" item="smsPhone"  index="index"  separator=","  >
            (#{smsPhone.spid},#{smsPhone.mdn,jdbcType=VARCHAR},#{smsPhone.channel,jdbcType=VARCHAR},
            #{smsPhone.oldtype,jdbcType=VARCHAR},#{smsPhone.newtype,jdbcType=VARCHAR},
            sysdate(),#{smsPhone.status,jdbcType=VARCHAR})
        </foreach>
    </insert>

    <!--彩信通道组-->
    <select id="listPaGroupMmsConfig" parameterType="MmsChannelGroup" resultType="MmsChannelGroup">
        select * from mms_channel_group g
        <where>
            g.status = '1'
            <if test="network != null and network != ''">
                and g.network = #{network}
            </if>
            <if test="name != null and name!=''">
                and g.name like CONCAT('%', #{name}, '%')
            </if>
            <if test="channels!=null and channels!=''">
                and CONCAT(',',channels, ',') like CONCAT('%,',#{channels}, ',%')
            </if>
        </where>
        order by g.id desc
    </select>

    <!--根据id获取彩信通道组-->
    <select id="getPaGroupMmsConfigById" parameterType="int" resultType="MmsChannelGroup">
        select * from mms_channel_group g where g.id = #{id}
    </select>

    <!--根据id获取彩信通道信息-->
    <select id="getPaConfigMmsById" parameterType="MmsChannelInfo" resultType="MmsChannelInfo">
        select channel_name channelName
        from mms_send_channel_info
        <where>
            <if test="id != null">
                id = #{id}
            </if>
        </where>
    </select>

    <!--分省通道日统计，不分省-->
    <update id="bitchUpdatePriceByChannelDayNew" parameterType="cn.roadm.bo.BitchUpdatePriceVO">
        update pa_day_count
        <trim prefix="set" suffixOverrides=",">
            <if test="price != null">
                price= #{price},
            </if>

        </trim>
        <where>
            <if test="startTime != null and startTime != ''">
                and total_time &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and total_time &lt;DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
            <if test="nettype >=0">
                and ifnull(nettype,0)=#{nettype}
            </if>
            <if test="otype!=null and otype>0">
                and otype=#{otype}
            </if>
            and channelid in
            <foreach collection="list" item="item" separator="," open="(" close=")">
                #{item}
            </foreach>
        </where>
    </update>

    <!--分省通道日统计，省网单价-->
    <update id="updatePriceByChannelDayPaNew" parameterType="cn.roadm.bo.BitchUpdatePriceVO">
        update pa_day_count
        <trim prefix="set" suffixOverrides=",">
            <if test="price != null">
                price= #{price,jdbcType=INTEGER},
            </if>
            <if test="nettype >=0">
                nettype=#{nettype}
            </if>
        </trim>
        <where>
            channelid =#{channelid}
            <if test="startTime != null and startTime != ''">
                and total_time &gt;= str_to_date(#{startTime},'%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and total_time &lt;DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
            <if test="nettype ==1">
                and province=#{province}
            </if>

        </where>
    </update>

    <select id="selectSignByCallMdn" resultType="cn.roadm.bo.ExportMateSign">
        SELECT callmdn,`sign` FROM sp_sign_extend
        WHERE id IN
        (SELECT MAX(id) FROM sp_sign_extend WHERE callmdn IN (${callMdns})
        <if test="channelIds!=channelIds != null and channelIds != ''">
            AND channelid IN (${channelIds})
        </if>
          GROUP BY callmdn )
    </select>

    <select id="selectSignByCallMdn2" resultType="cn.roadm.bo.ExportMateSign">
        SELECT callmdn,`sign` FROM sp_sign_extend
        WHERE id =
        (SELECT MAX(id) FROM sp_sign_extend WHERE callmdn = #{callMdns}
        <if test="channelIds!=channelIds != null and channelIds != ''">
            AND channelid IN (${channelIds})
        </if>
        )
    </select>

    <select id="getChannelMmsId" resultType="java.lang.Integer">
        select id from mms_send_channel_info where id = #{channelid}
    </select>

    <update id="updateChannelUpdateTime">
        update sms_send_channel_info set update_time = sysdate() where id = #{id}
    </update>

    <select id="exportSmsPhoneChannel" resultType="cn.roadm.bo.SmsPhoneChannel">
        select spid, channel, mdn from sms_phone_channel
        <where>
            <if test="spid != null and spid != ''">
                spid = #{spid}
            </if>
            <if test="channel != null and channel != '' and channel != '-1'">
                and channel = #{channel}
            </if>
            <if test="starttime != null and starttime != ''">
                and createtime &gt;= str_to_date(#{starttime},'%Y-%m-%d %H:%i:%s')
            </if>
            <if test="endtime != null and endtime != ''">
                and createtime &lt;DATE_ADD(str_to_date(#{endtime},'%Y-%m-%d %H:%i:%s'),INTERVAL 1 DAY)
            </if>
        </where>
    </select>
    <select id="listUnknownAlarmChannel" resultType="cn.roadm.bo.PaConfig">
        select a.id, a.channel_name name
        from sms_send_channel_info a
        where not exists (
        select 1 from sms_unknown_alarm_strategy b
        <where>
            b.status =0 and b.channel_id =a.ID
            <if test="channelId!=null">
                and b.channel_id!=#{channelId}
            </if>
        </where>
        )
    </select>

    <select id="queryAllCompany" resultType="String">
        SELECT
            value
        FROM
            sms_system_config
        WHERE
            config_key = 'cooperate_company'
    </select>


    <select id="queryAllChannelName"
            resultType="Map">
        select a.id channelid,a.channel_name channelName from sms_send_channel_info a
        union
        select a.id channelid,a.channel_name channelName from mms_send_channel_info a
        order by channelid
    </select>

</mapper>
