yansen 5 年前
父节点
当前提交
a5419eb109
共有 2 个文件被更改,包括 70 次插入69 次删除
  1. 2
    2
      src/main/resources/mapper/ActivityManageMapper.xml
  2. 68
    67
      src/main/resources/mapper/TaChannelMapper.xml

+ 2
- 2
src/main/resources/mapper/ActivityManageMapper.xml 查看文件

@@ -49,7 +49,7 @@
49 49
         ) as visit_num,
50 50
 
51 51
         -- 分享新增用户
52
-        (select count(*) from ta_share_person_from f
52
+        (select count(DISTINCT f.person_id) from ta_share_person_from f
53 53
         where	f.org_id = a.org_id
54 54
         <choose>
55 55
             <when test=" type == 'live'">
@@ -65,7 +65,7 @@
65 65
         ) as new_persons,
66 66
 
67 67
         -- 分享新增客户
68
-        (select count(*) from ta_share_person_from g
68
+        (select count(DISTINCT g.person_id) from ta_share_person_from g
69 69
         inner join ta_person h on h.person_id = g.person_id
70 70
         where	g.org_id = a.org_id
71 71
         <choose>

+ 68
- 67
src/main/resources/mapper/TaChannelMapper.xml 查看文件

@@ -1,67 +1,68 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
-<mapper namespace="com.huiju.estateagents.mapper.TaChannelMapper">
4
-
5
-    <select id="channelCode" resultType="int">
6
-        drop FUNCTION if exists roundNum;
7
-        create function roundNum() returns int
8
-        begin
9
-        declare x int default 1;
10
-        declare y int default 0;
11
-        declare a int default 20;
12
-        declare b int default 1;
13
-        while (b <![CDATA[ < a ]]> ) do
14
-        set x = (select (select FLOOR(100000 + RAND()*900000))  as num);
15
-        set y = (select count(1) from ta_channel where channel_code = x);
16
-        if y = 0
17
-        then return x;
18
-        END IF;
19
-        set b = b + 1;
20
-        end while;
21
-        return 0;
22
-        end;
23
-        select roundNum();
24
-    </select>
25
-    
26
-    <select id="selectChannelList" resultType="com.huiju.estateagents.entity.TaChannel">
27
-        select * from ta_channel
28
-        where org_id = #{orgId}
29
-    </select>
30
-
31
-    <select id="pageTaChannel" resultType="com.huiju.estateagents.entity.TaChannel">
32
-        SELECT
33
-        c.*,
34
-        count(tp.person_id) AS brokerCount,
35
-        (SELECT COUNT(p.recommend_agent ) from ta_person p WHERE cp.person_id = p.recommend_agent) AS inviteCount,
36
-        cp.person_id
37
-        FROM
38
-        ta_channel c
39
-        LEFT JOIN ta_channel_person cp ON c.channel_id = cp.channel_id
40
-        LEFT JOIN ta_person tp ON cp.person_id = tp.person_id 	AND tp.person_type = 'estate agent' 	AND cp.STATUS = 1
41
-        <where>
42
-            <if test="channelId != null and channelId != ''">
43
-                c.channel_id = #{channelId}
44
-            </if>
45
-            and c.org_id = #{orgId}
46
-        </where>
47
-        GROUP BY c.channel_id
48
-    </select>
49
-
50
-    <select id="recommendCount" resultType="com.huiju.estateagents.entity.TaChannel">
51
-        SELECT
52
-            c.channel_id,
53
-            COUNT( rc.recommend_person ) AS recommendCount
54
-        FROM
55
-        ta_channel c
56
-        LEFT JOIN ta_channel_person cp ON c.channel_id = cp.channel_id
57
-        LEFT JOIN ta_recommend_customer rc ON cp.person_id = rc.recommend_person 	AND rc.verify_status = 1 	AND rc.`status` = 1
58
-        <where>
59
-            <if test="channelId != null and channelId != ''">
60
-                c.channel_id = #{channelId}
61
-            </if>
62
-            and c.org_id = #{orgId}
63
-        </where>
64
-        GROUP BY c.channel_id
65
-    </select>
66
-
67
-</mapper>
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.huiju.estateagents.mapper.TaChannelMapper">
4
+
5
+    <select id="channelCode" resultType="int">
6
+        drop FUNCTION if exists roundNum;
7
+        create function roundNum() returns int
8
+        begin
9
+        declare x int default 1;
10
+        declare y int default 0;
11
+        declare a int default 20;
12
+        declare b int default 1;
13
+        while (b <![CDATA[ < a ]]> ) do
14
+        set x = (select (select FLOOR(100000 + RAND()*900000))  as num);
15
+        set y = (select count(1) from ta_channel where channel_code = x);
16
+        if y = 0
17
+        then return x;
18
+        END IF;
19
+        set b = b + 1;
20
+        end while;
21
+        return 0;
22
+        end;
23
+        select roundNum();
24
+    </select>
25
+    
26
+    <select id="selectChannelList" resultType="com.huiju.estateagents.entity.TaChannel">
27
+        select * from ta_channel
28
+        where org_id = #{orgId}
29
+    </select>
30
+
31
+    <select id="pageTaChannel" resultType="com.huiju.estateagents.entity.TaChannel">
32
+        SELECT
33
+        c.*,
34
+        count(tp.person_id) AS brokerCount,
35
+        (SELECT COUNT(p.recommend_agent ) from ta_person p WHERE cp.person_id = p.recommend_agent) AS inviteCount,
36
+        cp.person_id
37
+        FROM
38
+        ta_channel c
39
+        LEFT JOIN ta_channel_person cp ON c.channel_id = cp.channel_id
40
+        LEFT JOIN ta_person tp ON cp.person_id = tp.person_id 	AND tp.person_type = 'estate agent' 	AND cp.STATUS = 1
41
+        <where>
42
+            <if test="channelId != null and channelId != ''">
43
+                c.channel_id = #{channelId}
44
+            </if>
45
+            and c.org_id = #{orgId}
46
+        </where>
47
+        GROUP BY c.channel_id
48
+    </select>
49
+
50
+    <select id="recommendCount" resultType="com.huiju.estateagents.entity.TaChannel">
51
+        SELECT
52
+            c.channel_id,
53
+            COUNT( rc.recommend_person ) AS recommendCount
54
+        FROM
55
+        ta_channel c
56
+        LEFT JOIN ta_channel_person cp ON c.channel_id = cp.channel_id and cp.`status` = 1
57
+        LEFT JOIN ta_person t on cp.person_id = t.person_id and t.person_type = 'estate agent'
58
+        LEFT JOIN ta_recommend_customer rc ON t.person_id = rc.recommend_person AND rc.verify_status = 1 AND rc.`status` = 1
59
+        <where>
60
+            <if test="channelId != null and channelId != ''">
61
+                c.channel_id = #{channelId}
62
+            </if>
63
+            and c.org_id = #{orgId}
64
+        </where>
65
+        GROUP BY c.channel_id
66
+    </select>
67
+
68
+</mapper>