yanghb
2023-04-21 e52227b01983146f2e3c81dc575141d8b9889497
DriverTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/dao/mapping/OrderPrivateCarMapper.xml
@@ -46,7 +46,6 @@
        <result column="longDistanceMoney" property="longDistanceMoney"/>
        <result column="parkMoney" property="parkMoney"/>
        <result column="roadTollMoney" property="roadTollMoney"/>
        <result column="holidayFee" property="holidayFee"/>
        <result column="redPacketMoney" property="redPacketMoney"/>
        <result column="couponMoney" property="couponMoney"/>
        <result column="redPacketId" property="redPacketId"/>
@@ -56,7 +55,6 @@
        <result column="activityId" property="activityId"/>
        <result column="companyId" property="companyId"/>
        <result column="payMoney" property="payMoney"/>
        <result column="thankYouFee" property="thankYouFee"/>
        <result column="substitute" property="substitute"/>
        <result column="passengers" property="passengers"/>
        <result column="passengersPhone" property="passengersPhone"/>
@@ -70,6 +68,7 @@
        <result column="endServiceTime" property="endServiceTime"/>
        <result column="orderType" property="orderType"/>
        <result column="orderSource" property="orderSource"/>
        <result column="deviceCode" property="deviceCode"/>
        <result column="invoiceId" property="invoiceId"/>
        <result column="isReassign" property="isReassign"/>
        <result column="reassignNotice" property="reassignNotice"/>
@@ -87,17 +86,14 @@
            select
            id as id,
            (1) as type,
            ('快车订单') as `name`,
            ('专车订单') as `name`,
            DATE_FORMAT(travelTime, '%Y-%m-%d %H:%i:%s') as time,
            startAddress as startAddress,
            endAddress as endAddress,
            state as state,
            orderType as reservation,
            rideType as rideType,
            spellSuccess,
            totalPeopleNum as peopleNumber,
            driverId as driverId
            from t_order_private_car where 1 = 1  and pid is null
            from t_order_private_car where 1 = 1
            <if test="null != driverId">
                and driverId = #{driverId}
            </if>
