Subversion Repositories SmartDukaan

Rev

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