| 35406 |
amit |
1 |
package com.spice.profitmandi.dao.entity.fofo;
|
|
|
2 |
|
|
|
3 |
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
|
|
|
4 |
|
|
|
5 |
import javax.persistence.*;
|
|
|
6 |
import java.io.Serializable;
|
|
|
7 |
import java.time.LocalDateTime;
|
|
|
8 |
import java.util.List;
|
|
|
9 |
|
|
|
10 |
/**
|
|
|
11 |
* Entity representing Pinelabs customer mapping.
|
|
|
12 |
* Maps internal customers (fofo.customer) to Pinelabs customer IDs for payment tokenization.
|
|
|
13 |
*
|
|
|
14 |
* @author Pinelabs Integration Team
|
|
|
15 |
* @since 1.0
|
|
|
16 |
*/
|
|
|
17 |
@Entity
|
| 35652 |
vikas |
18 |
@Table(name = "fofo.pinelabs_customers", schema = "fofo")
|
| 35406 |
amit |
19 |
public class PinelabsCustomer implements Serializable {
|
|
|
20 |
|
|
|
21 |
private static final long serialVersionUID = 1L;
|
|
|
22 |
|
|
|
23 |
@Id
|
|
|
24 |
@Column(name = "id")
|
|
|
25 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
|
26 |
private Long id;
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
* Reference to internal customer ID (fofo.customer.id)
|
|
|
30 |
*/
|
|
|
31 |
@Column(name = "customer_id", nullable = false, unique = true)
|
|
|
32 |
private Integer customerId;
|
|
|
33 |
|
|
|
34 |
/**
|
|
|
35 |
* Customer ID generated by Pinelabs API
|
|
|
36 |
*/
|
|
|
37 |
@Column(name = "pinelabs_customer_id", nullable = false, unique = true, length = 100)
|
|
|
38 |
private String pinelabsCustomerId;
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* Customer mobile number (mirror from customer table for sync)
|
|
|
42 |
*/
|
|
|
43 |
@Column(name = "mobile_number", length = 20)
|
|
|
44 |
private String mobileNumber;
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* Customer email (mirror from customer table for sync)
|
|
|
48 |
*/
|
|
|
49 |
@Column(name = "email", length = 255)
|
|
|
50 |
private String email;
|
|
|
51 |
|
|
|
52 |
/**
|
|
|
53 |
* Customer first name
|
|
|
54 |
*/
|
|
|
55 |
@Column(name = "first_name", length = 100)
|
|
|
56 |
private String firstName;
|
|
|
57 |
|
|
|
58 |
/**
|
|
|
59 |
* Customer last name
|
|
|
60 |
*/
|
|
|
61 |
@Column(name = "last_name", length = 100)
|
|
|
62 |
private String lastName;
|
|
|
63 |
|
|
|
64 |
/**
|
|
|
65 |
* Record creation timestamp
|
|
|
66 |
*/
|
|
|
67 |
@Convert(converter = LocalDateTimeAttributeConverter.class)
|
|
|
68 |
@Column(name = "create_timestamp", nullable = false, updatable = false)
|
|
|
69 |
private LocalDateTime createTimestamp = LocalDateTime.now();
|
|
|
70 |
|
|
|
71 |
/**
|
|
|
72 |
* Record last update timestamp
|
|
|
73 |
*/
|
|
|
74 |
@Convert(converter = LocalDateTimeAttributeConverter.class)
|
|
|
75 |
@Column(name = "update_timestamp", nullable = false)
|
|
|
76 |
private LocalDateTime updateTimestamp = LocalDateTime.now();
|
|
|
77 |
|
|
|
78 |
/**
|
|
|
79 |
* Saved payment methods for this customer
|
|
|
80 |
*/
|
|
|
81 |
@OneToMany(mappedBy = "pinelabsCustomer", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
|
|
82 |
private List<PinelabsPaymentMethod> paymentMethods;
|
|
|
83 |
|
|
|
84 |
/**
|
|
|
85 |
* Default constructor
|
|
|
86 |
*/
|
|
|
87 |
public PinelabsCustomer() {
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
/**
|
|
|
91 |
* Constructor with customer ID
|
|
|
92 |
*
|
|
|
93 |
* @param customerId Internal customer ID
|
|
|
94 |
*/
|
|
|
95 |
public PinelabsCustomer(Integer customerId) {
|
|
|
96 |
this.customerId = customerId;
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
// ==================== Getters and Setters ====================
|
|
|
100 |
|
|
|
101 |
public Long getId() {
|
|
|
102 |
return id;
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
public void setId(Long id) {
|
|
|
106 |
this.id = id;
|
|
|
107 |
}
|
|
|
108 |
|
|
|
109 |
public Integer getCustomerId() {
|
|
|
110 |
return customerId;
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
public void setCustomerId(Integer customerId) {
|
|
|
114 |
this.customerId = customerId;
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
public String getPinelabsCustomerId() {
|
|
|
118 |
return pinelabsCustomerId;
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
public void setPinelabsCustomerId(String pinelabsCustomerId) {
|
|
|
122 |
this.pinelabsCustomerId = pinelabsCustomerId;
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
public String getMobileNumber() {
|
|
|
126 |
return mobileNumber;
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
public void setMobileNumber(String mobileNumber) {
|
|
|
130 |
this.mobileNumber = mobileNumber;
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
public String getEmail() {
|
|
|
134 |
return email;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
public void setEmail(String email) {
|
|
|
138 |
this.email = email;
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
public String getFirstName() {
|
|
|
142 |
return firstName;
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
public void setFirstName(String firstName) {
|
|
|
146 |
this.firstName = firstName;
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
public String getLastName() {
|
|
|
150 |
return lastName;
|
|
|
151 |
}
|
|
|
152 |
|
|
|
153 |
public void setLastName(String lastName) {
|
|
|
154 |
this.lastName = lastName;
|
|
|
155 |
}
|
|
|
156 |
|
|
|
157 |
public LocalDateTime getCreateTimestamp() {
|
|
|
158 |
return createTimestamp;
|
|
|
159 |
}
|
|
|
160 |
|
|
|
161 |
public void setCreateTimestamp(LocalDateTime createTimestamp) {
|
|
|
162 |
this.createTimestamp = createTimestamp;
|
|
|
163 |
}
|
|
|
164 |
|
|
|
165 |
public LocalDateTime getUpdateTimestamp() {
|
|
|
166 |
return updateTimestamp;
|
|
|
167 |
}
|
|
|
168 |
|
|
|
169 |
public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
|
|
|
170 |
this.updateTimestamp = updateTimestamp;
|
|
|
171 |
}
|
|
|
172 |
|
|
|
173 |
public List<PinelabsPaymentMethod> getPaymentMethods() {
|
|
|
174 |
return paymentMethods;
|
|
|
175 |
}
|
|
|
176 |
|
|
|
177 |
public void setPaymentMethods(List<PinelabsPaymentMethod> paymentMethods) {
|
|
|
178 |
this.paymentMethods = paymentMethods;
|
|
|
179 |
}
|
|
|
180 |
|
|
|
181 |
// ==================== Helper Methods ====================
|
|
|
182 |
|
|
|
183 |
/**
|
|
|
184 |
* Get full name of customer
|
|
|
185 |
*
|
|
|
186 |
* @return Full name (firstName + lastName)
|
|
|
187 |
*/
|
|
|
188 |
public String getFullName() {
|
|
|
189 |
if (firstName == null && lastName == null) {
|
|
|
190 |
return null;
|
|
|
191 |
}
|
|
|
192 |
StringBuilder fullName = new StringBuilder();
|
|
|
193 |
if (firstName != null) {
|
|
|
194 |
fullName.append(firstName);
|
|
|
195 |
}
|
|
|
196 |
if (lastName != null) {
|
|
|
197 |
if (fullName.length() > 0) {
|
|
|
198 |
fullName.append(" ");
|
|
|
199 |
}
|
|
|
200 |
fullName.append(lastName);
|
|
|
201 |
}
|
|
|
202 |
return fullName.toString();
|
|
|
203 |
}
|
|
|
204 |
|
|
|
205 |
// ==================== Object Methods ====================
|
|
|
206 |
|
|
|
207 |
@Override
|
|
|
208 |
public int hashCode() {
|
|
|
209 |
final int prime = 31;
|
|
|
210 |
int result = 1;
|
|
|
211 |
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
|
|
212 |
result = prime * result + ((customerId == null) ? 0 : customerId.hashCode());
|
|
|
213 |
result = prime * result + ((pinelabsCustomerId == null) ? 0 : pinelabsCustomerId.hashCode());
|
|
|
214 |
return result;
|
|
|
215 |
}
|
|
|
216 |
|
|
|
217 |
@Override
|
|
|
218 |
public boolean equals(Object obj) {
|
|
|
219 |
if (this == obj)
|
|
|
220 |
return true;
|
|
|
221 |
if (obj == null)
|
|
|
222 |
return false;
|
|
|
223 |
if (getClass() != obj.getClass())
|
|
|
224 |
return false;
|
|
|
225 |
PinelabsCustomer other = (PinelabsCustomer) obj;
|
|
|
226 |
if (id == null) {
|
|
|
227 |
if (other.id != null)
|
|
|
228 |
return false;
|
|
|
229 |
} else if (!id.equals(other.id))
|
|
|
230 |
return false;
|
|
|
231 |
if (customerId == null) {
|
|
|
232 |
if (other.customerId != null)
|
|
|
233 |
return false;
|
|
|
234 |
} else if (!customerId.equals(other.customerId))
|
|
|
235 |
return false;
|
|
|
236 |
if (pinelabsCustomerId == null) {
|
|
|
237 |
if (other.pinelabsCustomerId != null)
|
|
|
238 |
return false;
|
|
|
239 |
} else if (!pinelabsCustomerId.equals(other.pinelabsCustomerId))
|
|
|
240 |
return false;
|
|
|
241 |
return true;
|
|
|
242 |
}
|
|
|
243 |
|
|
|
244 |
@Override
|
|
|
245 |
public String toString() {
|
|
|
246 |
return "PinelabsCustomer [id=" + id + ", customerId=" + customerId + ", pinelabsCustomerId="
|
|
|
247 |
+ pinelabsCustomerId + ", mobileNumber=" + mobileNumber + ", email=" + email + ", firstName="
|
|
|
248 |
+ firstName + ", lastName=" + lastName + ", createTimestamp=" + createTimestamp
|
|
|
249 |
+ ", updateTimestamp=" + updateTimestamp + "]";
|
|
|
250 |
}
|
|
|
251 |
}
|