| Line 60... |
Line 60... |
| 60 |
@Autowired
|
60 |
@Autowired
|
| 61 |
private TagListingRepository tagListingRepository;
|
61 |
private TagListingRepository tagListingRepository;
|
| 62 |
|
62 |
|
| 63 |
@Autowired
|
63 |
@Autowired
|
| 64 |
private OfferTargetSlabRepository offerTargetSlabRepository;
|
64 |
private OfferTargetSlabRepository offerTargetSlabRepository;
|
| 65 |
|
65 |
|
| 66 |
@Autowired
|
66 |
@Autowired
|
| 67 |
CacheManager thirtyMinsTimeOutCacheManager;
|
67 |
CacheManager thirtyMinsTimeOutCacheManager;
|
| 68 |
|
68 |
|
| 69 |
|
69 |
|
| 70 |
private static final Logger LOGGER = LogManager.getLogger(OfferServiceImpl.class);
|
70 |
private static final Logger LOGGER = LogManager.getLogger(OfferServiceImpl.class);
|
| Line 232... |
Line 232... |
| 232 |
Collections.sort(targetSlabs);
|
232 |
Collections.sort(targetSlabs);
|
| 233 |
for (com.spice.profitmandi.dao.model.TargetSlab targetSlab : targetSlabs) {
|
233 |
for (com.spice.profitmandi.dao.model.TargetSlab targetSlab : targetSlabs) {
|
| 234 |
if (targetSlab.validate()) {
|
234 |
if (targetSlab.validate()) {
|
| 235 |
List<ItemCriteriaPayout> itemCriteriaPayouts = targetSlab.getItemCriteriaPayouts();
|
235 |
List<ItemCriteriaPayout> itemCriteriaPayouts = targetSlab.getItemCriteriaPayouts();
|
| 236 |
for (ItemCriteriaPayout itemCriteriaPayout : itemCriteriaPayouts) {
|
236 |
for (ItemCriteriaPayout itemCriteriaPayout : itemCriteriaPayouts) {
|
| - |
|
237 |
ItemCriteria itemCriteria = itemCriteriaRepository.selectById(itemCriteriaPayout.getItemCriteria().getId());
|
| - |
|
238 |
if (itemCriteriaPayout.getItemCriteria().getId() > 0) {
|
| - |
|
239 |
itemCriteriaPayout.getItemCriteria().setId(0);
|
| - |
|
240 |
} else {
|
| - |
|
241 |
|
| 237 |
String itemCriteriaJson = gson.toJson(itemCriteriaPayout.getItemCriteria());
|
242 |
String itemCriteriaJson = gson.toJson(itemCriteriaPayout.getItemCriteria());
|
| 238 |
ItemCriteria itemCriteria = itemCriteriaRepository.selectByCriteria(itemCriteriaJson);
|
243 |
itemCriteria = itemCriteriaRepository.selectByCriteria(itemCriteriaJson);
|
| 239 |
// ItemCriteria Only once
|
244 |
// ItemCriteria Only once
|
| 240 |
if (itemCriteria == null) {
|
245 |
if (itemCriteria == null) {
|
| 241 |
itemCriteria = new ItemCriteria();
|
246 |
itemCriteria = new ItemCriteria();
|
| 242 |
itemCriteria.setCriteria(gson.toJson(itemCriteriaPayout.getItemCriteria()));
|
247 |
itemCriteria.setCriteria(gson.toJson(itemCriteriaPayout.getItemCriteria()));
|
| 243 |
itemCriteriaRepository.persist(itemCriteria);
|
248 |
itemCriteriaRepository.persist(itemCriteria);
|
| - |
|
249 |
}
|
| 244 |
}
|
250 |
}
|
| 245 |
for (PayoutSlab payoutSlab : itemCriteriaPayout.getPayoutSlabs()) {
|
251 |
for (PayoutSlab payoutSlab : itemCriteriaPayout.getPayoutSlabs()) {
|
| 246 |
TargetSlab targetSlab1 = new TargetSlab();
|
252 |
TargetSlab targetSlab1 = new TargetSlab();
|
| 247 |
targetSlab1.setOfferId(createOfferRequest.getId());
|
253 |
targetSlab1.setOfferId(createOfferRequest.getId());
|
| 248 |
targetSlab1.setOnwardsTarget(targetSlab.getOnwardsAmount());
|
254 |
targetSlab1.setOnwardsTarget(targetSlab.getOnwardsAmount());
|
| Line 314... |
Line 320... |
| 314 |
|
320 |
|
| 315 |
createOfferRequest.getPartnerCriteria().setFofoIds(filterFofoIds);
|
321 |
createOfferRequest.getPartnerCriteria().setFofoIds(filterFofoIds);
|
| 316 |
int counter = 0;
|
322 |
int counter = 0;
|
| 317 |
List<ItemCriteriaPayout> itemCriteriaPayouts = createOfferRequest.getTargetSlabs().get(0)
|
323 |
List<ItemCriteriaPayout> itemCriteriaPayouts = createOfferRequest.getTargetSlabs().get(0)
|
| 318 |
.getItemCriteriaPayouts();
|
324 |
.getItemCriteriaPayouts();
|
| 319 |
List<PayoutSlab> payoutSlabs = itemCriteriaPayouts.stream().flatMap(x->x.getPayoutSlabs().stream()).collect(Collectors.toList());
|
325 |
List<PayoutSlab> payoutSlabs = itemCriteriaPayouts.stream().flatMap(x -> x.getPayoutSlabs().stream()).collect(Collectors.toList());
|
| 320 |
for (PayoutSlab payoutSlab : payoutSlabs) {
|
326 |
for (PayoutSlab payoutSlab : payoutSlabs) {
|
| 321 |
payoutSlab.setOnwardsAmount(targets.get(counter));
|
327 |
payoutSlab.setOnwardsAmount(targets.get(counter));
|
| 322 |
counter++;
|
328 |
counter++;
|
| 323 |
}
|
329 |
}
|
| 324 |
this.addOfferService(createOfferRequest);
|
330 |
this.addOfferService(createOfferRequest);
|
| Line 357... |
Line 363... |
| 357 |
"FOFO ID", row.getCell(0).toString(), "TGLSTNG_VE_1010");
|
363 |
"FOFO ID", row.getCell(0).toString(), "TGLSTNG_VE_1010");
|
| 358 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
364 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
| 359 |
throw profitMandiBusinessException;
|
365 |
throw profitMandiBusinessException;
|
| 360 |
}
|
366 |
}
|
| 361 |
List<Integer> targets = new ArrayList<>();
|
367 |
List<Integer> targets = new ArrayList<>();
|
| 362 |
long targetsSize = existingOffer.getTargetSlabs().get(0).getItemCriteriaPayouts().stream().flatMap(x->x.getPayoutSlabs().stream()).collect(Collectors.counting());
|
368 |
long targetsSize = existingOffer.getTargetSlabs().get(0).getItemCriteriaPayouts().stream().flatMap(x -> x.getPayoutSlabs().stream()).collect(Collectors.counting());
|
| 363 |
for (int cellNumber = 1; cellNumber <= targetsSize; cellNumber++) {
|
369 |
for (int cellNumber = 1; cellNumber <= targetsSize; cellNumber++) {
|
| 364 |
if (row.getCell(cellNumber) != null
|
370 |
if (row.getCell(cellNumber) != null
|
| 365 |
&& row.getCell(cellNumber).getCellTypeEnum() == CellType.NUMERIC) {
|
371 |
&& row.getCell(cellNumber).getCellTypeEnum() == CellType.NUMERIC) {
|
| 366 |
targets.add((int) row.getCell(cellNumber).getNumericCellValue());
|
372 |
targets.add((int) row.getCell(cellNumber).getNumericCellValue());
|
| 367 |
} else {
|
373 |
} else {
|
| Line 406... |
Line 412... |
| 406 |
|
412 |
|
| 407 |
while (cellIterator.hasNext()) {
|
413 |
while (cellIterator.hasNext()) {
|
| 408 |
Cell cell = cellIterator.next();
|
414 |
Cell cell = cellIterator.next();
|
| 409 |
// Check the cell type and format accordingly
|
415 |
// Check the cell type and format accordingly
|
| 410 |
switch (cell.getCellType()) {
|
416 |
switch (cell.getCellType()) {
|
| 411 |
case Cell.CELL_TYPE_NUMERIC:
|
417 |
case Cell.CELL_TYPE_NUMERIC:
|
| 412 |
System.out.print(cell.getNumericCellValue() + "t");
|
418 |
System.out.print(cell.getNumericCellValue() + "t");
|
| 413 |
break;
|
419 |
break;
|
| 414 |
case Cell.CELL_TYPE_STRING:
|
420 |
case Cell.CELL_TYPE_STRING:
|
| 415 |
System.out.print(cell.getStringCellValue() + "t");
|
421 |
System.out.print(cell.getStringCellValue() + "t");
|
| 416 |
break;
|
422 |
break;
|
| 417 |
}
|
423 |
}
|
| 418 |
}
|
424 |
}
|
| 419 |
System.out.println("");
|
425 |
System.out.println("");
|
| 420 |
}
|
426 |
}
|
| 421 |
}
|
427 |
}
|
| Line 430... |
Line 436... |
| 430 |
@Cacheable(value = "slabPayoutMap", cacheManager = "oneDayCacheManager")
|
436 |
@Cacheable(value = "slabPayoutMap", cacheManager = "oneDayCacheManager")
|
| 431 |
public Map<Integer, Map<Integer, Long>> getSlabPayoutMap(CreateOfferRequest createOfferRequest) {
|
437 |
public Map<Integer, Map<Integer, Long>> getSlabPayoutMap(CreateOfferRequest createOfferRequest) {
|
| 432 |
Map<Integer, Map<Integer, Long>> catalogSlabPayoutMap = new HashMap<>();
|
438 |
Map<Integer, Map<Integer, Long>> catalogSlabPayoutMap = new HashMap<>();
|
| 433 |
com.spice.profitmandi.dao.model.TargetSlab targetSlab = createOfferRequest.getTargetSlabs().get(0);
|
439 |
com.spice.profitmandi.dao.model.TargetSlab targetSlab = createOfferRequest.getTargetSlabs().get(0);
|
| 434 |
List<ItemCriteriaPayout> payouts = targetSlab.getItemCriteriaPayouts();
|
440 |
List<ItemCriteriaPayout> payouts = targetSlab.getItemCriteriaPayouts();
|
| 435 |
|
441 |
|
| 436 |
for (ItemCriteriaPayout itemCriteriaPayout : payouts) {
|
442 |
for (ItemCriteriaPayout itemCriteriaPayout : payouts) {
|
| 437 |
com.spice.profitmandi.service.offers.ItemCriteria itemCriteria = itemCriteriaPayout.getItemCriteria();
|
443 |
com.spice.profitmandi.service.offers.ItemCriteria itemCriteria = itemCriteriaPayout.getItemCriteria();
|
| 438 |
List<Integer> catalogIds = itemRepository.getCatalogIds(itemCriteria);
|
444 |
List<Integer> catalogIds = itemRepository.getCatalogIds(itemCriteria);
|
| 439 |
for (PayoutSlab payoutSlab : Lists.reverse(itemCriteriaPayout.getPayoutSlabs())) {
|
445 |
for (PayoutSlab payoutSlab : Lists.reverse(itemCriteriaPayout.getPayoutSlabs())) {
|
| 440 |
if (itemCriteriaPayout.getAmountType().equals(AmountType.FIXED)) {
|
446 |
if (itemCriteriaPayout.getAmountType().equals(AmountType.FIXED)) {
|