bug
jiangqs
2023-08-26 83c1a766957e4c74ea6e81c6e9b18f1b692b1b7b
ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
@@ -893,10 +893,10 @@
    <select id="getTotalActivityTotal" resultType="com.ruoyi.order.domain.vo.MgtTotalActivityTotalVo">
        SELECT
        COUNT(order_id) orderTotal,
        IFNULL(SUM(order_money),0) orderMoney,
        COUNT(DISTINCT user_id) orderPerson
        FROM t_order WHERE del_flag = 0 AND order_from = 2
        COUNT(CASE WHEN order_status = 3 THEN order_id ELSE NULL END) orderTotal,
        IFNULL(SUM(CASE WHEN order_status = 3 AND pay_type = 1 THEN change_receivable_money WHEN order_status = 3 AND pay_type = 2 THEN change_receivable_money + online_pay_money ELSE 0 END),0) orderMoney,
        COUNT(DISTINCT user_id) orderJoinPerson
        FROM t_order WHERE del_flag = 0 AND order_from = 2 AND order_status IN (2,3)
        <if test="param.shopId != null and param.shopId != ''">
            AND shop_id = #{param.shopId}
        </if>
@@ -913,9 +913,8 @@
        tog.goods_type mapKey,
        COUNT(DISTINCT toc.order_id) AS mapValueFirst,
        IFNULL(SUM(tog.goods_total_money),0) AS mapValueSecond,
        COUNT(DISTINCT toc.user_id) AS mapValueThird,
        FROM
        t_order toc
        COUNT(DISTINCT toc.user_id) AS mapValueThird
        FROM t_order toc
        INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
        WHERE toc.del_flag = 0 AND order_from = 2
        <if test="param.shopId != null and param.shopId != ''">
@@ -1200,7 +1199,7 @@
        SELECT
        tog.goods_type mapKey,
        COUNT(DISTINCT toc.order_id) AS mapValueFirst,
        IFNULL(SUM(tog.goods_total_money),0) AS mapValueSecond
        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
@@ -1217,7 +1216,8 @@
    <select id="listPlTotalOrderTotalGoodsRank" 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,
        COUNT(DISTINCT toc.order_id) mapTotalValue
        FROM t_order toc
        INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
        WHERE toc.del_flag = 0
@@ -1265,10 +1265,10 @@
    <select id="getPlTotalActivityTotal" resultType="com.ruoyi.order.domain.vo.MgtPlTotalActivityTotalVo">
        SELECT
        COUNT(order_id) orderTotal,
        IFNULL(SUM(order_money),0) orderMoney,
        COUNT(DISTINCT user_id) orderPerson
        FROM t_order WHERE del_flag = 0 AND order_from = 2
        COUNT(CASE WHEN order_status = 3 THEN order_id ELSE NULL END) orderTotal,
        IFNULL(SUM(CASE WHEN order_status = 3 AND pay_type = 1 THEN change_receivable_money WHEN order_status = 3 AND pay_type = 2 THEN change_receivable_money + online_pay_money ELSE 0 END),0) orderMoney,
        COUNT(DISTINCT user_id) orderJoinPerson
        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=")">
@@ -1283,15 +1283,61 @@
        </if>
    </select>
    <select id="getPlTotalActivityMemberTotal" resultType="com.ruoyi.order.domain.vo.MgtPlTotalActivityTotalVo">
        SELECT
        COUNT(DISTINCT toc.user_id) orderPerson,
        COUNT(DISTINCT CASE WHEN tog.goods_type = 1 THEN toc.user_id ELSE NULL END) cyclePerson,
        COUNT(DISTINCT CASE WHEN tog.goods_type = 2 THEN toc.user_id ELSE NULL END) experiencePerson,
        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
        <if test="param.shopIdList != null and param.shopIdList.size() > 0">
            AND toc.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(toc.create_time) &gt;= #{param.startDate}
        </if>
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(toc.create_time) &lt;= #{param.endDate}
        </if>
    </select>
    <select id="getTotalActivityMemberTotal" resultType="com.ruoyi.order.domain.vo.MgtTotalActivityTotalVo">
        SELECT
        COUNT(DISTINCT toc.user_id) orderPerson,
        COUNT(DISTINCT CASE WHEN tog.goods_type = 1 THEN toc.user_id ELSE NULL END) cyclePerson,
        COUNT(DISTINCT CASE WHEN tog.goods_type = 2 THEN toc.user_id ELSE NULL END) experiencePerson,
        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
        <if test="param.shopIdList != null and param.shopIdList.size() > 0">
            AND toc.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(toc.create_time) &gt;= #{param.startDate}
        </if>
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(toc.create_time) &lt;= #{param.endDate}
        </if>
    </select>
    <select id="listPlTotalActivityTotalGoodsType" 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,
        IFNULL(SUM(tog.goods_receivable_money),0) AS mapValueSecond,
        COUNT(DISTINCT toc.user_id) AS mapValueThird
        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
        WHERE toc.del_flag = 0 AND toc.order_from = 2 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=")">
@@ -1311,9 +1357,9 @@
        SELECT
        DATE_FORMAT(create_time, '%Y-%m-%d') AS mapKey,
        COUNT(DISTINCT order_id) AS mapValueFirst,
        IFNULL(SUM(order_money),0) AS mapValueSecond
        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
        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.shopIdList != null and param.shopIdList.size() > 0">
            AND shop_id IN
@@ -1371,12 +1417,18 @@
            shop_id AS mapKey,
            COUNT(order_id) 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=")">
                #{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 shop_id
        ORDER BY COUNT(order_id) DESC LIMIT 15
@@ -1409,6 +1461,12 @@
            <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 activity_name
        ORDER BY SUM(order_money) DESC LIMIT 15
@@ -1555,7 +1613,7 @@
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(toc.create_time) &lt;= #{param.endDate}
        </if>
        GROUP BY mapValue
        GROUP BY mapKey
        ORDER BY mapValue DESC LIMIT 15
    </select>
@@ -1794,13 +1852,41 @@
        GROUP BY mapKey
    </select>
    <select id="getMgtActivityGetMemberTotal" 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.order_from = 2 AND toc.new_member_flag = 1 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=")">
                #{item}
            </foreach>
        </if>
        <if test="param.userIdList !=null and param.userIdList.size()>0">
            AND toc.user_id IN
            <foreach collection="param.userIdList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </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="getStaffActivityMemberTotal" 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.shop_id = #{param.shopId} AND toc.order_from = 2
        WHERE toc.del_flag = 0 AND toc.shop_id = #{param.shopId} AND toc.order_from = 2 AND toc.order_staus IN (2,3)
        <if test="param.activityId !=null and param.activityId != ''">
            AND toc.activity_id = #{param.activityId}
        </if>
@@ -1822,6 +1908,35 @@
        GROUP BY mapKey
    </select>
    <select id="getMgtActivityMemberTotal" 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_staus 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=")">
                #{item}
            </foreach>
        </if>
        <if test="param.userIdList !=null and param.userIdList.size()>0">
            AND toc.user_id IN
            <foreach collection="param.userIdList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </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