魏超 5 年前
父节点
当前提交
3a928313f3
共有 1 个文件被更改,包括 90 次插入82 次删除
  1. 90
    82
      src/main/resources/mapper/statistic/TaActivityStaticMapper.xml

+ 90
- 82
src/main/resources/mapper/statistic/TaActivityStaticMapper.xml 查看文件

@@ -985,30 +985,29 @@
985 985
         ) as activity
986 986
 
987 987
         left join (
988
-        select * from (
989
-        select count(*) as shareNum, a.be_share, a.tagert_type From ta_share_count a where a.tagert_type in (
990
-        'activity', 'group','h5','help','liveApp','livePost')
991
-        and a.org_id = #{orgId}
992
-        <if test="targetType != null and targetType != ''">
993
-            and a.tagert_type = #{targetType}
994
-        </if>
995
-        <if test="startDate != null ">
996
-            and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
997
-        </if>
998
-        <if test="endDate != null ">
999
-            and a.create_date &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S' )
1000
-        </if>
1001
-        <if test="startDate == null or endDate == null ">
1002
-            AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1003
-        </if>
1004
-        group by a.be_share, tagert_type
1005
-        ) as a
988
+            SELECT count(1) as shareNum, a.be_share, case when a.tagert_type = 'liveApp' then 'live' when a.tagert_type = 'livePost' then 'live' else a.tagert_type end as tagert_type
989
+            FROM ta_share_count a where a.tagert_type in (
990
+            'activity', 'group','h5','help','liveApp','livePost')
991
+            and a.org_id = #{orgId}
992
+            <if test="targetType != null and targetType != ''">
993
+                and a.tagert_type = #{targetType}
994
+            </if>
995
+            <if test="startDate != null ">
996
+                and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
997
+            </if>
998
+            <if test="endDate != null ">
999
+                and a.create_date &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S' )
1000
+            </if>
1001
+            <if test="startDate == null or endDate == null ">
1002
+                AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1003
+            </if>
1004
+            group by a.be_share
1006 1005
         ) as shareNum on shareNum.be_share = activity.activityId and shareNum.tagert_type = activity.activityType
1007 1006
 
