| Line 709... |
Line 709... |
| 709 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
709 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
| 710 |
@RequestParam(value = "sort", required = false) String sort,
|
710 |
@RequestParam(value = "sort", required = false) String sort,
|
| 711 |
@RequestParam(value = "brand", required = false) String brand,
|
711 |
@RequestParam(value = "brand", required = false) String brand,
|
| 712 |
@RequestParam(value = "subCategoryId", required = false) int subCategoryId,
|
712 |
@RequestParam(value = "subCategoryId", required = false) int subCategoryId,
|
| 713 |
@RequestParam(value = "q", required = false) String queryTerm,
|
713 |
@RequestParam(value = "q", required = false) String queryTerm,
|
| 714 |
@RequestParam(value = " ", required = false, defaultValue = "true") boolean partnerStockOnly)
|
714 |
@RequestParam(required = false, defaultValue = "true") boolean partnerStockOnly)
|
| 715 |
throws Throwable {
|
715 |
throws Throwable {
|
| 716 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
716 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 717 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
717 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| - |
|
718 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
|
| - |
|
719 |
sort = "w" + fs.getWarehouseId() + "_i desc";
|
| 718 |
dealResponse = this.getCatalogResponse(
|
720 |
dealResponse = this.getCatalogResponse(
|
| 719 |
solrService.getSolrDocs(queryTerm, categoryId, offset, limit, sort, brand, subCategoryId, false), false,
|
721 |
solrService.getSolrDocs(queryTerm, categoryId, offset, limit, sort, brand, subCategoryId, false), false,
|
| 720 |
userInfo.getRetailerId());
|
722 |
userInfo.getRetailerId());
|
| 721 |
return responseSender.ok(dealResponse);
|
723 |
return responseSender.ok(dealResponse);
|
| 722 |
}
|
724 |
}
|
| Line 740... |
Line 742... |
| 740 |
}
|
742 |
}
|
| 741 |
}
|
743 |
}
|
| 742 |
if (itemsSet.size() == 0) {
|
744 |
if (itemsSet.size() == 0) {
|
| 743 |
return dealResponse;
|
745 |
return dealResponse;
|
| 744 |
}
|
746 |
}
|
| 745 |
if (hotDeal) {
|
- |
|
| 746 |
ourItemAvailabilityMap = saholicInventoryService
|
- |
|
| 747 |
.getTotalAvailabilityByItemIds(new ArrayList<>(itemsSet));
|
- |
|
| 748 |
} else if (fofoId > 0) {
|
747 |
if (fofoId > 0) {
|
| 749 |
partnerStockAvailabilityMap = currentInventorySnapshotRepository.selectItemsStock(fofoId).stream()
|
748 |
partnerStockAvailabilityMap = currentInventorySnapshotRepository.selectItemsStock(fofoId).stream()
|
| 750 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|
749 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|
| 751 |
ourItemAvailabilityMap = saholicInventoryService
|
- |
|
| 752 |
.getTotalAvailabilityByItemIds(new ArrayList<>(itemsSet));
|
- |
|
| 753 |
}
|
750 |
}
|
| - |
|
751 |
ourItemAvailabilityMap = saholicInventoryService
|
| - |
|
752 |
.getTotalAvailabilityByItemIds(new ArrayList<>(itemsSet));
|
| 754 |
}
|
753 |
}
|
| 755 |
|
754 |
|
| 756 |
for (int i = 0; i < docs.length(); i++) {
|
755 |
for (int i = 0; i < docs.length(); i++) {
|
| 757 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
756 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
| 758 |
JSONObject doc = docs.getJSONObject(i);
|
757 |
JSONObject doc = docs.getJSONObject(i);
|
| Line 788... |
Line 787... |
| 788 |
fdi.setItem_id(itemId);
|
787 |
fdi.setItem_id(itemId);
|
| 789 |
Float cashBack = schemeService.getItemSchemeCashBack().get(itemId);
|
788 |
Float cashBack = schemeService.getItemSchemeCashBack().get(itemId);
|
| 790 |
cashBack = cashBack == null ? 0 : cashBack;
|
789 |
cashBack = cashBack == null ? 0 : cashBack;
|
| 791 |
fdi.setCashback(cashBack);
|
790 |
fdi.setCashback(cashBack);
|
| 792 |
fdi.setMinBuyQuantity(1);
|
791 |
fdi.setMinBuyQuantity(1);
|
| 793 |
if (hotDeal) {
|
- |
|
| 794 |
try {
|
- |
|
| 795 |
int totalAvailability = ourItemAvailabilityMap.get(itemId);
|
- |
|
| 796 |
if (totalAvailability <= 0) {
|
- |
|
| 797 |
continue;
|
- |
|
| 798 |
}
|
- |
|
| 799 |
fdi.setAvailability(ourItemAvailabilityMap.get(itemId));
|
- |
|
| 800 |
} catch (Exception e) {
|
- |
|
| 801 |
continue;
|
- |
|
| 802 |
}
|
- |
|
| 803 |
} else if (fofoId == 0) {
|
- |
|
| 804 |
// For accessories item availability should at be ordered for Rs.1000
|
- |
|
| 805 |
fdi.setAvailability(100);
|
- |
|
| 806 |
Item item = itemRepository.selectById(itemId);
|
- |
|
| 807 |
// In case its tampered glass moq should be 5
|
- |
|
| 808 |
if (item.getCategoryId() == 10020) {
|
- |
|
| 809 |
fdi.setMinBuyQuantity(5);
|
- |
|
| 810 |
}
|
- |
|
| 811 |
} else {
|
- |
|
| 812 |
int ourStockAvailability = ourItemAvailabilityMap.get(itemId) == null ? 0
|
792 |
int ourStockAvailability = ourItemAvailabilityMap.get(itemId) == null ? 0 : Math.max(0,ourItemAvailabilityMap.get(itemId))
|
| 813 |
: ourItemAvailabilityMap.get(itemId);
|
- |
|
| 814 |
int partnerAvailability = partnerStockAvailabilityMap.get(itemId) == null ? 0
|
793 |
int partnerAvailability = partnerStockAvailabilityMap.get(itemId) == null ? 0
|
| 815 |
: partnerStockAvailabilityMap.get(itemId);
|
794 |
: partnerStockAvailabilityMap.get(itemId);
|
| 816 |
fdi.setAvailability(ourStockAvailability + partnerAvailability);
|
795 |
fdi.setAvailability(Math.min(5,ourStockAvailability + partnerAvailability));
|
| 817 |
}
|
- |
|
| 818 |
fdi.setQuantityStep(1);
|
796 |
fdi.setQuantityStep(1);
|
| 819 |
fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
|
797 |
fdi.setMaxQuantity(fdi.getAvailability());
|
| 820 |
fofoAvailabilityInfoMap.put(itemId, fdi);
|
798 |
fofoAvailabilityInfoMap.put(itemId, fdi);
|
| 821 |
}
|
799 |
}
|
| 822 |
}
|
800 |
}
|
| 823 |
}
|
801 |
}
|
| 824 |
if (fofoAvailabilityInfoMap.values().size() > 0) {
|
802 |
if (fofoAvailabilityInfoMap.values().size() > 0) {
|