<?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.PaymentInfo.mapper.PaymentInfoMapper">
    <resultMap type="PaymentInfo" id="PaymentInfoResult">
        <result property="payId"    column="payId"    />
        <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"    />
        <result property="orderId"    column="orderId"    />
        <result property="orderNo"    column="orderNo"    />
        <result property="payTime"    column="payTime"    />
        <result property="sellerId"    column="sellerId"    />
        <result property="description"    column="description"    />
        <result property="outTradeNo"    column="outTradeNo"    />
        <result property="notifyUrl"    column="notifyUrl"    />
        <result property="amountTotal"    column="amountTotal"    />
        <result property="payerOpenid"    column="payerOpenid"    />
        <result property="prepayId"    column="prepayId"    />
        <result property="notifyId"    column="notifyId"    />
        <result property="notifyTime"    column="notifyTime"    />
        <result property="eventType"    column="eventType"    />
        <result property="transactionId"    column="transactionId"    />
        <result property="tradeType"    column="tradeType"    />
        <result property="tradeState"    column="tradeState"    />
        <result property="tradeStateDesc"    column="tradeStateDesc"    />
        <result property="bankType"    column="bankType"    />
        <result property="successTime"    column="successTime"    />
    </resultMap>

    <sql id="selectPaymentInfo">
        select payId, delFlag, createUser, createTime, updateUser, updateTime, orderId, orderNo, payTime, sellerId, description, outTradeNo, notifyUrl, amountTotal, payerOpenid, prepayId, notifyId, notifyTime, eventType, transactionId, tradeType, tradeState, tradeStateDesc, bankType, successTime from t_payment_info
    </sql>

    <sql id="selectPaymentInfoExt">
        select
            ${tableAlias}.payId,
            ${tableAlias}.delFlag,
            ${tableAlias}.createUser,
            ${tableAlias}.createTime,
            ${tableAlias}.updateUser,
            ${tableAlias}.updateTime,
            ${tableAlias}.orderId,
            ${tableAlias}.orderNo,
            ${tableAlias}.payTime,
            ${tableAlias}.sellerId,
            ${tableAlias}.description,
            ${tableAlias}.outTradeNo,
            ${tableAlias}.notifyUrl,
            ${tableAlias}.amountTotal,
            ${tableAlias}.payerOpenid,
            ${tableAlias}.prepayId,
            ${tableAlias}.notifyId,
            ${tableAlias}.notifyTime,
            ${tableAlias}.eventType,
            ${tableAlias}.transactionId,
            ${tableAlias}.tradeType,
            ${tableAlias}.tradeState,
            ${tableAlias}.tradeStateDesc,
            ${tableAlias}.bankType,
            ${tableAlias}.successTime
        from t_payment_info ${tableAlias}
    </sql>

    <select id="selectPaymentInfoList" parameterType="PaymentInfo" resultMap="PaymentInfoResult">
        <include refid="selectPaymentInfo"/>
        <where>  
            <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>
            <if test="orderId != null "> and orderId = #{orderId}</if>
            <if test="orderNo != null  and orderNo != ''"> and orderNo = #{orderNo}</if>
            <if test="payTime != null "> and payTime = #{payTime}</if>
            <if test="sellerId != null "> and sellerId = #{sellerId}</if>
            <if test="description != null  and description != ''"> and description = #{description}</if>
            <if test="outTradeNo != null  and outTradeNo != ''"> and outTradeNo = #{outTradeNo}</if>
            <if test="notifyUrl != null  and notifyUrl != ''"> and notifyUrl = #{notifyUrl}</if>
            <if test="amountTotal != null "> and amountTotal = #{amountTotal}</if>
            <if test="payerOpenid != null  and payerOpenid != ''"> and payerOpenid = #{payerOpenid}</if>
            <if test="prepayId != null  and prepayId != ''"> and prepayId = #{prepayId}</if>
            <if test="notifyId != null  and notifyId != ''"> and notifyId = #{notifyId}</if>
            <if test="notifyTime != null "> and notifyTime = #{notifyTime}</if>
            <if test="eventType != null  and eventType != ''"> and eventType = #{eventType}</if>
            <if test="transactionId != null  and transactionId != ''"> and transactionId = #{transactionId}</if>
            <if test="tradeType != null  and tradeType != ''"> and tradeType = #{tradeType}</if>
            <if test="tradeState != null  and tradeState != ''"> and tradeState = #{tradeState}</if>
            <if test="tradeStateDesc != null  and tradeStateDesc != ''"> and tradeStateDesc = #{tradeStateDesc}</if>
            <if test="bankType != null  and bankType != ''"> and bankType = #{bankType}</if>
            <if test="successTime != null "> and successTime = #{successTime}</if>
        </where>
    </select>
    
    <select id="selectPaymentInfoByPayId" parameterType="Long" resultMap="PaymentInfoResult">
        <include refid="selectPaymentInfo"/>
        where payId = #{payId}
    </select>
        
    <insert id="insertPaymentInfo" parameterType="PaymentInfo" useGeneratedKeys="true" keyProperty="payId">
        insert into t_payment_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <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>
            <if test="orderId != null">orderId,</if>
            <if test="orderNo != null">orderNo,</if>
            <if test="payTime != null">payTime,</if>
            <if test="sellerId != null">sellerId,</if>
            <if test="description != null">description,</if>
            <if test="outTradeNo != null">outTradeNo,</if>
            <if test="notifyUrl != null">notifyUrl,</if>
            <if test="amountTotal != null">amountTotal,</if>
            <if test="payerOpenid != null">payerOpenid,</if>
            <if test="prepayId != null">prepayId,</if>
            <if test="notifyId != null">notifyId,</if>
            <if test="notifyTime != null">notifyTime,</if>
            <if test="eventType != null">eventType,</if>
            <if test="transactionId != null">transactionId,</if>
            <if test="tradeType != null">tradeType,</if>
            <if test="tradeState != null">tradeState,</if>
            <if test="tradeStateDesc != null">tradeStateDesc,</if>
            <if test="bankType != null">bankType,</if>
            <if test="successTime != null">successTime,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <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>
            <if test="orderId != null">#{orderId},</if>
            <if test="orderNo != null">#{orderNo},</if>
            <if test="payTime != null">#{payTime},</if>
            <if test="sellerId != null">#{sellerId},</if>
            <if test="description != null">#{description},</if>
            <if test="outTradeNo != null">#{outTradeNo},</if>
            <if test="notifyUrl != null">#{notifyUrl},</if>
            <if test="amountTotal != null">#{amountTotal},</if>
            <if test="payerOpenid != null">#{payerOpenid},</if>
            <if test="prepayId != null">#{prepayId},</if>
            <if test="notifyId != null">#{notifyId},</if>
            <if test="notifyTime != null">#{notifyTime},</if>
            <if test="eventType != null">#{eventType},</if>
            <if test="transactionId != null">#{transactionId},</if>
            <if test="tradeType != null">#{tradeType},</if>
            <if test="tradeState != null">#{tradeState},</if>
            <if test="tradeStateDesc != null">#{tradeStateDesc},</if>
            <if test="bankType != null">#{bankType},</if>
            <if test="successTime != null">#{successTime},</if>
         </trim>
    </insert>

    <insert id="batchInsertPaymentInfo">
        insert into t_payment_info( delFlag, createUser, createTime, updateUser, updateTime, orderId, orderNo, payTime, sellerId, description, outTradeNo, notifyUrl, amountTotal, payerOpenid, prepayId, notifyId, notifyTime, eventType, transactionId, tradeType, tradeState, tradeStateDesc, bankType, successTime) values
        <foreach item="item" index="index" collection="list" separator=",">
            ( #{item.delFlag}, #{item.createUser}, #{item.createTime}, #{item.updateUser}, #{item.updateTime}, #{item.orderId}, #{item.orderNo}, #{item.payTime}, #{item.sellerId}, #{item.description}, #{item.outTradeNo}, #{item.notifyUrl}, #{item.amountTotal}, #{item.payerOpenid}, #{item.prepayId}, #{item.notifyId}, #{item.notifyTime}, #{item.eventType}, #{item.transactionId}, #{item.tradeType}, #{item.tradeState}, #{item.tradeStateDesc}, #{item.bankType}, #{item.successTime})
        </foreach>
    </insert>

    <update id="updatePaymentInfo" parameterType="PaymentInfo">
        update t_payment_info
        <trim prefix="SET" suffixOverrides=",">
            <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>
            <if test="orderId != null">orderId = #{orderId},</if>
            <if test="orderNo != null">orderNo = #{orderNo},</if>
            <if test="payTime != null">payTime = #{payTime},</if>
            <if test="sellerId != null">sellerId = #{sellerId},</if>
            <if test="description != null">description = #{description},</if>
            <if test="outTradeNo != null">outTradeNo = #{outTradeNo},</if>
            <if test="notifyUrl != null">notifyUrl = #{notifyUrl},</if>
            <if test="amountTotal != null">amountTotal = #{amountTotal},</if>
            <if test="payerOpenid != null">payerOpenid = #{payerOpenid},</if>
            <if test="prepayId != null">prepayId = #{prepayId},</if>
            <if test="notifyId != null">notifyId = #{notifyId},</if>
            <if test="notifyTime != null">notifyTime = #{notifyTime},</if>
            <if test="eventType != null">eventType = #{eventType},</if>
            <if test="transactionId != null">transactionId = #{transactionId},</if>
            <if test="tradeType != null">tradeType = #{tradeType},</if>
            <if test="tradeState != null">tradeState = #{tradeState},</if>
            <if test="tradeStateDesc != null">tradeStateDesc = #{tradeStateDesc},</if>
            <if test="bankType != null">bankType = #{bankType},</if>
            <if test="successTime != null">successTime = #{successTime},</if>
        </trim>
        where payId = #{payId}
    </update>

    <delete id="deletePaymentInfoByPayId" parameterType="Long">
        delete from t_payment_info where payId = #{payId}
    </delete>

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

    <update id="logicDeletePaymentInfoByPayId" parameterType="Long">
        update t_payment_info
            set delFlag = '1'
        where payId = #{payId}
    </update>

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

    <update id="logicDeletePaymentInfoByCondition" parameterType="PaymentInfo">
        update t_payment_info
        set delFlag = '1'
        <where>
            <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>
            <if test="orderId != null "> and orderId = #{orderId}</if>
            <if test="orderNo != null  and orderNo != ''"> and orderNo = #{orderNo}</if>
            <if test="payTime != null "> and payTime = #{payTime}</if>
            <if test="sellerId != null "> and sellerId = #{sellerId}</if>
            <if test="description != null  and description != ''"> and description = #{description}</if>
            <if test="outTradeNo != null  and outTradeNo != ''"> and outTradeNo = #{outTradeNo}</if>
            <if test="notifyUrl != null  and notifyUrl != ''"> and notifyUrl = #{notifyUrl}</if>
            <if test="amountTotal != null "> and amountTotal = #{amountTotal}</if>
            <if test="payerOpenid != null  and payerOpenid != ''"> and payerOpenid = #{payerOpenid}</if>
            <if test="prepayId != null  and prepayId != ''"> and prepayId = #{prepayId}</if>
            <if test="notifyId != null  and notifyId != ''"> and notifyId = #{notifyId}</if>
            <if test="notifyTime != null "> and notifyTime = #{notifyTime}</if>
            <if test="eventType != null  and eventType != ''"> and eventType = #{eventType}</if>
            <if test="transactionId != null  and transactionId != ''"> and transactionId = #{transactionId}</if>
            <if test="tradeType != null  and tradeType != ''"> and tradeType = #{tradeType}</if>
            <if test="tradeState != null  and tradeState != ''"> and tradeState = #{tradeState}</if>
            <if test="tradeStateDesc != null  and tradeStateDesc != ''"> and tradeStateDesc = #{tradeStateDesc}</if>
            <if test="bankType != null  and bankType != ''"> and bankType = #{bankType}</if>
            <if test="successTime != null "> and successTime = #{successTime}</if>
        </where>
    </update>
</mapper>