| Line 315... |
Line 315... |
| 315 |
return String.join(",", strTagIds);
|
315 |
return String.join(",", strTagIds);
|
| 316 |
}
|
316 |
}
|
| 317 |
|
317 |
|
| 318 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
318 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 319 |
@RequestMapping(value = "/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
319 |
@RequestMapping(value = "/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
320 |
public ResponseEntity<?> getFofo(HttpServletRequest request, @RequestParam(value = "categoryId", required = false, defaultValue = "3") String categoryId, @RequestParam(value = "offset") int offset,
|
| 320 |
public ResponseEntity<?> getFofo(HttpServletRequest request, @RequestParam(value = "categoryId", required = false, defaultValue = "3") String categoryId, @RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit, @RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "brand", required = false) String brand, @RequestParam(value = "subCategoryId", required = false) int subCategoryId, @RequestParam(value = "q", required = false) String queryTerm, @RequestParam(value = "hotDeal", required = false) boolean hotDeal, @RequestParam(value = "endPoint", required = false) String endPoint) throws Throwable {
|
321 |
@RequestParam(value = "limit") int limit, @RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "brand", required = false) String brand, @RequestParam(value = "subCategoryId", required = false) int subCategoryId, @RequestParam(value = "q", required = false) String queryTerm, @RequestParam(value = "hotDeal", required = false) boolean hotDeal, @RequestParam(value = "endPoint", required = false) String endPoint) throws Throwable {
|
| 321 |
List<FofoCatalogResponse> dealResponse;
|
322 |
List<FofoCatalogResponse> dealResponse;
|
| 322 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
323 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 323 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
|
324 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
|
| 324 |
sort = "w" + fs.getWarehouseId() + "_i desc";
|
325 |
sort = "w" + fs.getWarehouseId() + "_i desc";
|
| 325 |
|
326 |
|
| Line 332... |
Line 333... |
| 332 |
} else {
|
333 |
} else {
|
| 333 |
|
334 |
|
| 334 |
dealResponse = this.getCatalogResponse(
|
335 |
dealResponse = this.getCatalogResponse(
|
| 335 |
solrService.getSolrDocs(queryTerm, categoryId, offset, limit, sort, brand, subCategoryId, hotDeal), hotDeal, userInfo.getRetailerId());
|
336 |
solrService.getSolrDocs(queryTerm, categoryId, offset, limit, sort, brand, subCategoryId, hotDeal), hotDeal, userInfo.getRetailerId());
|
| 336 |
}
|
337 |
}
|
| - |
|
338 |
|
| - |
|
339 |
Map<Integer, List<Integer>> similarModelMap = dealResponse.stream().filter(x -> x.getSimilarModelIds() != null && x.getSimilarModelIds().size() > 0)
|
| - |
|
340 |
.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x.getSimilarModelIds()));
|
| - |
|
341 |
Set<Integer> similarModelIds = similarModelMap.values().stream().flatMap(x -> x.stream()).collect(Collectors.toSet());
|
| 337 |
logger.info("log me");
|
342 |
logger.info("similarModelIds - {}", similarModelIds);
|
| - |
|
343 |
if(similarModelIds.size() > 0) {
|
| - |
|
344 |
WebListing webListing = new WebListing();
|
| - |
|
345 |
webListing.setType(WebListingType.solr);
|
| - |
|
346 |
webListing.setSolrQuery("catalogId_i:(" + String.join(" ", similarModelIds.stream().map(x -> String.valueOf(x)).collect(Collectors.toList())) + ")");
|
| - |
|
347 |
|
| - |
|
348 |
Map<Integer, FofoCatalogResponse> similarCatalogResponsesMap = this.getDealResponses(userInfo, webListing, 0, 300).stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
| - |
|
349 |
logger.info("Similar Catalog ResponseMap - {}", similarCatalogResponsesMap.keySet());
|
| - |
|
350 |
|
| - |
|
351 |
for (FofoCatalogResponse deal : dealResponse) {
|
| - |
|
352 |
if (similarModelMap.containsKey(deal.getCatalogId())) {
|
| - |
|
353 |
List<Integer> similarCatalogIds = similarModelMap.get(deal.getCatalogId());
|
| - |
|
354 |
logger.info("Similar Catalog Ids - {}", similarCatalogIds);
|
| - |
|
355 |
List<FofoCatalogResponse> similarModels = similarCatalogIds.stream().filter(x->similarCatalogResponsesMap.containsKey(x)).map(x -> similarCatalogResponsesMap.get(x)).collect(Collectors.toList());
|
| - |
|
356 |
deal.setSimilarModels(similarModels);
|
| - |
|
357 |
}
|
| - |
|
358 |
}
|
| - |
|
359 |
}
|
| 338 |
return responseSender.ok(dealResponse);
|
360 |
return responseSender.ok(dealResponse);
|
| 339 |
}
|
361 |
}
|
| 340 |
|
362 |
|
| 341 |
@RequestMapping(value = "/online-deals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
363 |
@RequestMapping(value = "/online-deals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 342 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
364 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| Line 588... |
Line 610... |
| 588 |
public ResponseEntity<?> getPartnersListing(HttpServletRequest request) throws Exception {
|
610 |
public ResponseEntity<?> getPartnersListing(HttpServletRequest request) throws Exception {
|
| 589 |
List<WebListing> webListings = webListingRepository.selectAllWebListingByType(Optional.of(true), WebListingSource.partner);
|
611 |
List<WebListing> webListings = webListingRepository.selectAllWebListingByType(Optional.of(true), WebListingSource.partner);
|
| 590 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
612 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 591 |
for (WebListing webListing : webListings) {
|
613 |
for (WebListing webListing : webListings) {
|
| 592 |
|
614 |
|
| 593 |
webListing.setFofoCatalogResponses(getDealResponses(userInfo, webListing, "0", "20"));
|
615 |
webListing.setFofoCatalogResponses(getDealResponses(userInfo, webListing, 0, 20));
|
| 594 |
}
|
616 |
}
|
| 595 |
return responseSender.ok(webListings);
|
617 |
return responseSender.ok(webListings);
|
| 596 |
}
|
618 |
}
|
| 597 |
|
619 |
|
| 598 |
private List<FofoCatalogResponse> getDealResponses(UserInfo userInfo, WebListing webListing, String offset, String limit) throws Exception {
|
620 |
private List<FofoCatalogResponse> getDealResponses(UserInfo userInfo, WebListing webListing, int offset, int limit) throws Exception {
|
| 599 |
|
621 |
|
| 600 |
RestClient rc = new RestClient();
|
622 |
RestClient rc = new RestClient();
|
| 601 |
Map<String, String> params = new HashMap<>();
|
623 |
Map<String, String> params = new HashMap<>();
|
| 602 |
List<String> mandatoryQ = new ArrayList<>();
|
624 |
List<String> mandatoryQ = new ArrayList<>();
|
| 603 |
|
625 |
|
| Line 610... |
Line 632... |
| 610 |
logger.info("solrtype {}", webListing.getSolrQuery());
|
632 |
logger.info("solrtype {}", webListing.getSolrQuery());
|
| 611 |
mandatoryQ.add(String.format("+{!parent which=\"" + webListing.getSolrQuery() + "\"} AND active_b:true AND show_default_b:true"));
|
633 |
mandatoryQ.add(String.format("+{!parent which=\"" + webListing.getSolrQuery() + "\"} AND active_b:true AND show_default_b:true"));
|
| 612 |
} else {
|
634 |
} else {
|
| 613 |
logger.info("solrtype2 {}", webListing.getSolrQuery());
|
635 |
logger.info("solrtype2 {}", webListing.getSolrQuery());
|
| 614 |
|
636 |
|
| 615 |
webProducts = webProductListingRepository.selectAllByWebListingId(webListing.getId(), Integer.parseInt(offset), Integer.parseInt(limit)).stream().filter(x -> x.getRank() > 0).map(x -> x.getEntityId()).collect(Collectors.toList());
|
637 |
webProducts = webProductListingRepository.selectAllByWebListingId(webListing.getId(), offset, limit).stream().filter(x -> x.getRank() > 0).map(x -> x.getEntityId()).collect(Collectors.toList());
|
| 616 |
|
638 |
|
| 617 |
if (webProducts.size() == 0) {
|
639 |
if (webProducts.size() == 0) {
|
| 618 |
return new ArrayList<>();
|
640 |
return new ArrayList<>();
|
| 619 |
}
|
641 |
}
|
| 620 |
|
642 |
|
| Line 712... |
Line 734... |
| 712 |
fofoCatalogResponse.setFavourite(true);
|
734 |
fofoCatalogResponse.setFavourite(true);
|
| 713 |
}
|
735 |
}
|
| 714 |
|
736 |
|
| 715 |
List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers().get(fofoCatalogResponse.getCatalogId());
|
737 |
List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers().get(fofoCatalogResponse.getCatalogId());
|
| 716 |
|
738 |
|
| 717 |
logger.info("webOffers {}", webOffers);
|
739 |
//logger.info("webOffers {}", webOffers);
|
| 718 |
if (webOffers != null && webOffers.size() > 0) {
|
740 |
if (webOffers != null && webOffers.size() > 0) {
|
| 719 |
fofoCatalogResponse.setWebOffers(webOffers);
|
741 |
fofoCatalogResponse.setWebOffers(webOffers);
|
| 720 |
fofoCatalogResponse.setOffers(webOffers.stream().map(x -> x.getTitle()).collect(Collectors.toList()));
|
742 |
fofoCatalogResponse.setOffers(webOffers.stream().map(x -> x.getTitle()).collect(Collectors.toList()));
|
| 721 |
|
743 |
|
| 722 |
}
|
744 |
}
|
| 723 |
|
745 |
|
| 724 |
List<ComboModel> comboModels = comboModelRepository.selectByWarehouseId(warehouseId).stream().filter(x -> x.getCatalogId() == fofoCatalogResponse.getCatalogId()).collect(Collectors.toList());
|
746 |
List<ComboModel> comboModels = comboModelRepository.selectByWarehouseId(warehouseId).stream().filter(x -> x.getCatalogId() == fofoCatalogResponse.getCatalogId()).collect(Collectors.toList());
|
| 725 |
|
747 |
|
| 726 |
logger.info("comboModels {}", comboModels);
|
748 |
//logger.info("comboModels {}", comboModels);
|
| 727 |
|
749 |
|
| 728 |
if (comboModels != null && comboModels.size() > 0) {
|
750 |
if (comboModels != null && comboModels.size() > 0) {
|
| 729 |
fofoCatalogResponse.setComboModels(comboModels);
|
751 |
fofoCatalogResponse.setComboModels(comboModels);
|
| 730 |
}
|
752 |
}
|
| 731 |
|
753 |
|
| Line 749... |
Line 771... |
| 749 |
}
|
771 |
}
|
| 750 |
|
772 |
|
| 751 |
fofoCatalogResponse.setLabels(new ArrayList<>(labels));
|
773 |
fofoCatalogResponse.setLabels(new ArrayList<>(labels));
|
| 752 |
|
774 |
|
| 753 |
}
|
775 |
}
|
| - |
|
776 |
if (doc.has("similarModels_ii")) {
|
| - |
|
777 |
JSONArray similarModelsArray = doc.getJSONArray("similarModels_ii");
|
| - |
|
778 |
List<Integer> similarCatalogIds = new ArrayList<>();
|
| - |
|
779 |
for (int j = 0; j < similarModelsArray.length(); j++) {
|
| - |
|
780 |
similarCatalogIds.add(similarModelsArray.getInt(j));
|
| - |
|
781 |
}
|
| - |
|
782 |
fofoCatalogResponse.setSimilarModelIds(similarCatalogIds);
|
| - |
|
783 |
}
|
| 754 |
|
784 |
|
| 755 |
if (doc.has("_childDocuments_")) {
|
785 |
if (doc.has("_childDocuments_")) {
|
| 756 |
String modelColorClass = "grey";
|
786 |
String modelColorClass = "grey";
|
| 757 |
FofoAvailabilityInfo fdiAnyColour = null;
|
787 |
FofoAvailabilityInfo fdiAnyColour = null;
|
| 758 |
// Iterating itemIds
|
788 |
// Iterating itemIds
|