<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.game.business.mapper.AppChargeChannelMapper">
    
    <resultMap type="com.game.business.domain.AppChargeChannel" id="AppChargeChannelResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="cKey"    column="c_key"    />
        <result property="type"    column="type"    />
        <result property="channelKey"    column="channel_key"    />
        <result property="rate"    column="rate"    />
        <result property="withdrawRate"    column="withdraw_rate"    />
        <result property="isShow"    column="is_show"    />
        <result property="logoUrl"    column="logo_url"    />
        <result property="company"    column="company"    />
        <result property="appId"    column="app_id"    />
        <result property="appSecret"    column="app_secret"    />
        <result property="thirdUrl"    column="third_url"    />
        <result property="status"    column="status"    />
        <result property="certPath"    column="cert_path"    />
        <result property="aliPublicCert"    column="ali_public_cert"    />
        <result property="aliApplyCert"    column="ali_apply_cert"    />
        <result property="aliCaCert"    column="ali_ca_cert"    />
        <result property="merchantNo"    column="merchant_no"    />
        <result property="apiSecret"    column="api_secret"    />
        <result property="orderno"    column="orderno"    />
    </resultMap>

    <sql id="selectAppChargeChannelVo">
        select id, name,c_key,type, channel_key,channel_no, rate,withdraw_rate,is_show, logo_url, company, app_id, app_secret, third_url, status, cert_path, ali_public_cert, ali_apply_cert, ali_ca_cert, merchant_no, api_secret, orderno from app_charge_channel
    </sql>

    <select id="selectAppChargeChannelList" parameterType="com.game.business.domain.AppChargeChannel" resultMap="AppChargeChannelResult">
        <include refid="selectAppChargeChannelVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="channelKey != null  and channelKey != ''"> and channel_key = #{channelKey}</if>
            <if test="cKey != null  and cKey != ''"> and c_key = #{cKey}</if>
            <if test="type != null"> and type = #{type}</if>
            <if test="channelNo != null  and channelNo != ''"> and channel_no = #{channelNo}</if>
            <if test="rate != null "> and rate = #{rate}</if>
            <if test="withdrawRate != null "> and withdraw_rate = #{withdrawRate}</if>
            <if test="isShow != null "> and is_show = #{isShow}</if>
            <if test="logoUrl != null  and logoUrl != ''"> and logo_url = #{logoUrl}</if>
            <if test="company != null  and company != ''"> and company = #{company}</if>
            <if test="appId != null  and appId != ''"> and app_id = #{appId}</if>
            <if test="appSecret != null  and appSecret != ''"> and app_secret = #{appSecret}</if>
            <if test="thirdUrl != null  and thirdUrl != ''"> and third_url = #{thirdUrl}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="certPath != null  and certPath != ''"> and cert_path = #{certPath}</if>
            <if test="aliPublicCert != null  and aliPublicCert != ''"> and ali_public_cert = #{aliPublicCert}</if>
            <if test="aliApplyCert != null  and aliApplyCert != ''"> and ali_apply_cert = #{aliApplyCert}</if>
            <if test="aliCaCert != null  and aliCaCert != ''"> and ali_ca_cert = #{aliCaCert}</if>
            <if test="merchantNo != null  and merchantNo != ''"> and merchant_no = #{merchantNo}</if>
            <if test="apiSecret != null  and apiSecret != ''"> and api_secret = #{apiSecret}</if>
            <if test="orderno != null "> and orderno = #{orderno}</if>
        </where>
        order by orderno asc
    </select>
    
    <select id="selectAppChargeChannelById" parameterType="Long" resultMap="AppChargeChannelResult">
        <include refid="selectAppChargeChannelVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAppChargeChannel" parameterType="com.game.business.domain.AppChargeChannel">
        insert into app_charge_channel
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null">name,</if>
            <if test="channelKey != null">channel_key,</if>
            <if test="cKey != null and cKey != ''">c_key,</if>
            <if test="type != null">type,</if>
            <if test="channelNo != null">channel_no,</if>
            <if test="rate != null">rate,</if>
            <if test="withdrawRate != null">withdraw_rate,</if>
            <if test="isShow != null">is_show,</if>
            <if test="logoUrl != null">logo_url,</if>
            <if test="company != null">company,</if>
            <if test="appId != null">app_id,</if>
            <if test="appSecret != null">app_secret,</if>
            <if test="thirdUrl != null">third_url,</if>
            <if test="status != null">status,</if>
            <if test="certPath != null">cert_path,</if>
            <if test="aliPublicCert != null">ali_public_cert,</if>
            <if test="aliApplyCert != null">ali_apply_cert,</if>
            <if test="aliCaCert != null">ali_ca_cert,</if>
            <if test="merchantNo != null">merchant_no,</if>
            <if test="apiSecret != null">api_secret,</if>
            <if test="orderno != null">orderno,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="cKey != null">#{cKey},</if>
            <if test="type != null">#{type},</if>
            <if test="channelKey != null">#{channelKey},</if>
            <if test="channelNo != null">#{channelNo},</if>
            <if test="rate != null">#{rate},</if>
            <if test="withdrawRate != null">#{withdrawRate},</if>
            <if test="isShow != null">#{isShow},</if>
            <if test="logoUrl != null">#{logoUrl},</if>
            <if test="company != null">#{company},</if>
            <if test="appId != null">#{appId},</if>
            <if test="appSecret != null">#{appSecret},</if>
            <if test="thirdUrl != null">#{thirdUrl},</if>
            <if test="status != null">#{status},</if>
            <if test="certPath != null">#{certPath},</if>
            <if test="aliPublicCert != null">#{aliPublicCert},</if>
            <if test="aliApplyCert != null">#{aliApplyCert},</if>
            <if test="aliCaCert != null">#{aliCaCert},</if>
            <if test="merchantNo != null">#{merchantNo},</if>
            <if test="apiSecret != null">#{apiSecret},</if>
            <if test="orderno != null">#{orderno},</if>
         </trim>
    </insert>

    <update id="updateAppChargeChannel" parameterType="com.game.business.domain.AppChargeChannel">
        update app_charge_channel
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="cKey != null">c_key = #{cKey},</if>
            <if test="type != null">type = #{type},</if>
            <if test="channelKey != null">channel_key = #{channelKey},</if>
            <if test="channelNo != null">channel_no = #{channelNo},</if>
            <if test="rate != null">rate = #{rate},</if>
            <if test="withdrawRate != null">withdraw_rate = #{withdrawRate},</if>
            <if test="isShow != null">is_show = #{isShow},</if>
            <if test="logoUrl != null">logo_url = #{logoUrl},</if>
            <if test="company != null">company = #{company},</if>
            <if test="appId != null">app_id = #{appId},</if>
            <if test="appSecret != null">app_secret = #{appSecret},</if>
            <if test="thirdUrl != null">third_url = #{thirdUrl},</if>
            <if test="status != null">status = #{status},</if>
            <if test="certPath != null">cert_path = #{certPath},</if>
            <if test="aliPublicCert != null">ali_public_cert = #{aliPublicCert},</if>
            <if test="aliApplyCert != null">ali_apply_cert = #{aliApplyCert},</if>
            <if test="aliCaCert != null">ali_ca_cert = #{aliCaCert},</if>
            <if test="merchantNo != null">merchant_no = #{merchantNo},</if>
            <if test="apiSecret != null">api_secret = #{apiSecret},</if>
            <if test="orderno != null">orderno = #{orderno},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppChargeChannelById" parameterType="Long">
        delete from app_charge_channel where id = #{id}
    </delete>

    <delete id="deleteAppChargeChannelByIds" parameterType="String">
        delete from app_charge_channel where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>