huliguo
2025-07-29 ef8cf60d8a9c33098e2e7be51bd4f0d6db6c0693
ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
@@ -567,7 +567,7 @@
        </if>
        ORDER BY toc.create_time DESC
    </select>
<!-- todo 统计-->
    <select id="totalOrderFirst" resultType="com.ruoyi.order.domain.vo.MgtOrderTotal">
        SELECT
        COUNT(temp.order_id) orderTotal,
@@ -730,7 +730,8 @@
        toc.receivable_money receivableMoney,
        toc.create_time createTime,
        toc.pay_money payMoney,
        CASE WHEN toc.unbinding_flag = 0 THEN toc.shop_id WHEN toc.unbinding_flag = 1 AND toc.order_from = 1 THEN toc.shop_id WHEN toc.order_status = 3 THEN toc.shop_id ELSE NULL END shopId,
--         CASE WHEN toc.unbinding_flag = 0 THEN toc.shop_id WHEN toc.unbinding_flag = 1 AND toc.order_from = 1 THEN toc.shop_id WHEN toc.order_status = 3 THEN toc.shop_id ELSE NULL END shopId,
        toc.shop_id shopId,
        toc.use_time verifyTime,
        CASE toc.order_from
            WHEN 1 THEN '小程序'
@@ -746,6 +747,9 @@
        WHERE toc.del_flag = 0 AND toc.order_from != 2  -- 不查找秒杀活动的订单
        <if test="param.orderStatus != null">
            AND toc.order_status = #{param.orderStatus}
        </if>
        <if test="param.orderFrom != null">
            and toc.order_from = #{param.orderFrom}
        </if>
        <if test="param.goodsType != null and param.goodsType !=''">
            AND tog.goods_type = #{param.goodsType}
@@ -1196,7 +1200,7 @@
        COUNT(order_id) orderTotal,
        IFNULL(SUM(CASE WHEN order_from = 1 THEN 1 ELSE 0 END),0) onlineTotal,
        IFNULL(SUM(CASE WHEN order_from = 3 THEN 1 ELSE 0 END),0) offlineTotal,
            IFNULL(SUM(CASE WHEN order_from = 2 THEN 1 ELSE 0 END),0) activityTotal,
        IFNULL(SUM(CASE WHEN order_from = 2 THEN 1 ELSE 0 END),0) activityTotal,
        IFNULL(SUM(CASE WHEN order_from = 5 THEN 1 ELSE 0 END),0) meituan,
        IFNULL(SUM(CASE WHEN order_from = 5 THEN receivable_money ELSE 0 END),0) meituanAmount,
        IFNULL(SUM(CASE WHEN order_from = 6 THEN 1 ELSE 0 END),0) douyin,
@@ -1213,6 +1217,9 @@
            <foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="param.">
            and order_from = #{param.}
        </if>
        <if test="param.startDate!=null and param.startDate!=''">
            AND Date(create_time) &gt;= #{param.startDate}
@@ -1324,7 +1331,6 @@
        WHEN 1 THEN "商城订单"
        WHEN 2 THEN "秒杀订单"
        WHEN 3 THEN "线下订单"
--             other
        END mapKey,
        IFNULL(SUM(CASE WHEN pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) + online_pay_money ELSE 0 END),0) mapValue
        FROM t_order toc
@@ -2245,11 +2251,11 @@
        <if test="param.createTimeEnd != null and param.createTimeEnd != ''">
            AND Date(toc.create_time) &lt;= #{param.createTimeEnd}
        </if>
        <if test="param.verifyStartTime != null and param.verifyStartTime != ''">
            AND Date(toc.use_time) &gt;= #{param.verifyStartTime}
        <if test="param.useTimeBegin != null and param.useTimeBegin != ''">
            AND Date(toc.use_time) &gt;= #{param.useTimeBegin}
        </if>
        <if test="param.verifyEndTime != null and param.verifyEndTime != ''">
            AND Date(toc.use_time) &lt;= #{param.verifyEndTime}
        <if test="param.useTimeEnd != null and param.useTimeEnd != ''">
            AND Date(toc.use_time) &lt;= #{param.useTimeEnd}
        </if>
        ORDER BY toc.create_time DESC
    </select>
@@ -2284,4 +2290,41 @@
            and create_time between #{param.startTime} and #{param.endTime}
        </if>
    </select>
    <select id="totalOrderFour" resultType="com.ruoyi.order.domain.vo.MgtOrderTotal">
        SELECT
        COUNT(temp.order_id) thirdOrderTotal,
        IFNULL(SUM( temp.receivable_money ),0) thirdOrderMoneyTotal,
        IFNULL(SUM(temp.pay_money),0) thirdPayMoneyTotal,
        IFNULL(SUM(CASE WHEN (temp.receivable_money ) &gt; temp.pay_money THEN ( temp.receivable_money ) - temp.pay_money ELSE 0 END),0)thirdUnPayMoneyTotal
        FROM
        (SELECT toc.order_id,toc.receivable_money,toc.pay_money
        FROM t_order toc
        INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
        WHERE toc.del_flag = 0 AND toc.order_from in (5,6,7)
        <if test="param.orderStatus != null">
            AND toc.order_status = #{param.orderStatus}
        </if>
        <if test="param.goodsType != null and param.goodsType !=''">
            AND tog.goods_type = #{param.goodsType}
        </if>
        <!--<if test="param.shopId != null and param.shopId != ''">-->
        <!--AND toc.shop_id = #{param.shopId}-->
        <!--</if>-->
        <if test="param.shopId != null and param.shopId != ''">
            AND toc.shop_id = #{param.shopId} AND (toc.unbinding_flag = 0 OR (toc.unbinding_flag = 1 AND toc.order_from in (5,6,7)) OR (toc.unbinding_flag = 1 AND toc.order_from in (5,6,7) AND toc.order_status = 3))
        </if>
        <if test="param.shopIds != null and param.shopIds != ''">
            and toc.order_status = 3 AND FIND_IN_SET(toc.shop_id, #{param.shopIds}) &gt; 0
        </if>
        <if test="param.keyword != null and param.keyword != ''">
            AND (toc.order_no LIKE CONCAT('%',#{param.keyword},'%') OR toc.activity_name LIKE CONCAT('%',#{param.keyword},'%') OR FIND_IN_SET(toc.user_id, #{param.userIds}) &gt; 0)
        </if>
        <if test="param.useTimeBegin != null and param.useTimeBegin != ''">
            AND Date(toc.use_time) &gt;= #{param.verifyStartTime}
        </if>
        <if test="param.verifyEndTime != null and param.verifyEndTime != ''">
            AND Date(toc.use_time) &lt;= #{param.verifyEndTime}
        </if>
        GROUP BY toc.order_id) AS temp
    </select>
</mapper>