浏览代码

数据分析添加折线数据

zhaoxian 2 年之前
父节点
当前提交
d2d6510602

+ 5 - 5
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouItemCollectSamplesServiceImpl.java

@@ -640,7 +640,7 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
                     JSONObject obj = new JSONObject();
                     obj.put("date", date);
                     obj.put("orderAmount", 0);
-                    obj.put("totalRegimentalSettleAmount", 0);
+                    obj.put("regimentalPromotionAmount", 0);
                     obj.put("promoterCount", 0);
                     obj.put("orderCount", 0);
                     list.add(obj);
@@ -659,9 +659,9 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
         JSONObject amount = supplyChainService.getMonthOrderAmountTotal(map);
         if (Check.isNotNull(amount)) {
             data.put("orderAmount", amount.getInteger("orderAmount"));
-            data.put("totalRegimentalSettleAmount", amount.getInteger("totalRegimentalSettleAmount"));
+            data.put("regimentalPromotionAmount", amount.getInteger("regimentalPromotionAmount"));
             data.put("orderAmountRate", amount.getString("orderAmountRate"));
-            data.put("totalRegimentalSettleAmountRate", amount.getString("totalRegimentalSettleAmountRate"));
+            data.put("regimentalPromotionAmountRate", amount.getString("regimentalPromotionAmountRate"));
         }
         JSONObject promoter = promoterService.getgetMonthPromoterTotal(userList, startDate, endDate);
         if (Check.isNotNull(promoter)) {
@@ -699,7 +699,7 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
                         JSONObject obj = new JSONObject();
                         obj.put("date", date);
                         obj.put("orderAmount", 0);
-                        obj.put("totalRegimentalSettleAmount", 0);
+                        obj.put("regimentalPromotionAmount", 0);
                         obj.put("orderCount", 0);
                         list.add(obj);
                     }
@@ -716,7 +716,7 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
             JSONObject amount = supplyChainService.getMonthOrderAmountTotalByItems(map);
             if (Check.isNotNull(amount)) {
                 data.put("orderAmount", amount.getInteger("orderAmount"));
-                data.put("totalRegimentalSettleAmount", amount.getInteger("totalRegimentalSettleAmount"));
+                data.put("regimentalPromotionAmount", amount.getInteger("regimentalPromotionAmount"));
                 data.put("orderAmountRate", amount.getString("orderAmountRate"));
                 data.put("totalRegimentalSettleAmountRate", amount.getString("totalRegimentalSettleAmountRate"));
                 data.put("orderCount", amount.getString("orderCount"));

+ 26 - 38
ruixuan-live/src/main/resources/mapper/isc/SupplyChainMapper.xml

@@ -1078,7 +1078,7 @@
         CONCAT(IFNULL(ROUND(sendCount / allNumber * 100, 2),0), '%') as 'sendRate'
         FROM (
         SELECT
-        count(DISTINCT promoter_id) as 'promoterCount',
+        COUNT(DISTINCT promoter_id) as 'promoterCount',
         COUNT(oid) as 'allNumber',
         IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
         IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END), 0) AS 'orderAmount',
@@ -1131,45 +1131,35 @@
     <select id="getMonthOrderAmount" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
         FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') as 'date',
-        IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'orderCount',
-        IFNULL(SUM(order_amount),0) AS 'orderAmount',
-        IFNULL(SUM(regimental_promotion_amount),0) AS 'totalRegimentalSettleAmount',
-        IFNULL(promoterCount,0) AS 'promoterCount'
+        count(1) AS 'orderCount',
+        IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderCount',
+        IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END),0) AS 'orderAmount',
+        IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
+        'regimentalPromotionAmount',
+        COUNT(DISTINCT promoter_id) as 'promoterCount'
         FROM kuaishou_supply_chain t1
-        LEFT JOIN (
-        SELECT count(promoter_id) as 'promoterCount', DATE_FORMAT(create_time, '%Y-%m-%d') as 'date'
-        FROM kuaishou_promoter
-        WHERE DATE_FORMAT(create_time, '%Y-%m-%d') >= #{start}
-        AND DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{end}
-        <if test="userList != null and userList.size() > 0 ">
-            AND user_id in
-            <foreach collection="userList" item="item" separator=","
-                     open="(" close=")">
-                #{item}
-            </foreach>
-        </if>
-        GROUP BY DATE_FORMAT(create_time, '%Y-%m-%d')
-        ) t2 ON FROM_UNIXTIME(t1.order_create_time / 1000, '%Y-%m-%d') = t2.date
-        WHERE order_status != 80
+        WHERE order_create_time >= #{startLong}
+        AND order_create_time &lt;= #{endLong}
         <if test='promoterIds != null and promoterIds.size() > 0'>
             AND promoter_id in
             <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
                 #{item}
             </foreach>
         </if>
