| Line 25... |
Line 25... |
| 25 |
import org.springframework.cache.annotation.Cacheable;
|
25 |
import org.springframework.cache.annotation.Cacheable;
|
| 26 |
import org.springframework.http.MediaType;
|
26 |
import org.springframework.http.MediaType;
|
| 27 |
import org.springframework.http.ResponseEntity;
|
27 |
import org.springframework.http.ResponseEntity;
|
| 28 |
import org.springframework.stereotype.Controller;
|
28 |
import org.springframework.stereotype.Controller;
|
| 29 |
import org.springframework.transaction.annotation.Transactional;
|
29 |
import org.springframework.transaction.annotation.Transactional;
|
| - |
|
30 |
import org.springframework.web.bind.annotation.GetMapping;
|
| 30 |
import org.springframework.web.bind.annotation.PathVariable;
|
31 |
import org.springframework.web.bind.annotation.PathVariable;
|
| - |
|
32 |
import org.springframework.web.bind.annotation.PostMapping;
|
| 31 |
import org.springframework.web.bind.annotation.RequestBody;
|
33 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 32 |
import org.springframework.web.bind.annotation.RequestMapping;
|
34 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 33 |
import org.springframework.web.bind.annotation.RequestMethod;
|
35 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 34 |
import org.springframework.web.bind.annotation.RequestParam;
|
36 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 35 |
|
37 |
|
| Line 38... |
Line 40... |
| 38 |
import com.google.common.collect.Ordering;
|
40 |
import com.google.common.collect.Ordering;
|
| 39 |
import com.google.gson.Gson;
|
41 |
import com.google.gson.Gson;
|
| 40 |
import com.google.gson.reflect.TypeToken;
|
42 |
import com.google.gson.reflect.TypeToken;
|
| 41 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
43 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
| 42 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
44 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
45 |
import com.spice.profitmandi.common.model.CreatePendingOrderItem;
|
| 43 |
import com.spice.profitmandi.common.model.CreatePendingOrderRequest;
|
46 |
import com.spice.profitmandi.common.model.CreatePendingOrderRequest;
|
| 44 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
47 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 45 |
import com.spice.profitmandi.common.model.CustomerOrderDetail;
|
48 |
import com.spice.profitmandi.common.model.CustomerOrderDetail;
|
| 46 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
49 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 47 |
import com.spice.profitmandi.common.model.UserInfo;
|
50 |
import com.spice.profitmandi.common.model.UserInfo;
|
| Line 55... |
Line 58... |
| 55 |
import com.spice.profitmandi.dao.entity.fofo.Customer;
|
58 |
import com.spice.profitmandi.dao.entity.fofo.Customer;
|
| 56 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
59 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
| 57 |
import com.spice.profitmandi.dao.entity.fofo.PendingOrder;
|
60 |
import com.spice.profitmandi.dao.entity.fofo.PendingOrder;
|
| 58 |
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
|
61 |
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
|
| 59 |
import com.spice.profitmandi.dao.entity.fofo.PincodePartner;
|
62 |
import com.spice.profitmandi.dao.entity.fofo.PincodePartner;
|
| 60 |
import com.spice.profitmandi.dao.entity.inventory.ItemAvailabilityCache;
|
- |
|
| 61 |
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
|
63 |
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
|
| 62 |
import com.spice.profitmandi.dao.model.AddCartRequest;
|
64 |
import com.spice.profitmandi.dao.model.AddCartRequest;
|
| 63 |
import com.spice.profitmandi.dao.model.CartItem;
|
65 |
import com.spice.profitmandi.dao.model.CartItem;
|
| 64 |
import com.spice.profitmandi.dao.model.CartItemResponseModel;
|
66 |
import com.spice.profitmandi.dao.model.CartItemResponseModel;
|
| 65 |
import com.spice.profitmandi.dao.model.CartResponse;
|
67 |
import com.spice.profitmandi.dao.model.CartResponse;
|
| Line 76... |
Line 78... |
| 76 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderService;
|
78 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderService;
|
| 77 |
import com.spice.profitmandi.dao.repository.fofo.PincodePartnerRepository;
|
79 |
import com.spice.profitmandi.dao.repository.fofo.PincodePartnerRepository;
|
| 78 |
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
|
80 |
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
|
| 79 |
import com.spice.profitmandi.service.CustomerService;
|
81 |
import com.spice.profitmandi.service.CustomerService;
|
| 80 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
82 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| - |
|
83 |
import com.spice.profitmandi.service.inventory.AvailabilityModel;
|
| 81 |
import com.spice.profitmandi.service.inventory.FofoAvailabilityInfo;
|
84 |
import com.spice.profitmandi.service.inventory.FofoAvailabilityInfo;
|
| 82 |
import com.spice.profitmandi.service.inventory.FofoCatalogResponse;
|
85 |
import com.spice.profitmandi.service.inventory.FofoCatalogResponse;
|
| - |
|
86 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 83 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
87 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
| 84 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
88 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 85 |
import com.spice.profitmandi.service.user.RetailerService;
|
89 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 86 |
import com.spice.profitmandi.web.processor.OtpProcessor;
|
90 |
import com.spice.profitmandi.web.processor.OtpProcessor;
|
| 87 |
import com.spice.profitmandi.web.res.DealBrands;
|
91 |
import com.spice.profitmandi.web.res.DealBrands;
|
| Line 106... |
Line 110... |
| 106 |
private static final int DEFAULT_STORE = 171912487;
|
110 |
private static final int DEFAULT_STORE = 171912487;
|
| 107 |
|
111 |
|
| 108 |
@Autowired
|
112 |
@Autowired
|
| 109 |
CustomerAddressRepository customerAddressRepository;
|
113 |
CustomerAddressRepository customerAddressRepository;
|
| 110 |
|
114 |
|
| - |
|
115 |
@Autowired
|
| - |
|
116 |
InventoryService inventoryService;
|
| - |
|
117 |
|
| 111 |
@Value("${python.api.host}")
|
118 |
@Value("${python.api.host}")
|
| 112 |
private String host;
|
119 |
private String host;
|
| 113 |
|
120 |
|
| 114 |
@Autowired
|
121 |
@Autowired
|
| 115 |
CustomerService customerService;
|
122 |
CustomerService customerService;
|
| 116 |
|
123 |
|
| 117 |
@Value("${python.api.port}")
|
124 |
@Value("${python.api.port}")
|
| 118 |
private int port;
|
125 |
private int port;
|
| 119 |
|
126 |
|
| 120 |
@Autowired
|
127 |
@Autowired
|
| 121 |
private SaholicInventoryService saholicInventoryService;
|
128 |
private SaholicInventoryService saholicInventoryService;
|
| 122 |
|
129 |
|
| 123 |
// This is now unused as we are not supporting multiple companies.
|
130 |
// This is now unused as we are not supporting multiple companies.
|
| 124 |
@Value("${gadgetCops.invoice.cc}")
|
131 |
@Value("${gadgetCops.invoice.cc}")
|
| Line 355... |
Line 362... |
| 355 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
362 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
| 356 |
}
|
363 |
}
|
| 357 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
364 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
| 358 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
365 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
| 359 |
final Ordering<Integer> rankOrdering = Ordering.explicit(webProducts);
|
366 |
final Ordering<Integer> rankOrdering = Ordering.explicit(webProducts);
|
| 360 |
dealResponse = getCatalogResponse(docs, false, userInfo.getRetailerId()).stream().sorted(new Comparator<FofoCatalogResponse>() {
|
367 |
dealResponse = getCatalogResponse(docs, false, userInfo.getRetailerId()).stream()
|
| - |
|
368 |
.sorted(new Comparator<FofoCatalogResponse>() {
|
| 361 |
@Override
|
369 |
@Override
|
| 362 |
public int compare(FofoCatalogResponse o1, FofoCatalogResponse o2) {
|
370 |
public int compare(FofoCatalogResponse o1, FofoCatalogResponse o2) {
|
| 363 |
return rankOrdering.compare(o1.getCatalogId(), o2.getCatalogId());
|
371 |
return rankOrdering.compare(o1.getCatalogId(), o2.getCatalogId());
|
| 364 |
}
|
372 |
}
|
| 365 |
}).collect(Collectors.toList());
|
373 |
}).collect(Collectors.toList());
|
| 366 |
webListing.setFofoCatalogResponses(dealResponse);
|
374 |
webListing.setFofoCatalogResponses(dealResponse);
|
| 367 |
return responseSender.ok(webListing);
|
375 |
return responseSender.ok(webListing);
|
| 368 |
}
|
376 |
}
|
| 369 |
|
377 |
|
| 370 |
@RequestMapping(value = "/store/otp/generateOTP", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
378 |
@RequestMapping(value = "/store/otp/generateOTP", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| Line 392... |
Line 400... |
| 392 |
return responseSender.ok(true);
|
400 |
return responseSender.ok(true);
|
| 393 |
} else {
|
401 |
} else {
|
| 394 |
return responseSender.ok(false);
|
402 |
return responseSender.ok(false);
|
| 395 |
}
|
403 |
}
|
| 396 |
}
|
404 |
}
|
| 397 |
|
405 |
|
| 398 |
@RequestMapping(value = "/store/resetPassword", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
406 |
@RequestMapping(value = "/store/resetPassword", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 399 |
public ResponseEntity<?> resetPassword(HttpServletRequest request, @RequestBody UserModel userModel) throws Exception {
|
407 |
public ResponseEntity<?> resetPassword(HttpServletRequest request, @RequestBody UserModel userModel)
|
| - |
|
408 |
throws Exception {
|
| 400 |
customerService.changePassword(userModel.getMobile(), userModel.getPassword());
|
409 |
customerService.changePassword(userModel.getMobile(), userModel.getPassword());
|
| 401 |
return responseSender.ok(true);
|
410 |
return responseSender.ok(true);
|
| 402 |
}
|
411 |
}
|
| 403 |
|
412 |
|
| 404 |
@RequestMapping(value = "/store/register", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
413 |
@RequestMapping(value = "/store/register", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| Line 416... |
Line 425... |
| 416 |
public ResponseEntity<?> confirmOrder(HttpServletRequest request,
|
425 |
public ResponseEntity<?> confirmOrder(HttpServletRequest request,
|
| 417 |
@RequestBody CreatePendingOrderRequest createPendingOrderRequest) throws Exception {
|
426 |
@RequestBody CreatePendingOrderRequest createPendingOrderRequest) throws Exception {
|
| 418 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
427 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 419 |
Integer storeId = userInfo.getRetailerId();
|
428 |
Integer storeId = userInfo.getRetailerId();
|
| 420 |
createPendingOrderRequest.setFofoId(storeId);
|
429 |
createPendingOrderRequest.setFofoId(storeId);
|
| - |
|
430 |
List<CreatePendingOrderItem> pendingOrderItems = createPendingOrderRequest.getCreatePendingOrderItem();
|
| - |
|
431 |
List<CartItem> cartItems = new ArrayList<>();
|
| - |
|
432 |
pendingOrderItems.stream().forEach(x -> {
|
| - |
|
433 |
CartItem ci = new CartItem();
|
| - |
|
434 |
ci.setItemId(x.getItemId());
|
| - |
|
435 |
ci.setQuantity(x.getQuantity());
|
| - |
|
436 |
ci.setSellingPrice(x.getSellingPrice());
|
| - |
|
437 |
cartItems.add(ci);
|
| - |
|
438 |
});
|
| - |
|
439 |
CartResponse cr = this.validateCart(storeId, cartItems);
|
| - |
|
440 |
if (cr.getCartMessageChanged() > 0 || cr.getTotalAmount() != createPendingOrderRequest.getTotalAmount()) {
|
| - |
|
441 |
return responseSender.badRequest("Invalid request");
|
| - |
|
442 |
}
|
| 421 |
return responseSender.ok(this.pendingOrderService.createPendingOrder(createPendingOrderRequest));
|
443 |
return responseSender.ok(this.pendingOrderService.createPendingOrder(createPendingOrderRequest, cr));
|
| 422 |
|
444 |
|
| 423 |
}
|
445 |
}
|
| 424 |
|
446 |
|
| 425 |
@RequestMapping(value = "/store/address", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
447 |
@RequestMapping(value = "/store/address", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 426 |
@ApiImplicitParams({
|
448 |
@ApiImplicitParams({
|
| Line 446... |
Line 468... |
| 446 |
if (pincodePartners.size() > 0) {
|
468 |
if (pincodePartners.size() > 0) {
|
| 447 |
fofoId = pincodePartners.get(0).getFofoId();
|
469 |
fofoId = pincodePartners.get(0).getFofoId();
|
| 448 |
}
|
470 |
}
|
| 449 |
return responseSender.ok(fofoStoreRepository.selectByRetailerId(fofoId).getCode());
|
471 |
return responseSender.ok(fofoStoreRepository.selectByRetailerId(fofoId).getCode());
|
| 450 |
}
|
472 |
}
|
| 451 |
|
473 |
|
| 452 |
@RequestMapping(value = "/store/order", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
474 |
@RequestMapping(value = "/store/order", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 453 |
public ResponseEntity<?> getOrderDetail(HttpServletRequest request, @RequestParam(value = "id") int id,
|
475 |
public ResponseEntity<?> getOrderDetail(HttpServletRequest request, @RequestParam(value = "id") int id,
|
| 454 |
@RequestParam(name = "offset") int offset, @RequestParam(name = "limit") int limit)
|
476 |
@RequestParam(name = "offset") int offset, @RequestParam(name = "limit") int limit)
|
| 455 |
throws ProfitMandiBusinessException {
|
477 |
throws ProfitMandiBusinessException {
|
| 456 |
List<CustomerOrderDetail> customerOrderDetails = new ArrayList<>();
|
478 |
List<CustomerOrderDetail> customerOrderDetails = new ArrayList<>();
|
| Line 469... |
Line 491... |
| 469 |
customerOrderDetail.setId(poi.getOrderId());
|
491 |
customerOrderDetail.setId(poi.getOrderId());
|
| 470 |
customerOrderDetail.setItemId(poi.getItemId());
|
492 |
customerOrderDetail.setItemId(poi.getItemId());
|
| 471 |
customerOrderDetail.setModelName(item.getModelName());
|
493 |
customerOrderDetail.setModelName(item.getModelName());
|
| 472 |
customerOrderDetail.setModelNumber(item.getModelNumber());
|
494 |
customerOrderDetail.setModelNumber(item.getModelNumber());
|
| 473 |
customerOrderDetail.setQuantity(poi.getQuantity());
|
495 |
customerOrderDetail.setQuantity(poi.getQuantity());
|
| 474 |
customerOrderDetail.setStatus(poi.getStatus());
|
496 |
customerOrderDetail.setStatus(po.getStatus());
|
| 475 |
customerOrderDetail.setTotalPrice(poi.getSellingPrice());
|
497 |
customerOrderDetail.setTotalPrice(poi.getSellingPrice());
|
| 476 |
customerOrderDetail.setPayMethod(po.getPayMethod());
|
498 |
customerOrderDetail.setPayMethod(po.getPayMethod());
|
| 477 |
customerOrderDetail.setCreatedTimeStamp(po.getCreateTimestamp());
|
499 |
customerOrderDetail.setCreatedTimeStamp(po.getCreateTimestamp());
|
| 478 |
customerOrderDetails.add(customerOrderDetail);
|
500 |
customerOrderDetails.add(customerOrderDetail);
|
| 479 |
}
|
501 |
}
|
| Line 481... |
Line 503... |
| 481 |
}
|
503 |
}
|
| 482 |
|
504 |
|
| 483 |
return responseSender.ok(customerOrderDetails);
|
505 |
return responseSender.ok(customerOrderDetails);
|
| 484 |
}
|
506 |
}
|
| 485 |
|
507 |
|
| 486 |
|
- |
|
| 487 |
@RequestMapping(value = "/store/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
508 |
@RequestMapping(value = "/store/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 488 |
@Cacheable(value = "storelisting.all", cacheManager = "thirtyMinsTimeOutCacheManager")
|
509 |
@Cacheable(value = "storelisting.all", cacheManager = "thirtyMinsTimeOutCacheManager")
|
| 489 |
public ResponseEntity<?> getStoresListing(HttpServletRequest request) throws Exception {
|
510 |
public ResponseEntity<?> getStoresListing(HttpServletRequest request) throws Exception {
|
| 490 |
List<WebListing> webListings = webListingRepository.selectAllWebListing(Optional.of(true));
|
511 |
List<WebListing> webListings = webListingRepository.selectAllWebListing(Optional.of(true));
|
| 491 |
for (WebListing webListing : webListings) {
|
512 |
for (WebListing webListing : webListings) {
|
| 492 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
513 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 493 |
Integer storeId = userInfo.getRetailerId();
|
514 |
Integer storeId = userInfo.getRetailerId();
|
| 494 |
|
515 |
|
| 495 |
List<Integer> webProducts = webProductListingRepository.selectAllByWebListingId(webListing.getId()).stream()
|
516 |
List<Integer> webProducts = webProductListingRepository.selectAllByWebListingId(webListing.getId()).stream()
|
| 496 |
.filter(x -> x.getRank() > 0).map(x -> x.getEntityId()).collect(Collectors.toList());
|
517 |
.filter(x -> x.getRank() > 0).map(x -> x.getEntityId()).collect(Collectors.toList());
|
| 497 |
|
518 |
|
| 498 |
RestClient rc = new RestClient();
|
519 |
RestClient rc = new RestClient();
|
| 499 |
Map<String, String> params = new HashMap<>();
|
520 |
Map<String, String> params = new HashMap<>();
|
| Line 532... |
Line 553... |
| 532 |
@ApiImplicitParams({
|
553 |
@ApiImplicitParams({
|
| 533 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
554 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 534 |
@ApiOperation(value = "Get brand list and count for category")
|
555 |
@ApiOperation(value = "Get brand list and count for category")
|
| 535 |
public ResponseEntity<?> cart(HttpServletRequest request, @RequestBody AddCartRequest cartRequest)
|
556 |
public ResponseEntity<?> cart(HttpServletRequest request, @RequestBody AddCartRequest cartRequest)
|
| 536 |
throws Exception {
|
557 |
throws Exception {
|
| - |
|
558 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| - |
|
559 |
Integer storeId = userInfo.getRetailerId();
|
| - |
|
560 |
ValidateCartResponse vc = new ValidateCartResponse(this.validateCart(storeId, cartRequest.getCartItems()),
|
| - |
|
561 |
"Success", "Items added to cart successfully");
|
| - |
|
562 |
return responseSender.ok(vc);
|
| - |
|
563 |
}
|
| - |
|
564 |
|
| - |
|
565 |
// Validate Cart for B2C Customers
|
| - |
|
566 |
private CartResponse validateCart(int storeId, List<CartItem> cartItems) throws Exception {
|
| - |
|
567 |
cartItems = cartItems.stream().filter(x -> x.getQuantity() > 0).collect(Collectors.toList());
|
| - |
|
568 |
List<Integer> itemIds = cartItems.stream().map(x -> x.getItemId()).collect(Collectors.toList());
|
| - |
|
569 |
Map<Integer, AvailabilityModel> inventoryItemAvailabilityMap = inventoryService.getStoreAndOurStock(storeId,
|
| - |
|
570 |
itemIds);
|
| 537 |
CartResponse cartResponse = new CartResponse();
|
571 |
CartResponse cartResponse = new CartResponse();
|
| 538 |
List<CartItemResponseModel> cartItemResponseModels = new ArrayList<>();
|
572 |
List<CartItemResponseModel> cartItemResponseModels = new ArrayList<>();
|
| 539 |
cartResponse.setCartItems(cartItemResponseModels);
|
573 |
cartResponse.setCartItems(cartItemResponseModels);
|
| 540 |
|
- |
|
| 541 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
- |
|
| 542 |
Integer storeId = userInfo.getRetailerId();
|
- |
|
| 543 |
List<Integer> itemIds = cartRequest.getCartItems().stream().map(x -> x.getItemId())
|
- |
|
| 544 |
.collect(Collectors.toList());
|
- |
|
| 545 |
Set<Integer> itemsIdsSet = new HashSet<>(itemIds);
|
574 |
Set<Integer> itemsIdsSet = new HashSet<>(itemIds);
|
| 546 |
logger.info("Store Id {}, Item Ids {}", storeId, itemsIdsSet);
|
575 |
logger.info("Store Id {}, Item Ids {}", storeId, itemsIdsSet);
|
| 547 |
List<CurrentInventorySnapshot> currentInventorySnapshot = currentInventorySnapshotRepository
|
- |
|
| 548 |
.selectByFofoItemIds(storeId, itemsIdsSet);
|
- |
|
| 549 |
Map<Integer, Integer> storeItemAvailabilityMap = currentInventorySnapshot.stream()
|
- |
|
| 550 |
.filter(x -> x.getAvailability() > 0)
|
- |
|
| 551 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|
- |
|
| 552 |
|
576 |
|
| 553 |
Map<Integer, Item> itemsMap = itemRepository.selectByIds(itemsIdsSet).stream()
|
577 |
Map<Integer, Item> itemsMap = itemRepository.selectByIds(itemsIdsSet).stream()
|
| 554 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
578 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 555 |
|
579 |
|
| 556 |
Map<Integer, TagListing> sdItemAvailabilityMap = tagListingRepository
|
580 |
Map<Integer, TagListing> tagListingMap = tagListingRepository
|
| 557 |
.selectByItemIdsAndTagIds(new HashSet<>(itemIds), new HashSet<>(Arrays.asList(4))).stream()
|
581 |
.selectByItemIdsAndTagIds(new HashSet<>(itemIds), new HashSet<>(Arrays.asList(4))).stream()
|
| 558 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
582 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
| 559 |
|
583 |
|
| 560 |
List<Integer> catalogIds = itemsMap.values().stream().map(x -> x.getCatalogItemId())
|
584 |
List<Integer> catalogIds = itemsMap.values().stream().map(x -> x.getCatalogItemId())
|
| 561 |
.collect(Collectors.toList());
|
585 |
.collect(Collectors.toList());
|
| 562 |
|
586 |
|
| 563 |
Map<Integer, JSONObject> contentMap = commonSolrService.getContentByCatalogIds(catalogIds);
|
587 |
Map<Integer, JSONObject> contentMap = commonSolrService.getContentByCatalogIds(catalogIds);
|
| 564 |
|
588 |
|
| 565 |
// cartResponse.getCartItems()
|
589 |
// cartResponse.getCartItems()
|
| 566 |
for (CartItem cartItem : cartRequest.getCartItems()) {
|
590 |
int cartMessageChanged = 0;
|
| 567 |
if (cartItem.getQuantity() == 0) {
|
591 |
int cartMessageOOS = 0;
|
| 568 |
continue;
|
592 |
int totalAmount = 0;
|
| 569 |
}
|
593 |
int totalQty = 0;
|
| - |
|
594 |
for (CartItem cartItem : cartItems) {
|
| 570 |
Item item = itemsMap.get(cartItem.getItemId());
|
595 |
Item item = itemsMap.get(cartItem.getItemId());
|
| 571 |
TagListing tagListing = sdItemAvailabilityMap.get(cartItem.getItemId());
|
596 |
TagListing tagListing = tagListingMap.get(cartItem.getItemId());
|
| - |
|
597 |
Float cashback = schemeService.getItemSchemeCashBack().get(cartItem.getItemId());
|
| - |
|
598 |
cashback = cashback == null ? 0 : cashback;
|
| - |
|
599 |
float itemSellingPrice = tagListing.getMop() - cashback;
|
| 572 |
CartItemResponseModel cartItemResponseModel = new CartItemResponseModel();
|
600 |
CartItemResponseModel cartItemResponseModel = new CartItemResponseModel();
|
| - |
|
601 |
cartItemResponseModel.setSellingPrice(cartItem.getSellingPrice());
|
| - |
|
602 |
if (itemSellingPrice != cartItem.getSellingPrice()) {
|
| - |
|
603 |
cartItemResponseModel.setSellingPrice(itemSellingPrice);
|
| - |
|
604 |
cartMessageChanged++;
|
| - |
|
605 |
}
|
| 573 |
int estimate = -2;
|
606 |
int estimate = -2;
|
| - |
|
607 |
int qtyRequired = (int) cartItem.getQuantity();
|
| 574 |
if (storeItemAvailabilityMap.containsKey(cartItem.getItemId())) {
|
608 |
AvailabilityModel availabilityModel = inventoryItemAvailabilityMap.get(cartItem.getItemId());
|
| - |
|
609 |
cartItemResponseModel.setMaxQuantity(availabilityModel.getMaxAvailability());
|
| 575 |
if (storeItemAvailabilityMap.get(cartItem.getItemId()) >= cartItem.getQuantity()) {
|
610 |
if (availabilityModel.getStoreAvailability() >= qtyRequired) {
|
| 576 |
estimate = 0;
|
611 |
estimate = 0;
|
| 577 |
} else if (tagListing.isActive()) {
|
612 |
} else if (availabilityModel.getWarehouseAvailability() >= qtyRequired) {
|
| 578 |
estimate = 2;
|
613 |
estimate = 2;
|
| 579 |
} else {
|
614 |
} else if (availabilityModel.getStoreAvailability() > 0) {
|
| 580 |
estimate = -2;
|
615 |
estimate = 0;
|
| - |
|
616 |
qtyRequired = availabilityModel.getStoreAvailability();
|
| 581 |
}
|
617 |
cartMessageChanged++;
|
| 582 |
} else if (tagListing.isActive()) {
|
618 |
} else if (availabilityModel.getWarehouseAvailability() > 0) {
|
| - |
|
619 |
qtyRequired = availabilityModel.getWarehouseAvailability();
|
| 583 |
estimate = 2;
|
620 |
estimate = 2;
|
| - |
|
621 |
cartMessageChanged++;
|
| 584 |
} else {
|
622 |
} else {
|
| 585 |
estimate = -2;
|
623 |
qtyRequired = 0;
|
| - |
|
624 |
cartMessageOOS++;
|
| 586 |
}
|
625 |
}
|
| - |
|
626 |
cartItemResponseModel.setQuantity(qtyRequired);
|
| 587 |
if (estimate >= 0 && LocalTime.now().isAfter(CUTOFF_TIME)) {
|
627 |
if (estimate >= 0 && LocalTime.now().isAfter(CUTOFF_TIME)) {
|
| 588 |
estimate = estimate + 1;
|
628 |
estimate = estimate + 1;
|
| 589 |
}
|
629 |
}
|
| - |
|
630 |
totalQty += qtyRequired;
|
| - |
|
631 |
totalAmount += qtyRequired * itemSellingPrice;
|
| 590 |
cartItemResponseModel.setEstimate(estimate);
|
632 |
cartItemResponseModel.setEstimate(estimate);
|
| 591 |
cartItemResponseModel.setTitle(item.getItemDescriptionNoColor());
|
633 |
cartItemResponseModel.setTitle(item.getItemDescriptionNoColor());
|
| 592 |
cartItemResponseModel.setItemId(cartItem.getItemId());
|
634 |
cartItemResponseModel.setItemId(cartItem.getItemId());
|
| 593 |
cartItemResponseModel.setMinBuyQuantity(1);
|
635 |
cartItemResponseModel.setMinBuyQuantity(1);
|
| 594 |
cartItemResponseModel.setQuantity(cartItem.getQuantity());
|
636 |
cartItemResponseModel.setQuantity(qtyRequired);
|
| 595 |
cartItemResponseModel.setQuantityStep(1);
|
637 |
cartItemResponseModel.setQuantityStep(1);
|
| 596 |
Float cashback = schemeService.getItemSchemeCashBack().get(cartItem.getItemId());
|
- |
|
| 597 |
cashback = cashback == null ? 0 : cashback;
|
- |
|
| 598 |
cartItemResponseModel.setSellingPrice(tagListing.getMop() - cashback);
|
638 |
cartItemResponseModel.setMaxQuantity(availabilityModel.getMaxAvailability());
|
| 599 |
cartItemResponseModel.setMaxQuantity(2);
|
- |
|
| 600 |
cartItemResponseModel.setCatalogItemId(item.getCatalogItemId());
|
639 |
cartItemResponseModel.setCatalogItemId(item.getCatalogItemId());
|
| 601 |
cartItemResponseModel.setImageUrl(contentMap.get(item.getCatalogItemId()).getString("imageUrl_s"));
|
640 |
cartItemResponseModel.setImageUrl(contentMap.get(item.getCatalogItemId()).getString("imageUrl_s"));
|
| 602 |
cartItemResponseModel.setColor(item.getColor());
|
641 |
cartItemResponseModel.setColor(item.getColor());
|
| 603 |
cartItemResponseModels.add(cartItemResponseModel);
|
642 |
cartItemResponseModels.add(cartItemResponseModel);
|
| 604 |
}
|
643 |
}
|
| - |
|
644 |
cartResponse.setCartItems(cartItemResponseModels);
|
| - |
|
645 |
cartResponse.setCartMessageChanged(cartMessageChanged);
|
| - |
|
646 |
cartResponse.setCartMessageOOS(cartMessageOOS);
|
| 605 |
ValidateCartResponse vc = new ValidateCartResponse(cartResponse, "Success", "Items added to cart successfully");
|
647 |
int maxEstimate = cartItemResponseModels.stream().mapToInt(x -> x.getEstimate()).max().getAsInt();
|
| - |
|
648 |
cartResponse.setMaxEstimate(maxEstimate);
|
| - |
|
649 |
cartResponse.setTotalAmount(totalAmount);
|
| 606 |
return responseSender.ok(vc);
|
650 |
cartResponse.setTotalQty(totalQty);
|
| 607 |
}
|
651 |
|
| - |
|
652 |
return cartResponse;
|
| 608 |
|
653 |
|
| 609 |
private boolean validateCart(int storeId, List<CartItem> cartItems) {
|
- |
|
| 610 |
return false;
|
- |
|
| 611 |
}
|
654 |
}
|
| 612 |
|
655 |
|
| 613 |
private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId)
|
656 |
private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId)
|
| 614 |
throws ProfitMandiBusinessException {
|
657 |
throws ProfitMandiBusinessException {
|
| 615 |
Map<Integer, Integer> ourItemAvailabilityMap = null;
|
658 |
Map<Integer, Integer> ourItemAvailabilityMap = null;
|
| Line 710... |
Line 753... |
| 710 |
}
|
753 |
}
|
| 711 |
}
|
754 |
}
|
| 712 |
}
|
755 |
}
|
| 713 |
if (fofoAvailabilityInfoMap.values().size() > 0) {
|
756 |
if (fofoAvailabilityInfoMap.values().size() > 0) {
|
| 714 |
ffdr.setItems(fofoAvailabilityInfoMap.values().stream()
|
757 |
ffdr.setItems(fofoAvailabilityInfoMap.values().stream()
|
| 715 |
.sorted((x,y)->y.getAvailability()-x.getAvailability())
|
758 |
.sorted((x, y) -> y.getAvailability() - x.getAvailability()).collect(Collectors.toList()));
|
| 716 |
.collect(Collectors.toList()));
|
- |
|
| 717 |
dealResponse.add(ffdr);
|
759 |
dealResponse.add(ffdr);
|
| 718 |
}
|
760 |
}
|
| 719 |
}
|
761 |
}
|
| 720 |
return dealResponse;
|
762 |
return dealResponse;
|
| 721 |
|
763 |
|
| 722 |
}
|
764 |
}
|
| - |
|
765 |
|
| - |
|
766 |
@GetMapping(value = "store/order-status/{pendingOrderId}")
|
| - |
|
767 |
public ResponseEntity<?> orderStatus(HttpServletRequest request, @PathVariable int pendingOrderId) throws Exception {
|
| - |
|
768 |
PendingOrder pendingOrder = pendingOrderRepository.selectById(pendingOrderId);
|
| - |
|
769 |
List<PendingOrderItem> pendingOrderItems = pendingOrderItemRepository.selectByOrderId(pendingOrder.getId());
|
| - |
|
770 |
List<Integer> catalogIds = new ArrayList<>();
|
| - |
|
771 |
for(PendingOrderItem pendingOrderItem: pendingOrderItems) {
|
| - |
|
772 |
Item item = itemRepository.selectById(pendingOrderItem.getItemId());
|
| - |
|
773 |
pendingOrderItem.setItemName(item.getItemDescription());
|
| - |
|
774 |
catalogIds.add(item.getCatalogItemId());
|
| - |
|
775 |
}
|
| - |
|
776 |
Map<Integer, JSONObject> contentMap = commonSolrService.getContentByCatalogIds(catalogIds);
|
| - |
|
777 |
for(PendingOrderItem pendingOrderItem: pendingOrderItems) {
|
| - |
|
778 |
Item item = itemRepository.selectById(pendingOrderItem.getItemId());
|
| - |
|
779 |
JSONObject jsonObj = contentMap.get(item.getCatalogItemId());
|
| - |
|
780 |
pendingOrderItem.setImgUrl(jsonObj.getString("imageUrl_s"));
|
| - |
|
781 |
}
|
| - |
|
782 |
pendingOrder.setPendingOrderItems(pendingOrderItems);
|
| - |
|
783 |
return responseSender.ok(pendingOrder);
|
| - |
|
784 |
}
|
| - |
|
785 |
|
| 723 |
@RequestMapping(value = "/store/addresses/{customerId}", method = RequestMethod.GET)
|
786 |
@RequestMapping(value = "/store/addresses/{customerId}", method = RequestMethod.GET)
|
| 724 |
public ResponseEntity<?> getAll(HttpServletRequest request, @PathVariable int customerId) throws Throwable {
|
787 |
public ResponseEntity<?> getAll(HttpServletRequest request, @PathVariable int customerId) throws Throwable {
|
| 725 |
return responseSender.ok(customerAddressRepository.selectByCustomerId(customerId));
|
788 |
return responseSender.ok(customerAddressRepository.selectByCustomerId(customerId));
|
| 726 |
}
|
789 |
}
|
| 727 |
|
790 |
|