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

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        sd.id,
        sd.city_outset_id,
        sd.city_arrive_id,
        sd.seat_num,
        sd.plain_type_id,
        sd.outset_time,
        sd.return_time,
        sd.status,
        sd.create_time,
        sd.update_time,
        sd.remarks,
        sd.money,
        sd.mc_id,
        sd.type
    </sql>

    <select id="getStrokeDiscountById" resultType="com.jumeirah.common.vo.StrokeDiscountQueryVo">
        select
            ctco.city_name_cn as city_outset_name,
            ctca.city_name_cn as city_arrive_name,
            pt.name as plain_type_name,
            <include refid="Base_Column_List"/>
        from stroke_discount sd
            INNER JOIN city_three_code ctco ON ctco.id = sd.city_outset_id
            INNER JOIN city_three_code ctca ON ctca.id = sd.city_arrive_id
            INNER JOIN plain_type pt ON pt.id = sd.plain_type_id
        where sd.id = #{id}
    </select>

    <select id="getStrokeDiscountPageList" parameterType="com.jumeirah.common.param.StrokeDiscountPageParam"
            resultType="com.jumeirah.common.vo.StrokeDiscountQueryVo">
        select
            ctco.city_name_cn as city_outset_name,
            ctca.city_name_cn as city_arrive_name,
            pt.name as plain_type_name,
            <include refid="Base_Column_List"/>
        from stroke_discount sd
        INNER JOIN city_three_code ctco ON ctco.id = sd.city_outset_id
        INNER JOIN city_three_code ctca ON ctca.id = sd.city_arrive_id
        INNER JOIN plain_type pt ON pt.id = sd.plain_type_id
        where sd.mc_id = #{mcId}
    </select>

    <select id="getAppStrokeDiscountPageList" parameterType="com.jumeirah.common.param.StrokeDiscountPageParam"
            resultType="com.jumeirah.common.vo.StrokeDiscountQueryVo">
        select
            ctco.city_name_cn as city_outset_name,
            ctca.city_name_cn as city_arrive_name,
            pt.name as plain_type_name,
            <include refid="Base_Column_List"/>
        from stroke_discount sd
        INNER JOIN city_three_code ctco ON ctco.id = sd.city_outset_id
        INNER JOIN city_three_code ctca ON ctca.id = sd.city_arrive_id
        INNER JOIN plain_type pt ON pt.id = sd.plain_type_id
        where sd.status = 0
            and sd.seat_num &gt; 0
    </select>

</mapper>
