DracChannelCodeMapper.xml
14.1 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
<?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.DracChannelCodeMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.DracChannelCode">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="code_state" jdbcType="VARCHAR" property="codeState"/>
<result column="code_remark" jdbcType="VARCHAR" property="codeRemark"/>
<result column="auto_add" jdbcType="INTEGER" property="autoAdd"/>
<result column="merchant_id" jdbcType="INTEGER" property="merchantId"/>
<result column="auto_welcome" jdbcType="INTEGER" property="autoWelcome"/>
<result column="config_id" jdbcType="VARCHAR" property="configId"/>
<result column="qr_code" jdbcType="VARCHAR" property="qrCode"/>
<result column="qr_add_time" jdbcType="TIMESTAMP" property="qrAddTime"/>
<result column="code_system" jdbcType="INTEGER" property="codeSystem"/>
<result column="code_uuid" jdbcType="VARCHAR" property="codeUuid"/>
<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="INTEGER" property="delFlag"/>
<result column="tagging" jdbcType="BLOB" property="tagging"/>
<result column="code_name" jdbcType="VARCHAR" property="codeName"/>
</resultMap>
<!--列表-->
<resultMap id="pageResultMap" type="cn.com.glsx.entmicro.model.response.DracChannelCodeListResponse">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="code_state" jdbcType="VARCHAR" property="codeState"/>
<result column="code_remark" jdbcType="VARCHAR" property="codeRemark"/>
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
<result column="qr_code" jdbcType="VARCHAR" property="qrCode"/>
<result column="auto_add" jdbcType="INTEGER" property="autoAdd"/>
<result column="config_id" jdbcType="VARCHAR" property="configId"/>
<result column="code_uuid" jdbcType="VARCHAR" property="codeUuid"/>
<result column="tagging" jdbcType="BLOB" property="tagging"/>
<result column="staff_name" jdbcType="VARCHAR" property="staffName"/>
<result column="code_name" jdbcType="VARCHAR" property="codeName"/>
<result column="auto_welcome" jdbcType="INTEGER" property="autoWelcome"/>
<result column="att_content" jdbcType="VARCHAR" property="attContent"/>
</resultMap>
<!--详情-->
<resultMap id="detailResultMap" type="cn.com.glsx.entmicro.model.response.DracChannelCodeDetailResponse">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="code_state" jdbcType="VARCHAR" property="codeState"/>
<result column="code_remark" jdbcType="VARCHAR" property="codeRemark"/>
<result column="qr_code" jdbcType="VARCHAR" property="qrCode"/>
<result column="auto_add" jdbcType="INTEGER" property="autoAdd"/>
<result column="config_id" jdbcType="VARCHAR" property="configId"/>
<result column="auto_welcome" jdbcType="INTEGER" property="autoWelcome"/>
<result column="code_uuid" jdbcType="VARCHAR" property="codeUuid"/>
<result column="tagging" jdbcType="BLOB" property="tagging"/>
<result column="code_name" jdbcType="VARCHAR" property="codeName"/>
<result column="auto_welcome" jdbcType="INTEGER" property="autoWelcome"/>
<result column="merchant_id" jdbcType="INTEGER" property="merchantId"/>
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="cn.com.glsx.entmicro.entity.DracChannelCode">
<!--
WARNING - @mbg.generated
-->
<result column="tagging" jdbcType="LONGVARCHAR" property="tagging"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, code_state, code_remark, auto_add, merchant_id, auto_welcome, config_id, qr_code,
qr_add_time, code_system, code_uuid, created_by, created_time, updated_by, updated_time,
del_flag, code_name, tagging
</sql>
<sql id="Blob_Column_List">
<!--
WARNING - @mbg.generated
-->
tagging
</sql>
<select id="findDracChannelCodeByName" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
drac_channel_code
where del_flag = 0
<if test="condition.codeName != null and condition.codeName != ''">
and code_name = #{condition.codeName}
</if>
and merchant_id = #{condition.merchantId}
</select>
<select id="findDracChannelCodeByState" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
drac_channel_code
where del_flag = 0
<if test="condition.codeState != null and condition.codeState != ''">
and code_state = #{condition.codeState}
</if>
</select>
<!--删除渠道活码-->
<update id="deleteChannelCode">
update drac_channel_code
set del_flag = -1,
updated_time = NOW()
where id = #{codeId}
and merchant_id = #{merchantId}
</update>
<!--活码列表-PC端-->
<select id="listChannelCode" resultMap="pageResultMap">
SELECT * from
(SELECT dcc.id,
dcc.code_name,
dcc.code_remark,
dcc.code_state,
dcc.config_id,
dcc.code_uuid,
dcc.auto_add,
dcc.created_time,
dcc.qr_code,
dcc.tagging,
dcc.auto_welcome,
dcc.created_by,
GROUP_CONCAT(DISTINCT dccfs.staff_name order by dccfs.created_time desc) staff_name
FROM drac_channel_code dcc
LEFT JOIN `drac_channel_code_follow_staff` dccfs ON dcc.id = dccfs.code_id AND dccfs.del_flag = 0
LEFT JOIN `entmicro_staff_depart_relation` esdr ON esdr.id = dccfs.staff_id AND esdr.del_flag = 0
WHERE dcc.del_flag = 0
<if test="condition.codeState != null and condition.codeState.size() > 0">
and dcc.code_state in
<foreach collection="condition.codeState" separator="," item="state" open="(" close=")">
#{state}
</foreach>
</if>
AND dcc.code_system = 0
AND dcc.merchant_id = #{condition.merchantId}
GROUP BY dcc.id
ORDER BY dcc.created_time DESC ) t
<where>
<if test="condition.staffName != null and condition.staffName != ''">
t.staff_name LIKE CONCAT('%',#{condition.staffName},'%')
</if>
<if test="condition.codeNameAndRemark != null and condition.codeNameAndRemark != ''">
and concat(ifnull(code_name, ''), ifnull(code_remark, '')) like concat('%',#{condition.codeNameAndRemark},'%')
</if>
</where>
</select>
<!--活码列表-企微端-->
<select id="listEntmicroChannelCode" resultMap="pageResultMap">
select * from
(select t1.id,
t1.code_name,
t1.code_remark,
t1.qr_code,
GROUP_CONCAT(t2.staff_name order by t2.created_time desc) staff_name
from drac_channel_code t1
left join drac_channel_code_follow_staff t2 on t1.id=t2.code_id
left join entmicro_staff_depart_relation t3 on t2.staff_id=t3.id
where t1.del_flag = 0
and t2.del_flag = 0
<if test="condition.uuid != null and condition.uuid != ''">
and t3.user_oneid=#{condition.uuid}
</if>
and t1.merchant_id = #{condition.merchantId}
and code_system = 0
group by t1.id
order by t1.created_time desc) t
<where>
<if test="condition.codeNameOrStaffName != null and condition.codeNameOrStaffName != ''">
CONCAT(code_name, staff_name) like '%${condition.codeNameOrStaffName}%'
</if>
</where>
</select>
<!--获取活码详情-->
<select id="getChannelCodeDetail" resultMap="detailResultMap">
select id, code_name,
code_remark, created_time,
qr_code, tagging,
code_uuid, config_id,
auto_add, auto_welcome,
code_state, merchant_id
from drac_channel_code
where del_flag = 0
<if test="codeUuid != null">
and code_uuid = #{codeUuid}
</if>
<if test="id != null">
and id = #{id}
</if>
<if test="qrCode != null and qrCode != ''">
and qr_code = #{qrCode}
</if>
</select>
<!--当前活码的员工列表-->
<select id="getChannelCodeStaffList" resultType="cn.com.glsx.entmicro.model.response.drainage.DracScrmStaCodeDetailStaffListResponse">
select t3.id staffId,
t2.staff_name staffName,
t2.created_time createdTime,
(case when t2.del_flag = -1 or t3.del_flag = -1
then -1 else 0 end) status,
t1.created_time createDate,
t1.merchant_id merchantId,
(CASE WHEN t2.updated_time IS NOT NULL
THEN t2.updated_time ELSE t3.updated_time END) deleteDate,
t1.code_state codeState
from drac_channel_code t1
left join drac_channel_code_follow_staff t2
on t1.id = t2.code_id
left join entmicro_staff_depart_relation t3
on t2.staff_id = t3.id
where t1.del_flag = 0
and t1.code_state = #{codeState}
group by t3.id
order by t1.created_time desc
</select>
<select id="getPageByCodeIds" resultType="cn.com.glsx.entmicro.model.response.drainage.DracStatisticCodeResponse">
select id, code_name as codeName,
code_state as codeState
from drac_channel_code
where code_system = 0
<if test="codeIds != null and codeIds.size>0">
and code_state in
<foreach collection="codeIds" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="keyWord != null and keyWord != ''">
and code_name like '%${keyWord}%'
</if>
and merchant_id = #{merchantId}
order by created_time desc
</select>
<!--查询所有活码-->
<select id="listAllChannelCode" resultMap="pageResultMap">
select <include refid="Base_Column_List"/>
from drac_channel_code
where del_flag = 0
and merchant_id = #{merchantId}
</select>
<select id="findCodesList" resultType="cn.com.glsx.entmicro.model.response.drainage.DracStatisticCodeResponse">
select id, code_name as codeName,
code_state as codeState
from drac_channel_code
where del_flag = 0
<if test="dracScrmStatisticCodeDefaultRequest.codeIds != null and dracScrmStatisticCodeDefaultRequest.codeIds.size>0">
and code_state in
<foreach collection="dracScrmStatisticCodeDefaultRequest.codeIds" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</if>
and code_system = 0
</select>
<!--无忧服务活码列表-->
<select id="getFreeChannelCode" resultMap="pageResultMap">
SELECT dcc.id,
dcc.code_name,
dswc.att_content,
GROUP_CONCAT(dccfs.staff_name ORDER BY dccfs.created_time DESC) AS staff_name,
dcc.tagging,
dcc.qr_code
FROM `drac_channel_code` dcc
LEFT JOIN `drac_scrm_welcome_config` dswc ON dcc.code_uuid = dswc.business_uuid AND dswc.del_flag = 0 AND dswc.att_type = 7
LEFT JOIN `drac_channel_code_follow_staff` dccfs ON dccfs.code_id = dcc.id AND dccfs.del_flag = 0
WHERE dcc.del_flag = 0
AND (CASE WHEN JSON_VALID(att_content)
THEN CAST(JSON_EXTRACT(dswc.att_content, '$.marketingType')AS UNSIGNED) = 6
ELSE NULL END)
and dcc.merchant_id = #{merchantId}
GROUP BY dcc.id
</select>
<!--查询系统活码-->
<select id="getChannelState" resultMap="BaseResultMap">
SELECT
code_name,
code_state
FROM
drac_channel_code
WHERE code_system = 0
and code_state in
<foreach collection="stateList" open="(" item="item" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getCodeStaffList" resultType="cn.com.glsx.entmicro.model.response.DracChannelCodeStaffRpcResponse">
SELECT es.`id` id,
es.`staff_name` staffName,
GROUP_CONCAT(DISTINCT ed.`department_name`) departmentName,
es.user_id userId,
dcc.code_name codeName,
dcc.`qr_code` qrCode
FROM `drac_channel_code_follow_staff` dccfs
LEFT JOIN `drac_channel_code` dcc ON dcc.id = dccfs.`code_id`
LEFT JOIN `entmicro_staff_depart_relation` esdr ON esdr.id = dccfs.`staff_id`
LEFT JOIN `entmicro_staff` es ON esdr.staff_id = es.`id`
LEFT JOIN `entmicro_department` ed ON ed.id = esdr.`department_id`
WHERE esdr.`relevance_merchant` = #{merchant}
AND esdr.`del_flag` = 0
AND dccfs.`del_flag` = 0
AND es.`del_flag` = 0
<if test="departmentId != null">
AND esdr.department_id = #{departmentId}
</if>
<if test="staffName != null and staffName != ''">
AND es.`staff_name` LIKE '%${staffName}%'
</if>
GROUP BY es.`id`
</select>
</mapper>