Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
26332 amit.gupta 1
 
21714 ashik.ali 2
package com.spice.profitmandi.dao.entity.fofo;
21596 ashik.ali 3
 
35065 aman 4
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
5
 
6
import javax.persistence.*;
21596 ashik.ali 7
import java.io.Serializable;
23019 ashik.ali 8
import java.time.LocalDateTime;
21687 ashik.ali 9
import java.util.Set;
21596 ashik.ali 10
 
11
@Entity
31860 tejbeer 12
@Table(name = "fofo.fofo_order_item", uniqueConstraints = {
28566 tejbeer 13
		@UniqueConstraint(name = "UK_ORDER_ID_AND_ITEM_ID", columnNames = { "order_id", "item_id" }) })
31285 tejbeer 14
 
15
@NamedQueries({
16
		@NamedQuery(name = "FofoOrderItem.selectPartnerMonthlySale", query = "select new com.spice.profitmandi.dao.model.PartnerMonthlySaleModel(fo.fofoId, "
17
				+ " DATE_FORMAT(foi.createTimestamp, '%m-%Y'),sum(CAST(foi.quantity*foi.mop  AS int))) from  FofoOrder fo join FofoOrderItem foi on "
18
				+ " fo.id = foi.orderId  where fo.fofoId in :fofoIds and fo.cancelledTimestamp is null "
19
				+ " and foi.createTimestamp >= :startDate"
35065 aman 20
				+ " group by fo.fofoId,DATE_FORMAT(foi.createTimestamp, '%m-%Y')"),
21
		@NamedQuery(
22
				name = "FofoOrderItem.selectPartnerBrandItemMonthlySale",
23
				query = "select new com.spice.profitmandi.dao.model.BrandItemWisePartnerSaleModel( " +
24
						"foi.brand, " +
25
						"foi.modelName, " +
26
						"foi.modelNumber, " +
27
						"sum(foi.quantity)) " +
28
						"from FofoOrder fo " +
29
						"join FofoOrderItem foi on fo.id = foi.orderId " +
30
						"join Catalog ca on ca.modelNumber = foi.modelNumber " +
31
						"where fo.fofoId in :fofoIds " +
32
						"and foi.brand =:brand " +
33
						"and fo.cancelledTimestamp is null " +
34
						"and foi.createTimestamp >= :startDate " +
35084 aman 35
						"and foi.createTimestamp < :endDate " +
36
						"and ca.categoryId =  10006 " +
37
						"group by foi.brand, foi.modelName, foi.modelNumber,ca.categoryId, fo.fofoId,DATE_FORMAT(foi.createTimestamp, '%m-%Y')"
35065 aman 38
		),
35104 vikas 39
        @NamedQuery(
40
                name = "FofoOrderItem.selectBrandItemsByRegionAndDate",
41
                query = "select new com.spice.profitmandi.dao.model.EligibleRewardItemsModel(" +
35152 vikas 42
                        "o.fofoId, pr.regionId, o.id, li.serialNumber, oi.brand, oi.dp, oi.quantity, i.catalogItemId, srh.imeis) " +
35104 vikas 43
                        "from ActivatedImei ai " +
44
                        "join FofoLineItem li on li.serialNumber = ai.serialNumber " +
45
                        "join FofoOrderItem oi on oi.id = li.fofoOrderItemId " +
46
                        "join FofoOrder o on o.id = oi.orderId " +
35193 vikas 47
                        "join Item i on i.id = oi.itemId and i.brand = :brand " +
48
                        "join PartnerRegion pr on pr.fofoId = o.fofoId and pr.regionId = :regionId " +
35152 vikas 49
                        "left join SaleRewardHistory srh on srh.imeis = ai.serialNumber " +
35193 vikas 50
                        "where ai.activationTimestamp between :orderStartDate and :orderEndDate "
35119 aman 51
		),
35065 aman 52
 
35119 aman 53
		@NamedQuery(
54
				name = "LineItem.selectPartnerBrandItemMonthlySecondarySale",
55
				query = "select new com.spice.profitmandi.dao.model.BrandItemWisePartnerSaleModel( " +
56
						"i.brand, " +
57
						"i.modelName, " +
58
						"i.modelNumber, " +
59
						"sum(l.quantity)) " +
60
						"from Order o " +
61
						"join LineItem l on o.id = l.orderId " +
62
						"join Item i on i.id = l.itemId " +
63
						"join Catalog  ca on ca.modelNumber=i.modelNumber " +
64
						"where i.brand =:brand " +
65
						"and o.retailerId = :fofoIds " +
66
						"and o.billingTimestamp >= :startDate " +
67
						"and o.billingTimestamp < :endDate " +
68
						"and ca.categoryId =  10006 " +
69
						"group by i.brand, i.modelName, i.modelNumber, DATE_FORMAT(o.billingTimestamp, '%m-%Y')"
70
		),
35065 aman 71
})
28566 tejbeer 72
public class FofoOrderItem implements Serializable {
21596 ashik.ali 73
 
74
	private static final long serialVersionUID = 1L;
75
 
76
	@Id
77
	@Column(name = "id")
78
	@GeneratedValue(strategy = GenerationType.IDENTITY)
79
	private int id;
28566 tejbeer 80
 
21596 ashik.ali 81
	@Column(name = "order_id")
82
	private int orderId;
28566 tejbeer 83
 
34287 vikas.jang 84
	@Column(name = "pending_order_item_id")
85
	private int pendingOrderItemId;
86
 
21596 ashik.ali 87
	@Column(name = "item_id")
88
	private int itemId;
28566 tejbeer 89
 
21596 ashik.ali 90
	@Column(name = "quantity")
91
	private int quantity;
28566 tejbeer 92
 
21596 ashik.ali 93
	@Column(name = "selling_price")
94
	private float sellingPrice;
28566 tejbeer 95
 
21710 ashik.ali 96
	@Column(name = "cost")
97
	private float cost;
28566 tejbeer 98
 
26332 amit.gupta 99
	@Column(name = "mop")
100
	private float mop;
28566 tejbeer 101
 
21895 ashik.ali 102
	@Column(name = "igst_rate")
103
	private float igstRate;
28566 tejbeer 104
 
21895 ashik.ali 105
	@Column(name = "cgst_rate")
106
	private float cgstRate;
28566 tejbeer 107
 
21895 ashik.ali 108
	@Column(name = "sgst_rate")
109
	private float sgstRate;
28566 tejbeer 110
 
21895 ashik.ali 111
	@Column(name = "hsn_code")
112
	private String hsnCode;
28566 tejbeer 113
 
21596 ashik.ali 114
	@Column(name = "dp")
115
	private float dp;
28566 tejbeer 116
 
21596 ashik.ali 117
	@Column(name = "brand")
118
	private String brand;
28566 tejbeer 119
 
21596 ashik.ali 120
	@Column(name = "model_name")
121
	private String modelName;
28566 tejbeer 122
 
21596 ashik.ali 123
	@Column(name = "model_number")
124
	private String modelNumber;
28566 tejbeer 125
 
21596 ashik.ali 126
	@Column(name = "color")
127
	private String color;
28566 tejbeer 128
 
22580 ashik.ali 129
	@Column(name = "discount")
130
	private float discount;
28566 tejbeer 131
 
24094 amit.gupta 132
	@Transient
133
	private boolean doa;
28566 tejbeer 134
 
135
	@Transient
136
	private String itemName;
137
 
24094 amit.gupta 138
	public boolean isDoa() {
139
		return doa;
140
	}
28566 tejbeer 141
 
142
	public String getItemName() {
143
		return itemName;
144
	}
145
 
146
	public void setItemName(String itemName) {
147
		this.itemName = itemName;
148
	}
149
 
24094 amit.gupta 150
	public void setDoa(boolean doa) {
151
		this.doa = doa;
152
	}
28566 tejbeer 153
 
23019 ashik.ali 154
	@Convert(converter = LocalDateTimeAttributeConverter.class)
155
	@Column(name = "create_timestamp")
156
	private LocalDateTime createTimestamp = LocalDateTime.now();
28566 tejbeer 157
 
158
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
159
	@JoinColumn(name = "fofo_order_item_id", insertable = false, updatable = false, nullable = false)
22859 ashik.ali 160
	private Set<FofoLineItem> fofoLineItems;
28566 tejbeer 161
 
21596 ashik.ali 162
	public int getId() {
163
		return id;
164
	}
28566 tejbeer 165
 
21596 ashik.ali 166
	public void setId(int id) {
167
		this.id = id;
168
	}
28566 tejbeer 169
 
21596 ashik.ali 170
	public int getOrderId() {
171
		return orderId;
172
	}
28566 tejbeer 173
 
21596 ashik.ali 174
	public void setOrderId(int orderId) {
175
		this.orderId = orderId;
176
	}
28566 tejbeer 177
 
34287 vikas.jang 178
	public int getPendingOrderItemId() {
179
		return pendingOrderItemId;
180
	}
181
 
182
	public void setPendingOrderItemId(int pendingOrderItemId) {
183
		this.pendingOrderItemId = pendingOrderItemId;
184
	}
185
 
21596 ashik.ali 186
	public int getItemId() {
187
		return itemId;
188
	}
28566 tejbeer 189
 
21596 ashik.ali 190
	public void setItemId(int itemId) {
191
		this.itemId = itemId;
192
	}
28566 tejbeer 193
 
21596 ashik.ali 194
	public int getQuantity() {
195
		return quantity;
196
	}
28566 tejbeer 197
 
21596 ashik.ali 198
	public void setQuantity(int quantity) {
199
		this.quantity = quantity;
200
	}
28566 tejbeer 201
 
21596 ashik.ali 202
	public float getSellingPrice() {
203
		return sellingPrice;
204
	}
28566 tejbeer 205
 
21596 ashik.ali 206
	public void setSellingPrice(float sellingPrice) {
207
		this.sellingPrice = sellingPrice;
208
	}
28566 tejbeer 209
 
21710 ashik.ali 210
	public float getCost() {
211
		return cost;
212
	}
28566 tejbeer 213
 
21710 ashik.ali 214
	public void setCost(float cost) {
215
		this.cost = cost;
216
	}
28566 tejbeer 217
 
26332 amit.gupta 218
	public float getMop() {
219
		return mop;
220
	}
28566 tejbeer 221
 
26332 amit.gupta 222
	public void setMop(float mop) {
223
		this.mop = mop;
224
	}
28566 tejbeer 225
 
21895 ashik.ali 226
	public float getIgstRate() {
227
		return igstRate;
21596 ashik.ali 228
	}
28566 tejbeer 229
 
21895 ashik.ali 230
	public void setIgstRate(float igstRate) {
231
		this.igstRate = igstRate;
21596 ashik.ali 232
	}
28566 tejbeer 233
 
21895 ashik.ali 234
	public float getCgstRate() {
235
		return cgstRate;
21687 ashik.ali 236
	}
28566 tejbeer 237
 
21895 ashik.ali 238
	public void setCgstRate(float cgstRate) {
239
		this.cgstRate = cgstRate;
21687 ashik.ali 240
	}
28566 tejbeer 241
 
21895 ashik.ali 242
	public float getSgstRate() {
243
		return sgstRate;
244
	}
28566 tejbeer 245
 
21895 ashik.ali 246
	public void setSgstRate(float sgstRate) {
247
		this.sgstRate = sgstRate;
248
	}
28566 tejbeer 249
 
21895 ashik.ali 250
	public String getHsnCode() {
251
		return hsnCode;
252
	}
28566 tejbeer 253
 
21895 ashik.ali 254
	public void setHsnCode(String hsnCode) {
255
		this.hsnCode = hsnCode;
256
	}
28566 tejbeer 257
 
21596 ashik.ali 258
	public float getDp() {
259
		return dp;
260
	}
26332 amit.gupta 261
 
21596 ashik.ali 262
	public void setDp(float dp) {
263
		this.dp = dp;
264
	}
28566 tejbeer 265
 
21596 ashik.ali 266
	public String getBrand() {
267
		return brand;
268
	}
28566 tejbeer 269
 
21596 ashik.ali 270
	public void setBrand(String brand) {
271
		this.brand = brand;
272
	}
28566 tejbeer 273
 
21596 ashik.ali 274
	public String getModelName() {
275
		return modelName;
276
	}
28566 tejbeer 277
 
21596 ashik.ali 278
	public void setModelName(String modelName) {
279
		this.modelName = modelName;
280
	}
28566 tejbeer 281
 
21596 ashik.ali 282
	public String getModelNumber() {
283
		return modelNumber;
284
	}
28566 tejbeer 285
 
21596 ashik.ali 286
	public void setModelNumber(String modelNumber) {
287
		this.modelNumber = modelNumber;
288
	}
28566 tejbeer 289
 
21596 ashik.ali 290
	public String getColor() {
291
		return color;
292
	}
28566 tejbeer 293
 
21596 ashik.ali 294
	public void setColor(String color) {
295
		this.color = color;
296
	}
28566 tejbeer 297
 
22580 ashik.ali 298
	public float getDiscount() {
299
		return discount;
300
	}
28566 tejbeer 301
 
22580 ashik.ali 302
	public void setDiscount(float discount) {
303
		this.discount = discount;
304
	}
28566 tejbeer 305
 
23019 ashik.ali 306
	public LocalDateTime getCreateTimestamp() {
307
		return createTimestamp;
308
	}
28566 tejbeer 309
 
23019 ashik.ali 310
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
311
		this.createTimestamp = createTimestamp;
312
	}
