bug
jiangqs
2023-08-27 db6083bc5e2446a62c208e1d9c93671c111da8ba
ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
@@ -748,11 +748,11 @@
        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(order_money),0) orderMoney,
        IFNULL(SUM(CASE WHEN order_from = 1 THEN order_money ELSE 0 END),0) onlineMoney,
        IFNULL(SUM(CASE WHEN order_from = 3 THEN order_money ELSE 0 END),0) offlineMoney,
        IFNULL(SUM(CASE WHEN order_from = 2 THEN order_money ELSE 0 END),0) activityMoney
        FROM t_order WHERE del_flag = 0
        IFNULL(SUM(change_receivable_money),0) orderMoney,
        IFNULL(SUM(CASE WHEN order_from = 1 THEN change_receivable_money ELSE 0 END),0) onlineMoney,
        IFNULL(SUM(CASE WHEN order_from = 3 THEN change_receivable_money ELSE 0 END),0) offlineMoney,
        IFNULL(SUM(CASE WHEN order_from = 2 THEN change_receivable_money ELSE 0 END),0) activityMoney
        FROM t_order WHERE del_flag = 0 AND order_status = 3
        <if test="param.shopId != null and param.shopId != ''">
            AND shop_id = #{param.shopId}
        </if>
@@ -818,43 +818,49 @@
        SELECT
            DATE_FORMAT(create_time, '%Y-%m-%d') AS mapKey,
            COUNT(order_id) AS mapValueFirst,
            IFNULL(SUM(order_money),0) AS mapValueSecond
        FROM
            t_order
        WHERE
            del_flag = 0
          AND Date(create_time) >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
            IFNULL(SUM(CASE WHEN pay_type = 1 THEN change_receivable_money WHEN pay_type = 2 THEN change_receivable_money + online_pay_money ELSE 0 END),0) AS mapValueSecond
        FROM t_order
        WHERE del_flag = 0 AND order_status IN (2,3)
        <if test="param.shopId != null and param.shopId != ''">
            AND shop_id = #{param.shopId}
        </if>
        GROUP BY
        DATE_FORMAT(create_time, '%Y-%m-%d')
        ORDER BY
        DATE_FORMAT(create_time, '%Y-%m-%d') ASC
        <if test="param.startDate!=null and param.startDate!=''">
            AND Date(create_time) &gt;= #{param.startDate}
        </if>
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(create_time) &lt;= #{param.endDate}
        </if>
        GROUP BY mapKey
        ORDER BY mapKey ASC
    </select>
    <select id="listTotalOrderTotalGoodsType" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
        SELECT
        tog.goods_type mapKey,
        COUNT(DISTINCT toc.order_id) AS mapValueFirst,
        IFNULL(SUM(tog.goods_total_money),0) AS mapValueSecond
        FROM
        t_order toc
        IFNULL(SUM(tog.goods_receivable_money),0) AS mapValueSecond
        FROM t_order toc
        INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
        WHERE toc.del_flag = 0
        WHERE toc.del_flag = 0 AND toc.order_status IN (2,3)
        <if test="param.shopId != null and param.shopId != ''">
            AND toc.shop_id = #{param.shopId}
        </if>
        GROUP BY tog.goods_type
        <if test="param.startDate!=null and param.startDate!=''">
            AND Date(toc.create_time) &gt;= #{param.startDate}
        </if>
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(toc.create_time) &lt;= #{param.endDate}
        </if>
        GROUP BY mapKey
    </select>
    <select id="listTotalOrderTotalGoodsRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
        SELECT
        tog.goods_name mapKey,
        IFNULL(SUM(tog.goods_total_money),0) mapValue
        IFNULL(SUM(tog.goods_receivable_money),0) mapValue
        FROM t_order toc
        INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
        WHERE toc.del_flag = 0
        WHERE toc.del_flag = 0 AND toc.order_status = 3
        <if test="param.shopId != null and param.shopId != ''">
            AND toc.shop_id = #{param.shopId}
        </if>
