| 21714 |
ashik.ali |
1 |
package com.spice.profitmandi.dao.entity.fofo;
|
| 21596 |
ashik.ali |
2 |
|
|
|
3 |
import java.io.Serializable;
|
| 25726 |
amit.gupta |
4 |
import java.time.LocalDate;
|
| 21596 |
ashik.ali |
5 |
import java.time.LocalDateTime;
|
| 22243 |
ashik.ali |
6 |
import java.time.format.DateTimeFormatter;
|
| 21596 |
ashik.ali |
7 |
|
|
|
8 |
import javax.persistence.Column;
|
| 22009 |
ashik.ali |
9 |
import javax.persistence.Convert;
|
| 21596 |
ashik.ali |
10 |
import javax.persistence.Entity;
|
|
|
11 |
import javax.persistence.GeneratedValue;
|
|
|
12 |
import javax.persistence.GenerationType;
|
|
|
13 |
import javax.persistence.Id;
|
| 27579 |
tejbeer |
14 |
import javax.persistence.NamedQueries;
|
|
|
15 |
import javax.persistence.NamedQuery;
|
| 21596 |
ashik.ali |
16 |
import javax.persistence.Table;
|
| 25083 |
amit.gupta |
17 |
import javax.persistence.Transient;
|
| 21596 |
ashik.ali |
18 |
|
| 22009 |
ashik.ali |
19 |
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
|
|
|
20 |
|
| 21596 |
ashik.ali |
21 |
@Entity
|
| 27579 |
tejbeer |
22 |
@Table(name = "fofo.fofo_order", schema = "fofo")
|
| 21596 |
ashik.ali |
23 |
|
| 27579 |
tejbeer |
24 |
@NamedQueries({
|
|
|
25 |
|
|
|
26 |
@NamedQuery(name = "FofoOrder.SelectItemWiseTertiary", query = "select new com.spice.profitmandi.dao.model.ItemWiseTertiaryModel(foi.brand,"
|
| 27586 |
tejbeer |
27 |
+ "foi.modelName, foi.modelNumber, foi.color, foi.quantity, foi.mop)"
|
| 27579 |
tejbeer |
28 |
+ " from FofoOrder fo join FofoOrderItem foi on fo.id = foi.orderId where fo.cancelledTimestamp is null and fo.fofoId = :fofoId"
|
|
|
29 |
+ " and fo.createTimestamp between :startDate and :endDate"),
|
|
|
30 |
|
| 27723 |
tejbeer |
31 |
@NamedQuery(name = "FofoOrder.selectGroupByBrandPartnerTertiary", query = "select new com.spice.profitmandi.dao.model.BrandWiseTertiaryModel(foi.brand, "
|
|
|
32 |
+ "sum(case when foi.createTimestamp >= :today then CAST(foi.quantity*foi.mop AS int) else 0 end),"
|
| 27728 |
tejbeer |
33 |
+ "sum(case when foi.createTimestamp >= :threedays and foi.createTimestamp < :endDate then CAST(foi.quantity*foi.mop AS int) else 0 end),"
|
| 27723 |
tejbeer |
34 |
+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :mtd then CAST(foi.quantity*foi.mop AS int) else 0 end),"
|
|
|
35 |
+ "sum(case when foi.createTimestamp between :lmtdStartDate and :lmtdEndDate then CAST(foi.quantity*foi.mop AS int) else 0 end),"
|
| 27748 |
tejbeer |
36 |
+ "sum(case when foi.createTimestamp between :lmtdStartDate and :lmsEndDate then CAST(foi.quantity*foi.mop AS int) else 0 end),"
|
| 27723 |
tejbeer |
37 |
+ "sum(case when foi.createTimestamp >= :today then foi.quantity else 0 end),"
|
| 27728 |
tejbeer |
38 |
+ "sum(case when foi.createTimestamp >= :threedays and foi.createTimestamp < :endDate then foi.quantity else 0 end),"
|
| 27723 |
tejbeer |
39 |
+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :mtd then foi.quantity else 0 end), "
|
| 27748 |
tejbeer |
40 |
+ "sum(case when foi.createTimestamp between :lmtdStartDate and :lmtdEndDate then foi.quantity else 0 end),"
|
|
|
41 |
+ "sum(case when foi.createTimestamp between :lmtdStartDate and :lmsEndDate then foi.quantity else 0 end)"
|
|
|
42 |
+ " )"
|
|
|
43 |
+ " from FofoStore fs join FofoOrder fo on fs.id = fo.fofoId join FofoOrderItem foi on foi.orderId = fo.id join Item i on i.id = foi.itemId "
|
|
|
44 |
+ " where fo.cancelledTimestamp is null and fs.active = true "
|
| 27723 |
tejbeer |
45 |
+ " and foi.createTimestamp >= :lmtdStartDate and fs.warehouseId in :warehouseId"
|
| 27748 |
tejbeer |
46 |
+ " group by foi.brand "),
|
| 27723 |
tejbeer |
47 |
|
| 27738 |
tejbeer |
48 |
@NamedQuery(name = "FofoOrder.selectItemPartnerTertiaryByBrand", query = "select new com.spice.profitmandi.dao.model.BrandItemWiseTertiaryModel(foi.brand, i.modelName,"
|
|
|
49 |
+ " i.modelNumber, i.color, foi.quantity*foi.mop, foi.quantity)"
|
|
|
50 |
+ " from FofoStore fs join FofoOrder fo on fs.id = fo.fofoId join FofoOrderItem foi on foi.orderId = fo.id join "
|
| 27748 |
tejbeer |
51 |
+ " Item i on i.id = foi.itemId where fo.cancelledTimestamp is null and fs.active = true "
|
|
|
52 |
+ " and foi.createTimestamp >= :startDate and foi.createTimestamp < :endDate and fs.warehouseId in :warehouseId and foi.brand in :brand order by foi.itemId desc"),
|
| 27738 |
tejbeer |
53 |
|
|
|
54 |
@NamedQuery(name = "FofoOrder.selectTodayItemPartnerTertiaryByBrand", query = "select new com.spice.profitmandi.dao.model.BrandItemWiseTertiaryModel(foi.brand, i.modelName,"
|
|
|
55 |
+ " i.modelNumber, i.color, foi.quantity*foi.mop, foi.quantity)"
|
|
|
56 |
+ " from FofoStore fs join FofoOrder fo on fs.id = fo.fofoId join FofoOrderItem foi on foi.orderId = fo.id join "
|
| 27748 |
tejbeer |
57 |
+ " Item i on i.id = foi.itemId where fo.cancelledTimestamp is null and fs.active = true "
|
|
|
58 |
+ " and foi.createTimestamp >= :startDate and fs.warehouseId in :warehouseId and foi.brand in :brand order by foi.itemId desc"),
|
| 27738 |
tejbeer |
59 |
|
| 28008 |
tejbeer |
60 |
@NamedQuery(name = "FofoOrder.selectValueOfActivatedImeis", query = "select new com.spice.profitmandi.common.model.ActivatedImeisWithSellingPrice("
|
|
|
61 |
+ " fo.fofoId, foi.brand, sum(CAST(foi.mop AS int) * foi.quantity)) "
|
|
|
62 |
+ " from FofoOrder fo join FofoOrderItem foi on fo.id = foi.orderId join FofoLineItem fli on foi.id = fli.fofoOrderItemId join ActivatedImei ai on "
|
|
|
63 |
+ " fli.serialNumber = ai.serialNumber where fo.createTimestamp between :startDate and :endDate and fo.fofoId = :fofoId and fo.cancelledTimestamp is null group by foi.brand"),
|
|
|
64 |
|
| 28004 |
tejbeer |
65 |
@NamedQuery(name = "FofoOrder.selectPartnersSaleByCatalogId", query = "select new com.spice.profitmandi.dao.model.FofoIdQtyModel("
|
|
|
66 |
+ " fs.id,sum(case when foi.quantity is null then 0 else foi.quantity end))"
|
|
|
67 |
+ " from FofoStore fs join FofoOrder fo on fs.id = fo.fofoId "
|
|
|
68 |
+ " join FofoOrderItem foi on foi.orderId = fo.id join TagListing tl on tl.itemId = foi.itemId "
|
|
|
69 |
+ " join Item i on i.id = tl.itemId"
|
|
|
70 |
+ " where fs.active = 1 and fs.internal = 0 and fo.cancelledTimestamp is null and fo.createTimestamp > :startDate and i.catalogItemId = :catalogItemId and i.categoryId=10006 group by fs.id"),
|
| 27884 |
tejbeer |
71 |
|
| 28004 |
tejbeer |
72 |
@NamedQuery(name = "FofoOrder.selectPartnersSaleByRange", query = "select new com.spice.profitmandi.dao.model.FofoIdItemDetailModel("
|
|
|
73 |
+ " fs.id,sum(case when foi.quantity is null then 0 else foi.quantity end),i.brand,i.modelName,i.modelNumber,i.catalogItemId)"
|
|
|
74 |
+ " from FofoStore fs join FofoOrder fo on fs.id = fo.fofoId "
|
|
|
75 |
+ " join FofoOrderItem foi on foi.orderId = fo.id join TagListing tl on tl.itemId = foi.itemId "
|
|
|
76 |
+ " join Item i on i.id = tl.itemId"
|
|
|
77 |
+ " where fs.active = 1 and fs.internal = 0 and fo.cancelledTimestamp is null "
|
|
|
78 |
+ " and fo.createTimestamp > :startDate and tl.mop between :startPrice and :endPrice and i.categoryId=10006 group by fs.id,i.catalogItemId,i.brand,i.modelName,i.modelNumber"),
|
|
|
79 |
|
| 27579 |
tejbeer |
80 |
})
|
|
|
81 |
public class FofoOrder implements Serializable {
|
|
|
82 |
|
| 21596 |
ashik.ali |
83 |
private static final long serialVersionUID = 1L;
|
|
|
84 |
|
|
|
85 |
@Id
|
|
|
86 |
@Column(name = "id")
|
|
|
87 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
|
88 |
private int id;
|
| 27579 |
tejbeer |
89 |
|
| 21596 |
ashik.ali |
90 |
@Column(name = "fofo_id")
|
|
|
91 |
private int fofoId;
|
| 27579 |
tejbeer |
92 |
|
| 21596 |
ashik.ali |
93 |
@Column(name = "customer_id")
|
|
|
94 |
private int customerId;
|
| 27579 |
tejbeer |
95 |
|
| 21710 |
ashik.ali |
96 |
@Column(name = "customer_address_id")
|
|
|
97 |
private int customerAddressId;
|
| 27579 |
tejbeer |
98 |
|
| 23369 |
ashik.ali |
99 |
@Column(name = "customer_gst_number")
|
|
|
100 |
private String customerGstNumber;
|
| 27579 |
tejbeer |
101 |
|
| 21596 |
ashik.ali |
102 |
@Column(name = "total_amount")
|
|
|
103 |
private float totalAmount;
|
| 27579 |
tejbeer |
104 |
|
| 21609 |
ashik.ali |
105 |
@Column(name = "invoice_number", length = 50)
|
| 21596 |
ashik.ali |
106 |
private String invoiceNumber;
|
| 27579 |
tejbeer |
107 |
|
| 22859 |
ashik.ali |
108 |
@Column(name = "cashback")
|
|
|
109 |
private float cashback;
|
| 27579 |
tejbeer |
110 |
|
| 22009 |
ashik.ali |
111 |
@Convert(converter = LocalDateTimeAttributeConverter.class)
|
| 21596 |
ashik.ali |
112 |
@Column(name = "create_timestamp")
|
| 27579 |
tejbeer |
113 |
private LocalDateTime createTimestamp = LocalDateTime.now();
|
|
|
114 |
|
| 24264 |
amit.gupta |
115 |
@Convert(converter = LocalDateTimeAttributeConverter.class)
|
|
|
116 |
@Column(name = "cancelled_timestamp")
|
| 27579 |
tejbeer |
117 |
private LocalDateTime cancelledTimestamp;
|
|
|
118 |
|
|
|
119 |
// @Convert(converter = LocalDateTimeAttributeConverter.class)
|
|
|
120 |
// @Column(name = "billing_timestamp")
|
| 25083 |
amit.gupta |
121 |
@Transient
|
| 27579 |
tejbeer |
122 |
private LocalDateTime billingTimestamp;
|
|
|
123 |
|
| 26817 |
amit.gupta |
124 |
@Transient
|
| 25083 |
amit.gupta |
125 |
private FofoOrderItem orderItem;
|
| 27579 |
tejbeer |
126 |
|
| 25726 |
amit.gupta |
127 |
@Transient
|
|
|
128 |
private LocalDate dateOfBirth;
|
| 27579 |
tejbeer |
129 |
|
| 25726 |
amit.gupta |
130 |
public LocalDate getDateOfBirth() {
|
|
|
131 |
return dateOfBirth;
|
|
|
132 |
}
|
| 27579 |
tejbeer |
133 |
|
| 25726 |
amit.gupta |
134 |
public void setDateOfBirth(LocalDate dateOfBirth) {
|
|
|
135 |
this.dateOfBirth = dateOfBirth;
|
|
|
136 |
}
|
| 27579 |
tejbeer |
137 |
|
| 25083 |
amit.gupta |
138 |
public FofoOrderItem getOrderItem() {
|
|
|
139 |
return orderItem;
|
|
|
140 |
}
|
| 27579 |
tejbeer |
141 |
|
| 25083 |
amit.gupta |
142 |
public void setOrderItem(FofoOrderItem orderItem) {
|
|
|
143 |
this.orderItem = orderItem;
|
|
|
144 |
}
|
| 27579 |
tejbeer |
145 |
|
| 24264 |
amit.gupta |
146 |
public LocalDateTime getCancelledTimestamp() {
|
|
|
147 |
return cancelledTimestamp;
|
|
|
148 |
}
|
| 27579 |
tejbeer |
149 |
|
| 24264 |
amit.gupta |
150 |
public void setCancelledTimestamp(LocalDateTime cancelledTimestamp) {
|
|
|
151 |
this.cancelledTimestamp = cancelledTimestamp;
|
|
|
152 |
}
|
| 27579 |
tejbeer |
153 |
|
| 21984 |
kshitij.so |
154 |
public int getId() {
|
|
|
155 |
return id;
|
|
|
156 |
}
|
| 27579 |
tejbeer |
157 |
|
| 21984 |
kshitij.so |
158 |
public void setId(int id) {
|
|
|
159 |
this.id = id;
|
|
|
160 |
}
|
| 27579 |
tejbeer |
161 |
|
| 21984 |
kshitij.so |
162 |
public int getFofoId() {
|
|
|
163 |
return fofoId;
|
|
|
164 |
}
|
| 27579 |
tejbeer |
165 |
|
| 21984 |
kshitij.so |
166 |
public void setFofoId(int fofoId) {
|
|
|
167 |
this.fofoId = fofoId;
|
|
|
168 |
}
|
| 27579 |
tejbeer |
169 |
|
| 21984 |
kshitij.so |
170 |
public int getCustomerId() {
|
|
|
171 |
return customerId;
|
|
|
172 |
}
|
| 27579 |
tejbeer |
173 |
|
| 21984 |
kshitij.so |
174 |
public void setCustomerId(int customerId) {
|
|
|
175 |
this.customerId = customerId;
|
|
|
176 |
}
|
| 27579 |
tejbeer |
177 |
|
| 21984 |
kshitij.so |
178 |
public int getCustomerAddressId() {
|
|
|
179 |
return customerAddressId;
|
|
|
180 |
}
|
| 27579 |
tejbeer |
181 |
|
| 21984 |
kshitij.so |
182 |
public void setCustomerAddressId(int customerAddressId) {
|
|
|
183 |
this.customerAddressId = customerAddressId;
|
|
|
184 |
}
|
| 27579 |
tejbeer |
185 |
|
| 23369 |
ashik.ali |
186 |
public String getCustomerGstNumber() {
|
|
|
187 |
return customerGstNumber;
|
|
|
188 |
}
|
| 27579 |
tejbeer |
189 |
|
| 23369 |
ashik.ali |
190 |
public void setCustomerGstNumber(String customerGstNumber) {
|
|
|
191 |
this.customerGstNumber = customerGstNumber;
|
|
|
192 |
}
|
| 27579 |
tejbeer |
193 |
|
| 21984 |
kshitij.so |
194 |
public float getTotalAmount() {
|
|
|
195 |
return totalAmount;
|
|
|
196 |
}
|
| 27579 |
tejbeer |
197 |
|
| 21984 |
kshitij.so |
198 |
public void setTotalAmount(float totalAmount) {
|
|
|
199 |
this.totalAmount = totalAmount;
|
|
|
200 |
}
|
| 27579 |
tejbeer |
201 |
|
| 21984 |
kshitij.so |
202 |
public String getInvoiceNumber() {
|
|
|
203 |
return invoiceNumber;
|
|
|
204 |
}
|
| 27579 |
tejbeer |
205 |
|
| 21984 |
kshitij.so |
206 |
public void setInvoiceNumber(String invoiceNumber) {
|
|
|
207 |
this.invoiceNumber = invoiceNumber;
|
|
|
208 |
}
|
| 27579 |
tejbeer |
209 |
|
| 22859 |
ashik.ali |
210 |
public float getCashback() {
|
|
|
211 |
return cashback;
|
|
|
212 |
}
|
| 27579 |
tejbeer |
213 |
|
| 22859 |
ashik.ali |
214 |
public void setCashback(float cashback) {
|
|
|
215 |
this.cashback = cashback;
|
|
|
216 |
}
|
| 27579 |
tejbeer |
217 |
|
| 21984 |
kshitij.so |
218 |
public LocalDateTime getCreateTimestamp() {
|
|
|
219 |
return createTimestamp;
|
|
|
220 |
}
|
| 27579 |
tejbeer |
221 |
|
| 21984 |
kshitij.so |
222 |
public void setCreateTimestamp(LocalDateTime createTimestamp) {
|
|
|
223 |
this.createTimestamp = createTimestamp;
|
|
|
224 |
}
|
| 27579 |
tejbeer |
225 |
|
|
|
226 |
public String getFormattedDate() {
|
|
|
227 |
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
|
| 22243 |
ashik.ali |
228 |
return this.createTimestamp.format(formatter);
|
| 27579 |
tejbeer |
229 |
}
|
|
|
230 |
|
| 21924 |
ashik.ali |
231 |
@Override
|
| 22009 |
ashik.ali |
232 |
public int hashCode() {
|
|
|
233 |
final int prime = 31;
|
|
|
234 |
int result = 1;
|
| 26817 |
amit.gupta |
235 |
result = prime * result + ((billingTimestamp == null) ? 0 : billingTimestamp.hashCode());
|
|
|
236 |
result = prime * result + ((cancelledTimestamp == null) ? 0 : cancelledTimestamp.hashCode());
|
|
|
237 |
result = prime * result + Float.floatToIntBits(cashback);
|
|
|
238 |
result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
|
|
|
239 |
result = prime * result + customerAddressId;
|
|
|
240 |
result = prime * result + ((customerGstNumber == null) ? 0 : customerGstNumber.hashCode());
|
|
|
241 |
result = prime * result + customerId;
|
|
|
242 |
result = prime * result + ((dateOfBirth == null) ? 0 : dateOfBirth.hashCode());
|
|
|
243 |
result = prime * result + fofoId;
|
| 22009 |
ashik.ali |
244 |
result = prime * result + id;
|
| 26817 |
amit.gupta |
245 |
result = prime * result + ((invoiceNumber == null) ? 0 : invoiceNumber.hashCode());
|
|
|
246 |
result = prime * result + ((orderItem == null) ? 0 : orderItem.hashCode());
|
|
|
247 |
result = prime * result + Float.floatToIntBits(totalAmount);
|
| 22009 |
ashik.ali |
248 |
return result;
|
|
|
249 |
}
|
| 27579 |
tejbeer |
250 |
|
| 22009 |
ashik.ali |
251 |
@Override
|
|
|
252 |
public boolean equals(Object obj) {
|
|
|
253 |
if (this == obj)
|
|
|
254 |
return true;
|
|
|
255 |
if (obj == null)
|
|
|
256 |
return false;
|
|
|
257 |
if (getClass() != obj.getClass())
|
|
|
258 |
return false;
|
|
|
259 |
FofoOrder other = (FofoOrder) obj;
|
| 26817 |
amit.gupta |
260 |
if (billingTimestamp == null) {
|
|
|
261 |
if (other.billingTimestamp != null)
|
|
|
262 |
return false;
|
|
|
263 |
} else if (!billingTimestamp.equals(other.billingTimestamp))
|
|
|
264 |
return false;
|
|
|
265 |
if (cancelledTimestamp == null) {
|
|
|
266 |
if (other.cancelledTimestamp != null)
|
|
|
267 |
return false;
|
|
|
268 |
} else if (!cancelledTimestamp.equals(other.cancelledTimestamp))
|
|
|
269 |
return false;
|
|
|
270 |
if (Float.floatToIntBits(cashback) != Float.floatToIntBits(other.cashback))
|
|
|
271 |
return false;
|
|
|
272 |
if (createTimestamp == null) {
|
|
|
273 |
if (other.createTimestamp != null)
|
|
|
274 |
return false;
|
|
|
275 |
} else if (!createTimestamp.equals(other.createTimestamp))
|
|
|
276 |
return false;
|
|
|
277 |
if (customerAddressId != other.customerAddressId)
|
|
|
278 |
return false;
|
|
|
279 |
if (customerGstNumber == null) {
|
|
|
280 |
if (other.customerGstNumber != null)
|
|
|
281 |
return false;
|
|
|
282 |
} else if (!customerGstNumber.equals(other.customerGstNumber))
|
|
|
283 |
return false;
|
|
|
284 |
if (customerId != other.customerId)
|
|
|
285 |
return false;
|
|
|
286 |
if (dateOfBirth == null) {
|
|
|
287 |
if (other.dateOfBirth != null)
|
|
|
288 |
return false;
|
|
|
289 |
} else if (!dateOfBirth.equals(other.dateOfBirth))
|
|
|
290 |
return false;
|
|
|
291 |
if (fofoId != other.fofoId)
|
|
|
292 |
return false;
|
| 22009 |
ashik.ali |
293 |
if (id != other.id)
|
|
|
294 |
return false;
|
| 26817 |
amit.gupta |
295 |
if (invoiceNumber == null) {
|
|
|
296 |
if (other.invoiceNumber != null)
|
|
|
297 |
return false;
|
|
|
298 |
} else if (!invoiceNumber.equals(other.invoiceNumber))
|
|
|
299 |
return false;
|
|
|
300 |
if (orderItem == null) {
|
|
|
301 |
if (other.orderItem != null)
|
|
|
302 |
return false;
|
|
|
303 |
} else if (!orderItem.equals(other.orderItem))
|
|
|
304 |
return false;
|
|
|
305 |
if (Float.floatToIntBits(totalAmount) != Float.floatToIntBits(other.totalAmount))
|
|
|
306 |
return false;
|
| 22009 |
ashik.ali |
307 |
return true;
|
|
|
308 |
}
|
| 27586 |
tejbeer |
309 |
|
| 22009 |
ashik.ali |
310 |
@Override
|
| 21602 |
ashik.ali |
311 |
public String toString() {
|
| 21710 |
ashik.ali |
312 |
return "FofoOrder [id=" + id + ", fofoId=" + fofoId + ", customerId=" + customerId + ", customerAddressId="
|
| 23369 |
ashik.ali |
313 |
+ customerAddressId + ", customerGstNumber=" + customerGstNumber + ", totalAmount=" + totalAmount
|
|
|
314 |
+ ", invoiceNumber=" + invoiceNumber + ", cashback=" + cashback + ", createTimestamp=" + createTimestamp
|
| 26817 |
amit.gupta |
315 |
+ ", cancelledTimestamp=" + cancelledTimestamp + ", billingTimestamp=" + billingTimestamp
|
|
|
316 |
+ ", orderItem=" + orderItem + ", dateOfBirth=" + dateOfBirth + "]";
|
| 21602 |
ashik.ali |
317 |
}
|
| 27586 |
tejbeer |
318 |
|
| 21596 |
ashik.ali |
319 |
}
|