|
@@ -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>
|