<?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.OrderDao">

    <!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.pine.admin.modules.business.entity.Order" id="entityMap">
        <result property="id" column="id"/>
        <result property="orderCode" column="order_code"/>
        <result property="masterOrderCode" column="master_order_code"/>
        <result property="customerId" column="customer_id"/>
        <result property="price" column="price"/>
        <result property="presalePrice" column="presale_price"/>
        <result property="originalPrice" column="original_price"/>
        <result property="freightPrice" column="freight_price"/>
        <result property="modifyPrice" column="modify_price"/>
        <result property="pointPrice" column="point_price"/>
        <result property="couponPrice" column="coupon_price"/>
        <result property="redEnvelopePrice" column="red_envelope_price"/>
        <result property="concessionalRate" column="concessional_rate"/>
        <result property="status" column="status"/>
        <result property="presaleStatus" column="presale_status"/>
        <result property="evaluationStatus" column="evaluation_status"/>
        <result property="redEnvelopeCode" column="red_envelope_code"/>
        <result property="couponNo" column="coupon_no"/>
        <result property="usePoint" column="use_point"/>
        <result property="payType" column="pay_type"/>
        <result property="storeId" column="store_id"/>
        <result property="cancelReson" column="cancel_reson"/>
        <result property="predepositPay" column="predeposit_pay"/>
        <result property="source" column="source"/>
        <result property="freightTemplateId" column="freight_template_id"/>
        <result property="waybillCode" column="waybill_code"/>
        <result property="orderType" column="order_type"/>
        <result property="createTime" column="create_time"/>
        <result property="payTime" column="pay_time"/>
        <result property="deliveryTime" column="delivery_time"/>
        <result property="receivingTime" column="receiving_time"/>
        <result property="cancelTime" column="cancel_time"/>
        <result property="modifyTime" column="modify_time"/>
        <result property="evaluationTime" column="evaluation_time"/>
        <result property="presaleTime" column="presale_time"/>
        <result property="openGroupTime" column="open_group_time"/>
        <result column="customer_name" property="customerName"/>
        <result property="recommended" column="recommended"/>
        <result property="lotteryStatus" column="lottery_status"/>
        <result property="writeOffCode" column="write_off_code"/>
        <result property="communityBuyCustomerId" column="community_buy_customer_id"/>
        <result property="communityBuyId" column="community_buy_id"/>
        <result property="profit" column="profit"/>
        <result property="communityName" column="community_name"/>
        <result property="communityBuyName" column="community_buy_name"/>
        <result property="dealerId" column="dealer_id"/>
        <result property="dealerInfo" column="dealer_info"/>
        <result property="payChannel" column="pay_channel"/>
        <result property="skuType" column="sku_type"/>
    </resultMap>

    <sql id="Base_Column_List">
                 id,
                     order_code,
                     master_order_code,
                     customer_id,
                     price,
                     presale_price,
                     original_price,
                     freight_price,
                     modify_price,
                     point_price,
                     coupon_price,
                     red_envelope_price,
                     concessional_rate,
                     status,
                     presale_status,
                     evaluation_status,
                     red_envelope_code,
                     coupon_no,
                     use_point,
                     pay_type,
                     store_id,
                     cancel_reson,
                     predeposit_pay,
                     source,
                     freight_template_id,
                     waybill_code,
                     order_type,
                     create_time,
                     pay_time,
                     delivery_time,
                     receiving_time,
                     cancel_time,
                     modify_time,
                     evaluation_time,
                     presale_time,
                     group_head,
                     group_id,
                     group_marketing_id,
                     group_sku_id,
                     group_status,
                     group_num,
                     open_group_time,
                     auto_handle_status,
                     recommended,
                     crowdfunding_id,
                     lottery_status,
                     write_off_code,
                     community_buy_customer_id,
                     community_buy_id,
                     profit,
                     community_name,
                     community_buy_name,
                     bill_no,
                     dealer_id,
                     dealer_info,
                     pay_channel,
                     sku_type,
                     jetour_send_flag,
                    incoming_url         </sql>
    <!-- 根据Id查询-->
    <select id="selectByPrimaryKey" resultMap="entityMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        from ls_order
        where id = #{id,jdbcType=INTEGER} and store_id = 0
    </select>

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

    <!-- 插入数据-->
    <insert id="insertSelective" parameterType="com.pine.admin.modules.business.entity.Order"
            useGeneratedKeys="true" keyProperty="id">
        insert into ls_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="orderCode != null">order_code,</if>
            <if test="masterOrderCode != null">master_order_code,</if>
            <if test="customerId != null">customer_id,</if>
            <if test="price != null">price,</if>
            <if test="presalePrice != null">presale_price,</if>
            <if test="originalPrice != null">original_price,</if>
            <if test="freightPrice != null">freight_price,</if>
            <if test="modifyPrice != null">modify_price,</if>
            <if test="pointPrice != null">point_price,</if>
            <if test="couponPrice != null">coupon_price,</if>
            <if test="redEnvelopePrice != null">red_envelope_price,</if>
            <if test="concessionalRate != null">concessional_rate,</if>
            <if test="status != null">status,</if>
            <if test="presaleStatus != null">presale_status,</if>
            <if test="evaluationStatus != null">evaluation_status,</if>
            <if test="redEnvelopeCode != null">red_envelope_code,</if>
            <if test="couponNo != null">coupon_no,</if>
            <if test="usePoint != null">use_point,</if>
            <if test="payType != null">pay_type,</if>
            <if test="storeId != null">store_id,</if>
            <if test="cancelReson != null">cancel_reson,</if>
            <if test="predepositPay != null">predeposit_pay,</if>
            <if test="source != null">source,</if>
            <if test="freightTemplateId != null">freight_template_id,</if>
            <if test="waybillCode != null">waybill_code,</if>
            <if test="orderType != null">order_type,</if>
            <if test="createTime != null">create_time,</if>
            <if test="payTime != null">pay_time,</if>
            <if test="deliveryTime != null">delivery_time,</if>
            <if test="receivingTime != null">receiving_time,</if>
            <if test="cancelTime != null">cancel_time,</if>
            <if test="modifyTime != null">modify_time,</if>
            <if test="evaluationTime != null">evaluation_time,</if>
            <if test="presaleTime != null">presale_time,</if>
            <if test="groupHead != null">group_head,</if>
            <if test="groupId != null">group_id,</if>
            <if test="groupMarketingId != null">group_marketing_id,</if>
            <if test="groupSkuId != null">group_sku_id,</if>
            <if test="groupStatus != null">group_status,</if>
            <if test="groupNum != null">group_num,</if>
            <if test="openGroupTime != null">open_group_time,</if>
            <if test="autoHandleStatus != null">auto_handle_status,</if>
            <if test="recommended != null">recommended,</if>
            <if test="crowdfundingId != null">crowdfunding_id,</if>
            <if test="lotteryStatus != null">lottery_status,</if>
            <if test="writeOffCode != null">write_off_code,</if>
            <if test="communityBuyCustomerId != null">community_buy_customer_id,</if>
            <if test="communityBuyId != null">community_buy_id,</if>
            <if test="profit != null">profit,</if>
            <if test="communityName != null">community_name,</if>
            <if test="communityBuyName != null">community_buy_name,</if>
            <if test="billNo != null">bill_no,</if>
            <if test="dealerId != null">dealer_id,</if>
            <if test="dealerInfo != null">dealer_info,</if>
            <if test="payChannel != null">pay_channel,</if>
            <if test="skuType != null">sku_type,</if>
            <if test="jetourSendFlag != null">jetour_send_flag,</if>
            <if test="incomingUrl != null">incoming_url,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="orderCode != null">#{orderCode},</if>
            <if test="masterOrderCode != null">#{masterOrderCode},</if>
            <if test="customerId != null">#{customerId},</if>
            <if test="price != null">#{price},</if>
            <if test="presalePrice != null">#{presalePrice},</if>
            <if test="originalPrice != null">#{originalPrice},</if>
            <if test="freightPrice != null">#{freightPrice},</if>
            <if test="modifyPrice != null">#{modifyPrice},</if>
            <if test="pointPrice != null">#{pointPrice},</if>
            <if test="couponPrice != null">#{couponPrice},</if>
            <if test="redEnvelopePrice != null">#{redEnvelopePrice},</if>
            <if test="concessionalRate != null">#{concessionalRate},</if>
            <if test="status != null">#{status},</if>
            <if test="presaleStatus != null">#{presaleStatus},</if>
            <if test="evaluationStatus != null">#{evaluationStatus},</if>
            <if test="redEnvelopeCode != null">#{redEnvelopeCode},</if>
            <if test="couponNo != null">#{couponNo},</if>
            <if test="usePoint != null">#{usePoint},</if>
            <if test="payType != null">#{payType},</if>
            <if test="storeId != null">#{storeId},</if>
            <if test="cancelReson != null">#{cancelReson},</if>
            <if test="predepositPay != null">#{predepositPay},</if>
            <if test="source != null">#{source},</if>
            <if test="freightTemplateId != null">#{freightTemplateId},</if>
            <if test="waybillCode != null">#{waybillCode},</if>
            <if test="orderType != null">#{orderType},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="payTime != null">#{payTime},</if>
            <if test="deliveryTime != null">#{deliveryTime},</if>
            <if test="receivingTime != null">#{receivingTime},</if>
            <if test="cancelTime != null">#{cancelTime},</if>
            <if test="modifyTime != null">#{modifyTime},</if>
            <if test="evaluationTime != null">#{evaluationTime},</if>
            <if test="presaleTime != null">#{presaleTime},</if>
            <if test="groupHead != null">#{groupHead},</if>
            <if test="groupId != null">#{groupId},</if>
            <if test="groupMarketingId != null">#{groupMarketingId},</if>
            <if test="groupSkuId != null">#{groupSkuId},</if>
            <if test="groupStatus != null">#{groupStatus},</if>
            <if test="groupNum != null">#{groupNum},</if>
            <if test="openGroupTime != null">#{openGroupTime},</if>
            <if test="autoHandleStatus != null">#{autoHandleStatus},</if>
            <if test="recommended != null">#{recommended},</if>
            <if test="crowdfundingId != null">#{crowdfundingId},</if>
            <if test="lotteryStatus != null">#{lotteryStatus},</if>
            <if test="writeOffCode != null">#{writeOffCode},</if>
            <if test="communityBuyCustomerId != null">#{communityBuyCustomerId},</if>
            <if test="communityBuyId != null">#{communityBuyId},</if>
            <if test="profit != null">#{profit},</if>
            <if test="communityName != null">#{communityName},</if>
            <if test="communityBuyName != null">#{communityBuyName},</if>
            <if test="billNo != null">#{billNo},</if>
            <if test="dealerId != null">#{dealerId},</if>
            <if test="dealerInfo != null">#{dealerInfo},</if>
            <if test="payChannel != null">#{payChannel},</if>
            <if test="skuType != null">#{skuType},</if>
            <if test="jetourSendFlag != null">#{jetourSendFlag},</if>
            <if test="incomingUrl != null">#{incomingUrl},</if>
        </trim>
    </insert>

    <!-- 更新数据-->
    <update id="updateByPrimaryKeySelective" parameterType="com.pine.admin.modules.business.entity.Order">
        update ls_order
        <set>
            <if test="id != null">id = #{id},</if>
            <if test="orderCode != null">order_code = #{orderCode},</if>
            <if test="masterOrderCode != null">master_order_code = #{masterOrderCode},</if>
            <if test="customerId != null">customer_id = #{customerId},</if>
            <if test="price != null">price = #{price},</if>
            <if test="presalePrice != null">presale_price = #{presalePrice},</if>
            <if test="originalPrice != null">original_price = #{originalPrice},</if>
            <if test="freightPrice != null">freight_price = #{freightPrice},</if>
            <if test="modifyPrice != null">modify_price = #{modifyPrice},</if>
            <if test="pointPrice != null">point_price = #{pointPrice},</if>
            <if test="couponPrice != null">coupon_price = #{couponPrice},</if>
            <if test="redEnvelopePrice != null">red_envelope_price = #{redEnvelopePrice},</if>
            <if test="concessionalRate != null">concessional_rate = #{concessionalRate},</if>
            <if test="status != null">status = #{status},</if>
            <if test="presaleStatus != null">presale_status = #{presaleStatus},</if>
            <if test="evaluationStatus != null">evaluation_status = #{evaluationStatus},</if>
            <if test="redEnvelopeCode != null">red_envelope_code = #{redEnvelopeCode},</if>
            <if test="couponNo != null">coupon_no = #{couponNo},</if>
            <if test="usePoint != null">use_point = #{usePoint},</if>
            <if test="payType != null">pay_type = #{payType},</if>
            <if test="storeId != null">store_id = #{storeId},</if>
            <if test="cancelReson != null">cancel_reson = #{cancelReson},</if>
            <if test="predepositPay != null">predeposit_pay = #{predepositPay},</if>
            <if test="source != null">source = #{source},</if>
            <if test="freightTemplateId != null">freight_template_id = #{freightTemplateId},</if>
            <if test="waybillCode != null">waybill_code = #{waybillCode},</if>
            <if test="orderType != null">order_type = #{orderType},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="payTime != null">pay_time = #{payTime},</if>
            <if test="deliveryTime != null">delivery_time = #{deliveryTime},</if>
            <if test="receivingTime != null">receiving_time = #{receivingTime},</if>
            <if test="cancelTime != null">cancel_time = #{cancelTime},</if>
            <if test="modifyTime != null">modify_time = #{modifyTime},</if>
            <if test="evaluationTime != null">evaluation_time = #{evaluationTime},</if>
            <if test="presaleTime != null">presale_time = #{presaleTime},</if>
            <if test="groupHead != null">group_head = #{groupHead},</if>
            <if test="groupId != null">group_id = #{groupId},</if>
            <if test="groupMarketingId != null">group_marketing_id = #{groupMarketingId},</if>
            <if test="groupSkuId != null">group_sku_id = #{groupSkuId},</if>
            <if test="groupStatus != null">group_status = #{groupStatus},</if>
            <if test="groupNum != null">group_num = #{groupNum},</if>
            <if test="openGroupTime != null">open_group_time = #{openGroupTime},</if>
            <if test="autoHandleStatus != null">auto_handle_status = #{autoHandleStatus},</if>
            <if test="recommended != null">recommended = #{recommended},</if>
            <if test="crowdfundingId != null">crowdfunding_id = #{crowdfundingId},</if>
            <if test="lotteryStatus != null">lottery_status = #{lotteryStatus},</if>
            <if test="writeOffCode != null">write_off_code = #{writeOffCode},</if>
            <if test="communityBuyCustomerId != null">community_buy_customer_id = #{communityBuyCustomerId},</if>
            <if test="communityBuyId != null">community_buy_id = #{communityBuyId},</if>
            <if test="profit != null">profit = #{profit},</if>
            <if test="communityName != null">community_name = #{communityName},</if>
            <if test="communityBuyName != null">community_buy_name = #{communityBuyName},</if>
            <if test="billNo != null">bill_no = #{billNo},</if>
            <if test="dealerId != null">dealer_id = #{dealerId},</if>
            <if test="dealerInfo != null">dealer_info = #{dealerInfo},</if>
            <if test="payChannel != null">pay_channel = #{payChannel},</if>
            <if test="skuType != null">sku_type = #{skuType},</if>
            <if test="jetourSendFlag != null">jetour_send_flag = #{jetourSendFlag},</if>
            <if test="incomingUrl != null">incoming_url = #{incomingUrl},</if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>

    <!-- 分页查询-->
    <select id="queryByPage" parameterType="java.util.Map"
            resultType="com.pine.admin.modules.business.entity.Order">
        select ls_order.*,
        ls_customer.username as customerName,
        ls_customer.mobile,
        ls_order_attr.receipt_mobile as receiptMobile,
        ls_order_attr.receipt_name as receiptName,
        concat(ls_order_attr.receipt_address,ls_order_attr.receipt_detail_address) as address,
        ls_order_sku.sku_name AS skuName
        from ls_order
        join ls_customer on ls_order.customer_id = ls_customer.id
        left join ls_order_attr on ls_order_attr.order_id = ls_order.id
        left join ls_order_sku on ls_order_sku.order_id = ls_order.id
        where ls_customer.del_flag = '0'
        and ls_order.store_id = 0
        and ls_order.status != 1
        and ls_order.status != 5
        <!-- 收货人手机号 -->
        <if test="record.receiptMobile != null and record.receiptMobile != '' ">
            and ls_order_attr.receipt_mobile = #{record.receiptMobile}
        </if>
        <if test="record.skuName != null and record.skuName != '' ">
            and  ls_order_sku.sku_name like CONCAT('%',CONCAT(#{record.skuName}),'%')
        </if>
        <!-- 收货人姓名 -->
        <if test="record.receiptName != null and record.receiptName != '' ">
            and ls_order_attr.receipt_name like CONCAT(CONCAT('%', #{record.receiptName}),'%')
        </if>
        <if test="record.orderCode != null and record.orderCode != '' ">
            AND ls_order.order_code = #{record.orderCode}
        </if>
        <if test="record.customerName != null and record.customerName != ''">
            AND ls_customer.username like CONCAT(CONCAT('%', #{record.customerName}),'%')
        </if>
        <if test="record.customerMobile != null and record.customerMobile != ''">
            AND ls_customer.mobile = #{record.customerMobile}
        </if>
        <if test="record.customerId != null and record.customerId != ''">
            AND ls_order.id=#{record.customerId}
        </if>
        <if test="record.dealerId != null and record.dealerId != ''">
            AND ls_order.dealer_id=#{record.dealerId}
        </if>

        <if test="record.payType != null and record.payType != '' ">
            AND ls_order.pay_type = #{record.payType}
        </if>

        <if test='record.status != null and record.status != "" and  record.status!= "5"'>
            AND ls_order.status = #{record.status}
        </if>
        <if test='record.status=="5"'>
            AND ls_order.status in ('5','6','7')
            AND ls_order.order_type in ('0','1','2','3','7')
        </if>
        <if test="record.startTime!=''and record.startTime!=null">
            AND ls_order.create_time &gt;=#{record.startTime,jdbcType=TIMESTAMP}
        </if>
        <if test="record.endTime!=''and record.endTime!=null">
            AND ls_order.create_time &lt;=#{record.endTime,jdbcType=TIMESTAMP}
        </if>
        <if test="record.orderType!=null and record.orderType !=''">
            AND ls_order.order_type=#{record.orderType}
        </if>
        <if test='record.status !="5"'>
            AND ls_order.order_type in ('0','1','2','7')
        </if>
        <choose>
            <when test="record.orderType ==1 ||record.orderType==2">
                order by ls_order.pay_time desc
            </when>
            <otherwise>
                order by ls_order.create_time desc
            </otherwise>
        </choose>

    </select>

    <!-- 全部查询 -->
    <select id="queryAll" parameterType="java.util.Map"
            resultType="com.pine.admin.modules.business.entity.Order">
        select ls_order.*,
        ls_customer.username as customerName,
        ls_customer.mobile,
        ls_order_attr.receipt_mobile as receiptMobile,
        ls_order_attr.receipt_name as receiptName,
        concat(ls_order_attr.receipt_address,ls_order_attr.receipt_detail_address) as address,
        ls_order_sku.sku_name AS skuName
        from ls_order
        join ls_customer on ls_order.customer_id = ls_customer.id
        join ls_order_attr on ls_order_attr.order_id = ls_order.id
        left join ls_order_sku on ls_order_sku.order_id = ls_order.id
        where ls_customer.del_flag = '0'
        and ls_order.store_id = 0
        and ls_order.status != 1
        and ls_order.status != 5
        <if test="skuName != null and skuName != '' ">
            and  ls_order_sku.sku_name like CONCAT('%',CONCAT(#{skuName}),'%')
        </if>
        <!-- 收货人手机号 -->
        <if test="receiptMobile != null and receiptMobile != '' ">
            and ls_order_attr.receipt_mobile = #{receiptMobile}
        </if>
        <!-- 收货人姓名 -->
        <if test="receiptName != null and receiptName != '' ">
            and ls_order_attr.receipt_name like CONCAT(CONCAT('%', #{receiptName}),'%')
        </if>
        <if test="orderCode != null and orderCode != '' ">
            AND ls_order.order_code = #{orderCode}
        </if>
        <if test="customerName != null and customerName != ''">
            AND ls_customer.username like CONCAT(CONCAT('%', #{customerName}),'%')
        </if>
        <if test="customerMobile != null and customerMobile != ''">
            AND ls_customer.mobile = #{customerMobile}
        </if>
        <if test="customerId != null and customerId != ''">
            AND ls_order.id=#{customerId}
        </if>
        <if test="dealerId != null and dealerId != ''">
            AND ls_order.dealer_id=#{dealerId}
        </if>

        <if test="payType != null and payType != '' ">
            AND ls_order.pay_type = #{payType}
        </if>

        <if test='status != null and status != "" and status!= "5"'>
            AND ls_order.status = #{status}
        </if>
        <if test='status=="5"'>
            AND ls_order.status in ('5','6','7')
            AND ls_order.order_type in ('0','1','2','3','7')
        </if>
        <if test="startTime!=''and startTime!=null">
            AND ls_order.create_time &gt;=#{startTime,jdbcType=TIMESTAMP}
        </if>
        <if test="endTime!=''and endTime!=null">
            AND ls_order.create_time &lt;=#{endTime,jdbcType=TIMESTAMP}
        </if>
        <if test="orderType!=null and orderType !=''">
            AND ls_order.order_type=#{orderType}
        </if>
        <if test='status !="5"'>
            AND ls_order.order_type in ('0','1','2','7')
        </if>
        <choose>
            <when test="orderType ==1 ||orderType==2">
                order by ls_order.pay_time desc
            </when>
            <otherwise>
                order by ls_order.create_time desc
            </otherwise>
        </choose>

    </select>

    <!-- 根据条件查询一个 -->
    <select id="queryOne" parameterType="java.util.Map"
            resultMap="entityMap">
        select
        <include refid="Base_Column_List"/>
        from ls_order
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="orderCode != null and !&quot;&quot;.equals(orderCode)">
                and order_code = #{orderCode}
            </if>
            <if test="masterOrderCode != null and !&quot;&quot;.equals(masterOrderCode)">
                and master_order_code = #{masterOrderCode}
            </if>
            <if test="customerId != null and !&quot;&quot;.equals(customerId)">
                and customer_id = #{customerId}
            </if>
            <if test="price != null and !&quot;&quot;.equals(price)">
                and price = #{price}
            </if>
            <if test="presalePrice != null and !&quot;&quot;.equals(presalePrice)">
                and presale_price = #{presalePrice}
            </if>
            <if test="originalPrice != null and !&quot;&quot;.equals(originalPrice)">
                and original_price = #{originalPrice}
            </if>
            <if test="freightPrice != null and !&quot;&quot;.equals(freightPrice)">
                and freight_price = #{freightPrice}
            </if>
            <if test="modifyPrice != null and !&quot;&quot;.equals(modifyPrice)">
                and modify_price = #{modifyPrice}
            </if>
            <if test="pointPrice != null and !&quot;&quot;.equals(pointPrice)">
                and point_price = #{pointPrice}
            </if>
            <if test="couponPrice != null and !&quot;&quot;.equals(couponPrice)">
                and coupon_price = #{couponPrice}
            </if>
            <if test="redEnvelopePrice != null and !&quot;&quot;.equals(redEnvelopePrice)">
                and red_envelope_price = #{redEnvelopePrice}
            </if>
            <if test="concessionalRate != null and !&quot;&quot;.equals(concessionalRate)">
                and concessional_rate = #{concessionalRate}
            </if>
            <if test="status != null and !&quot;&quot;.equals(status)">
                and status = #{status}
            </if>
            <if test="presaleStatus != null and !&quot;&quot;.equals(presaleStatus)">
                and presale_status = #{presaleStatus}
            </if>
            <if test="evaluationStatus != null and !&quot;&quot;.equals(evaluationStatus)">
                and evaluation_status = #{evaluationStatus}
            </if>
            <if test="redEnvelopeCode != null and !&quot;&quot;.equals(redEnvelopeCode)">
                and red_envelope_code = #{redEnvelopeCode}
            </if>
            <if test="couponNo != null and !&quot;&quot;.equals(couponNo)">
                and coupon_no = #{couponNo}
            </if>
            <if test="usePoint != null and !&quot;&quot;.equals(usePoint)">
                and use_point = #{usePoint}
            </if>
            <if test="payType != null and !&quot;&quot;.equals(payType)">
                and pay_type = #{payType}
            </if>
            <if test="storeId != null and !&quot;&quot;.equals(storeId)">
                and store_id = #{storeId}
            </if>
            <if test="cancelReson != null and !&quot;&quot;.equals(cancelReson)">
                and cancel_reson = #{cancelReson}
            </if>
            <if test="predepositPay != null and !&quot;&quot;.equals(predepositPay)">
                and predeposit_pay = #{predepositPay}
            </if>
            <if test="source != null and !&quot;&quot;.equals(source)">
                and source = #{source}
            </if>
            <if test="freightTemplateId != null and !&quot;&quot;.equals(freightTemplateId)">
                and freight_template_id = #{freightTemplateId}
            </if>
            <if test="waybillCode != null and !&quot;&quot;.equals(waybillCode)">
                and waybill_code = #{waybillCode}
            </if>
            <if test="orderType != null and !&quot;&quot;.equals(orderType)">
                and order_type = #{orderType}
            </if>
            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
                and create_time = #{createTime}
            </if>
            <if test="payTime != null and !&quot;&quot;.equals(payTime)">
                and pay_time = #{payTime}
            </if>
            <if test="deliveryTime != null and !&quot;&quot;.equals(deliveryTime)">
                and delivery_time = #{deliveryTime}
            </if>
            <if test="receivingTime != null and !&quot;&quot;.equals(receivingTime)">
                and receiving_time = #{receivingTime}
            </if>
            <if test="cancelTime != null and !&quot;&quot;.equals(cancelTime)">
                and cancel_time = #{cancelTime}
            </if>
            <if test="modifyTime != null and !&quot;&quot;.equals(modifyTime)">
                and modify_time = #{modifyTime}
            </if>
            <if test="evaluationTime != null and !&quot;&quot;.equals(evaluationTime)">
                and evaluation_time = #{evaluationTime}
            </if>
            <if test="presaleTime != null and !&quot;&quot;.equals(presaleTime)">
                and presale_time = #{presaleTime}
            </if>
            <if test="groupHead != null and !&quot;&quot;.equals(groupHead)">
                and group_head = #{groupHead}
            </if>
            <if test="groupId != null and !&quot;&quot;.equals(groupId)">
                and group_id = #{groupId}
            </if>
            <if test="groupMarketingId != null and !&quot;&quot;.equals(groupMarketingId)">
                and group_marketing_id = #{groupMarketingId}
            </if>
            <if test="groupSkuId != null and !&quot;&quot;.equals(groupSkuId)">
                and group_sku_id = #{groupSkuId}
            </if>
            <if test="groupStatus != null and !&quot;&quot;.equals(groupStatus)">
                and group_status = #{groupStatus}
            </if>
            <if test="groupNum != null and !&quot;&quot;.equals(groupNum)">
                and group_num = #{groupNum}
            </if>
            <if test="openGroupTime != null and !&quot;&quot;.equals(openGroupTime)">
                and open_group_time = #{openGroupTime}
            </if>
            <if test="autoHandleStatus != null and !&quot;&quot;.equals(autoHandleStatus)">
                and auto_handle_status = #{autoHandleStatus}
            </if>
            <if test="recommended != null and !&quot;&quot;.equals(recommended)">
                and recommended = #{recommended}
            </if>
            <if test="crowdfundingId != null and !&quot;&quot;.equals(crowdfundingId)">
                and crowdfunding_id = #{crowdfundingId}
            </if>
            <if test="lotteryStatus != null and !&quot;&quot;.equals(lotteryStatus)">
                and lottery_status = #{lotteryStatus}
            </if>
            <if test="writeOffCode != null and !&quot;&quot;.equals(writeOffCode)">
                and write_off_code = #{writeOffCode}
            </if>
            <if test="communityBuyCustomerId != null and !&quot;&quot;.equals(communityBuyCustomerId)">
                and community_buy_customer_id = #{communityBuyCustomerId}
            </if>
            <if test="communityBuyId != null and !&quot;&quot;.equals(communityBuyId)">
                and community_buy_id = #{communityBuyId}
            </if>
            <if test="profit != null and !&quot;&quot;.equals(profit)">
                and profit = #{profit}
            </if>
            <if test="communityName != null and !&quot;&quot;.equals(communityName)">
                and community_name = #{communityName}
            </if>
            <if test="communityBuyName != null and !&quot;&quot;.equals(communityBuyName)">
                and community_buy_name = #{communityBuyName}
            </if>
            <if test="billNo != null and !&quot;&quot;.equals(billNo)">
                and bill_no = #{billNo}
            </if>
            <if test="dealerId != null and !&quot;&quot;.equals(dealerId)">
                and dealer_id = #{dealerId}
            </if>
            <if test="dealerInfo != null and !&quot;&quot;.equals(dealerInfo)">
                and dealer_info = #{dealerInfo}
            </if>
            <if test="payChannel != null and !&quot;&quot;.equals(payChannel)">
                and pay_channel = #{payChannel}
            </if>
            <if test="skuType != null and !&quot;&quot;.equals(skuType)">
                and sku_type = #{skuType}
            </if>
            <if test="jetourSendFlag != null and !&quot;&quot;.equals(jetourSendFlag)">
                and jetour_send_flag = #{jetourSendFlag}
            </if>
            <if test="incomingUrl != null and !&quot;&quot;.equals(incomingUrl)">
                and incoming_url = #{incomingUrl}
            </if>
        </where>
        LIMIT 1
    </select>
    <select id="getById" parameterType="java.lang.Long" resultMap="entityMap">
        select
        <include refid="Base_Column_List"/>
        from ls_order
        where id = #{id,jdbcType=INTEGER} and store_id = 0
    </select>

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

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

</mapper>
