MassDetailCustomerMapper.xml
3.83 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
<?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.MassDetailCustomerMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.MassDetailCustomer">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="staff_relation_id" jdbcType="INTEGER" property="staffRelationId" />
<result column="customer_id" jdbcType="INTEGER" property="customerId" />
<result column="external_user_id" jdbcType="VARCHAR" property="externalUserId" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="del_flag" jdbcType="TINYINT" property="delFlag" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, staff_relation_id, customer_id, `external_user_id`, status, `del_flag`
</sql>
<select id="countCustomerSender" resultType="cn.com.glsx.entmicro.entity.mass.MassStatisticItemEntity">
SELECT COUNT(*) AS dataCount,a.`status` AS dataType FROM `scrm_mass_detail_customer` 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="getCustomerListByMassIdAndStatus" resultType="cn.com.glsx.entmicro.entity.mass.MassCustomerItemEntity">
SELECT a.`id`,b.`mass_id` as massId,a.`customer_id` as customerId,b.`staff_id` as staffId,a.`status`
FROM `scrm_mass_detail_customer` a
LEFT JOIN `scrm_mass_detail_staff` b ON b.`id`=a.`staff_relation_id`
<where>
b.mass_id=#{massId}
<if test="status != null and status!=2">
and a.status=#{status}
</if>
<if test="status != null and status==2">
and a.status in (2,3)
</if>
</where>
</select>
<select id="countCustomers" resultType="java.lang.Integer">
SELECT
COUNT(1)
FROM
`scrm_mass_detail_customer` c
WHERE c.`staff_relation_id` IN
(SELECT
id
FROM
`scrm_mass_detail_staff` s
WHERE s.`mass_id` = #{massId})
</select>
<select id="getSendSuccessCustomerIdList" resultType="java.lang.Integer">
SELECT c.`customer_id` FROM `scrm_mass` m LEFT JOIN `scrm_mass_detail_staff` s ON s.`mass_id`=m.`id`
LEFT JOIN `scrm_mass_detail_customer` c ON c.`staff_relation_id`=s.`id`
WHERE m.`id`=#{massId} AND c.`status`=1 AND m.`del_flag`=0 AND s.`del_flag`=0 AND c.`del_flag`=0
</select>
<select id="getCustomerListByMassIdAndStatusPage"
resultType="cn.com.glsx.entmicro.entity.mass.MassCustomerItemEntity">
SELECT a.`id`,b.`mass_id` as massId,a.`customer_id` as customerId,b.`staff_id` as staffId,a.`status`
FROM `scrm_mass_detail_customer` a
LEFT JOIN `scrm_mass_detail_staff` b ON b.`id`=a.`staff_relation_id`
<where>
b.mass_id=#{massId}
<if test="status != null and status!=2">
and a.status=#{status}
</if>
<if test="status != null and status==2">
and a.status in (2,3)
</if>
</where>
</select>
<update id="updateMassDetailCustomerSendResult" >
UPDATE `scrm_mass_detail_customer` a,`scrm_mass_detail_staff` b
SET a.`status`=#{status}
<where>
a.`staff_relation_id`=b.`id` AND b.`id`=#{staffRelationId} AND a.`customer_id`=#{customerId}
</where>
</update>
<update id="updateMassDetailCustomerSendStatus">
UPDATE `scrm_mass_detail_staff` s,`scrm_mass_detail_customer` c SET c.`status`=3 WHERE s.`id`=c.`staff_relation_id` AND s.`msg_id`=#{msgId}
</update>
<update id="updateMassDetailCustomerStatusByExternalUserId">
UPDATE `scrm_mass_detail_customer` SET `status` = #{status} WHERE staff_relation_id=#{staffRelationId} and external_user_id=#{external_user_id} and del_flag=0
</update>
</mapper>