魏超 5 anos atrás
pai
commit
ffd48a0838

+ 41
- 0
src/main/java/com/huiju/estateagents/excel/IntentionUser.java Ver arquivo

@@ -35,4 +35,45 @@ public class IntentionUser {
35 35
     @ExcelProperty(value = "意向值", index = 3)
36 36
     private Integer intention;
37 37
 
38
+    /**
39
+     * 归属地
40
+     */
41
+    @ColumnWidth(15)
42
+    @ExcelProperty(value = "归属地", index = 4)
43
+    private String province;
44
+
45
+    /**
46
+     * 置业顾问
47
+     */
48
+    @ColumnWidth(15)
49
+    @ExcelProperty(value = "置业顾问", index = 5)
50
+    private String realtyConsultant;
51
+
52
+    /**
53
+     * 置业顾问电话
54
+     */
55
+    @ColumnWidth(15)
56
+    @ExcelProperty(value = "置业顾问电话", index = 6)
57
+    private String realtyConsultantPhone;
58
+
59
+    /**
60
+     * 分享者
61
+     */
62
+    @ColumnWidth(15)
63
+    @ExcelProperty(value = "分享者", index = 7)
64
+    private String sharePersonName;
65
+
66
+    /**
67
+     * 分享者电话
68
+     */
69
+    @ColumnWidth(15)
70
+    @ExcelProperty(value = "分享者电话", index = 8)
71
+    private String sharePersonPhone;
72
+
73
+    /**
74
+     * 性别
75
+     */
76
+    @ColumnWidth(15)
77
+    @ExcelProperty(value = "性别", index = 9)
78
+    private String gender;
38 79
 }

+ 60
- 12
src/main/resources/mapper/TaPersonIntentionRecordMapper.xml Ver arquivo

@@ -43,31 +43,79 @@
43 43
         ORDER BY SUM(tpir.intention) DESC
44 44
     </select>
45 45
     <select id="selectExportIntentionUser" resultType="com.huiju.estateagents.excel.IntentionUser">
46
+        select t.*, IFNULL(b.nickname, c.user_name) as sharePersonName, ifnull(b.phone, c.phone) as sharePersonPhone From (
47
+
46 48
         SELECT
47
-        tpir.person_name as  person_name,
49
+        tpir.person_name as person_name,
50
+        if(tp.gender = '1' , '男', if(tp.gender = '2', '女', '未知')) as gender,
48 51
         tp.phone as phone,
49
-        tpir.building_name as building_name,
52
+        tp.province,
53
+        tpir.person_id,
54
+        tpir.building_name,
55
+        tpir.building_id,
56
+        d.user_name as realtyConsultant,
57
+        d.phone as realtyConsultantPhone,
50 58
         SUM(tpir.intention) as intention
51
-        FROM
52
-        ta_person_intention_record tpir
53
-        LEFT JOIN ta_person tp on tpir.person_id = tp.person_id
59
+
60
+        FROM ta_person_intention_record tpir
61
+        LEFT JOIN ta_person tp ON tpir.person_id = tp.person_id
62
+        left join ta_recommend_customer c on c.person_id = tpir.person_id
63
+        left join ta_user d on c.realty_consultant = d.user_id
54 64
         <trim prefix="where" prefixOverrides="and | or">
55
-            <if test="buildingId != null and buildingId != ''">
56
-                tpir.building_id = #{buildingId}
57
-            </if>
58 65
             <if test="orgId != null">
59 66
                 AND tpir.org_id = #{orgId}
60 67
                 AND tp.org_id = #{orgId}
61 68
             </if>
69
+        </trim>
70
+        GROUP BY tpir.person_id, tpir.building_id
71
+
72
+        ) as t
73
+        left join ta_share_person_from a on t.person_id = a.person_id
74
+        left join ta_user c on a.share_person = c.user_id
75
+        left join ta_person b on a.share_person = b.person_id
76
+
77
+        <trim prefix="where" prefixOverrides="and | or">
78
+            <if test="buildingId != null and buildingId != ''">
79
+                t.building_id = #{buildingId}
80
+            </if>
62 81
             <if test="personBuildingList != null and personBuildingList.size > 0">
63
-                AND tpir.building_id in
82
+                AND t.building_id in
64 83
                 <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
65 84
                     #{personBuilding.buildingId}
66 85
                 </foreach>
67 86
             </if>
68 87
         </trim>
69
-        GROUP BY
70
-        tpir.person_id, tpir.building_id
71
-        ORDER BY SUM(tpir.intention) DESC
88
+
89
+        group by t.person_id, t.building_id
90
+        order by t.intention desc
91
+
92
+
93
+
94
+<!--        SELECT-->
95
+<!--        tpir.person_name as  person_name,-->
96
+<!--        tp.phone as phone,-->
97
+<!--        tpir.building_name as building_name,-->
98
+<!--        SUM(tpir.intention) as intention-->
99
+<!--        FROM-->
100
+<!--        ta_person_intention_record tpir-->
101
+<!--        LEFT JOIN ta_person tp on tpir.person_id = tp.person_id-->
102
+<!--        <trim prefix="where" prefixOverrides="and | or">-->
103
+<!--            <if test="buildingId != null and buildingId != ''">-->
104
+<!--                tpir.building_id = #{buildingId}-->
105
+<!--            </if>-->
106
+<!--            <if test="orgId != null">-->
107
+<!--                AND tpir.org_id = #{orgId}-->
108
+<!--                AND tp.org_id = #{orgId}-->
109
+<!--            </if>-->
110
+<!--            <if test="personBuildingList != null and personBuildingList.size > 0">-->
111
+<!--                AND tpir.building_id in-->
112
+<!--                <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">-->
113
+<!--                    #{personBuilding.buildingId}-->
114
+<!--                </foreach>-->
115
+<!--            </if>-->
116
+<!--        </trim>-->
117
+<!--        GROUP BY-->
118
+<!--        tpir.person_id, tpir.building_id-->
119
+<!--        ORDER BY SUM(tpir.intention) DESC-->
72 120
     </select>
