<?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.SpinfoMapper">
    <sql id="spInfoColumns">
        sp.id,sp.sp_name,sp.ip,sp.status,sp.sp_name,sp.createtime,sp.mobile_prefix,sp.mobile_suffix,sp.mobile_num,sp.unicom_prefix,sp.unicom_suffix,sp.unicom_num,sp.telecom_prefix,sp.telecom_suffix,sp.telecom_num,sp.report_url,sp.reply_url,sp.is_lock,sp.is_audit_word,
        sp.sp_type,sp.contact_name,sp.contact_mdn,sp.sp_saler,sp.sp_saler_mdn,sp.droptime,sp.sp_desc,sp.platfrom,sp.is_api,sp.return_fee_type
    </sql>

    <resultMap type="SpInfo" id="spInfoAndSpcharge">
        <result column="spid" property="spid"/>
        <result column="sp_name" property="sp_name"/>
        <result column="fee_type" property="feetype"/>
        <result column="effect_month" property="effect_month"/>
        <result column="is_api_billing" property="is_api_billing"/>
        <result column="sp_saler" property="sp_saler"/>
        <result column="day_limit" property="day_limit"/>
        <result column="month_limit" property="month_limit"/>
        <association property="spCharge" column="spid" javaType="SpCharge">
            <id column="spid" property="sp_id"/>
            <result column="max_num" property="max_num"/>
            <result column="use_num" property="use_num"/>
            <result column="leftover_num" property="leftover_num"/>
            <result column="id" property="id"/>
        </association>
    </resultMap>
    <resultMap type="SpInfo" id="spInfoAndSpchargeMms">
        <result column="spid" property="spid"/>
        <result column="sp_name" property="sp_name"/>
        <result column="fee_type" property="feetype"/>
        <result column="effect_month" property="effect_month"/>
        <association property="spChargeMms" column="spid" javaType="SpChargeMms">
            <id column="spid" property="sp_id"/>
            <result column="max_num" property="max_num"/>
            <result column="use_num" property="use_num"/>
            <result column="leftover_num" property="leftover_num"/>
            <result column="id" property="id"/>
        </association>
    </resultMap>

    <resultMap type="SpInfo" id="spInfoAndChannel">
        <id column="id" property="spid"/>
        <result column="sp_name" property="sp_name"/>
        <result column="mobile_prefix" property="mobile_prefix"/>
        <result column="mobile_suffix" property="mobile_suffix"/>
        <result column="mobile_num" property="mobile_num"/>
        <result column="unicom_prefix" property="unicom_prefix"/>
        <result column="unicom_suffix" property="unicom_suffix"/>
        <result column="unicom_num" property="unicom_num"/>
        <result column="telecom_prefix" property="telecom_prefix"/>
        <result column="telecom_suffix" property="telecom_suffix"/>
        <result column="telecom_num" property="telecom_num"/>
        <result column="platform" property="platform"/>
        <result column="content_type" property="content_type"/>
        <result column="is_open_province" property="isOpenProvince"/>
        <result column="is_open_mms_province" property="isOpenMmsProvince"/>
        <result column="mobile" property="mobile"/>
        <result column="unicom" property="unicom"/>
        <result column="telecom" property="telecom"/>
        <result column="mobileGroup" property="mobileChannelGroupStringId"/>
        <result column="unicomGroup" property="unicomChannelGroupStringId"/>
        <result column="telecomGroup" property="telecomChannelGroupStringId"/>
        <result column="otype_limit" property="otype_limit"/>
    </resultMap>

	<resultMap type="PaConfig" id="paConfigIsSupport">
        <id column="id" property="id"/>
        <result column="channel_name" property="name"/>
        <result column="is_support_unicom" property="is_support_unicom"/>
        <result column="is_support_mobile" property="is_support_mobile"/>
        <result column="is_support_telecom" property="is_support_telecom"/>
    </resultMap>

    <resultMap type="ChargeRecord" id="ChargeRecordResult">
        <id column="id" property="id"/>
        <result column="sp_name" property="sp_name"/>
        <result column="chargenum" property="chargeNum"/>
        <result column="chargeopeartor" property="operator"/>
        <result column="amount" property="amount"/>
        <result column="price" property="price"/>
        <result column="sp_id" property="sp_id"/>
        <result column="type" property="type"/>
        <result column="descption" property="descption"/>
        <result column="platform" property="platform"/>
    </resultMap>
    <resultMap type="ChargeRecordMms" id="ChargeRecordMmsResult">
        <id column="id" property="id"/>
        <result column="sp_name" property="sp_name"/>
        <result column="chargenum" property="chargeNum"/>
        <result column="chargeopeartor" property="operator"/>
        <result column="amount" property="amount"/>
        <result column="price" property="price"/>
        <result column="sp_id" property="sp_id"/>
        <result column="type" property="type"/>
        <result column="descption" property="descption"/>
        <result column="platform" property="platform"/>
    </resultMap>

    <resultMap type="cn.roadm.bo.SpInfo" id="spInfoResultMap">
        <id column="id" property="spid"/>
        <result column="sp_name" property="sp_name"/>
        <result column="password" property="password"/>
        <result column="ip" property="ip"/>
        <result column="status" property="status"/>
        <result column="createtime" property="createTime"/>
        <result column="fee_type" property="feetype"/>
        <result column="mobile_prefix" property="mobile_prefix"/>
        <result column="mobile_suffix" property="mobile_suffix"/>
        <result column="mobile_num" property="mobile_num"/>
        <result column="unicom_prefix" property="unicom_prefix"/>
        <result column="unicom_suffix" property="unicom_suffix"/>
        <result column="unicom_num" property="unicom_num"/>
        <result column="telecom_prefix" property="telecom_prefix"/>
        <result column="telecom_suffix" property="telecom_suffix"/>
        <result column="telecom_num" property="telecom_num"/>
        <result column="is_api_billing" property="is_api_billing"/>
        <result column="return_fee_type" property="return_fee_type"/>
        <result column="unknown_billing" property="unknown_billing"/>

        <result column="sub_account_billing_mode"  property="subAccountBillingMode"/>
        <result column="grade" property="grade"/>
        <result column="sensitive_word_type" property="sensitive_word_type"/>
        <result column="is_audit_black" property="is_audit_black"/>
        <result column="mms_mobile_prefix" property="mms_mobile_prefix"/>
        <result column="mms_mobile_suffix" property="mms_mobile_suffix"/>
        <result column="mms_mobile_num" property="mms_mobile_num"/>
        <result column="mms_unicom_prefix" property="mms_unicom_prefix"/>
        <result column="mms_unicom_suffix" property="mms_unicom_suffix"/>
        <result column="mms_unicom_num" property="mms_unicom_num"/>
        <result column="mms_telecom_prefix" property="mms_telecom_prefix"/>
        <result column="mms_telecom_suffix" property="mms_telecom_suffix"/>
        <result column="mms_telecom_num" property="mms_telecom_num"/>
        <result column="batch_api_sms" property="batch_api_sms"/>
        <result column="fixed_length" property="fixed_length"/>
        <result column="zt_ms" property="zt_ms"/>
        <result column="report_url" property="report_url"/>
        <result column="reply_url" property="reply_url"/>
        <result column="push_flag" property="push_flag"/>
        <result column="is_lock" property="is_lock"/>
        <result column="username" property="username"/>
        <result column="is_audit_word" property="is_audit_word"/>
        <result column="error_count" property="error_count"/>
        <result column="contact_name" property="spContact_name"/>
        <result column="contact_mdn" property="spContact_mdn"/>
        <result column="sp_saler" property="sp_saler"/>
        <result column="sp_saler_mdn" property="sp_saler_mdn"/>
        <result column="droptime" property="droptime"/>
        <result column="sp_channelconfig" property="sp_channelconfig"/>
        <result column="sp_mms_channelconfig" property="sp_mms_channelconfig"/>
        <result column="sp_audit_type" property="audit_type"/>
        <result column="sp_type" property="sp_type"/>
        <result column="samemdnmaxnum" property="samemdnmaxnum"/>
        <result column="minsendtotal" property="minsendtotal"/>
        <result column="no_limit_mdn" property="no_limit_mdn"/>
        <result column="return_type" property="return_type"/>
        <result column="sp_audit_number" property="sp_audit_number"/>
        <result column="saleprice" property="saleprice"/>
        <result column="email" property="email"/>
        <result column="sp_desc" property="sp_desc"/>
        <result column="platform" property="platform"/>
        <result column="content_type" property="content_type"/>
        <result column="is_need_signture" property="is_need_signture"/>
        <result column="groupid" property="groupid"/>
        <result column="samecontentmaxnum" property="same_content_max_num"/>
        <result column="is_flowcode" property="is_flowcode"/>
        <result column="is_api" property="is_api"/>
        <result column="return_fee_type" property="return_fee_type"/>
        <result column="unknown_billing" property="unknown_billing"/>
        <result column="begin_send_time" property="beginSendTime"/>
        <result column="end_send_time" property="endSendTime"/>
        <result column="begin_send_time_one" property="beginSendTime1"/>
        <result column="end_send_time_one" property="endSendTime1"/>
        <result column="send_type" property="sendType"/>
        <result column="plan_send_time" property="planSendTime"/>
        <result column="is_send_priority" property="is_send_priority"/>
        <result column="send_priority" property="send_priority"/>
        <result column="business_license" property="business_license"/>
        <result column="identity_front" property="identity_front"/>
        <result column="identity_side" property="identity_side"/>
        <result column="check_signture_bank" property="check_signture_bank"/>
        <result column="is_contract" property="isContract"/>
        <result column="fail_retrun" property="failRetrun"/>
        <result column="sa_id" property="saId"/>
        <result column="sa_name" property="saName"/>
        <result column="product_id" property="productId"/>
        <result column="long_sms_show_first" property="longSmsShowFirst"/>
        <result column="intercept_timing" property="interceptTiming"/>
        <result column="enable_shunt" property="enableShunt"/>
        <result column="enable_resend" property="enableResend"/>
        <result column="null_check_supplier" property="nullCheckSupplier"/>
        <result column="number_transfer_supplier" property="numberTransferSupplier"/>
        <result column="check_null_sign" property="checkNullSign"/>
        <result column="full_name" property="full_name"/>
        <result column="leftover_num" property="leftover_num"/>
        <result column="transfer_interface" property="transfer_interface"/>
        <result column="clientid" property="clientid"/>
        <result column="update_time" property="updateTime"/>
        <result column="blackapi_before" property="blackApiBefore"/>
        <result column="disable_with_number" property="disableWithNumber"/>
        <result column="disable_number_rule" property="disableNumberRule"/>
        <result column="mms_reply_url" property="mmsReplyUrl"/>
        <result column="disableWithNumberTime" property="disableWithNumberTime"/>
        <result column="transfer_local" property="transferLocal"/>
        <result column="sp_scope" property="spScope"/>
        <result column="aim_over_70_limit" property="aim_over_70_limit"/>
        <result column="aim_is_match" property="aim_is_match"/>
        <result column="api_aim_is_match" property="api_aim_is_match"/>
        <result column="mms_template_auto_audit" property="mms_template_auto_audit"/>
        <result column="token" property="token"/>
        <result column="mms_sign_report_push" property="mmsSignReportPush"/>
        <result column="auto_extract_sign" property="auto_extract_sign"/>
        <result column="allow_temp_strategy" property="allow_temp_strategy"/>
        <result column="domainLimit" property="domainLimit"/>
        <result column="currency" property="currency"/>
        <result column="template_no_match" property="template_no_match"/>
        <result column="sign_limit_rule" property="sign_limit_rule"/>
        <result column="sign_template_limit" property="sign_template_limit"/>
        <result column="auto_generate_mmsChannel_template" property="auto_generate_mmsChannel_template"/>
        <result column="subacct_black_flag" property="subacct_black_flag"/>
        <result column="phone_safe_strategy" property="phone_safe_strategy"/>
        <result column="distinguish_fullwidth" property="distinguish_fullwidth"/>
    </resultMap>

    <resultMap type="SpInfo" id="spInfoconfigMap">
        <id column="sp_id" property="spid"/>
        <result column="sp_name" property="sp_name"/>
        <result column="samemdnmaxnum" property="samemdnmaxnum"/>
        <result column="minsendtotal" property="minsendtotal"/>
        <result column="no_limit_mdn" property="no_limit_mdn"/>
        <result column="return_type" property="return_type"/>
        <result column="report_url" property="report_url"/>
        <result column="reply_url" property="reply_url"/>
        <result column="sp_audit_number" property="sp_audit_number"/>
        <result column="saleprice" property="saleprice"/>
        <result column="push_flag" property="push_flag"/>
        <result column="loopsms_sec" property="loopsms_sec"/>
        <result column="loopsms_num" property="loopsms_num"/>
        <result column="loopsms_strategy" property="loopsms_strategy"/>

    </resultMap>

    <resultMap type="SpInfo" id="spAlarmResultMap">
        <id column="id" property="id"/>
        <result column="name" property="sp_saler"/>
        <result column="email" property="email"/>
        <result column="mdn" property="sp_saler_mdn"/>
        <result column="spid" property="spid"/>
        <result column="alarmnumber" property="alarmnumber"/>
    </resultMap>

    <resultMap type="SpInfo" id="spInfoCostMap">
        <id column="id" property="id"/>
        <result column="sp_saler" property="sp_saler"/>
        <result column="sp_name" property="sp_name"/>
        <result column="costprice" property="costprice"/>
        <result column="sp_id" property="spid"/>
        <result column="platform" property="platform"/>
        <result column="margin" property="margin"/>
        <result column="saleprice " property="saleprice "/>
        <result column="month" property="month"/>
        <result column="arrive_num" property="arrive_num"/>
        <result column="createTime" property="createTime"/>
    </resultMap>

    <resultMap type="SpInfo" id="SpInfoGrade">
        <id column="id" property="id"/>
        <result column="spid" property="spid"/>
        <result column="sp_name" property="sp_name"/>
        <result column="blacklist_group_name" property="blacklist_group_name"/>
        <result column="black_id" property="black_id"/>
    </resultMap>
    <resultMap type="SpInfo" id="Grade">
        <id column="id" property="id"/>
        <result column="spid" property="spid"/>
        <result column="sp_name" property="sp_name"/>
        <result column="blacklist_group_name" property="blacklist_group_name"/>
    </resultMap>

    <resultMap type="SpInfo" id="spInfoAndSpmoney">
        <result column="spid" property="spid"/>
        <result column="sp_name" property="sp_name"/>
        <result column="fee_type" property="feetype"/>
        <result column="effect_month" property="effect_month"/>
        <result column="is_api_billing" property="is_api_billing"/>
        <result column="money" property="money"/>
        <result column="use_money" property="useMoney"/>
        <result column="sa_id" property="saId"/>
        <result column="billing_mode" property="billing_mode"/>
        <result column="use_num" property="use_num"/>
        <result column="leftover_num" property="leftover_num"/>
    </resultMap>

    <resultMap type="cn.roadm.bo.SubAcctInfo" id="spSubAcctInfo">
        <id column="id" property="id"/>
        <result column="sp_id" property="spId"/>
        <result column="username" property="userName"/>
        <result column="sms_money" property="smsMoney"/>

        <result column="mms_money" property="mmsMoney"/>
        <result column="inter_money" property="interMoney"/>
        <result column="sub_account_billing_mode" property="subAccountBillingMode"/>

        <result column="role_id" property="roleId"/>
        <result column="mdn" property="mdn"/>
        <result column="createtime" property="createtime"/>
        <result column="groupName" property="groupName"/>

    </resultMap>

	<select id="getAllId" resultType="String">
		select id from sms_sp_info
	</select>

	<select id="getIsById" resultType="int">
		select count(id) from sms_sp_info where id=#{id}
	</select>

    <select id="getSpDescById" parameterType="SpInfo" resultMap="spInfoResultMap">
        select ssi.id spid,ssi.sp_desc,grade,sensitive_word_type,keyword_group_id,sign_gid from sms_sp_info ssi
        where ssi.id =
        #{spid}
    </select>

    <select id="listPageSpAlarm" parameterType="SpInfo" resultMap="spAlarmResultMap">
        select b.*, a.sp_name
        from (select si.id,
        si.name,
        si.email,
        si.mdn,
        si.spid,
        si.scan_time,
        si.alarmnumber
        from sms_sp_alarm_info si) b
        , (select
        sp.id, sp.sp_name,sp.sp_saler from sms_sp_info sp) a
        where a.id = b.spid
        <if test="spid!=null and spid!=0">
            and spid=#{spid}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and a.sp_saler =#{sp_saler}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and a.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        order by a.id desc
    </select>

    <delete id="deleteSpAlarm" parameterType="int">
        delete from sms_sp_alarm_info where id=#{id}
    </delete>

    <select id="getSpAlarmById" parameterType="int" resultMap="spAlarmResultMap">
        select b.*, a.sp_name
        from (select si.id,
        si.name,
        si.email,
        si.mdn,
        si.spid,
        si.scan_time,
        si.alarmnumber
        from sms_sp_alarm_info si) b
        left join
        (select sp.id, sp.sp_name from sms_sp_info sp) a
        on a.id = b.spid
        where
        b.id=#{id}
    </select>

    <update id="updateSpAlarmById" parameterType="SpInfo">
        update
        sms_sp_alarm_info set
        name=#{sp_saler,jdbcType=VARCHAR},
        email=#{email,jdbcType=VARCHAR},
        spid=#{spid},
        scan_time=#{scan_time},
        mdn=#{sp_saler_mdn,jdbcType=VARCHAR},
        alarmnumber=#{alarmnumber}
        where
        id=#{id}
    </update>

    <insert id="insertSpAlarm" useGeneratedKeys="true" keyProperty="id" parameterType="SpInfo">
        insert into sms_sp_alarm_info
        (SPID,NAME,MDN,EMAIL,ALARMNUMBER,scan_time) values
        (#{spid},#{sp_saler,jdbcType=VARCHAR},#{sp_saler_mdn,jdbcType=VARCHAR},#{email,jdbcType=VARCHAR},#{alarmnumber},#{scan_time})
    </insert>

    <select id="listAllSpInfo" resultMap="spInfoResultMap">
        select
        sp.id,sp.sp_name,sp.ip, sp.status,sp.fee_type,sp.createtime,sp.mobile_prefix,sp.mobile_suffix,sp.mobile_num,sp.unicom_prefix,sp.unicom_suffix,sp.unicom_num,sp.telecom_prefix,sp.telecom_suffix,sp.telecom_num,sp.report_url,sp.reply_url,sp.is_lock,sp.is_audit_word,
        su.error_count,sp.contact_name,sp.contact_mdn,sp.sp_saler,sp.sp_saler_mdn,sp.droptime,sp.sp_desc,sp.platform,sp.grade,sp.is_audit_black,sp.sp_type,sp.is_api_billing,sp.return_fee_type
        from sms_sp_info sp ,sms_sp_user_info su
        where su.sp_id=sp.id
        and su.role_id=0
        and sp.status = '1'
        and su.status = '1'
    </select>

    <select id="listAllSpSubAcctInfo" parameterType="integer" resultMap="spSubAcctInfo">
        SELECT su.id, su.sp_id, su.username, su.sms_money, su.mms_money, su.inter_money, sp.sub_account_billing_mode
        FROM sms_sp_user_info su
                 LEFT JOIN sms_sp_info sp ON sp.id = su.sp_id
        WHERE su.role_id != 0 AND su.`status` = 1 AND sp.`status` = 1
        <if test="spid != null ">
           and su.sp_id = #{spid}
        </if>

    </select>

    <select id="listPageSpSubAcctInfo" resultMap="spSubAcctInfo">
        SELECT a.*, d.`name` as groupName FROM
        (SELECT u.id, u.mdn, u.mms_money,u.username,
        u.createtime, u.role_id, u.sms_money, u.inter_money
        FROM sms_sp_user_info u
        <where>
            u.STATUS = 1 and u.role_id != 0
            <if test="spId!=null and spId>0">
                and u.sp_id = #{spId}
            </if>
            <if test="userName != null and userName != ''">
                and u.username like CONCAT('%', #{userName}, '%')
            </if>
        </where>
        ) AS a, sms_department d ,sms_department_user b
        <where>
            a.id = b.userid and b.departmentid = d.id
            <if test="groupId != null and groupId != '' and groupId != 0">
                and d.id=#{groupId}
            </if>
        </where>
        ORDER BY a.createtime DESC
    </select>

    <select id="listPageSpSubAcctCount" parameterType="cn.roadm.bo.SubAccountTaskInfo" resultType="cn.roadm.bo.SubAccountTaskInfo">
        select a.*, IFNULL(d.`name`, '全部') as groupName,
        ROUND(IFNULL(a.arrive_succ / (a.succ + a.fail) * 100, 0), 2) + '%' as successRate
        from
        (select  tk.uid,
        sp.username,
        IFNULL(sum(tk.allnumber),sum(tk.succ) + sum(IFNULL(tk.fail,0))) allnumber,
        sum(tk.succ) succ,
        sum(IFNULL(tk.fail,0)) fail,
        sum(tk.arrive_succ) arrive_succ,
        sum(tk.arrive_fail) arrive_fail
        from
        sms_sp_user_summary tk, sms_sp_user_info sp
        where sp.id = tk.uid
        <if test="sp_id!=null and sp_id>0">
            and sp.sp_id=#{sp_id}
        </if>
        <if test="username!=null and username!=''">
            and sp.username like concat('%',#{username},'%')
        </if>
        <if test="createTime!=null and createTime!=''">
            and tk.stat_time&gt;=str_to_date(#{createTime},'%Y-%m-%d')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and
            tk.stat_time&lt;DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
        <if test="groupId != null and groupId != 0">
            and sp.id in (select userid from sms_department_user where departmentid = #{groupId})
        </if>
        group by sp.id
        order by sp.id) a
        left join sms_department_user b on a.uid = userid
        left join sms_department d on  b.departmentid = d.id
    </select>

    <select id="exportSubAccountCount" parameterType="cn.roadm.bo.SubAccountTaskInfo" resultType="Map">
        select a.*, IFNULL(d.`name`, '全部') as groupName,
        ROUND(IFNULL(a.arrive_succ / (a.succ + a.fail) * 100, 0), 2) + '%' as successRate
        from
        (select tk.uid,
        sp.username,
        IFNULL(sum(tk.allnumber),sum(tk.succ) + sum(IFNULL(tk.fail,0))) allnumber,
        sum(tk.succ) succ,
        sum(IFNULL(tk.fail,0)) fail,
        sum(tk.arrive_succ) arrive_succ,
        sum(tk.arrive_fail) arrive_fail
        from
        sms_sp_user_summary tk, sms_sp_user_info sp
        where sp.id = tk.uid
        <if test="sp_id!=null and sp_id>0">
            and sp.sp_id=#{sp_id}
        </if>
        <if test="username!=null and username!=''">
            and sp.username like concat('%',#{username},'%')
        </if>
        <if test="createTime!=null and createTime!=''">
            and tk.stat_time&gt;=str_to_date(#{createTime},'%Y-%m-%d')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and
            tk.stat_time&lt;DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
        <if test="groupId != null and groupId != 0">
            and sp.id in (select userid from sms_department_user where departmentid = #{groupId})
        </if>
        group by sp.id
        order by sp.id) a
        left join sms_department_user b on a.uid = userid
        left join sms_department d on b.departmentid = d.id
    </select>

    <update id="updateSpSubAccountPwd" parameterType="SpInfo">
        update sms_sp_user_info set
        <if test="password != null and password != ''">
            password= #{password},
        </if>
        <if test="web_password != null and web_password != ''">
            web_password = #{web_password},
        </if>
        <if test="pawd != null and pawd != ''">
            pawd = #{pawd},
        </if>
        <if test="web_pawd != null and web_pawd != ''">
            web_pawd = #{web_pawd},
        </if>
        username = #{username}
        where sp_id = #{spid} and id = #{id}
        and role_id != 0
    </update>

    <select id="querySpSubAccountGroup" resultType="cn.roadm.bo.GroupItem">
        SELECT id, spId, name, orderNum, parentId
        FROM sms_department
        WHERE spId = #{spId}
        ORDER BY ordernum
    </select>

    <select id="listPageSpInfo" parameterType="SpInfo" resultMap="spInfoResultMap">
        select distinct sp.id,sp.sp_name,sp.ip, sp.status,
        sp.international_prefix,sp.international_suffix,sp.international_num,
        sp.fee_type,sp.createtime,sp.mobile_prefix,sp.mobile_suffix,sp.mobile_num,sp.unicom_prefix,sp.unicom_suffix,sp.unicom_num,sp.telecom_prefix,sp.telecom_suffix,sp.telecom_num,
        sp.mms_mobile_prefix,sp.mms_mobile_suffix,sp.mms_mobile_num,sp.mms_unicom_prefix,sp.mms_unicom_suffix,sp.mms_unicom_num,sp.mms_telecom_prefix,sp.mms_telecom_suffix,sp.mms_telecom_num,
        sp.report_url,sp.reply_url,sp.is_lock,
        sp.is_audit_word,sp.contact_name,sp.contact_mdn,sp.sp_saler,sp.sp_saler_mdn,sp.droptime,sp.sp_desc,sp.platform,sp.currency
        ,sp.is_api_billing,sp.fail_retrun failRetrun,is_contract isContract,sp.sa_id,sp.product_id productId,sp.is_open_province_group isOpenProvinceGroup,
        pro_group_id proGroupId,sa.saleprice,sa.billing_mode,sp.sp_type,sp.billing_type,ses.full_name,ssc.leftover_num,sas.clientid, DATE_FORMAT(sp.update_time, '%Y-%m-%d %H:%i:%s') as update_time
        from sms_sp_info sp
        left join sms_api_socket_sp sas on sas.spid = sp.id
        left join sms_sp_charge ssc on sp.id = ssc.sp_id
            left join sale_manager sm on sp.sp_saler = sm.seller
            left join sms_api_setting sa on sp.id=sa.sp_id
            left join sms_enterprise ses on ses.id = sp.eid,
        sms_sp_user_info sp_user
        where sp.id = sp_user.sp_id and sp.status=1
        <if test="clientid != null and clientid != ''">
            and sas.clientid=#{clientid}
            </if>
        <if test="saId!=null and saId>0">
        	and sp.sa_id=#{saId}
            </if>
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="sp_type!=null and sp_type>0">
        	and sp.sp_type =#{sp_type}
        </if>
        <if test="platform!=null and platform!='' and platform >0">
            and sp.platform =#{platform}
        </if>
        <if test="sp_saler!=null and sp_saler!='' and sp_saler!='undefined'">
            and sp.sp_saler =#{sp_saler}
        </if>
        <if test="managerId != null and managerId != ''">
            and sm.managerId = #{managerId}
        </if>
        <if test="spid!=null and spid!=0">
            and sp.id=#{spid}
        </if>
        <if test="is_lock!=null and is_lock!= '' ">
            and sp.is_lock=#{is_lock}
        </if>
        <if test="createTime!=null and createTime!='' ">
            and sp.createtime&gt;=#{createTime}
        </if>
        <if test="createTime1!=null and createTime1!='' ">
            and sp.createtime&lt;=DATE_ADD(#{createTime1},INTERVAL 1 DAY)
        </if>
        <if test="billing_mode!=null and billing_mode!=''">
			and billing_mode = #{billing_mode}
		</if>
        <if test="username != null and username != ''">
            and sp_user.username = #{username}
        </if>
        <if test="spIdCustomerList != null and spIdCustomerList.size() != 0">
            and sp.id in
            <foreach collection="spIdCustomerList" item="item" index="index" open="(" close=")" separator=",">
                ${item}
            </foreach>
        </if>
        <if test="full_name != null and full_name != ''">
            and sp.eid  = #{full_name}
        </if>
        <if test="priceConditionSymbol == 1 and priceConditionValue != null and priceConditionValue != ''">
            and sa.SALEPRICE &gt;= #{priceConditionValue}
        </if>
        <if test="priceConditionSymbol == 2 and priceConditionValue != null and priceConditionValue != ''">
            and sa.SALEPRICE &lt;= #{priceConditionValue}
        </if>
        <if test="spScope != null and spScope != ''">
            and sp.sp_scope = #{spScope}
        </if>
        <if test="star_level != null and star_level != ''">
            and sp.star_level = #{star_level}
        </if>
        order by
        <if test="orderType=='ASC'">
            <if test="col=='saleprice'">
                sa.${col} asc,
            </if>
        </if>
        <if test="orderType=='DESC'">
            <if test="col=='saleprice'">
                sa.${col} desc,
            </if>
        </if>
        createtime desc
    </select>


    <select id="getAllSpInfoGrade" parameterType="SpInfo" resultMap="spInfoResultMap">
        select sp.id,sp.sp_name,sp.sp_type,sp.send_priority,createtime
        from sms_sp_info sp
        where sp.status=1
        <if test="saId!=null and saId>0">
        	and sp.sa_id=#{saId}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="sp_type!=null and sp_type>0">
        	and sp.sp_type =#{sp_type}
        </if>
        <if test="platform!=null and platform!='' and platform >0">
            and sp.platform =#{platform}
        </if>
        <if test="spid!=null and spid!=0">
            and sp.id=#{spid}
        </if>
        <if test="createTime!=null and createTime!='' ">
            and sp.createtime&gt;=#{createTime}
        </if>
        <if test="createTime1!=null and createTime1!='' ">
            and sp.createtime&lt;=DATE_ADD(#{createTime1},INTERVAL 1 DAY)
        </if>
        <if test="billing_mode!=null and billing_mode!=''">
			and billing_mode = #{billing_mode}
		</if>
        <if test="username != null and username != ''">
            and sp_user.username = #{username}
        </if>
        order by
        createtime desc
    </select>

     <select id="listPageAgentSpInfo" parameterType="SpInfo" resultMap="spInfoResultMap">
        select sp.id,sp.sp_name,sp.ip, sp.status,
        sp.international_prefix,sp.international_suffix,sp.international_num,
        sp.fee_type,sp.createtime,sp.mobile_prefix,sp.mobile_suffix,sp.mobile_num,sp.unicom_prefix,sp.unicom_suffix,sp.unicom_num,sp.telecom_prefix,sp.telecom_suffix,sp.telecom_num,
        sp.mms_mobile_prefix,sp.mms_mobile_suffix,sp.mms_mobile_num,sp.mms_unicom_prefix,sp.mms_unicom_suffix,sp.mms_unicom_num,sp.mms_telecom_prefix,sp.mms_telecom_suffix,sp.mms_telecom_num,
        sp.report_url,sp.reply_url,sp.is_lock,
        sp.is_audit_word,sp.contact_name,sp.contact_mdn,sp.sp_saler,sp.sp_saler_mdn,sp.droptime,sp.sp_desc,sp.platform
        ,sp.is_api_billing,sp.fail_retrun failRetrun,sp.is_contract isContract,sa.sa_name saName,sp.sa_id saId
        from sms_sp_info sp,sms_agent_info sa
        where sp.status=1 and sp.sa_id=sa.id
        <if test="saId!=null and saId>0">
        	and sp.sa_id=#{saId}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="platform!=null and platform!='' and platform >0">
            and sp.platform =#{platform}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler =#{sp_saler}
        </if>
        <if test="spid!=null and spid!=0">
            and sp.id=#{spid}
        </if>
        <if test="createTime!=null and createTime!='' ">
            and sp.createtime&gt;=#{createTime}
        </if>
        <if test="createTime1!=null and createTime1!='' ">
            and sp.createtime&lt;=DATE_ADD(#{createTime1},INTERVAL 1 DAY)
        </if>
        order by createtime desc
    </select>

    <update id="removeSp">
    	update sms_sp_info set sa_id=null where id=#{id}
    </update>
    <update id="addSp">
    	update sms_sp_info set sa_id=#{saId} where id=#{spid}
    </update>

    <update id="updateSpBillingMode">
    	update sms_api_setting set billing_mode=#{billing_mode} where sp_id=#{spid}
    </update>

    <select id="listPageUnlockSpInfo" parameterType="SpInfo" resultMap="spInfoResultMap">
      select s.id,s.sp_name,su.error_count from sms_sp_info s,sms_sp_user_info su where
         su.SP_ID =s.id
        and su.role_id=0
        and s.is_lock= 0 and
        su.error_count>=5
    </select>

    <select id="listPageSpCharge" parameterType="SpInfo"
            resultMap="spInfoAndSpcharge">
        select sp.spid,
        sp.sp_name,
        sp.fee_type,
        sp.is_api_billing,
        sp.platform,
        sp.sp_saler,
        sp.month_limit,
        sp.day_limit,
        a.max_num,
        a.use_num,
        a.leftover_num,
        a.effect_month
        from ( select DISTINCT id
        spid,sp_name,fee_type,platform,sp_saler,is_api_billing,sa.month_limit,sa.day_limit from sms_sp_info sp left join sms_api_setting sa on sp.id=sa.sp_id left join sale_manager sm on sp.sp_saler = sm.seller
        where sp.status!=2  and sp.is_api_billing=0
        <if test="spid!=null">
            and sp.id=#{spid}
        </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 = #{sp_saler}
        </if>
        <if test="managerId != null and managerId != ''">
            and sm.managerId = #{managerId}
        </if>
        <if test="sp_type!=null and sp_type!='' and sp_type!=0">
            and sp.sp_type= #{sp_type}
        </if>
        <if test="platform!=null and platform!='' and platform >0">
            and sp.platform =#{platform}
        </if>
        ) sp left join (
        select sc.sp_id,
        sum(sc.max_num) max_num,
        sum(sc.use_num) use_num,
        sum(sc.leftover_num) leftover_num,
        (select
        max(sc1.effect_month) from sms_sp_charge sc1
        <where>
            <if test="spid!=null">
                and sc1.sp_id=#{spid}
            </if>
        </where>
        ) effect_month
        from sms_sp_charge sc
        <where>
            <if test="spid!=null">
                and sc.sp_id=#{spid}
            </if>
            <if test="effect_month!=null and effect_month!='' ">
                and sc.effect_month =#{effect_month}
            </if>
        </where>
        group by sc.SP_ID
        ) a
        on a.sp_id = sp.spid
        order by sp.spid desc
    </select>

    <select id="listPageSpChargeMms" parameterType="SpInfo"
            resultMap="spInfoAndSpcharge">
        SELECT sp.id spid , sp.sp_name, sp.is_api_billing, sp.platform,
        sc.max_num,
        sc.use_num,
        sc.leftover_num,
        sc.effect_month
        from sms_sp_info sp
        LEFT JOIN sms_sp_charge_mms sc
        on sp.id = sc.sp_id
        WHERE sp.status!=2 and sp.is_api_billing=0
        <if test="spid!=null">
            and sp.id=#{spid}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        order by sp.id desc
    </select>

    <select id="exportChargeList" parameterType="SpInfo" resultType="Map">
        select sp.spid,
        sp.sp_name,
        sp.fee_type,
        a.max_num,
        a.use_num,
        a.leftover_num,
        a.id,
        a.effect_month
        from ( select id spid
        ,sp_name,fee_type from sms_sp_info where status!=2
        <if test="spid!=null and spid!=0">
            and id=#{spid}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        ) sp left join (select sc.sp_id,
        sc.max_num,
        sc.use_num,
        sc.leftover_num,
        sc.id,
        sc.effect_month
        from sms_sp_charge sc
        <if test="effect_month!=null and effect_month!='' ">
            where sc.effect_month =#{effect_month}
        </if>
        <if test="effect_month==null || effect_month=='' ">
            where sc.effect_month =date_format(sysdate(),'%Y-%m')
        </if>
        ) a
        on a.sp_id = sp.spid
    </select>

    <!-- 充值记录列表 -->
    <select id="listPageChargeRecord" parameterType="ChargeRecord" resultMap="ChargeRecordResult">
        select sd.id,
        sd.charge_time,
        sd.sp_id,
        sd.chargenum,
        sd.chargeafternum,
        sd.chargeopeartor,
        sd.amount,
        sd.type,
        sd.price,
        sd.price display_price,
        sd.descption,
        sp.sp_name,
        sp.platform,
        sd.pay_type,
        sd.pay_time
        from
        sms_charge_record sd, sms_sp_info sp
        where sp.id = sd.sp_id
        and sp.status!=2
        <if test="platform!=null and platform!=0">
            and sp.platform = #{platform}
        </if>
        <if test="pay_type!=null and pay_type!=''">
            and sd.pay_type = #{pay_type}
        </if>
        <if test="sp_id!=null and sp_id!=0">
            and sp.id=#{sp_id}
        </if>
        <if test="month!=null and month!=''">
            and date_format(sd.charge_time ,'%Y-%m')=#{month}
        </if>
        <if test="createTime!=null and createTime!=''">
            and sd.charge_time&gt;=str_to_date(#{createTime},'%Y-%m-%d')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and
            sd.charge_time&lt;=DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </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 =#{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>
        order by sd.charge_time desc
    </select>

    <!-- 预支记录列表 -->
    <select id="listPageChargeRecordMonth" parameterType="ChargeRecord" resultMap="ChargeRecordResult">
    	SELECT
			sd.CHARGENUM chargeNum,
			sp.sp_name,
			sp.sp_saler,
			sa.saleprice,
			sp.id sp_id,
			TIMESTAMPDIFF(month, sp.createtime,date_add(NOW(), interval -day(now())+1 DAY)) newOrOld
		FROM
			sms_sp_info sp,(
			SELECT
				sum( CHARGENUM ) CHARGENUM,
				SP_ID
			FROM
			sms_charge_record
			<where>
				type=1
				<if test="sp_id!=null and sp_id!=''">
					and sp_id=#{sp_id}
				</if>
				<if test="pay_type!=null and pay_type!=''">
					and pay_type = #{pay_type}
				</if>
				<if test="createTime!=null and createTime!=''">
		            and year(charge_time)=year(str_to_date(#{createTime},'%Y-%m'))
		            and month(charge_time)=month(str_to_date(#{createTime},'%Y-%m'))
		        </if>
			</where>
			GROUP BY
				SP_ID
			) sd,
		sms_api_setting sa
		WHERE
		sp.id = sd.SP_ID
		AND sp.id = sa.SP_ID
		<if test="sp_name!=null and sp_name!=''">
			and sp_name like concat('%',#{sp_name},'%')
		</if>
		<if test="sp_saler!=null and sp_saler!=''">
			and sp_saler = #{sp_saler}
		</if>
		<if test="newOrOld==1">
			and TIMESTAMPDIFF(month, sp.createtime,date_add(NOW(), interval -day(now())+1 DAY)) &gt;2
		</if>
		<if test="newOrOld==2">
			and TIMESTAMPDIFF(month, sp.createtime,date_add(NOW(), interval -day(now())+1 DAY)) &lt;= 2
		</if>
    </select>

    <update id="updateSpChargeRecord" parameterType="int">
    	update sms_charge_record set pay_time = DATE_FORMAT(now(),"%Y-%m-%d %H:%m:%s"),pay_type=2 where id=#{id}
    </update>

    <update id="updateSpChargeRecordMms" parameterType="int">
    	update sms_charge_record_mms set pay_time = DATE_FORMAT(now(),"%Y-%m-%d %H:%i:%s"),pay_type=2 where id=#{id}
    </update>

    <!-- 彩信充值记录列表 -->
    <select id="listPageChargeRecordMms" parameterType="ChargeRecordMms" resultMap="ChargeRecordMmsResult">
        select sd.id,
        sd.charge_time,
        sd.sp_id,
        sd.chargenum,
        sd.chargeopeartor,
        sd.amount,
        sd.type,
        sd.price,
        sd.descption,
        sp.sp_name,
        sp.platform,
        sd.pay_type,
        sd.pay_time
        from
        sms_charge_record_mms sd, sms_sp_info sp
        where sp.id = sd.sp_id
        and sp.status!=2
        <if test="platform!=null and platform!=0">
            and sp.platform = #{platform}
        </if>
        <if test="sp_id!=null and sp_id!=0">
            and sp.id=#{sp_id}
        </if>
        <if test="month!=null and month!=''">
            and date_format(sd.charge_time ,'%Y-%m')=#{month}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        order by sd.charge_time desc
    </select>

    <select id="exportspChargeRecord" parameterType="ChargeRecord" resultType="Map">
        select sd.id,
        date_format( sd.charge_time,'%Y-%m-%d %H:%i:%s')
        charge_time,
        sd.sp_id,
        sd.chargenum,
        sd.chargeopeartor,
        sd.amount,
        <!--         decode(sd.type,1,'充值',2,'扣减')type, -->
        case
        when sd.type=1 then '充值'
        when sd.type=2 then '扣减'
        else '代理商等其他类型'
        end as type,
        sd.price,
        sd.descption,
        sp.sp_name
        from sms_charge_record sd, sms_sp_info sp
        where sp.id = sd.sp_id
        <if test="sp_id!=null and sp_id!=0">
            and sp.id=#{sp_id}
        </if>
        <if test="month!=null and month!=''">
            and date_format(sd.charge_time ,'%Y-%m')=#{month}
        </if>
        <if test="createTime!=null and createTime!=''">
            and sd.charge_time&gt;=str_to_date(#{createTime},'%Y-%m-%d')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and
            sd.charge_time&lt;=DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        order by sd.charge_time desc
    </select>
    <select id="exportspChargeRecordMms" parameterType="ChargeRecordMms" resultType="Map">
        select sd.id,
        date_format( sd.charge_time,'%Y-%m-%d %H:%i:%s')
        charge_time,
        sd.sp_id,
        sd.chargenum,
        sd.chargeopeartor,
        sd.amount,
        <!--         decode(sd.type,1,'充值',2,'扣减')type, -->
        case
        when sd.type=1 then '充值'
        when sd.type=2 then '扣减'
        else '其他类型'
        end as type,
        sd.price,
        sd.descption,
        sp.sp_name
        from sms_charge_record sd, sms_sp_info sp
        where sp.id = sd.sp_id
        <if test="sp_id!=null and sp_id!=0">
            and sp.id=#{sp_id}
        </if>
        <if test="month!=null and month!=''">
            and date_format(sd.charge_time ,'%Y-%m')=#{month}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        order by sd.charge_time desc
    </select>

    <select id="getChannelInfoRepeat" parameterType="SpInfo" resultMap="spInfoAndChannel">
        select
        sp.id,sp.sp_name,sp.mobile_prefix,sp.mobile_suffix,sp.mobile_num,sp.unicom_prefix,sp.unicom_suffix,sp.unicom_num,sp.telecom_prefix,sp.telecom_suffix,sp.platform,sa.content_type
        from sms_sp_info sp ,sms_api_setting sa
        where sp.id=sa.sp_id
        and sp.status=1
        <if test="spid != null and spid >0 ">
            AND sp.id != #{spid}
        </if>
        <if test="unicom_num!=null and unicom_num!=''">
            and sp.unicom_num = #{unicom_num}
        </if>
        <if test="mobile_num!=null and mobile_num!=''">
            and sp.mobile_num = #{mobile_num}
        </if>
        <if test="telecom_num!=null and telecom_num!=''">
            and sp.telecom_num = #{telecom_num}
        </if>
    </select>

    <select id="listPageSpCountryInfo" parameterType="SpInfo" resultMap="spInfoAndChannel">
        select
        sp.international_prefix,sp.international_suffix,sp.international_num,
        sp.id,sp.sp_name,sp.mobile_prefix,sp.mobile_suffix,sp.mobile_num,sp.unicom_prefix,sp.unicom_suffix,sp.unicom_num,sp.telecom_prefix,sp.telecom_suffix,
        sp.mms_mobile_prefix,sp.mms_mobile_suffix,sp.mms_mobile_num,sp.mms_unicom_prefix,sp.mms_unicom_suffix,sp.mms_unicom_num,sp.mms_telecom_prefix,sp.mms_telecom_suffix,sp.platform,sa.content_type,
        sp.is_open_province isOpenProvince, sp.pro_group_id as proGroupId, sp.is_open_province_group isOpenProvinceGroup, spg.name proGroupName,sscc.type as isOpenChannelGroup,sscc.mobile ,sscc.unicom ,sscc.telecom,sscc.mobileGroup ,sscc.unicomGroup ,sscc.telecomGroup
        , sp.countryGroupId,sp.inter_sms_flag,sp.is_open_country
        from sms_sp_info sp left join sms_api_setting sa
        on sp.id=sa.sp_id
        left join sms_province_group spg
        on sp.pro_group_id = spg.id
        left join sms_sp_channel_config sscc
        on sscc.spid = sp.id
        where 1=1
        and sp.status=1
        <if test="sp_type!=null and sp_type!=''">
            and sp.sp_type =#{sp_type}
        </if>
        <if test="platform!=null and platform!='' and platform >0">
            and sp.platform =#{platform}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="mobile!=null and mobile != '' and mobile.indexOf('g') &gt;= 0">
            and sp.id in (select spId from sms_sp_channel_config where type = 1 and mobileGroup like CONCAT(#{mobileChannelGroupStringId}, ',%'))
        </if>
        <if test="mobile!=null and mobile != '' and mobile.indexOf('g') &lt; 0">
            and  sp.id in(select sp_id from sms_chennel_config where OPERTOR_TYPE=2 and CHANNELID=#{mobile})
        </if>
        <if test="unicom!=null and unicom != '' and unicom.indexOf('g') &lt; 0">
            and sp.id in(select sp_id from sms_chennel_config where OPERTOR_TYPE=1 and CHANNELID=#{unicom})
        </if>
        <if test="unicom!=null and unicom != '' and unicom.indexOf('g') &gt;= 0">
            and sp.id in (select spId from sms_sp_channel_config where type = 1 and unicomGroup like CONCAT(#{unicomChannelGroupStringId}, ',%'))
        </if>
        <if test="telecom !=null and telecom != '' and telecom.indexOf('g') &lt; 0">
            and sp.id in(select sp_id from sms_chennel_config where OPERTOR_TYPE=3 and CHANNELID=#{telecom})
        </if>
        <if test="telecom !=null and telecom != '' and telecom.indexOf('g') &gt;= 0">
            and sp.id in (select spId from sms_sp_channel_config where type = 1 and telecomGroup like CONCAT(#{telecomChannelGroupStringId}, ',%'))
        </if>
        <if test="mobile_suffix!=null and mobile_suffix!=''">
            and sp.mobile_suffix=#{mobile_suffix}
        </if>
        <if test="unicom_suffix!=null and unicom_suffix!=''">
            and sp.unicom_suffix=#{unicom_suffix}
        </if>
        <if test="telecom_suffix!=null and telecom_suffix!=''">
            and sp.telecom_suffix=#{telecom_suffix}
        </if>
        <if test="mms_mobile_num!=null and mms_mobile_num!=''">
            and sp.mms_mobile_num like CONCAT('%',#{mms_mobile_num},'%')
        </if>
        <if test="mms_unicom_num!=null and mms_unicom_num!=''">
            and sp.mms_unicom_num like CONCAT('%',#{mms_unicom_num},'%')
        </if>
        <if test="mms_telecom_num!=null and mms_telecom_num!=''">
            and sp.mms_telecom_num like CONCAT('%',#{mms_telecom_num},'%')
        </if>
        <if test="inter_sms_flag!=null">
            and sp.inter_sms_flag=#{inter_sms_flag}
        </if>
        <if test="spid!=null and spid!=0">
            and sp.id=#{spid}
        </if>
        <if test="spScope != null and spScope != ''">
            and sp.sp_scope = #{spScope}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler =#{sp_saler}
        </if>
        <if test="channelid!=null and channelid!='-1'">
            and sp.id in (
            select spi.id spid
            from sms_country_group_config spgc, sms_sp_info spi
            where spgc.group_id = spi.countryGroupId
            and (spgc.interchannel=#{channelid})
            )
        </if>
        order by sp.createtime desc
    </select>

    <select id="listPageSpChannelInfo" parameterType="SpInfo" resultMap="spInfoAndChannel">
        select
        sp.international_prefix,sp.international_suffix,sp.international_num,
        sp.id,sp.sp_name,sp.mobile_prefix,sp.mobile_suffix,sp.mobile_num,sp.unicom_prefix,sp.unicom_suffix,sp.unicom_num,sp.telecom_prefix,sp.telecom_suffix,
        sp.mms_mobile_prefix,sp.mms_mobile_suffix,sp.mms_mobile_num,sp.mms_unicom_prefix,sp.mms_unicom_suffix,sp.mms_unicom_num,sp.mms_telecom_prefix,sp.mms_telecom_suffix,sp.platform,sa.content_type,sa.otype_limit,
        sp.is_open_province isOpenProvince, sp.pro_group_id as proGroupId, sp.is_open_province_group isOpenProvinceGroup, spg.name proGroupName,sscc.type as isOpenChannelGroup,sscc.mobile ,sscc.unicom ,sscc.telecom,sscc.mobileGroup ,sscc.unicomGroup ,sscc.telecomGroup
        , sp.countryGroupId,sp.inter_sms_flag,sp.is_open_country
        from sms_sp_info sp left join sms_api_setting sa
        on sp.id=sa.sp_id
        left join sms_province_group spg
        on sp.pro_group_id = spg.id
        left join sms_sp_channel_config sscc
        on sscc.spid = sp.id
        where 1=1
        and sp.status=1
        <if test="sp_type!=null and sp_type!=''">
            and sp.sp_type =#{sp_type}
        </if>
        <if test="platform!=null and platform!='' and platform >0">
            and sp.platform =#{platform}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="mobile!=null and mobile != '' and mobile.indexOf('g') &gt;= 0">
            and sp.id in (select spId from sms_sp_channel_config where type = 1 and mobileGroup like CONCAT(#{mobileChannelGroupStringId}, ',%'))
        </if>
        <if test="mobile!=null and mobile != '' and mobile.indexOf('g') &lt; 0">
            and  sp.id in(select sp_id from sms_chennel_config where OPERTOR_TYPE=2 and CHANNELID=#{mobile})
        </if>
        <if test="unicom!=null and unicom != '' and unicom.indexOf('g') &lt; 0">
            and sp.id in(select sp_id from sms_chennel_config where OPERTOR_TYPE=1 and CHANNELID=#{unicom})
        </if>
        <if test="unicom!=null and unicom != '' and unicom.indexOf('g') &gt;= 0">
            and sp.id in (select spId from sms_sp_channel_config where type = 1 and unicomGroup like CONCAT(#{unicomChannelGroupStringId}, ',%'))
        </if>
        <if test="telecom !=null and telecom != '' and telecom.indexOf('g') &lt; 0">
             and sp.id in(select sp_id from sms_chennel_config where OPERTOR_TYPE=3 and CHANNELID=#{telecom})
        </if>
        <if test="telecom !=null and telecom != '' and telecom.indexOf('g') &gt;= 0">
            and sp.id in (select spId from sms_sp_channel_config where type = 1 and telecomGroup like CONCAT(#{telecomChannelGroupStringId}, ',%'))
        </if>
        <if test="mobile_suffix!=null and mobile_suffix!=''">
            and sp.mobile_suffix=#{mobile_suffix}
        </if>
        <if test="unicom_suffix!=null and unicom_suffix!=''">
            and sp.unicom_suffix=#{unicom_suffix}
        </if>
        <if test="telecom_suffix!=null and telecom_suffix!=''">
            and sp.telecom_suffix=#{telecom_suffix}
        </if>
        <if test="mms_mobile_num!=null and mms_mobile_num!=''">
            and sp.mms_mobile_num like CONCAT('%',#{mms_mobile_num},'%')
        </if>
        <if test="mms_unicom_num!=null and mms_unicom_num!=''">
            and sp.mms_unicom_num like CONCAT('%',#{mms_unicom_num},'%')
        </if>
        <if test="mms_telecom_num!=null and mms_telecom_num!=''">
            and sp.mms_telecom_num like CONCAT('%',#{mms_telecom_num},'%')
        </if>
        <if test="inter_sms_flag!=null">
            and sp.inter_sms_flag=#{inter_sms_flag}
        </if>
        <if test="spid!=null and spid!=0">
            and sp.id=#{spid}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler =#{sp_saler}
        </if>
        <if test="channelid!=null and channelid!='-1'">
            and sp.id in (
            select spid
            from sms_channel_province_config
            where mobilechannel=#{channelid} or unicomchannel=#{channelid} or telecomchannel=#{channelid}
            union
            select spi.id spid
            from sms_province_group_config spgc, sms_sp_info spi
            where spgc.group_id = spi.pro_group_id
            and (spgc.mobilechannel=#{channelid} or spgc.unicomchannel=#{channelid} or spgc.telecomchannel=#{channelid})
            )
        </if>
        <if test="spScope != null and spScope != ''">
            and sp.sp_scope = #{spScope}
        </if>
        order by sp.createtime desc
    </select>

    <select id="listPageSpMmsChannelInfo" parameterType="SpInfo" resultMap="spInfoAndChannel">
        select
        sp.international_prefix,sp.international_suffix,sp.international_num,
        sp.id,sp.sp_name,sp.mobile_prefix,sp.mobile_suffix,sp.mobile_num,sp.unicom_prefix,sp.unicom_suffix,sp.unicom_num,sp.telecom_prefix,sp.telecom_suffix,
        sp.mms_mobile_prefix,sp.mms_mobile_suffix,sp.mms_mobile_num,sp.mms_unicom_prefix,sp.mms_unicom_suffix,sp.mms_unicom_num,sp.mms_telecom_prefix,sp.mms_telecom_suffix,sp.platform,sa.content_type,
        sp.is_open_mms_province isOpenMmsProvince, sp.mms_pro_group_id as mmsProvinceGroupId, sp.is_open_mms_province_group isOpenMmsProvinceGroup, spg.name proGroupName
        , sp.countryGroupId,sp.inter_sms_flag,sp.is_open_country
        from sms_sp_info sp left join sms_api_setting sa
        on sp.id=sa.sp_id
        left join mms_province_group spg
        on sp.mms_pro_group_id = spg.id
        where
        sp.status=1
        <if test="sp_type!=null and sp_type!=''">
            and sp.sp_type =#{sp_type}
        </if>
        <if test="platform!=null and platform!='' and platform >0">
            and sp.platform =#{platform}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="mobile_suffix!=null and mobile_suffix!=''">
            and sp.mobile_suffix=#{mobile_suffix}
        </if>
        <if test="unicom_suffix!=null and unicom_suffix!=''">
            and sp.unicom_suffix=#{unicom_suffix}
        </if>
        <if test="telecom_suffix!=null and telecom_suffix!=''">
            and sp.telecom_suffix=#{telecom_suffix}
        </if>
        <if test="mms_mobile_num!=null and mms_mobile_num!=''">
            and sp.mms_mobile_num like CONCAT('%',#{mms_mobile_num},'%')
        </if>
        <if test="mms_unicom_num!=null and mms_unicom_num!=''">
            and sp.mms_unicom_num like CONCAT('%',#{mms_unicom_num},'%')
        </if>
        <if test="mms_telecom_num!=null and mms_telecom_num!=''">
            and sp.mms_telecom_num like CONCAT('%',#{mms_telecom_num},'%')
        </if>
        <if test="inter_sms_flag!=null">
            and sp.inter_sms_flag=#{inter_sms_flag}
        </if>
        <if test="spid!=null and spid!=0">
            and sp.id=#{spid}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler =#{sp_saler}
        </if>
        <if test="channelid!=null and channelid!='-1'">
            and sp.id in (
            select spid
            from mms_channel_province_config
            where mobilechannel=#{channelid} or unicomchannel=#{channelid} or telecomchannel=#{channelid}
            union
            select spi.id spid
            from mms_province_group_config spgc, sms_sp_info spi
            where spgc.group_id = spi.mms_pro_group_id
            and (spgc.mobilechannel=#{channelid} or spgc.unicomchannel=#{channelid} or spgc.telecomchannel=#{channelid})
            )
        </if>
        order by sp.createtime desc
    </select>

    <select id="getSpInfoMmsSuffixBy" parameterType="SpInfo" resultMap="spInfoAndChannel">
    	select sp_name,mms_mobile_suffix,mms_telecom_suffix,mms_unicom_suffix from sms_sp_info where id=#{spid} limit 1
    </select>
	<select id="getMmsChannelid" parameterType="PaConfig" resultMap="paConfigIsSupport">
		select id,channel_name,is_support_unicom,is_support_mobile,is_support_telecom from mms_send_channel_info where id=#{channelid} limit 1
	</select>
    <select id="listPageSpConfig" parameterType="SpInfo" resultMap="spInfoconfigMap">
        select s.sp_name,
        g.sp_id,
        g.share_limit_sp,
        g.content_length_limit,
        g.samemdnmaxnum,
        g.minsendtotal,
        g.no_limit_mdn,
        g.return_type,
        g.report_url,
        g.reply_url,
        g.sp_audit_number,
        g.saleprice,
        g.push_buyun,
        IFNULL(g.samemdn_nday,0) samemdn_nday,
        IFNULL(g.limit_days,0) limit_days,
        IFNULL(g.samemdn_oneday,0) samemdn_oneday,
        IFNULL(g.samemdn_threeday,0) samemdn_threeday,
        IFNULL(g.samemdn_oneminute,0) samemdn_oneminute,
        IFNULL(g.samemdn_onehour,0) samemdn_onehour,
        IFNULL(g.loopsms_sec,0) loopsms_sec,
        IFNULL(g.loopsms_num,0) loopsms_num,
        IFNULL(g.loopsms_strategy,0) loopsms_strategy,
        g.push_flag,
        g.batch_api_sms,
        g.fixed_length,
        g.zt_ms
        from
        sms_api_setting g, sms_sp_info s
        where s.id = g.sp_id
        and s.status != 2
        <if test="sp_name!=null and sp_name!=''">
            and s.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="spid!=null and spid!=0">
            and s.id=#{spid}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and s.sp_saler =#{sp_saler}
        </if>
        <if test="salerList!=null and salerList.size()>0">
            and s.sp_saler in
            <foreach collection="salerList"  index="index"  item="item" open="(" separator="," close=")">
                '${item}'
            </foreach>
        </if>
        <if test="spScope != null and spScope != ''">
            and s.sp_scope = #{spScope}
        </if>
        order by s.id desc
    </select>

    <select id="getSpInfo" parameterType="SpInfo" resultMap="spInfoResultMap">
        select
        sp.id,sp.sp_name,sp.ip,sp.status,sp.sp_name,sp.fee_type,sp.createtime,sp.mobile_prefix,sp.mobile_suffix,sp.mobile_num,sp.unicom_prefix,sp.unicom_suffix,sp.unicom_num,sp.telecom_prefix,sp.telecom_suffix,sp.telecom_num,sp.report_url,sp.reply_url,sp.is_lock,sp.is_audit_word,
        sp.error_count,sp.contact_name,sp.contact_mdn,sp.sp_saler,sp.sp_saler_mdn,sp.droptime,sp.platform
        from sms_sp_info sp
        where 1=1
        <if test="sp_name!=null ">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="spid!=null and spid>0">
            and sp.id = #{spid}
        </if>

    </select>

    <select id="getSpInfoBySpNames" parameterType="SpInfo" resultMap="spInfoResultMap">
        select
        sp.id
        from sms_sp_info sp
        where sp.sp_name like CONCAT('%',#{spName},'%')
    </select>

    <select id="getSpinfoById" parameterType="int" resultMap="spInfoResultMap">
        select
        sp.id,sp.sp_name,sp.ip,sp.status,sp.fee_type,sp.createtime,sp.currency
        ,sp.mms_mobile_prefix,sp.mms_mobile_suffix,sp.mms_mobile_num,sp.mms_unicom_prefix,sp.mms_unicom_suffix,sp.mms_unicom_num,sp.mms_telecom_prefix,sp.mms_telecom_suffix,sp.mms_telecom_num
        ,sp.mobile_prefix,sp.mobile_suffix,sp.mobile_num,sp.unicom_prefix,sp.unicom_suffix,sp.unicom_num,sp.telecom_prefix,sp.telecom_suffix,sp.telecom_num

        ,sa.report_url,sa.reply_url,sa.push_flag,sp.is_lock,sp.is_audit_word,sp.is_audit_black,sp.template_word_policy,sp.is_api_billing,sp.sp_type,
        su.username,su.web_pawd,su.token,pawd,sp.contact_name,sp.contact_mdn,sp.sp_saler,sp.signature,sp.sp_saler_mdn,sp.droptime,sp.sp_channelconfig,sa.sp_audit_type,
        sa.samemdnmaxnum, sa.minsendtotal, sa.no_limit_mdn, sa.return_type, sa.saleprice, sa.saleprice display_saleprice, sa.sp_audit_number, sa.isvalidbome, sa.isreportnow,
        sa.samecontentmaxnum, sa.is_flowcode, sp.sp_desc, sp.platform, sa.content_type, sp.is_need_signture, sp.check_signture_bank,
        sp.groupid, sp.is_api, sp.is_web, sp.url_detect, sp.return_fee_type, sp.unknown_billing, sa.begin_send_time, sa.end_send_time,
        sa.begin_send_time_one, sa.end_send_time_one, sa.send_type, sa.plan_send_time, su.id userid, sp.grade,sa.samemdn_nday, sa.limit_days,
        sa.samemdn_threeday, sa.samemdn_oneday, sa.samemdn_oneminute, sa.samemdn_onehour, sa.share_limit_sp, sp.sensitive_word_type, sp.verification_code_free_review, sp.is_send_priority, sa.push_buyun, sa.push_receiver,
        sa.push_pswd, sa.samemsg_nminute, sa.samemsg_nnum, sa.batch_api_sms, sa.fixed_length, sa.zt_ms, sp.send_priority, sa.send_province, sp.business_license, sp.identity_front, sp.identity_side, sp.is_contract isContract,
        sp.fail_retrun failRetrun, sp.product_id, sa.loopsms_sec, sa.loopsms_num, sa.loopsms_strategy, sp.unsend_province, sp.is_open_channel_limit, sp.vcode_black_flag, sp.web_send_flag, sp.noProfit, sp.commission_price,
        sp.beauty_phone_flag, sp.system_limit_flag, sp.web_export_flag, sp.is_open_transfer, sp.inter_sms_flag, sp.inter_price_group, sp.inter_price_rate, sp.web_show_status_flag, sa.push_limit, sa.day_limit, sa.month_limit,
        sa.success_limit, sp.multi_sign_flag, sp.back_sign_flag, sp.unsend_city, sp.provinceNetPrice, sa.billing_mode, sp.detachment, sp.keyword_group_id, sp.phone_bypass_flag, sp.mms_phone_bypass_flag, sp.enableClientSms,
        sp.randomCallMdnSuffix, sp.clientMenu, sp.is_batch_black, sp.is_batch_mms, sp.client_status_col, sp.client_send_col, sp.client_send_condition, sp.province, sp.arab_send, sp.star_level, sp.eid, sa.speedControl,
        sa.allowOverSpeed, sa.overSpeedTimes, sa.overSpeedStrategy, sa.httpMaxSpeed, sp.send_city, sp.rc_mode, sp.long_sms_show_first, sp.sub_account_billing_mode, sa.otype_limit, sp.pro_group_price_id, sp.no_sp_black,
        sp.intercept_timing, sp.billing_type, sp.iptype, sp.special_character, sp.enable_shunt, sp.enable_resend, sp.null_check_supplier, sa.same_content_effect_time as sameContentEffectTime, sp.signtureEndTime,
        sp.signtureBeginTime, sp.AFTER_SP_EXTEND as afterSpExtend, url_content_intercept, sp.number_transfer_supplier, sp.check_null_sign, sp.no_match_template_audit, sp.client_other_area_valid, sp.sign_content_valid, sp.disable_login,
        sp.provision_price as provisionPrice, sp.transfer_interface, sp.channel_callmdn, sa.content_length_limit, sp.blackapi_before, sp.disable_with_number, sp.disable_number_rule, sp.aim_over_70_limit,sp.aim_is_match, sp.api_aim_is_match, sp.mms_template_auto_audit, sa.mms_reply_url,
        sp.disableWithNumberTime,sp.transfer_local, sp.sp_scope,sa.yuexin_push, sa.mms_sign_report_push, sp.auto_extract_sign, sp.allow_temp_strategy, sp.domainLimit,
        sp.template_no_match, sp.sign_limit_rule, sp.sign_template_limit, sp.auto_generate_mmsChannel_template, sp.subacct_black_flag, sp.phone_safe_strategy, sp.distinguish_fullwidth
        from
        sms_sp_info sp,sms_api_setting sa,sms_sp_user_info su
        where sp.id=sa.sp_id
        and su.sp_id=sp.id
        and su.role_id=0
        and sp.id =#{spid}
        and sp.status=1
        limit 1
    </select>

    <!-- SpInfoMapper.xml -->
    <select id="getSpNamesBySpIds" resultType="java.util.Map">
        SELECT
        id AS spid,
        sp_name
        FROM sms_sp_info
        WHERE id IN
        <foreach collection="list" item="spid" open="(" separator="," close=")">
            #{spid}
        </foreach>
    </select>

    <select id="listSpInfoByPrefix" parameterType="int" resultMap="spInfoResultMap">
          select
        sp.id,sp.sp_name,sp.ip,sp.status,sp.fee_type,sp.createtime
        ,sp.mms_mobile_prefix,sp.mms_mobile_suffix,sp.mms_mobile_num,sp.mms_unicom_prefix,sp.mms_unicom_suffix,sp.mms_unicom_num,sp.mms_telecom_prefix,sp.mms_telecom_suffix,sp.mms_telecom_num
        ,sp.mobile_prefix,sp.mobile_suffix,sp.mobile_num,sp.unicom_prefix,sp.unicom_suffix,sp.unicom_num,sp.telecom_prefix,sp.telecom_suffix,sp.telecom_num

        ,sa.report_url,sa.reply_url,sa.push_flag,sp.is_lock,sp.is_audit_word,sp.is_audit_black,sp.template_word_policy,sp.is_api_billing,sp.sp_type,
        su.username,su.web_pawd password,sp.contact_name,sp.contact_mdn,sp.sp_saler,sp.signature,sp.sp_saler_mdn,sp.droptime,sp.sp_channelconfig,sa.sp_audit_type,
        sa.samemdnmaxnum, sa.minsendtotal, sa.no_limit_mdn, sa.return_type, sa.saleprice, sa.sp_audit_number, sa.isvalidbome, sa.isreportnow, sa.samecontentmaxnum, sa.is_flowcode, sp.sp_desc,
        sp.platform, sa.content_type, sp.is_need_signture, sp.check_signture_bank, sp.groupid, sp.is_api, sp.return_fee_type, sa.begin_send_time, sa.end_send_time, sa.begin_send_time_one, sa.end_send_time_one, sa.send_type,
        sa.plan_send_time, su.id userid, sp.grade, sa.samemdn_nday, sa.limit_days, sa.samemdn_threeday, sa.samemdn_oneday, sa.samemdn_oneminute, sa.samemdn_onehour, sp.sensitive_word_type, sp.verification_code_free_review,
        sp.is_send_priority, sa.push_buyun, sa.push_receiver, sa.push_pswd, sa.batch_api_sms, sa.fixed_length, sa.zt_ms, sp.send_priority
        from
        sms_sp_info sp,sms_api_setting sa,sms_sp_user_info su
        where sp.id=sa.sp_id
        and su.sp_id=sp.id
        and su.role_id=0
        and sp.id in (SELECT spId from sms_sp_channel_config where substring_index(telecom,',',1)  = #{channelId}
	      UNION  	SELECT spId from sms_sp_channel_config where substring_index(unicom,',',1)  = #{channelId}
	      UNION  	SELECT spId from sms_sp_channel_config where substring_index(mobile,',',1)  = #{channelId}
        )
    </select>

   	<select id="getSpCountByUsername" parameterType="SpInfo"
            resultType="int">
            select count(1) from sms_sp_info s,sms_sp_user_info su
            <where>
            	s.id=su.sp_id
                <if test="username!=null and username!=''">
                    and su.username = #{username}
                </if>
                <if test="spid!=null and spid!=''">
                	and s.id!=#{spid}
                </if>
                and s.status=1
            </where>
        </select>

    <select id="getMailBySp_saler" parameterType="SpInfo" resultType="String">
        select email from sms_saler_info
        <where>
            <if test="sp_saler!=null and sp_saler!=''">
                NAME = #{sp_saler}
            </if>
        </where>
    </select>

    <select id="getChargeCountById" parameterType="SpCharge" resultType="int">
        select count(id) from sms_sp_charge
        <where>
            <if test="sp_id!=null and sp_id>0">
                sp_id = #{sp_id}
            </if>
        </where>
    </select>

    <select id="getChargeMonthPlanCountById" parameterType="integer" resultType="integer">
        select max_num from sms_sp_charge
        <where>
            <if test="spId!=null and spId>0">
                sp_id = #{spId}
            </if>
        </where>
    </select>

    <select id="getChargeLeftoverNumById" parameterType="SpCharge" resultType="int">
        select ifnull(leftover_num,0) leftover_num from sms_sp_charge
        <where>
            <if test="sp_id!=null and sp_id>0">
                sp_id = #{sp_id}
            </if>
        </where>
    </select>

    <select id="getChargeMmsCountById" parameterType="SpChargeMms" resultType="int">
        select count(id) from sms_sp_charge_mms
        <!--         where effect_month=date_format(sysdate(),'%Y-%m') -->
        <where>
            <if test="sp_id!=null and sp_id>0">
                sp_id = #{sp_id}
            </if>
        </where>
    </select>

    <!-- 短信充值月记录总费用 -->
    <select id="getChargeAmountBymonth" parameterType="ChargeRecord" resultType="float">
        select IFNULL(sum(sd.amount),0) amount
        from sms_charge_record
        sd,sms_sp_info sp
        where sp.id=sd.sp_id
        and sd.type=1
        <if test="month!=null and month !=''">
            and date_format(sd.charge_time,'%Y-%m')=#{month}
        </if>
        <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 sd.sp_id = #{sp_id}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler =#{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>
        <if test="createTime!=null and createTime!=''">
            and sd.charge_time&gt;=str_to_date(#{createTime},'%Y-%m-%d')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and
            sd.charge_time&lt;=DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
        <if test="pay_type!=null and pay_type!=''">
            and sd.pay_type = #{pay_type}
        </if>

    </select>
    <select id="getChargeAmountBymonthReduce" parameterType="ChargeRecord" resultType="float">
        select IFNULL(sum(sd.amount),0) amount
        from sms_charge_record
        sd,sms_sp_info sp
        where sp.id=sd.sp_id
        and sd.type=2
        <if test="month!=null and month !=''">
            and date_format(sd.charge_time,'%Y-%m')=#{month}
        </if>
        <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 sd.sp_id = #{sp_id}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler =#{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>
        <if test="createTime!=null and createTime!=''">
            and sd.charge_time&gt;=str_to_date(#{createTime},'%Y-%m-%d')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and
            sd.charge_time&lt;=DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>


    </select>
     <select id="getChargeBymonth" parameterType="ChargeRecord" resultType="double">
	    SELECT
				ifnull(sum(sd.CHARGENUM*sa.saleprice),0) chargeNum
			FROM
				sms_sp_info sp,(
				SELECT
					sum( CHARGENUM ) CHARGENUM,
					SP_ID
				FROM
				sms_charge_record
				WHERE
					pay_type = 1
				<if test="createTime!=null and createTime!=''">
		            and year(charge_time)=year(str_to_date(#{createTime},'%Y-%m'))
		            and month(charge_time)=month(str_to_date(#{createTime},'%Y-%m'))
		        </if>
				GROUP BY
					SP_ID
				) sd,
			sms_api_setting sa
			WHERE
			sp.id = sd.SP_ID
			AND sp.id = sa.SP_ID
			<if test="sp_name!=null and sp_name!=''">
				and sp_name like concat('%',#{sp_name},'%')
			</if>
			<if test="sp_saler!=null and sp_saler!=''">
				and sp_saler = #{sp_saler}
			</if>
		</select>
    <!-- 彩信充值月记录总费用 -->
    <select id="getChargeMmsAmountBymonth" parameterType="ChargeRecordMms" resultType="float">
        select IFNULL(sum(sd.amount),0) amount
        from sms_charge_record_mms
        sd,sms_sp_info sp
        where sp.id=sd.sp_id
        <if test="month!=null and month !=''">
            and date_format(sd.charge_time,'%Y-%m')=#{month}
        </if>
        <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 sd.sp_id = #{sp_id}
        </if>
    </select>
    <insert id="insertSpinfo" useGeneratedKeys="true" keyProperty="spid" parameterType="SpInfo">
        insert into sms_sp_info
        (sp_name,ip,report_url,reply_url,is_lock,is_audit_word,
        contact_name,contact_mdn,sp_saler,sp_saler_mdn,sp_type,
        platform,is_need_signture,check_signture_bank,groupid,signature,createtime,is_api,
        return_fee_type,unknown_billing,template_word_policy,
        is_api_billing,is_audit_black,grade,sensitive_word_type,verification_code_free_review,
        is_send_priority,is_web,send_priority,business_license,identity_front,identity_side
        ,url_detect,is_contract,fail_retrun,unsend_province,is_open_channel_limit,vcode_black_flag,web_send_flag,noProfit,commission_price,
        beauty_phone_flag,web_export_flag,is_open_transfer,inter_sms_flag,inter_price_group,inter_price_rate,web_show_status_flag,back_sign_flag,multi_sign_flag,
         unsend_city,provinceNetPrice,detachment,keyword_group_id,phone_bypass_flag,mms_phone_bypass_flag,enableClientSms,randomCallMdnSuffix,is_batch_black,is_batch_mms,
        client_status_col, client_send_col, client_send_condition, arab_send, star_level, eid, send_city, rc_mode,
        sub_account_billing_mode, long_sms_show_first,pro_group_price_id,no_sp_black,billing_type,system_limit_flag, intercept_timing,iptype, special_character,
        enable_shunt, enable_resend, null_check_supplier,signtureBeginTime,signtureEndTime, AFTER_SP_EXTEND, url_content_intercept,number_transfer_supplier,check_null_sign,no_match_template_audit,
        client_other_area_valid,sign_content_valid,disable_login,transfer_interface, channel_callmdn, transfer_local, sp_scope, auto_extract_sign, allow_temp_strategy, template_no_match, currency,
         sign_limit_rule, sign_template_limit, auto_generate_mmsChannel_template, phone_safe_strategy, distinguish_fullwidth, disable_with_number, disable_number_rule)
        values
        (#{sp_name},#{ip,jdbcType=VARCHAR},#{report_url,jdbcType=VARCHAR},#{reply_url,jdbcType=VARCHAR},1,#{is_audit_word},
        #{spContact_name,jdbcType=VARCHAR},#{spContact_mdn,jdbcType=VARCHAR},#{sp_saler,jdbcType=VARCHAR},#{sp_saler_mdn,jdbcType=VARCHAR}, #{sp_type},
        #{platform},#{is_need_signture},#{check_signture_bank},#{groupid},#{signature,jdbcType=VARCHAR},sysdate(),
        #{is_api},#{return_fee_type,jdbcType=INTEGER},#{unknown_billing,jdbcType=INTEGER},#{template_word_policy,jdbcType=INTEGER}, #{is_api_billing,jdbcType=INTEGER},
        #{is_audit_black,jdbcType=INTEGER},#{grade,jdbcType=VARCHAR}, #{sensitive_word_type,jdbcType=VARCHAR}, #{verification_code_free_review,jdbcType=INTEGER},
        #{is_send_priority,jdbcType=INTEGER},#{is_web,jdbcType=INTEGER}, #{send_priority,jdbcType=INTEGER},#{business_license,jdbcType=VARCHAR}, #{identity_front,jdbcType=VARCHAR},
        #{identity_side,jdbcType=VARCHAR}, #{url_detect,jdbcType=INTEGER},#{isContract,jdbcType=INTEGER}, #{failRetrun,jdbcType=INTEGER},
        #{unsend_province,jdbcType=VARCHAR}, #{is_open_channel_limit,jdbcType=INTEGER}, #{vcode_black_flag,jdbcType=VARCHAR}, #{web_send_flag,jdbcType=INTEGER},
        #{noProfit,jdbcType=INTEGER}, #{commission_price,jdbcType=INTEGER}*10000, #{beauty_phone_flag,jdbcType=INTEGER}, #{web_export_flag,jdbcType=INTEGER},
        #{is_open_transfer,jdbcType=INTEGER}, #{inter_sms_flag,jdbcType=INTEGER}, #{inter_price_group,jdbcType=VARCHAR}, #{inter_price_rate,jdbcType=DECIMAL},
        #{web_show_status_flag,jdbcType=INTEGER}, #{back_sign_flag}, #{multi_sign_flag},#{unsend_city}, #{provinceNetPrice}, #{detachment}, #{keyword_group_id}, #{phone_bypass_flag}, #{mms_phone_bypass_flag},
        #{enableClientSms}, #{randomCallMdnSuffix}, #{is_batch_black}, #{is_batch_mms}, #{client_status_col}, #{client_send_col}, #{client_send_condition}, #{arab_send}, #{star_level}, #{eid},
        #{send_city}, #{rc_mode}, #{subAccountBillingMode}, #{longSmsShowFirst}, #{pro_group_price_id}, #{no_sp_black}, #{billing_type}, #{system_limit_flag}, #{interceptTiming},
        #{iptype}, #{special_character}, #{enableShunt}, #{enableResend}, #{nullCheckSupplier}, #{signtureBeginTime}, #{signtureEndTime},
        #{afterSpExtend}, #{url_content_intercept}, #{numberTransferSupplier}, #{checkNullSign}, #{no_match_template_audit}, #{client_other_area_valid}, #{sign_content_valid},
         #{disable_login}, #{transfer_interface}, #{channel_callmdn}, #{transferLocal}, #{spScope}, #{auto_extract_sign}, #{allow_temp_strategy}, #{template_no_match}, #{currency}, #{sign_limit_rule},
         #{sign_template_limit}, #{auto_generate_mmsChannel_template}, #{phone_safe_strategy}, #{distinguish_fullwidth},#{disableWithNumber},#{disableNumberRule}
        )
    </insert>
     <select id="getSpUserById" parameterType="int" resultType="SpInfo">
    	select sp_id spid,username, web_password, password, web_pawd, pawd from sms_sp_user_info where sp_id=#{spid} and role_id = 0
    </select>
    <insert id="insertSpUserInfo" useGeneratedKeys="true" keyProperty="userid" parameterType="SpInfo">
        insert into
        sms_sp_user_info
        (sp_id, role_id, username, web_password, password, web_pawd, pawd, createtime, mdn)
        values
        (#{spid},0,#{username,jdbcType=VARCHAR},#{password,jdbcType=VARCHAR},#{password,jdbcType=VARCHAR},#{pawd,jdbcType=VARCHAR},#{pawd,jdbcType=VARCHAR},sysdate(), #{spContact_mdn})
    </insert>
    <select id="getSpSettingById" parameterType="int" resultType="SpInfo">
    	select sp_id,sp_audit_type,return_type,content_type,send_province,saleprice,SP_AUDIT_NUMBER from sms_api_setting where sp_id=#{spid}
    </select>
    <insert id="insertSpSetting" parameterType="SpInfo">
        insert into
        sms_api_setting
        (sp_id,sp_audit_type,return_type,content_type,send_province,saleprice,sp_audit_number)
        values(#{spid},#{audit_type,jdbcType=VARCHAR},#{return_type},#{content_type},#{send_province},#{saleprice},#{sp_audit_number})
    </insert>

    <insert id="insertSpCharge" useGeneratedKeys="true" keyProperty="id" parameterType="SpCharge">
        insert into sms_sp_charge
        (sp_id,max_num,use_num,leftover_num,effect_month) values
        (#{sp_id},#{max_num},#{use_num},#{leftover_num},#{effect_month})
    </insert>

    <insert id="insertSpChargeMms" useGeneratedKeys="true" keyProperty="id" parameterType="SpChargeMms">
        insert into sms_sp_charge_mms
        (sp_id,max_num,use_num,leftover_num,effect_month) values
        (#{sp_id},#{max_num},#{use_num},#{leftover_num},#{effect_month})
    </insert>

    <insert id="insertSpChargeRecord" useGeneratedKeys="true" keyProperty="id" parameterType="ChargeRecord">
        insert into sms_charge_record
        (sp_id,chargenum,chargeopeartor,productid,descption,amount,price,type,chargeafternum,charge_time,charge_mode,pay_time,pay_type)
        values
        (#{sp_id},#{chargeNum},#{operator,jdbcType=VARCHAR},1,#{descption,jdbcType=VARCHAR},#{amount},#{price},#{type},#{chargeAfterNum},sysdate(),#{charge_mode},#{pay_time},#{pay_type})
    </insert>
    <insert id="insertSpChargeRecordMms" useGeneratedKeys="true" keyProperty="id" parameterType="ChargeRecord">
        insert into sms_charge_record_mms
        (sp_id,chargenum,chargeopeartor,productid,descption,amount,price,type,charge_time,pay_time,pay_type)
        values
        (#{sp_id},#{chargeNum},#{operator,jdbcType=VARCHAR},1,#{descption,jdbcType=VARCHAR},#{amount},#{price},#{type},sysdate(),#{pay_time},#{pay_type})
    </insert>
    <!--    username=#{username,jdbcType=VARCHAR}, password=#{password,jdbcType=VARCHAR}, -->
    <update id="updateSpInfo" parameterType="SpInfo">
        update sms_sp_info set currency=#{currency,jdbcType=VARCHAR}, sp_name=#{sp_name,jdbcType=VARCHAR},platform=#{platform,jdbcType=VARCHAR},
        is_audit_word=#{is_audit_word},contact_name=#{spContact_name,jdbcType=VARCHAR},contact_mdn=#{spContact_mdn,jdbcType=VARCHAR},
        ip=#{ip,jdbcType=VARCHAR},sp_type=#{sp_type},report_url=#{report_url,jdbcType=VARCHAR},reply_url=#{reply_url,jdbcType=VARCHAR},
        sp_saler=#{sp_saler,jdbcType=VARCHAR},sp_saler_mdn=#{sp_saler_mdn,jdbcType=VARCHAR},is_need_signture=#{is_need_signture,jdbcType=VARCHAR},
        check_signture_bank=#{check_signture_bank,jdbcType=VARCHAR}, signature=#{signature,jdbcType=VARCHAR}, groupid=#{groupid,jdbcType=VARCHAR},
        is_api=#{is_api,jdbcType=INTEGER}, return_fee_type=#{return_fee_type,jdbcType=INTEGER}, unknown_billing=#{unknown_billing,jdbcType=INTEGER},is_audit_black=#{is_audit_black,jdbcType=INTEGER},
        template_word_policy=#{template_word_policy,jdbcType=INTEGER}, is_api_billing=#{is_api_billing,jdbcType=INTEGER}, grade=#{grade,jdbcType=VARCHAR},
        sensitive_word_type=#{sensitive_word_type,jdbcType=VARCHAR}, verification_code_free_review=#{verification_code_free_review},is_send_priority=#{is_send_priority,jdbcType=INTEGER},
        is_web=#{is_web,jdbcType=INTEGER}, send_priority=#{send_priority,jdbcType=INTEGER}, url_detect=#{url_detect,jdbcType=INTEGER},is_contract=#{isContract}, fail_retrun=#{failRetrun},
        unsend_province=#{unsend_province}, is_open_channel_limit=#{is_open_channel_limit}, vcode_black_flag=#{vcode_black_flag}, web_send_flag=#{web_send_flag}, noProfit=#{noProfit},
        commission_price=#{commission_price}*10000, beauty_phone_flag=#{beauty_phone_flag}, system_limit_flag=#{system_limit_flag}, web_export_flag=#{web_export_flag}, is_open_transfer=#{is_open_transfer},
        inter_sms_flag=#{inter_sms_flag}, inter_price_group=#{inter_price_group},inter_price_rate=#{inter_price_rate}, web_show_status_flag=#{web_show_status_flag}, back_sign_flag=#{back_sign_flag},
        multi_sign_flag=#{multi_sign_flag}, unsend_city=#{unsend_city}, provinceNetPrice=#{provinceNetPrice}, detachment=#{detachment}, keyword_group_id=#{keyword_group_id},
        phone_bypass_flag=#{phone_bypass_flag}, mms_phone_bypass_flag=#{mms_phone_bypass_flag}, enableClientSms=#{enableClientSms}, randomCallMdnSuffix=#{randomCallMdnSuffix}, clientMenu=#{clientMenu},
        is_batch_black=#{is_batch_black}, is_batch_mms=#{is_batch_mms}, client_status_col=#{client_status_col}, client_send_col=#{client_send_col}, client_send_condition=#{client_send_condition},
        arab_send=#{arab_send}, star_level=#{star_level}, eid = #{eid}, send_city = #{send_city}, rc_mode = #{rc_mode}, long_sms_show_first = #{longSmsShowFirst}, sub_account_billing_mode = #{subAccountBillingMode},
        pro_group_price_id=#{pro_group_price_id}, no_sp_black=#{no_sp_black}, billing_type=#{billing_type}, intercept_timing=#{interceptTiming}, iptype=#{iptype},
        special_character=#{special_character}, enable_shunt=#{enableShunt}, enable_resend=#{enableResend}, null_check_supplier=#{nullCheckSupplier}, signtureBeginTime=#{signtureBeginTime},
        signtureEndTime=#{signtureEndTime}, after_sp_extend = #{afterSpExtend}, url_content_intercept=#{url_content_intercept}, number_transfer_supplier=#{numberTransferSupplier},
        check_null_sign=#{checkNullSign}, no_match_template_audit=#{no_match_template_audit}, client_other_area_valid=#{client_other_area_valid}, sign_content_valid=#{sign_content_valid}, disable_login=#{disable_login},
        provision_price=#{provisionPrice}, transfer_interface = #{transfer_interface},channel_callmdn = #{channel_callmdn}, blackapi_before=#{blackApiBefore},
        disable_with_number=#{disableWithNumber}, disable_number_rule=#{disableNumberRule}, disableWithNumberTime=#{disableWithNumberTime}, transfer_local=#{transferLocal},
        sp_scope=#{spScope},aim_over_70_limit = #{aim_over_70_limit}, aim_is_match = #{aim_is_match}, api_aim_is_match = #{api_aim_is_match}, mms_template_auto_audit = #{mms_template_auto_audit},
        auto_extract_sign = #{auto_extract_sign}, allow_temp_strategy = #{allow_temp_strategy}, domainLimit = #{domainLimit}, template_no_match = #{template_no_match},
        sign_limit_rule = #{sign_limit_rule}, sign_template_limit = #{sign_template_limit}, auto_generate_mmsChannel_template = #{auto_generate_mmsChannel_template}, subacct_black_flag = #{subacct_black_flag}, phone_safe_strategy = #{phone_safe_strategy}, distinguish_fullwidth = #{distinguish_fullwidth}
        where id=#{spid}
    </update>

    <update id="updateSigntureFlag" parameterType="SpInfo">
    	 update sms_sp_info set check_signture_bank=#{check_signture_bank} where id=#{spid}
    </update>

	<update id="updateSpGrade" parameterType="SpInfo">
		update sms_sp_info set send_priority=#{send_priority} where id=#{id}
	</update>

    <update id="updateSpSetting" parameterType="SpInfo">
        update
        sms_api_setting c
        set
        <if test="audit_type != null and audit_type!=''">
            c.sp_audit_type = #{audit_type},
        </if>
        content_type=#{content_type,jdbcType=VARCHAR}
        ,send_province=#{send_province,jdbcType=VARCHAR}
        <if test="saleprice!=null and saleprice!=''">
	        ,c.saleprice = #{saleprice}
        </if>
        where
        c.sp_id = #{spid}
    </update>

    <update id="updateSpConfig" parameterType="SpInfo">
        update sms_api_setting
        <trim prefix="SET" suffixOverrides=",">
            <if test="samemdnmaxnum != null">samemdnmaxnum=#{samemdnmaxnum,jdbcType=VARCHAR},</if>
            <if test="minsendtotal != null">minsendtotal=#{minsendtotal},</if>
            <if test="no_limit_mdn != null">no_limit_mdn=#{no_limit_mdn,jdbcType=VARCHAR},</if>
            <if test="return_type != null">return_type=#{return_type},</if>
            <if test="report_url != null">report_url=#{report_url},</if>
            <if test="reply_url != null">reply_url=#{reply_url},</if>
            <if test="push_flag != null">push_flag=#{push_flag},</if>
            <if test="saleprice != null">saleprice=#{saleprice},</if>
            <if test="isvalidbome != null">isvalidbome=#{isvalidbome},</if>
            <if test="isreportnow != null">isreportnow=#{isreportnow},</if>
            <if test="same_content_max_num != null">samecontentmaxnum=#{same_content_max_num},</if>
            <if test="is_flowcode != null">is_flowcode=#{is_flowcode},</if>
            begin_send_time=#{beginSendTime},
            end_send_time=#{endSendTime},
            begin_send_time_one=#{beginSendTime1},
            end_send_time_one=#{endSendTime1},
            <if test="sendType != null and sendType!= ''">send_type=#{sendType},</if>
            samemdn_nday=#{samemdn_nday},
            limit_days=#{limit_days},
            samemdn_oneday=#{samemdn_oneday},
            samemdn_threeday=#{samemdn_threeday},
            samemdn_oneminute=#{samemdn_oneminute},
            samemdn_onehour=#{samemdn_onehour},
            share_limit_sp=#{share_limit_sp},
            content_length_limit=#{content_length_limit},
            plan_send_time=#{planSendTime},
            push_buyun =#{push_buyun},
            batch_api_sms =#{batch_api_sms},
            fixed_length =#{fixed_length},
            zt_ms =#{zt_ms},
            push_receiver =#{push_receiver},
            push_pswd =#{push_pswd},
            samemsg_nminute =#{samemsg_nminute},
            samemsg_nnum =#{samemsg_nnum},
            <choose>
                <when  test="sp_audit_number != null and sp_audit_number!= ''">
                    sp_audit_number=#{sp_audit_number},
                </when>
                <otherwise>
                    sp_audit_number = null ,
                </otherwise>
            </choose>

            loopsms_sec=#{loopsms_sec},
            loopsms_num=#{loopsms_num},
            loopsms_strategy=#{loopsms_strategy},
            push_limit=#{push_limit},
            day_limit=#{day_limit},
            month_limit=#{month_limit},
            success_limit=#{success_limit},
            speedControl=#{speedControl},
            allowOverSpeed=#{allowOverSpeed},
            overSpeedTimes=#{overSpeedTimes},
            overSpeedStrategy=#{overSpeedStrategy},
            httpMaxSpeed=#{httpMaxSpeed},
            otype_limit=#{otype_limit},
            <if test="audit_type != null and audit_type!= ''"> SP_AUDIT_TYPE =#{audit_type},</if>
            same_content_effect_time=#{sameContentEffectTime},
            mms_reply_url=#{mmsReplyUrl},
            yuexin_push=#{yuexin_push},
            mms_sign_report_push=#{mmsSignReportPush}
        </trim>

        where
        sp_id = #{spid}
    </update>

    <update id="updateSpConfigOtypeLimit" parameterType="SpInfo">
        update sms_api_setting
        <trim prefix="SET" suffixOverrides=",">
            otype_limit=#{otype_limit}
        </trim>
        where sp_id = #{spid}
    </update>

	<update id="updateSpConfigFreeAudit" parameterType="SpInfo">
	 update sms_api_setting  set SP_AUDIT_TYPE =#{audit_type}
	 where   sp_id = #{spid}
	</update>
    <update id="updateSpCharge" parameterType="SpCharge">
        update sms_sp_charge c
        set c.max_num = #{max_num},
        c.leftover_num = c.leftover_num + #{chargeNum}
        <!--         where c.effect_month = date_format(sysdate(),'%Y-%m') -->
        where c.sp_id = #{sp_id}
    </update>
    <update id="updateSpChargeMms" parameterType="SpChargeMms">
        update sms_sp_charge_mms c
        set c.max_num = #{max_num},
        c.leftover_num = c.leftover_num + #{chargeNum}
        <!--         where c.effect_month = date_format(sysdate(),'%Y-%m') -->
        where c.sp_id = #{sp_id}
    </update>

    <update id="updateSpLeftover" parameterType="SpCharge">
        update sms_sp_charge
        c set c.leftover_num =c.leftover_num-#{number}
        <!--         where c.effect_month = date_format(sysdate(),'%Y-%m') -->
        where c.sp_id = #{sp_id}
    </update>
    <update id="updateSpLeftoverAndUseCount" parameterType="SpCharge">
        update sms_sp_charge
        c set c.leftover_num =c.leftover_num-#{number},
        c.USE_NUM = c.USE_NUM + #{number}
        <!--         where c.effect_month = date_format(sysdate(),'%Y-%m') -->
        where c.sp_id = #{sp_id}
    </update>

    <update id="updateSpLeftoverMms" parameterType="SpChargeMms">
        update sms_sp_charge_mms
        c set c.leftover_num =c.leftover_num-#{max_num}
        <!--         where c.effect_month = date_format(sysdate(),'%Y-%m') -->
        where c.sp_id = #{sp_id}
    </update>
    <update id="updateSpChannel" parameterType="SpInfo">
        update sms_sp_info
        <set>
            <if test="mobile_prefix != null ">
                mobile_prefix=#{mobile_prefix,jdbcType=VARCHAR},
            </if>
            <if test="mobile_suffix != null ">
                mobile_suffix=#{mobile_suffix,jdbcType=VARCHAR},
            </if>
            <if test="signature != null">
                signature=#{signature,jdbcType=VARCHAR},
            </if>
            <if test="mobile_num != null ">
                mobile_num=#{mobile_num,jdbcType=VARCHAR},
            </if>
            <if test="unicom_prefix != null ">
                unicom_prefix=#{unicom_prefix,jdbcType=VARCHAR},
            </if>
            <if test="unicom_suffix != null ">
                unicom_suffix=#{unicom_suffix,jdbcType=VARCHAR},
            </if>
            <if test="unicom_num != null ">
                unicom_num=#{unicom_num,jdbcType=VARCHAR},
            </if>
            <if test="telecom_prefix != null ">
                telecom_prefix=#{telecom_prefix,jdbcType=VARCHAR},
            </if>
            <if test="telecom_suffix != null ">
                telecom_suffix=#{telecom_suffix,jdbcType=VARCHAR},
            </if>
            <if test="telecom_num != null">
                telecom_num=#{telecom_num,jdbcType=VARCHAR},
            </if>
             <if test="international_prefix != null ">
                international_prefix=#{international_prefix,jdbcType=VARCHAR},
            </if>
            <if test="international_suffix != null ">
                international_suffix=#{international_suffix,jdbcType=VARCHAR},
            </if>
            <if test="international_num != null">
                international_num=#{international_num,jdbcType=VARCHAR},
            </if>

            <if test="sp_channelconfig != null  ">
                sp_channelconfig=#{sp_channelconfig},
            </if>
            <!--彩信配置-->
            <if test="mms_mobile_prefix != null ">
                mms_mobile_prefix=#{mms_mobile_prefix,jdbcType=VARCHAR},
            </if>
            <if test="mms_mobile_suffix != null ">
                mms_mobile_suffix=#{mms_mobile_suffix,jdbcType=VARCHAR},
            </if>
            <if test="mms_mobile_num != null ">
                mms_mobile_num=#{mms_mobile_num,jdbcType=VARCHAR},
            </if>

            <if test="mms_unicom_prefix != null ">
                mms_unicom_prefix=#{mms_unicom_prefix,jdbcType=VARCHAR},
            </if>
            <if test="mms_unicom_suffix != null ">
                mms_unicom_suffix=#{mms_unicom_suffix,jdbcType=VARCHAR},
            </if>
            <if test="mms_unicom_num != null ">
                mms_unicom_num=#{mms_unicom_num,jdbcType=VARCHAR},
            </if>

            <if test="mms_telecom_prefix != null ">
                mms_telecom_prefix=#{mms_telecom_prefix,jdbcType=VARCHAR},
            </if>
            <if test="mms_telecom_suffix != null ">
                mms_telecom_suffix=#{mms_telecom_suffix,jdbcType=VARCHAR},
            </if>
            <if test="mms_telecom_num != null ">
                mms_telecom_num=#{mms_telecom_num,jdbcType=VARCHAR},
            </if>
            <if test="sp_mms_channelconfig != null ">
                sp_mms_channelconfig=#{sp_mms_channelconfig}
            </if>
        </set>

        where id=#{spid}
    </update>

    <update id="updateSpApiInfo" parameterType="SpInfo">
        update sms_sp_info
        set
        ip=#{ip,jdbcType=VARCHAR},
        report_url=#{report_url,jdbcType=VARCHAR},
        reply_url=#{reply_url,jdbcType=VARCHAR}
        where id=#{spid}
    </update>

    <update id="deleteSpInfo" parameterType="int">
        update sms_sp_info set
        status=2,droptime=sysdate() where id=#{spid}
    </update>

    <update id="updateSpInfostatus" parameterType="map">
        update sms_sp_info
        set is_lock=#{isLosk} where id=#{spid}
    </update>

    <update id="updateSpInfoWebLoginstatus" parameterType="map">
        update sms_sp_info
        set is_web=#{webFlag},web_send_flag= #{webSendFlag}
        <if test="ip != null and ip!= ''">
            ,ip=#{ip}
        </if>
        where id=#{spid}
    </update>

    <update id="updateUnlockSp" parameterType="SpInfo">
        update sms_sp_info set is_lock = 1 where id = #{spid}
    </update>

    <update id="updateSpErrorCount" parameterType="SpInfo">
        update sms_sp_user_info set error_count = 0 where sp_id = #{spid} and role_id = 0
    </update>

    <update id="updateSpInfoWebSmsLogins" parameterType="map">
        update sms_sp_info set enableClientSms = 1 where  id=#{spid}
    </update>

    <update id="updateSpInfoDescById">
        update sms_sp_info set
        sp_desc=#{sp_desc,jdbcType=VARCHAR} where id=#{spid}
    </update>

    <insert id="addOrderPackage" useGeneratedKeys="true" keyProperty="id" parameterType="SpOrderPackage">
        insert into sms_sp_order_packge (package_id,sp_id,status,ordertime) values (#{package_id},#{sp_id},#{status,jdbcType=VARCHAR},sysdate())
    </insert>
    <update id="updateSpUserInfo" parameterType="SpInfo">
        update sms_sp_user_info s
        <trim prefix="set" suffixOverrides=",">
            <if test="username!=null">s.username=#{username}</if>
            <if test="password!=null">,s.password=#{password},s.pawd=#{pawd}</if>
            <if test="web_password!=null">,s.web_password=#{web_password},s.web_pawd=#{web_pawd}</if>
        </trim>
        where s.sp_id=#{spid}
        and s.role_id=0
    </update>

    <update id="updateOrderPackage" parameterType="SpOrderPackage">
        update sms_sp_order_packge set
        package_id=#{package_id,jdbcType=VARCHAR},
        sp_id = #{sp_id,jdbcType=VARCHAR},
        status = #{status,jdbcType=VARCHAR}
        where id={id}
    </update>

    <select id="listAllSaler" parameterType="int" resultMap="spInfoResultMap">
      select si.id,
         si.user_name,
         si.role_id,
         si.name sp_saler,
         sr.role_name,
         sr.id
         from  sms_user_info si,sms_user_role sr
         where si.role_id=sr.id and sr.id in (42,520)  and si.`STATUS` = 1;
    </select>

    <select id="queryAllSaler" resultType="cn.roadm.bo.RoleInfo">
        select distinct si.id,
        si.user_name,
        si.role_id,sr.role_name AS roleName,
        si.NAME sealerName
        <if test="userName != null and userName != ''">
            , a.managerId
        </if>
        from sale_manager a left join  sms_user_info si on si.`NAME` = a.seller ,sms_user_role sr
        <where>
            si.role_id = sr.id AND sr.id = 42
            <if test="userName != null and userName != ''">
                and a.managerId =  #{userName}
            </if>
        </where>
    </select>


    <!-- 获取企业销售价格  -->
    <select id="getSpSalePrice" parameterType="SpInfo" resultType="Double">
    select a.saleprice from sms_api_setting a where a.sp_id =#{spid}
    </select>
    <!-- 计算到达计费企业发送成本  -->
    <select id="listSpArriveFee" parameterType="SpInfo" resultMap="spInfoCostMap">
    select sum(d.cost) costprice,sum(d.amount) arrive_num,d.sp_id,d.createtime createTime from
    (select b.amount*c.price*0.01 cost,b.sp_id,b.amount,b.createtime from
      (select count(0) amount,a.sp_id,a.channelid ,date_format(a.create_time,'%Y-%m-%d') createtime
      	from sms_arrive a
      	where a.sp_id=#{spid}
      		 and date_format(a.create_time,'%Y-%m')=#{month}
      		 and a.result = 0
      		 group by date_format(a.create_time,'%Y-%m-%d'),a.sp_id,a.channelid) b,
      		 sms_carrier_channel_info c
      		 where b.channelid = c.id) d
      		 group by d.sp_id,d.createtime
    </select>
    <insert id="insertSpDayFee" useGeneratedKeys="true" keyProperty="id" parameterType="SpInfo">
        insert into sms_sp_day_fee
        (SP_ID,COSTPRICE,SALEPRICE,CREATETIME,SP_SALER,ARRIVE_NUM) values
        (#{spid},#{costprice},#{saleprice},#{createTime,jdbcType=DATE},#{sp_saler,jdbcType=VARCHAR},#{arrive_num})
    </insert>
    <select id="getSpDayFeeBySpId" parameterType="SpInfo" resultType="int">
	    select count(0) from sms_sp_day_fee a
	    where a.sp_id =#{spid} and date_format(a.createtime,'%Y-%m-%d') = date_format(#{createTime},'%Y-%m-%d');
    </select>


    <select id="listPageSpCostMonth" resultMap="spInfoCostMap" parameterType="SpInfo">
        select
        sd.sp_id, s.sp_name, s.sp_saler, s.platform,
        sum( IFNULL(sd.costprice,0)) costprice,
        sum( IFNULL(sd.saleprice,0)) saleprice,
        sum( (IFNULL(sd.saleprice,0)-IFNULL(sd.costprice,0))) margin,
        date_format(sd.createtime,'%Y-%m') month
        from sms_sp_day_fee sd, sms_sp_info s
        where s.id = sd.sp_id
        <if test="sp_saler!=null and sp_saler!=''">
            and s.sp_saler =#{sp_saler}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and s.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="spid!=null and spid>0">
            and sd.sp_id=#{spid}
        </if>
        <if test="month!=null and month!=''">
            and date_format(sd.createtime,'%Y-%m')=#{month}
        </if>

        group by sd.sp_id,s.sp_name, s.sp_saler,
        date_format(sd.createtime,'%Y-%m'),s.platform
    </select>
    <select id="getlistSpCostMonthCount" resultType="SpInfo" parameterType="SpInfo">
        select

        sum( IFNULL(sd.costprice,0)) costprice,
        sum( IFNULL(sd.saleprice,0)) saleprice,
        sum( (IFNULL(sd.saleprice,0)-IFNULL(sd.costprice,0))) margin
        from sms_sp_day_fee sd, sms_sp_info s
        where s.id = sd.sp_id
        <if test="sp_saler!=null and sp_saler!=''">
            and s.sp_saler =#{sp_saler}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and s.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="spid!=null and spid>0">
            and sd.sp_id=#{spid}
        </if>
        <if test="month!=null and month!=''">
            and date_format(sd.createtime,'%Y-%m')=#{month}
        </if>

    </select>
    <select id="exportSpCostMonthList" resultType="Map" parameterType="SpInfo">
        select
        sd.sp_id, s.sp_name, s.sp_saler, s.platform,
        sum( IFNULL(sd.costprice,0)) costprice,
        sum( IFNULL(sd.saleprice,0)) saleprice,
        sum( (IFNULL(sd.saleprice,0)-IFNULL(sd.costprice,0))) margin,
        date_format(sd.createtime,'%Y-%m') month
        from sms_sp_day_fee sd, sms_sp_info s
        where s.id = sd.sp_id
        <if test="sp_saler!=null and sp_saler!=''">
            and s.sp_saler =#{sp_saler}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and s.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="spid!=null and spid>0">
            and sd.sp_id=#{spid}
        </if>
        <if test="month!=null and month!=''">
            and date_format(sd.createtime,'%Y-%m')=#{month}
        </if>

        group by sd.sp_id,s.sp_name, s.sp_saler,
        date_format(sd.createtime,'%Y-%m'),s.platform
    </select>


    <select id="getSpinfoGradeById" parameterType="SpInfo" resultMap="SpInfoGrade">
        select bp.spid ,
        bp.black_id,
        st.blacklist_group_name
        from sms_sp_black_phone bp,sms_black_phone_type st
        where bp.black_id = st.id and bp.spid = #{spid};
    </select>

    <select id="listBlackPhoneType" parameterType="BlackPhoneType"
            resultType="BlackPhoneType">
        select bt.id,
        bt.blacklist_group_name,bt.type,bt.buffer
        from sms_black_phone_type bt where 1=1
         <if test="type!=null and type!=''">
          and type=#{type}
         </if>
    </select>

    <delete id="deleteBlacklistGroupName" parameterType="SpInfo">
    	delete from sms_sp_black_phone where black_id=#{black_id}
    </delete>

    <insert id="insertBlackPhoneType" useGeneratedKeys="true" keyProperty="id" parameterType="SpInfo">
	    insert into sms_sp_black_phone(spid,black_id,createtime)
	    values(#{spid},#{black_id},sysdate())
    </insert>

    <select id="listBlackById" parameterType="SpInfo" resultMap="SpInfoGrade">
        select bt.id,
        bt.blacklist_group_name
        from sms_black_phone_type bt where blacklist_group_name = #{blacklist_group_name}
    </select>

    <select id="getSpSpecialConfig" parameterType="SpSpecialConfig" resultType="SpSpecialConfig">
        select st.sp_id spId,st.id,st.unknown,st.arrive,st.deduct_mdn,st.deduct_city,st.is_valid_mdn,deduct_flag,delay_second
        ,telecom,unicom,mobile,start_num,start_cycle,null_mdn_flag,long_sms_success,
         st.nday, st.ntimes,st.keyword,st.no_keyword,st.is_null_mdn,st.deduct_black,st.special_template_group_id specialTemplateGroupId,
        st.check_null_interface as checkNullInterface, succ_channel as successChannel, fail_channel as failChannel,is_buffer,succ_percent,
        st.real_channel_flag,st.real_channel_days,st.deduct_limit, st.deduct_limit_num
        from sms_sp_special_config st
        where  st.sp_id = #{spId}
    </select>
    <insert id="insertSpSpecialConfig" useGeneratedKeys="true" keyProperty="id" parameterType="SpSpecialConfig">
        insert into sms_sp_special_config
        (sp_id,is_valid_mdn,arrive,deduct_mdn,deduct_city,deduct_flag,telecom,unicom,mobile,delay_second,start_num,start_cycle,null_mdn_flag,long_sms_success, nday,
        ntimes,keyword,no_keyword, is_null_mdn,deduct_black, check_null_interface, succ_channel, fail_channel,is_buffer,succ_percent,real_channel_flag,real_channel_days,
        deduct_limit, deduct_limit_num) values
        (#{spId},#{is_valid_mdn},#{arrive},#{deduct_mdn},#{deduct_city},#{deduct_flag},#{telecom},#{unicom},#{mobile},#{delay_second},#{start_num},#{start_cycle},
        #{null_mdn_flag},#{long_sms_success},#{nday},#{ntimes},#{keyword},#{no_keyword}, #{is_null_mdn},#{deduct_black}, #{checkNullInterface},
        #{successChannel}, #{failChannel},#{is_buffer},#{succ_percent},#{real_channel_flag},#{real_channel_days},#{deduct_limit},#{deduct_limit_num})
    </insert>
    <update id="updateSpSpecialConfig" parameterType="SpSpecialConfig">
        update sms_sp_special_config set
        is_valid_mdn = #{is_valid_mdn},
        deduct_mdn = #{deduct_mdn},
        deduct_city = #{deduct_city},
        deduct_flag = #{deduct_flag},
        mobile = #{mobile},
        unicom = #{unicom},
        telecom = #{telecom},
        delay_second = #{delay_second},
        start_num = #{start_num},
        start_cycle = #{start_cycle},
        arrive = #{arrive},
        null_mdn_flag=#{null_mdn_flag},
        long_sms_success=#{long_sms_success},
        nday=#{nday},
        ntimes=#{ntimes},
        keyword=#{keyword},
        no_keyword=#{no_keyword},
        is_null_mdn=#{is_null_mdn},
        deduct_black=#{deduct_black},
        check_null_interface=#{checkNullInterface},
        succ_channel=#{successChannel},
        fail_channel=#{failChannel},
        is_buffer = #{is_buffer},
        real_channel_flag = #{real_channel_flag},
        real_channel_days = #{real_channel_days},
        succ_percent = #{succ_percent},
        deduct_limit = #{deduct_limit},
        deduct_limit_num = #{deduct_limit_num}
        where sp_id=#{spId}
    </update>

     <select id="listPageSpSpecialInfo" parameterType="SpInfo" resultMap="spInfoResultMap">
        select sp.id,sp.sp_name,sp.ip, sp.status,
        sp.fee_type,sp.createtime,sp.mobile_prefix,sp.mobile_suffix,sp.mobile_num,sp.unicom_prefix,sp.unicom_suffix,sp.unicom_num,sp.telecom_prefix,sp.telecom_suffix,sp.telecom_num,
        sp.mms_mobile_prefix,sp.mms_mobile_suffix,sp.mms_mobile_num,sp.mms_unicom_prefix,sp.mms_unicom_suffix,sp.mms_unicom_num,sp.mms_telecom_prefix,sp.mms_telecom_suffix,sp.mms_telecom_num,
        sp.report_url,sp.reply_url,sp.is_lock,
        sp.is_audit_word,sp.contact_name,sp.contact_mdn,sp.sp_saler,sp.sp_saler_mdn,sp.droptime,sp.sp_desc,sp.platform
        ,pec.arrive arrive_percent,pec.unknown unknown_percent,pec.is_valid_mdn,pec.deduct_mdn,pec.deduct_city,pec.deduct_flag
        ,pec.telecom,pec.unicom,pec.mobile,pec.delay_second
        from sms_sp_info sp
        left join sms_sp_special_config pec on sp.id=pec.sp_id
        where sp.status=1
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="platform!=null and platform!='' and platform >0">
            and sp.platform =#{platform}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler =#{sp_saler}
        </if>
        <if test="spid!=null and spid!=0">
            and sp.id=#{spid}
        </if>
        <if test="deduct_flag!=null and deduct_flag ==1">
            and pec.deduct_flag=1
        </if>
        <if test="deduct_flag!=null and deduct_flag ==2">
            and IFNULL(pec.deduct_flag, -1)!=1
        </if>

        <if test="createTime!=null and createTime!='' ">
            and sp.createtime&gt;=#{createTime}
        </if>
        <if test="createTime1!=null and createTime1!='' ">
            and sp.createtime&lt;=DATE_ADD(#{createTime1},INTERVAL 1 DAY)
        </if>
        order by createtime desc
    </select>

    <select id="listPageSpKeyWord" parameterType="KeywordBypass" resultType="KeywordBypass">
    	SELECT
			dk.id,
			dk.keyword,
			dk.description,
			dk.key_flag,
			DATE_FORMAT(dk.createtime , '%Y-%m-%d %H:%i:%s') createtime,
			dk.`status`,
			dk.spid,
			sp.sp_name
		FROM
			deduct_keyword dk
			LEFT JOIN sms_sp_info sp ON dk.spid = sp.id
		<where>
			<if test="spid!=null and spid!=''">
				and dk.spid=#{spid}
			</if>
			<if test="keyword!=null and keyword!=''">
				and dk.keyword LIKE CONCAT( '%',#{keyword}, '%' )
			</if>
			<if test="key_flag!=null and key_flag!=''">
				and dk.key_flag = #{key_flag}
			</if>
			<if test="status!=null and status!=''">
				and dk.status = #{status}
			</if>
			<if test="createtime!=null and createtime!=''">
				and dk.createtime &gt;= #{createtime}
			</if>
			<if test="createtime1!=null and createtime1!=''">
				and dk.createtime &lt;= DATE_ADD(#{createTime1},INTERVAL 1 DAY)
			</if>
		</where>
			 order by dk.createtime desc
    </select>

     <select id="getDeductKeyWord" parameterType="KeywordBypass" resultType="KeywordBypass">
    	SELECT
			dk.id,
			dk.keyword,
			dk.description,
			dk.key_flag,
			DATE_FORMAT(dk.createtime , '%Y-%m-%d %H:%i:%s') createtime,
			dk.`status`,
			dk.spid,
			sp.sp_name
		FROM
			deduct_keyword dk
			LEFT JOIN sms_sp_info sp ON dk.spid = sp.id
		where
			dk.id=#{id}
			limit 1
    </select>

    <insert id="insertDeductKeyWord" parameterType="KeywordBypass">
    	insert into deduct_keyword(keyword,description,createtime,spid,status,key_flag) values(#{keyword},#description},now(),#{spid},#{status},#{key_flag})
    </insert>
    <update id="updateDeductKeyWord" parameterType="KeywordBypass">
    	update deduct_keyword set keyword=#{keyword},description=#{description},spid=#{spid},status=#{status},key_flag=#{key_flag} where id=#{id}
    </update>

    <delete id="deleteDeductKeyWord">
    	delete from deduct_keyword where id =#{id}
    </delete>

    <select id="getDeductKeywordCountByName" parameterType="KeywordBypass"
            resultType="int">
        select count(1) from deduct_keyword dk
        where
        dk.keyword=#{keyword}
        <if test="sp_id!=null and sp_id!=' '">
            and dk.spid =#{spid}
        </if>
    </select>


     <select id="getSpInfoBySpName" parameterType="SpInfo" resultMap="spInfoResultMap">
        select
        sp.id,sp.sp_name
        from sms_sp_info sp
        where 1=1
        <if test="sp_name!=null ">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>

	 limit 1
    </select>


    <select id="listPageSpMonitorInfo" parameterType="SpInfo" resultMap="spInfoResultMap">
        select sp.id,sp.sp_name,sp.ip, sp.status,
        sp.international_prefix,sp.international_suffix,sp.international_num,
        sp.fee_type,sp.createtime,sp.mobile_prefix,sp.mobile_suffix,sp.mobile_num,sp.unicom_prefix,sp.unicom_suffix,sp.unicom_num,sp.telecom_prefix,sp.telecom_suffix,sp.telecom_num,
        sp.mms_mobile_prefix,sp.mms_mobile_suffix,sp.mms_mobile_num,sp.mms_unicom_prefix,sp.mms_unicom_suffix,sp.mms_unicom_num,sp.mms_telecom_prefix,sp.mms_telecom_suffix,sp.mms_telecom_num,
        sp.report_url,sp.reply_url,sp.is_lock,
        sp.is_audit_word,sp.contact_name,sp.contact_mdn,sp.sp_saler,sp.sp_saler_mdn,sp.droptime,sp.sp_desc,sp.platform
        ,sp.is_api_billing
        from sms_sp_info sp
        left join alarm_sp_api api on api.sp_id = sp.id
        left join alarm_sp_arrive arr on arr.sp_id = sp.id
        left join sms_url_sp_config susc on susc.spid = sp.id
        where sp.status=1

        <if test="alarmSpApi !=null and alarmSpApi.alarm_flag !=null and alarmSpApi.alarm_flag >=0">
            and IFNULL(api.alarm_flag,0) =#{alarmSpApi.alarm_flag}
        </if>
        <if test="alarmSpArrive !=null and  alarmSpArrive.alarm_flag !=null and alarmSpArrive.alarm_flag >=0 ">
            and IFNULL(arr.alarm_flag,0) =#{alarmSpArrive.alarm_flag}
        </if>
        <if test="url !=null and  url.isopen !=null and url.isopen >=0 ">
            and IFNULL(susc.isopen,0) =#{url.isopen}
        </if>

        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="platform!=null and platform!='' and platform >0">
            and sp.platform =#{platform}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler =#{sp_saler}
        </if>
        <if test="spid!=null and spid!=0">
            and sp.id=#{spid}
        </if>
        <if test="createTime!=null and createTime!='' ">
            and sp.createtime&gt;=#{createTime}
        </if>
        <if test="createTime1!=null and createTime1!='' ">
            and sp.createtime&lt;=DATE_ADD(#{createTime1},INTERVAL 1 DAY)
        </if>
        order by createtime desc
    </select>


    <select id="listPageDealySpMonitorInfo" parameterType="SpInfo" resultMap="spInfoResultMap">
        select sp.id,sp.sp_name,adr.alarm_flag adr_alarm_flag,arr.alarm_flag arr_alarm_flag
        from sms_sp_info sp
        left join alarm_delay_ratio adr on adr.sp_id = sp.id
        left join alarm_sp_arrive arr on arr.sp_id = sp.id
        where sp.status=1
        <if test="adr_alarm_flag !=null and adr_alarm_flag >=0">
            and IFNULL(adr.alarm_flag,0) =#{adr_alarm_flag}
        </if>
        <if test="arr_alarm_flag !=null and arr_alarm_flag >=0 ">
            and IFNULL(arr.alarm_flag,0) =#{arr_alarm_flag}
        </if>
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="platform!=null and platform!='' and platform >0">
            and sp.platform =#{platform}
        </if>
        <if test="sp_saler!=null and sp_saler!=''">
            and sp.sp_saler =#{sp_saler}
        </if>
        <if test="spid!=null and spid!=0">
            and sp.id=#{spid}
        </if>
        <if test="createTime!=null and createTime!='' ">
            and sp.createtime&gt;=#{createTime}
        </if>
        <if test="createTime1!=null and createTime1!='' ">
            and sp.createtime&lt;=DATE_ADD(#{createTime1},INTERVAL 1 DAY)
        </if>
        <if test="adr_alarm_flag==null and arr_alarm_flag==null">
			and adr.alarm_flag=1 or arr.alarm_flag=1
		</if>
        order by createtime desc
    </select>

    <update id="isOpenProvince">
    	update sms_sp_info set is_open_province=#{isOpenProvince} where id=#{id}
    </update>

    <update id="isOpenMmsProvince">
        update sms_sp_info set is_open_mms_province=#{isOpenMmsProvince} where id=#{id}
    </update>

    <update id="isOpenCountry" parameterType="SpInfo">
        update sms_sp_info set is_open_country=#{is_open_country},countryGroupId = #{countryGroupId} where id=#{id}
    </update>

    <select id="listPageEmptyObject" resultType="cn.roadm.bo.SmsEmptyObject">
    	select id,phone,descption,date_format(createtime,'%Y-%m-%d %H:%m:%s') createtime from sms_empty_object
		<where>
			<if test="phone!=null and phone!=''">
				phone LIKE CONCAT('%',#{phone},'%')
			</if>
		</where>
    </select>
    <insert id="addEmptyObject">
    	INSERT INTO `sms_empty_object` (`phone`, `createtime`, `descption`) VALUES (#{phone}, now(), #{descption})
    </insert>

    <delete id="deleteEmptyObject">
    	DELETE FROM `sms_empty_object` WHERE `id`=#{id}
    </delete>

    <select id="getSpPriceById" parameterType="cn.roadm.bo.SpPrice" resultType="cn.roadm.bo.SpPrice">
    	select id,name,lt_price ltPrice,yd_price ydPrice,dx_price dxPrice,DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,type from sms_price where id=#{id}
    </select>
    <insert id="addSpPrice" useGeneratedKeys="true" keyProperty="id" parameterType="cn.roadm.bo.SpPrice">
    	insert into sms_price(name,lt_price,yd_price,dx_price,createtime,type)
    	values(#{name},#{ltPrice}*100,#{ydPrice}*100,#{dxPrice}*100,now(),1)
    </insert>
    <update id="editSpPrice" parameterType="cn.roadm.bo.SpPrice">
    	update sms_price set name=#{name},lt_price=#{ltPrice}*100,yd_price=#{ydPrice}*100,dx_price=#{dxPrice}*100 where id=#{id}
    </update>

    <update id="setProductId" parameterType="spInfo">
    	update sms_sp_info set product_id=#{productId} where id=#{spid}
    </update>


    <select id="listPageMoney" parameterType="SpInfo"
            resultMap="spInfoAndSpmoney">
        select sp.id spid,sp.sp_name,sp.is_api_billing,sm.money,sm.use_money,sp.sa_id,sas.billing_mode,ssc.leftover_num,ssc.use_num
        from sms_sp_info sp left join sms_sp_money sm on sp.id=sm.spid
        left join sms_api_setting sas on sp.id=sas.sp_id left join sms_sp_charge ssc on sp.id=ssc.SP_ID
        <where>
        	sp.sa_id>0 and sp.status=1
        	<if test="saId!=null and saId!=''">
        		and sp.sa_id=#{saId}
        	</if>
        	<if test="spid!=null and spid!=''">
        		and sp.id=#{spid}
        	</if>
        	<if test="sp_name!=null and sp_name!=''">
        		and sp.sp_name like CONCAT('%',#{sp_name},'%')
        	</if>
        </where>
    </select>

    <select id="getMoneyCountById" parameterType="SpCharge" resultType="int">
        select count(id) from sms_sp_money
        <where>
            <if test="sp_id!=null and sp_id>0">
                spid = #{sp_id}
            </if>
        </where>
    </select>

    <insert id="insertMoney">
    	insert into sms_sp_money(spid,money,use_money) values(#{spId},#{money},0)
    </insert>

    <update id="updateSpMoney" parameterType="cn.roadm.bo.SpMoney">
        update sms_sp_money c
        set c.money = c.money + #{money}
        <!--         where c.effect_month = date_format(sysdate(),'%Y-%m') -->
        where c.spid = #{spId}
    </update>

     <select id="getMoneyById" parameterType="cn.roadm.bo.SpMoney" resultType="cn.roadm.bo.SpMoney">
        select money, billing_account_id as billingAccountId from sms_sp_money
        <where>
            <if test="spId!=null and spId>0">
                spid = #{spId}
            </if>
        </where>
    </select>


     <update id="updateSpMoneyReduce" parameterType="cn.roadm.bo.SpMoney">
        update sms_sp_money
        c set c.money =c.money-#{money}
        <!--         where c.effect_month = date_format(sysdate(),'%Y-%m') -->
        where c.spid = #{spId}
    </update>
    <select id="getAgentOpen" resultType="String">
    	select value from sms_system_config where config_key='agent_open'
    </select>
    <select id="listPageReturnFee" parameterType="cn.roadm.bo.SmsSpReturnFee" resultType="cn.roadm.bo.SmsSpReturnFee">
    	select id,sp_id,allnumber,money,createtime,returntime,billing_mode,status,realtime from sms_sp_return_fee
    	<where>
    		<if test="sp_id!=null and sp_id>=0">
    			and sp_id=#{sp_id}
    		</if>
    		<if test="billing_mode!=null and billing_mode!=''">
    			and billing_mode=#{billing_mode}
    		</if>
    		<if test="status!=null and status>-1">
    			and status=#{status}
    		</if>
    		<if test="createtime!=null and createtime!=''">
    			and returntime &gt;= #{createtime}
    		</if>
    		<if test="createtime1!=null and createtime1!=''">
    			and returntime &lt;= #{createtime1}
    		</if>
    	</where>
    	order by id desc
    </select>

    <select id="listPageSubReturnFee" parameterType="cn.roadm.bo.SmsSpReturnFee" resultType="cn.roadm.bo.SmsSpReturnFee">
        select id,sp_id,user_id,allnumber,money,createtime,returntime,billing_mode,status,realtime from sms_sp_return_fee_sub_account
        <where>
            <if test="sp_id!=null and sp_id>=0">
                and sp_id=#{sp_id}
            </if>
            <if test="user_id!=null and user_id>=0">
                and user_id=#{user_id}
            </if>
            <if test="billing_mode!=null and billing_mode!=''">
                and billing_mode=#{billing_mode}
            </if>
            <if test="status!=null and status>-1">
                and status=#{status}
            </if>
            <if test="createtime!=null and createtime!=''">
                and returntime &gt;= #{createtime}
            </if>
            <if test="createtime1!=null and createtime1!=''">
                and returntime &lt;= #{createtime1}
            </if>
        </where>
        order by id desc
    </select>

    <select id="getColumn" resultType="cn.roadm.bo.Column">
    	select COLUMN_NAME `column` from INFORMATION_SCHEMA.Columns where table_name=#{tableName} AND table_schema='zx_sms'
    	and COLUMN_NAME != #{excludeColumn} and COLUMN_NAME != 'sp_id' and COLUMN_NAME !='createtime'
    </select>

    <select id="getAllColSpinfoById"  parameterType="cn.roadm.bo.SpInfo" resultType="cn.roadm.bo.SpInfo">
    	select ${column} from sms_sp_info where id=#{spid}
    </select>
    <insert id="copySpinfo" useGeneratedKeys="true" keyProperty="id" parameterType="SpInfo">
    	insert into sms_sp_info(${column},createtime) select ${column},now() from sms_sp_info where id=#{spid}
    </insert>

    <insert id="copySpUserInfo" useGeneratedKeys="true" keyProperty="id" parameterType="SpInfo">
    	insert into sms_sp_user_info(${column},sp_id)  select ${column},#{newSpid} sp_id from sms_sp_user_info where sp_id=#{spid}
    </insert>

    <insert id="copyApiSetting" parameterType="SpInfo">
    	insert into sms_api_setting(${column},sp_id)  select ${column},#{newSpid} sp_id from sms_api_setting where sp_id=#{spid}
    </insert>

    <select id="listPageSpPriceHistory" parameterType="SpInfo" resultType="SpInfo">
    	select shp.id,shp.spid,shp.sp_price,DATE_FORMAT(shp.createtime, '%Y-%m-%d %H:%i:%s') createtime,
    	DATE_FORMAT(shp.effecttime, '%Y-%m-%d') effecttime,shp.otype,shp.user,shp.status,sp.sp_name,shp.province,shp.old_price from sp_history_price shp,sms_sp_info sp
    	<where>
    		shp.spid=sp.id
    		<if test="spid!=null and spid>=0">
    			and shp.spid=#{spid}
    		</if>
    		<if test="status!=null and status>=0">
    			and shp.status=#{status}
    		</if>
    		<if test="otype!=null and otype>0">
    			and shp.otype=#{otype}
    		</if>
    		<if test="otype!=null and otype==0">
    			and (shp.otype=0 or shp.otype is null)
    		</if>
    		<if test="sp_name!=null and sp_name!=''">
    			and sp.sp_name like concat('%',#{sp_name},'%')
    		</if>
    		<if test="createTime!=null and createTime!=''">
    			and shp.createtime &gt;= #{createTime}
    		</if>
    		<if test="createTime1!=null and createTime1!=''">
    			and shp.createtime &lt; DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL
                1 DAY)
    		</if>
            <if test="sp_saler!=null and sp_saler!=''">
                and sp.sp_saler = #{sp_saler}
            </if>
    	</where>
    	order by createtime desc
    </select>

    <select id="exportSpPriceHistory" parameterType="SpInfo" resultType="Map">
    	select shp.id,shp.spid,shp.sp_price,DATE_FORMAT(shp.createtime, '%Y-%m-%d %H:%i:%s') createtime,
    	DATE_FORMAT(IFNULL(shp.effecttime,shp.createtime), '%Y-%m-%d') effecttime,
    	(case
    	when shp.otype=1 then '联通'
    	when shp.otype=2 then '移动'
    	when shp.otype=3 then '电信'
    	else '全国'
    	 end) otype,
    	shp.user,shp.status,sp.sp_name,shp.province,shp.old_price from sp_history_price shp,sms_sp_info sp
    	<where>
    		shp.spid=sp.id
    		<if test="spid!=null and spid>=0">
    			and shp.spid=#{spid}
    		</if>
    		<if test="status!=null and status>=0">
    			and shp.status=#{status}
    		</if>
    		<if test="otype!=null and otype>0">
    			and shp.otype=#{otype}
    		</if>
    		<if test="otype!=null and otype==0">
    			and (shp.otype=0 or shp.otype is null)
    		</if>
    		<if test="sp_name!=null and sp_name!=''">
    			and sp.sp_name like concat('%',#{sp_name},'%')
    		</if>
    		<if test="createTime!=null and createTime!=''">
    			and shp.createtime &gt;= #{createTime}
    		</if>
    		<if test="createTime1!=null and createTime1!=''">
    			and shp.createtime &lt; DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL
                1 DAY)
    		</if>
    	</where>
    	order by createtime desc
    </select>

    <insert id="insertSpPriceHistory" useGeneratedKeys="true" keyProperty="id">
    	insert into sp_history_price(spid,old_price,sp_price,createtime,effecttime,otype,user,status,province)
    	 value(#{spid},#{old_price,jdbcType=INTEGER}*10000,#{sp_price,jdbcType=INTEGER}*10000,date_format(now(),'%Y-%m-%d %H:%i:%s'),#{effecttime},#{otype},#{user},#{status},#{province})
    </insert>
    <select id="getSpPriceHistoryById" resultType="SpInfo">
    	select id,spid,sp_price,createtime,effecttime,otype,status,province from sp_history_price where id=#{id}
    </select>
    <update id="updateSpPriceHistory">
    	update sp_history_price set status=1 where status=0 and effecttime is true and spid=#{spid}
    	<if test="province!=null and province!=''">
    		and province=#{province}
    	</if>
    </update>

    <update id="updatePriceHistory">
    	update sp_history_price set effecttime=#{effecttime},sp_price=#{sp_price,jdbcType=INTEGER}*10000,province=#{province},otype=#{otype},user=#{user} where id=#{id}
    </update>

    <update id="updatePriceHistoryStatus">
    	update sp_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 sp_price=#{sp_price,jdbcType=INTEGER}*10000,nettype=#{nettype} where spid=#{spid} 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="updateSpPrice">
    	update sms_api_setting set saleprice=#{sp_price} where sp_id=#{spid}
    </update>

    <update id="updateSpProPrice">
    	update sms_sp_info set provinceNetPrice=#{provinceNetPrice},province=#{province} where id=#{spid}
    </update>

    <select id="getSpPriceBySpId" resultType="SpInfo">
    	select spid,unicom_price,mobile_price,telecom_price from sp_price where spid=#{spid}
    </select>

    <insert id="insertSpPriceOtype">
    	insert sp_price(spid,unicom_price,mobile_price,telecom_price) values(#{spid},#{unicom_price}*10000,#{mobile_price}*10000,#{telecom_price}*10000)
    </insert>

    <update id="updateSpPriceOtype">
    	update sp_price set unicom_price=#{unicom_price}*10000,mobile_price=#{mobile_price}*10000,telecom_price=#{telecom_price}*10000 where spid=#{spid}
    </update>

    <delete id="delSpPriceOtype">
    	delete from sp_price where spid=#{spid}
    </delete>

    <update id="updateSpInfoImgById" parameterType="SpInfo">
        update sms_sp_info
        <set>
            <if test="business_license != null and business_license!=''">
                business_license=#{business_license,jdbcType=VARCHAR},

            </if>
            <if test="identity_front != null and identity_front!=''">
                identity_front=#{identity_front,jdbcType=VARCHAR},

            </if>
            <if test="identity_side != null and identity_side!=''">
                identity_side=#{identity_side,jdbcType=VARCHAR},

            </if>
            <if test="grade != null and grade!=''">
                `grade`=#{grade,jdbcType=VARCHAR},
            </if>
        </set>
        where id=#{spid}
    </update>

    <select id="getSpInfoListByGrade" parameterType="integer" resultType="SpInfo">
        select id spid,sp_name,grade,is_audit_black,sp_type from sms_sp_info
        where is_audit_black = 0
          and find_in_set(#{gradeId},grade)
          and status = '1'
    </select>

    <select id="getSpInfoListBySignGid" resultType="SpInfo">
    	select id spid,sp_name,sign_gid from sms_sp_info
        where find_in_set(#{sign_gid},sign_gid)
          and status = '1'
    </select>

	<select id="getSpInfoBySignture" resultType="SpInfo">
		select id spid,sp_name,sign_gid from sms_sp_info
        where check_signture_bank=1
          and status = '1'
	</select>

	<select id="getSpInfoByTranser" resultType="SpInfo">
		select id spid,sp_name
		<if test="rounting_number_flag!=null and rounting_number_flag>0">
			,rounting_number_flag
		</if>
		 from sms_sp_info
        where status = '1'
        <if test="rounting_number_flag!=null and rounting_number_flag>0">
        	and rounting_number_flag=1
        </if>
	</select>

	<update id="updateBatchFlag" parameterType="SpInfo">
    	 update sms_sp_info
    	 <set>
	    	 <if test="rounting_number_flag!=null and rounting_number_flag>-1">
				rounting_number_flag=#{rounting_number_flag},
			 </if>
    	 </set>
		 where id=#{spid}
    </update>

    <select id="getSpInfoListByKeywordGroupId" parameterType="integer" resultType="SpInfo">
        select id spid,sp_name,keyword_group_id,sp_type from sms_sp_info
        where  find_in_set(#{gradeId},keyword_group_id)
          and status = '1'
    </select>


    <select id="getSpInfoListBySensitive" parameterType="integer" resultType="SpInfo">
        select id spid,sp_name,sensitive_word_type,is_audit_word,sp_type from sms_sp_info
        where is_audit_word = 1
          and find_in_set(#{gradeId},sensitive_word_type)
          and status = '1'
    </select>

    <select id="listPageSpInfoListByGrade" parameterType="cn.roadm.bo.SpBlackReq" resultType="SpInfo">
        select id spid,sp_name,grade,is_audit_black,createTime from sms_sp_info
        where is_audit_black = 0
          and find_in_set(#{blackId},grade)
          and status = '1'
    </select>

    <update id="updateSpInfoGradeByIds">
            update sms_sp_info sp set
            sp.grade=#{grade},
            sp.is_audit_black = 0
            where sp.id=#{spid}
    </update>

    <update id="updateSpInfoSignIdByIds">
    	update sms_sp_info sp set sign_gid=#{sign_gid} where sp.id=#{spid}
    </update>

    <update id="updateSpInfoGradeByKeywordGroupId">
        update sms_sp_info sp set
        sp.keyword_group_id=#{grade}
        where sp.id=#{spid}
    </update>

    <update id="updateSpInfoSensitiveWordTypeByIds">
        update sms_sp_info sp set
        sp.sensitive_word_type=#{sensitiveWordType},
        sp.is_audit_word = 1
        where sp.id=#{spid}
    </update>
    <select id="listPageProvincePriceGroup" parameterType="ProvincePriceGroup" resultType="ProvincePriceGroup">
        SELECT id, name, DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime, remark
        FROM sms_province_price_group
        <where>
            <if test="name != null and name != ''">
                and name like concat('%',#{name},'%')
            </if>
        </where>
    </select>

    <select id="listAllProvincePriceGroup" parameterType="ProvincePriceGroup" resultType="ProvincePriceGroup">
        SELECT id, name, DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime, remark
        FROM sms_province_price_group
        <where>
            <if test="name != null and name != ''">
                and name like concat('%',#{name},'%')
            </if>
        </where>
    </select>

    <select id="listAllProvincePrice" parameterType="ProvincePrice" resultType="ProvincePrice">
        select province, ifnull(a.price,0) price
        from sms_price_province a
        <where>
        	<if test="gid!=null and gid!=''">
         		a.gid = #{gid}
        	</if>
        </where>

    </select>

    <insert id="insertProvincePriceGroup" useGeneratedKeys="true" keyProperty="id" parameterType="ProvincePriceGroup">
        insert into sms_province_price_group
        (name, createtime, remark)
        values (#{name}, now(), #{remark})
    </insert>


    <insert id="insertProvincePrice" useGeneratedKeys="true" keyProperty="id" parameterType="ProvincePrice">
        insert into sms_price_province
        (gid, province, price, createtime) values
        (#{gid}, #{province}, #{price}*10000, now())
    </insert>
    <update id="updateProvincePrice" parameterType="ProvincePrice">
        update sms_price_province set
        price=#{price}*10000,
        modifytime=now()
        where id=#{id}
    </update>

    <select id="getProvincePriceById" parameterType="int" resultType="ProvincePrice">
        select
        id, province, price
        from sms_price_province
        where id=#{id}
    </select>

    <select id="listPageProvincePrice" parameterType="ProvincePrice" resultType="ProvincePrice">
        select a.id, a.province, a.price,  DATE_FORMAT(modifytime, '%Y-%m-%d %H:%i:%s') modifytime,  DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') createtime,#{name} name
        from sms_price_province a
        where a.gid = #{gid}
        <if test="province != null and province != ''">
            and a.province like CONCAT('%',#{province},'%')
        </if>
    </select>

    <select id="getProvincePriceCountByPro" parameterType="ProvincePrice" resultType="int">
        select
        count(id)
        from sms_price_province
        where gid = #{gid} and province=#{province}
    </select>

    <delete id="deleteProvincePriceGroup" parameterType="int">
        delete from sms_province_price_group where id = #{id}
    </delete>

    <delete id="deleteProvincePriceByGid" parameterType="int">
        delete from sms_price_province where gid = #{gid}
    </delete>
    <delete id="deleteProvincePrice" parameterType="int">
        delete from sms_price_province where id = #{id}
    </delete>

    <select id="getProvincePriceGroupUsedCount" parameterType="int" resultType="int">
        select count(id)
        from sms_sp_info
        where pro_group_price_id=#{gid} and status != 2
    </select>

    <select id="listPageIpType" resultType="cn.roadm.bo.IpType">
    	select * from ip_type
    	<where>
    		<if test="name!=null and name!=''">
    			and name like concat('%',#{name},'%')
    		</if>
    		<if test="id!=null and id!=''">
    			and id=#{id}
    		</if>
    	</where>
    </select>

    <select id="getAllIpType" resultType="cn.roadm.bo.IpType">
    	select * from ip_type
    </select>

    <select id="getIpTypeById" resultType="cn.roadm.bo.IpType">
    	select * from ip_type where id=#{id} limit 1
    </select>

    <insert id="insertIpType">
    	insert into ip_type(name,ipoperator) values(#{name},#{ipoperator})
    </insert>

    <update id="updateIpType">
    	update ip_type set name=#{name},ipoperator=#{ipoperator} where id=#{id}
    </update>

    <delete id="deleteIpType">
    	delete from ip_type where id=#{id}
    </delete>

    <select id="getSpSameContentEffectTime" resultType="java.lang.String">
        select same_content_effect_time  from sms_api_setting where SP_ID = #{spId}
    </select>

    <update id="updateSpChargeRecordRemarks">
        update sms_charge_record set DESCPTION = #{remarks} where id = #{id}
    </update>

    <update id="updateMdnToSpUser">
        update sms_sp_user_info set mdn = #{spContact_mdn} where sp_id = #{spid} and role_id = 0
    </update>

    <select id="listSpClientUsers" resultType="java.util.Map">
        select id,username, `name` from sms_sp_user_info where sp_id = #{spId} and status = 1 order by createtime desc
    </select>

    <select id="listAllSpOtypePrice" resultType="cn.roadm.bo.SpOtypePrice">
        select spid as spId,unicom_price as unicomPrice,mobile_price as mobilePrice,telecom_price as telecomPrice from sp_price
    </select>

    <select id="querySpIdList" resultType="cn.roadm.bo.PageSelectOptionsVO">
        select distinct sp.id as value, sp.sp_name as label
        from sms_sp_info sp
                 left join sale_manager sm on sp.sp_saler = sm.seller
        where status = 1
        <if test="spSaleName != null and spSaleName != '' and spSaleName != 'undefined'">
            and sp.sp_saler = #{spSaleName}
        </if>
        <if test="spSaleManageId != null and spSaleManageId != ''">
            and sm.managerId = #{spSaleManageId}
        </if>

        <if test="saleList != null and saleList.size() != 0">
            and sp.sp_saler  in
            <foreach collection="saleList" item="item" index="index" open="(" close=")" separator=",">
                '${item}'
            </foreach>
        </if>
        <if test="spIdCustomerList != null and spIdCustomerList.size() != 0">
            and sp.id in
            <foreach collection="spIdCustomerList" item="item" index="index" open="(" close=")" separator=",">
                ${item}
            </foreach>
        </if>
    </select>

    <select id="querySubSpIdList" resultType="cn.roadm.bo.SubAcctInfo">
        select distinct sp.id as id, sp.username as userName,sp.sp_id as spId
        from sms_sp_user_info sp
        where role_id != 0
        <if test="spSaleManageId != null and spSaleManageId != ''">
            and sp.sp_id = #{spSaleManageId}
        </if>
    </select>

    <select id="querySmsChannelList" resultType="cn.roadm.bo.PageSelectOptionsVO">
        select id as value, channel_name as label
        from sms_send_channel_info
        where status = '1'
        order by id desc
    </select>

    <select id="getMmsChannelById" resultType="java.lang.String">
        select concat(id,' ',CHANNEL_NAME) from mms_send_channel_info where ID =#{channelid}
    </select>

    <select id="getAllSpInfoList" resultType="cn.roadm.bo.PageSelectOptionsVO">
        select id as value, sp_name as label
        from sms_sp_info
        where status = 1
    </select>
</mapper>