MassChatDetailMapper.xml
2.85 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
<?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.MassChatDetailMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.MassChatDetail">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="staff_id" jdbcType="INTEGER" property="staffId" />
<result column="chat_id" jdbcType="VARCHAR" property="chatId" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="send_time" jdbcType="TIMESTAMP" property="sendTime" />
<result column="del_flag" jdbcType="TINYINT" property="delFlag" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, staff_id, chat_id, `status`, send_time, del_flag
</sql>
<select id="selectBystaffIds" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> scrm_mass_chat_detail
where staff_id in
<foreach collection="staffIds" index="staffId" open="(" close=")" separator=",">
#{staffId}
</foreach>
and del_flag = 0;
</select>
<select id="countCustomerSender" resultType="cn.com.glsx.entmicro.entity.mass.MassStatisticItemEntity">
SELECT COUNT(*) AS dataCount,a.`status` AS dataType FROM `scrm_mass_chat_detail` a
LEFT JOIN `scrm_mass_detail_staff` b ON b.`id`=a.`staff_relation_id`
<where>
b.mass_id=#{massId}
GROUP BY a.`status`
</where>
</select>
<select id="searchMassGroupDetailList" resultType="cn.com.glsx.entmicro.entity.mass.MassChatItemEntity">
SELECT a.`id`,b.`staff_id` as staffId,b.`mass_id` as massId,a.`chat_id` as chatId,a.`status`,a.`send_time` as sendTime,c.merchant_id as merchantId,a.staff_relation_id as staffRelationId
FROM `scrm_mass_chat_detail` a
LEFT JOIN `scrm_mass_detail_staff` b ON b.`id`=a.`staff_relation_id`
LEFT JOIN `scrm_mass` c ON c.id=b.`mass_id`
<where>
b.`mass_id`=#{searchRequest.massId}
<if test="searchRequest.status!=null">
and a.`status`=#{searchRequest.status}
</if>
<if test="searchRequest.staffId!=null" >
AND b.`staff_id` = #{searchRequest.staffId}
</if>
</where>
</select>
<select id="countChats" resultType="java.lang.Integer">
SELECT
COUNT(1)
FROM
`scrm_mass_chat_detail` c
WHERE c.`staff_relation_id` IN
(SELECT
id
FROM
`scrm_mass_detail_staff` s
WHERE s.`mass_id` = #{massId})
</select>
<update id="updateMassDetailChatSendResult" >
UPDATE `scrm_mass_chat_detail` a,`scrm_mass_detail_staff` b
SET a.`status`=#{status},a.`send_time`=#{sendTime}
<where>
a.`staff_relation_id`=b.`id` AND b.`id`=#{staffRelationId} AND a.`chat_id`=#{chatId}
</where>
</update>
</mapper>