yanghb
2023-04-21 0481353111afb43a2322e18530dde26f1d841ead
ManagementTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TOrderLogisticsMapper.xml
@@ -119,7 +119,7 @@
        order by o.id desc
    </select>
    <!--根据快车订单ID获取小件物流订单详情-->
    <!--根据专车订单ID获取小件物流订单详情-->
    <select id="getLogisticsOrderDetailById" resultType="map">
        SELECT
        DATE_FORMAT(ot.insertTime,'%Y-%m-%d %H:%i') as insertTimeStr,
@@ -143,112 +143,4 @@
        where ot.id = #{orderId}
    </select>
    <select id="getTimeOutOrderList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
        SELECT
            l.id,
            l.type,
            timeOutMoney,
            endServiceTime,d.phone,d.`name`,
            (SELECT sum(money) FROM t_income WHERE userType=1 AND incomeId=l.id AND orderType=l.type and type = 7)-ifnull(a.returnMoney,0) companyMoney,
        a.createTime,
        ifnull(a.returnMoney,0) returnMoney
        FROM
            t_order_logistics l
        LEFT JOIN t_driver d ON l.driverId=d.id
        LEFT JOIN t_timeout_appeal a ON a.orderId=l.id AND a.state=2
        WHERE
            l.timeOutMoney > 0
            AND l.isDelete = 1 and d.companyId=#{companyId}
        <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
            AND (
            (l.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
            or
            (a.createTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
            )
        </if>
        <if test="phone != null and phone != ''">
            and d.phone  LIKE CONCAT('%',#{phone},'%')
        </if>
        <if test="name != null and name != ''">
            and d.name  LIKE CONCAT('%',#{name},'%')
        </if>
        <if test="id != null and id != ''">
            and l.id  LIKE CONCAT('%',#{id},'%')
        </if>
        <if test="null != orderType">
            and l.type = #{orderType}
        </if>
        order by l.insertTime desc
    </select>
    <select id="getTimeOutOrderListEx" resultType="map">
        SELECT
        l.id,
        l.type,
        timeOutMoney,
        endServiceTime,d.phone,d.`name`,
        (SELECT sum(money) FROM t_income WHERE userType=1 AND incomeId=l.id AND orderType=l.type and type = 7)-ifnull(a.returnMoney,0) companyMoney,
        a.createTime,
        ifnull(a.returnMoney,0) returnMoney
        FROM
        t_order_logistics l
        LEFT JOIN t_driver d ON l.driverId=d.id
        LEFT JOIN t_timeout_appeal a ON a.orderId=l.id AND a.state=2
        WHERE
        l.timeOutMoney > 0
        AND l.isDelete = 1  and d.companyId=#{companyId}
        <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
            AND (
            (l.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
            or
            (a.createTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
            )
        </if>
        <if test="phone != null and phone != ''">
            and d.phone  LIKE CONCAT('%',#{phone},'%')
        </if>
        <if test="name != null and name != ''">
            and d.name  LIKE CONCAT('%',#{name},'%')
        </if>
        <if test="id != null and id != ''">
            and l.id  LIKE CONCAT('%',#{id},'%')
        </if>
        <if test="null != orderType">
            and l.type = #{orderType}
        </if>
        order by l.insertTime desc
    </select>
    <select id="getTimeOutOrderSumMoney" resultType="map">
        SELECT
        IFNULL(SUM(timeOutMoney),0) timeOutMoney,
        IFNULL(SUM(a.returnMoney),0) returnMoney
        FROM
        t_order_logistics l
        LEFT JOIN t_driver d ON l.driverId=d.id
        LEFT JOIN t_timeout_appeal a ON a.orderId=l.id AND a.state=2
        WHERE
        l.timeOutMoney > 0
        AND l.isDelete = 1
        <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
            AND (
            (l.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
            or
            (a.createTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
            )
        </if>
        <if test="phone != null and phone != ''">
            and d.phone  LIKE CONCAT('%',#{phone},'%')
        </if>
        <if test="name != null and name != ''">
            and d.name  LIKE CONCAT('%',#{name},'%')
        </if>
        <if test="id != null and id != ''">
            and l.id  LIKE CONCAT('%',#{id},'%')
        </if>
        <if test="null != orderType">
            and l.type = #{orderType}
        </if>
    </select>
</mapper>