<?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.iamberry.wechat.service.mapper.IntegralProductConvertMapper">
    <resultMap  id="BaseResultMap" type="IntegralProductConvert" >
        <result    column="convert_id"    property="convertId" />
        <result    column="integral_product_id"    property="integralProductId" />
        <result    column="convert_dfbi"    property="convertDfbi" />
        <result    column="convert_is_mailing"    property="convertIsMailing" />
        <result    column="convert_is_pay"    property="convertIsPay" />
        <result    column="convert_price"    property="convertPrice" />
        <result    column="coupon_id"    property="couponId" />
        <result    column="convert_create_time"    property="convertCreateTime" />
        <result    column="convert_update_time"    property="convertUpdateTime" />
    </resultMap>
    <sql    id="Base_List" >
        t.convert_id,
        t.integral_product_id,
        t.convert_dfbi,
        t.convert_is_mailing,
        t.convert_is_pay,
        t.convert_price,
        t.coupon_id,
        t.convert_create_time,
        t.convert_update_time
    </sql>
    <select id="getIntegralProductConvertList" resultMap="BaseResultMap" parameterType="IntegralProductConvert" >
        select
        <include refid="Base_List" />
        from tb_iamberry_integral_product_convert t
        <where>
            <if test="convertId != null ">
                AND t.convert_id = #{convertId}
            </if >
            <if test="integralProductId != null ">
                AND t.integral_product_id = #{integralProductId}
            </if >
            <if test="convertDfbi != null ">
                AND t.convert_dfbi = #{convertDfbi}
            </if >
            <if test="convertIsMailing != null ">
                AND t.convert_is_mailing = #{convertIsMailing}
            </if >
            <if test="convertIsPay != null ">
                AND t.convert_is_pay = #{convertIsPay}
            </if >
            <if test="convertPrice != null ">
                AND t.convert_price = #{convertPrice}
            </if >
            <if test="couponId != null ">
                AND t.coupon_id = #{couponId}
            </if >
        </where>
    </select>

    <select id="getIntegralProductConvertByProductId" resultMap="BaseResultMap" parameterType="Integer" >
        select
        <include refid="Base_List" />
        from tb_iamberry_integral_product_convert t
        where t.integral_product_id = #{integralProductId}
    </select>

    <insert id="save" parameterType="IntegralProductConvert" >
        insert into
        tb_iamberry_integral_product_convert
        (
        convert_id,
        integral_product_id,
        convert_dfbi,
        convert_is_mailing,
        convert_is_pay,
        convert_price,
        coupon_id
        )
        values
        (
        #{convertId},
        #{integralProductId},
        #{convertDfbi},
        #{convertIsMailing},
        #{convertIsPay},
        #{convertPrice},
        #{couponId}
        )
    </insert>
    <update id="update" parameterType="IntegralProductConvert" >
        update
        tb_iamberry_integral_product_convert
        <set >
            <if test="convertId != null ">
                convert_id = #{convertId},
            </if >
            <if test="integralProductId != null ">
                integral_product_id = #{integralProductId},
            </if >
            <if test="convertDfbi != null ">
                convert_dfbi = #{convertDfbi},
            </if >
            <if test="convertIsMailing != null ">
                convert_is_mailing = #{convertIsMailing},
            </if >
            <if test="convertIsPay != null ">
                convert_is_pay = #{convertIsPay},
            </if >
            <if test="convertPrice != null ">
                convert_price = #{convertPrice},
            </if >
            <if test="couponId != null ">
                coupon_id = #{couponId},
            </if >
        </set >
        where convert_id= #{convertId}
    </update>
    <delete id="delete" parameterType="Integer" >
        delete
        tb_iamberry_integral_product_convert
        where convert_id=#{convertId}
    </delete>
</mapper>