| 37651 |
vikas |
1 |
package com.spice.profitmandi.dao.entity.user;
|
|
|
2 |
|
|
|
3 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadCallProvider;
|
|
|
4 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadCallStatus;
|
|
|
5 |
|
|
|
6 |
import javax.persistence.Column;
|
|
|
7 |
import javax.persistence.Entity;
|
|
|
8 |
import javax.persistence.EnumType;
|
|
|
9 |
import javax.persistence.Enumerated;
|
|
|
10 |
import javax.persistence.GeneratedValue;
|
|
|
11 |
import javax.persistence.GenerationType;
|
|
|
12 |
import javax.persistence.Id;
|
|
|
13 |
import javax.persistence.Table;
|
|
|
14 |
import javax.persistence.UniqueConstraint;
|
|
|
15 |
import java.time.LocalDateTime;
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* One dial attempt against an LMS lead (SOP §12) — the call history {@code Lead} cannot hold.
|
|
|
19 |
*
|
|
|
20 |
* <p>{@code Lead} keeps a single last-write-wins {@code disposition} and {@code recording_url} and has
|
|
|
21 |
* no call id, duration or direction at all; {@code lead_activity} is an append-only human trail whose
|
|
|
22 |
* {@code remark} is rendered prose. Neither can answer "how many calls, how long, which recording".
|
|
|
23 |
* This table can, and {@code lead_activity.lead_call_id} points back at it — the same shape
|
|
|
24 |
* {@code auth.partner_collection_remark.agent_call_log_id} already uses for collection remarks.
|
|
|
25 |
*
|
|
|
26 |
* <p>Rows are created by the answer webhook (not by the browser), keyed on the provider's
|
|
|
27 |
* {@code conversation_uuid}, and then advanced by the event and recording webhooks. Deliberately
|
|
|
28 |
* separate from {@code cs.agent_call_log}: that table is Knowlarity-shaped, keyed off
|
|
|
29 |
* {@code sip_master.caller_id}, and shared with the ticket/upsell flows this feature must not disturb.
|
|
|
30 |
*/
|
|
|
31 |
@Entity
|
|
|
32 |
@Table(name = "user.lead_call",
|
|
|
33 |
uniqueConstraints = {@UniqueConstraint(columnNames = "provider_call_uuid")})
|
|
|
34 |
public class LeadCall {
|
|
|
35 |
|
|
|
36 |
@Id
|
|
|
37 |
@Column(name = "id", unique = true, updatable = false)
|
|
|
38 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
|
39 |
private int id;
|
|
|
40 |
|
|
|
41 |
@Column(name = "lead_id")
|
|
|
42 |
private int leadId;
|
|
|
43 |
|
|
|
44 |
/** The agent who placed the call — {@code auth.auth_user.id}. */
|
|
|
45 |
@Column(name = "auth_id")
|
|
|
46 |
private int authId;
|
|
|
47 |
|
|
|
48 |
@Column(name = "provider")
|
|
|
49 |
@Enumerated(EnumType.STRING)
|
|
|
50 |
private LeadCallProvider provider;
|
|
|
51 |
|
|
|
52 |
/**
|
|
|
53 |
* The provider's own id for the agent leg. Null until the provider tells us — the row is created
|
|
|
54 |
* on the answer webhook, which is the first moment we have a durable handle.
|
|
|
55 |
*/
|
|
|
56 |
@Column(name = "provider_call_uuid")
|
|
|
57 |
private String providerCallUuid;
|
|
|
58 |
|
|
|
59 |
/** Groups both legs of the bridged call; this is the correlation key across webhooks. */
|
|
|
60 |
@Column(name = "conversation_uuid")
|
|
|
61 |
private String conversationUuid;
|
|
|
62 |
|
|
|
63 |
/** OUTBOUND for everything today; INBOUND reserved for a future retailer-callback flow. */
|
|
|
64 |
@Column(name = "direction")
|
|
|
65 |
private String direction;
|
|
|
66 |
|
|
|
67 |
/** Outbound CLI actually presented to the retailer. */
|
|
|
68 |
@Column(name = "from_number")
|
|
|
69 |
private String fromNumber;
|
|
|
70 |
|
|
|
71 |
@Column(name = "to_number")
|
|
|
72 |
private String toNumber;
|
|
|
73 |
|
|
|
74 |
@Column(name = "started_at")
|
|
|
75 |
private LocalDateTime startedAt;
|
|
|
76 |
|
|
|
77 |
/** When the retailer picked up. Null on an unanswered call — this is what proves contact. */
|
|
|
78 |
@Column(name = "answered_at")
|
|
|
79 |
private LocalDateTime answeredAt;
|
|
|
80 |
|
|
|
81 |
@Column(name = "ended_at")
|
|
|
82 |
private LocalDateTime endedAt;
|
|
|
83 |
|
|
|
84 |
/** Billed/talk seconds as reported by the provider, not {@code ended - started}. */
|
|
|
85 |
@Column(name = "duration_seconds")
|
|
|
86 |
private Integer durationSeconds;
|
|
|
87 |
|
|
|
88 |
@Column(name = "status")
|
|
|
89 |
@Enumerated(EnumType.STRING)
|
|
|
90 |
private LeadCallStatus status;
|
|
|
91 |
|
|
|
92 |
/** Provider's recording handle, kept as provenance even after we archive our own copy. */
|
|
|
93 |
@Column(name = "recording_uuid")
|
|
|
94 |
private String recordingUuid;
|
|
|
95 |
|
|
|
96 |
/**
|
|
|
97 |
* Key of our own archived copy in the object store. Null until the archival sweep has stored it.
|
|
|
98 |
*
|
|
|
99 |
* <p>Deliberately not {@code dtr.document}: that table's {@code path} is VARCHAR(30) and a
|
|
|
100 |
* recording key is ~58 characters, so routing recordings through it made every upload fail on a
|
|
|
101 |
* STRICT-mode truncation error.
|
|
|
102 |
*/
|
|
|
103 |
@Column(name = "recording_object_key")
|
|
|
104 |
private String recordingObjectKey;
|
|
|
105 |
|
|
|
106 |
/**
|
|
|
107 |
* Failed fetch attempts. A call whose audio has expired at the provider can never succeed, and
|
|
|
108 |
* without a ceiling it would occupy a slot in every batch forever and starve newer recordings.
|
|
|
109 |
*/
|
|
|
110 |
@Column(name = "recording_archive_attempts")
|
|
|
111 |
private int recordingArchiveAttempts;
|
|
|
112 |
|
|
|
113 |
@Column(name = "recording_duration")
|
|
|
114 |
private Integer recordingDuration;
|
|
|
115 |
|
|
|
116 |
/**
|
|
|
117 |
* Our archived copy — {@code dtr.document.id}. Null until the archival worker has fetched it;
|
|
|
118 |
* a null here with a non-null {@code recording_uuid} means "recording exists, not yet pulled".
|
|
|
119 |
*/
|
|
|
120 |
@Column(name = "recording_document_id")
|
|
|
121 |
private Integer recordingDocumentId;
|
|
|
122 |
|
|
|
123 |
/** The trail entry this call produced, once the agent dispositions it. */
|
|
|
124 |
@Column(name = "lead_activity_id")
|
|
|
125 |
private Integer leadActivityId;
|
|
|
126 |
|
|
|
127 |
@Column(name = "created_timestamp")
|
|
|
128 |
private LocalDateTime createdTimestamp;
|
|
|
129 |
|
|
|
130 |
public int getId() {
|
|
|
131 |
return id;
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
public void setId(int id) {
|
|
|
135 |
this.id = id;
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
public int getLeadId() {
|
|
|
139 |
return leadId;
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
public void setLeadId(int leadId) {
|
|
|
143 |
this.leadId = leadId;
|
|
|
144 |
}
|
|
|
145 |
|
|
|
146 |
public int getAuthId() {
|
|
|
147 |
return authId;
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
public void setAuthId(int authId) {
|
|
|
151 |
this.authId = authId;
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
public LeadCallProvider getProvider() {
|
|
|
155 |
return provider;
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
public void setProvider(LeadCallProvider provider) {
|
|
|
159 |
this.provider = provider;
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
public String getProviderCallUuid() {
|
|
|
163 |
return providerCallUuid;
|
|
|
164 |
}
|
|
|
165 |
|
|
|
166 |
public void setProviderCallUuid(String providerCallUuid) {
|
|
|
167 |
this.providerCallUuid = providerCallUuid;
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
public String getConversationUuid() {
|
|
|
171 |
return conversationUuid;
|
|
|
172 |
}
|
|
|
173 |
|
|
|
174 |
public void setConversationUuid(String conversationUuid) {
|
|
|
175 |
this.conversationUuid = conversationUuid;
|
|
|
176 |
}
|
|
|
177 |
|
|
|
178 |
public String getDirection() {
|
|
|
179 |
return direction;
|
|
|
180 |
}
|
|
|
181 |
|
|
|
182 |
public void setDirection(String direction) {
|
|
|
183 |
this.direction = direction;
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
public String getFromNumber() {
|
|
|
187 |
return fromNumber;
|
|
|
188 |
}
|
|
|
189 |
|
|
|
190 |
public void setFromNumber(String fromNumber) {
|
|
|
191 |
this.fromNumber = fromNumber;
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
public String getToNumber() {
|
|
|
195 |
return toNumber;
|
|
|
196 |
}
|
|
|
197 |
|
|
|
198 |
public void setToNumber(String toNumber) {
|
|
|
199 |
this.toNumber = toNumber;
|
|
|
200 |
}
|
|
|
201 |
|
|
|
202 |
public LocalDateTime getStartedAt() {
|
|
|
203 |
return startedAt;
|
|
|
204 |
}
|
|
|
205 |
|
|
|
206 |
public void setStartedAt(LocalDateTime startedAt) {
|
|
|
207 |
this.startedAt = startedAt;
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
public LocalDateTime getAnsweredAt() {
|
|
|
211 |
return answeredAt;
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
public void setAnsweredAt(LocalDateTime answeredAt) {
|
|
|
215 |
this.answeredAt = answeredAt;
|
|
|
216 |
}
|
|
|
217 |
|
|
|
218 |
public LocalDateTime getEndedAt() {
|
|
|
219 |
return endedAt;
|
|
|
220 |
}
|
|
|
221 |
|
|
|
222 |
public void setEndedAt(LocalDateTime endedAt) {
|
|
|
223 |
this.endedAt = endedAt;
|
|
|
224 |
}
|
|
|
225 |
|
|
|
226 |
public Integer getDurationSeconds() {
|
|
|
227 |
return durationSeconds;
|
|
|
228 |
}
|
|
|
229 |
|
|
|
230 |
public void setDurationSeconds(Integer durationSeconds) {
|
|
|
231 |
this.durationSeconds = durationSeconds;
|
|
|
232 |
}
|
|
|
233 |
|
|
|
234 |
public LeadCallStatus getStatus() {
|
|
|
235 |
return status;
|
|
|
236 |
}
|
|
|
237 |
|
|
|
238 |
public void setStatus(LeadCallStatus status) {
|
|
|
239 |
this.status = status;
|
|
|
240 |
}
|
|
|
241 |
|
|
|
242 |
public String getRecordingUuid() {
|
|
|
243 |
return recordingUuid;
|
|
|
244 |
}
|
|
|
245 |
|
|
|
246 |
public void setRecordingUuid(String recordingUuid) {
|
|
|
247 |
this.recordingUuid = recordingUuid;
|
|
|
248 |
}
|
|
|
249 |
|
|
|
250 |
public Integer getRecordingDuration() {
|
|
|
251 |
return recordingDuration;
|
|
|
252 |
}
|
|
|
253 |
|
|
|
254 |
public void setRecordingDuration(Integer recordingDuration) {
|
|
|
255 |
this.recordingDuration = recordingDuration;
|
|
|
256 |
}
|
|
|
257 |
|
|
|
258 |
public String getRecordingObjectKey() {
|
|
|
259 |
return recordingObjectKey;
|
|
|
260 |
}
|
|
|
261 |
|
|
|
262 |
public void setRecordingObjectKey(String recordingObjectKey) {
|
|
|
263 |
this.recordingObjectKey = recordingObjectKey;
|
|
|
264 |
}
|
|
|
265 |
|
|
|
266 |
public int getRecordingArchiveAttempts() {
|
|
|
267 |
return recordingArchiveAttempts;
|
|
|
268 |
}
|
|
|
269 |
|
|
|
270 |
public void setRecordingArchiveAttempts(int recordingArchiveAttempts) {
|
|
|
271 |
this.recordingArchiveAttempts = recordingArchiveAttempts;
|
|
|
272 |
}
|
|
|
273 |
|
|
|
274 |
public Integer getRecordingDocumentId() {
|
|
|
275 |
return recordingDocumentId;
|
|
|
276 |
}
|
|
|
277 |
|
|
|
278 |
public void setRecordingDocumentId(Integer recordingDocumentId) {
|
|
|
279 |
this.recordingDocumentId = recordingDocumentId;
|
|
|
280 |
}
|
|
|
281 |
|
|
|
282 |
public Integer getLeadActivityId() {
|
|
|
283 |
return leadActivityId;
|
|
|
284 |
}
|
|
|
285 |
|
|
|
286 |
public void setLeadActivityId(Integer leadActivityId) {
|
|
|
287 |
this.leadActivityId = leadActivityId;
|
|
|
288 |
}
|
|
|
289 |
|
|
|
290 |
public LocalDateTime getCreatedTimestamp() {
|
|
|
291 |
return createdTimestamp;
|
|
|
292 |
}
|
|
|
293 |
|
|
|
294 |
public void setCreatedTimestamp(LocalDateTime createdTimestamp) {
|
|
|
295 |
this.createdTimestamp = createdTimestamp;
|
|
|
296 |
}
|
|
|
297 |
|
|
|
298 |
@Override
|
|
|
299 |
public String toString() {
|
|
|
300 |
return "LeadCall [id=" + id + ", leadId=" + leadId + ", authId=" + authId + ", provider=" + provider
|
|
|
301 |
+ ", conversationUuid=" + conversationUuid + ", status=" + status
|
|
|
302 |
+ ", durationSeconds=" + durationSeconds + "]";
|
|
|
303 |
}
|
|
|
304 |
}
|