<?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.jumeirah.common.mapper.StrokeMapper">

    <!-- 分页列表查询结果列 -->
    <sql id="Page_Column_List">
        s.id,
        city_outset_id,
        city_outset_name,
        city_arrive_id,
        city_arrive_name,
        people_mun,
        plain_type_id,
        outset_time,
        return_time,
        type,
        STATUS,
        money,
        user_id,
        mu.username AS merchantName,
        outset_airport_name,arrive_airport_name,arrive_plain_type_id,back_outset_airport_name,back_arrive_airport_name

   </sql>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, city_outset_id, deleted, city_outset_name, city_arrive_id, city_arrive_name, people_mun, plain_type_id, outset_time, return_time, type, status, create_time, update_time, goods_name, goods_size, goods_weight, disease_name, instruments, medical_persons, remarks, money, user_id
        ,outset_airport_name,arrive_airport_name,arrive_plain_type_id,back_outset_airport_name,back_arrive_airport_name,payment_status,audit_status
    </sql>

    <select id="getStrokeById" resultType="com.jumeirah.common.vo.StrokeDetailVo">
        select
        <include refid="Base_Column_List"/>
        from stroke where id = #{id}
    </select>

    <select id="getStrokePageList" parameterType="com.jumeirah.common.param.StrokePageParam"
            resultType="com.jumeirah.common.vo.StrokeQueryVo">
        select
        <include refid="Page_Column_List"/>
        from stroke s
        INNER JOIN merchant_user mu ON mu.id = s.mc_id
        <where>
            and s.user_id = #{userId}
            and s.deleted = 0

            <if test="param.status != -1">
                -- 查询全部 = -1
                and s.`status` = #{param.status}
            </if>
        </where>
    </select>

</mapper>
