<?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.frequency.rechargerecord.mapper.RechargeRecordMapper">
    
    <resultMap type="com.ruoyi.frequency.rechargerecord.entity.RechargeRecord" id="RechargeRecordResult">
        <result property="id"    column="id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="rechargeCoinId"    column="recharge_coin_id"    />
        <result property="payPrice"    column="pay_price"    />
        <result property="coin"    column="coin"    />
        <result property="payOrderNo"    column="pay_order_no"    />
        <result property="aliBusinessId"    column="ali_business_id"    />
        <result property="status"    column="status"    />
        <result property="customerId"    column="customer_id"    />
        <result property="payType"    column="pay_type"    />
    </resultMap>

    <sql id="selectRechargeRecordVo">
        select id, create_by, create_time, update_by, update_time, del_flag, recharge_coin_id, pay_price, coin, pay_order_no, ali_business_id, status, customer_id, pay_type from t_recharge_record
    </sql>

    <select id="selectRechargeRecordList" parameterType="com.ruoyi.frequency.rechargerecord.entity.RechargeRecord" resultMap="RechargeRecordResult">
        <include refid="selectRechargeRecordVo"/>
        <where>  
            <if test="rechargeCoinId != null  and rechargeCoinId != ''"> and recharge_coin_id = #{rechargeCoinId}</if>
            <if test="payPrice != null "> and pay_price = #{payPrice}</if>
            <if test="coin != null "> and coin = #{coin}</if>
            <if test="payOrderNo != null  and payOrderNo != ''"> and pay_order_no = #{payOrderNo}</if>
            <if test="aliBusinessId != null  and aliBusinessId != ''"> and ali_business_id = #{aliBusinessId}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="customerId != null "> and customer_id = #{customerId}</if>
            <if test="payType != null "> and pay_type = #{payType}</if>
        </where>
    </select>
    
    <select id="selectRechargeRecordById" parameterType="Long" resultMap="RechargeRecordResult">
        <include refid="selectRechargeRecordVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertRechargeRecord" parameterType="com.ruoyi.frequency.rechargerecord.entity.RechargeRecord">
        insert into t_recharge_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="rechargeCoinId != null">recharge_coin_id,</if>
            <if test="payPrice != null">pay_price,</if>
            <if test="coin != null">coin,</if>
            <if test="payOrderNo != null">pay_order_no,</if>
            <if test="aliBusinessId != null">ali_business_id,</if>
            <if test="status != null">status,</if>
            <if test="customerId != null">customer_id,</if>
            <if test="payType != null">pay_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="rechargeCoinId != null">#{rechargeCoinId},</if>
            <if test="payPrice != null">#{payPrice},</if>
            <if test="coin != null">#{coin},</if>
            <if test="payOrderNo != null">#{payOrderNo},</if>
            <if test="aliBusinessId != null">#{aliBusinessId},</if>
            <if test="status != null">#{status},</if>
            <if test="customerId != null">#{customerId},</if>
            <if test="payType != null">#{payType},</if>
         </trim>
    </insert>

    <update id="updateRechargeRecord" parameterType="com.ruoyi.frequency.rechargerecord.entity.RechargeRecord">
        update t_recharge_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="rechargeCoinId != null">recharge_coin_id = #{rechargeCoinId},</if>
            <if test="payPrice != null">pay_price = #{payPrice},</if>
            <if test="coin != null">coin = #{coin},</if>
            <if test="payOrderNo != null">pay_order_no = #{payOrderNo},</if>
            <if test="aliBusinessId != null">ali_business_id = #{aliBusinessId},</if>
            <if test="status != null">status = #{status},</if>
            <if test="customerId != null">customer_id = #{customerId},</if>
            <if test="payType != null">pay_type = #{payType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRechargeRecordById" parameterType="Long">
        delete from t_recharge_record where id = #{id}
    </delete>

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