CustomerBaseRelationMapper.xml
4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.entmicro.mapper.CustomerBaseRelationMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.CustomerBaseRelation">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="customer_base_id" jdbcType="VARCHAR" property="customerBaseId"/>
<result column="customer_id" jdbcType="INTEGER" property="customerId"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="join_scene" jdbcType="TINYINT" property="joinScene"/>
<result column="join_time" jdbcType="TIMESTAMP" property="joinTime"/>
<result column="group_nickname" jdbcType="VARCHAR" property="groupNickname"/>
<result column="type" jdbcType="TINYINT" property="type"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, customer_base_id, customer_id, created_by, created_time, updated_by, updated_time,
del_flag, join_scene, join_time, group_nickname, `type`
</sql>
<update id="deleteByCustomerBaseId">
update scrm_customer_base_relation set del_flag = -1,updated_time = now() where customer_base_id = #{customerBaseId}
</update>
<update id="deletelist">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update scrm_customer_base_relation
set del_flag = -1,
quit_scene=#{item.quitScene},
updated_time=NOW(),
quit_time=NOW()
where
customer_base_id = #{item.customerBaseId}
and
customer_id = #{item.customerId}
</foreach>
</update>
<update id="updatelist">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update scrm_customer_base_relation
set
updated_time=NOW(),
join_scene=#{item.joinScene},
join_time=#{item.joinTime},
type=#{item.type},
group_nickname=#{item.groupNickname},
invitor=#{item.invitor},
del_flag=0
where
customer_base_id = #{item.customerBaseId}
and
customer_id = #{item.customerId}
</foreach>
</update>
<select id="findByCustomerId" resultMap="BaseResultMap">
select * from scrm_customer_base_relation where
<!-- del_flag =0 and -->
customer_base_id=#{customerBaseId}
</select>
<select id="findFirstCustomerByCustomerId" resultType="cn.com.glsx.entmicro.entity.CustomerBaseRelation">
select * from scrm_customer_base_relation where del_flag = 0 and customer_base_id=#{customerBaseId} and type = 2 order by join_time asc limit 1
</select>
<select id="getChatNum" resultType="cn.com.glsx.entmicro.model.response.ChatNumResponse">
SELECT t.customer_base_id id, COUNT(1) customerNum FROM(
SELECT a.customer_base_id, a.customer_id FROM `scrm_customer_base_relation` a WHERE a.del_flag = 0 AND a.type = 2
AND a.customer_base_id IN
<foreach collection="idList" open="(" close=")" separator="," item="item">
#{item,jdbcType=VARCHAR}
</foreach>
) t GROUP BY t.customer_base_id
</select>
<select id="getNickNameByCustId" resultMap="BaseResultMap">
select GROUP_CONCAT(distinct group_nickname) as group_nickname,
customer_id
from scrm_customer_base_relation
where del_flag = 0
and customer_id in
<foreach collection="idList" open="(" item="item" separator="," close=")">
#{item}
</foreach>
group by customer_id
</select>
</mapper>