@@ -108,134 +104,35 @@
            select
            id as id,
            (1) as type,
            ('快车订单') as `name`,
            ('专车订单') as `name`,
            DATE_FORMAT(travelTime, '%Y-%m-%d %H:%i:%s') as time,
            startAddress as startAddress,
            endAddress as endAddress,
            state as state,
            orderType as reservation,
            rideType as rideType,
            spellSuccess,
            totalPeopleNum as peopleNumber,
            driverId as driverId
            from t_order_private_car where 1 = 1 and pid is null
            from t_order_private_car where 1 = 1
            <if test="null != driverId">
                and driverId = #{driverId}
            </if>
            and state in (3, 4, 5, 6, 11)
            UNION ALL
            select
            id as id,
            (1) as type,
            ('快车订单') as `name`,
            DATE_FORMAT(travelTime, '%Y-%m-%d %H:%i:%s') as time,
            startAddress as startAddress,
            endAddress as endAddress,
            state as state,
            orderType as reservation,
            rideType as rideType,
            spellSuccess,
            totalPeopleNum as peopleNumber,
            driverId as driverId
            from t_order_private_car where 1 = 1  and pid is not null
            <if test="null != driverId">
                and driverId = #{driverId}
            </if>
            and pid not in (
            select
            GROUP_CONCAT(id)
            from t_order_private_car where 1 = 1  and pid is null
            <if test="null != driverId">
                and driverId = #{driverId}
            </if>
            and state = 2 and (UNIX_TIMESTAMP(travelTime) - UNIX_TIMESTAMP(now())) &lt; 1800
            )
            and state = 2 and (UNIX_TIMESTAMP(travelTime) - UNIX_TIMESTAMP(now())) &lt; 1800  group by pid
            UNION ALL
            select
            id as id,
            (1) as type,
            ('快车订单') as `name`,
            DATE_FORMAT(travelTime, '%Y-%m-%d %H:%i:%s') as time,
            startAddress as startAddress,
            endAddress as endAddress,
            state as state,
            orderType as reservation,
            rideType as rideType,
            spellSuccess,
            totalPeopleNum as peopleNumber,
            driverId as driverId
            from t_order_private_car where 1 = 1 and pid is not null
            <if test="null != driverId">
                and driverId = #{driverId}
            </if>
            and pid not in (
            select
            GROUP_CONCAT(id)
            from t_order_private_car where 1 = 1 and pid is null
            <if test="null != driverId">
                and driverId = #{driverId}
            </if>
            and state in (3, 4, 5, 6, 11)
            )
            and state in (3, 4, 5, 6, 11)  group by pid
        </if>
        <if test="state == 2">
            select
            id as id,
            (1) as type,
            ('快车订单') as `name`,
            ('专车订单') as `name`,
            DATE_FORMAT(travelTime, '%Y-%m-%d %H:%i:%s') as time,
            startAddress as startAddress,
            endAddress as endAddress,
            state as state,
            orderType as reservation,
            rideType as rideType,
            spellSuccess,
            totalPeopleNum as peopleNumber,
            driverId as driverId
            from t_order_private_car where 1 = 1  and pid is null
            from t_order_private_car where 1 = 1
            <if test="null != driverId">
                and driverId = #{driverId}
            </if>
            and state = 2 and (UNIX_TIMESTAMP(travelTime) - UNIX_TIMESTAMP(now())) &gt;= 1800
            UNION ALL
            select
            id as id,
            (1) as type,
            ('快车订单') as `name`,
            DATE_FORMAT(travelTime, '%Y-%m-%d %H:%i:%s') as time,
            startAddress as startAddress,
            endAddress as endAddress,
            state as state,
            orderType as reservation,
            rideType as rideType,
            spellSuccess,
            totalPeopleNum as peopleNumber,
            driverId as driverId
            from t_order_private_car where 1 = 1  and pid is not null
            <if test="null != driverId">
                and driverId = #{driverId}
            </if>
            and pid not in (
                select
                  GROUP_CONCAT(id)
                from t_order_private_car where 1 = 1  and pid is null
                <if test="null != driverId">
                    and driverId = #{driverId}
                </if>
                and state = 2 and (UNIX_TIMESTAMP(travelTime) - UNIX_TIMESTAMP(now())) &gt;= 1800
            )
            and state = 2 and (UNIX_TIMESTAMP(travelTime) - UNIX_TIMESTAMP(now())) &gt;= 1800 group by pid
        </if>
    </select>
@@ -246,14 +143,11 @@
        select
        id as id,
        (1) as type,
        ('快车订单') as `name`,
        ('专车订单') as `name`,
        DATE_FORMAT(travelTime, '%Y-%m-%d %H:%i:%s') as time,
        startAddress as startAddress,
        endAddress as endAddress,
        state as state,
        peopleNum as peopleNumber,
        rideType as rideType,
        spellSuccess,
        orderType as reservation,
        orderMoney as orderMoney,
        payManner as payManner,
@@ -281,7 +175,7 @@
        select
        id as orderId,
        state as orderState,
        ('快车订单') as orderName,
        ('专车订单') as orderName,
        DATE_FORMAT(travelTime, '%m月%d日 %H:%i') as travelTime,
        startAddress as startAddress,
        endAddress as endAddress,