@@ -875,9 +881,9 @@
        WHEN 2 THEN "秒杀活动订单"
        WHEN 3 THEN "线下创建订单"
        END mapKey,
        IFNULL(SUM(toc.order_money),0) mapValue
        IFNULL(SUM(CASE WHEN toc.pay_type = 1 THEN toc.change_receivable_money WHEN toc.pay_type = 2 THEN toc.change_receivable_money + toc.online_pay_money ELSE 0 END),0) mapValue
        FROM t_order toc
        WHERE toc.del_flag = 0
        WHERE toc.del_flag = 0 AND toc.order_status IN (2,3)
        <if test="param.shopId != null and param.shopId != ''">
            AND toc.shop_id = #{param.shopId}
        </if>
@@ -919,6 +925,12 @@
        WHERE toc.del_flag = 0 AND order_from = 2
        <if test="param.shopId != null and param.shopId != ''">
            AND toc.shop_id = #{param.shopId}
        </if>
        <if test="param.startDate!=null and param.startDate!=''">
            AND Date(toc.create_time) &gt;= #{param.startDate}
        </if>
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(toc.create_time) &lt;= #{param.endDate}
        </if>
        GROUP BY tog.goods_type
    </select>
@@ -1129,11 +1141,11 @@
        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(order_money),0) orderMoney,
        IFNULL(SUM(CASE WHEN order_from = 1 THEN order_money ELSE 0 END),0) onlineMoney,
        IFNULL(SUM(CASE WHEN order_from = 3 THEN order_money ELSE 0 END),0) offlineMoney,
        IFNULL(SUM(CASE WHEN order_from = 2 THEN order_money ELSE 0 END),0) activityMoney
        FROM t_order WHERE del_flag = 0
        IFNULL(SUM(change_receivable_money),0) orderMoney,
        IFNULL(SUM(CASE WHEN order_from = 1 THEN change_receivable_money ELSE 0 END),0) onlineMoney,
        IFNULL(SUM(CASE WHEN order_from = 3 THEN change_receivable_money ELSE 0 END),0) offlineMoney,
        IFNULL(SUM(CASE WHEN order_from = 2 THEN change_receivable_money ELSE 0 END),0) activityMoney
        FROM t_order WHERE del_flag = 0 AND order_status = 3
        <if test="param.shopIdList != null and param.shopIdList.size() > 0">
            AND shop_id IN
            <foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
@@ -1177,22 +1189,24 @@
        SELECT
        DATE_FORMAT(create_time, '%Y-%m-%d') AS mapKey,
        COUNT(order_id) AS mapValueFirst,
        IFNULL(SUM(order_money),0) AS mapValueSecond
        IFNULL(SUM(receivable_money),0) AS mapValueSecond
        FROM
        t_order
        WHERE
        del_flag = 0
        AND Date(create_time) >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
        WHERE del_flag = 0 AND order_status = 3
        <if test="param.startDate!=null and param.startDate!=''">
            AND Date(create_time) &gt;= #{param.startDate}
        </if>
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(create_time) &lt;= #{param.endDate}
        </if>
        <if test="param.shopIdList != null and param.shopIdList.size() > 0">
            AND shop_id IN
            <foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        GROUP BY
        DATE_FORMAT(create_time, '%Y-%m-%d')
        ORDER BY
        DATE_FORMAT(create_time, '%Y-%m-%d') ASC
        GROUP BY mapKey
        ORDER BY mapKey ASC
    </select>
    <select id="listPlTotalOrderTotalGoodsType" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
@@ -1203,7 +1217,7 @@
        FROM
        t_order toc
        INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
        WHERE toc.del_flag = 0
        WHERE toc.del_flag = 0 AND toc.order_status IN (2,3)
        <if test="param.shopIdList != null and param.shopIdList.size() > 0">
            AND toc.shop_id IN
            <foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
@@ -1216,11 +1230,10 @@
    <select id="listPlTotalOrderTotalGoodsRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
        SELECT
        tog.goods_name mapKey,
        IFNULL(SUM(tog.goods_receivable_money),0) mapValue,
        COUNT(DISTINCT toc.order_id) mapTotalValue
        IFNULL(SUM(tog.goods_receivable_money),0) mapValue
        FROM t_order toc
        INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
        WHERE toc.del_flag = 0
        WHERE toc.del_flag = 0 AND order_status = 3
        <if test="param.shopIdList != null and param.shopIdList.size() > 0">
            AND toc.shop_id IN
            <foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
