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

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.xxfc.platform.order.entity.ShuntApply" id="shuntApplyMap">
        <result property="id" column="id"/>
        <result property="status" column="status"/>
        <result property="crtTime" column="crt_time"/>
        <result property="crtUser" column="crt_user"/>
        <result property="userId" column="user_id"/>
        <result property="updUser" column="upd_user"/>
        <result property="updTime" column="upd_time"/>
        <result property="startCompanyId" column="start_company_id"/>
        <result property="endCompanyId" column="end_company_id"/>
        <result property="modelId" column="model_id"/>
        <result property="vehicleId" column="vehicle_id"/>
        <result property="startTime" column="start_time"/>
        <result property="endTime" column="end_time"/>
        <result property="orderId" column="order_id"/>
        <result property="orderNo" column="order_no"/>
        <result property="startCompanyName" column="start_company_name"/>
        <result property="endCompanyName" column="end_company_name"/>
    </resultMap>

    <select id="pageList" resultType="com.xxfc.platform.order.entity.ShuntApply">
        select *
            from shunt_apply

            <where>
                is_del = 0
                <if test="userId != null">
                    and user_id = #{userId}
                </if>
                <if test="pageStatus != null">
                    <if test="pageStatus == 1">
                        and status = 1
                    </if>
                    <if test="pageStatus == 2">
                        and ((status = 4 and order_status = 1) or status = 3)
                    </if>
                    <if test="pageStatus == 3">
                        and status = 4 and order_status = 2
                    </if>
                    <if test="pageStatus == 4">
                        and status in (2, 501, 502, 503, 504)
                    </if>
                </if>
            </where>

            order by crt_time desc
    </select>

</mapper>