<?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.IntegralOrderAddressMapper">
    <resultMap  id="BaseResultMap" type="IntegralOrderAddress" >
        <result    column="order_address_id"    property="orderAddressId" />
        <result    column="integral_order_id"    property="integralOrderId" />
        <result    column="order_address_post_num"    property="orderAddressPostNum" />
        <result    column="order_address_post_firm"    property="orderAddressPostFirm" />
        <result    column="order_address_status"    property="orderAddressStatus" />
        <result    column="order_address_send_date"    property="orderAddressSendDate" />
        <result    column="order_address_address_info"    property="orderAddressAddressInfo" />
        <result    column="order_address_address_postnum"    property="orderAddressAddressPostnum" />
        <result    column="order_address_address_tel"    property="orderAddressAddressTel" />
        <result    column="order_address_address_name"    property="orderAddressAddressName" />
    </resultMap>
    <sql    id="Base_List" >
        t.order_address_id,
        t.integral_order_id,
        t.order_address_post_num,
        t.order_address_post_firm,
        t.order_address_status,
        t.order_address_send_date,
        t.order_address_address_info,
        t.order_address_address_postnum,
        t.order_address_address_tel,
        t.order_address_address_name
    </sql>
    <select id="getIntegralOrderAddressList" resultMap="BaseResultMap" parameterType="IntegralOrderAddress" >
        select
        <include refid="Base_List" />
        from tb_iamberry_integral_order_address t
        <where>
            <if test="orderAddressId != null ">
                AND t.order_address_id = #{orderAddressId}
            </if >
            <if test="integralOrderId != null and integralOrderId != ''">
                AND t.integral_order_id = #{integralOrderId}
            </if >
            <if test="orderAddressPostNum != null and orderAddressPostNum != ''">
                AND t.order_address_post_num = #{orderAddressPostNum}
            </if >
            <if test="orderAddressPostFirm != null and orderAddressPostFirm != ''">
                AND t.order_address_post_firm = #{orderAddressPostFirm}
            </if >
            <if test="orderAddressStatus != null ">
                AND t.order_address_status = #{orderAddressStatus}
            </if >
            <if test="orderAddressAddressTel != null and orderAddressAddressTel != ''">
                AND t.order_address_address_tel  like  CONCAT ('%',#{orderAddressAddressTel},'%')
            </if >
            <if test="orderAddressAddressName != null and orderAddressAddressName != ''">
                AND t.order_address_address_name  like  CONCAT ('%',#{orderAddressAddressName},'%')
            </if >
        </where>
    </select>
    <select id="getIntegralOrderAddressById" resultMap="BaseResultMap" parameterType="Integer" >
        select
        <include refid="Base_List" />
        from tb_iamberry_integral_order_address t
        where t.order_address_id= #{orderAddressId}
    </select>
    <insert id="save" parameterType="IntegralOrderAddress" >
        insert into
        tb_iamberry_integral_order_address
        (
        order_address_id,
        integral_order_id,
        order_address_post_num,
        order_address_post_firm,
        order_address_status,
        order_address_send_date,
        order_address_address_info,
        order_address_address_postnum,
        order_address_address_tel,
        order_address_address_name
        )
        values
        (
        #{orderAddressId},
        #{integralOrderId},
        #{orderAddressPostNum},
        #{orderAddressPostFirm},
        #{orderAddressStatus},
        #{orderAddressSendDate},
        #{orderAddressAddressInfo},
        #{orderAddressAddressPostnum},
        #{orderAddressAddressTel},
        #{orderAddressAddressName}
        )
    </insert>
    <update id="update" parameterType="IntegralOrderAddress" >
        update
        tb_iamberry_integral_order_address
        <set >
            <if test="orderAddressId != null ">
                order_address_id = #{orderAddressId},
            </if >
            <if test="integralOrderId != null and integralOrderId != ''">
                integral_order_id = #{integralOrderId},
            </if >
            <if test="orderAddressPostNum != null and orderAddressPostNum != ''">
                order_address_post_num = #{orderAddressPostNum},
            </if >
            <if test="orderAddressPostFirm != null and orderAddressPostFirm != ''">
                order_address_post_firm = #{orderAddressPostFirm},
            </if >
            <if test="orderAddressStatus != null ">
                order_address_status = #{orderAddressStatus},
            </if >
            <if test="orderAddressSendDate != null and orderAddressSendDate != ''">
                order_address_send_date = #{orderAddressSendDate},
            </if >
            <if test="orderAddressAddressInfo != null and orderAddressAddressInfo != ''">
                order_address_address_info = #{orderAddressAddressInfo},
            </if >
            <if test="orderAddressAddressPostnum != null and orderAddressAddressPostnum != ''">
                order_address_address_postnum = #{orderAddressAddressPostnum},
            </if >
            <if test="orderAddressAddressTel != null and orderAddressAddressTel != ''">
                order_address_address_tel = #{orderAddressAddressTel},
            </if >
            <if test="orderAddressAddressName != null and orderAddressAddressName != ''">
                order_address_address_name = #{orderAddressAddressName}
            </if >
        </set >
        where order_address_id= #{orderAddressId}
    </update>
    <delete id="delete" parameterType="Integer" >
        delete
        tb_iamberry_integral_order_address
        where order_address_id=#{orderAddressId}
    </delete>
</mapper>