<?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.framework.recovery.mapper.WxRechargeMapper">
    
    <resultMap type="WxRecharge" id="WxRechargeResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="userName"    column="user_name"    />
        <result property="price"    column="price"    />
        <result property="points"    column="points"    />
        <result property="payTime"    column="pay_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="couponsId"    column="coupons_id"    />
    </resultMap>

    <sql id="selectWxRechargeVo">
        select id, user_id, user_name, price, points, pay_time, is_del, coupons_id from wx_recharge
    </sql>

    <select id="selectWxRechargeList" parameterType="WxRecharge" resultMap="WxRechargeResult">
        <include refid="selectWxRechargeVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
            <if test="price != null "> and price = #{price}</if>
            <if test="points != null "> and points = #{points}</if>
            <if test="payTime != null "> and pay_time = #{payTime}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
            <if test="couponsId != null  and couponsId != ''"> and coupons_id = #{couponsId}</if>
        </where>
    </select>
    
    <select id="selectWxRechargeById" parameterType="Long" resultMap="WxRechargeResult">
        <include refid="selectWxRechargeVo"/>
        where id = #{id}
    </select>

    <insert id="insertWxRecharge" parameterType="WxRecharge">
        insert into wx_recharge
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="userId != null">user_id,</if>
            <if test="userName != null">user_name,</if>
            <if test="price != null">price,</if>
            <if test="points != null">points,</if>
            <if test="payTime != null">pay_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="couponsId != null">coupons_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="userId != null">#{userId},</if>
            <if test="userName != null">#{userName},</if>
            <if test="price != null">#{price},</if>
            <if test="points != null">#{points},</if>
            <if test="payTime != null">#{payTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="couponsId != null">#{couponsId},</if>
         </trim>
    </insert>

    <update id="updateWxRecharge" parameterType="WxRecharge">
        update wx_recharge
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="price != null">price = #{price},</if>
            <if test="points != null">points = #{points},</if>
            <if test="payTime != null">pay_time = #{payTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="couponsId != null">coupons_id = #{couponsId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWxRechargeById" parameterType="Long">
        delete from wx_recharge where id = #{id}
    </delete>

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