PadMessageBoxMapper.xml
20.5 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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
<?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.dj.mindworkplate.mapper.PadMessageBoxMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.model.PadMessageBox">
<!--
WARNING - @mbg.generated
-->
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="module_type" property="moduleType" jdbcType="INTEGER"/>
<result column="business_type" property="businessType" jdbcType="INTEGER"/>
<result column="uuid" property="uuid" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
<result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP"/>
<result column="del_flag" property="delFlag" jdbcType="CHAR"/>
<result column="popup_count" property="popupCount" jdbcType="INTEGER"/>
<result column="read_type" property="readType" jdbcType="INTEGER"/>
<result column="read_count" property="readCount" jdbcType="INTEGER"/>
<result column="latest_read_time" property="latestReadTime" jdbcType="TIMESTAMP"/>
<result column="reminder_type" property="reminderType" jdbcType="TINYINT"/>
<result column="msg_title" property="msgTitle" jdbcType="VARCHAR"/>
<result column="task_start_time" property="taskStartTime" jdbcType="TIMESTAMP"/>
<result column="task_end_time" property="taskEndTime" jdbcType="TIMESTAMP"/>
</resultMap>
<resultMap id="newPadMessageBoxDTOMap" type="cn.com.glsx.dj.mindworkplate.dto.messagebox.NewPadMessageBoxDTO" extends="BaseResultMap"/>
<resultMap id="ScriptRecordPadPushDTOMap" extends="BaseResultMap"
type="cn.com.glsx.dj.mindworkplate.dto.script.ScriptRecordPadPushDTO" >
<id column="title" property="title"/>
<id column="task_name" property="taskName"/>
<id column="finish_time" property="finishTime"/>
<id column="task_type" property="taskType"/>
<id column="complete_status" property="completeStatus"/>
<id column="punish_type" property="punishType"/>
<id column="task_progress" property="taskProgress"/>
<id column="course_total_count" property="courseTotalCount"/>
<id column="total_duration" property="totalDuration"/>
<id column="detail_id" property="detailId"/>
</resultMap>
<resultMap id="BoxRecordDetailMap" type="cn.com.glsx.dj.mindworkplate.dto.script.PadMessageBoxRecordDetail">
<id column="id" property="id"/>
<id column="scriptId" property="scriptId"/>
<id column="class_name" property="className"/>
<id column="class_code" property="classCode"/>
<id column="status" property="status"/>
<id column="polish_content" property="polishContent"/>
<id column="push_time" property="pushTime"/>
<id column="label_name" property="excellentLabelName"/>
<id column="scene_label_name" property="sceneLabelName"/>
<result column="created_time" property="createdTime"/>
</resultMap>
<resultMap id="SopTaskMessageMap" type="cn.com.glsx.dj.mindworkplate.dto.script.SopTaskMessageInfoDTO">
<id column="boxId" property="boxId"/>
<id column="push_time" property="pushTime"/>
<id column="status" property="status"/>
<association property="sopTaskDetailInfoDTO" javaType="cn.com.glsx.dj.mindworkplate.dto.sop.SopTaskDetailInfoDTO">
<id column="id" property="id"/>
<id column="check_date" property="checkDate"/>
<id column="staff_uuid" property="staffUuid"/>
<id column="staff_phone" property="staffPhone"/>
<id column="merchant_id" property="merchantId"/>
<id column="task_status" property="taskStatus"/>
</association>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, module_type, business_type, uuid, phone, name, status, created_by, created_time,
updated_by, updated_time, del_flag, popup_count, read_type, read_count, latest_read_time,
reminder_type, msg_title, task_start_time, task_end_time
</sql>
<select id="listMessageBoxRecordDetail" parameterType="cn.com.glsx.dj.mindworkplate.dto.script.ScriptSearchDTO"
resultMap="BoxRecordDetailMap">
select pmb.id,
secc.class_name,
secc.class_code,
ser.polish_content,
ser.push_time,
ser.id as scriptId,
pmb.status, sl.scene_label_name,el.label_name,
pmb.created_time
from pad_message_box pmb
left join script_record_pad_push srpp on pmb.id = srpp.msg_bos_id and srpp.del_flag = 'N'
left join script_extract_record ser on srpp.script_id = ser.id
left join script_extract_config_class secc on ser.class_code = secc.class_code and secc.del_flag = 'N'
left join script_extract_config_scene_label sl on ser.scene_label_code = sl.scene_label_code and sl.del_flag =
'N'
left join script_extract_config_excellent_label el on ser.label_code = el.label_code and el.del_flag = 'N'
<where>
pmb.del_flag = 'N' and ser.del_flag = 'N'
and pmb.module_type = 1
<if test="businessType != null">
and pmb.business_type = #{businessType}
</if>
<if test="businessTypeList != null and businessTypeList.size>0">
and pmb.business_type IN
<foreach item="item" collection="businessTypeList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
and pmb.phone = #{phone}
<if test="classCode != null and classCode != ''">
and ser.class_code = #{classCode}
</if>
<if test="status != null">
and pmb.status = #{status}
</if>
</where>
order by pmb.status asc, ser.push_time desc
</select>
<select id="listSopMessageBoxRecordDetail" parameterType="cn.com.glsx.dj.mindworkplate.dto.script.ScriptSearchDTO" resultMap="SopTaskMessageMap">
select pmb.id as boxId, pmb.created_time as push_time, pmb.status,
stdi.id,
stdi.check_date,
stdi.task_status,
sti.merchant_id,
sti.staff_phone,
sti.staff_uuid
from pad_message_box pmb
inner join sop_task_pad_push stpp on pmb.id = stpp.msg_bos_id and stpp.del_flag = 'N'
inner join sop_task_detail_info stdi on stpp.task_id = stdi.id and stdi.deleted_flag = 'N'
inner join sop_task_info sti on stdi.sop_task_id = sti.id and sti.deleted_flag = 'N'
<where>
pmb.del_flag = 'N'
and pmb.module_type = 3
and pmb.business_type = #{businessType}
and pmb.phone = #{phone}
<if test="status != null">
and pmb.status = #{status}
</if>
<if test="checkDate != null and checkDate != ''">
and stdi.check_date = #{checkDate}
</if>
</where>
order by pmb.created_time desc
</select>
<select id="listAllConfigClass" resultType="cn.com.glsx.dj.mindworkplate.dto.script.ScriptExtractConfigClassCount">
select secc.class_code as classCode,
secc.class_name as className
from script_extract_config_class secc
where secc.del_flag = 'N'
</select>
<select id="pageStaffInfo" resultMap="BaseResultMap">
select staff_uuid as uuid,
staff_name as name,
phone_number as phone
from dj_car_life_staff_info
where deleted_flag = 'N' and phone_number is not null and length(phone_number) > 0
group by phone_number
</select>
<select id="messageBoxCountByStatus" resultType="java.lang.Integer">
SELECT ifnull(count(0),0) FROM `pad_message_box`
WHERE `phone` = #{phone}
AND del_flag='N'
<if test="status != null">
AND status = #{status}
</if>
<if test="businessType != null">
AND (business_type = #{businessType} OR business_type IS NULL)
</if>
<if test="moduleType != null">
and module_type = #{moduleType}
</if>
</select>
<select id="listShortCourseBoxMessage" resultMap="ScriptRecordPadPushDTOMap">
select
pmb.id,
stdi.id detail_id,
case when t.min_box_id = pmb.id then '新的短课程学习任务' else '短课程学习提醒' end title,
case when t.min_box_id = pmb.id then 1 else 2 end task_type,
concat_ws('·','短课程',date_format(stdi.created_date,'%m月%d日')) task_name,
DATE_ADD(stdi.created_date, INTERVAL stc.study_day DAY) finish_time,
pmb.created_time,
case when stdi.task_status = 2 then 1 else 0 end complete_status,
stc.punish_type punish_type,
pmb.status
from pad_message_box pmb
left join sop_task_pad_push stpp on pmb.id = stpp.msg_bos_id
left join (
select stpp2.task_id,min(pmb2.id) min_box_id
from pad_message_box pmb2
left join sop_task_pad_push stpp2 on pmb2.id = stpp2.msg_bos_id
where pmb2.del_flag = 'N' and stpp2.del_flag = 'N' and pmb2.module_type = 3
group by stpp2.task_id
)t on stpp.task_id = t.task_id
left join sop_task_detail_info stdi on stpp.task_id = stdi.id
left join sop_task_info sti on stdi.sop_task_id = sti.id
left join sop_task_config stc on sti.config_id = stc.id
where pmb.del_flag = 'N' and stpp.del_flag = 'N' and stdi.deleted_flag = 'N' and sti.deleted_flag = 'N'
and stc.deleted_flag = 'N' and pmb.module_type = 3 and stdi.business_id is not null
<if test="phone != null and phone != ''">
and sti.staff_phone = #{phone}
</if>
group by pmb.id
order by pmb.status asc, pmb.created_time desc
</select>
<select id="listLongCourseBoxMessage" resultMap="ScriptRecordPadPushDTOMap">
select
pmb.id,
dclcmts.id detail_id,
case when t.min_box_id = pmb.id then '新的长课程学习任务' else '长课程学习提醒' end title,
case when t.min_box_id = pmb.id then 1 else 2 end task_type,
dclcmt.title task_name,
dclcmtec.deadline finish_time,
pmb.created_time,
case when ss.punish_status = 3 then 1 else 0 end complete_status,
dclcmtec.punish_type punish_type,
ROUND(100 * count(case when ssc.status = 5 then ssc.id end) / NULLIF(count(ssc.id), 0), 2) task_progress,
count(ssc.id) course_total_count,
sum(sbc.total_duration) total_duration,
pmb.status, pmb.module_type
from pad_message_box pmb
left join dj_car_life_content_manager_task_staff_pad_push dclcmtspp on pmb.id = dclcmtspp.msg_bos_id
left join (
select dclcmtspp2.task_staff_id, min(pmb2.id) min_box_id
from pad_message_box pmb2
left join dj_car_life_content_manager_task_staff_pad_push dclcmtspp2 on pmb2.id = dclcmtspp2.msg_bos_id
where pmb2.del_flag = 'N' and dclcmtspp2.deleted_flag = 'N' and pmb2.module_type = 4
group by dclcmtspp2.task_staff_id
)t on t.task_staff_id = dclcmtspp.task_staff_id
left join dj_car_life_content_manager_task_staff dclcmts on dclcmtspp.task_staff_id = dclcmts.id
left join dj_car_life_content_manager_task dclcmt on dclcmts.cmt_id = dclcmt.id
left join dj_car_life_content_manager_task_extend_config dclcmtec on dclcmt.id = dclcmtec.cmt_id
left join staff_study ss on dclcmts.id = ss.content_task_staff_id
left join staff_study_course ssc on ss.id = ssc.staff_study_id
left join staff_beisen_course sbc on sbc.course_id = ssc.course_id and sbc.deleted_flag = 'N'
where pmb.del_flag = 'N' and dclcmtspp.deleted_flag = 'N' and dclcmts.deleted_flag = 'N' and dclcmt.deleted_flag = 'N'
and ss.deleted_flag = 'N' and ssc.deleted_flag = 'N' and dclcmtec.deleted_flag = 'N' and pmb.module_type = 4
<if test="phone != null and phone != ''">
and dclcmts.phone_number = #{phone}
</if>
group by pmb.id
union all
select
pmb.id, pmb.id as detail_id,
case when pmb.reminder_type = 1 then '新的长课程学习任务' else '长课程学习提醒' end title,
pmb.reminder_type as task_type, pmb.msg_title as task_name, pmb.task_end_time as finish_time,
pmb.created_time, null as complete_status,null as punish_type, null as task_progress, null as course_total_count, null as total_duration,
pmb.status,pmb.module_type
from pad_message_box pmb
where pmb.del_flag = 'N' and pmb.module_type = 6
<if test="phone != null and phone != ''">
and pmb.phone = #{phone}
</if>
<if test="businessType != null">
and pmb.business_type = #{businessType}
</if>
order by status asc, created_time desc
</select>
<update id="markDeadline">
update pad_message_box set updated_by = #{updatedBy}, updated_time = now(), status = 1
where del_flag = 'N' and status = 0 and id in
<foreach item="item" collection="ids" separator="," open="(" close=")" index="index">
#{item}
</foreach>
</update>
<select id="countMessageBoxByPhone" resultType="cn.com.glsx.dj.mindworkplate.dto.script.PadMessageSummaryDetail">
SELECT module_type as moduleType, ifnull(count(0),0) as count
FROM pad_message_box
WHERE phone = #{phone}
AND del_flag='N'
and module_type in(1,2,3,4,6,7)
<if test="status != null">
AND status = #{status}
</if>
<if test="businessType != null">
AND (business_type = #{businessType} OR business_type IS NULL)
</if>
group by module_type
</select>
<select id="selectLatestActivityMsg" resultType="cn.com.glsx.dj.mindworkplate.model.PadMessageBox">
select t1.created_time as createdTime, t1.module_type as moduleType
from pad_message_box t1
<where>
t1.del_flag = 'N'
and t1.phone = #{phone}
and t1.uuid = #{uuid}
and t1.module_type = 5
<if test="businessType != null">
and t1.business_type = #{businessType}
</if>
</where>
order by t1.status, t1.created_time desc
</select>
<select id="activityMessagePage"
resultType="cn.com.glsx.dj.mindworkplate.dto.messagebox.ActivityMessageRespDTO">
select
t1.created_time as createTime,
t1.id as msgId,
'活动中心' as title,
case t2.type when 0 then '有新的活动请及时查看' else '有新的活动获奖名单,请及时查看' end as content,
t1.status
from pad_message_box t1
left join activity_msg_relation t2 on t1.id = t2.msg_box_id
<where>
t1.del_flag = 'N'
and t1.module_type = 5
<if test="uuid != null and uuid != ''">
and t1.uuid = #{uuid}
</if>
<if test="readFlag != null">
and t1.status = if(#{readFlag}, 1, 0)
</if>
<if test="businessType != null">
and t1.business_type = #{businessType}
</if>
</where>
order by t1.status, t1.created_time desc
</select>
<select id="countMessageBoxByUuid"
resultType="cn.com.glsx.dj.mindworkplate.dto.script.PadMessageSummaryDetail">
SELECT module_type as moduleType, ifnull(count(0),0) as count
FROM pad_message_box
<where>
uuid = #{uuid}
AND del_flag='N'
and module_type in
<foreach item="item" collection="moduleTypes" separator="," open="(" close=")" index="index">
#{item}
</foreach>
<if test="status != null">
AND status = #{status}
</if>
<if test="businessType != null">
AND (business_type = #{businessType} OR business_type IS NULL)
</if>
group by module_type
</where>
</select>
<select id="listExcellentCaseBoxMessage" resultMap="ScriptRecordPadPushDTOMap">
select
pmb.id,
pmb.msg_title as title,
pmb.created_time as created_time,
pmb.status,
pmb.module_type
from pad_message_box pmb
<where>
pmb.del_flag = 'N'
and pmb.module_type = 7
<if test="phone != null and phone != ''">
and pmb.phone = #{phone}
</if>
<if test="businessType != null">
and pmb.business_type = #{businessType}
</if>
<if test="status != null">
and pmb.status = #{status}
</if>
</where>
order by pmb.status asc, pmb.created_time desc
</select>
<select id="getActivityMsgPopUpWindow"
resultType="cn.com.glsx.dj.mindworkplate.dto.messagebox.ActivityMessagePopUpWindowRespDTO">
select
t2.rel_id as relId,
t2.`type`,
t1.id as msgId
from pad_message_box t1
inner join activity_msg_relation t2 on t1.id = t2.msg_box_id
where
t1.del_flag = 'N'
and t1.module_type = '5'
and t1.uuid = #{uuid}
and t1.business_type = #{businessType}
and t1.status = 0
and t1.created_time >= DATE_SUB(CURDATE(), interval 6 day)
order by t2.`type` desc, t1.created_time desc
limit 1
</select>
<select id="pagePadMessageBox" resultMap="newPadMessageBoxDTOMap">
SELECT
<include refid="Base_Column_List" />
FROM pad_message_box
WHERE del_flag = 'N'
<if test="moduleType != null">
AND module_type = #{moduleType,jdbcType=INTEGER}
</if>
<if test="businessType != null">
AND business_type = #{businessType,jdbcType=INTEGER}
</if>
<if test="uuid != null and uuid != ''">
AND uuid = #{uuid,jdbcType=VARCHAR}
</if>
<if test="phone != null and phone != ''">
AND phone = #{phone,jdbcType=VARCHAR}
</if>
<if test="name != null and name != ''">
AND name = #{name,jdbcType=VARCHAR}
</if>
<if test="status != null">
AND status = #{status,jdbcType=INTEGER}
</if>
ORDER BY status ASC
<if test="createdTimeSortType == null or createdTimeSortType == 1">
, created_time DESC
</if>
<if test="createdTimeSortType != null and createdTimeSortType == 0">
, created_time ASC
</if>
</select>
<select id="listUnreadMessageCountByModuleType" parameterType="cn.com.glsx.dj.mindworkplate.dto.messagebox.ModuleUnreadQueryDTO" resultType="cn.com.glsx.dj.mindworkplate.dto.messagebox.ModuleUnreadCountDTO">
SELECT
module_type as moduleType,
COUNT(*) as unreadCount
FROM pad_message_box
WHERE del_flag = 'N'
AND status = 0
AND phone = #{phone}
<if test="moduleTypes != null and moduleTypes.size() > 0">
AND module_type IN
<foreach item="item" collection="moduleTypes" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="businessType != null">
AND business_type = #{businessType}
</if>
GROUP BY module_type
</select>
<select id="listNewShortCourseBoxMessage" resultMap="ScriptRecordPadPushDTOMap">
select
pmb.id,
pmb.msg_title as title,
pmb.created_time as created_time,
pmb.status,
pmb.module_type
from pad_message_box pmb
<where>
pmb.del_flag = 'N'
and pmb.module_type = 9
<if test="phone != null and phone != ''">
and pmb.phone = #{phone}
</if>
<if test="businessType != null">
and pmb.business_type = #{businessType}
</if>
<if test="status != null">
and pmb.status = #{status}
</if>
</where>
order by pmb.status asc, pmb.created_time desc
</select>
</mapper>