@@ -294,59 +188,12 @@
        orderSource as orderSource,
        orderType as orderType,
        isReassign as isReassign,
      rideType as rideType,
        spellSuccess,
        peopleNum as peopleNumber,
        companyId as companyId
        from t_order_private_car where id = #{orderId}
    </select>
    <select id="queryOrderInfo2" resultType="map">
        select
        a.id as orderId,
        a.userId as userId,
        a.driverId as driverId,
        a.state as orderState,
        DATE_FORMAT(a.travelTime, '%m月%d日 %H:%i') as travelTime_,
        DATE_FORMAT(a.travelTime, '%Y-%m-%d %H:%i:%s') as travelTime,
        DATE_FORMAT(a.arriveTime, '%Y-%m-%d %H:%i:%s') as arriveTime,
        a.startAddress as startAddress,
        a.endAddress as endAddress,
        a.startLon as startLon,
        a.startLat as startLat,
        a.endLon as endLon,
        a.endLat as endLat,
        a.orderMoney as orderMoney,
        a.payManner as payManner,
        a.thankYouFee,
        a.trackId as trackId,
        b.nickName as nickName,
        a.passengersPhone as phone,
        a.orderType as reservation,
        a.telX as telX,
        a.peopleNum as peopleNumber,
        a.rideType as rideType,
        a.spellSuccess as spellSuccess,
        a.bindId as bindId,
        (
        (select count(id) from t_order_private_car where userId = b.id and state in (8, 9)) +
        (select count(id) from t_order_taxi where userId = b.id and state in (8, 9)) +
        (select count(id) from t_order_cross_city where userId = b.id and state in (8, 9))
        ) as historyNum,
        (select phone from t_phone where companyId = a.companyId and `type` = 1) as emergencyCall,
        c.reason as cancelReason,
        c.remark as cancelRemark,
        c.money as cancelPayMoney,
        if(c.userType = 1, '用户取消', '平台取消') as cancelUser,
        (select isSpecialCar from t_sys_reformist where companyId = a.companyId) as reassign
        from t_order_private_car a
        left join t_user b on (a.userId = b.id)
        left join t_order_cancel c on (a.id = c.orderId and c.orderType = 1 and c.state = 2)
        where a.id = #{orderId}
    </select>
    <select id="queryOrderInfo" resultType="map">
        select
        a.id as orderId,
@@ -364,14 +211,11 @@
        a.endLat as endLat,
        a.orderMoney as orderMoney,
        a.payManner as payManner,
        a.thankYouFee,
        a.trackId as trackId,
        b.nickName as nickName,
        a.passengersPhone as phone,
        a.orderType as reservation,
        a.telX as telX,
        a.peopleNum as peopleNumber,
        a.rideType as rideType,
        a.bindId as bindId,
        (
        (select count(id) from t_order_private_car where userId = b.id and state in (8, 9)) +
@@ -387,39 +231,7 @@
        from t_order_private_car a
        left join t_user b on (a.userId = b.id)
        left join t_order_cancel c on (a.id = c.orderId and c.orderType = 1 and c.state = 2)
        where (a.id = #{orderId} or a.pid=#{orderId})
        <if test="state==4">
            and (a.state=2 or a.state=3 or a.state=4 )
            order by a.insertTime
        </if>
        <if test="state==5">
            and a.state=5
            order by ROUND(
            6378.138 * 2 * ASIN(
            SQRT(
            POW(
            SIN((
            #{lat} * PI()/ 180-endLat * PI()/ 180
            )/ 2
            ),
            2
            )+ COS( #{lat} * PI()/ 180 )* COS( endLat * PI()/ 180 )* POW(
            SIN((
            #{lon} * PI()/ 180-endLon * PI()/ 180
            )/ 2
            ),
            2
            )))* 1000
            ) asc
        </if>
        <if test="state!=4 and state!=5">
            and a.state!=2
            and a.state!=3
            and a.state!=4
            and a.state!=5
            order by a.endServiceTime
        </if>
        where a.id = #{orderId}
    </select>
@@ -655,11 +467,6 @@
        telX as telX,
        bindId as bindId
        from t_order_private_car where  orderType = 2 and state = 2 and (UNIX_TIMESTAMP(travelTime) - UNIX_TIMESTAMP(now())) between 1710 and 1800
    </select>
    <select id="taskMidAxbUnBindSend" resultType="OrderPrivateCar">
        select * from t_order_private_car where (state in (8, 9) and telX != '' and telX is not null and (UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(endServiceTime)) > 1800) or (state = 10 and telX != '' and telX is not null)
    </select>
</mapper>