<?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.IntegralOrderMapper">
    <resultMap  id="BaseResultMap" type="IntegralOrder" >
        <result    column="integral_order_id"    property="integralOrderId" />
        <result    column="integral_order_open_id"    property="integralOrderOpenId" />
        <result    column="integral_order_yet_amount"    property="integralOrderYetAmount" />
        <result    column="integral_order_dfbi"    property="integralOrderDfbi" />
        <result    column="integral_order_amount"    property="integralOrderAmount" />
        <result    column="integral_order_status"    property="integralOrderStatus" />
        <result    column="integral_order_admin_remark"    property="integralOrderAdminRemark" />
        <result    column="integral_order_user_remark"    property="integralOrderUserRemark" />
        <result    column="integral_order_transaction_id"    property="integralOrderTransactionId" />
        <result    column="integral_order_transaction_date"    property="integralOrderTransactionDate" />
        <result    column="integral_order_create_date"    property="integralOrderCreateDate" />
    </resultMap>
    <sql    id="Base_List" >
        t.integral_order_id,
        t.integral_order_open_id,
        t.integral_order_yet_amount,
        t.integral_order_dfbi,
        t.integral_order_amount,
        t.integral_order_status,
        t.integral_order_admin_remark,
        t.integral_order_user_remark,
        t.integral_order_transaction_id,
        t.integral_order_transaction_date,
        t.integral_order_create_date
    </sql>

    <select id="getIntegralOrderList" resultMap="BaseResultMap" parameterType="IntegralOrder" >
        select
        <include refid="Base_List" />
        from tb_iamberry_integral_order t
        <where>
            <if test="integralOrderId != null and integralOrderId != ''">
                AND t.integral_order_id = #{integralOrderId}
            </if >
            <if test="integralOrderOpenId != null and integralOrderOpenId != ''">
                AND t.integral_order_open_id = #{integralOrderOpenId}
            </if >
            <if test="integralOrderStatus != null ">
                AND t.integral_order_status = #{integralOrderStatus}
            </if >
            <if test="integralOrderAdminRemark != null and integralOrderAdminRemark != ''">
                AND t.integral_order_admin_remark = #{integralOrderAdminRemark}
            </if >
        </where>
        ORDER BY t.integral_order_id DESC
    </select>

    <select id="getIntegralOrderById" resultMap="BaseResultMap" parameterType="String" >
        select
        <include refid="Base_List" />
        from tb_iamberry_integral_order t
        where t.integral_order_id= #{integralOrderId}
    </select>
    <insert id="save" parameterType="IntegralOrder" >
        insert into
        tb_iamberry_integral_order
        (
        integral_order_id,
        integral_order_open_id,
        integral_order_yet_amount,
        integral_order_dfbi,
        integral_order_amount,
        integral_order_status,
        integral_order_admin_remark,
        integral_order_user_remark,
        integral_order_transaction_id,
        integral_order_transaction_date
        )
        values
        (
        #{integralOrderId},
        #{integralOrderOpenId},
        #{integralOrderYetAmount},
        #{integralOrderDfbi},
        #{integralOrderAmount},
        #{integralOrderStatus},
        #{integralOrderAdminRemark},
        #{integralOrderUserRemark},
        #{integralOrderTransactionId},
        #{integralOrderTransactionDate}
        )
    </insert>
    <update id="update" parameterType="IntegralOrder" >
        update
        tb_iamberry_integral_order
        <set >
            <if test="integralOrderId != null and integralOrderId != ''">
                integral_order_id = #{integralOrderId},
            </if >
            <if test="integralOrderOpenId != null and integralOrderOpenId != ''">
                integral_order_open_id = #{integralOrderOpenId},
            </if >
            <if test="integralOrderYetAmount != null ">
                integral_order_yet_amount = #{integralOrderYetAmount},
            </if >
            <if test="integralOrderDfbi != null ">
                integral_order_dfbi = #{integralOrderDfbi},
            </if >
            <if test="integralOrderAmount != null ">
                integral_order_amount = #{integralOrderAmount},
            </if >
            <if test="integralOrderStatus != null ">
                integral_order_status = #{integralOrderStatus},
            </if >
            <if test="integralOrderAdminRemark != null and integralOrderAdminRemark != ''">
                integral_order_admin_remark = #{integralOrderAdminRemark},
            </if >
            <if test="integralOrderUserRemark != null and integralOrderUserRemark != ''">
                integral_order_user_remark = #{integralOrderUserRemark},
            </if >
            <if test="integralOrderTransactionId != null and integralOrderTransactionId != ''">
                integral_order_transaction_id = #{integralOrderTransactionId},
            </if >
            <if test="integralOrderTransactionDate != null and integralOrderTransactionDate != ''">
                integral_order_transaction_date = #{integralOrderTransactionDate},
            </if >
        </set >
        where integral_order_id= #{integralOrderId}
    </update>
    <delete id="delete" parameterType="String" >
        delete
        tb_iamberry_integral_order
        where integral_order_id=#{integralOrderId}
    </delete>
</mapper>