| Line 745... |
Line 745... |
| 745 |
|
745 |
|
| 746 |
@RequestMapping(value = "/partner/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
746 |
@RequestMapping(value = "/partner/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 747 |
public ResponseEntity<?> getPartnersListing(HttpServletRequest request) throws Exception {
|
747 |
public ResponseEntity<?> getPartnersListing(HttpServletRequest request) throws Exception {
|
| 748 |
List<WebListing> webListings = webListingRepository.selectAllWebListingByType(Optional.of(true), WebListingSource.partner);
|
748 |
List<WebListing> webListings = webListingRepository.selectAllWebListingByType(Optional.of(true), WebListingSource.partner);
|
| 749 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
749 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 750 |
for (WebListing webListing : webListings) {
|
750 |
int userId = (int) userInfo.getUserId();
|
| - |
|
751 |
UserCart uc = userAccountRepository.getUserCart(userId);
|
| - |
|
752 |
int fofoId = uc.getUserId();
|
| 751 |
|
753 |
|
| - |
|
754 |
for (WebListing webListing : webListings) {
|
| - |
|
755 |
// catalogFavouriteList.contains(webListing.getId())?
|
| 752 |
webListing.setFofoCatalogResponses(getDealResponses(userInfo, webListing, 0, 20));
|
756 |
webListing.setFofoCatalogResponses(getDealResponses(userInfo, webListing, 0, 20));
|
| - |
|
757 |
// List<FofoCatalogResponse> responseList= new ArrayList<>();
|
| 753 |
}
|
758 |
}
|
| 754 |
return responseSender.ok(webListings);
|
759 |
return responseSender.ok(webListings);
|
| 755 |
}
|
760 |
}
|
| 756 |
|
761 |
|
| 757 |
private List<FofoCatalogResponse> getDealResponses(UserInfo userInfo, WebListing webListing, int offset,
|
762 |
private List<FofoCatalogResponse> getDealResponses(UserInfo userInfo, WebListing webListing, int offset,
|
| Line 760... |
Line 765... |
| 760 |
RestClient rc = new RestClient();
|
765 |
RestClient rc = new RestClient();
|
| 761 |
Map<String, String> params = new HashMap<>();
|
766 |
Map<String, String> params = new HashMap<>();
|
| 762 |
List<String> mandatoryQ = new ArrayList<>();
|
767 |
List<String> mandatoryQ = new ArrayList<>();
|
| 763 |
|
768 |
|
| 764 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
|
769 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
|
| 765 |
|
- |
|
| 766 |
params.put("sort", "w" + fs.getWarehouseId() + "_i desc");
|
770 |
params.put("sort", "w" + fs.getWarehouseId() + "_i desc");
|
| 767 |
|
771 |
|
| 768 |
List<Integer> webProducts = null;
|
772 |
List<Integer> webProducts = null;
|
| 769 |
if (webListing.getType().equals(WebListingType.solr)) {
|
773 |
if (webListing.getType().equals(WebListingType.solr)) {
|
| 770 |
logger.info("solrtype {}", webListing.getSolrQuery());
|
774 |
logger.info("solrtype {}", webListing.getSolrQuery());
|
| Line 863... |
Line 867... |
| 863 |
|
867 |
|
| 864 |
if (fofoId > 0) {
|
868 |
if (fofoId > 0) {
|
| 865 |
partnerStockAvailabilityMap = currentInventorySnapshotRepository.selectItemsStock(fofoId).stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|
869 |
partnerStockAvailabilityMap = currentInventorySnapshotRepository.selectItemsStock(fofoId).stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|
| 866 |
logger.info("partnerStockAvailabilityMap: {}",partnerStockAvailabilityMap);
|
870 |
logger.info("partnerStockAvailabilityMap: {}",partnerStockAvailabilityMap);
|
| 867 |
}
|
871 |
}
|
| 868 |
|
- |
|
| - |
|
872 |
List<CatalogFavourite> catalogFavouriteList = catalogFavouriteRepository.selectBypartnerId(fofoId);
|
| - |
|
873 |
Set<Integer> favouriteCatalogIds = catalogFavouriteList.stream()
|
| - |
|
874 |
.map(CatalogFavourite::getCatalogId)
|
| - |
|
875 |
.collect(Collectors.toSet());
|
| 869 |
for (int i = 0; i < docs.length(); i++) {
|
876 |
for (int i = 0; i < docs.length(); i++) {
|
| 870 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
877 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
| 871 |
JSONObject doc = docs.getJSONObject(i);
|
878 |
JSONObject doc = docs.getJSONObject(i);
|
| 872 |
FofoCatalogResponse fofoCatalogResponse = new FofoCatalogResponse();
|
879 |
FofoCatalogResponse fofoCatalogResponse = new FofoCatalogResponse();
|
| 873 |
fofoCatalogResponse.setCatalogId(doc.getInt("catalogId_i"));
|
880 |
fofoCatalogResponse.setCatalogId(doc.getInt("catalogId_i"));
|
| Line 875... |
Line 882... |
| 875 |
fofoCatalogResponse.setTitle(doc.getString("title_s"));
|
882 |
fofoCatalogResponse.setTitle(doc.getString("title_s"));
|
| 876 |
fofoCatalogResponse.setSuperCatalogTitle(doc.getString("superCatalog_s"));
|
883 |
fofoCatalogResponse.setSuperCatalogTitle(doc.getString("superCatalog_s"));
|
| 877 |
fofoCatalogResponse.setSuperCatalogId(doc.getInt("superCatalog_i"));
|
884 |
fofoCatalogResponse.setSuperCatalogId(doc.getInt("superCatalog_i"));
|
| 878 |
fofoCatalogResponse.setSuperCatalogVariants(doc.getString("superCatalogVariants_s"));
|
885 |
fofoCatalogResponse.setSuperCatalogVariants(doc.getString("superCatalogVariants_s"));
|
| 879 |
|
886 |
|
| 880 |
/*if (catalogFavouriteIds.contains(fofoCatalogResponse.getCatalogId())) {
|
887 |
if (favouriteCatalogIds.contains(fofoCatalogResponse.getCatalogId())) {
|
| 881 |
fofoCatalogResponse.setFavourite(true);
|
888 |
fofoCatalogResponse.setFavourite(true);
|
| - |
|
889 |
} else {
|
| - |
|
890 |
fofoCatalogResponse.setFavourite(false); // optional, since default is false
|
| 882 |
}*/
|
891 |
}
|
| 883 |
|
- |
|
| 884 |
List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers().get(fofoCatalogResponse.getCatalogId());
|
892 |
List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers().get(fofoCatalogResponse.getCatalogId());
|
| 885 |
|
893 |
|
| 886 |
//logger.info("webOffers {}", webOffers);
|
894 |
//logger.info("webOffers {}", webOffers);
|
| 887 |
if (webOffers != null && webOffers.size() > 0) {
|
895 |
if (webOffers != null && webOffers.size() > 0) {
|
| 888 |
fofoCatalogResponse.setWebOffers(webOffers);
|
896 |
fofoCatalogResponse.setWebOffers(webOffers);
|