<?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.qs.mp.user.mapper.UserDeliverOrderItemMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.qs.mp.user.domain.UserDeliverOrderItem">
        <id column="item_id" property="itemId" />
        <result column="order_id" property="orderId" />
        <result column="storage_id" property="storageId" />
        <result column="goods_id" property="goodsId" />
        <result column="sku_id" property="skuId" />
        <result column="properties" property="properties" />
        <result column="title" property="title" />
        <result column="pic_url" property="picUrl" />
        <result column="goods_num" property="goodsNum" />
        <result column="delivery_id" property="deliveryId" />
        <result column="delivery_flow_id" property="deliveryFlowId" />
        <result column="delivery_time" property="deliveryTime" />
        <result column="created_time" property="createdTime" />
        <result column="updated_time" property="updatedTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        item_id, order_id, storage_id, goods_id, sku_id, properties, title, pic_url, goods_num, delivery_id, delivery_flow_id, delivery_time, created_time, updated_time
    </sql>
    
    
    <!-- 查询用户提货物流清单列表 -->
    <select id="selectOrderDeliverItemVOList" resultType="com.qs.mp.user.domain.vo.OrderDeliverItemVO">
		select DISTINCT t1.delivery_id , t1.delivery_flow_id, t1.delivery_time, t2.company_name ,t2.company_home_url ,t2.query_url
		from mp_user_deliver_order_item t1
		left join mp_delivery_company t2 on t1.delivery_id = t2.delivery_id
		where t1.order_id = #{orderId} and t1.delivery_time is not null
	</select>
	
	 <!-- 查询用户订单明细列表 -->
    <select id="selectUserDeliverOrderItemVOList" resultType="com.qs.mp.user.domain.vo.UserDeliverOrderItemVO">
		select t1.*, t2.company_name ,t2.company_home_url ,t2.query_url,t3.goods_code,t3.value goodsValue,t3.cost goodsCost,t4.value skuValue,t4.sku_code,t5.name supplierName
		from mp_user_deliver_order_item t1
		left join mp_delivery_company t2 on t1.delivery_id = t2.delivery_id
        left join mp_goods t3 on t1.goods_id = t3.goods_id
        LEFT JOIN mp_goods_sku t4 on t1.sku_id = t4.sku_id
        LEFT JOIN mp_supplier t5 on t1.supplier_id = t5.id
		where t1.order_id = #{orderId}
	</select>

    <select id="selectUserDeliverOrderItemVOListByQueryWrapper"
            resultType="com.qs.mp.user.domain.vo.UserDeliverOrderItemVO">
        select t1.*, t2.company_name ,t2.company_home_url ,t2.query_url,t3.goods_code,t3.value goodsValue,t3.cost goodsCost,t4.value skuValue,t4.cost skuCost,t4.sku_code,t5.name supplierName
        from mp_user_deliver_order_item t1
        left join mp_delivery_company t2 on t1.delivery_id = t2.delivery_id
        left join mp_goods t3 on t1.goods_id = t3.goods_id
        LEFT JOIN mp_goods_sku t4 on t1.sku_id = t4.sku_id
        LEFT JOIN mp_supplier t5 on t1.supplier_id = t5.id
        ${ew.customSqlSegment}
    </select>
</mapper>
