<?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.pine.admin.modules.business.dao.OrderAttrDao">

    <!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.pine.admin.modules.business.entity.OrderAttr" id="entityMap">
                    <result property="id" column="id"/>
                    <result property="orderId" column="order_id"/>
                    <result property="receiptName" column="receipt_name"/>
                    <result property="receiptAddress" column="receipt_address"/>
                    <result property="receiptDetailAddress" column="receipt_detail_address"/>
                    <result property="receiptMobile" column="receipt_mobile"/>
                    <result property="receiptPhone" column="receipt_phone"/>
                    <result property="receiptZipCode" column="receipt_zip_code"/>
                    <result property="invoiceType" column="invoice_type"/>
                    <result property="invoiceTitle" column="invoice_title"/>
                    <result property="invoiceContent" column="invoice_content"/>
                    <result property="invoiceTaxid" column="invoice_taxid"/>
                    <result property="remark" column="remark"/>
                    <result property="giftInfos" column="gift_infos"/>
                    <result property="donationMessage" column="donation_message"/>
                    <result property="invoiceCompanyName" column="invoice_company_name"/>
                    <result property="invoiceRegisterAddress" column="invoice_register_address"/>
                    <result property="invoiceRegisterMobile" column="invoice_register_mobile"/>
                    <result property="invoiceOpenBank" column="invoice_open_bank"/>
                    <result property="invoiceBankAccount" column="invoice_bank_account"/>
                    <result property="invoiceTitleType" column="invoice_title_type"/>
                    <result property="deliveryTime" column="delivery_time"/>
                    <result property="address" column="address"/>
                    <result property="detailAddress" column="detail_address"/>
                    <result property="pickUpAddress" column="pick_up_address"/>
                    <result property="deliveryType" column="delivery_type"/>
                    <result property="houseNumber" column="house_number"/>
            </resultMap>

    <sql id="Base_Column_List">
                 id,
                     order_id,
                     receipt_name,
                     receipt_address,
                     receipt_detail_address,
                     receipt_mobile,
                     receipt_phone,
                     receipt_zip_code,
                     invoice_type,
                     invoice_title,
                     invoice_content,
                     invoice_taxid,
                     remark,
                     gift_infos,
                     donation_message,
                     invoice_company_name,
                     invoice_register_address,
                     invoice_register_mobile,
                     invoice_open_bank,
                     invoice_bank_account,
                     invoice_title_type,
                     delivery_time,
                     address,
                     detail_address,
                     pick_up_address,
                     delivery_type,
                    house_number         </sql>
    <!-- 根据Id查询-->
    <select id="selectByPrimaryKey" resultMap="entityMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        from ls_order_attr
        where id = #{id,jdbcType=INTEGER}
    </select>

    <select id="queryByOrderId" parameterType="java.lang.Long" resultMap="entityMap">
        select   <include refid="Base_Column_List"/> from ls_order_attr where order_id=#{orderId}
    </select>

    <!-- 根据Id删除-->
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
		delete from ls_order_attr
		where id = #{id,jdbcType=INTEGER}
	</delete>

    <!-- 插入数据-->
    <insert id="insertSelective" parameterType="com.pine.admin.modules.business.entity.OrderAttr"
            useGeneratedKeys="true" keyProperty="id">
        insert into  ls_order_attr
        <trim prefix="(" suffix=")" suffixOverrides=",">
                            <if test="id != null">  id,</if>
                            <if test="orderId != null">  order_id,</if>
                            <if test="receiptName != null">  receipt_name,</if>
                            <if test="receiptAddress != null">  receipt_address,</if>
                            <if test="receiptDetailAddress != null">  receipt_detail_address,</if>
                            <if test="receiptMobile != null">  receipt_mobile,</if>
                            <if test="receiptPhone != null">  receipt_phone,</if>
                            <if test="receiptZipCode != null">  receipt_zip_code,</if>
                            <if test="invoiceType != null">  invoice_type,</if>
                            <if test="invoiceTitle != null">  invoice_title,</if>
                            <if test="invoiceContent != null">  invoice_content,</if>
                            <if test="invoiceTaxid != null">  invoice_taxid,</if>
                            <if test="remark != null">  remark,</if>
                            <if test="giftInfos != null">  gift_infos,</if>
                            <if test="donationMessage != null">  donation_message,</if>
                            <if test="invoiceCompanyName != null">  invoice_company_name,</if>
                            <if test="invoiceRegisterAddress != null">  invoice_register_address,</if>
                            <if test="invoiceRegisterMobile != null">  invoice_register_mobile,</if>
                            <if test="invoiceOpenBank != null">  invoice_open_bank,</if>
                            <if test="invoiceBankAccount != null">  invoice_bank_account,</if>
                            <if test="invoiceTitleType != null">  invoice_title_type,</if>
                            <if test="deliveryTime != null">  delivery_time,</if>
                            <if test="address != null">  address,</if>
                            <if test="detailAddress != null">  detail_address,</if>
                            <if test="pickUpAddress != null">  pick_up_address,</if>
                            <if test="deliveryType != null">  delivery_type,</if>
                            <if test="houseNumber != null">  house_number,</if>
                    </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                            <if test="id != null">#{id},</if>
                            <if test="orderId != null">#{orderId},</if>
                            <if test="receiptName != null">#{receiptName},</if>
                            <if test="receiptAddress != null">#{receiptAddress},</if>
                            <if test="receiptDetailAddress != null">#{receiptDetailAddress},</if>
                            <if test="receiptMobile != null">#{receiptMobile},</if>
                            <if test="receiptPhone != null">#{receiptPhone},</if>
                            <if test="receiptZipCode != null">#{receiptZipCode},</if>
                            <if test="invoiceType != null">#{invoiceType},</if>
                            <if test="invoiceTitle != null">#{invoiceTitle},</if>
                            <if test="invoiceContent != null">#{invoiceContent},</if>
                            <if test="invoiceTaxid != null">#{invoiceTaxid},</if>
                            <if test="remark != null">#{remark},</if>
                            <if test="giftInfos != null">#{giftInfos},</if>
                            <if test="donationMessage != null">#{donationMessage},</if>
                            <if test="invoiceCompanyName != null">#{invoiceCompanyName},</if>
                            <if test="invoiceRegisterAddress != null">#{invoiceRegisterAddress},</if>
                            <if test="invoiceRegisterMobile != null">#{invoiceRegisterMobile},</if>
                            <if test="invoiceOpenBank != null">#{invoiceOpenBank},</if>
                            <if test="invoiceBankAccount != null">#{invoiceBankAccount},</if>
                            <if test="invoiceTitleType != null">#{invoiceTitleType},</if>
                            <if test="deliveryTime != null">#{deliveryTime},</if>
                            <if test="address != null">#{address},</if>
                            <if test="detailAddress != null">#{detailAddress},</if>
                            <if test="pickUpAddress != null">#{pickUpAddress},</if>
                            <if test="deliveryType != null">#{deliveryType},</if>
                            <if test="houseNumber != null">#{houseNumber},</if>
                    </trim>
    </insert>

    <!-- 更新数据-->
    <update id="updateByPrimaryKeySelective" parameterType="com.pine.admin.modules.business.entity.OrderAttr">
        update ls_order_attr
        <set>
                            <if test="id != null">id = #{id},</if>
                            <if test="orderId != null">order_id = #{orderId},</if>
                            <if test="receiptName != null">receipt_name = #{receiptName},</if>
                            <if test="receiptAddress != null">receipt_address = #{receiptAddress},</if>
                            <if test="receiptDetailAddress != null">receipt_detail_address = #{receiptDetailAddress},</if>
                            <if test="receiptMobile != null">receipt_mobile = #{receiptMobile},</if>
                            <if test="receiptPhone != null">receipt_phone = #{receiptPhone},</if>
                            <if test="receiptZipCode != null">receipt_zip_code = #{receiptZipCode},</if>
                            <if test="invoiceType != null">invoice_type = #{invoiceType},</if>
                            <if test="invoiceTitle != null">invoice_title = #{invoiceTitle},</if>
                            <if test="invoiceContent != null">invoice_content = #{invoiceContent},</if>
                            <if test="invoiceTaxid != null">invoice_taxid = #{invoiceTaxid},</if>
                            <if test="remark != null">remark = #{remark},</if>
                            <if test="giftInfos != null">gift_infos = #{giftInfos},</if>
                            <if test="donationMessage != null">donation_message = #{donationMessage},</if>
                            <if test="invoiceCompanyName != null">invoice_company_name = #{invoiceCompanyName},</if>
                            <if test="invoiceRegisterAddress != null">invoice_register_address = #{invoiceRegisterAddress},</if>
                            <if test="invoiceRegisterMobile != null">invoice_register_mobile = #{invoiceRegisterMobile},</if>
                            <if test="invoiceOpenBank != null">invoice_open_bank = #{invoiceOpenBank},</if>
                            <if test="invoiceBankAccount != null">invoice_bank_account = #{invoiceBankAccount},</if>
                            <if test="invoiceTitleType != null">invoice_title_type = #{invoiceTitleType},</if>
                            <if test="deliveryTime != null">delivery_time = #{deliveryTime},</if>
                            <if test="address != null">address = #{address},</if>
                            <if test="detailAddress != null">detail_address = #{detailAddress},</if>
                            <if test="pickUpAddress != null">pick_up_address = #{pickUpAddress},</if>
                            <if test="deliveryType != null">delivery_type = #{deliveryType},</if>
                            <if test="houseNumber != null">house_number = #{houseNumber},</if>
                    </set>
        where id = #{id,jdbcType=INTEGER}
    </update>

    <!-- 分页查询-->
    <select id="queryByPage" parameterType="java.util.Map"
            resultMap="entityMap">
        select
        <include refid="Base_Column_List"/>
        from ls_order_attr
        <where>
            and del_flag = 'N'
                            <if test="record.id != null and !&quot;&quot;.equals(record.id)">
                    and  id = #{record.id}
                </if>
                            <if test="record.orderId != null and !&quot;&quot;.equals(record.orderId)">
                    and  order_id = #{record.orderId}
                </if>
                            <if test="record.receiptName != null and !&quot;&quot;.equals(record.receiptName)">
                    and  receipt_name = #{record.receiptName}
                </if>
                            <if test="record.receiptAddress != null and !&quot;&quot;.equals(record.receiptAddress)">
                    and  receipt_address = #{record.receiptAddress}
                </if>
                            <if test="record.receiptDetailAddress != null and !&quot;&quot;.equals(record.receiptDetailAddress)">
                    and  receipt_detail_address = #{record.receiptDetailAddress}
                </if>
                            <if test="record.receiptMobile != null and !&quot;&quot;.equals(record.receiptMobile)">
                    and  receipt_mobile = #{record.receiptMobile}
                </if>
                            <if test="record.receiptPhone != null and !&quot;&quot;.equals(record.receiptPhone)">
                    and  receipt_phone = #{record.receiptPhone}
                </if>
                            <if test="record.receiptZipCode != null and !&quot;&quot;.equals(record.receiptZipCode)">
                    and  receipt_zip_code = #{record.receiptZipCode}
                </if>
                            <if test="record.invoiceType != null and !&quot;&quot;.equals(record.invoiceType)">
                    and  invoice_type = #{record.invoiceType}
                </if>
                            <if test="record.invoiceTitle != null and !&quot;&quot;.equals(record.invoiceTitle)">
                    and  invoice_title = #{record.invoiceTitle}
                </if>
                            <if test="record.invoiceContent != null and !&quot;&quot;.equals(record.invoiceContent)">
                    and  invoice_content = #{record.invoiceContent}
                </if>
                            <if test="record.invoiceTaxid != null and !&quot;&quot;.equals(record.invoiceTaxid)">
                    and  invoice_taxid = #{record.invoiceTaxid}
                </if>
                            <if test="record.remark != null and !&quot;&quot;.equals(record.remark)">
                    and  remark = #{record.remark}
                </if>
                            <if test="record.giftInfos != null and !&quot;&quot;.equals(record.giftInfos)">
                    and  gift_infos = #{record.giftInfos}
                </if>
                            <if test="record.donationMessage != null and !&quot;&quot;.equals(record.donationMessage)">
                    and  donation_message = #{record.donationMessage}
                </if>
                            <if test="record.invoiceCompanyName != null and !&quot;&quot;.equals(record.invoiceCompanyName)">
                    and  invoice_company_name = #{record.invoiceCompanyName}
                </if>
                            <if test="record.invoiceRegisterAddress != null and !&quot;&quot;.equals(record.invoiceRegisterAddress)">
                    and  invoice_register_address = #{record.invoiceRegisterAddress}
                </if>
                            <if test="record.invoiceRegisterMobile != null and !&quot;&quot;.equals(record.invoiceRegisterMobile)">
                    and  invoice_register_mobile = #{record.invoiceRegisterMobile}
                </if>
                            <if test="record.invoiceOpenBank != null and !&quot;&quot;.equals(record.invoiceOpenBank)">
                    and  invoice_open_bank = #{record.invoiceOpenBank}
                </if>
                            <if test="record.invoiceBankAccount != null and !&quot;&quot;.equals(record.invoiceBankAccount)">
                    and  invoice_bank_account = #{record.invoiceBankAccount}
                </if>
                            <if test="record.invoiceTitleType != null and !&quot;&quot;.equals(record.invoiceTitleType)">
                    and  invoice_title_type = #{record.invoiceTitleType}
                </if>
                            <if test="record.deliveryTime != null and !&quot;&quot;.equals(record.deliveryTime)">
                    and  delivery_time = #{record.deliveryTime}
                </if>
                            <if test="record.address != null and !&quot;&quot;.equals(record.address)">
                    and  address = #{record.address}
                </if>
                            <if test="record.detailAddress != null and !&quot;&quot;.equals(record.detailAddress)">
                    and  detail_address = #{record.detailAddress}
                </if>
                            <if test="record.pickUpAddress != null and !&quot;&quot;.equals(record.pickUpAddress)">
                    and  pick_up_address = #{record.pickUpAddress}
                </if>
                            <if test="record.deliveryType != null and !&quot;&quot;.equals(record.deliveryType)">
                    and  delivery_type = #{record.deliveryType}
                </if>
                            <if test="record.houseNumber != null and !&quot;&quot;.equals(record.houseNumber)">
                    and  house_number = #{record.houseNumber}
                </if>
                    </where>
        order by id desc
    </select>

    <!-- 全部查询 -->
    <select id="queryAll" parameterType="java.util.Map"
            resultMap="entityMap">
        select
        <include refid="Base_Column_List"/>
        from ls_order_attr
        <where>
            and del_flag = 'N'
                            <if test="id != null and !&quot;&quot;.equals(id)">
                    and  id = #{id}
                </if>
                            <if test="orderId != null and !&quot;&quot;.equals(orderId)">
                    and  order_id = #{orderId}
                </if>
                            <if test="receiptName != null and !&quot;&quot;.equals(receiptName)">
                    and  receipt_name = #{receiptName}
                </if>
                            <if test="receiptAddress != null and !&quot;&quot;.equals(receiptAddress)">
                    and  receipt_address = #{receiptAddress}
                </if>
                            <if test="receiptDetailAddress != null and !&quot;&quot;.equals(receiptDetailAddress)">
                    and  receipt_detail_address = #{receiptDetailAddress}
                </if>
                            <if test="receiptMobile != null and !&quot;&quot;.equals(receiptMobile)">
                    and  receipt_mobile = #{receiptMobile}
                </if>
                            <if test="receiptPhone != null and !&quot;&quot;.equals(receiptPhone)">
                    and  receipt_phone = #{receiptPhone}
                </if>
                            <if test="receiptZipCode != null and !&quot;&quot;.equals(receiptZipCode)">
                    and  receipt_zip_code = #{receiptZipCode}
                </if>
                            <if test="invoiceType != null and !&quot;&quot;.equals(invoiceType)">
                    and  invoice_type = #{invoiceType}
                </if>
                            <if test="invoiceTitle != null and !&quot;&quot;.equals(invoiceTitle)">
                    and  invoice_title = #{invoiceTitle}
                </if>
                            <if test="invoiceContent != null and !&quot;&quot;.equals(invoiceContent)">
                    and  invoice_content = #{invoiceContent}
                </if>
                            <if test="invoiceTaxid != null and !&quot;&quot;.equals(invoiceTaxid)">
                    and  invoice_taxid = #{invoiceTaxid}
                </if>
                            <if test="remark != null and !&quot;&quot;.equals(remark)">
                    and  remark = #{remark}
                </if>
                            <if test="giftInfos != null and !&quot;&quot;.equals(giftInfos)">
                    and  gift_infos = #{giftInfos}
                </if>
                            <if test="donationMessage != null and !&quot;&quot;.equals(donationMessage)">
                    and  donation_message = #{donationMessage}
                </if>
                            <if test="invoiceCompanyName != null and !&quot;&quot;.equals(invoiceCompanyName)">
                    and  invoice_company_name = #{invoiceCompanyName}
                </if>
                            <if test="invoiceRegisterAddress != null and !&quot;&quot;.equals(invoiceRegisterAddress)">
                    and  invoice_register_address = #{invoiceRegisterAddress}
                </if>
                            <if test="invoiceRegisterMobile != null and !&quot;&quot;.equals(invoiceRegisterMobile)">
                    and  invoice_register_mobile = #{invoiceRegisterMobile}
                </if>
                            <if test="invoiceOpenBank != null and !&quot;&quot;.equals(invoiceOpenBank)">
                    and  invoice_open_bank = #{invoiceOpenBank}
                </if>
                            <if test="invoiceBankAccount != null and !&quot;&quot;.equals(invoiceBankAccount)">
                    and  invoice_bank_account = #{invoiceBankAccount}
                </if>
                            <if test="invoiceTitleType != null and !&quot;&quot;.equals(invoiceTitleType)">
                    and  invoice_title_type = #{invoiceTitleType}
                </if>
                            <if test="deliveryTime != null and !&quot;&quot;.equals(deliveryTime)">
                    and  delivery_time = #{deliveryTime}
                </if>
                            <if test="address != null and !&quot;&quot;.equals(address)">
                    and  address = #{address}
                </if>
                            <if test="detailAddress != null and !&quot;&quot;.equals(detailAddress)">
                    and  detail_address = #{detailAddress}
                </if>
                            <if test="pickUpAddress != null and !&quot;&quot;.equals(pickUpAddress)">
                    and  pick_up_address = #{pickUpAddress}
                </if>
                            <if test="deliveryType != null and !&quot;&quot;.equals(deliveryType)">
                    and  delivery_type = #{deliveryType}
                </if>
                            <if test="houseNumber != null and !&quot;&quot;.equals(houseNumber)">
                    and  house_number = #{houseNumber}
                </if>
                    </where>
        order by id desc
    </select>

    <!-- 根据条件查询一个 -->
    <select id="queryOne" parameterType="java.util.Map"
            resultMap="entityMap">
        select
        <include refid="Base_Column_List"/>
        from ls_order_attr
        <where>
            and del_flag = 'N'
                            <if test="id != null and !&quot;&quot;.equals(id)">
                    and  id = #{id}
                </if>
                            <if test="orderId != null and !&quot;&quot;.equals(orderId)">
                    and  order_id = #{orderId}
                </if>
                            <if test="receiptName != null and !&quot;&quot;.equals(receiptName)">
                    and  receipt_name = #{receiptName}
                </if>
                            <if test="receiptAddress != null and !&quot;&quot;.equals(receiptAddress)">
                    and  receipt_address = #{receiptAddress}
                </if>
                            <if test="receiptDetailAddress != null and !&quot;&quot;.equals(receiptDetailAddress)">
                    and  receipt_detail_address = #{receiptDetailAddress}
                </if>
                            <if test="receiptMobile != null and !&quot;&quot;.equals(receiptMobile)">
                    and  receipt_mobile = #{receiptMobile}
                </if>
                            <if test="receiptPhone != null and !&quot;&quot;.equals(receiptPhone)">
                    and  receipt_phone = #{receiptPhone}
                </if>
                            <if test="receiptZipCode != null and !&quot;&quot;.equals(receiptZipCode)">
                    and  receipt_zip_code = #{receiptZipCode}
                </if>
                            <if test="invoiceType != null and !&quot;&quot;.equals(invoiceType)">
                    and  invoice_type = #{invoiceType}
                </if>
                            <if test="invoiceTitle != null and !&quot;&quot;.equals(invoiceTitle)">
                    and  invoice_title = #{invoiceTitle}
                </if>
                            <if test="invoiceContent != null and !&quot;&quot;.equals(invoiceContent)">
                    and  invoice_content = #{invoiceContent}
                </if>
                            <if test="invoiceTaxid != null and !&quot;&quot;.equals(invoiceTaxid)">
                    and  invoice_taxid = #{invoiceTaxid}
                </if>
                            <if test="remark != null and !&quot;&quot;.equals(remark)">
                    and  remark = #{remark}
                </if>
                            <if test="giftInfos != null and !&quot;&quot;.equals(giftInfos)">
                    and  gift_infos = #{giftInfos}
                </if>
                            <if test="donationMessage != null and !&quot;&quot;.equals(donationMessage)">
                    and  donation_message = #{donationMessage}
                </if>
                            <if test="invoiceCompanyName != null and !&quot;&quot;.equals(invoiceCompanyName)">
                    and  invoice_company_name = #{invoiceCompanyName}
                </if>
                            <if test="invoiceRegisterAddress != null and !&quot;&quot;.equals(invoiceRegisterAddress)">
                    and  invoice_register_address = #{invoiceRegisterAddress}
                </if>
                            <if test="invoiceRegisterMobile != null and !&quot;&quot;.equals(invoiceRegisterMobile)">
                    and  invoice_register_mobile = #{invoiceRegisterMobile}
                </if>
                            <if test="invoiceOpenBank != null and !&quot;&quot;.equals(invoiceOpenBank)">
                    and  invoice_open_bank = #{invoiceOpenBank}
                </if>
                            <if test="invoiceBankAccount != null and !&quot;&quot;.equals(invoiceBankAccount)">
                    and  invoice_bank_account = #{invoiceBankAccount}
                </if>
                            <if test="invoiceTitleType != null and !&quot;&quot;.equals(invoiceTitleType)">
                    and  invoice_title_type = #{invoiceTitleType}
                </if>
                            <if test="deliveryTime != null and !&quot;&quot;.equals(deliveryTime)">
                    and  delivery_time = #{deliveryTime}
                </if>
                            <if test="address != null and !&quot;&quot;.equals(address)">
                    and  address = #{address}
                </if>
                            <if test="detailAddress != null and !&quot;&quot;.equals(detailAddress)">
                    and  detail_address = #{detailAddress}
                </if>
                            <if test="pickUpAddress != null and !&quot;&quot;.equals(pickUpAddress)">
                    and  pick_up_address = #{pickUpAddress}
                </if>
                            <if test="deliveryType != null and !&quot;&quot;.equals(deliveryType)">
                    and  delivery_type = #{deliveryType}
                </if>
                            <if test="houseNumber != null and !&quot;&quot;.equals(houseNumber)">
                    and  house_number = #{houseNumber}
                </if>
                    </where>
        LIMIT 1
    </select>

    <update id="delete">
        UPDATE ls_order_attr SET del_flag = 'Y'
        <where>
            AND id = #{id}
        </where>
    </update>

    <update id="deleteIds" parameterType="java.util.ArrayList">
        UPDATE  ls_order_attr SET del_flag = 'Y'
        WHERE id IN
        <foreach item='ids' collection="array" index="index" open="(" separator="," close=")">
            #{ids}
        </foreach>
    </update>

</mapper>
