| 22653 |
ashik.ali |
1 |
package com.spice.profitmandi.service.scheme;
|
|
|
2 |
|
| 22859 |
ashik.ali |
3 |
import java.time.LocalDateTime;
|
| 23019 |
ashik.ali |
4 |
import java.util.ArrayList;
|
| 22653 |
ashik.ali |
5 |
import java.util.HashMap;
|
| 22859 |
ashik.ali |
6 |
import java.util.HashSet;
|
| 22653 |
ashik.ali |
7 |
import java.util.List;
|
|
|
8 |
import java.util.Map;
|
|
|
9 |
import java.util.Set;
|
| 23529 |
ashik.ali |
10 |
import java.util.stream.Collectors;
|
| 22653 |
ashik.ali |
11 |
|
| 23781 |
ashik.ali |
12 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
13 |
import org.apache.logging.log4j.Logger;
|
| 22653 |
ashik.ali |
14 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23781 |
ashik.ali |
15 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 22653 |
ashik.ali |
16 |
import org.springframework.stereotype.Component;
|
|
|
17 |
|
| 22859 |
ashik.ali |
18 |
import com.spice.profitmandi.common.enumuration.DateTimePattern;
|
| 22653 |
ashik.ali |
19 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 22859 |
ashik.ali |
20 |
import com.spice.profitmandi.common.model.CreateSchemeRequest;
|
| 22653 |
ashik.ali |
21 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 23019 |
ashik.ali |
22 |
import com.spice.profitmandi.common.model.SchemeModel;
|
| 22859 |
ashik.ali |
23 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 23339 |
ashik.ali |
24 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 22653 |
ashik.ali |
25 |
import com.spice.profitmandi.dao.entity.catalog.RetailerScheme;
|
|
|
26 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 23781 |
ashik.ali |
27 |
import com.spice.profitmandi.dao.entity.dtr.Role;
|
| 22653 |
ashik.ali |
28 |
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
|
| 23365 |
ashik.ali |
29 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 22859 |
ashik.ali |
30 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 22653 |
ashik.ali |
31 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 23339 |
ashik.ali |
32 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| 22859 |
ashik.ali |
33 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
|
|
34 |
import com.spice.profitmandi.dao.entity.fofo.SchemeItem;
|
| 23344 |
ashik.ali |
35 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 23527 |
ashik.ali |
36 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
| 22653 |
ashik.ali |
37 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| 23781 |
ashik.ali |
38 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| 22859 |
ashik.ali |
39 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 22653 |
ashik.ali |
40 |
import com.spice.profitmandi.dao.repository.catalog.RetailerSchemeRepository;
|
|
|
41 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| 22859 |
ashik.ali |
42 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
| 23781 |
ashik.ali |
43 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
| 23019 |
ashik.ali |
44 |
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemRepository;
|
|
|
45 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 23365 |
ashik.ali |
46 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| 22653 |
ashik.ali |
47 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 23339 |
ashik.ali |
48 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| 22859 |
ashik.ali |
49 |
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
|
|
|
50 |
import com.spice.profitmandi.dao.repository.fofo.SchemeItemRepository;
|
| 23344 |
ashik.ali |
51 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 23365 |
ashik.ali |
52 |
import com.spice.profitmandi.service.order.OrderService;
|
| 22859 |
ashik.ali |
53 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 22653 |
ashik.ali |
54 |
|
| 22859 |
ashik.ali |
55 |
import in.shop2020.model.v1.catalog.ItemType;
|
|
|
56 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
|
|
57 |
|
| 22653 |
ashik.ali |
58 |
@Component
|
|
|
59 |
public class SchemeServiceImpl implements SchemeService {
|
|
|
60 |
|
| 23568 |
govind |
61 |
private static final Logger LOGGER = LogManager.getLogger(SchemeServiceImpl.class);
|
| 23444 |
amit.gupta |
62 |
|
| 22653 |
ashik.ali |
63 |
@Autowired
|
| 23781 |
ashik.ali |
64 |
@Qualifier("fofoInventoryItemRepository")
|
| 22653 |
ashik.ali |
65 |
private InventoryItemRepository inventoryItemRepository;
|
| 23444 |
amit.gupta |
66 |
|
| 22653 |
ashik.ali |
67 |
@Autowired
|
| 22925 |
ashik.ali |
68 |
private OrderService orderService;
|
| 23444 |
amit.gupta |
69 |
|
| 22653 |
ashik.ali |
70 |
@Autowired
|
|
|
71 |
private SchemeRepository schemeRepository;
|
| 23444 |
amit.gupta |
72 |
|
| 22653 |
ashik.ali |
73 |
@Autowired
|
| 22859 |
ashik.ali |
74 |
private RetailerRepository retailerRepository;
|
| 23444 |
amit.gupta |
75 |
|
| 22859 |
ashik.ali |
76 |
@Autowired
|
| 22653 |
ashik.ali |
77 |
private RetailerSchemeRepository retailerSchemeRepository;
|
| 23444 |
amit.gupta |
78 |
|
| 22653 |
ashik.ali |
79 |
@Autowired
|
| 22859 |
ashik.ali |
80 |
private SchemeInOutRepository schemeInOutRepository;
|
| 23444 |
amit.gupta |
81 |
|
| 22653 |
ashik.ali |
82 |
@Autowired
|
| 23781 |
ashik.ali |
83 |
@Qualifier("catalogItemRepository")
|
| 22859 |
ashik.ali |
84 |
private ItemRepository itemRepository;
|
| 23444 |
amit.gupta |
85 |
|
| 22859 |
ashik.ali |
86 |
@Autowired
|
|
|
87 |
private SchemeItemRepository schemeItemRepository;
|
| 23444 |
amit.gupta |
88 |
|
| 22859 |
ashik.ali |
89 |
@Autowired
|
|
|
90 |
private WalletService walletService;
|
| 23444 |
amit.gupta |
91 |
|
| 23019 |
ashik.ali |
92 |
@Autowired
|
|
|
93 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
| 23444 |
amit.gupta |
94 |
|
| 23019 |
ashik.ali |
95 |
@Autowired
|
|
|
96 |
private FofoLineItemRepository fofoLineItemRepository;
|
| 23444 |
amit.gupta |
97 |
|
| 23339 |
ashik.ali |
98 |
@Autowired
|
|
|
99 |
private PurchaseRepository purchaseRepository;
|
| 23444 |
amit.gupta |
100 |
|
| 23344 |
ashik.ali |
101 |
@Autowired
|
|
|
102 |
private OrderRepository orderRepository;
|
| 23444 |
amit.gupta |
103 |
|
| 23365 |
ashik.ali |
104 |
@Autowired
|
|
|
105 |
private FofoOrderRepository fofoOrderRepository;
|
| 23796 |
amit.gupta |
106 |
|
| 23781 |
ashik.ali |
107 |
@Autowired
|
|
|
108 |
private RoleRepository roleRepository;
|
| 23444 |
amit.gupta |
109 |
|
| 22653 |
ashik.ali |
110 |
@Override
|
| 22859 |
ashik.ali |
111 |
public void saveScheme(int creatorId, CreateSchemeRequest createSchemeRequest) throws ProfitMandiBusinessException {
|
| 23444 |
amit.gupta |
112 |
|
| 23019 |
ashik.ali |
113 |
this.validateCreateSchemeRequest(createSchemeRequest);
|
| 23444 |
amit.gupta |
114 |
|
| 22859 |
ashik.ali |
115 |
Scheme scheme = this.toScheme(creatorId, createSchemeRequest);
|
| 23444 |
amit.gupta |
116 |
|
|
|
117 |
if (scheme.getStartDateTime().isAfter(scheme.getEndDateTime())) {
|
|
|
118 |
throw new ProfitMandiBusinessException(
|
|
|
119 |
ProfitMandiConstants.START_DATE + ", " + ProfitMandiConstants.END_DATE,
|
|
|
120 |
scheme.getStartDateTime() + ", " + scheme.getEndDateTime(), "SCHM_VE_1005");
|
| 22653 |
ashik.ali |
121 |
}
|
| 23444 |
amit.gupta |
122 |
|
| 22859 |
ashik.ali |
123 |
this.validateItemIds(createSchemeRequest);
|
|
|
124 |
schemeRepository.persist(scheme);
|
| 23444 |
amit.gupta |
125 |
if (!createSchemeRequest.isRetailerAll()) {
|
| 22859 |
ashik.ali |
126 |
this.validateRetailerIds(createSchemeRequest);
|
| 23444 |
amit.gupta |
127 |
for (int retailerId : createSchemeRequest.getRetailerIds()) {
|
| 22859 |
ashik.ali |
128 |
RetailerScheme retailerScheme = new RetailerScheme();
|
|
|
129 |
retailerScheme.setRetailerId(retailerId);
|
|
|
130 |
retailerScheme.setSchemeId(scheme.getId());
|
|
|
131 |
retailerSchemeRepository.persist(retailerScheme);
|
|
|
132 |
}
|
| 22653 |
ashik.ali |
133 |
}
|
| 23444 |
amit.gupta |
134 |
for (int itemId : createSchemeRequest.getItemIds()) {
|
| 22859 |
ashik.ali |
135 |
SchemeItem schemeItem = new SchemeItem();
|
|
|
136 |
schemeItem.setSchemeId(scheme.getId());
|
|
|
137 |
schemeItem.setItemId(itemId);
|
|
|
138 |
schemeItemRepository.persist(schemeItem);
|
|
|
139 |
}
|
| 23444 |
amit.gupta |
140 |
|
| 22653 |
ashik.ali |
141 |
}
|
| 23444 |
amit.gupta |
142 |
|
|
|
143 |
private void validateCreateSchemeRequest(CreateSchemeRequest createSchemeRequest)
|
|
|
144 |
throws ProfitMandiBusinessException {
|
|
|
145 |
if (createSchemeRequest.getName() == null || createSchemeRequest.getName().isEmpty()) {
|
|
|
146 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.NAME, createSchemeRequest.getName(),
|
|
|
147 |
"SCHM_VE_1000");
|
| 23019 |
ashik.ali |
148 |
}
|
| 23444 |
amit.gupta |
149 |
if (createSchemeRequest.getAmount() <= 0) {
|
|
|
150 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.AMOUNT, createSchemeRequest.getAmount(),
|
|
|
151 |
"SCHM_VE_1001");
|
| 23019 |
ashik.ali |
152 |
}
|
| 23444 |
amit.gupta |
153 |
|
| 23527 |
ashik.ali |
154 |
if (AmountType.valueOf(createSchemeRequest.getAmountType()) == AmountType.PERCENTAGE
|
| 23444 |
amit.gupta |
155 |
&& createSchemeRequest.getAmount() > 100) {
|
|
|
156 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.AMOUNT, createSchemeRequest.getAmount(),
|
|
|
157 |
"SCHM_VE_1002");
|
| 23019 |
ashik.ali |
158 |
}
|
| 23444 |
amit.gupta |
159 |
|
|
|
160 |
if (createSchemeRequest.getStartDateTimeString() == null
|
|
|
161 |
|| createSchemeRequest.getStartDateTimeString().isEmpty()) {
|
|
|
162 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.START_DATE,
|
|
|
163 |
createSchemeRequest.getStartDateTimeString(), "SCHM_VE_1003");
|
| 23019 |
ashik.ali |
164 |
}
|
| 23444 |
amit.gupta |
165 |
|
|
|
166 |
if (createSchemeRequest.getEndDateTimeString() == null
|
|
|
167 |
|| createSchemeRequest.getStartDateTimeString().isEmpty()) {
|
|
|
168 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.END_DATE,
|
|
|
169 |
createSchemeRequest.getEndDateTimeString(), "SCHM_VE_1004");
|
| 23019 |
ashik.ali |
170 |
}
|
|
|
171 |
}
|
| 23444 |
amit.gupta |
172 |
|
|
|
173 |
private Scheme toScheme(int creatorId, CreateSchemeRequest createSchemeRequest) {
|
| 22859 |
ashik.ali |
174 |
Scheme scheme = new Scheme();
|
|
|
175 |
scheme.setName(createSchemeRequest.getName());
|
|
|
176 |
scheme.setDescription(createSchemeRequest.getDescription());
|
|
|
177 |
scheme.setType(SchemeType.valueOf(createSchemeRequest.getType()));
|
| 23527 |
ashik.ali |
178 |
scheme.setAmountType(AmountType.valueOf(createSchemeRequest.getAmountType()));
|
| 22859 |
ashik.ali |
179 |
scheme.setAmount(createSchemeRequest.getAmount());
|
| 23444 |
amit.gupta |
180 |
scheme.setStartDateTime(StringUtils.toDateTime(createSchemeRequest.getStartDateTimeString(),
|
|
|
181 |
DateTimePattern.DD_MM_YYYY_T_HH_MM_SS));
|
|
|
182 |
scheme.setEndDateTime(StringUtils.toDateTime(createSchemeRequest.getEndDateTimeString(),
|
|
|
183 |
DateTimePattern.DD_MM_YYYY_T_HH_MM_SS));
|
| 22859 |
ashik.ali |
184 |
scheme.setCreatedBy(creatorId);
|
|
|
185 |
scheme.setRetailerAll(createSchemeRequest.isRetailerAll());
|
|
|
186 |
return scheme;
|
|
|
187 |
}
|
| 23444 |
amit.gupta |
188 |
|
|
|
189 |
private void validateRetailerIds(CreateSchemeRequest createSchemeRequest) throws ProfitMandiBusinessException {
|
|
|
190 |
if (createSchemeRequest.getRetailerIds() == null || createSchemeRequest.getRetailerIds().isEmpty()) {
|
|
|
191 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID,
|
|
|
192 |
createSchemeRequest.getRetailerIds(), "SCHM_1001");
|
| 22859 |
ashik.ali |
193 |
}
|
| 22870 |
ashik.ali |
194 |
List<Integer> foundRetailerIds = retailerRepository.selectIdsByIds(createSchemeRequest.getRetailerIds());
|
| 23444 |
amit.gupta |
195 |
if (foundRetailerIds.size() != createSchemeRequest.getRetailerIds().size()) {
|
| 22859 |
ashik.ali |
196 |
createSchemeRequest.getRetailerIds().removeAll(foundRetailerIds);
|
| 23444 |
amit.gupta |
197 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID,
|
|
|
198 |
createSchemeRequest.getRetailerIds(), "SCHM_1002");
|
| 22859 |
ashik.ali |
199 |
}
|
|
|
200 |
}
|
| 23444 |
amit.gupta |
201 |
|
|
|
202 |
private void validateItemIds(CreateSchemeRequest createSchemeRequest) throws ProfitMandiBusinessException {
|
|
|
203 |
if (createSchemeRequest.getItemIds() == null || createSchemeRequest.getItemIds().isEmpty()) {
|
|
|
204 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.ITEM_ID, createSchemeRequest.getItemIds(),
|
|
|
205 |
"SCHM_1003");
|
| 22859 |
ashik.ali |
206 |
}
|
| 23444 |
amit.gupta |
207 |
List<Integer> foundItemIds = itemRepository.selectIdsByIdsAndType(createSchemeRequest.getItemIds(),
|
|
|
208 |
ItemType.SERIALIZED);
|
|
|
209 |
if (foundItemIds.size() != createSchemeRequest.getItemIds().size()) {
|
| 22859 |
ashik.ali |
210 |
createSchemeRequest.getItemIds().removeAll(foundItemIds);
|
| 23444 |
amit.gupta |
211 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.ITEM_ID, createSchemeRequest.getItemIds(),
|
|
|
212 |
"SCHM_1004");
|
| 22859 |
ashik.ali |
213 |
}
|
|
|
214 |
}
|
| 23444 |
amit.gupta |
215 |
|
| 22859 |
ashik.ali |
216 |
@Override
|
|
|
217 |
public Scheme getSchemeById(int schemeId) throws ProfitMandiBusinessException {
|
|
|
218 |
Scheme scheme = schemeRepository.selectById(schemeId);
|
| 23444 |
amit.gupta |
219 |
if (!scheme.isRetailerAll()) {
|
| 23019 |
ashik.ali |
220 |
List<Integer> retailerIds = retailerSchemeRepository.selectRetailerIdsBySchemeId(scheme.getId());
|
|
|
221 |
scheme.getRetailerIds().addAll(retailerIds);
|
| 22859 |
ashik.ali |
222 |
}
|
|
|
223 |
List<Integer> itemIds = schemeItemRepository.selectItemIdsBySchemeId(scheme.getId());
|
| 23339 |
ashik.ali |
224 |
List<Item> items = itemRepository.selectByIds(new HashSet<>(itemIds));
|
|
|
225 |
scheme.setItemStringMap(this.toItemStringMap(items));
|
| 22859 |
ashik.ali |
226 |
return scheme;
|
|
|
227 |
}
|
| 23444 |
amit.gupta |
228 |
|
|
|
229 |
public Map<Integer, String> toItemStringMap(List<Item> items) {
|
| 23339 |
ashik.ali |
230 |
Map<Integer, String> itemMap = new HashMap<>();
|
| 23444 |
amit.gupta |
231 |
for (Item item : items) {
|
| 23339 |
ashik.ali |
232 |
itemMap.put(item.getId(), this.getItemString(item));
|
|
|
233 |
}
|
|
|
234 |
return itemMap;
|
|
|
235 |
}
|
| 23444 |
amit.gupta |
236 |
|
|
|
237 |
public String getItemString(Item item) {
|
| 23339 |
ashik.ali |
238 |
StringBuilder itemString = new StringBuilder();
|
| 23444 |
amit.gupta |
239 |
if (item.getBrand() != null && !item.getBrand().isEmpty()) {
|
| 23339 |
ashik.ali |
240 |
itemString.append(item.getBrand().trim());
|
|
|
241 |
}
|
|
|
242 |
itemString.append(" ");
|
| 23444 |
amit.gupta |
243 |
if (item.getModelName() != null && !item.getModelName().isEmpty()) {
|
| 23339 |
ashik.ali |
244 |
itemString.append(item.getModelName().trim());
|
|
|
245 |
}
|
|
|
246 |
itemString.append(" ");
|
| 23444 |
amit.gupta |
247 |
if (item.getModelNumber() != null && !item.getModelNumber().isEmpty()) {
|
| 23339 |
ashik.ali |
248 |
itemString.append(item.getModelNumber().trim());
|
|
|
249 |
}
|
|
|
250 |
itemString.append(" ");
|
| 23444 |
amit.gupta |
251 |
if (item.getColor() != null && !item.getColor().isEmpty()) {
|
| 23339 |
ashik.ali |
252 |
itemString.append(item.getColor().trim());
|
|
|
253 |
}
|
|
|
254 |
return itemString.toString();
|
|
|
255 |
}
|
| 23444 |
amit.gupta |
256 |
|
|
|
257 |
private Set<Integer> schemeItemsToItemIds(List<SchemeItem> schemeItems) {
|
| 23339 |
ashik.ali |
258 |
Set<Integer> itemIds = new HashSet<>();
|
| 23444 |
amit.gupta |
259 |
for (SchemeItem schemeItem : schemeItems) {
|
| 23339 |
ashik.ali |
260 |
itemIds.add(schemeItem.getItemId());
|
|
|
261 |
}
|
|
|
262 |
return itemIds;
|
|
|
263 |
}
|
| 23444 |
amit.gupta |
264 |
|
| 23019 |
ashik.ali |
265 |
@Override
|
|
|
266 |
public List<SchemeModel> getAllSchemeModels(LocalDateTime startDateTime, LocalDateTime endDateTime) {
|
|
|
267 |
List<Scheme> schemes = schemeRepository.selectAllBetweenCreateTimestamp(startDateTime, endDateTime);
|
|
|
268 |
Map<Integer, Scheme> schemeIdSchemeMap = this.toSchemeIdSchemeMap(schemes);
|
|
|
269 |
List<SchemeItem> schemeItems = schemeItemRepository.selectBySchemeIds(schemeIdSchemeMap.keySet());
|
| 23339 |
ashik.ali |
270 |
Set<Integer> itemIds = this.schemeItemsToItemIds(schemeItems);
|
|
|
271 |
List<Item> items = itemRepository.selectByIds(itemIds);
|
|
|
272 |
Map<Integer, String> itemStringMap = this.toItemStringMap(items);
|
|
|
273 |
this.addItemIdsToSchemes(schemeItems, schemeIdSchemeMap, itemStringMap);
|
| 23019 |
ashik.ali |
274 |
List<RetailerScheme> retailerSchemes = retailerSchemeRepository.selectBySchemeIds(schemeIdSchemeMap.keySet());
|
|
|
275 |
this.addRetailerIdsToSchemes(retailerSchemes, schemeIdSchemeMap);
|
|
|
276 |
return this.toSchemeModels(schemeIdSchemeMap);
|
|
|
277 |
}
|
| 23444 |
amit.gupta |
278 |
|
|
|
279 |
private void addItemIdsToSchemes(List<SchemeItem> schemeItems, Map<Integer, Scheme> schemeIdSchemeMap,
|
|
|
280 |
Map<Integer, String> itemStringMap) {
|
|
|
281 |
for (SchemeItem schemeItem : schemeItems) {
|
|
|
282 |
schemeIdSchemeMap.get(schemeItem.getSchemeId()).getItemStringMap().put(schemeItem.getItemId(),
|
|
|
283 |
itemStringMap.get(schemeItem.getItemId()));
|
| 23019 |
ashik.ali |
284 |
}
|
|
|
285 |
}
|
| 23444 |
amit.gupta |
286 |
|
|
|
287 |
private void addRetailerIdsToSchemes(List<RetailerScheme> retailerSchemes, Map<Integer, Scheme> schemeIdSchemeMap) {
|
|
|
288 |
for (RetailerScheme retailerScheme : retailerSchemes) {
|
|
|
289 |
schemeIdSchemeMap.get(retailerScheme.getSchemeId()).getRetailerIds().add(retailerScheme.getRetailerId());
|
| 23019 |
ashik.ali |
290 |
}
|
|
|
291 |
}
|
| 23444 |
amit.gupta |
292 |
|
|
|
293 |
private List<SchemeModel> toSchemeModels(Map<Integer, Scheme> schemeIdSchemeMap) {
|
| 23019 |
ashik.ali |
294 |
List<SchemeModel> schemeModels = new ArrayList<>();
|
| 23444 |
amit.gupta |
295 |
for (Map.Entry<Integer, Scheme> schemeIdSchemeEntry : schemeIdSchemeMap.entrySet()) {
|
| 23019 |
ashik.ali |
296 |
schemeModels.add(this.toSchemeModel(schemeIdSchemeEntry.getValue()));
|
|
|
297 |
}
|
|
|
298 |
return schemeModels;
|
|
|
299 |
}
|
| 23444 |
amit.gupta |
300 |
|
|
|
301 |
private SchemeModel toSchemeModel(Scheme scheme) {
|
| 23019 |
ashik.ali |
302 |
SchemeModel schemeModel = new SchemeModel();
|
|
|
303 |
schemeModel.setSchemeId(scheme.getId());
|
|
|
304 |
schemeModel.setName(scheme.getName());
|
|
|
305 |
schemeModel.setDescription(scheme.getDescription());
|
|
|
306 |
schemeModel.setSchemeType(scheme.getType().toString());
|
|
|
307 |
schemeModel.setAmountType(scheme.getAmountType().toString());
|
|
|
308 |
schemeModel.setAmount(scheme.getAmount());
|
|
|
309 |
schemeModel.setStartDateTime(StringUtils.toString(scheme.getStartDateTime()));
|
|
|
310 |
schemeModel.setEndDateTime(StringUtils.toString(scheme.getEndDateTime()));
|
|
|
311 |
schemeModel.setCreateTimestamp(StringUtils.toString(scheme.getCreateTimestamp()));
|
|
|
312 |
schemeModel.setActiveTimestamp(StringUtils.toString(scheme.getActiveTimestamp()));
|
|
|
313 |
schemeModel.setExpireTimestamp(StringUtils.toString(scheme.getExpireTimestamp()));
|
|
|
314 |
schemeModel.setCreatedBy(scheme.getCreatedBy());
|
| 23339 |
ashik.ali |
315 |
schemeModel.setItemStringMap(scheme.getItemStringMap());
|
| 23019 |
ashik.ali |
316 |
schemeModel.setRetailerIds(scheme.getRetailerIds());
|
|
|
317 |
return schemeModel;
|
|
|
318 |
}
|
| 22653 |
ashik.ali |
319 |
|
|
|
320 |
@Override
|
|
|
321 |
public void activeSchemeById(int schemeId) throws ProfitMandiBusinessException {
|
|
|
322 |
Scheme scheme = schemeRepository.selectById(schemeId);
|
| 23444 |
amit.gupta |
323 |
if (scheme.getActiveTimestamp() != null) {
|
|
|
324 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.ACTIVE_TIMESTAMP, scheme.getActiveTimestamp(),
|
|
|
325 |
"SCHM_1005");
|
| 22653 |
ashik.ali |
326 |
}
|
| 23444 |
amit.gupta |
327 |
if (scheme.getExpireTimestamp() != null) {
|
|
|
328 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.EXPIRE_TIMESTAMP, scheme.getExpireTimestamp(),
|
|
|
329 |
"SCHM_1006");
|
| 22653 |
ashik.ali |
330 |
}
|
| 22859 |
ashik.ali |
331 |
scheme.setActiveTimestamp(LocalDateTime.now());
|
|
|
332 |
schemeRepository.persist(scheme);
|
| 23444 |
amit.gupta |
333 |
if (scheme.getType() == SchemeType.IN) {
|
| 23019 |
ashik.ali |
334 |
this.processPreviousPurchases(scheme);
|
| 23444 |
amit.gupta |
335 |
} else if (scheme.getType() == SchemeType.OUT) {
|
| 23019 |
ashik.ali |
336 |
this.processPreviousSales(scheme);
|
|
|
337 |
}
|
| 22653 |
ashik.ali |
338 |
}
|
| 23444 |
amit.gupta |
339 |
|
|
|
340 |
private void processPreviousPurchases(Scheme scheme) throws ProfitMandiBusinessException {
|
|
|
341 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectBetweenDates(scheme.getStartDateTime(),
|
|
|
342 |
scheme.getEndDateTime());
|
|
|
343 |
if (inventoryItems.isEmpty()) {
|
| 23370 |
ashik.ali |
344 |
return;
|
|
|
345 |
}
|
| 23019 |
ashik.ali |
346 |
List<Integer> itemIds = schemeItemRepository.selectItemIdsBySchemeId(scheme.getId());
|
| 23444 |
amit.gupta |
347 |
if (itemIds.isEmpty()) {
|
| 23370 |
ashik.ali |
348 |
return;
|
|
|
349 |
}
|
| 23339 |
ashik.ali |
350 |
List<Item> items = itemRepository.selectByIds(new HashSet<>(itemIds));
|
|
|
351 |
Map<Integer, String> itemStringMap = this.toItemStringMap(items);
|
| 23444 |
amit.gupta |
352 |
List<InventoryItem> completedInventoryItems = this.toFilteredPurchaseCompletedInventoryItems(inventoryItems,
|
|
|
353 |
itemIds, true);
|
|
|
354 |
if (completedInventoryItems.isEmpty()) {
|
| 23370 |
ashik.ali |
355 |
return;
|
|
|
356 |
}
|
| 23444 |
amit.gupta |
357 |
if (scheme.isRetailerAll()) {
|
|
|
358 |
for (InventoryItem inventoryItem : completedInventoryItems) {
|
| 23019 |
ashik.ali |
359 |
float cashback = this.createSchemeInOut(scheme, inventoryItem);
|
| 23444 |
amit.gupta |
360 |
walletService.addAmountToWallet(inventoryItem.getFofoId(), inventoryItem.getPurchaseId(),
|
|
|
361 |
WalletReferenceType.SCHEME_IN,
|
| 23796 |
amit.gupta |
362 |
"Added SCHEME_IN for item " + itemStringMap.get(inventoryItem.getItemId())
|
|
|
363 |
+ " against invoiceNumber " + inventoryItem.getPurchase().getPurchaseReference(),
|
| 23444 |
amit.gupta |
364 |
cashback);
|
| 23019 |
ashik.ali |
365 |
}
|
| 23444 |
amit.gupta |
366 |
} else {
|
| 23019 |
ashik.ali |
367 |
List<Integer> retailerIds = retailerSchemeRepository.selectRetailerIdsBySchemeId(scheme.getId());
|
| 23444 |
amit.gupta |
368 |
for (InventoryItem inventoryItem : completedInventoryItems) {
|
|
|
369 |
if (retailerIds.contains(inventoryItem.getFofoId())) {
|
| 23019 |
ashik.ali |
370 |
float cashback = this.createSchemeInOut(scheme, inventoryItem);
|
| 23444 |
amit.gupta |
371 |
walletService.addAmountToWallet(inventoryItem.getFofoId(), inventoryItem.getPurchaseId(),
|
|
|
372 |
WalletReferenceType.SCHEME_IN,
|
| 23796 |
amit.gupta |
373 |
"Added SCHEME_IN for item " + itemStringMap.get(inventoryItem.getItemId())
|
|
|
374 |
+ " against invoiceNumber " + inventoryItem.getPurchase().getPurchaseReference(),
|
|
|
375 |
cashback);
|
| 23019 |
ashik.ali |
376 |
}
|
|
|
377 |
}
|
|
|
378 |
}
|
| 23444 |
amit.gupta |
379 |
|
| 23019 |
ashik.ali |
380 |
}
|
| 23444 |
amit.gupta |
381 |
|
|
|
382 |
private Map<Integer, Integer> toInventoryItemIdFofoOrderIdMap(List<FofoLineItem> fofoLineItems,
|
|
|
383 |
Map<Integer, FofoOrderItem> fofoOrderItemIdFofoOrderItemMap) {
|
| 23019 |
ashik.ali |
384 |
Map<Integer, Integer> inventoryItemIdFofoOrderIdMap = new HashMap<>();
|
| 23444 |
amit.gupta |
385 |
|
|
|
386 |
for (FofoLineItem fofoLineItem : fofoLineItems) {
|
|
|
387 |
inventoryItemIdFofoOrderIdMap.put(fofoLineItem.getInventoryItemId(),
|
| 23019 |
ashik.ali |
388 |
fofoOrderItemIdFofoOrderItemMap.get(fofoLineItem.getFofoOrderItemId()).getOrderId());
|
|
|
389 |
}
|
|
|
390 |
return inventoryItemIdFofoOrderIdMap;
|
|
|
391 |
}
|
| 23444 |
amit.gupta |
392 |
|
|
|
393 |
private void processPreviousSales(Scheme scheme) throws ProfitMandiBusinessException {
|
|
|
394 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectBetweenDates(scheme.getStartDateTime(),
|
|
|
395 |
scheme.getEndDateTime());
|
|
|
396 |
|
|
|
397 |
if (fofoOrderItems.isEmpty()) {
|
| 23370 |
ashik.ali |
398 |
return;
|
|
|
399 |
}
|
| 22653 |
ashik.ali |
400 |
|
| 23444 |
amit.gupta |
401 |
Map<Integer, FofoOrderItem> fofoOrderItemIdFofoOrderItemMap = this
|
|
|
402 |
.toFofoOrderItemIdFofoOrderItemMap(fofoOrderItems);
|
|
|
403 |
|
|
|
404 |
List<FofoLineItem> fofoLineItems = fofoLineItemRepository
|
|
|
405 |
.selectByFofoOrderItemIds(fofoOrderItemIdFofoOrderItemMap.keySet());
|
|
|
406 |
|
|
|
407 |
if (fofoLineItems.isEmpty()) {
|
| 23370 |
ashik.ali |
408 |
return;
|
|
|
409 |
}
|
| 23444 |
amit.gupta |
410 |
|
|
|
411 |
Map<Integer, Integer> inventoryItemIdFofoOrderIdMap = this.toInventoryItemIdFofoOrderIdMap(fofoLineItems,
|
|
|
412 |
fofoOrderItemIdFofoOrderItemMap);
|
|
|
413 |
|
|
|
414 |
List<InventoryItem> inventoryItems = inventoryItemRepository
|
|
|
415 |
.selectByIds(inventoryItemIdFofoOrderIdMap.keySet());
|
|
|
416 |
|
|
|
417 |
if (inventoryItems.isEmpty()) {
|
| 23370 |
ashik.ali |
418 |
return;
|
|
|
419 |
}
|
| 23444 |
amit.gupta |
420 |
|
| 23019 |
ashik.ali |
421 |
List<Integer> itemIds = schemeItemRepository.selectItemIdsBySchemeId(scheme.getId());
|
| 23444 |
amit.gupta |
422 |
|
|
|
423 |
if (itemIds.isEmpty()) {
|
| 23370 |
ashik.ali |
424 |
return;
|
|
|
425 |
}
|
| 23444 |
amit.gupta |
426 |
|
|
|
427 |
List<InventoryItem> completedInventoryItems = this.toFilteredPurchaseCompletedInventoryItems(inventoryItems,
|
|
|
428 |
itemIds, false);
|
|
|
429 |
|
|
|
430 |
if (scheme.isRetailerAll()) {
|
|
|
431 |
for (InventoryItem inventoryItem : completedInventoryItems) {
|
| 23019 |
ashik.ali |
432 |
float cashback = this.createSchemeInOut(scheme, inventoryItem);
|
| 23444 |
amit.gupta |
433 |
walletService.addAmountToWallet(inventoryItem.getFofoId(), inventoryItem.getPurchaseId(),
|
|
|
434 |
WalletReferenceType.SCHEME_OUT, "Added for SCHEME_OUT", cashback);
|
| 23019 |
ashik.ali |
435 |
}
|
| 23444 |
amit.gupta |
436 |
} else {
|
| 23019 |
ashik.ali |
437 |
List<Integer> retailerIds = retailerSchemeRepository.selectRetailerIdsBySchemeId(scheme.getId());
|
| 23444 |
amit.gupta |
438 |
for (InventoryItem inventoryItem : completedInventoryItems) {
|
|
|
439 |
if (retailerIds.contains(inventoryItem.getFofoId())) {
|
| 23019 |
ashik.ali |
440 |
float cashback = this.createSchemeInOut(scheme, inventoryItem);
|
| 23444 |
amit.gupta |
441 |
walletService.addAmountToWallet(inventoryItem.getFofoId(),
|
|
|
442 |
inventoryItemIdFofoOrderIdMap.get(inventoryItem.getId()), WalletReferenceType.SCHEME_OUT,
|
|
|
443 |
"Added for SCHEME_OUT", cashback);
|
| 23019 |
ashik.ali |
444 |
}
|
|
|
445 |
}
|
|
|
446 |
}
|
|
|
447 |
}
|
| 23444 |
amit.gupta |
448 |
|
|
|
449 |
private Map<Integer, FofoOrderItem> toFofoOrderItemIdFofoOrderItemMap(List<FofoOrderItem> fofoOrderItems) {
|
| 23019 |
ashik.ali |
450 |
Map<Integer, FofoOrderItem> fofoOrderItemIdFofoOrderItemMap = new HashMap<>();
|
| 23444 |
amit.gupta |
451 |
for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
|
| 23019 |
ashik.ali |
452 |
fofoOrderItemIdFofoOrderItemMap.put(fofoOrderItem.getId(), fofoOrderItem);
|
|
|
453 |
}
|
|
|
454 |
return fofoOrderItemIdFofoOrderItemMap;
|
|
|
455 |
}
|
| 23444 |
amit.gupta |
456 |
|
|
|
457 |
private List<InventoryItem> toFilteredPurchaseCompletedInventoryItems(List<InventoryItem> inventoryItems,
|
|
|
458 |
List<Integer> itemIds, boolean purchase) {
|
| 23019 |
ashik.ali |
459 |
List<InventoryItem> completedInventoryItems = new ArrayList<>();
|
| 23444 |
amit.gupta |
460 |
for (InventoryItem inventoryItem : inventoryItems) {
|
|
|
461 |
if (purchase && inventoryItem.getPurchase().getCompleteTimestamp() != null
|
|
|
462 |
&& itemIds.contains(inventoryItem.getItemId())) {
|
| 23019 |
ashik.ali |
463 |
completedInventoryItems.add(inventoryItem);
|
| 23444 |
amit.gupta |
464 |
} else if (!purchase && itemIds.contains(inventoryItem.getItemId())) {
|
| 23297 |
ashik.ali |
465 |
completedInventoryItems.add(inventoryItem);
|
| 23019 |
ashik.ali |
466 |
}
|
|
|
467 |
}
|
|
|
468 |
return completedInventoryItems;
|
|
|
469 |
}
|
| 23444 |
amit.gupta |
470 |
|
| 22653 |
ashik.ali |
471 |
@Override
|
|
|
472 |
public void expireSchemeById(int schemeId) throws ProfitMandiBusinessException {
|
|
|
473 |
Scheme scheme = schemeRepository.selectById(schemeId);
|
| 23444 |
amit.gupta |
474 |
if (scheme.getActiveTimestamp() == null) {
|
|
|
475 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.ACTIVE_TIMESTAMP, scheme.getActiveTimestamp(),
|
|
|
476 |
"SCHM_1007");
|
| 22653 |
ashik.ali |
477 |
}
|
| 23444 |
amit.gupta |
478 |
if (scheme.getExpireTimestamp() != null) {
|
|
|
479 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.EXPIRE_TIMESTAMP, scheme.getExpireTimestamp(),
|
|
|
480 |
"SCHM_1008");
|
| 22653 |
ashik.ali |
481 |
}
|
| 22859 |
ashik.ali |
482 |
scheme.setExpireTimestamp(LocalDateTime.now());
|
|
|
483 |
schemeRepository.persist(scheme);
|
| 22653 |
ashik.ali |
484 |
}
|
| 23444 |
amit.gupta |
485 |
|
|
|
486 |
private Map<Integer, Scheme> toSchemeIdSchemeMap(List<Scheme> schemes) {
|
| 23019 |
ashik.ali |
487 |
Map<Integer, Scheme> schemeIdSchemeMap = new HashMap<>();
|
| 23444 |
amit.gupta |
488 |
for (Scheme scheme : schemes) {
|
| 23019 |
ashik.ali |
489 |
schemeIdSchemeMap.put(scheme.getId(), scheme);
|
| 22859 |
ashik.ali |
490 |
}
|
| 23019 |
ashik.ali |
491 |
return schemeIdSchemeMap;
|
| 22859 |
ashik.ali |
492 |
}
|
| 23444 |
amit.gupta |
493 |
|
|
|
494 |
private Set<Integer> inventoryItemSchemesMapToSchemeIds(Map<InventoryItem, Set<Scheme>> inventoryItemSchemesMap) {
|
| 22859 |
ashik.ali |
495 |
Set<Integer> schemeIds = new HashSet<>();
|
| 23444 |
amit.gupta |
496 |
for (Map.Entry<InventoryItem, Set<Scheme>> inventoryItemSchemesEntry : inventoryItemSchemesMap.entrySet()) {
|
|
|
497 |
for (Scheme scheme : inventoryItemSchemesEntry.getValue()) {
|
| 22859 |
ashik.ali |
498 |
schemeIds.add(scheme.getId());
|
|
|
499 |
}
|
|
|
500 |
}
|
|
|
501 |
return schemeIds;
|
|
|
502 |
}
|
| 23444 |
amit.gupta |
503 |
|
|
|
504 |
private Set<Integer> fofoLineItemSchemesMapToSchemeIds(Map<FofoOrderItem, Set<Scheme>> fofoLineItemSchemesMap) {
|
| 22859 |
ashik.ali |
505 |
Set<Integer> schemeIds = new HashSet<>();
|
| 23444 |
amit.gupta |
506 |
for (Map.Entry<FofoOrderItem, Set<Scheme>> inventoryItemSchemesEntry : fofoLineItemSchemesMap.entrySet()) {
|
|
|
507 |
for (Scheme scheme : inventoryItemSchemesEntry.getValue()) {
|
| 22859 |
ashik.ali |
508 |
schemeIds.add(scheme.getId());
|
|
|
509 |
}
|
|
|
510 |
}
|
|
|
511 |
return schemeIds;
|
|
|
512 |
}
|
| 23444 |
amit.gupta |
513 |
|
|
|
514 |
private Set<Integer> inventoryItemsToItemIds(List<InventoryItem> inventoryItems) {
|
| 22859 |
ashik.ali |
515 |
Set<Integer> itemIds = new HashSet<>();
|
| 23444 |
amit.gupta |
516 |
for (InventoryItem inventoryItem : inventoryItems) {
|
| 22859 |
ashik.ali |
517 |
itemIds.add(inventoryItem.getItemId());
|
|
|
518 |
}
|
|
|
519 |
return itemIds;
|
|
|
520 |
}
|
| 23444 |
amit.gupta |
521 |
|
|
|
522 |
private Set<Integer> fofoOrderItemsToItemIds(List<FofoOrderItem> fofoOrderItems) {
|
| 22859 |
ashik.ali |
523 |
Set<Integer> itemIds = new HashSet<>();
|
| 23444 |
amit.gupta |
524 |
for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
|
| 22859 |
ashik.ali |
525 |
itemIds.add(fofoOrderItem.getItemId());
|
|
|
526 |
}
|
|
|
527 |
return itemIds;
|
|
|
528 |
}
|
| 23444 |
amit.gupta |
529 |
|
|
|
530 |
private Map<Integer, Set<Scheme>> toItemIdSchemesMap(List<SchemeItem> schemeItems, List<Scheme> schemes) {
|
| 23019 |
ashik.ali |
531 |
Map<Integer, Scheme> schemeIdSchemesMap = this.toSchemeIdSchemeMap(schemes);
|
| 22859 |
ashik.ali |
532 |
Map<Integer, Set<Scheme>> itemIdSchemesMap = new HashMap<>();
|
| 23444 |
amit.gupta |
533 |
for (SchemeItem schemeItem : schemeItems) {
|
|
|
534 |
if (!itemIdSchemesMap.containsKey(schemeItem.getItemId())) {
|
| 22859 |
ashik.ali |
535 |
Set<Scheme> schemesSet = new HashSet<>();
|
|
|
536 |
schemesSet.add(schemeIdSchemesMap.get(schemeItem.getSchemeId()));
|
|
|
537 |
itemIdSchemesMap.put(schemeItem.getItemId(), schemesSet);
|
| 23444 |
amit.gupta |
538 |
} else {
|
| 22859 |
ashik.ali |
539 |
itemIdSchemesMap.get(schemeItem.getItemId()).add(schemeIdSchemesMap.get(schemeItem.getSchemeId()));
|
|
|
540 |
}
|
|
|
541 |
}
|
|
|
542 |
return itemIdSchemesMap;
|
|
|
543 |
}
|
| 22653 |
ashik.ali |
544 |
|
| 23444 |
amit.gupta |
545 |
private Map<InventoryItem, Set<Scheme>> toInventoryItemSchemesMap(List<Scheme> schemes,
|
|
|
546 |
List<InventoryItem> inventoryItems) {
|
| 22859 |
ashik.ali |
547 |
Set<Integer> schemeIds = new HashSet<>();
|
| 23444 |
amit.gupta |
548 |
for (Scheme scheme : schemes) {
|
| 22859 |
ashik.ali |
549 |
schemeIds.add(scheme.getId());
|
|
|
550 |
}
|
|
|
551 |
Set<Integer> itemIds = this.inventoryItemsToItemIds(inventoryItems);
|
|
|
552 |
List<SchemeItem> schemeItems = schemeItemRepository.selectBySchemeIdsAndItemIds(schemeIds, itemIds);
|
| 23444 |
amit.gupta |
553 |
|
| 22859 |
ashik.ali |
554 |
Map<Integer, Set<Scheme>> itemIdSchemesMap = this.toItemIdSchemesMap(schemeItems, schemes);
|
|
|
555 |
Map<InventoryItem, Set<Scheme>> inventoryItemSchemsMap = new HashMap<>();
|
| 23444 |
amit.gupta |
556 |
for (InventoryItem inventoryItem : inventoryItems) {
|
|
|
557 |
if (itemIdSchemesMap.containsKey(inventoryItem.getItemId())) {
|
| 22859 |
ashik.ali |
558 |
inventoryItemSchemsMap.put(inventoryItem, itemIdSchemesMap.get(inventoryItem.getItemId()));
|
|
|
559 |
}
|
|
|
560 |
}
|
|
|
561 |
return inventoryItemSchemsMap;
|
|
|
562 |
}
|
| 23444 |
amit.gupta |
563 |
|
|
|
564 |
private Map<FofoOrderItem, Set<Scheme>> toFofoOrderItemSchemesMap(List<Scheme> schemes,
|
|
|
565 |
List<FofoOrderItem> fofoOrderItems) {
|
| 22859 |
ashik.ali |
566 |
Set<Integer> schemeIds = new HashSet<>();
|
| 23444 |
amit.gupta |
567 |
for (Scheme scheme : schemes) {
|
| 22859 |
ashik.ali |
568 |
schemeIds.add(scheme.getId());
|
|
|
569 |
}
|
|
|
570 |
Set<Integer> itemIds = this.fofoOrderItemsToItemIds(fofoOrderItems);
|
|
|
571 |
List<SchemeItem> schemeItems = schemeItemRepository.selectBySchemeIdsAndItemIds(schemeIds, itemIds);
|
| 23444 |
amit.gupta |
572 |
|
| 22859 |
ashik.ali |
573 |
Map<FofoOrderItem, Set<Scheme>> fofoOrderItemSchemsMap = new HashMap<>();
|
| 23444 |
amit.gupta |
574 |
|
|
|
575 |
if (!schemeItems.isEmpty()) {
|
| 22859 |
ashik.ali |
576 |
Map<Integer, Set<Scheme>> itemIdSchemesMap = this.toItemIdSchemesMap(schemeItems, schemes);
|
| 23444 |
amit.gupta |
577 |
for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
|
|
|
578 |
if (itemIdSchemesMap.containsKey(fofoOrderItem.getItemId())) {
|
| 22859 |
ashik.ali |
579 |
fofoOrderItemSchemsMap.put(fofoOrderItem, itemIdSchemesMap.get(fofoOrderItem.getItemId()));
|
|
|
580 |
}
|
| 22653 |
ashik.ali |
581 |
}
|
|
|
582 |
}
|
| 22859 |
ashik.ali |
583 |
return fofoOrderItemSchemsMap;
|
|
|
584 |
}
|
| 23444 |
amit.gupta |
585 |
|
| 22859 |
ashik.ali |
586 |
@Override
|
| 23365 |
ashik.ali |
587 |
public void processSchemeIn(int purchaseId, int retailerId) throws ProfitMandiBusinessException {
|
| 23369 |
ashik.ali |
588 |
LOGGER.info("Trying to process SchemeIn with purchaseId [{}] and retailerId [{}]", purchaseId, retailerId);
|
| 23344 |
ashik.ali |
589 |
Purchase purchase = purchaseRepository.selectByIdAndFofoId(purchaseId, retailerId);
|
| 23369 |
ashik.ali |
590 |
LOGGER.info("purchase is completed = {}", (purchase.getCompleteTimestamp() != null));
|
| 23444 |
amit.gupta |
591 |
if (purchase.getCompleteTimestamp() != null) {
|
|
|
592 |
List<Order> orders = orderRepository.selectByAirwayBillOrInvoiceNumber(purchase.getPurchaseReference(),
|
|
|
593 |
retailerId);
|
| 23378 |
ashik.ali |
594 |
LocalDateTime billingTimestamp = purchase.getCreateTimestamp();
|
| 23444 |
amit.gupta |
595 |
if (!orders.isEmpty()) {
|
| 23365 |
ashik.ali |
596 |
billingTimestamp = orders.get(0).getBillingTimestamp();
|
|
|
597 |
}
|
|
|
598 |
List<Scheme> schemes = schemeRepository.selectActiveAll(SchemeType.IN, billingTimestamp);
|
|
|
599 |
float totalCashback = 0;
|
| 23444 |
amit.gupta |
600 |
if (schemes.isEmpty()) {
|
| 23365 |
ashik.ali |
601 |
return;
|
|
|
602 |
}
|
|
|
603 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchaseId);
|
| 23444 |
amit.gupta |
604 |
|
|
|
605 |
Map<InventoryItem, Set<Scheme>> inventoryItemSchemesMap = this.toInventoryItemSchemesMap(schemes,
|
|
|
606 |
inventoryItems);
|
|
|
607 |
|
|
|
608 |
if (inventoryItemSchemesMap.isEmpty()) {
|
| 23365 |
ashik.ali |
609 |
return;
|
|
|
610 |
}
|
|
|
611 |
Map<InventoryItem, Set<Scheme>> notAllInventoryItemSchemesMap = new HashMap<>();
|
|
|
612 |
Map<InventoryItem, Set<Scheme>> allInventoryItemSchemesMap = new HashMap<>();
|
|
|
613 |
Set<Integer> itemIds = new HashSet<>();
|
| 23444 |
amit.gupta |
614 |
|
|
|
615 |
for (Map.Entry<InventoryItem, Set<Scheme>> inventoryItemSchemesEntry : inventoryItemSchemesMap.entrySet()) {
|
| 23365 |
ashik.ali |
616 |
Set<Scheme> notAllSchemes = new HashSet<>();
|
|
|
617 |
Set<Scheme> allSchemes = new HashSet<>();
|
| 23444 |
amit.gupta |
618 |
for (Scheme scheme : inventoryItemSchemesEntry.getValue()) {
|
|
|
619 |
if (!scheme.isRetailerAll()) {
|
| 23365 |
ashik.ali |
620 |
notAllSchemes.add(scheme);
|
| 23444 |
amit.gupta |
621 |
} else {
|
| 23365 |
ashik.ali |
622 |
allSchemes.add(scheme);
|
|
|
623 |
}
|
| 22859 |
ashik.ali |
624 |
}
|
| 23365 |
ashik.ali |
625 |
notAllInventoryItemSchemesMap.put(inventoryItemSchemesEntry.getKey(), notAllSchemes);
|
|
|
626 |
allInventoryItemSchemesMap.put(inventoryItemSchemesEntry.getKey(), allSchemes);
|
|
|
627 |
itemIds.add(inventoryItemSchemesEntry.getKey().getItemId());
|
| 22859 |
ashik.ali |
628 |
}
|
| 23444 |
amit.gupta |
629 |
|
|
|
630 |
int itemsCount = 0;
|
|
|
631 |
for (Map.Entry<InventoryItem, Set<Scheme>> allInventoryItemSchemesEntry : allInventoryItemSchemesMap
|
|
|
632 |
.entrySet()) {
|
|
|
633 |
float inventoryItemCashback = 0;
|
|
|
634 |
for (Scheme scheme : allInventoryItemSchemesEntry.getValue()) {
|
| 23365 |
ashik.ali |
635 |
InventoryItem inventoryItem = allInventoryItemSchemesEntry.getKey();
|
|
|
636 |
float cashback = this.createSchemeInOut(scheme, inventoryItem);
|
| 23444 |
amit.gupta |
637 |
inventoryItemCashback += cashback;
|
| 23339 |
ashik.ali |
638 |
}
|
| 23444 |
amit.gupta |
639 |
if (inventoryItemCashback > 0) {
|
|
|
640 |
totalCashback += inventoryItemCashback;
|
|
|
641 |
itemsCount++;
|
|
|
642 |
}
|
| 22859 |
ashik.ali |
643 |
}
|
| 23444 |
amit.gupta |
644 |
|
| 23365 |
ashik.ali |
645 |
Set<Integer> schemeIds = this.inventoryItemSchemesMapToSchemeIds(notAllInventoryItemSchemesMap);
|
| 23444 |
amit.gupta |
646 |
if (!schemeIds.isEmpty()) {
|
| 23365 |
ashik.ali |
647 |
List<Integer> foundSchemeIds = retailerSchemeRepository.selectSchemeIds(schemeIds, retailerId);
|
| 23444 |
amit.gupta |
648 |
for (Map.Entry<InventoryItem, Set<Scheme>> notAllInventoryItemSchemesEntry : notAllInventoryItemSchemesMap
|
|
|
649 |
.entrySet()) {
|
|
|
650 |
float inventoryItemCashback = 0;
|
|
|
651 |
for (Scheme scheme : notAllInventoryItemSchemesEntry.getValue()) {
|
|
|
652 |
if (foundSchemeIds.contains(scheme.getId())) {
|
| 23365 |
ashik.ali |
653 |
InventoryItem inventoryItem = notAllInventoryItemSchemesEntry.getKey();
|
|
|
654 |
float cashback = this.createSchemeInOut(scheme, inventoryItem);
|
| 23444 |
amit.gupta |
655 |
inventoryItemCashback += cashback;
|
| 23339 |
ashik.ali |
656 |
}
|
| 22653 |
ashik.ali |
657 |
}
|
| 23444 |
amit.gupta |
658 |
if (inventoryItemCashback > 0) {
|
|
|
659 |
totalCashback += inventoryItemCashback;
|
|
|
660 |
itemsCount++;
|
|
|
661 |
}
|
| 22653 |
ashik.ali |
662 |
}
|
|
|
663 |
}
|
| 23511 |
amit.gupta |
664 |
LOGGER.info("Items count for purchase id {} is {}", purchaseId, itemsCount);
|
| 23796 |
amit.gupta |
665 |
if (itemsCount > 0) {
|
| 23508 |
amit.gupta |
666 |
walletService.addAmountToWallet(retailerId, purchaseId, WalletReferenceType.SCHEME_IN,
|
| 23796 |
amit.gupta |
667 |
"Added for SCHEME IN against invoice " + purchase.getPurchaseReference() + " (total "
|
|
|
668 |
+ itemsCount + " pcs)",
|
|
|
669 |
totalCashback);
|
|
|
670 |
LOGGER.info("Added Rs.{} for SCHEME IN against invoice {} total pcs({}) {}", totalCashback,
|
|
|
671 |
purchase.getPurchaseReference(), itemsCount);
|
| 23508 |
amit.gupta |
672 |
purchase.setCashback(purchase.getCashback() + totalCashback);
|
|
|
673 |
purchaseRepository.persist(purchase);
|
|
|
674 |
}
|
| 22653 |
ashik.ali |
675 |
}
|
|
|
676 |
}
|
| 23444 |
amit.gupta |
677 |
|
|
|
678 |
private float createSchemeInOut(Scheme scheme, InventoryItem inventoryItem) {
|
| 23443 |
amit.gupta |
679 |
SchemeInOut schemeInOut = schemeInOutRepository.selectByScheme(scheme.getId(), inventoryItem.getId());
|
|
|
680 |
float amount = 0;
|
| 23444 |
amit.gupta |
681 |
if (schemeInOut == null) {
|
| 23443 |
amit.gupta |
682 |
schemeInOut = new SchemeInOut();
|
|
|
683 |
amount = this.getAmount(inventoryItem, scheme);
|
|
|
684 |
schemeInOut.setSchemeId(scheme.getId());
|
|
|
685 |
schemeInOut.setInventoryItemId(inventoryItem.getId());
|
|
|
686 |
schemeInOut.setAmount(amount);
|
|
|
687 |
schemeInOutRepository.persist(schemeInOut);
|
|
|
688 |
}
|
| 22859 |
ashik.ali |
689 |
return amount;
|
|
|
690 |
}
|
| 23444 |
amit.gupta |
691 |
|
|
|
692 |
private float getAmount(InventoryItem inventoryItem, Scheme scheme) {
|
| 22653 |
ashik.ali |
693 |
float amount = 0;
|
| 22859 |
ashik.ali |
694 |
float totalTaxRate = inventoryItem.getIgstRate() + inventoryItem.getSgstRate() + inventoryItem.getCgstRate();
|
|
|
695 |
float taxableSellingPrice = inventoryItem.getUnitPrice() / (1 + totalTaxRate / 100);
|
| 23444 |
amit.gupta |
696 |
|
| 23527 |
ashik.ali |
697 |
if (scheme.getAmountType() == AmountType.PERCENTAGE) {
|
| 22859 |
ashik.ali |
698 |
amount = taxableSellingPrice * scheme.getAmount() / 100;
|
| 23444 |
amit.gupta |
699 |
} else {
|
| 22653 |
ashik.ali |
700 |
amount = scheme.getAmount();
|
|
|
701 |
}
|
| 22859 |
ashik.ali |
702 |
return amount;
|
| 22653 |
ashik.ali |
703 |
}
|
| 23444 |
amit.gupta |
704 |
|
|
|
705 |
private Map<Integer, InventoryItem> toInventoryItemIdInventoryItemMap(List<InventoryItem> inventoryItems) {
|
| 22859 |
ashik.ali |
706 |
Map<Integer, InventoryItem> itemIdInventoryItemMap = new HashMap<>();
|
| 23444 |
amit.gupta |
707 |
for (InventoryItem inventoryItem : inventoryItems) {
|
| 22859 |
ashik.ali |
708 |
itemIdInventoryItemMap.put(inventoryItem.getId(), inventoryItem);
|
| 22653 |
ashik.ali |
709 |
}
|
| 22859 |
ashik.ali |
710 |
return itemIdInventoryItemMap;
|
| 22653 |
ashik.ali |
711 |
}
|
| 23444 |
amit.gupta |
712 |
|
|
|
713 |
private Set<Integer> toInventoryItemIds(Set<FofoOrderItem> fofoOrderItems) {
|
| 22859 |
ashik.ali |
714 |
Set<Integer> inventoryItemIds = new HashSet<>();
|
| 23444 |
amit.gupta |
715 |
// Map<Integer, Set<FofoLineItem>> fofoOrderItemIdFofoLineItemsMap =
|
|
|
716 |
// this.toFofoOrderItemIdFofoLineItems(fofoOrderItems);
|
|
|
717 |
for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
|
|
|
718 |
for (FofoLineItem fofoLineItem : fofoOrderItem.getFofoLineItems()) {
|
| 22859 |
ashik.ali |
719 |
inventoryItemIds.add(fofoLineItem.getInventoryItemId());
|
|
|
720 |
}
|
|
|
721 |
}
|
|
|
722 |
return inventoryItemIds;
|
|
|
723 |
}
|
| 22653 |
ashik.ali |
724 |
|
|
|
725 |
@Override
|
| 23365 |
ashik.ali |
726 |
public void processSchemeOut(int fofoOrderId, int retailerId) throws ProfitMandiBusinessException {
|
|
|
727 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(retailerId, fofoOrderId);
|
| 22859 |
ashik.ali |
728 |
List<Scheme> schemes = schemeRepository.selectActiveAll(SchemeType.OUT, LocalDateTime.now());
|
|
|
729 |
LOGGER.info("Active Schemes {}", schemes);
|
|
|
730 |
float totalCashback = 0;
|
| 23512 |
amit.gupta |
731 |
int count = 0;
|
| 23444 |
amit.gupta |
732 |
if (schemes.isEmpty()) {
|
| 23365 |
ashik.ali |
733 |
return;
|
| 22859 |
ashik.ali |
734 |
}
|
| 23444 |
amit.gupta |
735 |
|
| 22925 |
ashik.ali |
736 |
List<FofoOrderItem> fofoOrderItems = orderService.getByOrderId(fofoOrderId);
|
| 23444 |
amit.gupta |
737 |
// LOGGER.info("fofoOrderItems {}", fofoOrderItems);
|
|
|
738 |
|
|
|
739 |
Map<FofoOrderItem, Set<Scheme>> fofoOrderItemSchemesMap = this.toFofoOrderItemSchemesMap(schemes,
|
|
|
740 |
fofoOrderItems);
|
|
|
741 |
|
| 22859 |
ashik.ali |
742 |
LOGGER.info("fofoOrderItemSchemesMap {}", fofoOrderItemSchemesMap);
|
| 23444 |
amit.gupta |
743 |
|
|
|
744 |
if (fofoOrderItemSchemesMap.isEmpty()) {
|
| 23365 |
ashik.ali |
745 |
return;
|
| 22859 |
ashik.ali |
746 |
}
|
| 23444 |
amit.gupta |
747 |
|
| 22859 |
ashik.ali |
748 |
Set<Integer> inventoryItemIds = this.toInventoryItemIds(fofoOrderItemSchemesMap.keySet());
|
| 23444 |
amit.gupta |
749 |
|
| 22859 |
ashik.ali |
750 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByIds(inventoryItemIds);
|
| 23444 |
amit.gupta |
751 |
|
|
|
752 |
Map<Integer, InventoryItem> inventoryItemIdInventoryItemMap = this
|
|
|
753 |
.toInventoryItemIdInventoryItemMap(inventoryItems);
|
|
|
754 |
|
| 22859 |
ashik.ali |
755 |
Map<FofoOrderItem, Set<Scheme>> notAllFofoOrderItemSchemesMap = new HashMap<>();
|
|
|
756 |
Map<FofoOrderItem, Set<Scheme>> allFofoOrderItemSchemesMap = new HashMap<>();
|
| 23444 |
amit.gupta |
757 |
|
|
|
758 |
for (Map.Entry<FofoOrderItem, Set<Scheme>> fofoOrderItemSchemesEntry : fofoOrderItemSchemesMap.entrySet()) {
|
| 22859 |
ashik.ali |
759 |
Set<Scheme> notAllSchemes = new HashSet<>();
|
|
|
760 |
Set<Scheme> allSchemes = new HashSet<>();
|
| 23444 |
amit.gupta |
761 |
for (Scheme scheme : fofoOrderItemSchemesEntry.getValue()) {
|
|
|
762 |
if (!scheme.isRetailerAll()) {
|
| 22859 |
ashik.ali |
763 |
notAllSchemes.add(scheme);
|
| 23444 |
amit.gupta |
764 |
} else {
|
| 22859 |
ashik.ali |
765 |
allSchemes.add(scheme);
|
|
|
766 |
}
|
| 22653 |
ashik.ali |
767 |
}
|
| 22859 |
ashik.ali |
768 |
notAllFofoOrderItemSchemesMap.put(fofoOrderItemSchemesEntry.getKey(), notAllSchemes);
|
|
|
769 |
allFofoOrderItemSchemesMap.put(fofoOrderItemSchemesEntry.getKey(), allSchemes);
|
| 22653 |
ashik.ali |
770 |
}
|
| 23444 |
amit.gupta |
771 |
|
|
|
772 |
for (Map.Entry<FofoOrderItem, Set<Scheme>> allFofoOrderItemSchemesEntry : allFofoOrderItemSchemesMap
|
|
|
773 |
.entrySet()) {
|
|
|
774 |
for (FofoLineItem fofoLineItem : allFofoOrderItemSchemesEntry.getKey().getFofoLineItems()) {
|
| 23796 |
amit.gupta |
775 |
float itemCashback = 0;
|
| 23444 |
amit.gupta |
776 |
for (Scheme scheme : allFofoOrderItemSchemesEntry.getValue()) {
|
| 23796 |
amit.gupta |
777 |
itemCashback += this.createSchemeInOut(scheme,
|
| 23444 |
amit.gupta |
778 |
inventoryItemIdInventoryItemMap.get(fofoLineItem.getInventoryItemId()));
|
| 22859 |
ashik.ali |
779 |
}
|
| 23796 |
amit.gupta |
780 |
if (itemCashback > 0) {
|
|
|
781 |
totalCashback += itemCashback;
|
|
|
782 |
count += 1;
|
|
|
783 |
}
|
| 22859 |
ashik.ali |
784 |
}
|
| 22653 |
ashik.ali |
785 |
}
|
| 23444 |
amit.gupta |
786 |
|
| 22859 |
ashik.ali |
787 |
Set<Integer> schemeIds = this.fofoLineItemSchemesMapToSchemeIds(notAllFofoOrderItemSchemesMap);
|
| 23444 |
amit.gupta |
788 |
|
|
|
789 |
if (!schemeIds.isEmpty()) {
|
| 22859 |
ashik.ali |
790 |
List<Integer> foundSchemeIds = retailerSchemeRepository.selectSchemeIds(schemeIds, retailerId);
|
| 23444 |
amit.gupta |
791 |
|
|
|
792 |
for (Map.Entry<FofoOrderItem, Set<Scheme>> notAllFofoOrderItemSchemesEntry : notAllFofoOrderItemSchemesMap
|
|
|
793 |
.entrySet()) {
|
|
|
794 |
for (FofoLineItem fofoLineItem : notAllFofoOrderItemSchemesEntry.getKey().getFofoLineItems()) {
|
| 23796 |
amit.gupta |
795 |
float itemCashback = 0;
|
| 23444 |
amit.gupta |
796 |
for (Scheme scheme : notAllFofoOrderItemSchemesEntry.getValue()) {
|
|
|
797 |
if (foundSchemeIds.contains(scheme.getId())) {
|
| 23796 |
amit.gupta |
798 |
itemCashback += this.createSchemeInOut(scheme,
|
| 23444 |
amit.gupta |
799 |
inventoryItemIdInventoryItemMap.get(fofoLineItem.getInventoryItemId()));
|
| 22653 |
ashik.ali |
800 |
}
|
|
|
801 |
}
|
| 23796 |
amit.gupta |
802 |
if (itemCashback > 0) {
|
|
|
803 |
totalCashback += itemCashback;
|
|
|
804 |
count += 1;
|
|
|
805 |
}
|
| 22653 |
ashik.ali |
806 |
}
|
| 23444 |
amit.gupta |
807 |
}
|
| 22653 |
ashik.ali |
808 |
}
|
| 23444 |
amit.gupta |
809 |
if (totalCashback > 0) {
|
|
|
810 |
walletService.addAmountToWallet(retailerId, fofoOrderId, WalletReferenceType.SCHEME_OUT,
|
| 23796 |
amit.gupta |
811 |
"Sales margin for invoice number " + fofoOrder.getInvoiceNumber() + ". Total " + count + " pc(s)",
|
|
|
812 |
totalCashback);
|
| 23365 |
ashik.ali |
813 |
fofoOrder.setCashback(totalCashback);
|
|
|
814 |
fofoOrderRepository.persist(fofoOrder);
|
| 22859 |
ashik.ali |
815 |
}
|
| 22653 |
ashik.ali |
816 |
}
|
| 23444 |
amit.gupta |
817 |
|
| 23508 |
amit.gupta |
818 |
@Override
|
| 23796 |
amit.gupta |
819 |
public void rollbackSchemes(List<Integer> inventoryItemIds, int rollbackReference, String rollbackReason)
|
|
|
820 |
throws Exception {
|
| 23638 |
amit.gupta |
821 |
Set<Integer> inventoryItemIdSet = new HashSet<>(inventoryItemIds);
|
| 23508 |
amit.gupta |
822 |
float amountToRollback = 0;
|
|
|
823 |
List<SchemeInOut> schemes = schemeInOutRepository.selectByInventoryItemIds(inventoryItemIdSet);
|
| 23796 |
amit.gupta |
824 |
for (SchemeInOut schemeInOut : schemes) {
|
| 23527 |
ashik.ali |
825 |
schemeInOut.setRolledBackTimestamp(LocalDateTime.now());
|
| 23508 |
amit.gupta |
826 |
schemeInOutRepository.persist(schemeInOut);
|
|
|
827 |
amountToRollback += schemeInOut.getAmount();
|
|
|
828 |
}
|
| 23796 |
amit.gupta |
829 |
if (schemes.size() > 0) {
|
| 23638 |
amit.gupta |
830 |
int inventoryItemId = inventoryItemIds.get(0);
|
|
|
831 |
Integer fofoId = inventoryItemRepository.selectById(inventoryItemId).getFofoId();
|
| 23796 |
amit.gupta |
832 |
walletService.rollbackAmountFromWallet(fofoId, amountToRollback, rollbackReference,
|
|
|
833 |
WalletReferenceType.SCHEME_IN, rollbackReason);
|
| 23638 |
amit.gupta |
834 |
}
|
| 23508 |
amit.gupta |
835 |
}
|
| 23796 |
amit.gupta |
836 |
|
| 23781 |
ashik.ali |
837 |
@Override
|
| 23796 |
amit.gupta |
838 |
public Map<String, Object> getSchemes(Set<Integer> roleIds, int offset, int limit)
|
|
|
839 |
throws ProfitMandiBusinessException {
|
| 23781 |
ashik.ali |
840 |
Map<String, Object> map = new HashMap<>();
|
|
|
841 |
List<Scheme> schemes = null;
|
|
|
842 |
long size = 0;
|
|
|
843 |
Role role = roleRepository.selectByName(RoleType.FOFO_ADMIN.toString());
|
| 23796 |
amit.gupta |
844 |
if (roleIds.contains(role.getId())) {
|
| 23781 |
ashik.ali |
845 |
schemes = schemeRepository.selectAll(offset, limit);
|
|
|
846 |
size = schemeRepository.selectAllCount();
|
| 23796 |
amit.gupta |
847 |
} else {
|
| 23781 |
ashik.ali |
848 |
schemes = schemeRepository.selectActiveAll(offset, limit);
|
|
|
849 |
size = schemeRepository.selectAllActiveCount();
|
|
|
850 |
}
|
|
|
851 |
map.put("schemes", schemes);
|
|
|
852 |
map.put("start", offset + 1);
|
|
|
853 |
map.put("size", size);
|
| 23796 |
amit.gupta |
854 |
if (schemes.size() < limit) {
|
| 23781 |
ashik.ali |
855 |
map.put("end", offset + schemes.size());
|
| 23796 |
amit.gupta |
856 |
} else {
|
| 23781 |
ashik.ali |
857 |
map.put("end", offset + limit);
|
|
|
858 |
}
|
|
|
859 |
return map;
|
|
|
860 |
}
|
| 23796 |
amit.gupta |
861 |
|
| 23781 |
ashik.ali |
862 |
@Override
|
| 23796 |
amit.gupta |
863 |
public List<Scheme> getPaginatedSchemes(Set<Integer> roleIds, int offset, int limit)
|
|
|
864 |
throws ProfitMandiBusinessException {
|
| 23781 |
ashik.ali |
865 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
|
|
866 |
List<Scheme> schemes = null;
|
|
|
867 |
Role role = roleRepository.selectByName(RoleType.FOFO_ADMIN.toString());
|
| 23796 |
amit.gupta |
868 |
if (roleIds.contains(role.getId())) {
|
| 23781 |
ashik.ali |
869 |
schemes = schemeRepository.selectAll(offset, limit);
|
| 23796 |
amit.gupta |
870 |
} else {
|
| 23781 |
ashik.ali |
871 |
schemes = schemeRepository.selectActiveAll(offset, limit);
|
|
|
872 |
}
|
|
|
873 |
return schemes;
|
|
|
874 |
}
|
| 23508 |
amit.gupta |
875 |
|
| 22653 |
ashik.ali |
876 |
}
|