| Line 7... |
Line 7... |
| 7 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
7 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 8 |
import com.spice.profitmandi.dao.entity.catalog.ItemCriteria;
|
8 |
import com.spice.profitmandi.dao.entity.catalog.ItemCriteria;
|
| 9 |
import com.spice.profitmandi.dao.entity.catalog.Offer;
|
9 |
import com.spice.profitmandi.dao.entity.catalog.Offer;
|
| 10 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
10 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 11 |
import com.spice.profitmandi.dao.entity.catalog.TargetSlab;
|
11 |
import com.spice.profitmandi.dao.entity.catalog.TargetSlab;
|
| - |
|
12 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| - |
|
13 |
import com.spice.profitmandi.dao.entity.fofo.OfferPayout;
|
| 12 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
14 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
| 13 |
import com.spice.profitmandi.dao.enumuration.catalog.OfferSchemeType;
|
15 |
import com.spice.profitmandi.dao.enumuration.catalog.OfferSchemeType;
|
| - |
|
16 |
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
|
| 14 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
17 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
| 15 |
import com.spice.profitmandi.dao.model.ItemCriteriaPayout;
|
18 |
import com.spice.profitmandi.dao.model.ItemCriteriaPayout;
|
| 16 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
19 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
| - |
|
20 |
import com.spice.profitmandi.dao.repository.fofo.OfferPayoutRepository;
|
| 17 |
import com.spice.profitmandi.service.user.RetailerService;
|
21 |
import com.spice.profitmandi.service.user.RetailerService;
|
| - |
|
22 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| - |
|
23 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
| 18 |
import org.apache.logging.log4j.LogManager;
|
24 |
import org.apache.logging.log4j.LogManager;
|
| 19 |
import org.apache.logging.log4j.Logger;
|
25 |
import org.apache.logging.log4j.Logger;
|
| 20 |
import org.apache.poi.ss.usermodel.Cell;
|
26 |
import org.apache.poi.ss.usermodel.Cell;
|
| 21 |
import org.apache.poi.ss.usermodel.CellType;
|
27 |
import org.apache.poi.ss.usermodel.CellType;
|
| 22 |
import org.apache.poi.ss.usermodel.Row;
|
28 |
import org.apache.poi.ss.usermodel.Row;
|
| Line 30... |
Line 36... |
| 30 |
import org.springframework.stereotype.Component;
|
36 |
import org.springframework.stereotype.Component;
|
| 31 |
|
37 |
|
| 32 |
import java.io.IOException;
|
38 |
import java.io.IOException;
|
| 33 |
import java.io.InputStream;
|
39 |
import java.io.InputStream;
|
| 34 |
import java.time.LocalDate;
|
40 |
import java.time.LocalDate;
|
| - |
|
41 |
import java.time.LocalDateTime;
|
| 35 |
import java.time.YearMonth;
|
42 |
import java.time.YearMonth;
|
| 36 |
import java.util.*;
|
43 |
import java.util.*;
|
| 37 |
import java.util.stream.Collectors;
|
44 |
import java.util.stream.Collectors;
|
| 38 |
|
45 |
|
| 39 |
@Component
|
46 |
@Component
|
| Line 50... |
Line 57... |
| 50 |
|
57 |
|
| 51 |
@Autowired
|
58 |
@Autowired
|
| 52 |
private RetailerService retailerService;
|
59 |
private RetailerService retailerService;
|
| 53 |
|
60 |
|
| 54 |
@Autowired
|
61 |
@Autowired
|
| - |
|
62 |
OfferPayoutRepository offerPayoutRepository;
|
| - |
|
63 |
|
| - |
|
64 |
@Autowired
|
| 55 |
private ItemCriteriaRepository itemCriteriaRepository;
|
65 |
private ItemCriteriaRepository itemCriteriaRepository;
|
| 56 |
|
66 |
|
| 57 |
@Autowired
|
67 |
@Autowired
|
| 58 |
private ItemRepository itemRepository;
|
68 |
private ItemRepository itemRepository;
|
| 59 |
|
69 |
|
| Line 225... |
Line 235... |
| 225 |
}
|
235 |
}
|
| 226 |
return createOfferRequest;
|
236 |
return createOfferRequest;
|
| 227 |
|
237 |
|
| 228 |
}
|
238 |
}
|
| 229 |
|
239 |
|
| - |
|
240 |
@Autowired
|
| - |
|
241 |
private WalletService walletService;
|
| - |
|
242 |
|
| - |
|
243 |
@Override
|
| - |
|
244 |
public void reverseAdditionalSelloutSchemes(int fofoId, List<InventoryItem> inventoryItems) throws ProfitMandiBusinessException {
|
| - |
|
245 |
List<OfferPayout> offerPayouts = new ArrayList<>();
|
| - |
|
246 |
for (InventoryItem inventoryItem : inventoryItems) {
|
| - |
|
247 |
offerPayouts.addAll(offerPayoutRepository.selectAllBySerialNumber(inventoryItem.getFofoId(), inventoryItem.getSerialNumber())
|
| - |
|
248 |
.stream()
|
| - |
|
249 |
.filter(x -> x.getRejectTimestamp() != null)
|
| - |
|
250 |
.collect(Collectors.toList()));
|
| - |
|
251 |
}
|
| - |
|
252 |
for (OfferPayout offerPayout : offerPayouts) {
|
| - |
|
253 |
offerPayout.setStatus(SchemePayoutStatus.REJECTED);
|
| - |
|
254 |
offerPayout.setRejectTimestamp(LocalDateTime.now());
|
| - |
|
255 |
}
|
| - |
|
256 |
Map<Long, Double> offerPayoutAmountMap = offerPayouts.stream().collect(Collectors.groupingBy(x -> x.getOfferId(), Collectors.summingDouble(x -> x.getAmount())));
|
| - |
|
257 |
for (Map.Entry<Long, Double> offerPayoutEntry : offerPayoutAmountMap.entrySet()) {
|
| - |
|
258 |
walletService.rollbackAmountFromWallet(fofoId, offerPayoutEntry.getValue().floatValue(), offerPayoutEntry.getKey().intValue(),
|
| - |
|
259 |
WalletReferenceType.ADDITIONAL_SCHEME, "Imeis for corresponding schemes are returned", LocalDateTime.now());
|
| - |
|
260 |
}
|
| - |
|
261 |
}
|
| - |
|
262 |
|
| 230 |
private void createTargetSlabs(CreateOfferRequest createOfferRequest) throws ProfitMandiBusinessException {
|
263 |
private void createTargetSlabs(CreateOfferRequest createOfferRequest) throws ProfitMandiBusinessException {
|
| 231 |
List<com.spice.profitmandi.dao.model.TargetSlab> targetSlabs = createOfferRequest.getTargetSlabs().stream()
|
264 |
List<com.spice.profitmandi.dao.model.TargetSlab> targetSlabs = createOfferRequest.getTargetSlabs().stream()
|
| 232 |
.filter(x -> x.validate()).collect(Collectors.toList());
|
265 |
.filter(x -> x.validate()).collect(Collectors.toList());
|
| 233 |
if (targetSlabs.size() >= 0) {
|
266 |
if (targetSlabs.size() >= 0) {
|
| 234 |
Collections.sort(targetSlabs);
|
267 |
Collections.sort(targetSlabs);
|