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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.qs.mp.user.domain.UserDeliverOrder">
        <id column="order_id" property="orderId" />
        <result column="user_id" property="userId" />
        <result column="receiver" property="receiver" />
        <result column="tel" property="tel" />
        <result column="province" property="province" />
        <result column="city" property="city" />
        <result column="area" property="area" />
        <result column="address" property="address" />
        <result column="order_num" property="orderNum" />
        <result column="pay_amt" property="payAmt" />
        <result column="freight_amt" property="freightAmt" />
        <result column="memo" property="memo" />
        <result column="status" property="status" />
        <result column="created_time" property="createdTime" />
        <result column="updated_time" property="updatedTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        order_id, user_id, receiver, tel, province, city, area, address, order_num, pay_amt, freight_amt, memo, status, created_time, updated_time
    </sql>
    
    
    <!-- 查询用户提货订单列表 -->
    <select id="selectUserDeliverOrderVoList" resultType="com.qs.mp.user.domain.vo.UserDeliverOrderVO">
		select DISTINCT t1.* , t2.nick_name nickName
		from mp_user_deliver_order t1
		left join sys_user t2 on t1.user_id = t2.user_id
		left join mp_user_deliver_order_item t3 on t1.order_id = t3.order_id
		${ew.customSqlSegment}
	</select>
	
	    
    <!-- 查询满足筛选条件的用户提货订单数量 -->
    <select id="selectUserDeliverOrderCount" resultType="integer">
		select count(DISTINCT t1.order_id) 
		from mp_user_deliver_order t1
		left join sys_user t2 on t1.user_id = t2.user_id
		left join mp_user_deliver_order_item t3 on t1.order_id = t3.order_id
		${ew.customSqlSegment}
	</select>
	
	 <!-- 查询用户提货订单列表 -->
    <select id="selectUserDeliverOrderVo" resultType="com.qs.mp.user.domain.vo.UserDeliverOrderVO">
		select t1.* , t2.nick_name nickName
		from mp_user_deliver_order t1
		left join sys_user t2 on t1.user_id = t2.user_id
		where t1.order_id = #{orderId}
	</select>
	
	

</mapper>
