| Line 22... |
Line 22... |
| 22 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
22 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 23 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
23 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
| 24 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
24 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
| 25 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
|
25 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
|
| 26 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
26 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
| - |
|
27 |
import com.spice.profitmandi.dao.entity.similarModel.SimilarModel;
|
| 27 |
import com.spice.profitmandi.dao.enumuration.dtr.WebListingSource;
|
28 |
import com.spice.profitmandi.dao.enumuration.dtr.WebListingSource;
|
| 28 |
import com.spice.profitmandi.dao.enumuration.dtr.WebListingType;
|
29 |
import com.spice.profitmandi.dao.enumuration.dtr.WebListingType;
|
| 29 |
import com.spice.profitmandi.dao.model.AmountModel;
|
30 |
import com.spice.profitmandi.dao.model.AmountModel;
|
| 30 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
31 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
| 31 |
import com.spice.profitmandi.dao.model.UserCart;
|
32 |
import com.spice.profitmandi.dao.model.UserCart;
|
| Line 313... |
Line 314... |
| 313 |
strTagIds.add(String.valueOf(tagId));
|
314 |
strTagIds.add(String.valueOf(tagId));
|
| 314 |
}
|
315 |
}
|
| 315 |
return String.join(",", strTagIds);
|
316 |
return String.join(",", strTagIds);
|
| 316 |
}
|
317 |
}
|
| 317 |
|
318 |
|
| - |
|
319 |
@RequestMapping(value = "/fofo/similar-models/{modelId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
320 |
public ResponseEntity<?> similarModels(HttpServletRequest httpServletRequest, @PathVariable int modelId) throws Throwable {
|
| - |
|
321 |
UserInfo userInfo = (UserInfo) httpServletRequest.getAttribute("userInfo");
|
| - |
|
322 |
//FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
|
| - |
|
323 |
|
| - |
|
324 |
JSONObject jsonObject = solrService.getContentByCatalogIds(Arrays.asList(modelId)).get(modelId);
|
| - |
|
325 |
|
| - |
|
326 |
JSONArray similarModelsArray = jsonObject.getJSONArray("similarModels_ii");
|
| - |
|
327 |
List<Integer> similarCatalogIds = new ArrayList<>();
|
| - |
|
328 |
for (int j = 0; j < similarModelsArray.length(); j++) {
|
| - |
|
329 |
similarCatalogIds.add(similarModelsArray.getInt(j));
|
| - |
|
330 |
}
|
| - |
|
331 |
|
| - |
|
332 |
Map<String, String> params = new HashMap<>();
|
| - |
|
333 |
List<String> mandatoryQ = new ArrayList<>();
|
| - |
|
334 |
|
| - |
|
335 |
mandatoryQ.add(String.format(
|
| - |
|
336 |
"+{!parent which=\"catalogId_i:(" + StringUtils.join(similarCatalogIds, " ") + ")\"} AND active_b:true AND show_default_b:true"));
|
| - |
|
337 |
|
| - |
|
338 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
| - |
|
339 |
params.put("fl", "*, [child parentFilter=id:catalog* childFilter=active_b:true ]");
|
| - |
|
340 |
params.put("wt", "json");
|
| - |
|
341 |
params.put("rows", similarCatalogIds.size() + "");
|
| - |
|
342 |
try {
|
| - |
|
343 |
String response = restClient.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);
|
| - |
|
344 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
| - |
|
345 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
| - |
|
346 |
return responseSender.ok(this.getCatalogResponse(docs, false, userInfo.getRetailerId()));
|
| - |
|
347 |
} catch (HttpHostConnectException e) {
|
| - |
|
348 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
| - |
|
349 |
}
|
| - |
|
350 |
}
|
| - |
|
351 |
|
| 318 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
352 |
@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)
|
353 |
@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,
|
354 |
public ResponseEntity<?> getFofo(HttpServletRequest request, @RequestParam(value = "categoryId", required = false, defaultValue = "3") String categoryId, @RequestParam(value = "offset") int offset,
|
| 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 {
|
355 |
@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 {
|
| 322 |
List<FofoCatalogResponse> dealResponse;
|
356 |
List<FofoCatalogResponse> dealResponse;
|
| Line 338... |
Line 372... |
| 338 |
|
372 |
|
| 339 |
Map<Integer, List<Integer>> similarModelMap = dealResponse.stream().filter(x -> x.getSimilarModelIds() != null && x.getSimilarModelIds().size() > 0)
|
373 |
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()));
|
374 |
.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x.getSimilarModelIds()));
|
| 341 |
Set<Integer> similarModelIds = similarModelMap.values().stream().flatMap(x -> x.stream()).collect(Collectors.toSet());
|
375 |
Set<Integer> similarModelIds = similarModelMap.values().stream().flatMap(x -> x.stream()).collect(Collectors.toSet());
|
| 342 |
logger.info("similarModelIds - {}", similarModelIds);
|
376 |
logger.info("similarModelIds - {}", similarModelIds);
|
| 343 |
if(similarModelIds.size() > 0) {
|
377 |
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 |
|
378 |
|
| 348 |
Map<Integer, FofoCatalogResponse> similarCatalogResponsesMap = this.getDealResponses(userInfo, webListing, 0, 300).stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
379 |
Map<Integer, FofoCatalogResponse> similarCatalogResponsesMap = this.getSimpleDocs(similarModelIds).stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
| 349 |
logger.info("Similar Catalog ResponseMap - {}", similarCatalogResponsesMap.keySet());
|
380 |
logger.info("Similar Catalog ResponseMap - {}", similarCatalogResponsesMap.keySet());
|
| 350 |
|
381 |
|
| 351 |
for (FofoCatalogResponse deal : dealResponse) {
|
382 |
for (FofoCatalogResponse deal : dealResponse) {
|
| 352 |
if (similarModelMap.containsKey(deal.getCatalogId())) {
|
383 |
if (similarModelMap.containsKey(deal.getCatalogId())) {
|
| 353 |
List<Integer> similarCatalogIds = similarModelMap.get(deal.getCatalogId());
|
384 |
List<Integer> similarCatalogIds = similarModelMap.get(deal.getCatalogId());
|
| 354 |
logger.info("Similar Catalog Ids - {}", similarCatalogIds);
|
385 |
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());
|
386 |
List<FofoCatalogResponse> similarModels = similarCatalogIds.stream().filter(x -> similarCatalogResponsesMap.containsKey(x)).map(x -> similarCatalogResponsesMap.get(x)).collect(Collectors.toList());
|
| 356 |
deal.setSimilarModels(similarModels);
|
387 |
deal.setSimilarModels(similarModels);
|
| 357 |
}
|
388 |
}
|
| 358 |
}
|
389 |
}
|
| 359 |
}
|
390 |
}
|
| 360 |
return responseSender.ok(dealResponse);
|
391 |
return responseSender.ok(dealResponse);
|
| 361 |
}
|
392 |
}
|
| 362 |
|
393 |
|
| - |
|
394 |
private List<FofoCatalogResponse> getSimpleDocs(Set<Integer> catalogIds) throws ProfitMandiBusinessException {
|
| - |
|
395 |
List<FofoCatalogResponse> fofoCatalogResponses = new ArrayList<>();
|
| - |
|
396 |
|
| - |
|
397 |
|
| - |
|
398 |
Map<String, String> params = new HashMap<>();
|
| - |
|
399 |
List<String> mandatoryQ = new ArrayList<>();
|
| - |
|
400 |
|
| - |
|
401 |
mandatoryQ.add(String.format(
|
| - |
|
402 |
"+{!parent which=\"catalogId_i:(" + StringUtils.join(catalogIds, " ") + ")\"} AND active_b:true AND show_default_b:true"));
|
| - |
|
403 |
|
| - |
|
404 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
| - |
|
405 |
params.put("fl", "*, [child parentFilter=id:catalog* childFilter=active_b:true ]");
|
| - |
|
406 |
params.put("wt", "json");
|
| - |
|
407 |
params.put("rows", catalogIds.size() + "");
|
| - |
|
408 |
try {
|
| - |
|
409 |
String response = restClient.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);
|
| - |
|
410 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
| - |
|
411 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
| - |
|
412 |
|
| - |
|
413 |
for (int i = 0; i < docs.length(); i++) {
|
| - |
|
414 |
JSONObject doc = docs.getJSONObject(i);
|
| - |
|
415 |
FofoCatalogResponse fofoCatalogResponse = this.toFofoCatalogResponse(doc);
|
| - |
|
416 |
fofoCatalogResponses.add(fofoCatalogResponse);
|
| - |
|
417 |
}
|
| - |
|
418 |
} catch (HttpHostConnectException e) {
|
| - |
|
419 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
| - |
|
420 |
}
|
| - |
|
421 |
return fofoCatalogResponses;
|
| - |
|
422 |
|
| - |
|
423 |
}
|
| - |
|
424 |
|
| - |
|
425 |
private FofoCatalogResponse toFofoCatalogResponse(JSONObject doc) {
|
| - |
|
426 |
FofoCatalogResponse fofoCatalogResponse = new FofoCatalogResponse();
|
| - |
|
427 |
fofoCatalogResponse.setCatalogId(doc.getInt("catalogId_i"));
|
| - |
|
428 |
fofoCatalogResponse.setImageUrl(doc.getString("imageUrl_s"));
|
| - |
|
429 |
fofoCatalogResponse.setTitle(doc.getString("title_s"));
|
| - |
|
430 |
fofoCatalogResponse.setMop(doc.getFloat("mop_f"));
|
| - |
|
431 |
fofoCatalogResponse.setDp(doc.getFloat("dp_f"));
|
| - |
|
432 |
fofoCatalogResponse.setBrand(doc.getJSONArray("brand_ss").getString(0));
|
| - |
|
433 |
return fofoCatalogResponse;
|
| - |
|
434 |
}
|
| - |
|
435 |
|
| 363 |
@RequestMapping(value = "/online-deals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
436 |
@RequestMapping(value = "/online-deals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 364 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
437 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 365 |
@ApiOperation(value = "Get online deals")
|
438 |
@ApiOperation(value = "Get online deals")
|
| 366 |
public ResponseEntity<?> getOnlineDeals(HttpServletRequest request, @RequestParam(value = "categoryId") String categoryId, @RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit, @RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "direction", required = false) String direction, @RequestParam(value = "filterData", required = false) String filterData) throws Throwable {
|
439 |
public ResponseEntity<?> getOnlineDeals(HttpServletRequest request, @RequestParam(value = "categoryId") String
|
| - |
|
440 |
categoryId, @RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String
|
| - |
|
441 |
limit, @RequestParam(value = "sort", required = false) String
|
| - |
|
442 |
sort, @RequestParam(value = "direction", required = false) String
|
| - |
|
443 |
direction, @RequestParam(value = "filterData", required = false) String filterData) throws Throwable {
|
| 367 |
logger.info("Request " + request.getParameterMap());
|
444 |
logger.info("Request " + request.getParameterMap());
|
| 368 |
String response = null;
|
445 |
String response = null;
|
| 369 |
int userId = (int) request.getAttribute("userId");
|
446 |
int userId = (int) request.getAttribute("userId");
|
| 370 |
|
447 |
|
| 371 |
String uri = "/deals/" + userId;
|
448 |
String uri = "/deals/" + userId;
|
| Line 411... |
Line 488... |
| 411 |
}
|
488 |
}
|
| 412 |
|
489 |
|
| 413 |
@RequestMapping(value = ProfitMandiConstants.URL_BRANDS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
490 |
@RequestMapping(value = ProfitMandiConstants.URL_BRANDS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 414 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
491 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 415 |
@ApiOperation(value = "Get brand list and count for category")
|
492 |
@ApiOperation(value = "Get brand list and count for category")
|
| 416 |
public ResponseEntity<?> getBrands(HttpServletRequest request, @RequestParam(value = "category_id") String category_id) throws ProfitMandiBusinessException {
|
493 |
public ResponseEntity<?> getBrands(HttpServletRequest request, @RequestParam(value = "category_id") String
|
| - |
|
494 |
category_id) throws ProfitMandiBusinessException {
|
| 417 |
logger.info("Request " + request.getParameterMap());
|
495 |
logger.info("Request " + request.getParameterMap());
|
| 418 |
String response = null;
|
496 |
String response = null;
|
| 419 |
// TODO: move to properties
|
497 |
// TODO: move to properties
|
| 420 |
String uri = ProfitMandiConstants.URL_BRANDS;
|
498 |
String uri = ProfitMandiConstants.URL_BRANDS;
|
| 421 |
RestClient rc = new RestClient();
|
499 |
RestClient rc = new RestClient();
|
| Line 435... |
Line 513... |
| 435 |
}
|
513 |
}
|
| 436 |
|
514 |
|
| 437 |
@RequestMapping(value = ProfitMandiConstants.URL_UNIT_DEAL, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
515 |
@RequestMapping(value = ProfitMandiConstants.URL_UNIT_DEAL, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 438 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
516 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 439 |
@ApiOperation(value = "Get unit deal object")
|
517 |
@ApiOperation(value = "Get unit deal object")
|
| 440 |
public ResponseEntity<?> getUnitDeal(HttpServletRequest request, @PathVariable(value = "id") long id) throws ProfitMandiBusinessException {
|
518 |
public ResponseEntity<?> getUnitDeal(HttpServletRequest request, @PathVariable(value = "id") long id) throws
|
| - |
|
519 |
ProfitMandiBusinessException {
|
| 441 |
String response = null;
|
520 |
String response = null;
|
| 442 |
// TODO: move to properties
|
521 |
// TODO: move to properties
|
| 443 |
String uri = "getDealById/" + id;
|
522 |
String uri = "getDealById/" + id;
|
| 444 |
System.out.println("Unit deal " + uri);
|
523 |
System.out.println("Unit deal " + uri);
|
| 445 |
RestClient rc = new RestClient();
|
524 |
RestClient rc = new RestClient();
|
| Line 465... |
Line 544... |
| 465 |
}
|
544 |
}
|
| 466 |
|
545 |
|
| 467 |
@RequestMapping(value = "/partnerdeals/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
546 |
@RequestMapping(value = "/partnerdeals/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 468 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
547 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 469 |
@ApiOperation(value = "Get unit deal object")
|
548 |
@ApiOperation(value = "Get unit deal object")
|
| 470 |
public ResponseEntity<?> getUnitFocoDeal(HttpServletRequest request, @PathVariable(value = "id") long id) throws Exception {
|
549 |
public ResponseEntity<?> getUnitFocoDeal(HttpServletRequest request, @PathVariable(value = "id") long id) throws
|
| - |
|
550 |
Exception {
|
| 471 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
551 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 472 |
List<Integer> tagIds = Arrays.asList(4);
|
552 |
List<Integer> tagIds = Arrays.asList(4);
|
| 473 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
553 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 474 |
if (roleManagerService.isPartner(userInfo.getRoleIds())) {
|
554 |
if (roleManagerService.isPartner(userInfo.getRoleIds())) {
|
| 475 |
String categoryId = "(3 OR 6)";
|
555 |
String categoryId = "(3 OR 6)";
|
| Line 500... |
Line 580... |
| 500 |
}
|
580 |
}
|
| 501 |
return responseSender.ok(dealResponse.get(0));
|
581 |
return responseSender.ok(dealResponse.get(0));
|
| 502 |
}
|
582 |
}
|
| 503 |
|
583 |
|
| 504 |
@RequestMapping(value = "/fofo/brands", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
584 |
@RequestMapping(value = "/fofo/brands", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
585 |
public ResponseEntity<?> getBrandsToDisplay(HttpServletRequest request,
|
| 505 |
public ResponseEntity<?> getBrandsToDisplay(HttpServletRequest request, @RequestParam(required = false, defaultValue = "0") int categoryId) throws Exception {
|
586 |
@RequestParam(required = false, defaultValue = "0") int categoryId) throws Exception {
|
| 506 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
587 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 507 |
logger.info("userInfo [{}]", userInfo);
|
588 |
logger.info("userInfo [{}]", userInfo);
|
| 508 |
List<BrandCatalog> brandsDisplay = brandsService.getBrandsToDisplay(categoryId);
|
589 |
List<BrandCatalog> brandsDisplay = brandsService.getBrandsToDisplay(categoryId);
|
| 509 |
//List<DBObject> brandsDisplay = mongoClient.getMongoBrands(userInfo.getRetailerId(), userInfo.getEmail(), categoryId);
|
590 |
//List<DBObject> brandsDisplay = mongoClient.getMongoBrands(userInfo.getRetailerId(), userInfo.getEmail(), categoryId);
|
| 510 |
return new ResponseEntity<>(brandsDisplay, HttpStatus.OK);
|
591 |
return new ResponseEntity<>(brandsDisplay, HttpStatus.OK);
|
| 511 |
}
|
592 |
}
|
| 512 |
|
593 |
|
| 513 |
@RequestMapping(value = "/fofo/brandCatalog", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
594 |
@RequestMapping(value = "/fofo/brandCatalog", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
595 |
public ResponseEntity<?> getBrands(HttpServletRequest request,
|
| 514 |
public ResponseEntity<?> getBrands(HttpServletRequest request, @RequestParam(required = false, defaultValue = "0") int categoryId) throws Exception {
|
596 |
@RequestParam(required = false, defaultValue = "0") int categoryId) throws Exception {
|
| 515 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
597 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 516 |
logger.info("userInfo [{}]", userInfo);
|
598 |
logger.info("userInfo [{}]", userInfo);
|
| 517 |
|
599 |
|
| 518 |
List<BrandCatalog> brandsDisplay = brandsService.getBrands(userInfo.getRetailerId(), userInfo.getEmail(), categoryId);
|
600 |
List<BrandCatalog> brandsDisplay = brandsService.getBrands(userInfo.getRetailerId(), userInfo.getEmail(), categoryId);
|
| 519 |
return new ResponseEntity<>(brandsDisplay, HttpStatus.OK);
|
601 |
return new ResponseEntity<>(brandsDisplay, HttpStatus.OK);
|
| Line 639... |
Line 721... |
| 639 |
if (webProducts.size() == 0) {
|
721 |
if (webProducts.size() == 0) {
|
| 640 |
return new ArrayList<>();
|
722 |
return new ArrayList<>();
|
| 641 |
}
|
723 |
}
|
| 642 |
|
724 |
|
| 643 |
mandatoryQ.add(String.format(
|
725 |
mandatoryQ.add(String.format(
|
| 644 |
"+{!parent which=\"catalogId_i:" + StringUtils.join(webProducts, " ") + "\"} AND active_b:true AND show_default_b:true"));
|
726 |
"+{!parent which=\"catalogId_i:(" + StringUtils.join(webProducts, " ") + ")\"} AND active_b:true AND show_default_b:true"));
|
| 645 |
|
727 |
|
| 646 |
}
|
728 |
}
|
| 647 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
729 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
| 648 |
params.put("fl", "*, [child parentFilter=id:catalog* childFilter=active_b:true ]");
|
730 |
params.put("fl", "*, [child parentFilter=id:catalog* childFilter=active_b:true ]");
|
| 649 |
|
731 |
|
| Line 670... |
Line 752... |
| 670 |
}
|
752 |
}
|
| 671 |
|
753 |
|
| 672 |
@Autowired
|
754 |
@Autowired
|
| 673 |
private SaholicCISTableRepository saholicCISTableRepository;
|
755 |
private SaholicCISTableRepository saholicCISTableRepository;
|
| 674 |
|
756 |
|
| 675 |
private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId) throws Exception {
|
757 |
private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId) throws
|
| - |
|
758 |
Exception {
|
| 676 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
759 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 677 |
List<Integer> tagIds = Arrays.asList(4);
|
760 |
List<Integer> tagIds = Arrays.asList(4);
|
| 678 |
List<Integer> itemIds = new ArrayList<>();
|
761 |
List<Integer> itemIds = new ArrayList<>();
|
| 679 |
if (docs.length() > 0) {
|
762 |
if (docs.length() > 0) {
|
| 680 |
for (int i = 0; i < docs.length(); i++) {
|
763 |
for (int i = 0; i < docs.length(); i++) {
|
| Line 710... |
Line 793... |
| 710 |
if (priceCircularItemModelNews != null) {
|
793 |
if (priceCircularItemModelNews != null) {
|
| 711 |
priceCircularItemModelMap = priceCircularItemModelNews.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
794 |
priceCircularItemModelMap = priceCircularItemModelNews.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
| 712 |
}
|
795 |
}
|
| 713 |
}
|
796 |
}
|
| 714 |
|
797 |
|
| 715 |
List<CatalogFavourite> catalogFavourites = catalogFavouriteRepository.selectBypartnerId(fofoId);
|
798 |
/*List<CatalogFavourite> catalogFavourites = catalogFavouriteRepository.selectBypartnerId(fofoId);
|
| 716 |
List<Integer> catalogFavouriteIds = new ArrayList<>();
|
799 |
List<Integer> catalogFavouriteIds = new ArrayList<>();
|
| 717 |
if (!catalogFavourites.isEmpty()) {
|
800 |
if (!catalogFavourites.isEmpty()) {
|
| 718 |
catalogFavouriteIds = catalogFavourites.stream().map(x -> x.getCatalogId()).collect(Collectors.toList());
|
801 |
catalogFavouriteIds = catalogFavourites.stream().map(x -> x.getCatalogId()).collect(Collectors.toList());
|
| 719 |
}
|
802 |
}
|
| 720 |
|
803 |
|
| 721 |
if (!catalogFavourites.isEmpty()) {
|
804 |
if (!catalogFavourites.isEmpty()) {
|
| 722 |
catalogFavourites.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
805 |
catalogFavourites.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
| 723 |
}
|
806 |
}*/
|
| 724 |
|
807 |
|
| 725 |
for (int i = 0; i < docs.length(); i++) {
|
808 |
for (int i = 0; i < docs.length(); i++) {
|
| 726 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
809 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
| 727 |
JSONObject doc = docs.getJSONObject(i);
|
810 |
JSONObject doc = docs.getJSONObject(i);
|
| 728 |
FofoCatalogResponse fofoCatalogResponse = new FofoCatalogResponse();
|
811 |
FofoCatalogResponse fofoCatalogResponse = new FofoCatalogResponse();
|
| 729 |
fofoCatalogResponse.setCatalogId(doc.getInt("catalogId_i"));
|
812 |
fofoCatalogResponse.setCatalogId(doc.getInt("catalogId_i"));
|
| 730 |
fofoCatalogResponse.setImageUrl(doc.getString("imageUrl_s"));
|
813 |
fofoCatalogResponse.setImageUrl(doc.getString("imageUrl_s"));
|
| 731 |
fofoCatalogResponse.setTitle(doc.getString("title_s"));
|
814 |
fofoCatalogResponse.setTitle(doc.getString("title_s"));
|
| 732 |
|
815 |
|
| 733 |
if (catalogFavouriteIds.contains(fofoCatalogResponse.getCatalogId())) {
|
816 |
/*if (catalogFavouriteIds.contains(fofoCatalogResponse.getCatalogId())) {
|
| 734 |
fofoCatalogResponse.setFavourite(true);
|
817 |
fofoCatalogResponse.setFavourite(true);
|
| 735 |
}
|
818 |
}*/
|
| 736 |
|
819 |
|
| 737 |
List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers().get(fofoCatalogResponse.getCatalogId());
|
820 |
List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers().get(fofoCatalogResponse.getCatalogId());
|
| 738 |
|
821 |
|
| 739 |
//logger.info("webOffers {}", webOffers);
|
822 |
//logger.info("webOffers {}", webOffers);
|
| 740 |
if (webOffers != null && webOffers.size() > 0) {
|
823 |
if (webOffers != null && webOffers.size() > 0) {
|
| Line 916... |
Line 999... |
| 916 |
}
|
999 |
}
|
| 917 |
return dealResponse;
|
1000 |
return dealResponse;
|
| 918 |
|
1001 |
|
| 919 |
}
|
1002 |
}
|
| 920 |
|
1003 |
|
| - |
|
1004 |
private List<FofoCatalogResponse> getCatalogSingleSkuResponse(JSONArray
|
| 921 |
private List<FofoCatalogResponse> getCatalogSingleSkuResponse(JSONArray docs, Map<Integer, Integer> itemFilter, boolean hotDeal) throws ProfitMandiBusinessException {
|
1005 |
docs, Map<Integer, Integer> itemFilter, boolean hotDeal) throws ProfitMandiBusinessException {
|
| 922 |
Map<Integer, TagListing> itemTagListingMap = null;
|
1006 |
Map<Integer, TagListing> itemTagListingMap = null;
|
| 923 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
1007 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 924 |
List<Integer> tagIds = Arrays.asList(4);
|
1008 |
List<Integer> tagIds = Arrays.asList(4);
|
| 925 |
|
1009 |
|
| 926 |
itemTagListingMap = tagListingRepository.selectByItemIdsAndTagIds(itemFilter.keySet(), new HashSet<>(tagIds)).stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
1010 |
itemTagListingMap = tagListingRepository.selectByItemIdsAndTagIds(itemFilter.keySet(), new HashSet<>(tagIds)).stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
| Line 995... |
Line 1079... |
| 995 |
List<ComboModel> comboModels = comboModelRepository.selectByCatalogIdAndWarehouseId(catalogId, warehouseId);
|
1079 |
List<ComboModel> comboModels = comboModelRepository.selectByCatalogIdAndWarehouseId(catalogId, warehouseId);
|
| 996 |
return responseSender.ok(comboModels);
|
1080 |
return responseSender.ok(comboModels);
|
| 997 |
}
|
1081 |
}
|
| 998 |
|
1082 |
|
| 999 |
@RequestMapping(value = "/checkCombo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
1083 |
@RequestMapping(value = "/checkCombo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 1000 |
public ResponseEntity<?> checkCombo(HttpServletRequest request, @RequestParam int catalogId, @RequestParam int warehouseId, @RequestParam int qty) throws Exception {
|
1084 |
public ResponseEntity<?> checkCombo(HttpServletRequest request, @RequestParam int catalogId,
|
| - |
|
1085 |
@RequestParam int warehouseId, @RequestParam int qty) throws Exception {
|
| 1001 |
boolean isCombo = false;
|
1086 |
boolean isCombo = false;
|
| 1002 |
ComboModel comboModel = comboModelRepository.selectByCatalogIdWarehouseIdAndQty(catalogId, warehouseId, qty);
|
1087 |
ComboModel comboModel = comboModelRepository.selectByCatalogIdWarehouseIdAndQty(catalogId, warehouseId, qty);
|
| 1003 |
if (comboModel != null) {
|
1088 |
if (comboModel != null) {
|
| 1004 |
isCombo = true;
|
1089 |
isCombo = true;
|
| 1005 |
}
|
1090 |
}
|