<?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.sckw.usual.mapper.KwOrderUsualLandTransportCirculateMapper">
    <select id="findCirculate" resultType="com.sckw.usual.entity.KwOrderUsualLandTransportCirculate" >
        select
            id, ent_id entId, order_id orderId, t_order_id tOrderId, type, truck_id truckId,
            truck_no truckNo, driver_id driverId, driver_name driverName, driver_phone driverPhone,
            driver_idcard driverIdcard, start_time startTime, end_time endTime, entrust_amount entrustAmount,
            remark, status, create_by createBy, create_time createTime, update_by updateBy, update_time updateTime
        from kw_order_usual_land_transport_circulate
        where del_flag = 0
          and order_id = #{lOrderId, jdbcType=BIGINT}
          and truck_id = #{truckId, jdbcType=BIGINT}
          and driver_id = #{driverId, jdbcType=BIGINT}
    </select>

    <update id="updateIdByKey">
        UPDATE kw_order_usual_land_transport_circulate
        set
            id = #{newId}, t_order_id = #{tOrderId},
            update_by = #{updateBy}, update_time = #{updateTime}
        WHERE id = #{id}
    </update>

    <select id="findCirculateList" resultType="com.sckw.usual.entity.KwOrderUsualLandTransportCirculate">
        select
        id, ent_id entId, order_id lOrderId, t_order_id wOrderId, type, truck_id truckId,
        truck_no truckNo, driver_id driverId, driver_name driverName, driver_phone driverPhone,
        driver_idcard driverIdcard, start_time startTime, end_time endTime, entrust_amount entrustAmount,
        remark, status, create_by createBy, create_time createTime, update_by updateBy, update_time updateTime
        from kw_order_usual_land_transport_circulate
        where del_flag = 0
        and order_id = #{lOrderId, jdbcType=BIGINT}
        <if test="truckId != null and truckId !=''">
            and truck_id = #{truckId, jdbcType=BIGINT}
        </if>
        <if test="driverId != null and driverId !=''">
            and driver_id = #{driverId, jdbcType=BIGINT}
        </if>
        <if test="status != null and status !=''">
            and status = #{status, jdbcType=INTEGER}
        </if>
    </select>
</mapper>