| Line 8... |
Line 8... |
| 8 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
8 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
| 9 |
import com.spice.profitmandi.common.services.ReporticoService;
|
9 |
import com.spice.profitmandi.common.services.ReporticoService;
|
| 10 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
10 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 11 |
import com.spice.profitmandi.common.util.StringUtils;
|
11 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 12 |
import com.spice.profitmandi.common.util.Utils;
|
12 |
import com.spice.profitmandi.common.util.Utils;
|
| 13 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
13 |
import com.spice.profitmandi.dao.entity.catalog.*;
|
| 14 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
- |
|
| 15 |
import com.spice.profitmandi.dao.entity.catalog.SchemeRegion;
|
- |
|
| 16 |
import com.spice.profitmandi.dao.entity.catalog.SchemesImeisModel;
|
- |
|
| 17 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
14 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
| 18 |
import com.spice.profitmandi.dao.entity.inventory.PartnerAgeingModel;
|
15 |
import com.spice.profitmandi.dao.entity.inventory.PartnerAgeingModel;
|
| 19 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
16 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
| 20 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
17 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 21 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
18 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| Line 23... |
Line 20... |
| 23 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
20 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| 24 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
21 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
| 25 |
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
|
22 |
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
|
| 26 |
import com.spice.profitmandi.dao.model.AmountModel;
|
23 |
import com.spice.profitmandi.dao.model.AmountModel;
|
| 27 |
import com.spice.profitmandi.dao.model.CreateSchemeRequest;
|
24 |
import com.spice.profitmandi.dao.model.CreateSchemeRequest;
|
| - |
|
25 |
import com.spice.profitmandi.dao.model.DateRangeModel;
|
| 28 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
26 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
| 29 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
27 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 30 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
28 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
| 31 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
29 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
| 32 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
30 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
| Line 78... |
Line 76... |
| 78 |
);
|
76 |
);
|
| 79 |
|
77 |
|
| 80 |
private static final List<SchemeType> ACTIVATION_SCHEME_TYPES = Arrays.asList(SchemeType.ACTIVATION, SchemeType.SPECIAL_SUPPORT, SchemeType.SELLOUT);
|
78 |
private static final List<SchemeType> ACTIVATION_SCHEME_TYPES = Arrays.asList(SchemeType.ACTIVATION, SchemeType.SPECIAL_SUPPORT, SchemeType.SELLOUT);
|
| 81 |
|
79 |
|
| 82 |
@Autowired
|
80 |
@Autowired
|
| - |
|
81 |
SchemeBlockedImeiRepository schemeBlockedImeiRepository;
|
| - |
|
82 |
@Autowired
|
| 83 |
StateGstRateRepository stateGstRateRepository;
|
83 |
StateGstRateRepository stateGstRateRepository;
|
| 84 |
@Autowired
|
84 |
@Autowired
|
| 85 |
NotificationService notificationService;
|
85 |
NotificationService notificationService;
|
| 86 |
@Autowired
|
86 |
@Autowired
|
| 87 |
@Qualifier("fofoInventoryItemRepository")
|
87 |
@Qualifier("fofoInventoryItemRepository")
|
| Line 129... |
Line 129... |
| 129 |
|
129 |
|
| 130 |
@Autowired
|
130 |
@Autowired
|
| 131 |
private SamsungExceptionRepository samsungExceptionRepository;
|
131 |
private SamsungExceptionRepository samsungExceptionRepository;
|
| 132 |
|
132 |
|
| 133 |
@Override
|
133 |
@Override
|
| - |
|
134 |
public List<String> getBlockedImeis() {
|
| - |
|
135 |
List<SchemeBlockedImei> schemeBlockedImeis = schemeBlockedImeiRepository.selectByDateRange(DateRangeModel.of(LocalDateTime.now().minusMonths(6), LocalDateTime.now()));
|
| - |
|
136 |
return schemeBlockedImeis.stream().filter(x -> x.isBlocked()).map(x -> x.getImei()).collect(Collectors.toList());
|
| - |
|
137 |
}
|
| - |
|
138 |
|
| - |
|
139 |
|
| - |
|
140 |
|
| - |
|
141 |
@Override
|
| 134 |
public void saveScheme(int creatorId, CreateSchemeRequest createSchemeRequest) throws ProfitMandiBusinessException {
|
142 |
public void saveScheme(int creatorId, CreateSchemeRequest createSchemeRequest) throws ProfitMandiBusinessException {
|
| 135 |
|
143 |
|
| 136 |
this.validateCreateSchemeRequest(createSchemeRequest);
|
144 |
this.validateCreateSchemeRequest(createSchemeRequest);
|
| 137 |
|
145 |
|
| 138 |
Scheme scheme = this.toScheme(creatorId, createSchemeRequest);
|
146 |
Scheme scheme = this.toScheme(creatorId, createSchemeRequest);
|
| Line 426... |
Line 434... |
| 426 |
throw new ProfitMandiBusinessException("", "Invalid purchase id for inventory item", "SCHM_1009");
|
434 |
throw new ProfitMandiBusinessException("", "Invalid purchase id for inventory item", "SCHM_1009");
|
| 427 |
}
|
435 |
}
|
| 428 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnMonth(purchase.getFofoId(),
|
436 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnMonth(purchase.getFofoId(),
|
| 429 |
YearMonth.from(purchase.getCreateTimestamp()));
|
437 |
YearMonth.from(purchase.getCreateTimestamp()));
|
| 430 |
//Remove imeis from blocked imeis list
|
438 |
//Remove imeis from blocked imeis list
|
| - |
|
439 |
List<String> blocked_imeis = this.getBlockedImeis();
|
| 431 |
inventoryItems = inventoryItems.stream().filter(inventoryItem -> !BLOCKED_IMEIS.contains(inventoryItem.getSerialNumber())).collect(Collectors.toList());
|
440 |
inventoryItems = inventoryItems.stream().filter(inventoryItem -> !blocked_imeis.contains(inventoryItem.getSerialNumber())).collect(Collectors.toList());
|
| 432 |
if (inventoryItems.size() == 0) return;
|
441 |
if (inventoryItems.size() == 0) return;
|
| 433 |
|
442 |
|
| 434 |
Set<Integer> itemIds = inventoryItems.stream().map(x -> x.getItemId()).collect(Collectors.toSet());
|
443 |
Set<Integer> itemIds = inventoryItems.stream().map(x -> x.getItemId()).collect(Collectors.toSet());
|
| 435 |
Map<Integer, Item> itemsMap = itemRepository.selectByIds(itemIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
444 |
Map<Integer, Item> itemsMap = itemRepository.selectByIds(itemIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 436 |
inventoryItems.stream().forEach(x -> x.setItem(itemsMap.get(x.getItemId())));
|
445 |
inventoryItems.stream().forEach(x -> x.setItem(itemsMap.get(x.getItemId())));
|
| Line 482... |
Line 491... |
| 482 |
}
|
491 |
}
|
| 483 |
|
492 |
|
| 484 |
|
493 |
|
| 485 |
// We are maintaining price drop after grn
|
494 |
// We are maintaining price drop after grn
|
| 486 |
private float getAmount(InventoryItem inventoryItem, Scheme scheme) throws ProfitMandiBusinessException {
|
495 |
private float getAmount(InventoryItem inventoryItem, Scheme scheme) throws ProfitMandiBusinessException {
|
| 487 |
if (BLOCKED_IMEIS.contains(inventoryItem.getSerialNumber())) {
|
496 |
if (this.getBlockedImeis().contains(inventoryItem.getSerialNumber())) {
|
| 488 |
return 0;
|
497 |
return 0;
|
| 489 |
}
|
498 |
}
|
| 490 |
float amount = 0;
|
499 |
float amount = 0;
|
| 491 |
float dpForCalc = 0;
|
500 |
float dpForCalc = 0;
|
| 492 |
float taxableSellingPrice = 0;
|
501 |
float taxableSellingPrice = 0;
|
| Line 696... |
Line 705... |
| 696 |
if (inventoryItemIds.size() == 0) return 0;
|
705 |
if (inventoryItemIds.size() == 0) return 0;
|
| 697 |
|
706 |
|
| 698 |
Set<InventoryItem> inventoryItems = inventoryItemRepository.selectByIds(inventoryItemIds).stream()
|
707 |
Set<InventoryItem> inventoryItems = inventoryItemRepository.selectByIds(inventoryItemIds).stream()
|
| 699 |
.filter(x -> x.getSerialNumber() != null && !x.getSerialNumber().equals(""))
|
708 |
.filter(x -> x.getSerialNumber() != null && !x.getSerialNumber().equals(""))
|
| 700 |
.collect(Collectors.toSet());
|
709 |
.collect(Collectors.toSet());
|
| 701 |
inventoryItems = inventoryItems.stream().filter(inventoryItem -> !BLOCKED_IMEIS.contains(inventoryItem.getSerialNumber())).collect(Collectors.toSet());
|
710 |
inventoryItems = inventoryItems.stream().filter(inventoryItem -> !this.getBlockedImeis().contains(inventoryItem.getSerialNumber())).collect(Collectors.toSet());
|
| 702 |
|
711 |
|
| 703 |
//Do not consider imei above 90 days for samsung
|
712 |
//Do not consider imei above 90 days for samsung
|
| 704 |
List<String> samsungSerialNumbers = inventoryItems.stream().filter(x -> x.getItem().getBrand().equalsIgnoreCase("samsung")).map(x -> x.getSerialNumber()).collect(Collectors.toList());
|
713 |
List<String> samsungSerialNumbers = inventoryItems.stream().filter(x -> x.getItem().getBrand().equalsIgnoreCase("samsung")).map(x -> x.getSerialNumber()).collect(Collectors.toList());
|
| 705 |
|
714 |
|
| 706 |
if (samsungSerialNumbers.size() > 0) {
|
715 |
if (samsungSerialNumbers.size() > 0) {
|