-        AND order_create_time >= #{startLong}
-        AND order_create_time &lt;= #{endLong}
         GROUP BY FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d')
     </select>
 
     <select id="getMonthOrderAmountByItems" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
         FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') as 'date',
-        IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'orderCount',
-        IFNULL(SUM(order_amount),0) AS 'orderAmount',
-        IFNULL(SUM(regimental_promotion_amount),0) AS 'totalRegimentalSettleAmount'
+        count(1) AS 'orderCount',
+        IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderCount',
+        IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END),0) AS 'orderAmount',
+        IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
+        'regimentalPromotionAmount'
         FROM kuaishou_supply_chain
-        WHERE order_status != 80
+        WHERE order_create_time >= #{startLong}
+        AND order_create_time &lt;= #{endLong}
         <if test='itemIds != null and itemIds.size() > 0'>
             AND item_id in
             <foreach collection="itemIds" item="item" separator=","
@@ -1177,23 +1167,21 @@
                 #{item}
             </foreach>
         </if>
-        AND order_create_time >= #{startLong}
-        AND order_create_time &lt;= #{endLong}
         GROUP BY FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d')
     </select>
 
     <select id="getMonthOrderAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
         t1.orderAmount,
-        t1.totalRegimentalSettleAmount,
+        t1.regimentalPromotionAmount,
         CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
-        CONCAT(IFNULL(ROUND(t2.totalRegimentalSettleAmount/t1.totalRegimentalSettleAmount*100,2),0),'%') as
-        'totalRegimentalSettleAmountRate'
+        CONCAT(IFNULL(ROUND(t2.regimentalPromotionAmount/t1.regimentalPromotionAmount*100,2),0),'%') as
+        'regimentalPromotionAmountRate'
         FROM
         (
         SELECT
         IFNULL(SUM(order_amount),0) AS 'orderAmount',
-        IFNULL(SUM(regimental_promotion_amount),0) AS 'totalRegimentalSettleAmount'
+        IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount'
         FROM kuaishou_supply_chain t1
         WHERE order_status != 80
         <if test='promoterIds != null and promoterIds.size() > 0'>
@@ -1208,7 +1196,7 @@
         (
         SELECT
         IFNULL(SUM(order_amount),0) AS 'orderAmount',
-        IFNULL(SUM(regimental_promotion_amount),0) AS 'totalRegimentalSettleAmount'
+        IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount'
         FROM kuaishou_supply_chain t1
         WHERE order_status != 80
         <if test='promoterIds != null and promoterIds.size() > 0'>
@@ -1224,17 +1212,17 @@
     <select id="getMonthOrderAmountTotalByItems" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
         t1.orderAmount,
-        t1.totalRegimentalSettleAmount,
+        t1.regimentalPromotionAmount,
         t1.orderCount,
         CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
         CONCAT(IFNULL(ROUND(t2.orderCount/t1.orderCount*100,2),0),'%') as 'orderCountRate',
-        CONCAT(IFNULL(ROUND(t2.totalRegimentalSettleAmount/t1.totalRegimentalSettleAmount*100,2),0),'%') as
-        'totalRegimentalSettleAmountRate'
+        CONCAT(IFNULL(ROUND(t2.regimentalPromotionAmount/t1.regimentalPromotionAmount*100,2),0),'%') as
+        'regimentalPromotionAmountRate'
         FROM
         (
         SELECT
         IFNULL(SUM(order_amount),0) AS 'orderAmount',
-        IFNULL(SUM(regimental_promotion_amount),0) AS 'totalRegimentalSettleAmount',
+        IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount',
         COUNT(oid) as 'orderCount'
         FROM kuaishou_supply_chain t1
         WHERE order_status != 80
@@ -1252,7 +1240,7 @@
         (
         SELECT
         IFNULL(SUM(order_amount),0) AS 'orderAmount',
-        IFNULL(SUM(regimental_promotion_amount),0) AS 'totalRegimentalSettleAmount',
+        IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount',
         COUNT(oid) as 'orderCount'
         FROM kuaishou_supply_chain t1
         WHERE order_status != 80