<?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.admin.mapper.SpInfoMapper">
    <resultMap id="editSpInfo" type="cn.roadm.admin.dto.SmsSpInfoEditDO">
        <id property="id" column="id"/>
        <result property="spName" column="sp_name"/>
        <result property="status" column="status"/>
        <result property="ip" column="ip"/>
        <result property="createTime" column="createtime"/>
        <result property="dropTime" column="droptime"/>
        <result property="mobilePrefix" column="mobile_prefix"/>
        <result property="mobileSuffix" column="mobile_suffix"/>
        <result property="unicomPrefix" column="unicom_prefix"/>
        <result property="unicomSuffix" column="unicom_suffix"/>
        <result property="telecomPrefix" column="telecom_prefix"/>
        <result property="telecomSuffix" column="telecom_suffix"/>
        <result property="mobileNum" column="mobile_num"/>
        <result property="unicomNum" column="unicom_num"/>
        <result property="telecomNum" column="telecom_num"/>
        <result property="mmsMobilePrefix" column="mms_mobile_prefix"/>
        <result property="mmsMobileSuffix" column="mms_mobile_suffix"/>
        <result property="mmsUnicomPrefix" column="mms_unicom_prefix"/>
        <result property="mmsUnicomSuffix" column="mms_unicom_suffix"/>
        <result property="mmsTelecomPrefix" column="mms_telecom_prefix"/>
        <result property="mmsTelecomSuffix" column="mms_telecom_suffix"/>
        <result property="mmsMobileNum" column="mms_mobile_num"/>
        <result property="mmsUnicomNum" column="mms_unicom_num"/>
        <result property="mmsTelecomNum" column="mms_telecom_num"/>
        <result property="isLock" column="is_lock"/>
        <result property="signature" column="signature"/>
        <result property="feeType" column="fee_type"/>
        <result property="isAuditWord" column="is_audit_word"/>
        <result property="groupId" column="groupid"/>
        <result property="address" column="adress"/>
        <result property="qq" column="qq"/>
        <result property="email" column="email"/>
        <result property="contactName" column="contact_name"/>
        <result property="contactMdn" column="contact_mdn"/>
        <result property="spSaler" column="sp_saler"/>
        <result property="spSalerMdn" column="sp_saler_mdn"/>
        <result property="spDesc" column="sp_desc"/>
        <result property="spType" column="sp_type"/>
        <result property="isNeedSignture" column="is_need_signture"/>
        <result property="checkSigntureBank" column="check_signture_bank"/>
        <result property="reportUrl" column="report_url"/>
        <result property="replyUrl" column="reply_url"/>
        <result property="spChannelconfig" column="sp_channelconfig"/>
        <result property="spMmsChannelconfig" column="sp_mms_channelconfig"/>
        <result property="platform" column="PLATFORM"/>
        <result property="portalSpCode" column="portal_sp_code"/>
        <result property="portalSpUsername" column="portal_sp_username"/>
        <result property="portalSpPassword" column="portal_sp_password"/>
        <result property="portalSpid" column="portal_spid"/>
        <result property="unsubscribeSms" column="unsubscribe_sms"/>
        <result property="isApi" column="is_api"/>
        <result property="returnFeeType" column="return_fee_type"/>
        <result property="isAuditBlack" column="is_audit_black"/>
        <result property="templateWordPolicy" column="template_word_policy"/>
        <result property="isApiBilling" column="is_api_billing"/>
        <result property="grade" column="grade"/>
        <result property="sensitiveWordType" column="sensitive_word_type"/>
        <result property="verificationCodeFreeReview" column="verification_code_free_review"/>
        <result property="sendPriority" column="send_priority"/>
        <result property="isSendPriority" column="is_send_priority"/>
        <result property="isWeb" column="is_web"/>
        <result property="internationalSuffix" column="international_suffix"/>
        <result property="internationalNum" column="international_num"/>
        <result property="internationalPrefix" column="international_prefix"/>
        <result property="businessLicense" column="business_license"/>
        <result property="identityFront" column="identity_front"/>
        <result property="identitySide" column="identity_side"/>
        <result property="urlDetect" column="url_detect"/>
        <result property="isOpenProvince" column="is_open_province"/>
        <result property="isContract" column="is_contract"/>
        <result property="failRetrun" column="fail_retrun"/>
        <result property="saId" column="sa_id"/>
        <result property="productId" column="product_id"/>
        <result property="isOpenProvinceGroup" column="is_open_province_group"/>
        <result property="proGroupId" column="pro_group_id"/>
        <result property="sendProvince" column="send_province"/>
        <result property="unsendProvince" column="unsend_province"/>
        <result property="isOpenChannelLimit" column="is_open_channel_limit"/>
        <result property="vcodeBlackFlag" column="vcode_black_flag"/>
        <result property="commissionPrice" column="commission_price"/>
        <result property="webSendFlag" column="web_send_flag"/>
        <result property="noProfit" column="noProfit"/>
        <result property="beautyPhoneFlag" column="beauty_phone_flag"/>
        <result property="systemLimitFlag" column="system_limit_flag"/>
        <result property="isOpenTransfer" column="is_open_transfer"/>
        <result property="transferInterface" column="transfer_interface"/>
        <result property="webExportFlag" column="web_export_flag"/>
        <result property="interSmsFlag" column="inter_sms_flag"/>
        <result property="interPriceGroup" column="inter_price_group"/>
        <result property="interPriceRate" column="inter_price_rate"/>
        <result property="webShowStatusFlag" column="web_show_status_flag"/>
        <result property="backSignFlag" column="back_sign_flag"/>
        <result property="multiSignFlag" column="multi_sign_flag"/>
        <result property="unsendCity" column="unsend_city"/>
        <result property="provinceNetPrice" column="provinceNetPrice"/>
        <result property="detachment" column="detachment"/>
        <result property="keywordGroupId" column="keyword_group_id"/>
        <result property="phoneBypassFlag" column="phone_bypass_flag"/>
        <result property="enableClientSms" column="enableClientSms"/>
        <result property="clientMenu" column="clientMenu"/>
        <result property="randomCallMdnSuffix" column="randomCallMdnSuffix"/>
        <result property="isBatchBlack" column="is_batch_black"/>
        <result property="isBatchMms" column="is_batch_mms"/>
        <result property="clientStatusCol" column="client_status_col"/>
        <result property="clientSendCol" column="client_send_col"/>
        <result property="clientSendCondition" column="client_send_condition"/>
        <result property="arabSend" column="arab_send"/>
        <result property="starLevel" column="star_level"/>
        <result property="eid" column="eid"/>
        <result property="province" column="province"/>
        <result property="sendCity" column="send_city"/>
        <result property="rcMode" column="rc_mode"/>
        <result property="customer" column="customer"/>
        <result property="subAccountBillingMode" column="sub_account_billing_mode"/>
        <result property="longSmsShowFirst" column="long_sms_show_first"/>
        <result property="proGroupPriceId" column="pro_group_price_id"/>
        <result property="countryGroupId" column="countryGroupId"/>
        <result property="isOpenCountry" column="is_open_country"/>
        <result property="noSpBlack" column="no_sp_black"/>
        <result property="signGid" column="sign_gid"/>
        <result property="interceptTiming" column="intercept_timing"/>
        <result property="rountingNumberFlag" column="rounting_number_flag"/>
        <result property="billingType" column="billing_type"/>
        <result property="specialCharacter" column="special_character"/>
        <result property="iptype" column="iptype"/>
        <result property="enableShunt" column="enable_shunt"/>
        <result property="enableResend" column="enable_resend"/>
        <result property="nullCheckSupplier" column="null_check_supplier"/>
        <result property="signtureBeginTime" column="signtureBeginTime"/>
        <result property="signtureEndTime" column="signtureEndTime"/>
        <result property="afterSpExtend" column="AFTER_SP_EXTEND"/>
        <result property="urlContentIntercept" column="url_content_intercept"/>
        <result property="numberTransferSupplier" column="number_transfer_supplier"/>
        <result property="checkNullSign" column="check_null_sign"/>
        <result property="isOpenMmsProvince" column="is_open_mms_province"/>
        <result property="isOpenMmsProvinceGroup" column="is_open_mms_province_group"/>
        <result property="mmsProGroupId" column="mms_pro_group_id"/>
        <result property="mmsPhoneBypassFlag" column="mms_phone_bypass_flag"/>
        <result property="lockStatus" column="lock_status"/>
        <result property="disableLogin" column="disable_login"/>
        <result property="noMatchTemplateAudit" column="no_match_template_audit"/>
        <result property="clientOtherAreaValid" column="client_other_area_valid"/>
        <result property="signContentValid" column="sign_content_valid"/>
        <result property="provisionPrice" column="provision_price"/>
        <result property="channelCallMdn" column="channel_callmdn"/>
        <result property="updateTime" column="update_time"/>
        <result column="blackapi_before" property="blackApiBefore"/>
        <result column="disable_with_number" property="disableWithNumber"/>
        <result column="disable_number_rule" property="disableNumberRule"/>
        <result column="pawd" property="password"/>
        <result column="web_pawd" property="webPassword"/>
        <result column="disableWithNumberTime" property="disableWithNumberTime"/>
        <result column="mms_template_auto_audit" property="mmsTemplateAutoAudit"/>
        <result column="auto_extract_sign" property="autoExtractSign"/>
        <result column="auto_generate_mmsChannel_template" property="autoGenerateMmsChannelTemplate"/>
        <result column="subacct_black_flag" property="subacctBlackFlag"/>
        <result column="domainLimit" property="domainLimit"/>
        <result column="sign_limit_rule" property="signLimitRule"/>
        <result column="sign_template_limit" property="signTemplateLimit"/>
        <result column="aim_over_70_limit" property="aimOver70Limit"/>
        <result column="aim_is_match" property="aimIsMatch"/>
        <result column="api_aim_is_match" property="apiAimIsMatch"/>
        <result column="distinguish_fullwidth" property="distinguishFullwidth"/>
        <result column="allow_temp_strategy" property="allowTempStrategy"/>
        <result column="phone_safe_strategy" property="phoneSafeStrategy"/>
        <result column="unknown_billing" property="unknownBilling"/>
        <result column="transfer_local" property="transferLocal"/>
        <result column="template_no_match" property="templateNoMatch"/>
        <result column="currency" property="currency"/>
        <result column="sp_scope" property="spScope"/>
        <result column="sp_mms_otype" property="spMmsOtype"/>
        <result column="yuexin_push" property="yuexinPush"/>
        <result column="mms_sign_report_push" property="mmsSignReportPush"/>
        <result column="content_length_limit" property="contentLengthLimit"/>
        <result column="mms_reply_url" property="mmsReplyUrl"/>
    </resultMap>

    <resultMap type="cn.roadm.admin.entity.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="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="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_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="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="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"/>
    </resultMap>

    <select id="selectListPageSpInfo" resultType="cn.roadm.admin.dto.SmsSpInfoDO">
        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.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 as salePrice,
        sa.billing_mode,
        sp.sp_type,
        sp.billing_type,
        ses.full_name,
        ssc.leftover_num as leftOverNum,
        sas.clientid
        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="params.clientid != null and params.clientid != ''">
                and sas.clientid = #{params.clientid}
            </if>
            <if test="params.spName != null and params.spName != ''">
                and sp.sp_name like CONCAT('%', #{params.spName}, '%')
            </if>
            <if test="params.spId != null and params.spId != 0">
                and sp.id = #{params.spId}
            </if>
            <if test="params.username != null and params.username != ''">
                and sp_user.username like CONCAT('%', #{params.username}, '%')
            </if>
            <if test="params.is_lock != null and params.is_lock != ''">
                and sp.is_lock = #{params.is_lock}
            </if>
            <if test="params.startTime != null and params.startTime != ''">
                and sp.createtime &gt;= #{params.startTime}
            </if>
            <if test="params.endTime != null and params.endTime != ''">
                and sp.createtime &lt;= DATE_ADD(#{params.endTime}, INTERVAL 1 DAY)
            </if>
            <if test="params.username != null and params.username != ''">
                and sp_user.username = #{params.username}
            </if>
            <if test="params.spType!=null and params.spType>0">
                and sp.sp_type =#{params.spType}
            </if>
            <if test="params.eid != null and params.eid != ''">
                and sp.eid  = #{params.eid}
            </if>
            <if test="params.priceConditionSymbol == 1 and params.priceConditionValue != null and params.priceConditionValue != ''">
                and sa.SALEPRICE &gt;= #{params.priceConditionValue}
            </if>
            <if test="params.priceConditionSymbol == 2 and params.priceConditionValue != null and params.priceConditionValue != ''">
                and sa.SALEPRICE &lt;= #{params.priceConditionValue}
            </if>
            <if test="params.startLevel != null and params.startLevel != ''">
                and sp.star_level = #{params.startLevel}
            </if>
            <if test="params.clientid != null">
                and sas.clientid = #{params.clientid}
            </if>
        </where>
        order by createtime desc
    </select>

    <select id="getEditSpInfoById" resultMap="editSpInfo">
        select sp.id, sp_name, sp.status, ip, sp.createtime, sp.droptime,mobile_prefix,
        mobile_suffix, unicom_prefix, unicom_suffix, telecom_prefix, telecom_suffix,mobile_num, unicom_num, telecom_num,
        mms_mobile_prefix,
        mms_mobile_suffix,
        mms_unicom_prefix,mms_unicom_suffix,mms_telecom_prefix,mms_telecom_suffix,mms_mobile_num,mms_unicom_num,mms_telecom_num,
        is_lock,signature,fee_type,is_audit_word,groupid,adress,qq,email,contact_name,contact_mdn,sp_saler,sp_saler_mdn,sp_desc,sp_type,is_need_signture,
        check_signture_bank,sas.report_url,sas.reply_url,sp_channelconfig,sp_mms_channelconfig,PLATFORM,portal_sp_code,portal_sp_username,portal_sp_password,
        portal_spid,unsubscribe_sms,is_api,return_fee_type,is_audit_black,template_word_policy,is_api_billing,grade,sensitive_word_type,verification_code_free_review,
        send_priority,is_send_priority,is_web,international_suffix,international_num,international_prefix,business_license,identity_front,identity_side,url_detect,
        is_open_province,is_contract,fail_retrun,sa_id,product_id,is_open_province_group,pro_group_id,unsend_province,is_open_channel_limit,vcode_black_flag,commission_price,
        web_send_flag,noProfit,beauty_phone_flag,system_limit_flag,is_open_transfer,transfer_interface,web_export_flag,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,enableClientSms,clientMenu,randomCallMdnSuffix,is_batch_black,is_batch_mms,
        client_status_col,client_send_col,client_send_condition,arab_send,star_level,eid,province,send_city,rc_mode,customer,sub_account_billing_mode,long_sms_show_first,pro_group_price_id,
        countryGroupId,is_open_country,no_sp_black,sign_gid,intercept_timing,rounting_number_flag,billing_type,special_character,iptype,enable_shunt,enable_resend,null_check_supplier,
        signtureBeginTime,signtureEndTime,AFTER_SP_EXTEND,url_content_intercept,number_transfer_supplier,check_null_sign,is_open_mms_province,is_open_mms_province_group,mms_pro_group_id,
        mms_phone_bypass_flag,lock_status,disable_login,no_match_template_audit,client_other_area_valid,sign_content_valid,provision_price,channel_callmdn,
        disableWithNumberTime,mms_template_auto_audit,auto_extract_sign,auto_generate_mmsChannel_template,subacct_black_flag,domainLimit,
        sign_limit_rule, sign_template_limit, aim_over_70_limit, aim_is_match, api_aim_is_match,
        distinguish_fullwidth,allow_temp_strategy, phone_safe_strategy,
        sp.update_time, sp.blackapi_before, sp.disable_with_number, sp.disable_number_rule,
        ssui.pawd, ssui.web_pawd, sas.send_province,
        sp.unknown_billing, sp.transfer_local, sp.template_no_match,
        sp.currency, sp.sp_scope, sp.sp_mms_otype,
        sas.yuexin_push, sas.mms_sign_report_push, sas.content_length_limit, sas.mms_reply_url
        from sms_sp_info sp
        left join sms_sp_user_info ssui on sp.id = ssui.sp_id
        left join sms_api_setting sas on sp.id = sas.SP_ID
        where sp.id = #{id}
        and ssui.role_id = 0
    </select>

    <select id="getCompanyNameByEid" resultType="java.lang.String">
        select full_name from sms_enterprise where id = #{eid}
    </select>

    <select id="getEnterpriseList" resultType="cn.roadm.admin.table.SmsEnterpriseTable">
        select id,
               full_name          as fullName,
               short_name         as shortName,
               is_sign            as isSign,
               company_user       as companyUser,
               company_user_phone as companyUserPhone
        from sms_enterprise
        where state = 0;
    </select>

    <select id="getProvinceNetPriceGroupList" resultType="cn.roadm.admin.table.SmsProvincePriceGroupTable">
        SELECT id, name, DATE_FORMAT(createtime, '%Y-%m-%d %H:%i:%s') as createTime, remark
        FROM sms_province_price_group
        <where>
            <if test="name != null and name != ''">
                and name like concat('%', #{name}, '%')
            </if>
        </where>
    </select>

    <select id="getProvinceNetPriceGroupOptions" resultType="cn.roadm.admin.entity.SpEditInfoSelectorEntity$Options">
        SELECT CAST(id AS CHAR) as `value`, name as label
        from sms_province_price_group
    </select>

    <select id="getEnterpriseOptions" resultType="cn.roadm.admin.entity.SpEditInfoSelectorEntity$Options">
        SELECT CAST(id AS CHAR) as `value`, full_name as label
        from sms_enterprise
        where state = 0
    </select>

    <select id="getBusinessOptions" resultType="cn.roadm.admin.entity.SpEditInfoSelectorEntity$Options">
        SELECT CAST(id AS CHAR) as `value`, serviceType as label
        from sms_service_type
        where status = 1
        order by id desc
    </select>

    <select id="getSaleOptions" resultType="cn.roadm.admin.entity.SpEditInfoSelectorEntity$Options">
        select NAME as label, NAME as `value`
        from sms_user_info
        where ROLE_ID in (52,520,50,530)
          and STATUS = 1
        order by NAME asc
    </select>

    <select id="getInterPriceGroupOptions" resultType="cn.roadm.admin.entity.SpEditInfoSelectorEntity$Options">
        select id as `value`, name as label
        from inter_sms_price_group
    </select>

    <select id="getKeyWordGroupOptions" resultType="cn.roadm.admin.entity.SpEditInfoSelectorEntity$Options">
        SELECT id as `value`, groupName as label
        FROM sms_keyword_group
        where state = 0
    </select>

    <select id="getApiSettingConfigByColumn" resultType="cn.roadm.admin.dto.SpBitchUpdateDO">
        select a.id as spId, a.sp_name as spName, SP_AUDIT_TYPE as val
        from sms_sp_info a
                 left join sms_api_setting b on a.id = b.SP_ID
        where a.status = 1
    </select>

    <select id="getSpConfigListByColumn" resultType="cn.roadm.admin.dto.SpBitchUpdateDO">
        select id as spId, sp_name as spName, ${column} as val from sms_sp_info a where a.status = 1
    </select>

    <select id="getBusinessList" resultType="cn.roadm.admin.table.SmsServiceTypeTable">
        select id, serviceType
        from sms_service_type
        where status = 1
        order by id desc
    </select>

    <select id="getSimpleListOptions" resultType="cn.roadm.admin.controller.vo.PageSelectOptionsVO">
        select id as value, sp_name as label
        from sms_sp_info
        where status = 1
          and is_lock = 1
    </select>

    <update id="updateProvinceChannelConfig">
        update sms_sp_info set is_open_province = #{isOpenProvince}, is_open_province_group = #{isOpenProvinceGroup},
        pro_group_id = #{channelGroupId}
        where id = #{spId}
    </update>

    <insert id="addSpInfo" useGeneratedKeys="true" keyProperty="id">
        insert into sms_sp_info (sp_name, ip, eid, sp_type, is_api_billing, return_fee_type, noProfit, contact_name,
        contact_mdn, sp_saler, fail_retrun, billing_type, is_audit_word,
        is_web, inter_sms_flag, disable_login, send_priority, createtime, is_lock)
        values (#{spName}, #{ip}, #{eid}, #{spType}, #{isApiBilling}, #{returnFeeType}, #{noProfit}, #{spContactName},
        #{spContactMdn}, #{spSaler}, #{failRetrun}, #{billingType}, #{isAuditWord},
        #{isWeb}, #{interSmsFlag}, #{disableLogin}, #{sendPriority}, now(), 1)
    </insert>

    <insert id="insertSpUserInfo" useGeneratedKeys="true" keyProperty="id">
        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>

    <insert id="addSpSetting">
        insert into sms_api_setting (sp_id, sp_audit_type, return_type, content_type, send_province, saleprice,
        sp_audit_number)
        values (#{id}, 0, #{returnFeeType}, #{spType}, #{province}, #{spSaler}, 0)
    </insert>

    <insert id="insertSpApiSettingIfAbsent">
        insert into sms_api_setting (sp_id, sp_audit_type, return_type, content_type, send_province, saleprice,
                                     sp_audit_number)
        select sp_id, sp_audit_type, return_type, content_type, send_province, saleprice, sp_audit_number
        from (
                 select #{id}               as sp_id,
                        0                   as sp_audit_type,
                        #{returnFeeType}    as return_type,
                        #{spType}           as content_type,
                        #{sendProvince}     as send_province,
                        COALESCE(#{salePrice}, 0) as saleprice,
                        0                   as sp_audit_number
             ) v
        where not exists (select 1 from sms_api_setting t where t.sp_id = #{id})
    </insert>

    <insert id="addSpChannelConfig">
        insert into sms_chennel_config (opertor_type,channelid,sp_id,createtime) values (#{otype},#{channelId},#{spId},
        #{createTime})
    </insert>

    <delete id="deleteSpChannelConfigBySpId">
        delete from sms_chennel_config where sp_id = #{spId}
    </delete>

    <update id="updateSpChannelNum">
        update sms_sp_info
        <set>
            <if test="mobilePrefix != null">
                mobile_prefix = #{mobilePrefix},
            </if>
            <if test="mobileSuffix != null">
                mobile_suffix = #{mobileSuffix},
            </if>
            <if test="mobileNum != null">
                mobile_num = #{mobileNum},
            </if>
            <if test="unicomPrefix != null">
                unicom_prefix = #{unicomPrefix},
            </if>
            <if test="unicomSuffix != null">
                unicom_suffix = #{unicomSuffix},
            </if>
            <if test="unicomNum != null">
                unicom_num = #{unicomNum},
            </if>
            <if test="telecomPrefix != null">
                telecom_prefix = #{telecomPrefix},
            </if>
            <if test="telecomSuffix != null">
                telecom_suffix = #{telecomSuffix},
            </if>
            <if test="telecomNum != null">
                telecom_num = #{telecomNum},
            </if>
            <if test="spChannelconfig != null">
                sp_channelconfig = #{spChannelconfig}
            </if>
        </set>
        where id = #{spId}
    </update>

    <update id="addSpTemp3">
        update sms_api_setting
        <set>
            <if test="returnType != null">
                return_type = #{returnType},
            </if>
            <if test="isReportNow != null">
                isreportnow = #{isReportNow},
            </if>
            <if test="isValidBome != null">
                isvalidbome = #{isValidBome},
            </if>
            <if test="auditType != null">
                sp_audit_type = #{auditType},
            </if>
            <if test="price != null and price != ''">
                saleprice = #{price},
            </if>
            <choose>
                <when test="customAuditNum != null and customAuditNum &gt; 0">
                    sp_audit_number=#{customAuditNum},
                </when>
                <otherwise>
                    sp_audit_number = null ,
                </otherwise>
            </choose>
        </set>
        where SP_ID = #{spId}
    </update>

    <select id="getSpApiBillingType" resultType="java.lang.Integer">
        select is_api_billing from sms_sp_info where id = #{spId}
    </select>

    <select id="getApiSettingConfigBySpId" resultType="cn.roadm.admin.dto.SmsApiSettingDO">
        select sp_id, sp_audit_type, samemdnmaxnum, minsendtotal, return_type, no_limit_mdn, sp_audit_number, saleprice,
        isreportnow, isvalidbome, samecontentmaxnum, content_type, is_flowcode, begin_send_time, end_send_time,
        send_type, plan_send_time, report_url, reply_url, push_flag, samemdn_nday, samemdn_oneday, samemdn_threeday,
        samemdn_oneminute, samemdn_onehour, limit_days, share_limit_sp, push_buyun, push_receiver, push_pswd,
        batch_api_sms, fixed_length, zt_ms, send_province, samemsg_nminute, samemsg_nnum, loopsms_sec, loopsms_num,
        loopsms_strategy, push_limit, day_limit, success_limit, billing_mode, speedcontrol, allowoverspeed,
        overspeedtimes, overspeedstrategy, httpmaxspeed, month_limit, otype_limit, same_content_effect_time,
        begin_send_time_one, end_send_time_one, content_length_limit, yuexin_push from sms_api_setting where SP_ID =
        #{spId}
    </select>

    <update id="updateApiSettingConfig">
        update sms_api_setting set REPLY_URL = #{replyUrl}, REPORT_URL = #{reportUrl} where SP_ID = #{spId}
    </update>

    <select id="getColumn" resultType="cn.roadm.admin.entity.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>

    <insert id="copySpInfo" useGeneratedKeys="true" keyProperty="id" parameterType="cn.roadm.admin.entity.CopySpInfo">
        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="cn.roadm.admin.entity.CopySpInfo">
        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="cn.roadm.admin.entity.CopySpInfo">
        insert into sms_api_setting(${column},sp_id) select ${column},#{newSpId} sp_id from sms_api_setting where
        sp_id=#{spId}
    </insert>

    <select id="getSpInfoById" 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,
        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,
        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
        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 = #{id}
        and sp.status = 1
        and sp.is_lock = 1
        limit 1
    </select>

    <select id="listAllSpSubAcctInfo" parameterType="integer" resultType="cn.roadm.admin.entity.SubAcctInfo">
        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>

    <update id="updateSpInfo">
        update sms_sp_info set
        sp_name=#{spName,jdbcType=VARCHAR},
        platform=#{platform,jdbcType=VARCHAR},
        is_audit_word=#{isAuditWord},
        contact_name=#{spContactName,jdbcType=VARCHAR},
        contact_mdn=#{spContactMdn,jdbcType=VARCHAR},
        ip=#{ip,jdbcType=VARCHAR},
        sp_type=#{spType},
        report_url=#{reportUrl,jdbcType=VARCHAR},
        reply_url=#{replyUrl,jdbcType=VARCHAR},
        sp_saler=#{spSaler,jdbcType=VARCHAR},
        sp_saler_mdn=#{spSalerMdn,jdbcType=VARCHAR},
        is_need_signture=#{isNeedSignture,jdbcType=VARCHAR},
        check_signture_bank=#{checkSigntureBank,jdbcType=VARCHAR},
        signature=#{signature,jdbcType=VARCHAR},
        groupid=#{groupId,jdbcType=VARCHAR},
        is_api=#{isApi,jdbcType=INTEGER},
        return_fee_type=#{returnFeeType,jdbcType=INTEGER},
        is_audit_black=#{isAuditBlack,jdbcType=INTEGER},
        template_word_policy=#{templateWordPolicy,jdbcType=INTEGER},
        is_api_billing=#{isApiBilling,jdbcType=INTEGER},
        grade=#{grade,jdbcType=VARCHAR},
        sensitive_word_type=#{sensitiveWordType,jdbcType=VARCHAR},
        verification_code_free_review=#{verificationCodeFreeReview},
        is_send_priority=#{isSendPriority,jdbcType=INTEGER},
        is_web=#{isWeb,jdbcType=INTEGER},
        send_priority=#{sendPriority,jdbcType=INTEGER},
        url_detect=#{urlDetect,jdbcType=INTEGER},
        is_contract=#{isContract},
        fail_retrun=#{failRetrun},
        unsend_province=#{unSendProvince},
        is_open_channel_limit=#{isOpenChannelLimit},
        vcode_black_flag=#{vcodeBlackFlag},
        web_send_flag=#{webSendFlag},
        noProfit=#{noProfit},
        commission_price=#{commissionPrice}*10000,
        beauty_phone_flag=#{beautyPhoneFlag},
        system_limit_flag=#{systemLimitFlag},
        web_export_flag=#{webExportFlag},
        is_open_transfer=#{isOpenTransfer},
        inter_sms_flag=#{interSmsFlag},
        inter_price_group=#{interPriceGroup},
        inter_price_rate=#{interPriceRate},
        web_show_status_flag=#{webShowStatusFlag},
        back_sign_flag=#{backSignFlag},
        multi_sign_flag=#{multiSignFlag},
        unsend_city=#{unSendCity},
        provinceNetPrice=#{provinceNetPrice},
        detachment=#{detachment},
        keyword_group_id=#{keywordGroupId},
        phone_bypass_flag=#{phoneBypassFlag},
        mms_phone_bypass_flag=#{mmsPhoneBypassFlag},
        enableClientSms=#{enableClientSms},
        randomCallMdnSuffix=#{randomCallMdnSuffix},
        clientMenu=#{clientMenu},
        is_batch_black=#{isBatchBlack},
        is_batch_mms=#{isBatchMms},
        client_status_col=#{clientStatusCol},
        client_send_col=#{clientSendCol},
        client_send_condition=#{clientSendCondition},
        arab_send=#{arabSend},
        star_level=#{starLevel},
        eid = #{eid},
        send_city = #{sendCity},
        rc_mode = #{rcMode},
        long_sms_show_first = #{longSmsShowFirst},
        sub_account_billing_mode = #{subAccountBillingMode},
        pro_group_price_id=#{proGroupPriceId},
        no_sp_black=#{noSpBlack},
        billing_type=#{billingType},
        intercept_timing=#{interceptTiming},
        iptype=#{iptype},
        special_character=#{specialCharacter},
        enable_shunt=#{enableShunt},
        enable_resend=#{enableResend},
        null_check_supplier=#{nullCheckSupplier},
        signtureBeginTime=#{signtureBeginTime},
        signtureEndTime=#{signtureEndTime},
        after_sp_extend = #{afterSpExtend},
        url_content_intercept=#{urlContentIntercept},
        number_transfer_supplier=#{numberTransferSupplier},
        check_null_sign=#{checkNullSign},
        no_match_template_audit=#{noMatchTemplateAudit},
        client_other_area_valid=#{clientOtherAreaValid},
        sign_content_valid=#{signContentValid},
        disable_login=#{disableLogin},
        provision_price=#{provisionPrice},
        transfer_interface = #{transferInterface},
        channel_callmdn = #{channelCallMdn},
        blackapi_before=#{blackApiBefore},
        disable_with_number=#{disableWithNumber},
        disable_number_rule=#{disableNumberRule},
        unknown_billing = #{unknownBilling},
        mms_template_auto_audit = #{mmsTemplateAutoAudit},
        auto_extract_sign = #{autoExtractSign},
        auto_generate_mmsChannel_template = #{autoGenerateMmsChannelTemplate},
        subacct_black_flag = #{subacctBlackFlag},
        transfer_local = #{transferLocal},
        template_no_match = #{templateNoMatch},
        domainLimit = #{domainLimit},
        sign_template_limit = #{signTemplateLimit},
        aim_is_match = #{aimIsMatch},
        api_aim_is_match = #{apiAimIsMatch},
        currency = #{currency,jdbcType=VARCHAR},
        sp_scope = #{spScope,jdbcType=VARCHAR},
        sp_mms_otype = #{spMmsOtype,jdbcType=VARCHAR},
        sign_limit_rule = #{signLimitRule},
        aim_over_70_limit = #{aimOver70Limit},
        distinguish_fullwidth = #{distinguishFullwidth},
        allow_temp_strategy = #{allowTempStrategy},
        phone_safe_strategy = #{phoneSafeStrategy},
        disableWithNumberTime = #{disableWithNumberTime}
        where id=#{id}
    </update>

    <select id="listPageQuerySpPrice" resultType="cn.roadm.admin.dto.SpPriceListDO">
        select shp.id,
        shp.spid,
        shp.sp_price,
        DATE_FORMAT(shp.createtime, '%Y-%m-%d %H:%i:%s') as createTime,
        DATE_FORMAT(shp.effecttime, '%Y-%m-%d') as 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="spPriceListVO.spId != null and spPriceListVO.spId >= 0">
                and shp.spid = #{spPriceListVO.spId}
            </if>
            <if test="spPriceListVO.status != null and spPriceListVO.status >= 0">
                and shp.status = #{spPriceListVO.status}
            </if>
            <if test="spPriceListVO.otype != null and spPriceListVO.otype > 0">
                and shp.otype = #{spPriceListVO.otype}
            </if>
            <if test="spPriceListVO.otype != null and spPriceListVO.otype == 0">
                and (shp.otype = 0 or shp.otype is null)
            </if>
            <if test="spPriceListVO.spName != null and spPriceListVO.spName != ''">
                and sp.sp_name like concat('%', #{spPriceListVO.spName}, '%')
            </if>
            <if test="spPriceListVO.startTime != null and spPriceListVO.startTime != ''">
                and shp.createtime &gt;= #{spPriceListVO.startTime}
            </if>
            <if test="spPriceListVO.endTime != null and spPriceListVO.endTime != ''">
                and shp.createtime &lt; DATE_ADD(str_to_date(#{spPriceListVO.endTime}, '%Y-%m-%d'), INTERVAL 1 DAY)
            </if>
        </where>
    </select>

    <!-- spId;isOtype;spPrice;unicomPrice;telecomPrice;mobilePrice;province;provinceNetPrice; -->
    <select id="getSpPriceInfo" resultType="cn.roadm.admin.dto.SpPriceUpdateInfoDO">
        select spId,unicom_price,mobile_price,telecom_price from sp_price where spid=#{spId}
    </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>

    <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}, #{oldPrice,jdbcType=INTEGER} * 10000, #{spPrice,jdbcType=INTEGER} * 10000,
        date_format(now(), '%Y-%m-%d %H:%i:%s'), #{effectTime}, #{otype}, #{user}, #{status}, #{province})
    </insert>

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

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

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

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

    <update id="updateSpPrice">
        update sms_api_setting set saleprice=#{spPrice} where sp_id=#{spId}
    </update>

    <select id="exportListSpHistoryPrice" resultType="cn.roadm.admin.dto.SpPriceListDO">
        select shp.id,
        shp.spid,
        shp.sp_price,
        DATE_FORMAT(shp.createtime, '%Y-%m-%d %H:%i:%s') as createTime,
        DATE_FORMAT(shp.effecttime, '%Y-%m-%d') as 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="spName != null and spName != ''">
                and sp.sp_name like concat('%', #{spName}, '%')
            </if>
            <if test="startTime != null and startTime != ''">
                and shp.createtime &gt;= #{startTime}
            </if>
            <if test="endTime != null and endTime != ''">
                and shp.createtime &lt; DATE_ADD(str_to_date(#{endTime}, '%Y-%m-%d'), INTERVAL 1 DAY)
            </if>
        </where>
        order by createtime desc
    </select>

    <select id="getSpHistoryPriceInfoById" resultType="cn.roadm.admin.entity.SpPriceUpdateVO">
        select id,spid,sp_price,effecttime,otype,status,province from sp_history_price where id=#{id}
    </select>

    <update id="updatePriceHistory">
        update sp_history_price set
        effecttime=#{effectTime},sp_price=#{spPrice,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=#{username} where id=#{id}
    </update>

    <select id="getServiceTypeOptions" resultType="cn.roadm.admin.controller.vo.PageSelectOptionsStringVO">
        select serviceType as label, serviceType as value
        from sms_service_type
        where status = 1
    </select>

    <select id="getSpInfoProductId" resultType="java.lang.Integer">
        select product_id from sms_sp_info where id=#{spId}
    </select>

    <select id="getSpPriceById" resultType="cn.roadm.admin.dto.SmsSpPriceDO">
        select id,spid,unicom_price as ltPrice, mobile_price as ydPrice, telecom_price as dxPrice from sp_price where id=#{id}
    </select>

    <select id="getSpIsExist" resultType="java.lang.Integer">
        select count(1) from sms_sp_info where status = 1 and is_lock = 1 and id = #{spId}
    </select>

    <select id="getSpBasicMainUserInfo" resultType="cn.roadm.admin.dto.SpUserBasicDO">
        select sp.id as spId, sp.sp_name as spName, user.id as userId, user.username, user.password, user.web_password
        as webPassword
        from sms_sp_info sp left join sms_sp_user_info user on sp.id = user.sp_id
        where sp.status = 1 and sp.is_lock = 1 and sp.id = #{spId}
    </select>

    <select id="getSpLevelBatchUpdateList" resultType="cn.roadm.admin.dto.SpLevelBatchUpdateDTO">
        select id as spId, sp_name as spName, sp_type as spType, star_level as level, DATE_FORMAT(createtime, '%Y-%m-%d
        %H:%i:%s') as createTime from sms_sp_info
        <where>
            status = 1
            <if test="spId != null and spId != ''">
                and id = #{spId}
            </if>
            <if test="spName != null and spName != ''">
                and sp_name like concat('%', #{spName}, '%')
            </if>
            <if test="spType != null">
                and sp_type = #{spType}
            </if>
            <if test="startTime != null and startTime != ''">
                and createtime &gt;= #{startTime}
            </if>
            <if test="endTime != null and endTime != ''">
                and createtime &lt;= #{endTime}
            </if>
        </where>
        order by createtime desc
    </select>

    <update id="batchUpdateSpLevel">
        update sms_sp_info set star_level = #{updateLevel} where id in
        <foreach item="item" collection="spIdList" separator="," open="(" close=")" index="index">
            #{item}
        </foreach>
    </update>

    <select id="getSpInfoPriceConfigById" resultType="cn.roadm.admin.dto.SpPriceUpdateInfoDO">
        select a.province, a.provinceNetPrice, a.sp_saler as salePrice from sms_sp_info a left join sms_api_setting b on a.id = b.SP_ID where id = #{spId}
    </select>

    <select id="getSpExportList" resultType="cn.roadm.admin.dto.SpListExportDO">
        select sp.id as spId, sp.sp_name as spName, sp.status, sp.createtime as createTime, sp.update_time as updateTime,
        sp.is_lock as status, sp.sp_desc as remark, sp.is_api_billing as billingMode, sa.saleprice as price, sp.sp_type,
        ses.full_name as companyName, ssc.leftover_num as balance, sp.currency,
        sas.clientid as cmppId 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 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="params.clientid != null and params.clientid != ''">
                and sas.clientid = #{params.clientid}
            </if>
            <if test="params.spName != null and params.spName != ''">
                and sp.sp_name like CONCAT('%', #{params.spName}, '%')
            </if>
            <if test="params.spId != null and params.spId != 0">
                and sp.id = #{params.spId}
            </if>
            <if test="params.username != null and params.username != ''">
                and sp_user.username like CONCAT('%', #{params.username}, '%')
            </if>
            <if test="params.is_lock != null and params.is_lock != ''">
                and sp.is_lock = #{params.is_lock}
            </if>
            <if test="params.startTime != null and params.startTime != ''">
                and sp.createtime &gt;= #{params.startTime}
            </if>
            <if test="params.endTime != null and params.endTime != ''">
                and sp.createtime &lt;= DATE_ADD(#{params.endTime}, INTERVAL 1 DAY)
            </if>
            <if test="params.username != null and params.username != ''">
                and sp_user.username = #{params.username}
            </if>
            <if test="params.spType!=null and params.spType>0">
                and sp.sp_type =#{params.spType}
            </if>
            <if test="params.eid != null and params.eid != ''">
                and sp.eid  = #{params.eid}
            </if>
            <if test="params.priceConditionSymbol == 1 and params.priceConditionValue != null and params.priceConditionValue != ''">
                and sa.SALEPRICE &gt;= #{params.priceConditionValue}
            </if>
            <if test="params.priceConditionSymbol == 2 and params.priceConditionValue != null and params.priceConditionValue != ''">
                and sa.SALEPRICE &lt;= #{params.priceConditionValue}
            </if>
            <if test="params.startLevel != null and params.startLevel != ''">
                and sp.star_level = #{params.startLevel}
            </if>
            <if test="params.clientid != null">
                and sas.clientid = #{params.clientid}
            </if>
            <if test="endId != null">
                and sp.id &gt; #{endId}
            </if>
        </where>
        order by sp.id
    </select>

    <update id="bitchUpdateSpConfig">
        update sms_sp_info set ${column} = #{value} where id in
        <foreach collection="selectResult" item="spId" open="(" separator="," close=")">
            #{spId}
        </foreach>
    </update>

    <select id="getAllSpOtypePriceList" resultType="cn.roadm.admin.dto.SmsSpPriceDO">
        select spid as spId, unicom_price as ltPrice, mobile_price as ydPrice, telecom_price as dxPrice from sp_price
    </select>
</mapper>
