huliguo
2025-07-03 e3a2245265516fef78b4737d6fffc939e7c5e0af
pt-errand/src/main/resources/mapper/OrderMapper.xml
@@ -11,19 +11,22 @@
            o.recipient_phone,
            o.order_status,
            o.order_time,
            o.rating,
            e.rating,
            o.courier_id,
            c.name,
            c.phone
            c.name courierName,
            c.phone courierPhone
            from t_order o
            left join t_courier c on o.courier_id = c.id
            left join t_courier c on c.id = o.courier_id
            left join t_evaluation e on o.id = e.order_id and e.type =0
            where
                o.del_flag=0
              and o.order_status != 3
              and o.pay_status=2
              and o.app_user_id = #{appUserId}
              <if test="orderStatus!=null and orderStatus!=0">
                  and o.order_status = #{orderStatus}
              </if>
        order by o.order_time desc
    </select>
    <select id="getOrderDetail" resultType="com.ruoyi.errand.object.vo.app.OrderDetailVO">
        select
@@ -43,17 +46,20 @@
            o.order_time as orderTime,
            o.pay_method as payMethod,
            o.payment_amount as paymentAmount,
            c.courier_name as courierName,
            c.courier_phone as courierPhone,
            c.name as courierName,
            c.phone as courierPhone,
            e.id as evaluationId,
            e.rating as rating,
            e.content as content
            e.content as content,
            e2.rating as courierRating,
            e2.content as courierContent
            from t_order o
        left join t_courier c on o.courier_id = c.id
        left join t_evaluation e on o.id = e.order_id
        left join t_evaluation e on o.id = e.order_id and e.type = 0
        left join t_evaluation e2 on o.id = e2.order_id and e2.type = 1
        where
            o.id=#{id}
            and o.del_flag=0
            and e.type = 0
    </select>
    <select id="getOrderTopInfoByDate" resultType="java.util.Map">
@@ -64,10 +70,11 @@
            t_order
        where
            del_flag=0
          and pay_status = 2
        and
            order_status in (4,5)
        <if test="communityId!=null and communityId!=0">
            and communityId =#{communityId}
            and community_id =#{communityId}
        </if>
        <if test="start!=null and end!=null">
            and order_time BETWEEN #{start} AND #{end}
@@ -89,7 +96,10 @@
            COALESCE(SUM(payment_amount), 0.00) AS amount
        FROM t_order
        WHERE order_time BETWEEN #{start} AND #{end}
          and del_flag=0 and order_status in (4,5)
          and del_flag=0 and order_status in (4,5)and pay_status = 2
        <if test="communityId!=null and 0!= communityId">
            and community_id =#{communityId}
        </if>
        GROUP BY
            CASE #{datePattern}
                WHEN 'HH时' THEN DATE_FORMAT(order_time, '%H时')
@@ -140,15 +150,12 @@
                and tau.phone like concat('%',#{dto.phone},'%')
            </if>
        <if test="dto.orderStatus!=null and 0!=dto.orderStatus and dto.orderStatus !=4">
        <if test="dto.orderStatus!=null and 0!=dto.orderStatus ">
            and t.order_status = #{dto.orderStatus}
        </if>
        <if test="dto.orderStatus ==4">
            and t.order_status in(4,5)
        <if test="dto.startTime!=null and dto.endTime != null">
            and t.order_time between #{dto.startTime} and #{dto.endTime}
        </if>
            <if test="dto.startTime!=null and dto.endTime != null">
                and t.order_time between #{dto.startTime} and #{dto.endTime}
            </if>
        ) t
        where
            1=1