@@ -1233,8 +1246,8 @@
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(toc.create_time) &lt;= #{param.endDate}
        </if>
        GROUP BY tog.goods_name
        ORDER BY SUM(tog.goods_total_money) DESC LIMIT 10
        GROUP BY mapKey
        ORDER BY mapValue DESC LIMIT 15
    </select>
    <select id="listPlTotalOrderTotalOrderFrom" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
@@ -1246,7 +1259,7 @@
        END mapKey,
        IFNULL(SUM(toc.order_money),0) mapValue
        FROM t_order toc
        WHERE toc.del_flag = 0
        WHERE toc.del_flag = 0 AND order_status = 3
        <if test="param.shopIdList != null and param.shopIdList.size() > 0">
            AND toc.shop_id IN
            <foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
@@ -1260,7 +1273,7 @@
            AND Date(toc.create_time) &lt;= #{param.endDate}
        </if>
        GROUP BY toc.order_from
        ORDER BY SUM(toc.order_money) DESC LIMIT 10
        ORDER BY SUM(toc.order_money) DESC LIMIT 15
    </select>
    <select id="getPlTotalActivityTotal" resultType="com.ruoyi.order.domain.vo.MgtPlTotalActivityTotalVo">
@@ -1274,6 +1287,9 @@
            <foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="param.activityId!=null and param.activityId!=''">
            AND toc.activity_id = #{param.activityId}
        </if>
        <if test="param.startDate!=null and param.startDate!=''">
            AND Date(create_time) &gt;= #{param.startDate}
@@ -1291,7 +1307,7 @@
        COUNT(DISTINCT CASE WHEN tog.goods_type = 3 THEN toc.user_id ELSE NULL END) servicePerson
        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 = 2 AND toc.order_status = 3 AND toc.new_member_flag = 1
        WHERE toc.del_flag = 0 AND toc.order_from = 2 AND toc.order_status IN (2,3) AND toc.new_member_flag = 1
        <if test="param.shopIdList != null and param.shopIdList.size() > 0">
            AND toc.shop_id IN
            <foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
@@ -1345,10 +1361,10 @@
            </foreach>
        </if>
        <if test="param.startDate!=null and param.startDate!=''">
            AND Date(create_time) &gt;= #{param.startDate}
            AND Date(toc.create_time) &gt;= #{param.startDate}
        </if>
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(create_time) &lt;= #{param.endDate}
            AND Date(toc.create_time) &lt;= #{param.endDate}
        </if>
        GROUP BY tog.goods_type
    </select>
@@ -1360,17 +1376,20 @@
        IFNULL(SUM(CASE WHEN pay_type = 1 THEN change_receivable_money WHEN pay_type = 2 THEN change_receivable_money + online_pay_money ELSE 0 END),0) AS mapValueSecond
        FROM t_order
        WHERE del_flag = 0 AND order_from = 2 AND order_status = 3
        AND Date(create_time) >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
        <if test="param.startDate!=null and param.startDate!=''">
            AND Date(create_time) &gt;= #{param.startDate}
        </if>
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(create_time) &lt;= #{param.endDate}
        </if>
        <if test="param.shopIdList != null and param.shopIdList.size() > 0">
            AND shop_id IN
            <foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        GROUP BY
        DATE_FORMAT(create_time, '%Y-%m-%d')
        ORDER BY
        DATE_FORMAT(create_time, '%Y-%m-%d') ASC
        GROUP BY mapKey
        ORDER BY mapKey ASC
    </select>
    <select id="getPlUserIdAgeRank" resultType="java.lang.Long">
@@ -1407,9 +1426,9 @@
            </foreach>
        </if>
        GROUP BY
        DATE_FORMAT(create_time, '%Y-%m-%d')
        mapKey
        ORDER BY
        DATE_FORMAT(create_time, '%Y-%m-%d') ASC
        mapValue ASC
    </select>
    <select id="listPlTotalShopActivityRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
