| Line 25... |
Line 25... |
| 25 |
import com.spice.profitmandi.dao.enumuration.catalog.AchievementType;
|
25 |
import com.spice.profitmandi.dao.enumuration.catalog.AchievementType;
|
| 26 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
26 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
| 27 |
import com.spice.profitmandi.dao.enumuration.catalog.OfferSchemeType;
|
27 |
import com.spice.profitmandi.dao.enumuration.catalog.OfferSchemeType;
|
| 28 |
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
|
28 |
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
|
| 29 |
import com.spice.profitmandi.dao.model.*;
|
29 |
import com.spice.profitmandi.dao.model.*;
|
| - |
|
30 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
| 30 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
31 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
| 31 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
32 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 32 |
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
|
33 |
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
|
| 33 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
34 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 34 |
import com.spice.profitmandi.dao.repository.fofo.OfferPayoutRepository;
|
35 |
import com.spice.profitmandi.dao.repository.fofo.OfferPayoutRepository;
|
| Line 82... |
Line 83... |
| 82 |
@Autowired
|
83 |
@Autowired
|
| 83 |
private CacheManager oneDayCacheManager;
|
84 |
private CacheManager oneDayCacheManager;
|
| 84 |
|
85 |
|
| 85 |
// Dependencies - Repositories
|
86 |
// Dependencies - Repositories
|
| 86 |
@Autowired
|
87 |
@Autowired
|
| - |
|
88 |
private GenericRepository genericRepository;
|
| - |
|
89 |
|
| - |
|
90 |
@Autowired
|
| 87 |
private OfferRepository offerRepository;
|
91 |
private OfferRepository offerRepository;
|
| 88 |
|
92 |
|
| 89 |
@Autowired
|
93 |
@Autowired
|
| 90 |
private OfferPayoutRepository offerPayoutRepository;
|
94 |
private OfferPayoutRepository offerPayoutRepository;
|
| 91 |
|
95 |
|
| Line 444... |
Line 448... |
| 444 |
ymListToEvict.add(YearMonth.from(createOfferRequest.getStartDate()));
|
448 |
ymListToEvict.add(YearMonth.from(createOfferRequest.getStartDate()));
|
| 445 |
}
|
449 |
}
|
| 446 |
for (YearMonth ymToEvict : ymListToEvict) {
|
450 |
for (YearMonth ymToEvict : ymListToEvict) {
|
| 447 |
oneDayCacheManager.getCache("allOffers").evict(ymToEvict);
|
451 |
oneDayCacheManager.getCache("allOffers").evict(ymToEvict);
|
| 448 |
}
|
452 |
}
|
| 449 |
|
- |
|
| 450 |
}
|
453 |
}
|
| 451 |
|
454 |
|
| 452 |
private Map<CreateOfferRequest, List<PartnerTargetModel>> parseFromExcel(InputStream inputStream)
|
455 |
private Map<CreateOfferRequest, List<PartnerTargetModel>> parseFromExcel(InputStream inputStream)
|
| 453 |
throws ProfitMandiBusinessException {
|
456 |
throws ProfitMandiBusinessException {
|
| 454 |
|
457 |
|
| Line 1506... |
Line 1509... |
| 1506 |
private void appendPartnerCodes(List<Integer> fofoIds, StringBuilder sb) throws ProfitMandiBusinessException {
|
1509 |
private void appendPartnerCodes(List<Integer> fofoIds, StringBuilder sb) throws ProfitMandiBusinessException {
|
| 1507 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getAllFofoRetailers();
|
1510 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getAllFofoRetailers();
|
| 1508 |
List<String> businessNames = fofoIds.stream().map(x -> customRetailersMap.get(x)).filter(x -> x != null).map(x -> x.getBusinessName()).collect(Collectors.toList());
|
1511 |
List<String> businessNames = fofoIds.stream().map(x -> customRetailersMap.get(x)).filter(x -> x != null).map(x -> x.getBusinessName()).collect(Collectors.toList());
|
| 1509 |
sb.append(String.join(", ", businessNames));
|
1512 |
sb.append(String.join(", ", businessNames));
|
| 1510 |
}
|
1513 |
}
|
| - |
|
1514 |
|
| - |
|
1515 |
@Override
|
| - |
|
1516 |
public void deleteOffer(int offerId) throws ProfitMandiBusinessException {
|
| - |
|
1517 |
Offer offer = offerRepository.selectById(offerId);
|
| - |
|
1518 |
if (offer == null) {
|
| - |
|
1519 |
throw new ProfitMandiBusinessException("Offer not found", "Offer not found", "");
|
| - |
|
1520 |
}
|
| - |
|
1521 |
if (offer.isActive()) {
|
| - |
|
1522 |
throw new ProfitMandiBusinessException("Cannot delete a published offer", "Cannot delete a published offer", "");
|
| - |
|
1523 |
}
|
| - |
|
1524 |
List<TargetSlabEntity> targetSlabs = offerTargetSlabRepository.selectByOfferIds(Collections.singletonList(offerId));
|
| - |
|
1525 |
for (TargetSlabEntity targetSlab : targetSlabs) {
|
| - |
|
1526 |
genericRepository.delete(targetSlab);
|
| - |
|
1527 |
}
|
| - |
|
1528 |
genericRepository.delete(offer);
|
| - |
|
1529 |
LOGGER.info("Deleted offer {} and {} target slabs", offerId, targetSlabs.size());
|
| - |
|
1530 |
}
|
| - |
|
1531 |
|
| - |
|
1532 |
@Override
|
| - |
|
1533 |
public List<Offer> publishAllUnpublished(YearMonth yearMonth) throws ProfitMandiBusinessException {
|
| - |
|
1534 |
List<Offer> allOffers = offerRepository.selectAll(yearMonth, false);
|
| - |
|
1535 |
List<Offer> unpublished = allOffers.stream().filter(o -> !o.isActive()).collect(Collectors.toList());
|
| - |
|
1536 |
for (Offer offer : unpublished) {
|
| - |
|
1537 |
offer.setActive(true);
|
| - |
|
1538 |
}
|
| - |
|
1539 |
LOGGER.info("Published {} unpublished offers for {}", unpublished.size(), yearMonth);
|
| - |
|
1540 |
return unpublished;
|
| - |
|
1541 |
}
|
| 1511 |
}
|
1542 |
}
|