28566 tejbeer 313
 
22859 ashik.ali 314
	public Set<FofoLineItem> getFofoLineItems() {
315
		return fofoLineItems;
21687 ashik.ali 316
	}
28566 tejbeer 317
 
22859 ashik.ali 318
	public void setFofoLineItems(Set<FofoLineItem> fofoLineItems) {
319
		this.fofoLineItems = fofoLineItems;
21687 ashik.ali 320
	}
28566 tejbeer 321
 
21602 ashik.ali 322
	@Override
21924 ashik.ali 323
	public int hashCode() {
324
		final int prime = 31;
325
		int result = 1;
28566 tejbeer 326
		result = prime * result + ((brand == null) ? 0 : brand.hashCode());
327
		result = prime * result + Float.floatToIntBits(cgstRate);
328
		result = prime * result + ((color == null) ? 0 : color.hashCode());
329
		result = prime * result + Float.floatToIntBits(cost);
330
		result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
331
		result = prime * result + Float.floatToIntBits(discount);
332
		result = prime * result + (doa ? 1231 : 1237);
333
		result = prime * result + Float.floatToIntBits(dp);
334
		result = prime * result + ((fofoLineItems == null) ? 0 : fofoLineItems.hashCode());
335
		result = prime * result + ((hsnCode == null) ? 0 : hsnCode.hashCode());
21924 ashik.ali 336
		result = prime * result + id;
28566 tejbeer 337
		result = prime * result + Float.floatToIntBits(igstRate);
338
		result = prime * result + itemId;
339
		result = prime * result + ((itemName == null) ? 0 : itemName.hashCode());
340
		result = prime * result + ((modelName == null) ? 0 : modelName.hashCode());
341
		result = prime * result + ((modelNumber == null) ? 0 : modelNumber.hashCode());
342
		result = prime * result + Float.floatToIntBits(mop);
343
		result = prime * result + orderId;
344
		result = prime * result + quantity;
345
		result = prime * result + Float.floatToIntBits(sellingPrice);
346
		result = prime * result + Float.floatToIntBits(sgstRate);
21924 ashik.ali 347
		return result;
348
	}
