| 30652 |
amit.gupta |
1 |
package com.spice.profitmandi.dao.entity.fofo;
|
|
|
2 |
|
|
|
3 |
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
|
|
|
4 |
|
|
|
5 |
import javax.persistence.*;
|
|
|
6 |
import java.time.LocalDateTime;
|
|
|
7 |
import java.util.Objects;
|
|
|
8 |
|
| 31008 |
amit.gupta |
9 |
@Entity
|
| 31860 |
tejbeer |
10 |
@Table(name = "fofo.offer_payout")
|
| 31008 |
amit.gupta |
11 |
@NamedQueries({
|
| 31380 |
amit.gupta |
12 |
@NamedQuery(name = "OfferPayout.selectPaidOffers", query = "select new com.spice.profitmandi.service.transaction.InventoryMarginModel("
|
|
|
13 |
+ " o.retailerId, li.sgstRate, li.cgstRate, li.igstRate," +
|
|
|
14 |
" cast(case when op.createTimestamp between :startDate and :endDate and op.rejectTimestamp is null then op.amount " +
|
|
|
15 |
" when op.createTimestamp between :startDate and :endDate and op.rejectTimestamp between :startDate and :endDate then 0" +
|
|
|
16 |
" when op.rejectTimestamp between :startDate and :endDate then -op.amount" +
|
|
|
17 |
" else 0 end as float), lii.serialNumber, op.description, o.invoiceNumber, " +
|
|
|
18 |
" case when op.rejectTimestamp between :startDate and :endDate then op.rejectTimestamp else op.createTimestamp end) from "
|
|
|
19 |
+ " OfferPayout op join LineItemImei lii on (op.serialNumber=lii.serialNumber) join LineItem li on li.id=lii.lineItemId "
|
|
|
20 |
+ " join Order o on (o.retailerId=op.fofoId and o.billingTimestamp is not null and o.id=li.orderId) "
|
|
|
21 |
+ " where op.createTimestamp >= :cnDate and ((op.createTimestamp between :startDate and :endDate) or (op.rejectTimestamp between :startDate and :endDate))"
|
|
|
22 |
+ " and lii.id=(select max(lii2.id) from LineItemImei lii2 join LineItem li2 on li2.id=lii2.lineItemId join Order o2 on o2.id=li2.orderId where lii2.serialNumber=lii.serialNumber and o2.retailerId=op.fofoId)"),
|
| 31352 |
amit.gupta |
23 |
|
| 31380 |
amit.gupta |
24 |
@NamedQuery(name = "OfferPayout.getTotalPayoutsByPartnerPeriod", query = "select new com.spice.profitmandi.common.model.OfferPayoutImeiIncomeModel(" +
|
|
|
25 |
" ii.id, ii.serialNumber, " +
|
|
|
26 |
" case when (sr.type='PURCHASE' and o.schemeType='SELLIN') then max(sr.createTimestamp) end," +
|
|
|
27 |
" case when (sr.type='SALE' and o.schemeType != 'SELLIN') then max(sr.createTimestamp) end, " +
|
|
|
28 |
" case when (sr.type='PURCHASE' and o.schemeType='SELLIN') then sum(op.amount) else 0 end, " +
|
|
|
29 |
" case when (sr.type='SALE' and o.schemeType!='SELLIN') then sum(op.amount) else 0 end, " +
|
|
|
30 |
" i.catalogItemId, i.brand, i.modelName, i.modelNumber" +
|
|
|
31 |
") from OfferPayout op join Offer o on o.id=op.offerId join InventoryItem ii on ii.serialNumber=op.serialNumber and op.fofoId=ii.fofoId" +
|
|
|
32 |
" join Item i on i.id=ii.itemId join ScanRecord sr on sr.inventoryItemId=ii.id " +
|
|
|
33 |
" and ((sr.type='PURCHASE' and o.schemeType='SELLIN') or (sr.type='SALE' and o.schemeType!='SELLIN'))" +
|
|
|
34 |
" where op.rejectTimestamp is null and sr.createTimestamp between :startDate and :endDate" +
|
|
|
35 |
" and (:brand is null or i.brand=:brand)" +
|
|
|
36 |
" and (:catalogId is null or i.catalogItemId=:catalogId)" +
|
|
|
37 |
" and op.fofoId=:fofoId" +
|
| 32234 |
amit.gupta |
38 |
" group by ii.id, sr.type "),
|
| 31352 |
amit.gupta |
39 |
|
| 31380 |
amit.gupta |
40 |
@NamedQuery(name = "OfferPayout.getTotalPayoutsByImei", query = "select new com.spice.profitmandi.common.model.OfferPayoutImeiIncomeModel(" +
|
|
|
41 |
" ii.id, ii.serialNumber, " +
|
|
|
42 |
" max(case when (sr.type='PURCHASE' and o.schemeType='SELLIN') then sr.createTimestamp end)," +
|
|
|
43 |
" max(case when (sr.type='SALE' and o.schemeType != 'SELLIN') then sr.createTimestamp end), " +
|
|
|
44 |
" sum(case when (sr.type='PURCHASE' and o.schemeType='SELLIN') then op.amount else 0 end), " +
|
|
|
45 |
" sum(case when (sr.type='SALE' and o.schemeType!='SELLIN') then op.amount else 0 end), " +
|
|
|
46 |
" i.catalogItemId, i.brand, i.modelName, i.modelNumber" +
|
|
|
47 |
") from OfferPayout op join Offer o on o.id=op.offerId join InventoryItem ii on ii.serialNumber=op.serialNumber and op.fofoId=ii.fofoId" +
|
|
|
48 |
" join Item i on i.id=ii.itemId join ScanRecord sr on sr.inventoryItemId=ii.id " +
|
|
|
49 |
" and ((sr.type='PURCHASE' and o.schemeType='SELLIN') or (sr.type='SALE' and o.schemeType!='SELLIN'))" +
|
|
|
50 |
" where op.rejectTimestamp is null and ii.serialNumber in :serialNumbers" +
|
| 31382 |
amit.gupta |
51 |
" group by ii.id ")/*,
|
| 31380 |
amit.gupta |
52 |
@NamedQuery(name = "OfferPayout.selectMarginsByYearMonth", query = "select com.spice.profitmandi.common.model.MarginModel(" +
|
|
|
53 |
" " +
|
|
|
54 |
") from Order ord join OfferPayout op join Offer on o.id=op.offerId join InventoryItem ii on ii.serialNumber=op.serialNumber and op.fofoId=ii.fofoId" +
|
|
|
55 |
" join Item i on i.id=ii.itemId join ScanRecord sr on sr.inventoryItemId=ii.id " +
|
|
|
56 |
" and ((sr.type='PURCHASE' and o.schemeType='SELLIN') or (sr.type='SALE' and o.schemeType!='SELLIN'))" +
|
|
|
57 |
" join " +
|
|
|
58 |
" where op.rejectTimestamp is null and ii.serialNumber in :serialNumbers" +
|
| 31382 |
amit.gupta |
59 |
" group by ii.id ")*/
|
| 31008 |
amit.gupta |
60 |
})
|
| 30652 |
amit.gupta |
61 |
public class OfferPayout {
|
| 31380 |
amit.gupta |
62 |
@Id
|
|
|
63 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
|
64 |
private long id;
|
|
|
65 |
@Column(name = "fofo_id", nullable = false)
|
|
|
66 |
private long fofoId;
|
|
|
67 |
@Column(name = "offer_id", nullable = false)
|
|
|
68 |
private long offerId;
|
|
|
69 |
@Column(name = "criteria_id", nullable = false)
|
|
|
70 |
private long criteriaId;
|
|
|
71 |
@Column(name = "slab_amount", nullable = false)
|
|
|
72 |
private double slabAmount;
|
|
|
73 |
@Column(name = "serial_number", nullable = false)
|
|
|
74 |
private String serialNumber;
|
|
|
75 |
@Column(name = "amount", nullable = false)
|
|
|
76 |
private double amount;
|
|
|
77 |
@Column(name = "status", nullable = false)
|
|
|
78 |
@Enumerated(EnumType.STRING)
|
|
|
79 |
private SchemePayoutStatus status;
|
|
|
80 |
@Column(name = "description", nullable = false)
|
|
|
81 |
private String description;
|
|
|
82 |
@Column(name = "inventory_item_id", nullable = false)
|
|
|
83 |
private int inventoryItemId;
|
|
|
84 |
@Column(name = "create_timestamp", nullable = false)
|
|
|
85 |
private LocalDateTime createTimestamp;
|
|
|
86 |
@Column(name = "reject_timestamp")
|
|
|
87 |
private LocalDateTime rejectTimestamp;
|
| 30652 |
amit.gupta |
88 |
|
| 31380 |
amit.gupta |
89 |
public OfferPayout() {
|
| 30996 |
amit.gupta |
90 |
|
| 31380 |
amit.gupta |
91 |
}
|
| 30996 |
amit.gupta |
92 |
|
| 31380 |
amit.gupta |
93 |
public OfferPayout(long fofoId, long offerId, long criteriaId, double slabAmount, String serialNumber, double amount, SchemePayoutStatus status, String description, LocalDateTime createTimestamp) {
|
|
|
94 |
this.fofoId = fofoId;
|
|
|
95 |
this.offerId = offerId;
|
|
|
96 |
this.criteriaId = criteriaId;
|
|
|
97 |
this.slabAmount = slabAmount;
|
|
|
98 |
this.serialNumber = serialNumber;
|
|
|
99 |
this.amount = amount;
|
|
|
100 |
this.status = status;
|
|
|
101 |
this.description = description;
|
|
|
102 |
this.createTimestamp = createTimestamp;
|
|
|
103 |
}
|
| 31008 |
amit.gupta |
104 |
|
| 31380 |
amit.gupta |
105 |
@Override
|
|
|
106 |
public String toString() {
|
|
|
107 |
return "OfferPayout{" +
|
|
|
108 |
"id=" + id +
|
|
|
109 |
", fofoId=" + fofoId +
|
|
|
110 |
", offerId=" + offerId +
|
|
|
111 |
", criteriaId=" + criteriaId +
|
|
|
112 |
", slabAmount=" + slabAmount +
|
|
|
113 |
", serialNumber='" + serialNumber + '\'' +
|
|
|
114 |
", amount=" + amount +
|
|
|
115 |
", status=" + status +
|
|
|
116 |
", description='" + description + '\'' +
|
|
|
117 |
", inventoryItemId=" + inventoryItemId +
|
|
|
118 |
", createTimestamp=" + createTimestamp +
|
|
|
119 |
", rejectTimestamp=" + rejectTimestamp +
|
|
|
120 |
'}';
|
|
|
121 |
}
|
| 30996 |
amit.gupta |
122 |
|
| 31380 |
amit.gupta |
123 |
public int getInventoryItemId() {
|
|
|
124 |
return inventoryItemId;
|
|
|
125 |
}
|
| 31008 |
amit.gupta |
126 |
|
| 31380 |
amit.gupta |
127 |
public void setInventoryItemId(int inventoryItemId) {
|
|
|
128 |
this.inventoryItemId = inventoryItemId;
|
|
|
129 |
}
|
| 31008 |
amit.gupta |
130 |
|
| 31380 |
amit.gupta |
131 |
@Override
|
|
|
132 |
public boolean equals(Object o) {
|
|
|
133 |
if (this == o) return true;
|
|
|
134 |
if (o == null || getClass() != o.getClass()) return false;
|
|
|
135 |
OfferPayout that = (OfferPayout) o;
|
|
|
136 |
return id == that.id && fofoId == that.fofoId && offerId == that.offerId && criteriaId == that.criteriaId && Double.compare(that.slabAmount, slabAmount) == 0 && Double.compare(that.amount, amount) == 0 && inventoryItemId == that.inventoryItemId && Objects.equals(serialNumber, that.serialNumber) && status == that.status && Objects.equals(description, that.description) && Objects.equals(createTimestamp, that.createTimestamp) && Objects.equals(rejectTimestamp, that.rejectTimestamp);
|
|
|
137 |
}
|
| 31008 |
amit.gupta |
138 |
|
| 31380 |
amit.gupta |
139 |
@Override
|
|
|
140 |
public int hashCode() {
|
|
|
141 |
return Objects.hash(id, fofoId, offerId, criteriaId, slabAmount, serialNumber, amount, status, description, inventoryItemId, createTimestamp, rejectTimestamp);
|
|
|
142 |
}
|
| 31008 |
amit.gupta |
143 |
|
| 31380 |
amit.gupta |
144 |
public LocalDateTime getCreateTimestamp() {
|
|
|
145 |
return createTimestamp;
|
|
|
146 |
}
|
| 30652 |
amit.gupta |
147 |
|
| 31380 |
amit.gupta |
148 |
public void setCreateTimestamp(LocalDateTime createTimestamp) {
|
|
|
149 |
this.createTimestamp = createTimestamp;
|
|
|
150 |
}
|
| 30652 |
amit.gupta |
151 |
|
| 31380 |
amit.gupta |
152 |
public LocalDateTime getRejectTimestamp() {
|
|
|
153 |
return rejectTimestamp;
|
|
|
154 |
}
|
| 30996 |
amit.gupta |
155 |
|
| 31380 |
amit.gupta |
156 |
public void setRejectTimestamp(LocalDateTime rejectTimestamp) {
|
|
|
157 |
this.rejectTimestamp = rejectTimestamp;
|
|
|
158 |
}
|
| 30996 |
amit.gupta |
159 |
|
| 31380 |
amit.gupta |
160 |
public long getId() {
|
|
|
161 |
return id;
|
|
|
162 |
}
|
| 30996 |
amit.gupta |
163 |
|
| 31380 |
amit.gupta |
164 |
public void setId(long id) {
|
|
|
165 |
this.id = id;
|
|
|
166 |
}
|
| 30652 |
amit.gupta |
167 |
|
| 31380 |
amit.gupta |
168 |
public long getFofoId() {
|
|
|
169 |
return fofoId;
|
|
|
170 |
}
|
| 30652 |
amit.gupta |
171 |
|
| 31380 |
amit.gupta |
172 |
public void setFofoId(long fofoId) {
|
|
|
173 |
this.fofoId = fofoId;
|
|
|
174 |
}
|
| 30652 |
amit.gupta |
175 |
|
| 31380 |
amit.gupta |
176 |
public long getOfferId() {
|
|
|
177 |
return offerId;
|
|
|
178 |
}
|
| 30652 |
amit.gupta |
179 |
|
| 31380 |
amit.gupta |
180 |
public void setOfferId(long offerId) {
|
|
|
181 |
this.offerId = offerId;
|
|
|
182 |
}
|
| 30652 |
amit.gupta |
183 |
|
| 31380 |
amit.gupta |
184 |
public long getCriteriaId() {
|
|
|
185 |
return criteriaId;
|
|
|
186 |
}
|
| 30652 |
amit.gupta |
187 |
|
| 31380 |
amit.gupta |
188 |
public void setCriteriaId(long criteriaId) {
|
|
|
189 |
this.criteriaId = criteriaId;
|
|
|
190 |
}
|
| 30652 |
amit.gupta |
191 |
|
| 31380 |
amit.gupta |
192 |
public double getSlabAmount() {
|
|
|
193 |
return slabAmount;
|
|
|
194 |
}
|
| 30652 |
amit.gupta |
195 |
|
| 31380 |
amit.gupta |
196 |
public void setSlabAmount(double slabAmount) {
|
|
|
197 |
this.slabAmount = slabAmount;
|
|
|
198 |
}
|
| 30652 |
amit.gupta |
199 |
|
| 31380 |
amit.gupta |
200 |
public String getSerialNumber() {
|
|
|
201 |
return serialNumber;
|
|
|
202 |
}
|
| 30652 |
amit.gupta |
203 |
|
| 31380 |
amit.gupta |
204 |
public void setSerialNumber(String serialNumber) {
|
|
|
205 |
this.serialNumber = serialNumber;
|
|
|
206 |
}
|
| 30652 |
amit.gupta |
207 |
|
| 31380 |
amit.gupta |
208 |
public double getAmount() {
|
|
|
209 |
return amount;
|
|
|
210 |
}
|
| 30652 |
amit.gupta |
211 |
|
| 31380 |
amit.gupta |
212 |
public void setAmount(double amount) {
|
|
|
213 |
this.amount = amount;
|
|
|
214 |
}
|
| 30652 |
amit.gupta |
215 |
|
| 31380 |
amit.gupta |
216 |
public SchemePayoutStatus getStatus() {
|
|
|
217 |
return status;
|
|
|
218 |
}
|
| 30652 |
amit.gupta |
219 |
|
| 31380 |
amit.gupta |
220 |
public void setStatus(SchemePayoutStatus status) {
|
|
|
221 |
this.status = status;
|
|
|
222 |
}
|
| 30652 |
amit.gupta |
223 |
|
| 31380 |
amit.gupta |
224 |
public String getDescription() {
|
|
|
225 |
return description;
|
|
|
226 |
}
|
| 30652 |
amit.gupta |
227 |
|
| 31380 |
amit.gupta |
228 |
public void setDescription(String description) {
|
|
|
229 |
this.description = description;
|
|
|
230 |
}
|
| 30652 |
amit.gupta |
231 |
}
|