魏超 5 years ago
parent
commit
7f49269ecd
1 changed files with 35 additions and 20 deletions
  1. 35
    20
      src/main/resources/mapper/statistic/TaActivityStaticMapper.xml

+ 35
- 20
src/main/resources/mapper/statistic/TaActivityStaticMapper.xml View File

857
             and t.building_id = #{buildingId}
857
             and t.building_id = #{buildingId}
858
         </if>
858
         </if>
859
         <if test="targetType != null and targetType != ''">
859
         <if test="targetType != null and targetType != ''">
860
-            and t.target_type = #{targetType}
860
+            and (case when #{targetType} = 'activity' then t.target_type = 'dynamic' else t.target_type = #{targetType}
861
+            end)
861
         </if>
862
         </if>
862
         <if test="startDate != null">
863
         <if test="startDate != null">
863
             and t.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
864
             and t.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
890
             and t.building_id = #{buildingId}
891
             and t.building_id = #{buildingId}
891
         </if>
892
         </if>
892
         <if test="targetType != null and targetType != ''">
893
         <if test="targetType != null and targetType != ''">
893
-            and t.target_type = #{targetType}
894
+            and (case when #{targetType} = 'activity' then t.target_type = 'dynamic' else t.target_type = #{targetType}
895
+            end)
894
         </if>
896
         </if>
895
         <if test="startDate != null">
897
         <if test="startDate != null">
896
             and t.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
898
             and t.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1081
         <if test="startDate == null or endDate == null ">
1083
         <if test="startDate == null or endDate == null ">
1082
             AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1084
             AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1083
         </if>
1085
         </if>
1084
-        group by a.person_id
1086
+        group by a.person_id, be_share
1085
 <!--        , be_share, tagert_type-->
1087
 <!--        , be_share, tagert_type-->
1086
         ) as sharePersonNum group by sharePersonNum.be_share, sharePersonNum.tagert_type
1088
         ) as sharePersonNum group by sharePersonNum.be_share, sharePersonNum.tagert_type
1087
         ) as sharePersonNum on sharePersonNum.be_share = activity.activityId and sharePersonNum.tagert_type =
1089
         ) as sharePersonNum on sharePersonNum.be_share = activity.activityId and sharePersonNum.tagert_type =
1179
             and a.building_id = #{buildingId}
1181
             and a.building_id = #{buildingId}
1180
         </if>
1182
         </if>
1181
         <if test="activityName != null and activityName != '' ">
1183
         <if test="activityName != null and activityName != '' ">
