<?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.njzscloud.supervisory.order.mapper.OrderInfoMapper">

    <sql id="base_select">
        SELECT a.id,
        a.sn,
        a.station_id,
        a.lane_id,
        a.project_id,
        a.traffic_company_id,
        a.user_id,
        a.audit_status,
        a.audit_memo,
        a.order_category,
        a.order_status,
        a.checker_id,
        a.check_status,
        a.truck_id,
        a.driver_id,
        a.goods_id,
        a.discount_money,
        a.revise_money,
        a.settle_money,
        a.payer,
        a.payer_category,
        a.payment_status,
        a.payment_time,
        a.customer_memo,
        a.checker_memo,
        a.cargo_photo,
        a.check_photo,
        a.creator_id,
        a.modifier_id,
        a.create_time,
        a.modify_time,
        a.deleted,
        a.cargo_place_id,
        a.car_in_out_id,

        b.province,
        b.city,
        b.area,
        b.town,
        b.province_name,
        b.city_name,
        b.area_name,
        b.town_name,
        b.address,
        b.lng,
        b.lat,

        c.goods_category_id,
        c.origin_goods_id,
        c.goods_name,
        c.unit_price,
        c.unit,
        c.money_strategy,
        c.money_config_id,
        c.picture,
        c.tax_rate,
        c.quantity,
        c.total_money,

        d.rough_weight,
        d.tare_weight,
        d.settle_weight,
        d.in_front_photo,
        d.in_body_photo,
        d.out_front_photo,
        d.out_body_photo,
        d.in_time,
        d.out_time,


        e.license_plate,
        e.truck_license,
        e.vn_code,
        e.qualification,
        e.carrying_capacity,
        e.tare_weight history_tare_weight,
        e.audit_status,
        e.audit_memo,

        f.driver_name,
        f.phone driver_phone,
        f.driving_licence,
        f.licence_start_time,
        f.licence_end_time,

        g.uscc tarffic_company_uscc,
        g.company_name tarffic_company_company_name,
        g.business_license tarffic_company_business_license,
        g.license_start_time tarffic_company_license_start_time,
        g.license_end_time tarffic_company_license_end_time,
        g.legal_representative tarffic_company_legal_representative,
        g.province tarffic_company_province,
        g.city tarffic_company_city,
        g.area tarffic_company_area,
        g.town tarffic_company_town,
        g.province_name tarffic_company_province_name,
        g.city_name tarffic_company_city_name,
        g.area_name tarffic_company_area_name,
        g.town_name tarffic_company_town_name,
        g.address tarffic_company_address,
        g.lng tarffic_company_lng,
        g.lat tarffic_company_lat,
        g.contacts tarffic_company_contacts,
        g.phone tarffic_company_phone,
        h.nickname,
        h.phone

        FROM order_info a
        INNER JOIN order_cargo_place b ON b.id = a.cargo_place_id
        INNER JOIN order_goods c ON c.id = a.goods_id
        INNER JOIN order_car_in_out d ON d.id = a.car_in_out_id
        INNER JOIN biz_truck e ON e.id = a.truck_id
        INNER JOIN biz_driver f ON f.id = a.driver_id
        INNER JOIN biz_company g ON g.id = a.traffic_company_id
        INNER JOIN sys_user h ON h.id = a.user_id
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
        </if>
    </sql>
    <select id="paging" resultType="com.njzscloud.supervisory.order.pojo.result.OrderPagingResult">
        <include refid="base_select"/>
    </select>
    <select id="detail" resultType="com.njzscloud.supervisory.order.pojo.result.OrderPagingResult">
        <include refid="base_select"/>
    </select>
</mapper>