28566 tejbeer 349
 
21924 ashik.ali 350
	@Override
351
	public boolean equals(Object obj) {
352
		if (this == obj)
353
			return true;
354
		if (obj == null)
355
			return false;
356
		if (getClass() != obj.getClass())
357
			return false;
22859 ashik.ali 358
		FofoOrderItem other = (FofoOrderItem) obj;
28566 tejbeer 359
		if (brand == null) {
360
			if (other.brand != null)
361
				return false;
362
		} else if (!brand.equals(other.brand))
363
			return false;
364
		if (Float.floatToIntBits(cgstRate) != Float.floatToIntBits(other.cgstRate))
365
			return false;
366
		if (color == null) {
367
			if (other.color != null)
368
				return false;
369
		} else if (!color.equals(other.color))
370
			return false;
371
		if (Float.floatToIntBits(cost) != Float.floatToIntBits(other.cost))
372
			return false;
373
		if (createTimestamp == null) {
374
			if (other.createTimestamp != null)
375
				return false;
376
		} else if (!createTimestamp.equals(other.createTimestamp))
377
			return false;
378
		if (Float.floatToIntBits(discount) != Float.floatToIntBits(other.discount))
379
			return false;
380
		if (doa != other.doa)
381
			return false;
382
		if (Float.floatToIntBits(dp) != Float.floatToIntBits(other.dp))
383
			return false;
384
		if (fofoLineItems == null) {
385
			if (other.fofoLineItems != null)
386
				return false;
387
		} else if (!fofoLineItems.equals(other.fofoLineItems))
388
			return false;
389
		if (hsnCode == null) {
390
			if (other.hsnCode != null)
391
				return false;
392
		} else if (!hsnCode.equals(other.hsnCode))
393
			return false;
21924 ashik.ali 394
		if (id != other.id)
395
			return false;
28566 tejbeer 396
		if (Float.floatToIntBits(igstRate) != Float.floatToIntBits(other.igstRate))
397
			return false;
398
		if (itemId != other.itemId)
399
			return false;
400
		if (itemName == null) {
401
			if (other.itemName != null)
402
				return false;
403
		} else if (!itemName.equals(other.itemName))
404
			return false;
405
		if (modelName == null) {
406
			if (other.modelName != null)
407
				return false;
408
		} else if (!modelName.equals(other.modelName))
409
			return false;
410
		if (modelNumber == null) {
411
			if (other.modelNumber != null)
412
				return false;
413
		} else if (!modelNumber.equals(other.modelNumber))
414
			return false;
415
		if (Float.floatToIntBits(mop) != Float.floatToIntBits(other.mop))
416
			return false;
417
		if (orderId != other.orderId)
418
			return false;
419
		if (quantity != other.quantity)
420
			return false;
421
		if (Float.floatToIntBits(sellingPrice) != Float.floatToIntBits(other.sellingPrice))
422
			return false;
423
		if (Float.floatToIntBits(sgstRate) != Float.floatToIntBits(other.sgstRate))
424
			return false;
21924 ashik.ali 425
		return true;
426
	}
28566 tejbeer 427
 
21924 ashik.ali 428
	@Override
21602 ashik.ali 429
	public String toString() {
22859 ashik.ali 430
		return "FofoOrderItem [id=" + id + ", orderId=" + orderId + ", itemId=" + itemId + ", quantity=" + quantity
26332 amit.gupta 431
				+ ", sellingPrice=" + sellingPrice + ", cost=" + cost + ", mop=" + mop + ", igstRate=" + igstRate
432
				+ ", cgstRate=" + cgstRate + ", sgstRate=" + sgstRate + ", hsnCode=" + hsnCode + ", dp=" + dp
433
				+ ", brand=" + brand + ", modelName=" + modelName + ", modelNumber=" + modelNumber + ", color=" + color
28566 tejbeer 434
				+ ", discount=" + discount + ", doa=" + doa + ", itemName=" + itemName + ", createTimestamp="
435
				+ createTimestamp + ", fofoLineItems=" + fofoLineItems + "]";
21602 ashik.ali 436
	}
28566 tejbeer 437
 
21596 ashik.ali 438
}