1008 1007
         left join (
1009
-        select count(*) as sharePersonNum ,sharePersonNum.be_share, sharePersonNum.tagert_type,
1010
-        sharePersonNum.create_date from (
1011
-        select a.* From ta_share_count a where a.tagert_type in ( 'activity', 'group','h5','help','liveApp','livePost')
1008
+        SELECT count(*) as sharePersonNum ,sharePersonNum.be_share, sharePersonNum.tagert_type, sharePersonNum.create_date from (
1009
+        SELECT a.be_share, a.create_date ,case when a.tagert_type = 'liveApp' then 'live' when a.tagert_type = 'livePost' then 'live' else a.tagert_type end   as tagert_type
1010
+        From ta_share_count a where a.tagert_type in ( 'activity', 'group','h5','help','liveApp','livePost')
1012 1011
         and a.org_id = #{orgId}
1013 1012
         <if test="targetType != null and targetType != ''">
1014 1013
             and a.tagert_type = #{targetType}
@@ -1028,45 +1027,43 @@
1028 1027
         activity.activityType
1029 1028
 
1030 1029
         left join (
1031
-        select * from (
1032
-        select count(*) as visitNum, a.target_id, a.event_type From ta_person_visit_record a where a.event_type in
1033
-        ('activity','group','h5','help') and a.`event` = 'detail' and a.org_id = #{orgId}
1034
-        <if test="targetType != null and targetType != ''">
1035
-            and (case when #{targetType} = 'activity' then a.target_type = 'dynamic' else a.target_type = #{targetType}
1036
-            end)
1037
-        </if>
1038
-        <if test="startDate != null">
1039
-            and a.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1040
-        </if>
1041
-        <if test="endDate != null">
1042
-            and a.visit_time &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S' )
1043
-        </if>
1044
-        <if test="startDate == null or endDate == null ">
1045
-            AND a.visit_time BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1046
-        </if>
1047
-        group by a.target_id, a.event_type
1048
-        ) as a
1049
-        ) as visitNum on visitNum.target_id = activity.activityId and visitNum.event_type = activity.activityType
1030
+            select count(*) as visitNum, a.target_id, case when a.target_type = 'dynamic' then 'activity' else a.target_type end as target_type
1031
+            From ta_person_visit_record a where a.event_type in
1032
+            ('activity','group','h5','help') and a.`event` = 'detail' and a.org_id = #{orgId}
1033
+            <if test="targetType != null and targetType != ''">
1034
+                and (case when #{targetType} = 'activity' then a.target_type = 'dynamic' else a.target_type = #{targetType}
1035
+                end)
1036
+            </if>
1037
+            <if test="startDate != null">
1038
+                and a.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1039
+            </if>
1040
+            <if test="endDate != null">
1041
+                and a.visit_time &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S' )
1042
+            </if>
1043
+            <if test="startDate == null or endDate == null ">
1044
+                AND a.visit_time BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1045
+            </if>
1046
+            group by a.target_id, a.event_type
1047
+        ) as visitNum on visitNum.target_id = activity.activityId and visitNum.target_type = activity.activityType
1050 1048
 
1051 1049
         left join (
1052
-        select count(*) as visitPersonNum ,visitPersonNum.target_id, visitPersonNum.event_type from (
1053
-        select a.* From ta_person_visit_record a where a.event_type in ('activity','group','h5','help') and a.`event` =
1054
-        'detail' and a.org_id = #{orgId}
1055
-        <if test="targetType != null and targetType != ''">
1056
-            and (case when #{targetType} = 'activity' then a.target_type = 'dynamic' else a.target_type = #{targetType}
1057
-            end)
1058
-        </if>
1059
-        <if test="startDate != null">
1060
-            and a.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1061
-        </if>
1062
-        <if test="endDate != null">
1063
-            and a.visit_time &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S' )
1064
-        </if>
1065
-        <if test="startDate == null or endDate == null ">
1066
-            AND a.visit_time BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1067
-        </if>
1068
-        group by a.person_id, a.target_id, a.event_type
1069
-        ) as visitPersonNum group by visitPersonNum.target_id, visitPersonNum.event_type
1050
+            SELECT count(DISTINCT(a.person_id)) as visitPersonNum , a.target_id, case when a.target_type = 'dynamic' then 'activity' else a.target_type end as event_type
1051
+            From ta_person_visit_record a where a.event_type in ('activity','group','h5','help') and a.`event` =
1052
+            'detail' and a.org_id = #{orgId}
1053
+            <if test="targetType != null and targetType != ''">
1054
+                and (case when #{targetType} = 'activity' then a.target_type = 'dynamic' else a.target_type = #{targetType}
1055
+                end)
1056
+            </if>
1057
+            <if test="startDate != null">
1058
+                and a.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1059
+            </if>
1060
+            <if test="endDate != null">
1061
+                and a.visit_time &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S' )
1062
+            </if>
1063
+            <if test="startDate == null or endDate == null ">
1064
+                AND a.visit_time BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1065
+            </if>
1066
+            group by a.target_id, a.event_type
1070 1067
         ) as visitPersonNum on visitPersonNum.target_id = activity.activityId and visitPersonNum.event_type =
1071 1068
         activity.activityType
1072 1069
 
@@ -1200,8 +1197,8 @@
1200 1197
         ) as activity
1201 1198
 
1202 1199
         left join (
1203
-        select * from (
1204
-        select count(*) as shareNum, a.be_share, a.tagert_type From ta_share_count a where a.tagert_type in (
1200
+        SELECT count(1) as shareNum, a.be_share, case when a.tagert_type = 'liveApp' then 'live' when a.tagert_type = 'livePost' then 'live' else a.tagert_type end as tagert_type
1201
+        FROM ta_share_count a where a.tagert_type in (
1205 1202
         'activity', 'group','h5','help','liveApp','livePost')
1206 1203
         and a.org_id = #{orgId}
1207 1204
         <if test="startDate != null ">
@@ -1213,14 +1210,13 @@
1213 1210
         <if test="startDate == null or endDate == null ">
1214 1211
             AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1215 1212
         </if>
1216
-        group by a.be_share, tagert_type
1217
-        ) as a
1213
+        group by a.be_share
1218 1214
         ) as shareNum on shareNum.be_share = activity.activityId and shareNum.tagert_type = activity.activityType
1219 1215
 
1220 1216
         left join (
1221 1217
         select count(*) as sharePersonNum ,sharePersonNum.be_share, sharePersonNum.tagert_type,
1222 1218
         sharePersonNum.create_date from (
1223
-        select a.* From ta_share_count a where a.tagert_type in ( 'activity', 'group','h5','help','liveApp','livePost')
1219
+        SELECT a.be_share, a.create_date ,case when a.tagert_type = 'liveApp' then 'live' when a.tagert_type = 'livePost' then 'live' else a.tagert_type end   as tagert_type From ta_share_count a where a.tagert_type in ( 'activity', 'group','h5','help','liveApp','livePost')
1224 1220
         and a.org_id = #{orgId}
1225 1221
         <if test="startDate != null ">
1226 1222
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d' )
@@ -1372,21 +1368,27 @@
1372 1368
         ) as person
1373 1369
 
1374 1370
         left join (
1375
-        select * from (
1376
-        SELECT count(*) as shareNum, t.person_id
1377
-        FROM ta_share_count t
1378
-        LEFT JOIN ta_help_activity a ON t.be_share = a.help_activity_id
1379
-        LEFT JOIN ta_share_activity b ON t.be_share = b.share_id
1380
-        LEFT JOIN ta_live_activity c ON t.be_share = c.live_activity_id
1381
-        LEFT JOIN ta_drainage d ON t.be_share = d.drainage_id
1382
-        LEFT JOIN ta_building_dynamic e ON t.be_share = e.dynamic_id
1383
-        LEFT JOIN ta_person f
1384
-        ON t.person_id = f.person_id
1385
-        WHERE t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
1386
-        and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' ) and t.create_date &lt;=
1387
-        DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' )
1388
-        group by person_id
1389
-        ) as temp
1371
+            select * from (
1372
+                SELECT count(*) as shareNum, t.person_id
1373
+                FROM ta_share_count t
1374
+                LEFT JOIN ta_help_activity a ON t.be_share = a.help_activity_id
1375
+                LEFT JOIN ta_share_activity b ON t.be_share = b.share_id
1376
+                LEFT JOIN ta_live_activity c ON t.be_share = c.live_activity_id
1377
+                LEFT JOIN ta_drainage d ON t.be_share = d.drainage_id
1378
+                LEFT JOIN ta_building_dynamic e ON t.be_share = e.dynamic_id
1379
+                LEFT JOIN ta_person f
1380
+                ON t.person_id = f.person_id
1381
+                WHERE t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
1382
+                and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' ) and t.create_date &lt;=
1383
+                DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' )
1384
+                <if test="activityId != null and activityId != ''">
1385
+                    and t.be_share = #{activityId}
1386
+                </if>
1387
+                <if test="activityType != null and activityType != ''">
1388
+                    and t.tagert_type = #{activityType}
1389
+                </if>
1390
+                group by person_id
1391
+            ) as temp
1390 1392
         ) as shareNum on person.person_id = shareNum.person_id
1391 1393
 
1392 1394
         left join (
@@ -1517,6 +1519,12 @@
1517 1519
         WHERE t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
1518 1520
         and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' ) and t.create_date &lt;=
1519 1521
         DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' )
1522
+        <if test="activityId != null and activityId != ''">
1523
+            and t.be_share = #{activityId}
1524
+        </if>
1525
+        <if test="activityType != null and activityType != ''">
1526
+            and t.tagert_type = #{activityType}
1527
+        </if>
1520 1528
         group by person_id
1521 1529
         ) as temp
1522 1530
         ) as shareNum on person.person_id = shareNum.person_id
@@ -1848,7 +1856,7 @@
1848 1856
             and t.target_id = #{activityId}
1849 1857
         </if>
1850 1858
         <if test="activityType != null and activityType != ''">
1851
-            and t.event_type = #{activityType}
1859
+            and t.target_type = #{activityType}
1852 1860
         </if>
1853 1861
         <if test="buildingId != null and buildingId != ''">
1854 1862
             and t.building_id = #{buildingId}
@@ -1905,7 +1913,7 @@
1905 1913
             and t.target_id = #{activityId}
1906 1914
         </if>
1907 1915
         <if test="activityType != null and activityType != ''">
1908
-            and t.event_type = #{activityType}
1916
+            and t.target_type = #{activityType}
1909 1917
         </if>
1910 1918
         <if test="buildingId != null and buildingId != ''">
1911 1919
             and t.building_id = #{buildingId}
@@ -1970,7 +1978,7 @@
1970 1978
             and t.target_id = #{activityId}
1971 1979
         </if>
1972 1980
         <if test="activityType != null and activityType != ''">
1973
-            and t.event_type = #{activityType}
1981
+            and t.target_type = #{activityType}
1974 1982
         </if>
1975 1983
         <if test="buildingId != null and buildingId != ''">
1976 1984
             and t.building_id = #{buildingId}
@@ -2036,7 +2044,7 @@
2036 2044
             and t.target_id = #{activityId}
2037 2045
         </if>
2038 2046
         <if test="activityType != null and activityType != ''">
2039
-            and t.event_type = #{activityType}
2047
+            and t.target_type = #{activityType}
2040 2048
         </if>
2041 2049
         <if test="buildingId != null and buildingId != ''">
2042 2050
             and t.building_id = #{buildingId}