<?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.ruoyi.voluntary.mapper.BBusiPaymentOrdersMapper">
    
    <resultMap type="BBusiPaymentOrders" id="BBusiPaymentOrdersResult">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="outTradeNo"    column="outTradeNo"    />
        <result property="qrcodeId"    column="qrcodeId"    />
        <result property="type"    column="type"    />
        <result property="cardId"    column="cardId"    />
        <result property="cardNo"    column="cardNo"    />
        <result property="year"    column="year"    />
        <result property="phonenumber"    column="phonenumber"    />
        <result property="transactionId"    column="transaction_id"    />
        <result property="customerCode"    column="customerCode"    />
        <result property="outTime"    column="outTime"    />
        <result property="price"    column="price"    />
        <result property="num"    column="num"    />
        <result property="fee"    column="fee"    />
        <result property="totalFee"    column="totalFee"    />
        <result property="payFee"    column="payFee"    />
        <result property="createTime"    column="createTime"    />
        <result property="creator"    column="creator"    />
        <result property="body"    column="body"    />
        <result property="detail"    column="detail"    />
        <result property="attach"    column="attach"    />
        <result property="prepayId"    column="prepayId"    />
        <result property="payer"    column="payer"    />
        <result property="payTime"    column="payTime"    />
        <result property="feedBack"    column="feedBack"    />
        <result property="syncTime"    column="syncTime"    />
        <result property="status"    column="status"    />
    </resultMap>

    <sql id="selectBBusiPaymentOrdersVo">
        select id, code, outTradeNo, qrcodeId, type, cardId, cardNo, year, phonenumber, transaction_id, customerCode, outTime, price, num, fee, totalFee, payFee, createTime, creator, body, detail, attach, prepayId, payer, payTime, feedBack, syncTime, status from b_busi_payment_orders
    </sql>

    <select id="selectBBusiPaymentOrdersList" parameterType="BBusiPaymentOrders" resultMap="BBusiPaymentOrdersResult">
        <include refid="selectBBusiPaymentOrdersVo"/>
        <where>  
            <if test="code != null  and code != ''"> and code = #{code}</if>
            <if test="outTradeNo != null  and outTradeNo != ''"> and outTradeNo = #{outTradeNo}</if>
            <if test="qrcodeId != null  and qrcodeId != ''"> and qrcodeId = #{qrcodeId}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="cardId != null "> and cardId = #{cardId}</if>
            <if test="cardNo != null  and cardNo != ''"> and cardNo = #{cardNo}</if>
            <if test="year != null  and year != ''"> and year = #{year}</if>
            <if test="phonenumber != null  and phonenumber != ''"> and phonenumber = #{phonenumber}</if>
            <if test="transactionId != null  and transactionId != ''"> and transaction_id = #{transactionId}</if>
            <if test="customerCode != null  and customerCode != ''"> and customerCode = #{customerCode}</if>
            <if test="outTime != null "> and outTime = #{outTime}</if>
            <if test="price != null "> and price = #{price}</if>
            <if test="num != null "> and num = #{num}</if>
            <if test="fee != null "> and fee = #{fee}</if>
            <if test="totalFee != null "> and totalFee = #{totalFee}</if>
            <if test="payFee != null "> and payFee = #{payFee}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="creator != null  and creator != ''"> and creator = #{creator}</if>
            <if test="body != null  and body != ''"> and body = #{body}</if>
            <if test="detail != null  and detail != ''"> and detail = #{detail}</if>
            <if test="attach != null  and attach != ''"> and attach = #{attach}</if>
            <if test="prepayId != null  and prepayId != ''"> and prepayId = #{prepayId}</if>
            <if test="payer != null  and payer != ''"> and payer = #{payer}</if>
            <if test="payTime != null "> and payTime = #{payTime}</if>
            <if test="feedBack != null  and feedBack != ''"> and feedBack = #{feedBack}</if>
            <if test="syncTime != null "> and syncTime = #{syncTime}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
        order by id desc
    </select>
    
    <select id="selectBBusiPaymentOrdersById" parameterType="Long" resultMap="BBusiPaymentOrdersResult">
        <include refid="selectBBusiPaymentOrdersVo"/>
        where id = #{id}
    </select>

    <select id="selectBBusiPaymentOrdersByCardNo" parameterType="String" resultMap="BBusiPaymentOrdersResult">
        <include refid="selectBBusiPaymentOrdersVo"/>
        where cardNo = #{cardNo}
    </select>
        
    <insert id="insertBBusiPaymentOrders" parameterType="BBusiPaymentOrders" useGeneratedKeys="true" keyProperty="id">
        insert into b_busi_payment_orders
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="code != null and code != ''">code,</if>
            <if test="outTradeNo != null and outTradeNo != ''">outTradeNo,</if>
            <if test="qrcodeId != null">qrcodeId,</if>
            <if test="type != null">type,</if>
            <if test="cardId != null">cardId,</if>
            <if test="cardNo != null">cardNo,</if>
            <if test="year != null and year != ''">year,</if>
            <if test="phonenumber != null">phonenumber,</if>
            <if test="transactionId != null">transaction_id,</if>
            <if test="customerCode != null">customerCode,</if>
            <if test="outTime != null">outTime,</if>
            <if test="price != null">price,</if>
            <if test="num != null">num,</if>
            <if test="fee != null">fee,</if>
            <if test="totalFee != null">totalFee,</if>
            <if test="payFee != null">payFee,</if>
            <if test="createTime != null">createTime,</if>
            <if test="creator != null and creator != ''">creator,</if>
            <if test="body != null">body,</if>
            <if test="detail != null">detail,</if>
            <if test="attach != null">attach,</if>
            <if test="prepayId != null">prepayId,</if>
            <if test="payer != null">payer,</if>
            <if test="payTime != null">payTime,</if>
            <if test="feedBack != null">feedBack,</if>
            <if test="syncTime != null">syncTime,</if>
            <if test="status != null">status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="code != null and code != ''">#{code},</if>
            <if test="outTradeNo != null and outTradeNo != ''">#{outTradeNo},</if>
            <if test="qrcodeId != null">#{qrcodeId},</if>
            <if test="type != null">#{type},</if>
            <if test="cardId != null">#{cardId},</if>
            <if test="cardNo != null">#{cardNo},</if>
            <if test="year != null and year != ''">#{year},</if>
            <if test="phonenumber != null">#{phonenumber},</if>
            <if test="transactionId != null">#{transactionId},</if>
            <if test="customerCode != null">#{customerCode},</if>
            <if test="outTime != null">#{outTime},</if>
            <if test="price != null">#{price},</if>
            <if test="num != null">#{num},</if>
            <if test="fee != null">#{fee},</if>
            <if test="totalFee != null">#{totalFee},</if>
            <if test="payFee != null">#{payFee},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="creator != null and creator != ''">#{creator},</if>
            <if test="body != null">#{body},</if>
            <if test="detail != null">#{detail},</if>
            <if test="attach != null">#{attach},</if>
            <if test="prepayId != null">#{prepayId},</if>
            <if test="payer != null">#{payer},</if>
            <if test="payTime != null">#{payTime},</if>
            <if test="feedBack != null">#{feedBack},</if>
            <if test="syncTime != null">#{syncTime},</if>
            <if test="status != null">#{status},</if>
         </trim>
    </insert>

    <update id="updateBBusiPaymentOrders" parameterType="BBusiPaymentOrders">
        update b_busi_payment_orders
        <trim prefix="SET" suffixOverrides=",">
            <if test="code != null and code != ''">code = #{code},</if>
            <if test="outTradeNo != null and outTradeNo != ''">outTradeNo = #{outTradeNo},</if>
            <if test="qrcodeId != null">qrcodeId = #{qrcodeId},</if>
            <if test="type != null">type = #{type},</if>
            <if test="cardId != null">cardId = #{cardId},</if>
            <if test="cardNo != null">cardNo = #{cardNo},</if>
            <if test="year != null and year != ''">year = #{year},</if>
            <if test="phonenumber != null">phonenumber = #{phonenumber},</if>
            <if test="transactionId != null">transaction_id = #{transactionId},</if>
            <if test="customerCode != null">customerCode = #{customerCode},</if>
            <if test="outTime != null">outTime = #{outTime},</if>
            <if test="price != null">price = #{price},</if>
            <if test="num != null">num = #{num},</if>
            <if test="fee != null">fee = #{fee},</if>
            <if test="totalFee != null">totalFee = #{totalFee},</if>
            <if test="payFee != null">payFee = #{payFee},</if>
            <if test="createTime != null">createTime = #{createTime},</if>
            <if test="creator != null and creator != ''">creator = #{creator},</if>
            <if test="body != null">body = #{body},</if>
            <if test="detail != null">detail = #{detail},</if>
            <if test="attach != null">attach = #{attach},</if>
            <if test="prepayId != null">prepayId = #{prepayId},</if>
            <if test="payer != null">payer = #{payer},</if>
            <if test="payTime != null">payTime = #{payTime},</if>
            <if test="feedBack != null">feedBack = #{feedBack},</if>
            <if test="syncTime != null">syncTime = #{syncTime},</if>
            <if test="status != null">status = #{status},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBBusiPaymentOrdersById" parameterType="Long">
        delete from b_busi_payment_orders where id = #{id}
    </delete>

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