73 121
 </mapper>

+ 13
- 15
src/main/resources/mapper/statistic/TaActivityStaticMapper.xml Ver arquivo

@@ -1197,7 +1197,7 @@
1197 1197
         and a.status = 1
1198 1198
         and a.is_first_time = 1
1199 1199
         <if test="targetType != null and targetType != '' and targetType != 'h5'">
1200
-            and a.target_type = #{targetType}
1200
+            and a.target_type = concat(REPLACE(#{targetType}, 'activity', 'dynamic'), '_share')
1201 1201
         </if>
1202 1202
         <if test="startDate != null ">
1203 1203
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
@@ -1210,8 +1210,7 @@
1210 1210
         </if>
1211 1211
         group by a.person_id, a.target_type ,a.target_id
1212 1212
         ) as addRegistNum group by addRegistNum.target_type, addRegistNum.target_id
1213
-        ) as addRegistNum on addRegistNum.target_id = activity.activityId and substring_index(addRegistNum.target_type,
1214
-        '_share', 1) = activity.activityType
1213
+        ) as addRegistNum on addRegistNum.target_id = activity.activityId and REPLACE(addRegistNum.target_type, 'dynamic_share', 'activity') = activity.activityType
1215 1214
         <if test="targetType != null and targetType != ''">
1216 1215
             where activity.activityType = #{targetType}
1217 1216
         </if>
@@ -1410,7 +1409,7 @@
1410 1409
         and a.status = 1
1411 1410
         and a.is_first_time = 1
1412 1411
         <if test="targetType != null and targetType != '' and targetType != 'h5'">
1413
-            and a.target_type = #{targetType}
1412
+            and a.target_type = concat(REPLACE(#{targetType}, 'activity', 'dynamic'), '_share')
1414 1413
         </if>
1415 1414
         <if test="startDate != null ">
1416 1415
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
@@ -1423,8 +1422,7 @@
1423 1422
         </if>
1424 1423
         group by a.person_id, a.target_type ,a.target_id
1425 1424
         ) as addRegistNum group by addRegistNum.target_type, addRegistNum.target_id
1426
-        ) as addRegistNum on addRegistNum.target_id = activity.activityId and substring_index(addRegistNum.target_type,
1427
-        '_share', 1) = activity.activityType
1425
+        ) as addRegistNum on addRegistNum.target_id = activity.activityId and REPLACE(addRegistNum.target_type, 'dynamic_share', 'activity') = activity.activityType
1428 1426
         <if test="targetType != null and targetType != ''">
1429 1427
             where activity.activityType = #{targetType}
1430 1428
         </if>
@@ -1972,18 +1970,18 @@
1972 1970
         if(a.gender = '1', '男', if(a.gender = '2', '女','未知') ) as gender,
1973 1971
         a.province,
1974 1972
         b1.scene_alias as personFrom,
1975
-        GROUP_CONCAT(c.name) as realtyConsultant,
1976
-        ifnull(d.phone, d.tel) as realtyConsultantPhone,
1977
-        ifnull(e.nickname, f.user_name) as sharePersonName,
1978
-        ifnull(e.phone, e.tel) as sharePersonPhone
1973
+        GROUP_CONCAT(d.user_name) as realtyConsultant,
1974
+        d.phone as realtyConsultantPhone,
1975
+        ifnull(e.nickname, f.name) as sharePersonName,
1976
+        ifnull(e.phone, f.phone) as sharePersonPhone
1979 1977
         FROM ta_share_person_from t
1980 1978
         left join ta_person a on t.person_id = a.person_id
1981 1979
         left join ta_person_from_record b on a.person_id = b.person_id and b.org_id = #{orgId} and b.is_first_time =1
1982 1980
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
1983 1981
         left join ta_recommend_customer c on c.person_id = t.person_id
1984
-        left join ta_person d on c.recommend_person = d.person_id
1985
-        left join ta_person e on t.share_person = e.person_id
1986
-        left join ta_user f on t.share_person = f.user_id
1982
+        LEFT JOIN ta_user d ON c.realty_consultant = d.user_id
1983
+        LEFT JOIN ta_person e ON t.share_person = e.person_id
1984
+        LEFT JOIN ta_person f ON t.share_person = f.user_id
1987 1985
         WHERE t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share') and t.org_id =
1988 1986
         #{orgId} and t.status = 1
1989 1987
         and t.is_first_time = 1
@@ -1993,7 +1991,7 @@
1993 1991
             and t.target_id = #{activityId}
1994 1992
         </if>
1995 1993
         <if test="activityType != null and activityType != ''">
1996
-            and t.target_type = concat(#{activityType}, '_share')
1994
+            and t.target_type = concat(REPLACE(#{activityType}, 'activity', 'dynamic'), '_share')
1997 1995
         </if>
1998 1996
         <if test="province != null and province != ''">
1999 1997
             and a.province like concat('%', #{province}, '%')
@@ -2035,7 +2033,7 @@
2035 2033
             and t.target_id = #{activityId}
2036 2034
         </if>
2037 2035
         <if test="activityType != null and activityType != ''">
2038
-            and t.target_type = concat(#{activityType}, '_share')
2036
+            and t.target_type = concat(REPLACE(#{activityType}, 'activity', 'dynamic'), '_share')
2039 2037
         </if>
2040 2038
         <if test="province != null and province != ''">
2041 2039
             and a.province like concat('%', #{province}, '%')