<?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.mall.order.mapper.OrderMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mall.order.domain.entity.Order">
        <id column="id" property="id"/>
        <id column="member_id" property="memberId"/>
        <id column="order_sn" property="orderSn"/>
        <id column="coupon_id" property="couponId"/>
        <id column="create_time" property="createTime"/>
        <id column="member_username" property="memberUsername"/>
        <id column="total_amount" property="totalAmount"/>
        <id column="pay_amount" property="payAmount"/>
        <id column="freight_amount" property="freightAmount"/>
        <id column="promotion_amount" property="promotionAmount"/>
        <id column="integration_amount" property="integrationAmount"/>
        <id column="coupon_amount" property="couponAmount"/>
        <id column="discount_amount" property="discountAmount"/>
        <id column="pay_type" property="payType"/>
        <id column="source_type" property="sourceType"/>
        <id column="status" property="status"/>
        <id column="delivery_company" property="deliveryCompany"/>
        <id column="delivery_sn" property="deliverySn"/>
        <id column="auto_confirm_day" property="autoConfirmDay"/>
        <id column="integration" property="integration"/>
        <id column="growth" property="growth"/>
        <id column="bill_type" property="billType"/>
        <id column="bill_header" property="billHeader"/>
        <id column="bill_content" property="billContent"/>
        <id column="bill_receiver_phone" property="billReceiverPhone"/>
        <id column="bill_receiver_email" property="billReceiverEmail"/>
        <id column="receiver_name" property="receiverName"/>
        <id column="receiver_phone" property="receiverPhone"/>
        <id column="receiver_post_code" property="receiverPostCode"/>
        <id column="receiver_province" property="receiverProvince"/>
        <id column="receiver_city" property="receiverCity"/>
        <id column="receiver_region" property="receiverRegion"/>
        <id column="receiver_detail_address" property="receiverDetailAddress"/>
        <id column="note" property="note"/>
        <id column="confirm_status" property="confirmStatus"/>
        <id column="delete_status" property="deleteStatus"/>
        <id column="use_integration" property="useIntegration"/>
        <id column="payment_time" property="paymentTime"/>
        <id column="delivery_time" property="deliveryTime"/>
        <id column="receive_time" property="receiveTime"/>
        <id column="comment_time" property="commentTime"/>
        <id column="modify_time" property="modifyTime"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,member_id,order_sn,coupon_id,create_time,member_username,total_amount,pay_amount,freight_amount,promotion_amount,integration_amount,coupon_amount,discount_amount,pay_type,source_type,status,delivery_company,delivery_sn,auto_confirm_day,integration,growth,bill_type,bill_header,bill_content,bill_receiver_phone,bill_receiver_email,receiver_name,receiver_phone,receiver_post_code,receiver_province,receiver_city,receiver_region,receiver_detail_address,note,confirm_status,delete_status,use_integration,payment_time,delivery_time,receive_time,comment_time,modify_time
    </sql>

    <!-- 分页查询订单内容 -->
    <select id="selectListByPage" resultType="com.mall.order.domain.vo.OrderVo">
        select
        <include refid="Base_Column_List"/>
        from oms_order
        <where>
            <if test="dto.id != null and dto.id != ''">
                and id like CONCAT('%',#{dto.id},'%')
            </if>
            <if test="dto.memberId != null and dto.memberId != ''">
                and member_id like CONCAT('%',#{dto.memberId},'%')
            </if>
            <if test="dto.orderSn != null and dto.orderSn != ''">
                and order_sn like CONCAT('%',#{dto.orderSn},'%')
            </if>
            <if test="dto.couponId != null and dto.couponId != ''">
                and coupon_id like CONCAT('%',#{dto.couponId},'%')
            </if>
            <if test="dto.createTime != null and dto.createTime != ''">
                and create_time like CONCAT('%',#{dto.createTime},'%')
            </if>
            <if test="dto.memberUsername != null and dto.memberUsername != ''">
                and member_username like CONCAT('%',#{dto.memberUsername},'%')
            </if>
            <if test="dto.totalAmount != null and dto.totalAmount != ''">
                and total_amount like CONCAT('%',#{dto.totalAmount},'%')
            </if>
            <if test="dto.payAmount != null and dto.payAmount != ''">
                and pay_amount like CONCAT('%',#{dto.payAmount},'%')
            </if>
            <if test="dto.freightAmount != null and dto.freightAmount != ''">
                and freight_amount like CONCAT('%',#{dto.freightAmount},'%')
            </if>
            <if test="dto.promotionAmount != null and dto.promotionAmount != ''">
                and promotion_amount like CONCAT('%',#{dto.promotionAmount},'%')
            </if>
            <if test="dto.integrationAmount != null and dto.integrationAmount != ''">
                and integration_amount like CONCAT('%',#{dto.integrationAmount},'%')
            </if>
            <if test="dto.couponAmount != null and dto.couponAmount != ''">
                and coupon_amount like CONCAT('%',#{dto.couponAmount},'%')
            </if>
            <if test="dto.discountAmount != null and dto.discountAmount != ''">
                and discount_amount like CONCAT('%',#{dto.discountAmount},'%')
            </if>
            <if test="dto.payType != null and dto.payType != ''">
                and pay_type like CONCAT('%',#{dto.payType},'%')
            </if>
            <if test="dto.sourceType != null and dto.sourceType != ''">
                and source_type like CONCAT('%',#{dto.sourceType},'%')
            </if>
            <if test="dto.status != null and dto.status != ''">
                and status like CONCAT('%',#{dto.status},'%')
            </if>
            <if test="dto.deliveryCompany != null and dto.deliveryCompany != ''">
                and delivery_company like CONCAT('%',#{dto.deliveryCompany},'%')
            </if>
            <if test="dto.deliverySn != null and dto.deliverySn != ''">
                and delivery_sn like CONCAT('%',#{dto.deliverySn},'%')
            </if>
            <if test="dto.autoConfirmDay != null and dto.autoConfirmDay != ''">
                and auto_confirm_day like CONCAT('%',#{dto.autoConfirmDay},'%')
            </if>
            <if test="dto.integration != null and dto.integration != ''">
                and integration like CONCAT('%',#{dto.integration},'%')
            </if>
            <if test="dto.growth != null and dto.growth != ''">
                and growth like CONCAT('%',#{dto.growth},'%')
            </if>
            <if test="dto.billType != null and dto.billType != ''">
                and bill_type like CONCAT('%',#{dto.billType},'%')
            </if>
            <if test="dto.billHeader != null and dto.billHeader != ''">
                and bill_header like CONCAT('%',#{dto.billHeader},'%')
            </if>
            <if test="dto.billContent != null and dto.billContent != ''">
                and bill_content like CONCAT('%',#{dto.billContent},'%')
            </if>
            <if test="dto.billReceiverPhone != null and dto.billReceiverPhone != ''">
                and bill_receiver_phone like CONCAT('%',#{dto.billReceiverPhone},'%')
            </if>
            <if test="dto.billReceiverEmail != null and dto.billReceiverEmail != ''">
                and bill_receiver_email like CONCAT('%',#{dto.billReceiverEmail},'%')
            </if>
            <if test="dto.receiverName != null and dto.receiverName != ''">
                and receiver_name like CONCAT('%',#{dto.receiverName},'%')
            </if>
            <if test="dto.receiverPhone != null and dto.receiverPhone != ''">
                and receiver_phone like CONCAT('%',#{dto.receiverPhone},'%')
            </if>
            <if test="dto.receiverPostCode != null and dto.receiverPostCode != ''">
                and receiver_post_code like CONCAT('%',#{dto.receiverPostCode},'%')
            </if>
            <if test="dto.receiverProvince != null and dto.receiverProvince != ''">
                and receiver_province like CONCAT('%',#{dto.receiverProvince},'%')
            </if>
            <if test="dto.receiverCity != null and dto.receiverCity != ''">
                and receiver_city like CONCAT('%',#{dto.receiverCity},'%')
            </if>
            <if test="dto.receiverRegion != null and dto.receiverRegion != ''">
                and receiver_region like CONCAT('%',#{dto.receiverRegion},'%')
            </if>
            <if test="dto.receiverDetailAddress != null and dto.receiverDetailAddress != ''">
                and receiver_detail_address like CONCAT('%',#{dto.receiverDetailAddress},'%')
            </if>
            <if test="dto.note != null and dto.note != ''">
                and note like CONCAT('%',#{dto.note},'%')
            </if>
            <if test="dto.confirmStatus != null and dto.confirmStatus != ''">
                and confirm_status like CONCAT('%',#{dto.confirmStatus},'%')
            </if>
            <if test="dto.deleteStatus != null and dto.deleteStatus != ''">
                and delete_status like CONCAT('%',#{dto.deleteStatus},'%')
            </if>
            <if test="dto.useIntegration != null and dto.useIntegration != ''">
                and use_integration like CONCAT('%',#{dto.useIntegration},'%')
            </if>
            <if test="dto.paymentTime != null and dto.paymentTime != ''">
                and payment_time like CONCAT('%',#{dto.paymentTime},'%')
            </if>
            <if test="dto.deliveryTime != null and dto.deliveryTime != ''">
                and delivery_time like CONCAT('%',#{dto.deliveryTime},'%')
            </if>
            <if test="dto.receiveTime != null and dto.receiveTime != ''">
                and receive_time like CONCAT('%',#{dto.receiveTime},'%')
            </if>
            <if test="dto.commentTime != null and dto.commentTime != ''">
                and comment_time like CONCAT('%',#{dto.commentTime},'%')
            </if>
            <if test="dto.modifyTime != null and dto.modifyTime != ''">
                and modify_time like CONCAT('%',#{dto.modifyTime},'%')
            </if>
        </where>
    </select>

</mapper>
