<?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.xxfc.platform.order.mapper.OrderAccountMapper">
    <select id="getOrderAccountByOrderType" resultType="com.xxfc.platform.order.pojo.account.OrderAccountDTO">
        SELECT
        date(DATE_SUB(now(),interval #{day} day)) as oneDay,
        a.*
        <if test="type != null and type == 1">
            , v.start_company_id as companyId
        </if>
        <if test="type != null and type == 2">
            , t.start_company_id as companyId
        </if>
        FROM
        order_account a
        LEFT JOIN base_order b ON a.order_id = b.id
        <if test="type != null and type==1">
            LEFT JOIN order_rent_vehicle_detail v ON b.id = v.order_id
        </if>
        <if test="type != null and type==2">
            LEFT JOIN order_tour_detail t ON b.id = t.order_id
        </if>
        WHERE
        a.account_status=1
        AND
        b.type = #{type}
        AND date( FROM_UNIXTIME( a.crt_time / 1000 ) ) = date( DATE_SUB( now( ), INTERVAL #{day} DAY ) )
    </select>
</mapper>