| Line 14... |
Line 14... |
| 14 |
/**
|
14 |
/**
|
| 15 |
* This class basically contains scheme details
|
15 |
* This class basically contains scheme details
|
| 16 |
*
|
16 |
*
|
| 17 |
* @author ashikali
|
17 |
* @author ashikali
|
| 18 |
*/
|
18 |
*/
|
| 19 |
@NamedQueries({
|
- |
|
| 20 |
@NamedQuery(name = "scheme.selectSchemesByRetailerIdsSchemeIds", query = "select sr.schemeId from" +
|
19 |
@NamedQueries({ @NamedQuery(name = "scheme.selectSchemesByRetailerIdsSchemeIds", query = "select sr.schemeId from"
|
| 21 |
" SchemeRegion sr join PartnerRegion pr on pr.regionId=sr.regionId where pr.fofoId in :fofoIds and sr.schemeId in :schemeIds"),
|
20 |
+ " SchemeRegion sr join PartnerRegion pr on pr.regionId=sr.regionId where pr.fofoId in :fofoIds and sr.schemeId in :schemeIds"),
|
| 22 |
|
- |
|
| 23 |
@NamedQuery(name = "Scheme.selectSchemeByModelsPartnerTypeFofoId", query = "select s from Scheme s" +
|
- |
|
| 24 |
" join SchemeItem si on si.schemeId = s.id" +
|
- |
|
| 25 |
" join SchemeRegion sr on sr.schemeId = s.id" +
|
- |
|
| 26 |
" join PartnerRegion pr on pr.regionId=sr.regionId" +
|
- |
|
| 27 |
" where pr.fofoId in :fofoIds and s.partnerType in :partnerTypes" +
|
- |
|
| 28 |
" and si.catalogId in :catalogIds" +
|
- |
|
| 29 |
" and :onDate between s.startDateTime and s.endDateTime" +
|
- |
|
| 30 |
//" and s.endDateTime >= :onDate" +
|
- |
|
| 31 |
" and s.activeTimestamp is not null")
|
- |
|
| 32 |
|
21 |
|
| 33 |
/*,
|
- |
|
| 34 |
@NamedQuery(name="scheme.getImeiMarginsPaidOnBillingMonth", query= "select new com.spice.profitmandi.dao.repository.catalog.ImeiMarginModel(" +
|
22 |
@NamedQuery(name = "Scheme.selectSchemeByModelsPartnerTypeFofoId", query = "select s from Scheme s"
|
| 35 |
") from LineItemImei li1" +
|
- |
|
| 36 |
" left join LineItemImei li2 on (li1.serialNumber = li2.serialNumber and li1.id < li2.id)" +
|
- |
|
| 37 |
" join LineItem li on li.id = li1.lineItemId" +
|
- |
|
| 38 |
" join Order o on o.id = li.orderId" +
|
- |
|
| 39 |
" join Item ci on li.itemId = ci.id" +
|
- |
|
| 40 |
" join SchemeItem si on si.catalogId = ci.catalogItemId" +
|
- |
|
| 41 |
" join Scheme s1 on s1.id = si.schemeId" +
|
- |
|
| 42 |
" join SchemeRegion sr on sr.schemeId = s1.id" +
|
23 |
+ " join SchemeItem si on si.schemeId = s.id" + " join SchemeRegion sr on sr.schemeId = s.id"
|
| 43 |
" join PartnerRegion pr on (pr.regionId = sr.regionId and pr.fofoId in (0, o.id))" +
|
24 |
+ " join PartnerRegion pr on pr.regionId=sr.regionId"
|
| 44 |
" left join PartnerTypeChange ptc on ptc.fofoId = o.retailerId" +
|
25 |
+ " where pr.fofoId in :fofoIds and s.partnerType in :partnerTypes" + " and si.catalogId in :catalogIds"
|
| 45 |
" left join PartnerTypeChange ptc2 on (ptc2.fofoId = ptc.fofoId and ptc.createTimestamp < ptc2.createTimestamp)" +
|
- |
|
| 46 |
"where li2.id is null" +
|
- |
|
| 47 |
" and ptc2.createTimestamp is null" +
|
- |
|
| 48 |
" and o.billing_timestamp between :startDate and :endDate" +
|
- |
|
| 49 |
" and '2022-12-01' between s1.start_date_time and s1.end_date_time" +
|
26 |
+ " and :onDate between s.startDateTime and s.endDateTime" +
|
| 50 |
" and ((ptc.partnerType is null and s1.partner_type in ('ALL', 'NEW'))" +
|
- |
|
| 51 |
" or s1.partnerType in (ptc.partnerType, 'ALL'))" +
|
27 |
// " and s.endDateTime >= :onDate" +
|
| 52 |
" and s1.activeTimestamp is not null" +
|
28 |
" and s.activeTimestamp is not null")
|
| 53 |
" and s1.amountType = 'PERCENTAGE'" +
|
- |
|
| 54 |
"group by li.serial_number) as set1\n" +
|
- |
|
| 55 |
"")*/
|
- |
|
| 56 |
|
29 |
|
| - |
|
30 |
/*
|
| - |
|
31 |
* ,
|
| - |
|
32 |
*
|
| - |
|
33 |
* @NamedQuery(name="scheme.getImeiMarginsPaidOnBillingMonth", query=
|
| - |
|
34 |
* "select new com.spice.profitmandi.dao.repository.catalog.ImeiMarginModel(" +
|
| - |
|
35 |
* ") from LineItemImei li1" +
|
| - |
|
36 |
* " left join LineItemImei li2 on (li1.serialNumber = li2.serialNumber and li1.id < li2.id)"
|
| - |
|
37 |
* + " join LineItem li on li.id = li1.lineItemId" +
|
| - |
|
38 |
* " join Order o on o.id = li.orderId" +
|
| - |
|
39 |
* " join Item ci on li.itemId = ci.id" +
|
| - |
|
40 |
* " join SchemeItem si on si.catalogId = ci.catalogItemId" +
|
| - |
|
41 |
* " join Scheme s1 on s1.id = si.schemeId" +
|
| - |
|
42 |
* " join SchemeRegion sr on sr.schemeId = s1.id" +
|
| - |
|
43 |
* " join PartnerRegion pr on (pr.regionId = sr.regionId and pr.fofoId in (0, o.id))"
|
| - |
|
44 |
* + " left join PartnerTypeChange ptc on ptc.fofoId = o.retailerId" +
|
| - |
|
45 |
* " left join PartnerTypeChange ptc2 on (ptc2.fofoId = ptc.fofoId and ptc.createTimestamp < ptc2.createTimestamp)"
|
| - |
|
46 |
* + "where li2.id is null" + " and ptc2.createTimestamp is null" +
|
| - |
|
47 |
* " and o.billing_timestamp between :startDate and :endDate" +
|
| - |
|
48 |
* " and '2022-12-01' between s1.start_date_time and s1.end_date_time" +
|
| - |
|
49 |
* " and ((ptc.partnerType is null and s1.partner_type in ('ALL', 'NEW'))" +
|
| - |
|
50 |
* " or s1.partnerType in (ptc.partnerType, 'ALL'))" +
|
| - |
|
51 |
* " and s1.activeTimestamp is not null" + " and s1.amountType = 'PERCENTAGE'"
|
| - |
|
52 |
* + "group by li.serial_number) as set1\n" + "")
|
| - |
|
53 |
*/
|
| 57 |
|
54 |
|
| 58 |
})
|
55 |
})
|
| 59 |
|
56 |
|
| 60 |
@NamedNativeQueries({
|
57 |
@NamedNativeQueries({
|
| 61 |
@NamedNativeQuery(name = "scheme.selectMissedActivationSale",
|
- |
|
| 62 |
query = "select cs.id as scheme_id, ai.serial_number, sr.order_id, ii.id as inventory_item_id, ai.activation_timestamp" +
|
- |
|
| 63 |
" from fofo.activated_imei ai " +
|
- |
|
| 64 |
" join fofo.inventory_item ii on ai.serial_number = ii.serial_number " +
|
- |
|
| 65 |
" join catalog.item i on i.id = ii.item_id " +
|
- |
|
| 66 |
" join catalog.scheme cs on (date(ai.activation_timestamp) between cs.start_date_time and cs.end_date_time) " +
|
- |
|
| 67 |
" join fofo.scheme_item si on (si.scheme_id = cs.id and i.catalog_item_id = si.catalog_id) " +
|
- |
|
| 68 |
" join fofo.scan_record sr on (sr.inventory_item_id = ii.id)" +
|
- |
|
| 69 |
" left join fofo.scheme_in_out sio on (sio.scheme_id = cs.id and sio.inventory_item_id = ii.id) " +
|
- |
|
| 70 |
" where cs.active_timestamp is not null " +
|
- |
|
| 71 |
" and cs.type in ('SPECIAL_SUPPORT', 'ACTIVATION')" +
|
- |
|
| 72 |
" and sr.type = 'SALE'" +
|
- |
|
| 73 |
" and (sio.id is null or sio.status='REJECTED') " +
|
- |
|
| 74 |
" and ai.checked = false", resultSetMapping = "missedActivationSaleMapping")
|
- |
|
| 75 |
})
|
- |
|
| 76 |
|
58 |
|
| - |
|
59 |
@NamedNativeQuery(name = "scheme.getActiveScheme", query = "select si.catalog_id from catalog.scheme s join fofo.scheme_item si on s.id = si.scheme_id "
|
| - |
|
60 |
+ " where s.active_timestamp is not null and date(start_date_time) <= :startDate and date(end_date_time) >= :startDate and type = :type order by active_timestamp desc "),
|
| - |
|
61 |
|
| - |
|
62 |
@NamedNativeQuery(name = "scheme.selectMissedActivationSale", query = "select cs.id as scheme_id, ai.serial_number, sr.order_id, ii.id as inventory_item_id, ai.activation_timestamp"
|
| 77 |
@SqlResultSetMappings({
|
63 |
+ " from fofo.activated_imei ai "
|
| - |
|
64 |
+ " join fofo.inventory_item ii on ai.serial_number = ii.serial_number "
|
| - |
|
65 |
+ " join catalog.item i on i.id = ii.item_id "
|
| - |
|
66 |
+ " join catalog.scheme cs on (date(ai.activation_timestamp) between cs.start_date_time and cs.end_date_time) "
|
| - |
|
67 |
+ " join fofo.scheme_item si on (si.scheme_id = cs.id and i.catalog_item_id = si.catalog_id) "
|
| - |
|
68 |
+ " join fofo.scan_record sr on (sr.inventory_item_id = ii.id)"
|
| - |
|
69 |
+ " left join fofo.scheme_in_out sio on (sio.scheme_id = cs.id and sio.inventory_item_id = ii.id) "
|
| - |
|
70 |
+ " where cs.active_timestamp is not null " + " and cs.type in ('SPECIAL_SUPPORT', 'ACTIVATION')"
|
| - |
|
71 |
+ " and sr.type = 'SALE'" + " and (sio.id is null or sio.status='REJECTED') "
|
| - |
|
72 |
+ " and ai.checked = false", resultSetMapping = "missedActivationSaleMapping") })
|
| - |
|
73 |
|
| 78 |
@SqlResultSetMapping(name = "missedActivationSaleMapping", classes = {
|
74 |
@SqlResultSetMappings({ @SqlResultSetMapping(name = "missedActivationSaleMapping", classes = {
|
| 79 |
@ConstructorResult(targetClass = SchemesImeisModel.class, columns = {
|
75 |
@ConstructorResult(targetClass = SchemesImeisModel.class, columns = {
|
| 80 |
@ColumnResult(name = "serial_number", type = String.class),
|
76 |
@ColumnResult(name = "serial_number", type = String.class),
|
| 81 |
@ColumnResult(name = "activation_timestamp", type = LocalDateTime.class),
|
77 |
@ColumnResult(name = "activation_timestamp", type = LocalDateTime.class),
|
| 82 |
@ColumnResult(name = "order_id", type = Integer.class),
|
78 |
@ColumnResult(name = "order_id", type = Integer.class),
|
| 83 |
@ColumnResult(name = "inventory_item_id", type = Integer.class),
|
79 |
@ColumnResult(name = "inventory_item_id", type = Integer.class),
|
| 84 |
@ColumnResult(name = "scheme_id", type = Integer.class),
|
80 |
@ColumnResult(name = "scheme_id", type = Integer.class), }) }) })
|
| 85 |
})
|
- |
|
| 86 |
})})
|
- |
|
| 87 |
@Entity
|
81 |
@Entity
|
| 88 |
@Table(name = "catalog.scheme", schema = "catalog")
|
82 |
@Table(name = "catalog.scheme", schema = "catalog")
|
| 89 |
public class Scheme implements Serializable {
|
83 |
public class Scheme implements Serializable {
|
| 90 |
|
84 |
|
| 91 |
public PartnerType getPartnerType() {
|
85 |
public PartnerType getPartnerType() {
|
| Line 104... |
Line 98... |
| 104 |
@Id
|
98 |
@Id
|
| 105 |
@Column(name = "id")
|
99 |
@Column(name = "id")
|
| 106 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
100 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
| 107 |
private int id;
|
101 |
private int id;
|
| 108 |
|
102 |
|
| 109 |
@Column(name = "name")
|
103 |
@Column(name = "`name`")
|
| 110 |
private String name;
|
104 |
private String name;
|
| 111 |
|
105 |
|
| 112 |
@Column(name = "description")
|
106 |
@Column(name = "description")
|
| 113 |
private String description;
|
107 |
private String description;
|
| 114 |
|
108 |
|
| 115 |
@Column(name = "type")
|
109 |
@Column(name = "`type`")
|
| 116 |
@Enumerated(EnumType.STRING)
|
110 |
@Enumerated(EnumType.STRING)
|
| 117 |
private SchemeType type;
|
111 |
private SchemeType type;
|
| 118 |
|
112 |
|
| 119 |
@Column(name = "amount_type")
|
113 |
@Column(name = "amount_type")
|
| 120 |
@Enumerated(EnumType.STRING)
|
114 |
@Enumerated(EnumType.STRING)
|
| Line 159... |
Line 153... |
| 159 |
private String amountModel;
|
153 |
private String amountModel;
|
| 160 |
|
154 |
|
| 161 |
@Transient
|
155 |
@Transient
|
| 162 |
private float schemeValue;
|
156 |
private float schemeValue;
|
| 163 |
|
157 |
|
| 164 |
|
- |
|
| 165 |
public float getSchemeValue() {
|
158 |
public float getSchemeValue() {
|
| 166 |
return schemeValue;
|
159 |
return schemeValue;
|
| 167 |
}
|
160 |
}
|
| 168 |
|
161 |
|
| 169 |
public void setSchemeValue(float schemeValue) {
|
162 |
public void setSchemeValue(float schemeValue) {
|
| Line 172... |
Line 165... |
| 172 |
|
165 |
|
| 173 |
@Column(name = "partner_type")
|
166 |
@Column(name = "partner_type")
|
| 174 |
@Enumerated(EnumType.STRING)
|
167 |
@Enumerated(EnumType.STRING)
|
| 175 |
private PartnerType partnerType;
|
168 |
private PartnerType partnerType;
|
| 176 |
|
169 |
|
| 177 |
|
- |
|
| 178 |
@Override
|
170 |
@Override
|
| 179 |
public String toString() {
|
171 |
public String toString() {
|
| 180 |
return "Scheme{" +
|
- |
|
| 181 |
"id=" + id +
|
- |
|
| 182 |
", name='" + name + '\'' +
|
- |
|
| 183 |
", description='" + description + '\'' +
|
172 |
return "Scheme{" + "id=" + id + ", name='" + name + '\'' + ", description='" + description + '\'' + ", type="
|
| 184 |
", type=" + type +
|
- |
|
| 185 |
", amountType=" + amountType +
|
- |
|
| 186 |
", gstReversal=" + basePlusGstCalc +
|
173 |
+ type + ", amountType=" + amountType + ", gstReversal=" + basePlusGstCalc + ", amount=" + amount
|
| 187 |
", amount=" + amount +
|
- |
|
| 188 |
", startDateTime=" + startDateTime +
|
- |
|
| 189 |
", endDateTime=" + endDateTime +
|
- |
|
| 190 |
", createTimestamp=" + createTimestamp +
|
174 |
+ ", startDateTime=" + startDateTime + ", endDateTime=" + endDateTime + ", createTimestamp="
|
| 191 |
", activeTimestamp=" + activeTimestamp +
|
175 |
+ createTimestamp + ", activeTimestamp=" + activeTimestamp + ", expireTimestamp=" + expireTimestamp
|
| 192 |
", expireTimestamp=" + expireTimestamp +
|
- |
|
| 193 |
", createdBy=" + createdBy +
|
- |
|
| 194 |
", cashback=" + cashback +
|
- |
|
| 195 |
", retailerIds=" + retailerIds +
|
176 |
+ ", createdBy=" + createdBy + ", cashback=" + cashback + ", retailerIds=" + retailerIds
|
| 196 |
", amountModel='" + amountModel + '\'' +
|
177 |
+ ", amountModel='" + amountModel + '\'' + ", schemeValue=" + schemeValue + ", partnerType="
|
| 197 |
", schemeValue=" + schemeValue +
|
- |
|
| 198 |
", partnerType=" + partnerType +
|
- |
|
| 199 |
", catalogStringMap=" + catalogStringMap +
|
178 |
+ partnerType + ", catalogStringMap=" + catalogStringMap + '}';
|
| 200 |
'}';
|
- |
|
| 201 |
}
|
179 |
}
|
| 202 |
|
180 |
|
| 203 |
@Override
|
181 |
@Override
|
| 204 |
public boolean equals(Object o) {
|
182 |
public boolean equals(Object o) {
|
| 205 |
if (this == o) return true;
|
183 |
if (this == o)
|
| - |
|
184 |
return true;
|
| 206 |
if (o == null || getClass() != o.getClass()) return false;
|
185 |
if (o == null || getClass() != o.getClass())
|
| - |
|
186 |
return false;
|
| 207 |
Scheme scheme = (Scheme) o;
|
187 |
Scheme scheme = (Scheme) o;
|
| 208 |
return id == scheme.id && basePlusGstCalc == scheme.basePlusGstCalc && Float.compare(scheme.amount, amount) == 0 && createdBy == scheme.createdBy && cashback == scheme.cashback && Float.compare(scheme.schemeValue, schemeValue) == 0 && Objects.equals(name, scheme.name) && Objects.equals(description, scheme.description) && type == scheme.type && amountType == scheme.amountType && Objects.equals(startDateTime, scheme.startDateTime) && Objects.equals(endDateTime, scheme.endDateTime) && Objects.equals(createTimestamp, scheme.createTimestamp) && Objects.equals(activeTimestamp, scheme.activeTimestamp) && Objects.equals(expireTimestamp, scheme.expireTimestamp) && Objects.equals(retailerIds, scheme.retailerIds) && Objects.equals(amountModel, scheme.amountModel) && partnerType == scheme.partnerType && Objects.equals(catalogStringMap, scheme.catalogStringMap);
|
188 |
return id == scheme.id && basePlusGstCalc == scheme.basePlusGstCalc && Float.compare(scheme.amount, amount) == 0
|
| - |
|
189 |
&& createdBy == scheme.createdBy && cashback == scheme.cashback
|
| - |
|
190 |
&& Float.compare(scheme.schemeValue, schemeValue) == 0 && Objects.equals(name, scheme.name)
|
| - |
|
191 |
&& Objects.equals(description, scheme.description) && type == scheme.type
|
| - |
|
192 |
&& amountType == scheme.amountType && Objects.equals(startDateTime, scheme.startDateTime)
|
| - |
|
193 |
&& Objects.equals(endDateTime, scheme.endDateTime)
|
| - |
|
194 |
&& Objects.equals(createTimestamp, scheme.createTimestamp)
|
| - |
|
195 |
&& Objects.equals(activeTimestamp, scheme.activeTimestamp)
|
| - |
|
196 |
&& Objects.equals(expireTimestamp, scheme.expireTimestamp)
|
| - |
|
197 |
&& Objects.equals(retailerIds, scheme.retailerIds) && Objects.equals(amountModel, scheme.amountModel)
|
| - |
|
198 |
&& partnerType == scheme.partnerType && Objects.equals(catalogStringMap, scheme.catalogStringMap);
|
| 209 |
}
|
199 |
}
|
| 210 |
|
200 |
|
| 211 |
@Override
|
201 |
@Override
|
| 212 |
public int hashCode() {
|
202 |
public int hashCode() {
|
| 213 |
return Objects.hash(id, name, description, type, amountType, basePlusGstCalc, amount, startDateTime, endDateTime, createTimestamp, activeTimestamp, expireTimestamp, createdBy, cashback, retailerIds, amountModel, schemeValue, partnerType, catalogStringMap);
|
203 |
return Objects.hash(id, name, description, type, amountType, basePlusGstCalc, amount, startDateTime,
|
| - |
|
204 |
endDateTime, createTimestamp, activeTimestamp, expireTimestamp, createdBy, cashback, retailerIds,
|
| - |
|
205 |
amountModel, schemeValue, partnerType, catalogStringMap);
|
| 214 |
}
|
206 |
}
|
| 215 |
|
207 |
|
| 216 |
@Transient
|
208 |
@Transient
|
| 217 |
private Map<Integer, String> catalogStringMap = new HashMap<>();
|
209 |
private Map<Integer, String> catalogStringMap = new HashMap<>();
|
| 218 |
|
210 |
|
| Line 222... |
Line 214... |
| 222 |
|
214 |
|
| 223 |
public void setId(int id) {
|
215 |
public void setId(int id) {
|
| 224 |
this.id = id;
|
216 |
this.id = id;
|
| 225 |
}
|
217 |
}
|
| 226 |
|
218 |
|
| 227 |
|
- |
|
| 228 |
public String getAmountModel() {
|
219 |
public String getAmountModel() {
|
| 229 |
return amountModel;
|
220 |
return amountModel;
|
| 230 |
}
|
221 |
}
|
| 231 |
|
222 |
|
| 232 |
public void setAmountModel(String amountModel) {
|
223 |
public void setAmountModel(String amountModel) {
|
| Line 385... |
Line 376... |
| 385 |
}
|
376 |
}
|
| 386 |
}
|
377 |
}
|
| 387 |
return String.join(", ", stringRetailerIds);
|
378 |
return String.join(", ", stringRetailerIds);
|
| 388 |
}
|
379 |
}
|
| 389 |
|
380 |
|
| 390 |
|
- |
|
| 391 |
public boolean isBasePlusGstCalc() {
|
381 |
public boolean isBasePlusGstCalc() {
|
| 392 |
return basePlusGstCalc;
|
382 |
return basePlusGstCalc;
|
| 393 |
}
|
383 |
}
|
| 394 |
|
384 |
|
| 395 |
public void setBasePlusGstCalc(boolean gstReversal) {
|
385 |
public void setBasePlusGstCalc(boolean gstReversal) {
|
| 396 |
this.basePlusGstCalc = gstReversal;
|
386 |
this.basePlusGstCalc = gstReversal;
|
| 397 |
}
|
387 |
}
|
| 398 |
|
388 |
|
| 399 |
|
- |
|
| 400 |
public Map<Integer, String> getCatalogStringMap() {
|
389 |
public Map<Integer, String> getCatalogStringMap() {
|
| 401 |
return catalogStringMap;
|
390 |
return catalogStringMap;
|
| 402 |
}
|
391 |
}
|
| 403 |
|
392 |
|
| 404 |
public void setCatalogStringMap(Map<Integer, String> catalogStringMap) {
|
393 |
public void setCatalogStringMap(Map<Integer, String> catalogStringMap) {
|