<?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.fs.store.mapper.FsUserRechargeMapper">
    
    <resultMap type="FsUserRecharge" id="FsUserRechargeResult">
        <result property="id"    column="id"    />
        <result property="uid"    column="uid"    />
        <result property="nickname"    column="nickname"    />
        <result property="orderId"    column="order_id"    />
        <result property="price"    column="price"    />
        <result property="givePrice"    column="give_price"    />
        <result property="rechargeType"    column="recharge_type"    />
        <result property="paid"    column="paid"    />
        <result property="payTime"    column="pay_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="refundPrice"    column="refund_price"    />
        <result property="isDel"    column="is_del"    />
    </resultMap>

    <sql id="selectFsUserRechargeVo">
        select id, uid, nickname, order_id, price, give_price, recharge_type, paid, pay_time, create_time, update_time, refund_price, is_del from fs_user_recharge
    </sql>

    <select id="selectFsUserRechargeList" parameterType="FsUserRecharge" resultMap="FsUserRechargeResult">
        <include refid="selectFsUserRechargeVo"/>
        <where>  
            <if test="uid != null "> and uid = #{uid}</if>
            <if test="nickname != null  and nickname != ''"> and nickname like concat('%', #{nickname}, '%')</if>
            <if test="orderId != null  and orderId != ''"> and order_id = #{orderId}</if>
            <if test="price != null "> and price = #{price}</if>
            <if test="givePrice != null "> and give_price = #{givePrice}</if>
            <if test="rechargeType != null  and rechargeType != ''"> and recharge_type = #{rechargeType}</if>
            <if test="paid != null "> and paid = #{paid}</if>
            <if test="payTime != null "> and pay_time = #{payTime}</if>
            <if test="refundPrice != null "> and refund_price = #{refundPrice}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectFsUserRechargeById" parameterType="Long" resultMap="FsUserRechargeResult">
        <include refid="selectFsUserRechargeVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFsUserRecharge" parameterType="FsUserRecharge" useGeneratedKeys="true" keyProperty="id">
        insert into fs_user_recharge
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="uid != null">uid,</if>
            <if test="nickname != null">nickname,</if>
            <if test="orderId != null">order_id,</if>
            <if test="price != null">price,</if>
            <if test="givePrice != null">give_price,</if>
            <if test="rechargeType != null">recharge_type,</if>
            <if test="paid != null">paid,</if>
            <if test="payTime != null">pay_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="refundPrice != null">refund_price,</if>
            <if test="isDel != null">is_del,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="uid != null">#{uid},</if>
            <if test="nickname != null">#{nickname},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="price != null">#{price},</if>
            <if test="givePrice != null">#{givePrice},</if>
            <if test="rechargeType != null">#{rechargeType},</if>
            <if test="paid != null">#{paid},</if>
            <if test="payTime != null">#{payTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="refundPrice != null">#{refundPrice},</if>
            <if test="isDel != null">#{isDel},</if>
         </trim>
    </insert>

    <update id="updateFsUserRecharge" parameterType="FsUserRecharge">
        update fs_user_recharge
        <trim prefix="SET" suffixOverrides=",">
            <if test="uid != null">uid = #{uid},</if>
            <if test="nickname != null">nickname = #{nickname},</if>
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="price != null">price = #{price},</if>
            <if test="givePrice != null">give_price = #{givePrice},</if>
            <if test="rechargeType != null">recharge_type = #{rechargeType},</if>
            <if test="paid != null">paid = #{paid},</if>
            <if test="payTime != null">pay_time = #{payTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="refundPrice != null">refund_price = #{refundPrice},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsUserRechargeById" parameterType="Long">
        delete from fs_user_recharge where id = #{id}
    </delete>

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