| Line 427... |
Line 427... |
| 427 |
}
|
427 |
}
|
| 428 |
|
428 |
|
| 429 |
@Override
|
429 |
@Override
|
| 430 |
@Cacheable(value = "slabPayoutMap", cacheManager = "thirtyMinsTimeOutCacheManager")
|
430 |
@Cacheable(value = "slabPayoutMap", cacheManager = "thirtyMinsTimeOutCacheManager")
|
| 431 |
public Map<Integer, Map<Integer, Long>> getSlabPayoutMap(CreateOfferRequest createOfferRequest) {
|
431 |
public Map<Integer, Map<Integer, Long>> getSlabPayoutMap(CreateOfferRequest createOfferRequest) {
|
| 432 |
Map<Integer, Map<Integer, Long>> itemSlabPayoutMap = new HashMap<>();
|
432 |
Map<Integer, Map<Integer, Long>> catalogSlabPayoutMap = new HashMap<>();
|
| 433 |
com.spice.profitmandi.dao.model.TargetSlab targetSlab = createOfferRequest.getTargetSlabs().get(0);
|
433 |
com.spice.profitmandi.dao.model.TargetSlab targetSlab = createOfferRequest.getTargetSlabs().get(0);
|
| 434 |
List<ItemCriteriaPayout> payouts = targetSlab.getItemCriteriaPayouts();
|
434 |
List<ItemCriteriaPayout> payouts = targetSlab.getItemCriteriaPayouts();
|
| 435 |
|
435 |
|
| 436 |
for (ItemCriteriaPayout itemCriteriaPayout : payouts) {
|
436 |
for (ItemCriteriaPayout itemCriteriaPayout : payouts) {
|
| 437 |
com.spice.profitmandi.service.offers.ItemCriteria itemCriteria = itemCriteriaPayout.getItemCriteria();
|
437 |
com.spice.profitmandi.service.offers.ItemCriteria itemCriteria = itemCriteriaPayout.getItemCriteria();
|
| 438 |
List<Integer> itemIds = itemRepository.getItems(itemCriteria);
|
438 |
List<Integer> catalogIds = itemRepository.getCatalogIds(itemCriteria);
|
| 439 |
for (PayoutSlab payoutSlab : Lists.reverse(itemCriteriaPayout.getPayoutSlabs())) {
|
439 |
for (PayoutSlab payoutSlab : Lists.reverse(itemCriteriaPayout.getPayoutSlabs())) {
|
| 440 |
if (itemCriteriaPayout.getAmountType().equals(AmountType.FIXED)) {
|
440 |
if (itemCriteriaPayout.getAmountType().equals(AmountType.FIXED)) {
|
| 441 |
for (Integer itemId : itemIds) {
|
441 |
for (Integer catalogId : catalogIds) {
|
| 442 |
if (!itemSlabPayoutMap.containsKey(itemId)) {
|
442 |
if (!catalogSlabPayoutMap.containsKey(catalogId)) {
|
| 443 |
itemSlabPayoutMap.put(itemId, new LinkedHashMap<>());
|
443 |
catalogSlabPayoutMap.put(catalogId, new LinkedHashMap<>());
|
| 444 |
}
|
444 |
}
|
| 445 |
itemSlabPayoutMap.get(itemId).put(payoutSlab.getOnwardsAmount(),
|
445 |
catalogSlabPayoutMap.get(catalogId).put(payoutSlab.getOnwardsAmount(),
|
| 446 |
(long) payoutSlab.getPayoutAmount());
|
446 |
(long) payoutSlab.getPayoutAmount());
|
| 447 |
}
|
447 |
}
|
| 448 |
} else if (itemCriteriaPayout.getAmountType().equals(AmountType.SLAB_FIXED)) {
|
448 |
} else if (itemCriteriaPayout.getAmountType().equals(AmountType.SLAB_FIXED)) {
|
| 449 |
for (Integer itemId : itemIds) {
|
449 |
for (Integer catalogId : catalogIds) {
|
| 450 |
if (!itemSlabPayoutMap.containsKey(itemId)) {
|
450 |
if (!catalogSlabPayoutMap.containsKey(catalogId)) {
|
| 451 |
itemSlabPayoutMap.put(itemId, new LinkedHashMap<>());
|
451 |
catalogSlabPayoutMap.put(catalogId, new LinkedHashMap<>());
|
| 452 |
}
|
452 |
}
|
| 453 |
itemSlabPayoutMap.get(itemId).put(payoutSlab.getOnwardsAmount(),
|
453 |
catalogSlabPayoutMap.get(catalogId).put(payoutSlab.getOnwardsAmount(),
|
| 454 |
(long) (payoutSlab.getPayoutAmount() / payoutSlab.getOnwardsAmount()));
|
454 |
(long) (payoutSlab.getPayoutAmount() / payoutSlab.getOnwardsAmount()));
|
| 455 |
}
|
455 |
}
|
| 456 |
} else if (itemCriteriaPayout.getAmountType().equals(AmountType.PERCENTAGE)) {
|
456 |
} else if (itemCriteriaPayout.getAmountType().equals(AmountType.PERCENTAGE)) {
|
| 457 |
List<TagListing> tagListings = tagListingRepository.selectByItemIdsAndTagIds(new HashSet<>(itemIds),
|
457 |
List<TagListing> tagListings = tagListingRepository.selectAllByCatalogIds(catalogIds);
|
| 458 |
null);
|
- |
|
| 459 |
for (TagListing tagListing : tagListings) {
|
458 |
for (TagListing tagListing : tagListings) {
|
| 460 |
float taxableSellingPrice = tagListing.getSellingPrice() / (1 + 18f / 100);
|
459 |
float taxableSellingPrice = tagListing.getSellingPrice() / (1 + 18f / 100);
|
| 461 |
if (!itemSlabPayoutMap.containsKey(tagListing.getItemId())) {
|
460 |
if (!catalogSlabPayoutMap.containsKey(tagListing.getItemId())) {
|
| 462 |
itemSlabPayoutMap.put(tagListing.getItemId(), new LinkedHashMap<>());
|
461 |
catalogSlabPayoutMap.put(tagListing.getItemId(), new LinkedHashMap<>());
|
| 463 |
}
|
462 |
}
|
| 464 |
itemSlabPayoutMap.get(tagListing.getItemId()).put(payoutSlab.getOnwardsAmount(),
|
463 |
catalogSlabPayoutMap.get(tagListing.getItemId()).put(payoutSlab.getOnwardsAmount(),
|
| 465 |
(long) (taxableSellingPrice * payoutSlab.getPayoutAmount() / 100));
|
464 |
(long) (taxableSellingPrice * payoutSlab.getPayoutAmount() / 100));
|
| 466 |
}
|
465 |
}
|
| 467 |
}
|
466 |
}
|
| 468 |
}
|
467 |
}
|
| 469 |
}
|
468 |
}
|
| 470 |
return itemSlabPayoutMap;
|
469 |
return catalogSlabPayoutMap;
|
| 471 |
}
|
470 |
}
|
| 472 |
|
471 |
|
| 473 |
}
|
472 |
}
|