OutboundTaskCustomerMapper.xml
11.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
<?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.OutboundTaskCustomerMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.outbound.OutboundTaskCustomer">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="outbound_task_tbid" jdbcType="INTEGER" property="outboundTaskTbid"/>
<result column="outbound_execute_task_tbid" jdbcType="INTEGER" property="outboundExecuteTaskTbid"/>
<result column="task_member_id" jdbcType="BIGINT" property="taskMemberId"/>
<result column="phone" jdbcType="VARCHAR" property="phone"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="phone_status" jdbcType="INTEGER" property="phoneStatus"/>
<result column="past_time" jdbcType="TIMESTAMP" property="pastTime"/>
<result column="execute_status" jdbcType="INTEGER" property="executeStatus"/>
<result column="call_times" jdbcType="INTEGER" property="callTimes"/>
<result column="call_start_time" jdbcType="TIMESTAMP" property="callStartTime"/>
<result column="call_end_time" jdbcType="TIMESTAMP" property="callEndTime"/>
<result column="end_type" jdbcType="INTEGER" property="endType"/>
<result column="end_type_reason" jdbcType="VARCHAR" property="endTypeReason"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<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="phone_msg_status" jdbcType="TINYINT" property="phoneMsgStatus"/>
<result column="phone_msg_detail" jdbcType="VARCHAR" property="phoneMsgDetail"/>
<result column="talking_time_len" jdbcType="INTEGER" property="talkingTimeLen"/>
<result column="talking_time_leng" jdbcType="INTEGER" property="talkingTimeLeng"/>
<result column="start_time" jdbcType="BIGINT" property="startTime"/>
<result column="intent" jdbcType="VARCHAR" property="intent"/>
<result column="car_number" jdbcType="VARCHAR" property="carNumber"/>
<result column="last_insurance_company" jdbcType="VARCHAR" property="lastInsuranceCompany"/>
<result column="insurance_end_time" jdbcType="DATE" property="insuranceEndTime"/>
</resultMap>
<resultMap id="BaseResponseMap" type="cn.com.glsx.entmicro.model.response.outbound.OutBoundTaskCustomerRpcResponse">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="outbound_task_tbid" jdbcType="INTEGER" property="outboundTaskTbid"/>
<result column="outbound_execute_task_tbid" jdbcType="INTEGER" property="outboundExecuteTaskTbid"/>
<result column="task_member_id" jdbcType="BIGINT" property="taskMemberId"/>
<result column="phone" jdbcType="VARCHAR" property="phone"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="phone_status" jdbcType="INTEGER" property="phoneStatus"/>
<result column="past_time" jdbcType="TIMESTAMP" property="pastTime"/>
<result column="execute_status" jdbcType="INTEGER" property="executeStatus"/>
<result column="call_times" jdbcType="INTEGER" property="callTimes"/>
<result column="call_start_time" jdbcType="TIMESTAMP" property="callStartTime"/>
<result column="call_end_time" jdbcType="TIMESTAMP" property="callEndTime"/>
<result column="end_type" jdbcType="INTEGER" property="endType"/>
<result column="end_type_reason" jdbcType="VARCHAR" property="endTypeReason"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<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="talking_time_len" jdbcType="INTEGER" property="talkingTimeLen"/>
<result column="talking_time_leng" jdbcType="INTEGER" property="talkingTimeLeng"/>
<result column="start_time" jdbcType="BIGINT" property="startTime"/>
<result column="intent" jdbcType="VARCHAR" property="intent"/>
<result column="car_number" jdbcType="VARCHAR" property="carNumber"/>
<result column="last_insurance_company" jdbcType="VARCHAR" property="lastInsuranceCompany"/>
<result column="insurance_end_time" jdbcType="DATE" property="insuranceEndTime"/>
</resultMap>
<sql id="Base_Column_List">
id, outbound_task_tbid, outbound_execute_task_tbid, task_member_id, phone, `name`,
phone_status, past_time, execute_status, call_times, call_start_time, call_end_time, end_type,
end_type_reason, del_flag, created_by, created_time, updated_by, updated_time, phone_msg_status, phone_msg_detail,
talking_time_len,talking_time_leng,start_time,intent,car_number,last_insurance_company,insurance_end_time
</sql>
<update id="updateOutboundTaskCustomerPhoneStatus">
UPDATE `scrm_outbound_task_customer` SET phone_status=4,past_time=SYSDATE()
WHERE phone=#{customerPhone}
AND outbound_task_tbid
IN (SELECT id FROM `scrm_outbound_task` WHERE merchant_id IN
<foreach collection="merchantIds" item="merchantId" separator="," close=")" open="(">
#{merchantId}
</foreach>
)
</update>
<select id="queryTaskCustomerCount" resultType="cn.com.glsx.entmicro.model.outbound.TaskCustomerCountModel">
SELECT outbound_task_tbid id,COUNT(execute_status) `count`
FROM `scrm_outbound_task_customer`
WHERE outbound_task_tbid IN
<foreach collection="outboundTaskTbids" open="(" close=")" separator="," item="id">
#{id}
</foreach>
AND execute_status IN (1,2) GROUP BY outbound_task_tbid
</select>
<select id="queryTaskCustomerPhoneStatusCount"
resultType="cn.com.glsx.entmicro.model.outbound.TaskCustomerCountModel">
SELECT outbound_task_tbid id,phone_status phoneStatus,COUNT(phone_status) `count`
FROM `scrm_outbound_task_customer`
WHERE outbound_task_tbid IN
<foreach collection="outboundTaskTbids" open="(" close=")" separator="," item="id">
#{id}
</foreach>
AND phone_status IN (1,2,3,4)
GROUP BY outbound_task_tbid,phone_status
</select>
<select id="getExecuteTaskCustomerPhonesByTaskId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM `scrm_outbound_task_customer`
WHERE outbound_task_tbid = #{taskId}
AND execute_status = 0
AND outbound_execute_task_tbid IS NULL
AND del_flag = 0 LIMIT #{limitNum}
</select>
<select id="countNeedToContinueCustomers" resultType="java.lang.Integer">
SELECT COUNT(1)
FROM `scrm_outbound_task_customer`
WHERE outbound_task_tbid = #{outboundTaskId}
AND outbound_execute_task_tbid IS NULL
</select>
<select id="queryCondition" resultMap="BaseResponseMap">
SELECT * FROM scrm_outbound_task_customer WHERE del_flag = 0
<if test="condition.id != null and condition.id != ''">
AND outbound_task_tbid = #{condition.id}
</if>
<if test="condition.phone != null and condition.phone != ''">
AND phone = #{condition.phone}
</if>
<if test="condition.phoneStatus != null and condition.phoneStatus != ''">
AND phone_status = #{condition.phoneStatus}
</if>
</select>
<select id="selectTaskCountTotalCallMinuteAndAnswersById"
resultType="cn.com.glsx.entmicro.model.response.outbound.OutboundCallTaskEchoRpcResponse">
SELECT COUNT(1) answers, IF(SUM(t.`talking_time_leng`) IS NULL,0,SUM(t.`talking_time_leng`)) totalCallMinute
FROM `scrm_outbound_task_customer` t
WHERE t.`outbound_task_tbid`=#{taskId}
AND t.`end_type`=1
AND t.`talking_time_leng`>0
AND t.`del_flag`=0;
</select>
<select id="selectNotConnectPhoneStatusList"
resultType="cn.com.glsx.entmicro.model.response.outbound.NotConnectPhoneStatusResponse">
SELECT t.`end_type_reason` reason,COUNT(1) notConnectCount
FROM `scrm_outbound_task_customer` t
WHERE t.`outbound_task_tbid`=#{taskId}
AND t.`end_type`=0
AND t.`del_flag`=0
GROUP BY t.`end_type_reason`
</select>
<select id="selectTaskCountTotalCallMinuteAndAnswersByIds" resultType="cn.com.glsx.entmicro.model.response.outbound.OutboundCallTaskEchoRpcResponse">
SELECT t.`outbound_task_tbid` id,IF(SUM(t.`talking_time_leng`) IS NULL,0,SUM(t.`talking_time_leng`))
totalCallMinute
FROM `scrm_outbound_task_customer` t
WHERE t.`outbound_task_tbid` IN
<foreach collection="taskIds" item="taskId" open="(" separator="," close=")">
#{taskId}
</foreach>
AND t.`end_type`=1
AND t.`talking_time_leng`>0
AND t.`del_flag`=0
GROUP BY t.`outbound_task_tbid`
</select>
<select id="findCustomersPageByCondition" resultMap="BaseResponseMap">
SELECT
<include refid="Base_Column_List"/>
FROM `scrm_outbound_task_customer` t
WHERE t.`outbound_task_tbid` = #{taskId}
<if test="phone!=null and phone!=''">
AND t.phone LIKE CONCAT('%',#{phone},'%')
</if>
<if test="answer!=null and answer.size()>0 and endType != null and endType==1">
AND (t.end_type_reason IN
<foreach collection="answer" item="reason" open="(" separator="," close=")">
#{reason}
</foreach>
OR t.talking_time_len <![CDATA[>]]> 0)
</if>
<if test="answer!=null and answer.size()>0 and endType == null">
AND t.end_type = 0
AND t.end_type_reason IN
<foreach collection="answer" item="reason" open="(" separator="," close=")">
#{reason}
</foreach>
</if>
<if test="answer==null and endType != null and endType==1">
AND t.talking_time_len <![CDATA[>]]> 0
</if>
<if test="reCallTimes != null">
AND t.call_times = #{reCallTimes}+1
</if>
<if test="intent != null and intent==true ">
AND t.intent is not null
</if>
<if test="intent != null and intent==false ">
AND t.intent is null
</if>
<if test="talkingTimeLenMin != null">
AND t.talking_time_len <![CDATA[>=]]> #{talkingTimeLenMin}
</if>
<if test="talkingTimeLenMax != null">
AND t.talking_time_len <![CDATA[<=]]> #{talkingTimeLenMax}
</if>
<if test="carNumber != null and carNumber != ''">
AND t.car_number LIKE CONCAT('%',#{carNumber},'%')
</if>
<if test="insuranceCompany != null and insuranceCompany != ''">
AND t.last_insurance_company LIKE CONCAT('%',#{insuranceCompany},'%')
</if>
<if test="startTime != null">
AND t.insurance_end_time <![CDATA[>=]]> #{startTime}
</if>
<if test="endTime != null">
AND t.insurance_end_time <![CDATA[<=]]> #{endTime}
</if>
</select>
</mapper>