| Line 73... |
Line 73... |
| 73 |
import com.spice.profitmandi.dao.model.AddCartRequest;
|
73 |
import com.spice.profitmandi.dao.model.AddCartRequest;
|
| 74 |
import com.spice.profitmandi.dao.model.CartItem;
|
74 |
import com.spice.profitmandi.dao.model.CartItem;
|
| 75 |
import com.spice.profitmandi.dao.model.CartItemResponseModel;
|
75 |
import com.spice.profitmandi.dao.model.CartItemResponseModel;
|
| 76 |
import com.spice.profitmandi.dao.model.CartResponse;
|
76 |
import com.spice.profitmandi.dao.model.CartResponse;
|
| 77 |
import com.spice.profitmandi.dao.model.CustomerOrderDetail;
|
77 |
import com.spice.profitmandi.dao.model.CustomerOrderDetail;
|
| 78 |
import com.spice.profitmandi.dao.model.UserCart;
|
- |
|
| 79 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
78 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 80 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
79 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 81 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
80 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 82 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
81 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 83 |
import com.spice.profitmandi.dao.repository.dtr.WebListingRepository;
|
82 |
import com.spice.profitmandi.dao.repository.dtr.WebListingRepository;
|
| Line 209... |
Line 208... |
| 209 |
@Autowired
|
208 |
@Autowired
|
| 210 |
JavaMailSender mailSender;
|
209 |
JavaMailSender mailSender;
|
| 211 |
|
210 |
|
| 212 |
List<String> filterableParams = Arrays.asList("brand");
|
211 |
List<String> filterableParams = Arrays.asList("brand");
|
| 213 |
|
212 |
|
| 214 |
/*
|
- |
|
| 215 |
* @ApiImplicitParams({
|
- |
|
| 216 |
*
|
- |
|
| 217 |
* @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true,
|
- |
|
| 218 |
* dataType = "string", paramType = "header") })
|
- |
|
| 219 |
*
|
- |
|
| 220 |
* @RequestMapping(value = "/store/fofo", method = RequestMethod.GET, produces =
|
- |
|
| 221 |
* MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?>
|
- |
|
| 222 |
* getFofo(HttpServletRequest request,
|
- |
|
| 223 |
*
|
- |
|
| 224 |
* @RequestParam(value = "categoryId", required = false, defaultValue =
|
- |
|
| 225 |
* "(3 OR 6)") String categoryId,
|
- |
|
| 226 |
*
|
- |
|
| 227 |
* @RequestParam(value = "offset") String offset, @RequestParam(value = "limit")
|
- |
|
| 228 |
* String limit,
|
- |
|
| 229 |
*
|
- |
|
| 230 |
* @RequestParam(value = "sort", required = false) String sort,
|
- |
|
| 231 |
*
|
- |
|
| 232 |
* @RequestParam(value = "brand", required = false) String brand,
|
- |
|
| 233 |
*
|
- |
|
| 234 |
* @RequestParam(value = "subCategoryId", required = false) int subCategoryId,
|
- |
|
| 235 |
*
|
- |
|
| 236 |
* @RequestParam(value = "q", required = false) String queryTerm,
|
- |
|
| 237 |
*
|
- |
|
| 238 |
* @RequestParam(value = "hotDeal", required = false) boolean hotDeal) throws
|
- |
|
| 239 |
* Throwable { List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
- |
|
| 240 |
* UserInfo userInfo = (UserInfo) request.getAttribute("userInfo"); if
|
- |
|
| 241 |
* (roleManagerService.isPartner(userInfo.getRoleIds())) { // UserCart uc =
|
- |
|
| 242 |
* userAccountRepository.getUserCart(userInfo.getUserId()); RestClient rc = new
|
- |
|
| 243 |
* RestClient(); Map<String, String> params = new HashMap<>(); List<String>
|
- |
|
| 244 |
* mandatoryQ = new ArrayList<>(); if (queryTerm != null &&
|
- |
|
| 245 |
* !queryTerm.equals("null")) { mandatoryQ.add(String.format("+(%s)",
|
- |
|
| 246 |
* queryTerm)); } else { queryTerm = null; } if (subCategoryId != 0) {
|
- |
|
| 247 |
* mandatoryQ .add(String.
|
- |
|
| 248 |
* format("+(subCategoryId_i:%s) +{!parent which=\"subCategoryId_i:%s\"} tagId_i:(%s)"
|
- |
|
| 249 |
* , subCategoryId, subCategoryId, StringUtils.join(TAG_IDS, " "))); } else if
|
- |
|
| 250 |
* (hotDeal) { mandatoryQ.add(String.
|
- |
|
| 251 |
* format("+{!parent which=\"hot_deals_b=true\"} tagId_i:(%s)",
|
- |
|
| 252 |
* StringUtils.join(TAG_IDS, " ")));
|
- |
|
| 253 |
*
|
- |
|
| 254 |
* } else if (StringUtils.isNotBlank(brand)) { mandatoryQ.add( String.
|
- |
|
| 255 |
* format("+(categoryId_i:%s) +(brand_ss:%s) +{!parent which=\"brand_ss:%s\"} tagId_i:(%s)"
|
- |
|
| 256 |
* , categoryId, brand, brand, StringUtils.join(TAG_IDS, " ")));
|
- |
|
| 257 |
*
|
- |
|
| 258 |
* } else { mandatoryQ.add(
|
- |
|
| 259 |
* String.format("+{!parent which=\"id:catalog*\"} tagId_i:(%s)",
|
- |
|
| 260 |
* StringUtils.join(TAG_IDS, " "))); } params.put("q",
|
- |
|
| 261 |
* StringUtils.join(mandatoryQ, " ")); params.put("fl",
|
- |
|
| 262 |
* "*, [child parentFilter=id:catalog*]"); if (queryTerm == null) {
|
- |
|
| 263 |
* params.put("sort", "create_s desc"); } params.put("start",
|
- |
|
| 264 |
* String.valueOf(offset)); params.put("rows", String.valueOf(limit));
|
- |
|
| 265 |
* params.put("wt", "json"); String response = null; try { response =
|
- |
|
| 266 |
* rc.get(SchemeType.HTTP, "50.116.10.120", 8984, "solr/demo/select", params); }
|
- |
|
| 267 |
* catch (HttpHostConnectException e) { throw new
|
- |
|
| 268 |
* ProfitMandiBusinessException("", "", "Could not connect to host"); }
|
- |
|
| 269 |
* JSONObject solrResponseJSONObj = new
|
- |
|
| 270 |
* JSONObject(response).getJSONObject("response"); JSONArray docs =
|
- |
|
| 271 |
* solrResponseJSONObj.getJSONArray("docs"); dealResponse =
|
- |
|
| 272 |
* getCatalogResponse(docs, false, userInfo.getRetailerId());
|
- |
|
| 273 |
*
|
- |
|
| 274 |
* if (Mongo.PARTNER_BLoCKED_BRANDS.containsKey(userInfo.getEmail())) {
|
- |
|
| 275 |
* dealResponse.stream() .filter(x ->
|
- |
|
| 276 |
* Mongo.PARTNER_BLoCKED_BRANDS.get(userInfo.getEmail()).contains(x.getBrand()))
|
- |
|
| 277 |
* ; }
|
- |
|
| 278 |
*
|
- |
|
| 279 |
* } else { return responseSender.badRequest( new
|
- |
|
| 280 |
* ProfitMandiBusinessException("Retailer id", userInfo.getUserId(),
|
- |
|
| 281 |
* "NOT_FOFO_RETAILER")); } return responseSender.ok(dealResponse); }
|
- |
|
| 282 |
*/
|
- |
|
| 283 |
|
213 |
|
| 284 |
@RequestMapping(value = "/store/entity/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
214 |
@RequestMapping(value = "/store/entity/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 285 |
@ApiImplicitParams({
|
215 |
@ApiImplicitParams({
|
| 286 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
216 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 287 |
@ApiOperation(value = "Get unit deal object")
|
217 |
@ApiOperation(value = "Get unit deal object")
|
| Line 354... |
Line 284... |
| 354 |
return responseSender.ok(dealBrandsResponse);
|
284 |
return responseSender.ok(dealBrandsResponse);
|
| 355 |
}
|
285 |
}
|
| 356 |
|
286 |
|
| 357 |
@RequestMapping(value = "/store/listing/{listingUrl}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
287 |
@RequestMapping(value = "/store/listing/{listingUrl}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 358 |
public ResponseEntity<?> bestSellers(HttpServletRequest request, @PathVariable String listingUrl) throws Exception {
|
288 |
public ResponseEntity<?> bestSellers(HttpServletRequest request, @PathVariable String listingUrl) throws Exception {
|
| 359 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
- |
|
| 360 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
289 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 361 |
List<Integer> tagIds = Arrays.asList(4);
|
- |
|
| 362 |
|
- |
|
| 363 |
WebListing webListing = webListingRepository.selectByUrl("url");
|
290 |
WebListing webListing = webListingRepository.selectByUrl(listingUrl);
|
| 364 |
if (webListing == null) {
|
- |
|
| 365 |
throw new ProfitMandiBusinessException("Url", listingUrl, "Could not find the Url");
|
- |
|
| 366 |
}
|
- |
|
| 367 |
List<Integer> webProducts = webProductListingRepository.selectAllByWebListingId(webListing.getId()).stream()
|
- |
|
| 368 |
.filter(x -> x.getRank() > 0).map(x -> x.getEntityId()).collect(Collectors.toList());
|
- |
|
| 369 |
|
- |
|
| 370 |
RestClient rc = new RestClient();
|
- |
|
| 371 |
Map<String, String> params = new HashMap<>();
|
- |
|
| 372 |
List<String> mandatoryQ = new ArrayList<>();
|
- |
|
| 373 |
mandatoryQ.add(String.format(
|
- |
|
| 374 |
"+{!parent which=\"catalogId_i:" + StringUtils.join(webProducts, " ") + "\"} tagId_i:(%s)",
|
- |
|
| 375 |
StringUtils.join(tagIds, " ")));
|
- |
|
| 376 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
- |
|
| 377 |
params.put("fl", "*, [child parentFilter=id:catalog*]");
|
- |
|
| 378 |
// params.put("sort", "create_s desc");
|
- |
|
| 379 |
params.put("start", String.valueOf(0));
|
- |
|
| 380 |
params.put("rows", String.valueOf(100));
|
- |
|
| 381 |
params.put("wt", "json");
|
- |
|
| 382 |
String response = null;
|
- |
|
| 383 |
try {
|
- |
|
| 384 |
response = rc.get(SchemeType.HTTP, "50.116.10.120", 8984, "solr/demo/select", params);
|
- |
|
| 385 |
} catch (HttpHostConnectException e) {
|
- |
|
| 386 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
- |
|
| 387 |
}
|
- |
|
| 388 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
- |
|
| 389 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
- |
|
| 390 |
final Ordering<Integer> rankOrdering = Ordering.explicit(webProducts);
|
- |
|
| 391 |
dealResponse = getCatalogResponse(docs, false, userInfo.getRetailerId()).stream()
|
- |
|
| 392 |
.sorted(new Comparator<FofoCatalogResponse>() {
|
- |
|
| 393 |
@Override
|
- |
|
| 394 |
public int compare(FofoCatalogResponse o1, FofoCatalogResponse o2) {
|
- |
|
| 395 |
return rankOrdering.compare(o1.getCatalogId(), o2.getCatalogId());
|
- |
|
| 396 |
}
|
- |
|
| 397 |
}).collect(Collectors.toList());
|
- |
|
| 398 |
webListing.setFofoCatalogResponses(dealResponse);
|
291 |
webListing.setFofoCatalogResponses(getDealResponses(userInfo, webListing));
|
| 399 |
return responseSender.ok(webListing);
|
292 |
return responseSender.ok(webListing);
|
| 400 |
}
|
293 |
}
|
| 401 |
|
294 |
|
| 402 |
@RequestMapping(value = "/store/otp/generateOTP", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
295 |
@RequestMapping(value = "/store/otp/generateOTP", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 403 |
public ResponseEntity<?> generateOtp(HttpServletRequest request, @RequestParam String mobile) throws Exception {
|
296 |
public ResponseEntity<?> generateOtp(HttpServletRequest request, @RequestParam String mobile) throws Exception {
|
| Line 491... |
Line 384... |
| 491 |
public ResponseEntity<?> getStoresByPincode(HttpServletRequest request, @PathVariable String pincode)
|
384 |
public ResponseEntity<?> getStoresByPincode(HttpServletRequest request, @PathVariable String pincode)
|
| 492 |
throws Exception {
|
385 |
throws Exception {
|
| 493 |
List<PincodePartner> pincodePartners = pincodePartnerRepository.selectPartnersByPincode(pincode);
|
386 |
List<PincodePartner> pincodePartners = pincodePartnerRepository.selectPartnersByPincode(pincode);
|
| 494 |
int fofoId = DEFAULT_STORE;
|
387 |
int fofoId = DEFAULT_STORE;
|
| 495 |
if (pincodePartners.size() > 0) {
|
388 |
if (pincodePartners.size() > 0) {
|
| 496 |
List<Integer> fofoIds = pincodePartners.stream().map(x->x.getFofoId()).collect(Collectors.toList());
|
389 |
List<Integer> fofoIds = pincodePartners.stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
| 497 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActivePartnersByRetailerIds(fofoIds);
|
390 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActivePartnersByRetailerIds(fofoIds);
|
| 498 |
if(fofoStores.size() > 0) {
|
391 |
if (fofoStores.size() > 0) {
|
| 499 |
fofoId = fofoStores.get(0).getId();
|
392 |
fofoId = fofoStores.get(0).getId();
|
| 500 |
}
|
393 |
}
|
| 501 |
|
394 |
|
| 502 |
}
|
395 |
}
|
| 503 |
return responseSender.ok(fofoStoreRepository.selectByRetailerId(fofoId).getCode());
|
396 |
return responseSender.ok(fofoStoreRepository.selectByRetailerId(fofoId).getCode());
|
| 504 |
}
|
397 |
}
|
| 505 |
|
398 |
|
| 506 |
@RequestMapping(value = "/store/order", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
399 |
@RequestMapping(value = "/store/order", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| Line 550... |
Line 443... |
| 550 |
|
443 |
|
| 551 |
@RequestMapping(value = "/store/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
444 |
@RequestMapping(value = "/store/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 552 |
@Cacheable(value = "storelisting.all", cacheManager = "thirtyMinsTimeOutCacheManager")
|
445 |
@Cacheable(value = "storelisting.all", cacheManager = "thirtyMinsTimeOutCacheManager")
|
| 553 |
public ResponseEntity<?> getStoresListing(HttpServletRequest request) throws Exception {
|
446 |
public ResponseEntity<?> getStoresListing(HttpServletRequest request) throws Exception {
|
| 554 |
List<WebListing> webListings = webListingRepository.selectAllWebListing(Optional.of(true));
|
447 |
List<WebListing> webListings = webListingRepository.selectAllWebListing(Optional.of(true));
|
| - |
|
448 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 555 |
for (WebListing webListing : webListings) {
|
449 |
for (WebListing webListing : webListings) {
|
| 556 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
- |
|
| 557 |
Integer storeId = userInfo.getRetailerId();
|
- |
|
| 558 |
|
- |
|
| 559 |
List<Integer> webProducts = webProductListingRepository.selectAllByWebListingId(webListing.getId()).stream()
|
- |
|
| 560 |
.filter(x -> x.getRank() > 0).map(x -> x.getEntityId()).collect(Collectors.toList());
|
- |
|
| 561 |
if(webProducts.size() == 0) {
|
- |
|
| 562 |
logger.info("Could not add the listing");
|
- |
|
| 563 |
continue;
|
- |
|
| 564 |
}
|
- |
|
| 565 |
RestClient rc = new RestClient();
|
- |
|
| 566 |
Map<String, String> params = new HashMap<>();
|
- |
|
| 567 |
List<String> mandatoryQ = new ArrayList<>();
|
- |
|
| 568 |
mandatoryQ.add(String.format(
|
- |
|
| 569 |
"+{!parent which=\"catalogId_i:" + StringUtils.join(webProducts, " ") + "\"} tagId_i:(%s)",
|
- |
|
| 570 |
StringUtils.join(TAG_IDS, " ")));
|
- |
|
| 571 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
- |
|
| 572 |
params.put("fl", "*, [child parentFilter=id:catalog*]");
|
- |
|
| 573 |
// params.put("sort", "create_s desc");
|
- |
|
| 574 |
params.put("start", String.valueOf(0));
|
- |
|
| 575 |
params.put("rows", String.valueOf(100));
|
- |
|
| 576 |
params.put("wt", "json");
|
- |
|
| 577 |
String response = null;
|
- |
|
| 578 |
try {
|
- |
|
| 579 |
response = rc.get(SchemeType.HTTP, "50.116.10.120", 8984, "solr/demo/select", params);
|
- |
|
| 580 |
} catch (HttpHostConnectException e) {
|
- |
|
| 581 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
- |
|
| 582 |
}
|
- |
|
| 583 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
- |
|
| 584 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
- |
|
| 585 |
//final Ordering<Integer> colorOrdering = Ordering.explicit(webProducts);
|
- |
|
| 586 |
List<FofoCatalogResponse> dealResponse = getCatalogResponse(docs, false, userInfo.getRetailerId());
|
- |
|
| 587 |
/* .stream()
|
- |
|
| 588 |
.sorted(new Comparator<FofoCatalogResponse>() {
|
- |
|
| 589 |
@Override
|
- |
|
| 590 |
public int compare(FofoCatalogResponse o1, FofoCatalogResponse o2) {
|
- |
|
| 591 |
return colorOrdering.compare(o1.getCatalogId(), o2.getCatalogId());
|
- |
|
| 592 |
}
|
- |
|
| 593 |
}).collect(Collectors.toList());*/
|
- |
|
| 594 |
webListing.setFofoCatalogResponses(dealResponse);
|
450 |
webListing.setFofoCatalogResponses(getDealResponses(userInfo, webListing));
|
| 595 |
}
|
451 |
}
|
| 596 |
return responseSender.ok(webListings);
|
452 |
return responseSender.ok(webListings);
|
| 597 |
}
|
453 |
}
|
| 598 |
|
454 |
|
| - |
|
455 |
private List<FofoCatalogResponse> getDealResponses(UserInfo userInfo, WebListing webListing)
|
| - |
|
456 |
throws ProfitMandiBusinessException {
|
| - |
|
457 |
List<Integer> webProducts = webProductListingRepository.selectAllByWebListingId(webListing.getId()).stream()
|
| - |
|
458 |
.filter(x -> x.getRank() > 0).map(x -> x.getEntityId()).collect(Collectors.toList());
|
| - |
|
459 |
if (webProducts.size() == 0) {
|
| - |
|
460 |
return new ArrayList<>();
|
| - |
|
461 |
}
|
| - |
|
462 |
RestClient rc = new RestClient();
|
| - |
|
463 |
Map<String, String> params = new HashMap<>();
|
| - |
|
464 |
List<String> mandatoryQ = new ArrayList<>();
|
| - |
|
465 |
mandatoryQ.add(String.format(
|
| - |
|
466 |
"+{!parent which=\"catalogId_i:" + StringUtils.join(webProducts, " ") + "\"} tagId_i:(%s)",
|
| - |
|
467 |
StringUtils.join(TAG_IDS, " ")));
|
| - |
|
468 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
| - |
|
469 |
params.put("fl", "*, [child parentFilter=id:catalog*]");
|
| - |
|
470 |
// params.put("sort", "create_s desc");
|
| - |
|
471 |
params.put("start", String.valueOf(0));
|
| - |
|
472 |
params.put("rows", String.valueOf(100));
|
| - |
|
473 |
params.put("wt", "json");
|
| - |
|
474 |
String response = null;
|
| - |
|
475 |
try {
|
| - |
|
476 |
response = rc.get(SchemeType.HTTP, "50.116.10.120", 8984, "solr/demo/select", params);
|
| - |
|
477 |
} catch (HttpHostConnectException e) {
|
| - |
|
478 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
| - |
|
479 |
}
|
| - |
|
480 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
| - |
|
481 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
| - |
|
482 |
List<FofoCatalogResponse> dealResponse = getCatalogResponse(docs, false, userInfo.getRetailerId());
|
| - |
|
483 |
return dealResponse;
|
| - |
|
484 |
}
|
| - |
|
485 |
|
| 599 |
@RequestMapping(value = "/store/cart", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
486 |
@RequestMapping(value = "/store/cart", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 600 |
@ApiImplicitParams({
|
487 |
@ApiImplicitParams({
|
| 601 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
488 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 602 |
@ApiOperation(value = "Get brand list and count for category")
|
489 |
@ApiOperation(value = "Get brand list and count for category")
|
| 603 |
public ResponseEntity<?> cart(HttpServletRequest request, @RequestBody AddCartRequest cartRequest)
|
490 |
public ResponseEntity<?> cart(HttpServletRequest request, @RequestBody AddCartRequest cartRequest)
|
| Line 709... |
Line 596... |
| 709 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
596 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
| 710 |
@RequestParam(value = "sort", required = false) String sort,
|
597 |
@RequestParam(value = "sort", required = false) String sort,
|
| 711 |
@RequestParam(value = "brand", required = false) String brand,
|
598 |
@RequestParam(value = "brand", required = false) String brand,
|
| 712 |
@RequestParam(value = "subCategoryId", required = false) int subCategoryId,
|
599 |
@RequestParam(value = "subCategoryId", required = false) int subCategoryId,
|
| 713 |
@RequestParam(value = "q", required = false) String queryTerm,
|
600 |
@RequestParam(value = "q", required = false) String queryTerm,
|
| - |
|
601 |
@RequestParam(required = false) String listing,
|
| 714 |
@RequestParam(required = false, defaultValue = "true") boolean partnerStockOnly)
|
602 |
@RequestParam(required = false, defaultValue = "true") boolean partnerStockOnly) throws Throwable {
|
| 715 |
throws Throwable {
|
- |
|
| 716 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
603 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 717 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
604 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 718 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
|
605 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
|
| 719 |
sort = "w" + fs.getWarehouseId() + "_i desc";
|
606 |
sort = "w" + fs.getWarehouseId() + "_i desc";
|
| 720 |
dealResponse = this.getCatalogResponse(
|
607 |
dealResponse = this.getCatalogResponse(
|
| Line 746... |
Line 633... |
| 746 |
}
|
633 |
}
|
| 747 |
if (fofoId > 0) {
|
634 |
if (fofoId > 0) {
|
| 748 |
partnerStockAvailabilityMap = currentInventorySnapshotRepository.selectItemsStock(fofoId).stream()
|
635 |
partnerStockAvailabilityMap = currentInventorySnapshotRepository.selectItemsStock(fofoId).stream()
|
| 749 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|
636 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|
| 750 |
}
|
637 |
}
|
| 751 |
ourItemAvailabilityMap = saholicInventoryService
|
- |
|
| 752 |
.getTotalAvailabilityByItemIds(new ArrayList<>(itemsSet));
|
638 |
ourItemAvailabilityMap = saholicInventoryService.getTotalAvailabilityByItemIds(new ArrayList<>(itemsSet));
|
| 753 |
}
|
639 |
}
|
| 754 |
|
640 |
|
| 755 |
for (int i = 0; i < docs.length(); i++) {
|
641 |
for (int i = 0; i < docs.length(); i++) {
|
| 756 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
642 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
| 757 |
JSONObject doc = docs.getJSONObject(i);
|
643 |
JSONObject doc = docs.getJSONObject(i);
|
| Line 787... |
Line 673... |
| 787 |
fdi.setItem_id(itemId);
|
673 |
fdi.setItem_id(itemId);
|
| 788 |
Float cashBack = schemeService.getItemSchemeCashBack().get(itemId);
|
674 |
Float cashBack = schemeService.getItemSchemeCashBack().get(itemId);
|
| 789 |
cashBack = cashBack == null ? 0 : cashBack;
|
675 |
cashBack = cashBack == null ? 0 : cashBack;
|
| 790 |
fdi.setCashback(cashBack);
|
676 |
fdi.setCashback(cashBack);
|
| 791 |
fdi.setMinBuyQuantity(1);
|
677 |
fdi.setMinBuyQuantity(1);
|
| 792 |
int ourStockAvailability = ourItemAvailabilityMap.get(itemId) == null ? 0 : Math.max(0,ourItemAvailabilityMap.get(itemId));
|
678 |
int ourStockAvailability = ourItemAvailabilityMap.get(itemId) == null ? 0
|
| - |
|
679 |
: Math.max(0, ourItemAvailabilityMap.get(itemId));
|
| 793 |
int partnerAvailability = partnerStockAvailabilityMap.get(itemId) == null ? 0
|
680 |
int partnerAvailability = partnerStockAvailabilityMap.get(itemId) == null ? 0
|
| 794 |
: partnerStockAvailabilityMap.get(itemId);
|
681 |
: partnerStockAvailabilityMap.get(itemId);
|
| 795 |
fdi.setAvailability(Math.min(5,ourStockAvailability + partnerAvailability));
|
682 |
fdi.setAvailability(Math.min(5, ourStockAvailability + partnerAvailability));
|
| 796 |
fdi.setQuantityStep(1);
|
683 |
fdi.setQuantityStep(1);
|
| 797 |
fdi.setMaxQuantity(fdi.getAvailability());
|
684 |
fdi.setMaxQuantity(fdi.getAvailability());
|
| 798 |
fofoAvailabilityInfoMap.put(itemId, fdi);
|
685 |
fofoAvailabilityInfoMap.put(itemId, fdi);
|
| 799 |
}
|
686 |
}
|
| 800 |
}
|
687 |
}
|
| Line 803... |
Line 690... |
| 803 |
ffdr.setItems(fofoAvailabilityInfoMap.values().stream()
|
690 |
ffdr.setItems(fofoAvailabilityInfoMap.values().stream()
|
| 804 |
.sorted((x, y) -> y.getAvailability() - x.getAvailability()).collect(Collectors.toList()));
|
691 |
.sorted((x, y) -> y.getAvailability() - x.getAvailability()).collect(Collectors.toList()));
|
| 805 |
dealResponse.add(ffdr);
|
692 |
dealResponse.add(ffdr);
|
| 806 |
}
|
693 |
}
|
| 807 |
}
|
694 |
}
|
| 808 |
return dealResponse.stream().sorted((x,y)-> {
|
695 |
return dealResponse.stream().sorted((x, y) -> {
|
| 809 |
return Math.min(y.getItems().get(0).getAvailability(),1) - Math.min(x.getItems().get(0).getAvailability(),1);
|
696 |
return Math.min(y.getItems().get(0).getAvailability(), 1)
|
| - |
|
697 |
- Math.min(x.getItems().get(0).getAvailability(), 1);
|
| 810 |
}).collect(Collectors.toList());
|
698 |
}).collect(Collectors.toList());
|
| 811 |
|
699 |
|
| 812 |
}
|
700 |
}
|
| 813 |
|
701 |
|
| 814 |
@GetMapping(value = "store/order-status/{pendingOrderId}")
|
702 |
@GetMapping(value = "store/order-status/{pendingOrderId}")
|
| Line 851... |
Line 739... |
| 851 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(pendingOrder.getFofoId());
|
739 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(pendingOrder.getFofoId());
|
| 852 |
Customer customer = customerRepository.selectById(pendingOrder.getCustomerId());
|
740 |
Customer customer = customerRepository.selectById(pendingOrder.getCustomerId());
|
| 853 |
MimeMessage message = mailSender.createMimeMessage();
|
741 |
MimeMessage message = mailSender.createMimeMessage();
|
| 854 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
742 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
| 855 |
if (!customer.getEmailId().equals(null)) {
|
743 |
if (!customer.getEmailId().equals(null)) {
|
| 856 |
String[] email = {customer.getEmailId() };
|
744 |
String[] email = { customer.getEmailId() };
|
| 857 |
helper.setTo(email);
|
745 |
helper.setTo(email);
|
| 858 |
}
|
746 |
}
|
| 859 |
String[] bccemail = { customRetailer.getEmail(), "tejbeer.kaur@shop2020.in", "tarun.verma@smartdukaan.com" };
|
747 |
String[] bccemail = { customRetailer.getEmail(), "tejbeer.kaur@shop2020.in", "tarun.verma@smartdukaan.com" };
|
| 860 |
helper.setSubject(subject);
|
748 |
helper.setSubject(subject);
|
| 861 |
helper.setBcc(bccemail);
|
749 |
helper.setBcc(bccemail);
|