@@ -1430,32 +1449,16 @@
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(create_time) &lt;= #{param.endDate}
        </if>
        GROUP BY shop_id
        ORDER BY COUNT(order_id) DESC LIMIT 15
        GROUP BY mapKey
        ORDER BY mapValue DESC LIMIT 15
    </select>
    <select id="listPlTotalShopActivitySalesRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
        SELECT
            shop_id AS mapKey,
            IFNULL(SUM(order_money),0) AS mapValue
        shop_id AS mapKey,
        IFNULL(SUM(CASE WHEN pay_type = 1 THEN change_receivable_money WHEN pay_type = 2 THEN change_receivable_money+online_pay_money ELSE 0 END),0) AS mapValue
        FROM t_order
        WHERE del_flag = 0 AND order_from = 2
        <if test="param.shopIdList != null and param.shopIdList.size() > 0">
            AND shop_id IN
            <foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        GROUP BY shop_id
        ORDER BY SUM(order_money) DESC LIMIT 15
    </select>
    <select id="listPlTotalActivitySalesRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
        SELECT
        activity_name AS mapKey,
        IFNULL(SUM(order_money),0) AS mapValue
        FROM t_order
        WHERE del_flag = 0 AND order_from = 2
        WHERE del_flag = 0 AND order_from = 2 AND order_status IN (2,3)
        <if test="param.shopIdList != null and param.shopIdList.size() > 0">
            AND shop_id IN
            <foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
@@ -1468,8 +1471,30 @@
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(create_time) &lt;= #{param.endDate}
        </if>
        GROUP BY activity_name
        ORDER BY SUM(order_money) DESC LIMIT 15
        GROUP BY mapKey
        ORDER BY mapValue DESC LIMIT 15
    </select>
    <select id="listPlTotalActivitySalesRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
        SELECT
        activity_name AS mapKey,
        IFNULL(SUM(CASE WHEN pay_type = 1 THEN change_receivable_money WHEN pay_type = 2 THEN change_receivable_money+online_pay_money ELSE 0 END),0) AS mapValue
        FROM t_order
        WHERE del_flag = 0 AND order_from = 2 AND order_status IN (2,3)
        <if test="param.shopIdList != null and param.shopIdList.size() > 0">
            AND shop_id IN
            <foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="param.startDate!=null and param.startDate!=''">
            AND Date(create_time) &gt;= #{param.startDate}
        </if>
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(create_time) &lt;= #{param.endDate}
        </if>
        GROUP BY mapKey
        ORDER BY mapValue DESC LIMIT 15
    </select>
    <select id="getMerHomeShopTotalVo" resultType="com.ruoyi.system.api.domain.vo.MerHomeShopTotalVo">
@@ -1558,7 +1583,7 @@
                #{item}
            </foreach>
        </if>
        AND toc.create_time >= DATE_SUB(CURDATE(), INTERVAL 5 DAY)
        AND toc.create_time >= DATE_SUB(CURDATE(), INTERVAL 4 DAY)
        GROUP BY mapKey
    </select>
@@ -1812,7 +1837,7 @@
        <if test="param.activityId !=null and param.activityId != ''">
            AND toc.activity_id = #{param.activityId}
        </if>
        AND toc.create_time >= DATE_SUB(CURDATE(), INTERVAL 5 DAY)
        AND toc.create_time >= DATE_SUB(CURDATE(), INTERVAL 4 DAY)
        GROUP BY mapKey
    </select>
@@ -1937,6 +1962,25 @@
        GROUP BY mapKey
    </select>
    <select id="getActivityMemberTotal" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
        SELECT
        DATE(toc.create_time) AS mapKey,
        COUNT(DISTINCT toc.user_id) AS mapValue
        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 = 2 AND toc.order_status IN (2,3)
        <if test="param.shopId != null and param.shopId != ''">
            AND toc.shop_id = #{param.shopId}
        </if>
        <if test="param.startDate!=null and param.startDate!=''">
            AND Date(toc.create_time) &gt;= #{param.startDate}
        </if>
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(toc.create_time) &lt;= #{param.endDate}
        </if>
        GROUP BY mapKey
    </select>
    <select id="countUserBuyGoodsNum" resultType="java.lang.Integer">
        SELECT SUM(tog.buy_num)
        FROM t_order toc