Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
21716 ashik.ali 1
package com.spice.profitmandi.dao.entity.transaction;
21545 ashik.ali 2
 
3
import java.io.Serializable;
4
import java.time.LocalDateTime;
5
 
6
import javax.persistence.Column;
7
import javax.persistence.Entity;
21819 amit.gupta 8
import javax.persistence.EnumType;
9
import javax.persistence.Enumerated;
21545 ashik.ali 10
import javax.persistence.GeneratedValue;
11
import javax.persistence.GenerationType;
12
import javax.persistence.Id;
13
import javax.persistence.NamedQueries;
14
import javax.persistence.NamedQuery;
15
import javax.persistence.Table;
16
 
21716 ashik.ali 17
import in.shop2020.model.v1.order.TransactionStatus;
21545 ashik.ali 18
 
19
/**
20
 * This class basically contains transaction details
21
 * 
22
 * @author ashikali
23
 *
24
 */
25
@Entity
26
@Table(name="transaction.transaction", schema = "transaction")
27
@NamedQueries({
28
	@NamedQuery(name = "Transaction.selectCount", query = "select count(t) from Transaction t"),
29
	@NamedQuery(name = "Transaction.selectCountByRetailerId", query = "select count(t) from Transaction t where t.retailerId = :retailerId"),
30
	@NamedQuery(name="Transaction.selectAll", query="select t from Transaction t"),
21809 amit.gupta 31
	//and t.status in (1,2,4,5,6)
32
	@NamedQuery(name="Transaction.selectById", query="select t from Transaction t where t.id= :id"),
21989 amit.gupta 33
	@NamedQuery(name = "Transaction.selectIdsByRetailerId", query = "select t.id from Transaction t where t.retailerId = :retailerId and t.status != 0 order by id desc"),
21545 ashik.ali 34
	@NamedQuery(
35
			name = "Transaction.selectByIds", 
36
			query = "select t.id, t.createTimestamp, o.retailerAddress1, o.retailerAddress2, o.retailerCity, "
37
					+ "o.retailerPinCode, o.retailerState, o.shippingCost, o.statusDescription, o.invoiceNumber, o.airwayBillNumber, o.totalAmount, li.brand, li.modelName, "
21812 amit.gupta 38
					+ "li.modelNumber, li.color, li.quantity, li.unitPrice, p.id, p.name, o.shippingTimestamp, o.status, o.promisedDeliveryTime, o.retailerName, t.status  from Transaction t join Order o on o.transactionId = t.id "
21808 amit.gupta 39
					+ "join LineItem li on li.orderId = o.id left join Provider p on p.id = o.logisticsProviderId where t.id in :ids order by t.id desc")
21545 ashik.ali 40
	})
41
 
42
public class Transaction implements Serializable{
43
 
44
	private static final long serialVersionUID = 1L;
45
 
46
	public Transaction() {
47
	}
48
 
49
	@Id
50
	@Column(name="id", unique=true, updatable=false)
51
	@GeneratedValue(strategy = GenerationType.IDENTITY)
52
	private int id;
53
 
54
	@Column(name = "createdOn")
55
	private LocalDateTime createTimestamp;
56
 
21819 amit.gupta 57
	@Enumerated(EnumType.ORDINAL)
21545 ashik.ali 58
	@Column(name = "status")
59
	private TransactionStatus status;
60
 
61
	@Column(name = "status_message", length = 100)
62
	private String statusMessage;
63
 
64
	@Column(name = "customer_id")
65
	private int retailerId;
66
 
67
	@Column(name = "shopping_cart_id")
68
	private int shoppingCartId;
69
 
70
	@Column(name = "coupon_code", length = 20)
71
	private String couponCode;
72
 
73
	@Column(name = "session_source", length = 100)
74
	private String sessionSource;
75
 
76
	@Column(name = "session_start_time")
77
	private LocalDateTime sessionStateTime;
78
 
79
	@Column(name = "first_source")
80
	private String firstSource;
81
 
82
	@Column(name = "first_source_start_time")
83
	private LocalDateTime firstSourceStateTime;
84
 
85
	@Column(name = "totalShippingCost")
86
	private float totalShippingCost;
87
 
88
	@Column(name = "totalCodCharges")
89
	private float totalCodCharges;
90
 
91
	@Column(name = "payment_option")
92
	private int paymentOption;
93
 
94
	public int getId() {
95
		return id;
96
	}
97
	public void setId(int id) {
98
		this.id = id;
99
	}
100
 
101
 
102
	public LocalDateTime getCreateTimestamp() {
103
		return createTimestamp;
104
	}
105
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
106
		this.createTimestamp = createTimestamp;
107
	}
108
	public TransactionStatus getStatus() {
109
		return status;
110
	}
111
	public void setStatus(TransactionStatus status) {
112
		this.status = status;
113
	}
114
	public String getStatusMessage() {
115
		return statusMessage;
116
	}
117
	public void setStatusMessage(String statusMessage) {
118
		this.statusMessage = statusMessage;
119
	}
120
	public int getRetailerId() {
121
		return retailerId;
122
	}
123
	public void setRetailerId(int retailerId) {
124
		this.retailerId = retailerId;
125
	}
126
	public int getShoppingCartId() {
127
		return shoppingCartId;
128
	}
129
	public void setShoppingCartId(int shoppingCartId) {
130
		this.shoppingCartId = shoppingCartId;
131
	}
132
	public String getCouponCode() {
133
		return couponCode;
134
	}
135
	public void setCouponCode(String couponCode) {
136
		this.couponCode = couponCode;
137
	}
138
	public String getSessionSource() {
139
		return sessionSource;
140
	}