@@ -161,8 +168,10 @@
    <select id="financeStatistics" resultType="com.ruoyi.errand.object.vo.sys.FinanceStatisticsVO">
        select * from (
                SELECT t.id as id,
                       t.order_amount as money,
                       t.order_time as orderTime,
                       1 as type,
                        t.pay_method as payMethod,
                       t.order_number as orderNumber,
                       tau.name as appUserName,
                       tau.phone as phone,
@@ -180,41 +189,45 @@
                <if test="dto.orderStatus!=null and 0!=dto.orderStatus and dto.orderStatus !=4">
                    and t.order_status = #{dto.orderStatus}
                </if>
        <if test="dto.orderStatus ==4">
            and t.order_status in(4,5)
        </if>
                <if test="dto.startTime!=null and dto.endTime != null">
                    and t.order_time between #{dto.startTime} and #{dto.endTime}
                </if>
            UNION ALL
                SELECT t.id as id,
                t.order_time as orderTime,
                2 as type,
                t.order_number as orderNumber,
                tau.name as appUserName,
                tau.phone as phone,
                t.order_status as orderStatus
                FROM t_vip_order t
                INNER JOIN t_app_user tau ON t.app_user_id = tau.id
                WHERE t.del_flag=0
        and t.pay_status=2
                <if test="dto.appUserName!=null and  ''!=dto.appUserName">
                    and tau.name like concat('%',#{dto.appUserName},'%')
                </if>
                <if test="dto.phone!=null and  ''!=dto.phone">
                    and tau.phone like concat('%',#{dto.phone},'%')
                </if>
                <if test="dto.orderStatus!=null and 0!=dto.orderStatus and dto.orderStatus !=4">
                    and t.order_status = #{dto.orderStatus}
                </if>
                <if test="dto.orderStatus ==4">
                    and t.order_status in(4,5)
                </if>
                <if test="dto.startTime!=null and dto.endTime != null">
                    and t.order_time between #{dto.startTime} and #{dto.endTime}
                </if>
                <if test="dto.payMethod!=null">
                    and t.pay_method = #{dto.payMethod}
                </if>
                <if test="dto.payMethod==null || dto.payMethod==0">
                UNION ALL
                    SELECT t.id as id,
                       t.order_amount as money,
                        t.order_time as orderTime,
                        2 as type,
                        0 as payMethod,
                        t.order_number as orderNumber,
                        tau.name as appUserName,
                        tau.phone as phone,
                        t.order_status as orderStatus
                    FROM t_vip_order t
                    INNER JOIN t_app_user tau ON t.app_user_id = tau.id
                    WHERE t.del_flag=0
                        and t.pay_status=2
                    <if test="dto.appUserName!=null and  ''!=dto.appUserName">
                            and tau.name like concat('%',#{dto.appUserName},'%')
                    </if>
                    <if test="dto.phone!=null and  ''!=dto.phone">
                            and tau.phone like concat('%',#{dto.phone},'%')
                    </if>
                    <if test="dto.orderStatus!=null and 0!=dto.orderStatus ">
                            and t.order_status = #{dto.orderStatus}
                    </if>
                    <if test="dto.startTime!=null and dto.endTime != null">
                        and t.order_time between #{dto.startTime} and #{dto.endTime}
                    </if>
                </if>
                ) t
            where
@@ -266,14 +279,13 @@
            and o.order_time between #{dto.orderStartTime} and #{dto.orderEndTime}
        </if>
        <if test="dto.finishStartTime!=null and dto.finishEndTime != null">
            and o.finishTime between #{dto.finishStartTime} and #{dto.finishEndTime}
            and o.finish_time between #{dto.finishStartTime} and #{dto.finishEndTime}
        </if>
        <if test="dto.orderStatus!=null and 0!=dto.orderStatus and dto.orderStatus !=4">
        <if test="dto.orderStatus!=null and 0!=dto.orderStatus">
            and o.order_status = #{dto.orderStatus}
        </if>
        <if test="dto.orderStatus ==4">
            and o.order_status in(4,5)
        </if>
        order by o.order_time desc
    </select>
    <select id="detail" resultType="com.ruoyi.errand.object.vo.sys.OrderSysDetailVO">
        select
@@ -303,7 +315,7 @@
        inner join t_app_user tau on o.app_user_id = tau.id
        left join t_courier tc on o.courier_id = tc.id
        left join t_evaluation teu on o.id = teu.order_id and teu.type=0
        left join t_evaluation tec on o.id = teu.order_id and teu.type=1
        left join t_evaluation tec on o.id = tec.order_id and tec.type=1
        where
            o.id=#{id}
    </select>
@@ -311,7 +323,9 @@
        select * from (
        SELECT t.id as id,
        t.order_time as orderTime,
        t.order_amount as money,
        1 as type,
        t.pay_method as payMethod,
        t.order_number as orderNumber,
        tau.name as appUserName,
        tau.phone as phone,
@@ -335,10 +349,17 @@
        <if test="dto.startTime!=null and dto.endTime != null">
            and t.order_time between #{dto.startTime} and #{dto.endTime}
        </if>
        <if test="dto.payMethod!=null">
            and t.pay_method = #{dto.payMethod}
        </if>
        <if test="dto.payMethod==null || dto.payMethod==0">
        UNION ALL
        SELECT t.id as id,
        t.order_time as orderTime,
        t.order_amount as money,
        2 as type,
        0 as payMethod,
        t.order_number as orderNumber,
        tau.name as appUserName,
        tau.phone as phone,
@@ -355,15 +376,14 @@
            and tau.phone like concat('%',#{dto.phone},'%')
        </if>
        <if test="dto.orderStatus!=null and 0!=dto.orderStatus and dto.orderStatus !=4">
        <if test="dto.orderStatus!=null and 0!=dto.orderStatus ">
            and t.order_status = #{dto.orderStatus}
        </if>
        <if test="dto.orderStatus ==4">
            and t.order_status in(4,5)
        </if>
        <if test="dto.startTime!=null and dto.endTime != null">
            and t.order_time between #{dto.startTime} and #{dto.endTime}
        </if>
        </if>
        ) t
        where
@@ -414,7 +434,7 @@
            and o.order_time between #{dto.orderStartTime} and #{dto.orderEndTime}
        </if>
        <if test="dto.finishStartTime!=null and dto.finishEndTime != null">
            and o.finishTime between #{dto.finishStartTime} and #{dto.finishEndTime}
            and o.finish_time between #{dto.finishStartTime} and #{dto.finishEndTime}
        </if>
        <if test="dto.orderStatus!=null and 0!=dto.orderStatus and dto.orderStatus !=4">
            and o.order_status = #{dto.orderStatus}
@@ -422,5 +442,6 @@
        <if test="dto.orderStatus ==4">
            and o.order_status in(4,5)
        </if>
        order by o.order_time desc
    </select>
</mapper>