<?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.pz.system.mapper.StoreOrderMapper">

    <resultMap type="com.pz.system.domain.StoreOrder" id="StoreOrderResult">
        <result property="id" column="id"/>
        <result property="storeId" column="store_id"/>
        <result property="orderId" column="order_id"/>
        <result property="goodsId" column="goods_id"/>
        <result property="num" column="num"/>
        <result property="addressId" column="address_id"/>
        <result property="status" column="status"/>
        <result property="overTime" column="over_time"/>
        <result property="voucher" column="voucher"/>
        <result property="logistics" column="logistics"/>
        <result property="logisticsCode" column="logistics_code"/>
        <result property="refundLogistics" column="refund_logistics"/>
        <result property="refundLogisticsCode" column="refund_logistics_code"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="delFlag" column="del_flag"/>
    </resultMap>
    <select id="findStoreAdminOrderVoPage" resultType="com.pz.system.domain.vo.StoreAdminOrderVo">
        SELECT
        so.id as id,
        c.NAME AS cityName,
        sg.title AS title,
        so.num AS num,
        tao.pay_money payMoney,
        si.name AS sName,
        su.user_name AS userName,
        so.`status` AS orderStatus,
        so.create_time AS createTime,
        tao.status as toStatus,
        so.address_id addressId,
        so.logistics logistics,
        so.logistics_code logisticsCode,
        so.refund_logistics refundLogistics,
        so.refund_logistics_code refundLogisticsCode,
        tao.refund_reason as refundReason
        FROM
        store_order AS so
        LEFT JOIN total_order AS tao ON tao.id = so.order_id
        LEFT JOIN city AS c ON c.id = tao.city_id
        LEFT JOIN store_info AS si ON si.id = so.store_id
        LEFT JOIN store_goods AS sg ON sg.id = so.goods_id
        LEFT JOIN sys_user AS su ON su.user_id = tao.uid
        <where>
            <if test="bo.title != null and bo.title != ''">
                and sg.title LIKE CONCAT('%', #{bo.title}, '%')
            </if>
            <if test="bo.storeId != null">
                and so.store_id = #{bo.storeId}
            </if>
        </where>
    </select>
    <select id="selectSonOrderInfoByTotalId" resultType="com.pz.merchant.domain.vo.SonOrderVo">
        select s.id as sonOrderId, s.status as orderStatus from store_order s where s.order_id = #{totalId}
    </select>


</mapper>