Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
37651 vikas 1
package com.spice.profitmandi.dao.entity.user;
2
 
3
import javax.persistence.Column;
4
import javax.persistence.Entity;
5
import javax.persistence.GeneratedValue;
6
import javax.persistence.GenerationType;
7
import javax.persistence.Id;
8
import javax.persistence.Table;
9
import javax.persistence.UniqueConstraint;
10
import java.time.LocalDateTime;
11
 
12
/**
13
 * Do-not-call register (SOP §17). A retailer who asks not to be contacted goes here and is blocked
14
 * from every future dial, on any lead.
15
 *
16
 * <p>Keyed on the <b>mobile number</b>, not the lead: the same retailer can appear as several leads
17
 * (re-created after a drop, entered by two different agents, Path A and Path B), and a block that
18
 * only covered one row would be no block at all. Numbers are stored as the last 10 digits so
19
 * {@code +91 98…}, {@code 098…} and {@code 98…} all collide on the same row.
20
 *
21
 * <p>Written when an agent dispositions {@code DO_NOT_CALL}, and checked by the dialer pre-check
22
 * before any call is placed. Before this table existed {@code DO_NOT_CALL} only moved the lead's
23
 * stage — nothing stopped a re-dial.
24
 */
25
@Entity
26
@Table(name = "user.lead_dnd",
27
        uniqueConstraints = {@UniqueConstraint(columnNames = "mobile")})
28
public class LeadDnd {
29
 
30
    @Id
31
    @Column(name = "id", unique = true, updatable = false)
32
    @GeneratedValue(strategy = GenerationType.IDENTITY)
33
    private int id;
34
 
35
    /** Last 10 digits, normalised. The block key. */
36
    @Column(name = "mobile")
37
    private String mobile;
38
 
39
    /** The lead that triggered the block — provenance only; the block is number-wide. */
40
    @Column(name = "lead_id")
41
    private Integer leadId;
42
 
43
    /** Who blocked it. */
44
    @Column(name = "auth_id")
45
    private Integer authId;
46
 
47
    /** DISPOSITION (agent marked DO_NOT_CALL) | AUDIT (audit team) | REGULATOR (NCPR/DLT import). */
48
    @Column(name = "source")
49
    private String source;
50
 
51
    @Column(name = "reason")
52
    private String reason;
53
 
54
    @Column(name = "created_timestamp")
55
    private LocalDateTime createdTimestamp;
56
 
57
    /** Reduce any input to the comparable last-10-digit form. Null/short input returns null. */
58
    public static String normalise(String mobile) {
59
        if (mobile == null) {
60
            return null;
61
        }
62
        String digits = mobile.replaceAll("\\D", "");
63
        if (digits.length() < 10) {
64
            return null;
65
        }
66
        return digits.substring(digits.length() - 10);
67
    }
68
 
69
    public int getId() {
70
        return id;
71
    }
72
 
73
    public void setId(int id) {
74
        this.id = id;
75
    }
76
 
77
    public String getMobile() {
78
        return mobile;
79
    }
80
 
81
    public void setMobile(String mobile) {
82
        this.mobile = mobile;
83
    }
84
 
85
    public Integer getLeadId() {
86
        return leadId;
87
    }
88
 
89
    public void setLeadId(Integer leadId) {
90
        this.leadId = leadId;
91
    }
92
 
93
    public Integer getAuthId() {
94
        return authId;
95
    }
96
 
97
    public void setAuthId(Integer authId) {
98
        this.authId = authId;
99
    }
100
 
101
    public String getSource() {
102
        return source;
103
    }
104
 
105
    public void setSource(String source) {
106
        this.source = source;
107
    }
108
 
109
    public String getReason() {
110
        return reason;
111
    }
112
 
113
    public void setReason(String reason) {
114
        this.reason = reason;
115
    }
116
 
117
    public LocalDateTime getCreatedTimestamp() {
118
        return createdTimestamp;
119
    }
120
 
121
    public void setCreatedTimestamp(LocalDateTime createdTimestamp) {
122
        this.createdTimestamp = createdTimestamp;
123
    }
124
 
125
    @Override
126
    public String toString() {
127
        return "LeadDnd [id=" + id + ", mobile=" + mobile + ", source=" + source + ", leadId=" + leadId + "]";
128
    }
129
}