<?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.xingxi.business.MerchantWxpay.mapper.MerchantWxpayMapper">
    <resultMap type="MerchantWxpay" id="MerchantWxpayResult">
        <result property="mercWxpayId"    column="mercWxpayId"    />
        <result property="wxPayId"    column="wxPayId"    />
        <result property="wxMchId"    column="wxMchId"    />
        <result property="wxSecret"    column="wxSecret"    />
        <result property="wxApiV3key"    column="wxApiV3key"    />
        <result property="wxCert"    column="wxCert"    />
        <result property="wxCertFile"    column="wxCertFile"    />
        <result property="wxKeyFile"    column="wxKeyFile"    />
        <result property="delFlag"    column="delFlag"    />
        <result property="createUser"    column="createUser"    />
        <result property="createTime"    column="createTime"    />
        <result property="updateUser"    column="updateUser"    />
        <result property="updateTime"    column="updateTime"    />
    </resultMap>

    <sql id="selectMerchantWxpay">
        select mercWxpayId, wxPayId, wxMchId, wxSecret, wxApiV3key, wxCert, wxCertFile, wxKeyFile, delFlag, createUser, createTime, updateUser, updateTime from t_merchant_wxpay
    </sql>

    <sql id="selectMerchantWxpayExt">
        select
            ${tableAlias}.mercWxpayId,
            ${tableAlias}.wxPayId,
            ${tableAlias}.wxMchId,
            ${tableAlias}.wxSecret,
            ${tableAlias}.wxApiV3key,
            ${tableAlias}.wxCert,
            ${tableAlias}.wxCertFile,
            ${tableAlias}.wxKeyFile,
            ${tableAlias}.delFlag,
            ${tableAlias}.createUser,
            ${tableAlias}.createTime,
            ${tableAlias}.updateUser,
            ${tableAlias}.updateTime
        from t_merchant_wxpay ${tableAlias}
    </sql>

    <select id="selectMerchantWxpayList" parameterType="MerchantWxpay" resultMap="MerchantWxpayResult">
        <include refid="selectMerchantWxpay"/>
        <where>  
            <if test="wxPayId != null  and wxPayId != ''"> and wxPayId = #{wxPayId}</if>
            <if test="wxMchId != null  and wxMchId != ''"> and wxMchId = #{wxMchId}</if>
            <if test="wxSecret != null  and wxSecret != ''"> and wxSecret = #{wxSecret}</if>
            <if test="wxApiV3key != null  and wxApiV3key != ''"> and wxApiV3key = #{wxApiV3key}</if>
            <if test="wxCert != null  and wxCert != ''"> and wxCert = #{wxCert}</if>
            <if test="wxCertFile != null  and wxCertFile != ''"> and wxCertFile = #{wxCertFile}</if>
            <if test="wxKeyFile != null  and wxKeyFile != ''"> and wxKeyFile = #{wxKeyFile}</if>
            <if test="delFlag != null  and delFlag != ''"> and delFlag = #{delFlag}</if>
            <if test="createUser != null  and createUser != ''"> and createUser = #{createUser}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="updateUser != null  and updateUser != ''"> and updateUser = #{updateUser}</if>
            <if test="updateTime != null "> and updateTime = #{updateTime}</if>
        </where>
    </select>
    
    <select id="selectMerchantWxpayByMercWxpayId" parameterType="Long" resultMap="MerchantWxpayResult">
        <include refid="selectMerchantWxpay"/>
        where mercWxpayId = #{mercWxpayId}
    </select>
        
    <insert id="insertMerchantWxpay" parameterType="MerchantWxpay" useGeneratedKeys="true" keyProperty="mercWxpayId">
        insert into t_merchant_wxpay
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="wxPayId != null">wxPayId,</if>
            <if test="wxMchId != null">wxMchId,</if>
            <if test="wxSecret != null">wxSecret,</if>
            <if test="wxApiV3key != null">wxApiV3key,</if>
            <if test="wxCert != null">wxCert,</if>
            <if test="wxCertFile != null">wxCertFile,</if>
            <if test="wxKeyFile != null">wxKeyFile,</if>
            <if test="delFlag != null">delFlag,</if>
            <if test="createUser != null">createUser,</if>
            <if test="createTime != null">createTime,</if>
            <if test="updateUser != null">updateUser,</if>
            <if test="updateTime != null">updateTime,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="wxPayId != null">#{wxPayId},</if>
            <if test="wxMchId != null">#{wxMchId},</if>
            <if test="wxSecret != null">#{wxSecret},</if>
            <if test="wxApiV3key != null">#{wxApiV3key},</if>
            <if test="wxCert != null">#{wxCert},</if>
            <if test="wxCertFile != null">#{wxCertFile},</if>
            <if test="wxKeyFile != null">#{wxKeyFile},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createUser != null">#{createUser},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateUser != null">#{updateUser},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <insert id="batchInsertMerchantWxpay">
        insert into t_merchant_wxpay( wxPayId, wxMchId, wxSecret, wxApiV3key, wxCert, wxCertFile, wxKeyFile, delFlag, createUser, createTime, updateUser, updateTime) values
        <foreach item="item" index="index" collection="list" separator=",">
            ( #{item.wxPayId}, #{item.wxMchId}, #{item.wxSecret}, #{item.wxApiV3key}, #{item.wxCert}, #{item.wxCertFile}, #{item.wxKeyFile}, #{item.delFlag}, #{item.createUser}, #{item.createTime}, #{item.updateUser}, #{item.updateTime})
        </foreach>
    </insert>

    <update id="updateMerchantWxpay" parameterType="MerchantWxpay">
        update t_merchant_wxpay
        <trim prefix="SET" suffixOverrides=",">
            <if test="wxPayId != null">wxPayId = #{wxPayId},</if>
            <if test="wxMchId != null">wxMchId = #{wxMchId},</if>
            <if test="wxSecret != null">wxSecret = #{wxSecret},</if>
            <if test="wxApiV3key != null">wxApiV3key = #{wxApiV3key},</if>
            <if test="wxCert != null">wxCert = #{wxCert},</if>
            <if test="wxCertFile != null">wxCertFile = #{wxCertFile},</if>
            <if test="wxKeyFile != null">wxKeyFile = #{wxKeyFile},</if>
            <if test="delFlag != null">delFlag = #{delFlag},</if>
            <if test="createUser != null">createUser = #{createUser},</if>
            <if test="createTime != null">createTime = #{createTime},</if>
            <if test="updateUser != null">updateUser = #{updateUser},</if>
            <if test="updateTime != null">updateTime = #{updateTime},</if>
        </trim>
        where mercWxpayId = #{mercWxpayId}
    </update>

    <delete id="deleteMerchantWxpayByMercWxpayId" parameterType="Long">
        delete from t_merchant_wxpay where mercWxpayId = #{mercWxpayId}
    </delete>

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

    <update id="logicDeleteMerchantWxpayByMercWxpayId" parameterType="Long">
        update t_merchant_wxpay
            set delFlag = '1'
        where mercWxpayId = #{mercWxpayId}
    </update>

    <update id="logicDeleteMerchantWxpayByMercWxpayIds" parameterType="String">
        update t_merchant_wxpay
        set delFlag = '1'
        where mercWxpayId in
        <foreach item="mercWxpayId" collection="array" open="(" separator="," close=")">
            #{mercWxpayId}
        </foreach>
    </update>

    <update id="logicDeleteMerchantWxpayByCondition" parameterType="MerchantWxpay">
        update t_merchant_wxpay
        set delFlag = '1'
        <where>
            <if test="wxPayId != null  and wxPayId != ''"> and wxPayId = #{wxPayId}</if>
            <if test="wxMchId != null  and wxMchId != ''"> and wxMchId = #{wxMchId}</if>
            <if test="wxSecret != null  and wxSecret != ''"> and wxSecret = #{wxSecret}</if>
            <if test="wxApiV3key != null  and wxApiV3key != ''"> and wxApiV3key = #{wxApiV3key}</if>
            <if test="wxCert != null  and wxCert != ''"> and wxCert = #{wxCert}</if>
            <if test="wxCertFile != null  and wxCertFile != ''"> and wxCertFile = #{wxCertFile}</if>
            <if test="wxKeyFile != null  and wxKeyFile != ''"> and wxKeyFile = #{wxKeyFile}</if>
            <if test="delFlag != null  and delFlag != ''"> and delFlag = #{delFlag}</if>
            <if test="createUser != null  and createUser != ''"> and createUser = #{createUser}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="updateUser != null  and updateUser != ''"> and updateUser = #{updateUser}</if>
            <if test="updateTime != null "> and updateTime = #{updateTime}</if>
        </where>
    </update>
</mapper>