<?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="org.springblade.modules.app.mapper.TransportMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="org.springblade.modules.app.entity.TransportDO">
        <result column="id" property="id" />
        <result column="version" property="version" />
        <result column="is_deleted" property="isDeleted" />
        <result column="created_time" property="createdTime" />
        <result column="creator" property="creator" />
        <result column="modified_time" property="modifiedTime" />
        <result column="modifier" property="modifier" />
        <result column="waybill_id" property="waybillId" />
        <result column="waybill_name" property="waybillName" />
        <result column="waybill_out_code" property="waybillOutCode" />
        <result column="state" property="state" />
        <result column="accept_state" property="acceptState" />
        <result column="code" property="code" />
        <result column="slaughter_house_id" property="slaughterHouseId" />
        <result column="driver_user_id" property="driverUserId" />
        <result column="driver_user_name" property="driverUserName" />
        <result column="driver_vehicle_code" property="driverVehicleCode" />
        <result column="driver_transport_permit_code" property="driverTransportPermitCode" />
        <result column="driver_phone" property="driverPhone" />
        <result column="saler_prov_id" property="salerProvId" />
        <result column="saler_city_id" property="salerCityId" />
        <result column="saler_area_id" property="salerAreaId" />
        <result column="saler_user_address" property="salerUserAddress" />
        <result column="saler_user_id" property="salerUserId" />
        <result column="agent_user_id" property="agentUserId" />
        <result column="agent_user_name" property="agentUserName" />
        <result column="saler_user_name" property="salerUserName" />
        <result column="saler_user_link_man" property="salerUserLinkMan" />
        <result column="saler_phone" property="salerPhone" />
        <result column="buyer_prov_id" property="buyerProvId" />
        <result column="buyer_user_id" property="buyerUserId" />
        <result column="buyer_user_name" property="buyerUserName" />
        <result column="buyer_city_id" property="buyerCityId" />
        <result column="buyer_area_id" property="buyerAreaId" />
        <result column="buyer_user_address" property="buyerUserAddress" />
        <result column="buyer_user_link_man" property="buyerUserLinkMan" />
        <result column="buyer_phone" property="buyerPhone" />
        <result column="price_type" property="priceType" />
        <result column="front_price" property="frontPrice" />
        <result column="price" property="price" />
        <result column="exp_type" property="expType" />
        <result column="verify_id" property="verifyId" />
        <result column="verify_name" property="verifyName" />
        <result column="verify_address" property="verifyAddress" />
        <result column="verify_result_info" property="verifyResultInfo" />
        <result column="submit_time" property="submitTime" />
        <result column="finish_time" property="finishTime" />
        <result column="remark" property="remark" />
        <result column="confirm_time" property="confirmTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,
        version,
        is_deleted,
        created_time,
        creator,
        modified_time,
        modifier,
        waybill_id, waybill_name, waybill_out_code, code, state, slaughter_house_id, driver_user_id, driver_user_name, driver_vehicle_code, driver_transport_permit_code, driver_phone, saler_prov_id, saler_city_id, saler_area_id, saler_user_id, saler_user_address, saler_user_link_man, saler_phone, buyer_user_id, buyer_prov_id, buyer_city_id, buyer_area_id, buyer_user_address, buyer_user_link_man, buyer_phone, price_type, front_price, price, verify_id, verify_name, verify_addressremark, expType, confirm_time,agent_user_id,
        agent_user_name,saler_user_name,buyer_user_name,accept_state,exp_type,verify_result_info,submit_time,finish_time
    </sql>
    <select id="queryAutoCloseData" resultType="org.springblade.modules.app.common.dto.TransportDTO">
        select t.* from tb_transport t
          left join tb_waybill w on w.id=t.waybill_id
          left join tb_transport_stage_info f on f.transport_id=t.id and f.stage=3
        where
          NOW() > date_add(w.plan_time,INTERVAL 48 HOUR)
          and t.state between 0 and 2
          and f.id is null
    </select>

</mapper>
