Subversion Repositories SmartDukaan

Rev

Rev 23527 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
23504 ashik.ali 1
package com.spice.profitmandi.dao.entity.dtr;
2
 
3
import java.io.Serializable;
4
import java.time.LocalDateTime;
5
import java.time.format.DateTimeFormatter;
6
 
7
import javax.persistence.Column;
8
import javax.persistence.Convert;
9
import javax.persistence.Entity;
10
import javax.persistence.EnumType;
11
import javax.persistence.Enumerated;
12
import javax.persistence.GeneratedValue;
13
import javax.persistence.GenerationType;
14
import javax.persistence.Id;
15
import javax.persistence.Table;
16
 
17
import org.hibernate.annotations.UpdateTimestamp;
18
 
19
import com.spice.profitmandi.common.enumuration.RechargeStatus;
20
import com.spice.profitmandi.common.model.OperatorType;
21
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
22
import com.spice.profitmandi.dao.enumuration.dtr.RechargeType;
23
 
24
/**
25
 * This class basically contains recharge transaction details
26
 * 
27
 * @author ashikali
28
 *
29
 */
30
 
31
@Entity
32
@Table(name="dtr.recharge_transaction", schema = "dtr")
33
public class RechargeTransaction implements Serializable{
34
 
35
	private static final long serialVersionUID = 1L;
36
 
37
	public RechargeTransaction() {
38
	}
39
 
40
	@Id
41
	@Column(name="id", unique=true, updatable=false)
42
	@GeneratedValue(strategy = GenerationType.IDENTITY)
43
	private int id;
44
 
45
	@Column(name = "retailer_id")
46
	private int retailerId;
47
 
48
	@Column(name = "request_id")
49
	private String requestId;
50
 
51
	@Column(name = "provider_id")
52
	private int providerId;
53
 
54
	@Column(name="operator_id", unique = true)
55
	private int operatorId;
56
 
57
	@Column(name="reference_number", unique = true)
58
	private String referenceNumber;
59
 
60
	@Column(name = "operator_type")
61
	@Enumerated(EnumType.STRING)
62
	private OperatorType operatorType;
63
 
64
	@Column(name = "type")
65
	@Enumerated(EnumType.STRING)
66
	private RechargeType type;
67
 
68
	@Column(name = "amount")
69
	private float amount;
70
 
71
	@Column(name = "status")
72
	@Enumerated(EnumType.STRING)
73
	private RechargeStatus status;
74
 
75
	@Column(name = "status_message")
76
	private String statusMessage;
77
 
78
	@Convert(converter = LocalDateTimeAttributeConverter.class)
79
	@Column(name="create_timestamp", updatable = false)
80
	private LocalDateTime createTimestamp = LocalDateTime.now();
81
 
82
	@Convert(converter = LocalDateTimeAttributeConverter.class)
83
	@Column(name="update_timestamp")
84
	@UpdateTimestamp
85
	private LocalDateTime updateTimestamp = LocalDateTime.now();
86
 
87
	public int getId() {
88
		return id;
89
	}
90
 
91
	public void setId(int id) {
92
		this.id = id;
93
	}
94
 
95
	public int getRetailerId() {
96
		return retailerId;
97
	}
98
 
99
	public void setRetailerId(int retailerId) {
100
		this.retailerId = retailerId;
101
	}
102
 
103
	public String getRequestId() {
104
		return requestId;
105
	}
106
 
107
	public void setRequestId(String requestId) {
108
		this.requestId = requestId;
109
	}
110
 
111
	public int getProviderId() {
112
		return providerId;
113
	}
114
 
115
	public void setProviderId(int providerId) {
116
		this.providerId = providerId;
117
	}
118
 
119
	public int getOperatorId() {
120
		return operatorId;
121
	}
122
 
123
	public void setOperatorId(int operatorId) {
124
		this.operatorId = operatorId;
125
	}
126
 
127
	public String getReferenceNumber() {
128
		return referenceNumber;
129
	}
130
 
131
	public void setReferenceNumber(String referenceNumber) {
132
		this.referenceNumber = referenceNumber;
133
	}
134
 
135
	public OperatorType getOperatorType() {
136
		return operatorType;
137
	}
138
 
139
	public void setOperatorType(OperatorType operatorType) {
140
		this.operatorType = operatorType;
141
	}
142
 
143
	public RechargeType getType() {
144
		return type;
145
	}
146
 
147
	public void setType(RechargeType type) {
148
		this.type = type;
149
	}
150
 
151
	public float getAmount() {
152
		return amount;
153
	}
154
 
155
	public void setAmount(float amount) {
156
		this.amount = amount;
157
	}
158
 
159
	public RechargeStatus getStatus() {
160
		return status;
161
	}
162
 
163
	public void setStatus(RechargeStatus status) {
164
		this.status = status;
165
	}
166
 
167
	public String getStatusMessage() {
168
		return statusMessage;
169
	}
170
 
171
	public void setStatusMessage(String statusMessage) {
172
		this.statusMessage = statusMessage;
173
	}
174
 
175
	public LocalDateTime getCreateTimestamp() {
176
		return createTimestamp;
177
	}
178
 
179
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
180
		this.createTimestamp = createTimestamp;
181
	}
182
 
183
	public LocalDateTime getUpdateTimestamp() {
184
		return updateTimestamp;
185
	}
186
 
187
	public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
188
		this.updateTimestamp = updateTimestamp;
189
	}
190
 
191
	public String getFormattedCreateTimestamp(){
192
		if(createTimestamp == null){
193
			return null;
194
		}
195
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-YYYY HH:mm");
196
		return createTimestamp.format(formatter);
197
    }
198
 
199
	public String getFormattedUpdateTimestamp(){
200
		if(updateTimestamp == null){
201
			return null;
202
		}
203
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-YYYY HH:mm");
204
		return updateTimestamp.format(formatter);
205
    }
206
 
207
	@Override
208
	public int hashCode() {
209
		final int prime = 31;
210
		int result = 1;
211
		result = prime * result + id;
212
		return result;
213
	}
214
 
215
	@Override
216
	public boolean equals(Object obj) {
217
		if (this == obj)
218
			return true;
219
		if (obj == null)
220
			return false;
221
		if (getClass() != obj.getClass())
222
			return false;
223
		RechargeTransaction other = (RechargeTransaction) obj;
224
		if (id != other.id)
225
			return false;
226
		return true;
227
	}
228
 
229
	@Override
230
	public String toString() {
231
		return "RechargeTransaction [id=" + id + ", retailerId=" + retailerId + ", requestId=" + requestId
232
				+ ", providerId=" + providerId + ", operatorId=" + operatorId + ", referenceNumber=" + referenceNumber
233
				+ ", operatorType=" + operatorType + ", type=" + type + ", amount=" + amount + ", status=" + status
234
				+ ", statusMessage=" + statusMessage + ", createTimestamp=" + createTimestamp + ", updateTimestamp="
235
				+ updateTimestamp + "]";
236
	}
237
 
238
}