141
	public void setSessionSource(String sessionSource) {
142
		this.sessionSource = sessionSource;
143
	}
144
	public LocalDateTime getSessionStateTime() {
145
		return sessionStateTime;
146
	}
147
	public void setSessionStateTime(LocalDateTime sessionStateTime) {
148
		this.sessionStateTime = sessionStateTime;
149
	}
150
	public String getFirstSource() {
151
		return firstSource;
152
	}
153
	public void setFirstSource(String firstSource) {
154
		this.firstSource = firstSource;
155
	}
156
	public LocalDateTime getFirstSourceStateTime() {
157
		return firstSourceStateTime;
158
	}
159
	public void setFirstSourceStateTime(LocalDateTime firstSourceStateTime) {
160
		this.firstSourceStateTime = firstSourceStateTime;
161
	}
162
	public float getTotalShippingCost() {
163
		return totalShippingCost;
164
	}
165
	public void setTotalShippingCost(float totalShippingCost) {
166
		this.totalShippingCost = totalShippingCost;
167
	}
168
	public float getTotalCodCharges() {
169
		return totalCodCharges;
170
	}
171
	public void setTotalCodCharges(float totalCodCharges) {
172
		this.totalCodCharges = totalCodCharges;
173
	}
174
	public int getPaymentOption() {
175
		return paymentOption;
176
	}
177
	public void setPaymentOption(int paymentOption) {
178
		this.paymentOption = paymentOption;
179
	}
180
 
21924 ashik.ali 181
 
182
 
21545 ashik.ali 183
	@Override
21924 ashik.ali 184
	public int hashCode() {
185
		final int prime = 31;
186
		int result = 1;
187
		result = prime * result + ((couponCode == null) ? 0 : couponCode.hashCode());
188
		result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
189
		result = prime * result + ((firstSource == null) ? 0 : firstSource.hashCode());
190
		result = prime * result + ((firstSourceStateTime == null) ? 0 : firstSourceStateTime.hashCode());
191
		result = prime * result + id;
192
		result = prime * result + paymentOption;
193
		result = prime * result + retailerId;
194
		result = prime * result + ((sessionSource == null) ? 0 : sessionSource.hashCode());
195
		result = prime * result + ((sessionStateTime == null) ? 0 : sessionStateTime.hashCode());
196
		result = prime * result + shoppingCartId;
197
		result = prime * result + ((status == null) ? 0 : status.hashCode());
198
		result = prime * result + ((statusMessage == null) ? 0 : statusMessage.hashCode());
199
		result = prime * result + Float.floatToIntBits(totalCodCharges);
200
		result = prime * result + Float.floatToIntBits(totalShippingCost);
201
		return result;
202
	}
203
	@Override
204
	public boolean equals(Object obj) {
205
		if (this == obj)
206
			return true;
207
		if (obj == null)
208
			return false;
209
		if (getClass() != obj.getClass())
210
			return false;
211
		Transaction other = (Transaction) obj;
212
		if (couponCode == null) {
213
			if (other.couponCode != null)
214
				return false;
215
		} else if (!couponCode.equals(other.couponCode))
216
			return false;
217
		if (createTimestamp == null) {
218
			if (other.createTimestamp != null)
219
				return false;
220
		} else if (!createTimestamp.equals(other.createTimestamp))
221
			return false;
222
		if (firstSource == null) {
223
			if (other.firstSource != null)
224
				return false;
225
		} else if (!firstSource.equals(other.firstSource))
226
			return false;
227
		if (firstSourceStateTime == null) {
228
			if (other.firstSourceStateTime != null)
229
				return false;
230
		} else if (!firstSourceStateTime.equals(other.firstSourceStateTime))
231
			return false;
232
		if (id != other.id)
233
			return false;
234
		if (paymentOption != other.paymentOption)
235
			return false;
236
		if (retailerId != other.retailerId)
237
			return false;
238
		if (sessionSource == null) {
239
			if (other.sessionSource != null)
240
				return false;
241
		} else if (!sessionSource.equals(other.sessionSource))
242
			return false;
243
		if (sessionStateTime == null) {
244
			if (other.sessionStateTime != null)
245
				return false;
246
		} else if (!sessionStateTime.equals(other.sessionStateTime))
247
			return false;
248
		if (shoppingCartId != other.shoppingCartId)
249
			return false;
250
		if (status != other.status)
251
			return false;
252
		if (statusMessage == null) {
253
			if (other.statusMessage != null)
254
				return false;
255
		} else if (!statusMessage.equals(other.statusMessage))
256
			return false;
257
		if (Float.floatToIntBits(totalCodCharges) != Float.floatToIntBits(other.totalCodCharges))
258
			return false;
259
		if (Float.floatToIntBits(totalShippingCost) != Float.floatToIntBits(other.totalShippingCost))
260
			return false;
261
		return true;
262
	}
263
	@Override
21545 ashik.ali 264
	public String toString() {
265
		return "Transaction [createTimestamp=" + createTimestamp + ", status=" + status + ", statusMessage="
266
				+ statusMessage + ", retailerId=" + retailerId + ", shoppingCartId=" + shoppingCartId + ", couponCode="
267
				+ couponCode + ", sessionSource=" + sessionSource + ", sessionStateTime=" + sessionStateTime
268
				+ ", firstSource=" + firstSource + ", firstSourceStateTime=" + firstSourceStateTime
269
				+ ", totalShippingCost=" + totalShippingCost + ", totalCodCharges=" + totalCodCharges
270
				+ ", paymentOption=" + paymentOption + "]";
271
	}
272
 
273
 
274
}