<?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.kxs.product.biz.mapper.KxsShopOrderMapper">

    <resultMap type="com.kxs.product.api.model.KxsShopOrder" id="KxsShopOrderMap">
        <result column="id" property="id"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="del_flag" property="delFlag"/>
        <result column="version" property="version"/>
        <result column="order_sn" property="orderSn"/>
        <result column="user_id" property="userId"/>
        <result column="get_mode" property="getMode"/>
        <result column="pay_type" property="payType"/>
        <result column="pay_time" property="payTime"/>
        <result column="send_time" property="sendTime"/>
        <result column="remark" property="remark"/>
        <result column="consignee" property="consignee"/>
        <result column="phone" property="phone"/>
        <result column="address" property="address"/>
        <result column="expressage_sn" property="expressageSn"/>
        <result column="expressage_name" property="expressageName"/>
        <result column="status" property="status"/>
        <result column="return_status" property="returnStatus"/>
        <result column="return_time" property="returnTime"/>
        <result column="total_price" property="totalPrice"/>
        <result column="pay_price" property="payPrice"/>
        <result column="trade_no" property="tradeNo"/>
        <result column="warehouse_id" property="warehouseId"/>
        <result column="order_type" property="orderType"/>

    </resultMap>
    <!-- kxs app 订单列表分页 map -->
    <resultMap type="com.kxs.product.api.vo.kxsapp.shop.ShopOrderListVO" id="KxsShopOrderPageMap">
        <result column="id" property="id"/>
        <result column="create_time" property="createTime"/>
        <result column="status" property="status"/>
        <result column="return_status" property="returnStatus"/>
        <result column="total_price" property="totalPrice"/>
        <result column="pay_price" property="payPrice"/>
        <result column="order_sn" property="orderSn"/>
        <collection property="goodsList" ofType="com.kxs.product.api.vo.kxsapp.shop.ShopOrderInfoListVO">
            <result column="number" property="number"/>
            <result column="goods_price" property="goodsPrice"/>
            <result column="pic_url" property="picUrl"/>
            <result column="goods_name" property="goodsName"/>
            <result column="specifications" property="specifications"/>
        </collection>
    </resultMap>

    <select id="getByPage" resultMap="KxsShopOrderPageMap">
        SELECT a.id, a.create_time, a.order_sn, a.status, a.return_status, a.total_price, a.pay_price, a.warehouse_id, a.order_type,
               t.number, t.goods_price, t.pic_url, t.goods_name, t.specifications
        FROM (
                SELECT * FROM kxs_shop_order
                <where>
                    del_flag = 0
                    <if test="query.status != null">
                        and status = #{query.status}
                    </if>
                </where>
                LIMIT #{start}, #{size}
             ) a
        LEFT JOIN kxs_shop_order_info t  ON a.id = t.order_id
        <where>

        </where>
    </select>

</mapper>
