Subversion Repositories SmartDukaan

Rev

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