1182
-            and a.title = #{activityName}
1184
+            and a.title like concat('%', #{activityName}, '%')
1183
         </if>
1185
         </if>
1184
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1186
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1185
             and a.building_id in
1187
             and a.building_id in
1194
             and b.building_id = #{buildingId}
1196
             and b.building_id = #{buildingId}
1195
         </if>
1197
         </if>
1196
         <if test="activityName != null and activityName != '' ">
1198
         <if test="activityName != null and activityName != '' ">
1197
-            and b.title = #{activityName}
1199
+            and b.title like concat('%', #{activityName}, '%')
1198
         </if>
1200
         </if>
1199
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1201
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1200
             and b.building_id in
1202
             and b.building_id in
1210
             and c.building_id = #{buildingId}
1212
             and c.building_id = #{buildingId}
1211
         </if>
1213
         </if>
1212
         <if test="activityName != null and activityName != '' ">
1214
         <if test="activityName != null and activityName != '' ">
1213
-            and c.activity_name = #{activityName}
1215
+            and c.activity_name like concat('%', #{activityName}, '%')
1214
         </if>
1216
         </if>
1215
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1217
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1216
             and c.building_id in
1218
             and c.building_id in
1225
             and d.building_id = #{buildingId}
1227
             and d.building_id = #{buildingId}
1226
         </if>
1228
         </if>
1227
         <if test="activityName != null and activityName != '' ">
1229
         <if test="activityName != null and activityName != '' ">
1228
-            and d.name = #{activityName}
1230
+            and d.name like concat('%', #{activityName}, '%')
1229
         </if>
1231
         </if>
1230
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1232
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1231
             and (d.building_id in
1233
             and (d.building_id in
1243
             and e.building_id = #{buildingId}
1245
             and e.building_id = #{buildingId}
1244
         </if>
1246
         </if>
1245
         <if test="activityName != null and activityName != '' ">
1247
         <if test="activityName != null and activityName != '' ">
1246
-            and e.live_activity_title = #{activityName}
1248
+            and e.live_activity_title like concat('%', #{activityName}, '%')
1247
         </if>
1249
         </if>
1248
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1250
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1249
             and (e.building_id in
1251
             and (e.building_id in
1261
         'activity', 'group','h5','help','liveApp','livePost')
1263
         'activity', 'group','h5','help','liveApp','livePost')
1262
         and a.org_id = #{orgId}
1264
         and a.org_id = #{orgId}
1263
         <if test="targetType != null and targetType != ''">
1265
         <if test="targetType != null and targetType != ''">
1264
-            and a.tagert_type = #{targetType}
1266
+            and (case when #{targetType} = 'live' then a.tagert_type in ('liveApp', 'livePost') else a.tagert_type = #{targetType}
1267
+            end)
1265
         </if>
1268
         </if>
1266
         <if test="startDate != null ">
1269
         <if test="startDate != null ">
1267
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1270
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1281
         From ta_share_count a where a.tagert_type in ( 'activity', 'group','h5','help','liveApp','livePost')
1284
         From ta_share_count a where a.tagert_type in ( 'activity', 'group','h5','help','liveApp','livePost')
1282
         and a.org_id = #{orgId}
1285
         and a.org_id = #{orgId}
1283
         <if test="targetType != null and targetType != ''">
1286
         <if test="targetType != null and targetType != ''">
1284
-            and a.tagert_type = #{targetType}
1287
+            and (case when #{targetType} = 'live' then a.tagert_type in ('liveApp', 'livePost') else a.tagert_type = #{targetType}
1288
+            end)
1285
         </if>
1289
         </if>
1286
         <if test="startDate != null ">
1290
         <if test="startDate != null ">
1287
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1291
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1292
         <if test="startDate == null or endDate == null ">
1296
         <if test="startDate == null or endDate == null ">
1293
             AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1297
             AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1294
         </if>
1298
         </if>
1295
-        group by a.person_id, be_share, tagert_type
1299
+        group by a.person_id, be_share
1300
+        <!--        , be_share, tagert_type-->
1296
         ) as sharePersonNum group by sharePersonNum.be_share, sharePersonNum.tagert_type
1301
         ) as sharePersonNum group by sharePersonNum.be_share, sharePersonNum.tagert_type
1297
         ) as sharePersonNum on sharePersonNum.be_share = activity.activityId and sharePersonNum.tagert_type =
1302
         ) as sharePersonNum on sharePersonNum.be_share = activity.activityId and sharePersonNum.tagert_type =
1298
         activity.activityType
1303
         activity.activityType
1523
         ifnull(shareNum, 0) as shareNum,
1528
         ifnull(shareNum, 0) as shareNum,
1524
         ifnull(visitNum, 0) as visitNum,
1529
         ifnull(visitNum, 0) as visitNum,
1525
         ifnull(visitPersonNum, 0) as visitPersonNum,
1530
         ifnull(visitPersonNum, 0) as visitPersonNum,
1526
-        person.person_type as sharePersonType,
1531
+        CASE
1532
+        WHEN person.person_type = 'drift' THEN
1533
+        "游客"
1534
+        WHEN person.person_type = 'customer' THEN
1535
+        "普通客户"
1536
+        WHEN person.person_type = 'Realty Consultant' THEN
1537
+        "置业顾问"
1538
+        END `sharePersonType`,
1527
         person.person_id
1539
         person.person_id
1528
         from (
1540
         from (
1529
         SELECT t.*, f.nickname, f.phone, f.person_type
1541
         SELECT t.*, f.nickname, f.phone, f.person_type
1645
             and t.target_type = concat(REPLACE(#{activityType}, 'activity', 'dynamic'), '_share')
1657
             and t.target_type = concat(REPLACE(#{activityType}, 'activity', 'dynamic'), '_share')
1646
         </if>
1658
         </if>
1647
         and t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share')
1659
         and t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share')
1648
-        and t.org_id = #{orgId} group by t.share_person ) t
1660
+        and t.org_id = #{orgId}
1661
+        <!--        group by t.share_person -->
1662
+        ) t
1649
         left join ta_person a on t.share_person = a.person_id
1663
         left join ta_person a on t.share_person = a.person_id
1650
         left join ta_person b on t.share_person = b.user_id
1664
         left join ta_person b on t.share_person = b.user_id
1651
         ) as visitPersonNum on visitPersonNum.person_id = person.person_id
1665
         ) as visitPersonNum on visitPersonNum.person_id = person.person_id
1779
             and t.be_share = #{activityId}
1793
             and t.be_share = #{activityId}
1780
         </if>
1794
         </if>
1781
         <if test="activityType != null and activityType != ''">
1795
         <if test="activityType != null and activityType != ''">
1782
-            and t.tagert_type = #{activityType}
1796
+            and (case when #{activityType} = 'live' then t.tagert_type in ('liveApp', 'livePost') else t.tagert_type = #{activityType}
1797
+            end)
1783
         </if>
1798
         </if>
1784
         <if test="buildingId != null and buildingId != ''">
1799
         <if test="buildingId != null and buildingId != ''">
1785
             and (
1800
             and (
2293
         SELECT count(1) as visitNum, t.person_id, t.create_date
2308
         SELECT count(1) as visitNum, t.person_id, t.create_date
2294
         FROM ta_share_person_from t
2309
         FROM ta_share_person_from t
2295
         WHERE t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' ) and t.create_date &lt;=
2310
         WHERE t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' ) and t.create_date &lt;=
2296
-        DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' ) and t.target_type in
2297
-        ('dynamic_share','h5_share','help_share','live_share', 'group_share')
2311
+        DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' )
2298
         <if test="activityId != null and activityId != ''">
2312
         <if test="activityId != null and activityId != ''">
2299
             and t.target_id = #{activityId}
2313
             and t.target_id = #{activityId}
2300
         </if>
2314
         </if>
2301
         <if test="activityType != null and activityType != ''">
2315
         <if test="activityType != null and activityType != ''">
2302
             and t.target_type = concat(REPLACE(#{activityType}, 'activity', 'dynamic'), '_share')
2316
             and t.target_type = concat(REPLACE(#{activityType}, 'activity', 'dynamic'), '_share')
2303
         </if>
2317
         </if>
2318
+        and t.target_type in
2319
+        ('dynamic_share','h5_share','help_share','live_share', 'group_share')
2304
         and
2320
         and
2305
         (t.share_person = (select b.user_id from ta_person t left join ta_user b on t.user_id = b.user_id where t.person_id = #{personId})
2321
         (t.share_person = (select b.user_id from ta_person t left join ta_user b on t.user_id = b.user_id where t.person_id = #{personId})
2306
         or t.share_person = #{personId})
2322
         or t.share_person = #{personId})
2330
         ifnull(e.nickname, f.user_name) as sharePersonName,
2346
         ifnull(e.nickname, f.user_name) as sharePersonName,
2331
         ifnull(e.phone, f.phone) as sharePersonPhone
2347
         ifnull(e.phone, f.phone) as sharePersonPhone
2332
         From (
2348
         From (
2333
-        SELECT t.person_id, t.create_date
2349
+        SELECT t.person_id, t.create_date, t.share_person
2334
         FROM ta_share_person_from t
2350
         FROM ta_share_person_from t
2335
         LEFT JOIN (
2351
         LEFT JOIN (
2336
-        SELECT a.person_id, b.user_id, t.share_person
2352
+        SELECT a.person_id, b.user_id
2337
         FROM ta_person a
2353
         FROM ta_person a
2338
         LEFT JOIN ta_user b
2354
         LEFT JOIN ta_user b
2339
         ON a.user_id = b.user_id
2355
         ON a.user_id = b.user_id
2340
         WHERE a.org_id = #{orgId} ) as a ON t.share_person = a.person_id or t.share_person = a.user_id
2356
         WHERE a.org_id = #{orgId} ) as a ON t.share_person = a.person_id or t.share_person = a.user_id
2341
         WHERE t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' ) and t.create_date &lt;=
2357
         WHERE t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' ) and t.create_date &lt;=
2342
-        DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' )
2343
-        and t.target_type in
2358
+        DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' ) and t.target_type in
2344
         ('dynamic_share','h5_share','help_share','live_share', 'group_share')
2359
         ('dynamic_share','h5_share','help_share','live_share', 'group_share')
2345
         <if test="activityId != null and activityId != ''">
2360
         <if test="activityId != null and activityId != ''">
2346
             and t.target_id = #{activityId}
2361
             and t.target_id = #{activityId}