<?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.xxfc.platform.order.mapper.BaseOrderMapper">

	<!-- 可根据自己的需求，是否要使用 -->
<!--    <resultMap type="com.xxfc.platform.order.entity.BaseOrder" id="baseOrderMap">-->
<!--        <result property="id" column="id"/>-->
<!--        <result property="no" column="no"/>-->
<!--        <result property="type" column="type"/>-->
<!--        <result property="detailId" column="detail_id"/>-->
<!--        <result property="status" column="status"/>-->
<!--        <result property="productAmount" column="product_amount"/>-->
<!--        <result property="orderAmount" column="order_amount"/>-->
<!--        <result property="detailJson" column="detail_json"/>-->
<!--        <result property="thirdType" column="third_type"/>-->
<!--        <result property="outTradeNo" column="out_trade_no"/>-->
<!--        <result property="crtTime" column="crt_time"/>-->
<!--        <result property="crtUser" column="crt_user"/>-->
<!--        <result property="crtName" column="crt_name"/>-->
<!--        <result property="crtHost" column="crt_host"/>-->
<!--        <result property="updTime" column="upd_time"/>-->
<!--        <result property="updUser" column="upd_user"/>-->
<!--        <result property="updName" column="upd_name"/>-->
<!--        <result property="updHost" column="upd_host"/>-->
<!--    </resultMap>-->

    <resultMap type="com.xxfc.platform.order.pojo.order.OrderPageVO" id="orderPageMap">
        <result javaType="Integer" column="type" property="type"></result>
        <discriminator javaType="Integer" column="type">
            <case value="1" resultType="com.xxfc.platform.order.pojo.order.OrderPageVO">
                <association column="detail_id" property="orderRentVehicleDetail" select="com.xxfc.platform.order.mapper.OrderRentVehicleDetailMapper.selectByPrimaryKey" javaType="com.xxfc.platform.order.entity.OrderRentVehicleDetail"></association>
            </case>
            <case value="2" resultType="com.xxfc.platform.order.pojo.order.OrderPageVO">
                <association column="detail_id" property="orderTourDetail" select="com.xxfc.platform.order.mapper.OrderTourDetailMapper.selectByPrimaryKey" javaType="com.xxfc.platform.order.entity.OrderTourDetail"></association>
            </case>
        </discriminator>
    </resultMap>
    
    <select id="pageByParm" parameterType="Map" resultMap="orderPageMap">
        select *
            from base_order
        <where>
            <if test="crtUser != null">
                and crt_user = #{crtUser}
            </if>
            <if test="status != null">
                and status = #{status}
            </if>
            <if test="no != null">
                and no = #{no}
            </if>
        </where>
        order by crt_time desc
    </select>

</mapper>