Subversion Repositories SmartDukaan

Rev

Rev 34474 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
29515 tejbeer 1
package com.spice.profitmandi.dao.entity.dtr;
2
 
33665 ranu 3
import javax.persistence.*;
29515 tejbeer 4
import java.io.Serializable;
5
import java.time.LocalDateTime;
34474 aman.kumar 6
import java.util.Objects;
29515 tejbeer 7
 
8
@Entity
31860 tejbeer 9
@Table(name = "dtr.scratch_offer")
33665 ranu 10
@NamedQueries({@NamedQuery(name = "ScratchOffer.selectAllCountOfOffer",
11
		query = "SELECT so.offerName, COUNT(so) FROM ScratchOffer so " +
33680 ranu 12
				"WHERE so.scratched=true AND so.createdTimestamp BETWEEN :startDate AND :endDate " +
33665 ranu 13
				"GROUP BY so.offerName")
14
})
29515 tejbeer 15
public class ScratchOffer implements Serializable {
16
 
17
	/**
18
	 * 
19
	 */
20
	private static final long serialVersionUID = 1L;
21
 
22
	@Id
23
	@Column(name = "id", unique = true, updatable = false)
24
	@GeneratedValue(strategy = GenerationType.IDENTITY)
25
	private int id;
26
 
27
	@Column(name = "invoice_number")
28
	private String invoiceNumber;
29
 
30
	@Column(name = "customer_id")
31
	private int customerId;
32
 
33
	@Column(name = "offer_name")
34474 aman.kumar 34
	private String offerName;
29515 tejbeer 35
 
36
	@Column(name = "scratched")
37
	private boolean scratched;
38
 
39
	@Column(name = "created_timestamp")
40
	private LocalDateTime createdTimestamp;
41
 
42
	@Column(name = "unlocked_at")
43
	private LocalDateTime unlockedAt;
44
 
45
	@Column(name = "scracthed_at")
46
	private LocalDateTime scracthedAt;
47
 
34474 aman.kumar 48
	@Column(name = "offer_id")
49
	private int offerId;
50
 
51
	@Column(name = "gift_id")
37316 vikas 52
	private Integer giftId = 0;
34474 aman.kumar 53
 
29515 tejbeer 54
	public LocalDateTime getScracthedAt() {
55
		return scracthedAt;
56
	}
57
 
58
	public void setScracthedAt(LocalDateTime scracthedAt) {
59
		this.scracthedAt = scracthedAt;
60
	}
61
 
62
	@Transient
63
	private boolean unlocked;
64
 
65
	@Transient
66
	private LocalDateTime expiredTimestamp;
67
 
32671 ranu 68
	@Transient
69
	private boolean expired;
70
 
71
	public boolean isExpired() {
72
		return expired;
73
	}
74
 
75
	public void setExpired(boolean expired) {
76
		this.expired = expired;
77
	}
78
 
29515 tejbeer 79
	public LocalDateTime getExpiredTimestamp() {
80
		return expiredTimestamp;
81
	}
82
 
83
	public void setExpiredTimestamp(LocalDateTime expiredTimestamp) {
84
		this.expiredTimestamp = expiredTimestamp;
85
	}
86
 
87
	public boolean isUnlocked() {
88
		return unlocked;
89
	}
90
 
91
	public void setUnlocked(boolean unlocked) {
92
		this.unlocked = unlocked;
93
	}
94
 
95
	public LocalDateTime getUnlockedAt() {
96
		return unlockedAt;
97
	}
98
 
99
	public void setUnlockedAt(LocalDateTime unlockedAt) {
100
		this.unlockedAt = unlockedAt;
101
	}
102
 
103
	public int getId() {
104
		return id;
105
	}
106
 
107
	public void setId(int id) {
108
		this.id = id;
109
	}
110
 
111
	public int getCustomerId() {
112
		return customerId;
113
	}
114
 
115
	public void setCustomerId(int customerId) {
116
		this.customerId = customerId;
117
	}
118
 
119
	public String getInvoiceNumber() {
120
		return invoiceNumber;
121
	}
122
 
123
	public void setInvoiceNumber(String invoiceNumber) {
124
		this.invoiceNumber = invoiceNumber;
125
	}
126
 
34474 aman.kumar 127
	public String getOfferName() {
29515 tejbeer 128
		return offerName;
129
	}
130
 
34474 aman.kumar 131
	public void setOfferName(String offerName) {
29515 tejbeer 132
		this.offerName = offerName;
133
	}
134
 
135
	public boolean isScratched() {
136
		return scratched;
137
	}
138
 
139
	public void setScratched(boolean scratched) {
140
		this.scratched = scratched;
141
	}
142
 
143
	public LocalDateTime getCreatedTimestamp() {
144
		return createdTimestamp;
145
	}
146
 
147
	public void setCreatedTimestamp(LocalDateTime createdTimestamp) {
148
		this.createdTimestamp = createdTimestamp;
149
	}
150
 
34474 aman.kumar 151
	public int getOfferId() {
152
		return offerId;
153
	}
154
 
155
	public void setOfferId(int offerId) {
156
		this.offerId = offerId;
157
	}
158
 
37316 vikas 159
	// gift_id is nullable for legacy rows - treat NULL as "no gift" (0)
34474 aman.kumar 160
	public int getGiftId() {
37316 vikas 161
		return giftId == null ? 0 : giftId;
34474 aman.kumar 162
	}
163
 
164
	public void setGiftId(int giftId) {
165
		this.giftId = giftId;
166
	}
167
 
29515 tejbeer 168
	@Override
169
	public int hashCode() {
170
		final int prime = 31;
171
		int result = 1;
172
		result = prime * result + ((createdTimestamp == null) ? 0 : createdTimestamp.hashCode());
173
		result = prime * result + customerId;
174
		result = prime * result + ((expiredTimestamp == null) ? 0 : expiredTimestamp.hashCode());
175
		result = prime * result + id;
176
		result = prime * result + ((invoiceNumber == null) ? 0 : invoiceNumber.hashCode());
177
		result = prime * result + ((offerName == null) ? 0 : offerName.hashCode());
178
		result = prime * result + ((scracthedAt == null) ? 0 : scracthedAt.hashCode());
179
		result = prime * result + (scratched ? 1231 : 1237);
180
		result = prime * result + (unlocked ? 1231 : 1237);
181
		result = prime * result + ((unlockedAt == null) ? 0 : unlockedAt.hashCode());
182
		return result;
183
	}
184
 
185
	@Override
186
	public boolean equals(Object obj) {
187
		if (this == obj)
188
			return true;
189
		if (obj == null)
190
			return false;
191
		if (getClass() != obj.getClass())
192
			return false;
193
		ScratchOffer other = (ScratchOffer) obj;
194
		if (createdTimestamp == null) {
195
			if (other.createdTimestamp != null)
196
				return false;
197
		} else if (!createdTimestamp.equals(other.createdTimestamp))
198
			return false;
199
		if (customerId != other.customerId)
200
			return false;
201
		if (expiredTimestamp == null) {
202
			if (other.expiredTimestamp != null)
203
				return false;
204
		} else if (!expiredTimestamp.equals(other.expiredTimestamp))
205
			return false;
206
		if (id != other.id)
207
			return false;
208
		if (invoiceNumber == null) {
209
			if (other.invoiceNumber != null)
210
				return false;
211
		} else if (!invoiceNumber.equals(other.invoiceNumber))
212
			return false;
34474 aman.kumar 213
		if (!Objects.equals(offerName, other.offerName))
29515 tejbeer 214
			return false;
215
		if (scracthedAt == null) {
216
			if (other.scracthedAt != null)
217
				return false;
218
		} else if (!scracthedAt.equals(other.scracthedAt))
219
			return false;
220
		if (scratched != other.scratched)
221
			return false;
222
		if (unlocked != other.unlocked)
223
			return false;
224
		if (unlockedAt == null) {
225
			if (other.unlockedAt != null)
226
				return false;
227
		} else if (!unlockedAt.equals(other.unlockedAt))
228
			return false;
229
		return true;
230
	}
231
 
232
	@Override
233
	public String toString() {
234
		return "ScratchOffer [id=" + id + ", invoiceNumber=" + invoiceNumber + ", customerId=" + customerId
235
				+ ", offerName=" + offerName + ", scratched=" + scratched + ", createdTimestamp=" + createdTimestamp
236
				+ ", unlockedAt=" + unlockedAt + ", scracthedAt=" + scracthedAt + ", unlocked=" + unlocked
34474 aman.kumar 237
				+ ", offerId=" + offerId + ", giftId=" + giftId
29515 tejbeer 238
				+ ", expiredTimestamp=" + expiredTimestamp + "]";
239
	}
240
 
241
}