<?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.ruoyi.system.mapper.TaxiOrderMapper">
    
    <resultMap type="TaxiOrder" id="TaxiOrderResult">
        <result property="id"    column="id"    />
        <result property="ddId"    column="dd_id"    />
        <result property="userId"    column="user_id"    />
        <result property="driverId"    column="driver_id"    />
        <result property="boardingAddress"    column="boarding_address"    />
        <result property="intoLongitude"    column="into_longitude"    />
        <result property="intoLatitude"    column="into_latitude"    />
        <result property="downAddress"    column="down_address"    />
        <result property="downLongitude"    column="down_longitude"    />
        <result property="downLatitude"    column="down_latitude"    />
        <result property="distance"    column="distance"    />
        <result property="state"    column="state"    />
        <result property="taxiType"    column="taxi_type"    />
        <result property="releaseId"    column="release_id"    />
        <result property="orderTime"    column="order_time"    />
        <result property="boardingTime"    column="boarding_time"    />
        <result property="alightingTime"    column="alighting_time"    />
        <result property="appointmentTime"    column="appointment_time"    />
        <result property="fare"    column="fare"    />
        <result property="highwayCosts"    column="highway_costs"    />
        <result property="amount"    column="amount"    />
        <result property="estimatedDuration"    column="estimated_duration"    />
        <result property="notes"    column="notes"    />
        <result property="coupon"    column="coupon"    />
    </resultMap>

    <sql id="selectTaxiOrderVo">
        select id, dd_id, user_id, driver_id, boarding_address, into_longitude, into_latitude, down_address, down_longitude, down_latitude, distance, state, taxi_type, release_id, order_time, boarding_time, alighting_time, appointment_time, fare, highway_costs, amount, estimated_duration, notes, coupon from taxi_order
    </sql>

    <select id="selectTaxiOrderList" parameterType="TaxiOrder" resultMap="TaxiOrderResult">
        <include refid="selectTaxiOrderVo"/>
        <where>  
            <if test="ddId != null "> and dd_id = #{ddId}</if>
            <if test="orderTime != null "> and order_time = #{orderTime}</if>
        </where>
    </select>
    
    <select id="selectTaxiOrderById" parameterType="Long" resultMap="TaxiOrderResult">
        <include refid="selectTaxiOrderVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTaxiOrder" parameterType="TaxiOrder" useGeneratedKeys="true" keyProperty="id">
        insert into taxi_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="ddId != null">dd_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="driverId != null">driver_id,</if>
            <if test="boardingAddress != null">boarding_address,</if>
            <if test="intoLongitude != null">into_longitude,</if>
            <if test="intoLatitude != null">into_latitude,</if>
            <if test="downAddress != null">down_address,</if>
            <if test="downLongitude != null">down_longitude,</if>
            <if test="downLatitude != null">down_latitude,</if>
            <if test="distance != null">distance,</if>
            <if test="state != null">state,</if>
            <if test="taxiType != null">taxi_type,</if>
            <if test="releaseId != null">release_id,</if>
            <if test="orderTime != null">order_time,</if>
            <if test="boardingTime != null">boarding_time,</if>
            <if test="alightingTime != null">alighting_time,</if>
            <if test="appointmentTime != null">appointment_time,</if>
            <if test="fare != null">fare,</if>
            <if test="highwayCosts != null">highway_costs,</if>
            <if test="amount != null">amount,</if>
            <if test="estimatedDuration != null">estimated_duration,</if>
            <if test="notes != null">notes,</if>
            <if test="coupon != null">coupon,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="ddId != null">#{ddId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="driverId != null">#{driverId},</if>
            <if test="boardingAddress != null">#{boardingAddress},</if>
            <if test="intoLongitude != null">#{intoLongitude},</if>
            <if test="intoLatitude != null">#{intoLatitude},</if>
            <if test="downAddress != null">#{downAddress},</if>
            <if test="downLongitude != null">#{downLongitude},</if>
            <if test="downLatitude != null">#{downLatitude},</if>
            <if test="distance != null">#{distance},</if>
            <if test="state != null">#{state},</if>
            <if test="taxiType != null">#{taxiType},</if>
            <if test="releaseId != null">#{releaseId},</if>
            <if test="orderTime != null">#{orderTime},</if>
            <if test="boardingTime != null">#{boardingTime},</if>
            <if test="alightingTime != null">#{alightingTime},</if>
            <if test="appointmentTime != null">#{appointmentTime},</if>
            <if test="fare != null">#{fare},</if>
            <if test="highwayCosts != null">#{highwayCosts},</if>
            <if test="amount != null">#{amount},</if>
            <if test="estimatedDuration != null">#{estimatedDuration},</if>
            <if test="notes != null">#{notes},</if>
            <if test="coupon != null">#{coupon},</if>
         </trim>
    </insert>

    <update id="updateTaxiOrder" parameterType="TaxiOrder">
        update taxi_order
        <trim prefix="SET" suffixOverrides=",">
            <if test="ddId != null">dd_id = #{ddId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="driverId != null">driver_id = #{driverId},</if>
            <if test="boardingAddress != null">boarding_address = #{boardingAddress},</if>
            <if test="intoLongitude != null">into_longitude = #{intoLongitude},</if>
            <if test="intoLatitude != null">into_latitude = #{intoLatitude},</if>
            <if test="downAddress != null">down_address = #{downAddress},</if>
            <if test="downLongitude != null">down_longitude = #{downLongitude},</if>
            <if test="downLatitude != null">down_latitude = #{downLatitude},</if>
            <if test="distance != null">distance = #{distance},</if>
            <if test="state != null">state = #{state},</if>
            <if test="taxiType != null">taxi_type = #{taxiType},</if>
            <if test="releaseId != null">release_id = #{releaseId},</if>
            <if test="orderTime != null">order_time = #{orderTime},</if>
            <if test="boardingTime != null">boarding_time = #{boardingTime},</if>
            <if test="alightingTime != null">alighting_time = #{alightingTime},</if>
            <if test="appointmentTime != null">appointment_time = #{appointmentTime},</if>
            <if test="fare != null">fare = #{fare},</if>
            <if test="highwayCosts != null">highway_costs = #{highwayCosts},</if>
            <if test="amount != null">amount = #{amount},</if>
            <if test="estimatedDuration != null">estimated_duration = #{estimatedDuration},</if>
            <if test="notes != null">notes = #{notes},</if>
            <if test="coupon != null">coupon = #{coupon},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTaxiOrderById" parameterType="Long">
        delete from taxi_order where id = #{id}
    </delete>

    <delete id="deleteTaxiOrderByIds" parameterType="String">
        delete from taxi_order where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>