liujie
2025-08-08 f604df04d1f9fe90ee543a1772a3a8cdb50d3d66
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/shunfeng/dao/mapping/OrderRideMapper.xml
@@ -31,11 +31,12 @@
    </sql>
    <!--用户顺风车订单 type :1待处理的订单,2根据线路、时间,人数综合匹配排序 3按时间排序最早,4距离最近排序,5价格最高 and r.startTime>=now()-->
    <select id="getOrderRide" resultType="com.stylefeng.guns.modular.shunfeng.model.vo.OrderRideVo">
        select r.*,_fnGetDistance(#{lon},#{lat}, r.startLon, r.startLat)  as distance,u.headImg,u.sex,u.totalOrders,u.nickName as name,
        r.id as userOrderId,t.id as  driverOrderId from app_order_ride r
        select r.*,calculate_distance(#{lat},#{lon},r.startLat, r.startLon) as distance,u.avatar as headImg,u.sex,u.totalOrders,u.nickName as name,
        r.id as userOrderId,t.id as  driverOrderId, r.startLon as lon, r.startLat as lat
        from app_order_ride r
        left join app_order_travel t on r.travelId=t.id
        left join app_user_info u on r.userId=u.id
        left join app_user_info u1 on r.driverId=u1.driverId
        left join t_user u on r.userId=u.id
        left join t_user u1 on r.driverId=u1.driverId
        <where>
            <if test="userId!=null">
                and r.userId = #{userId}
@@ -51,13 +52,13 @@
            order by r.startTime desc
        </if>
        <if test="type==2">
            order by _fnGetDistance(#{lon},#{lat}, r.startLon, r.startLat) asc,r.startTime desc,(r.num-#{num}) asc
            order by calculate_distance(#{lat},#{lon},r.startLat, r.startLon) asc,r.startTime desc,(r.num-#{num}) asc
        </if>
        <if test="type==3">
            order by r.startTime asc
        </if>
        <if test="type==4">
            order by _fnGetDistance(#{lon},#{lat}, r.startLon, r.startLat) asc
            order by calculate_distance(#{lat},#{lon},r.startLat, r.startLon) asc
        </if>
        <if test="type==5">
            order by r.money desc
@@ -67,10 +68,10 @@
    <!--获取用户身份和司机身份的订单 只需要按照时间排序-->
    <select id="getOrderRideAndTravel" resultType="com.stylefeng.guns.modular.shunfeng.model.vo.OrderRideVo">
       select * from (
         select r.addTime,r.startTime,1 as type,r.state,r.startName,r.endName,r.userId,t.driverId,r.num,r.id as userOrderId,t.id as driverOrderId,r.money from app_order_ride r
         select r.addTime,r.startTime,1 as type,r.state,r.startName,r.endName,r.userId,t.driverId,r.num,r.id as userOrderId,t.id as driverOrderId,r.money, r.startLon as lon, r.startLat as lat from app_order_ride r
            left join app_order_travel t on r.travelId=t.id where r.userId=#{userId}
        UNION
        select t.addTime,t.startTime,2 as type,t.state,t.startName,t.endName,0,t.driverId,r.num,r.id as userOrderId,t.id as driverOrderId,0 as money  from app_order_travel t
        select t.addTime,t.startTime,2 as type,t.state,t.startName,t.endName,0,t.driverId,r.num,r.id as userOrderId,t.id as driverOrderId,0 as money, r.startLon as lon, r.startLat as lat  from app_order_travel t
            left join app_order_ride r on r.travelId=t.id where t.driverId=#{driverId}
        ) o
        order by o.addTime desc
@@ -79,12 +80,12 @@
    <!--获取订单详情-->
    <select id="getOrderInfo" resultType="com.stylefeng.guns.modular.shunfeng.model.vo.OrderRideInfoVo">
        select r.addTime,r.startTime,r.endName,r.startName,r.money,r.id as userOrderId,r.state,t.id as driverOrderId,r.isEvaluate,t.isComplaint,
        r.num,r.userId,r.driverId ,u.headImg,CASE  when r.isDai=1 then r.lxPhone else u.phone end as phone,u.sex,u.nickName as name,u.totalOrders,
        _fnGetDistance(#{lon},#{lat}, r.startLon, r.startLat) as distance
        r.num,r.userId,r.driverId ,u.avatar as headImg,CASE  when r.isDai=1 then r.lxPhone else u.phone end as phone,u.sex,u.nickName as name,u.totalOrders,
        calculate_distance(#{lat},#{lon},r.startLat, r.startLon) as distance,r.startLat as lat, r.startLon as lon
        from (select * from app_order_ride where id=#{userOrderId}) r
        left join app_order_travel t on r.travelId=t.id
        left join app_driver_ride d on d.id=r.driverId
        left join app_user_info u on r.userId=u.id
        left join t_user u on r.userId=u.id
    </select>
    <select id="queryMyOrderList" resultType="java.util.Map">