| Line 18... |
Line 18... |
| 18 |
import com.spice.profitmandi.dao.entity.dtr.ScratchOffer;
|
18 |
import com.spice.profitmandi.dao.entity.dtr.ScratchOffer;
|
| 19 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
19 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
| 20 |
import com.spice.profitmandi.dao.entity.dtr.WebListing;
|
20 |
import com.spice.profitmandi.dao.entity.dtr.WebListing;
|
| 21 |
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
|
21 |
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
|
| 22 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
22 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
| - |
|
23 |
import com.spice.profitmandi.dao.entity.inventory.State;
|
| 23 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
24 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 24 |
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
|
25 |
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
|
| 25 |
import com.spice.profitmandi.dao.enumuration.dtr.WebListingSource;
|
26 |
import com.spice.profitmandi.dao.enumuration.dtr.WebListingSource;
|
| 26 |
import com.spice.profitmandi.dao.enumuration.inventory.ScratchedGift;
|
27 |
import com.spice.profitmandi.dao.enumuration.inventory.ScratchedGift;
|
| 27 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
28 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
| Line 30... |
Line 31... |
| 30 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
31 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 31 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
32 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 32 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
33 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
| 33 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
34 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
| 34 |
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
|
35 |
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
|
| - |
|
36 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| 35 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
37 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 36 |
import com.spice.profitmandi.service.CustomerService;
|
38 |
import com.spice.profitmandi.service.CustomerService;
|
| 37 |
import com.spice.profitmandi.service.EmailService;
|
39 |
import com.spice.profitmandi.service.EmailService;
|
| 38 |
import com.spice.profitmandi.service.NotificationService;
|
40 |
import com.spice.profitmandi.service.NotificationService;
|
| 39 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
41 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| - |
|
42 |
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
|
| - |
|
43 |
import com.spice.profitmandi.service.integrations.zest.MobileInsurancePlan;
|
| 40 |
import com.spice.profitmandi.service.inventory.*;
|
44 |
import com.spice.profitmandi.service.inventory.*;
|
| 41 |
import com.spice.profitmandi.service.order.OrderService;
|
45 |
import com.spice.profitmandi.service.order.OrderService;
|
| 42 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
46 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 43 |
import com.spice.profitmandi.service.user.RetailerService;
|
47 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 44 |
import com.spice.profitmandi.web.processor.OtpProcessor;
|
48 |
import com.spice.profitmandi.web.processor.OtpProcessor;
|
| Line 63... |
Line 67... |
| 63 |
import org.springframework.http.HttpStatus;
|
67 |
import org.springframework.http.HttpStatus;
|
| 64 |
import org.springframework.http.MediaType;
|
68 |
import org.springframework.http.MediaType;
|
| 65 |
import org.springframework.http.ResponseEntity;
|
69 |
import org.springframework.http.ResponseEntity;
|
| 66 |
import org.springframework.stereotype.Controller;
|
70 |
import org.springframework.stereotype.Controller;
|
| 67 |
import org.springframework.transaction.annotation.Transactional;
|
71 |
import org.springframework.transaction.annotation.Transactional;
|
| - |
|
72 |
import org.springframework.ui.Model;
|
| 68 |
import org.springframework.web.bind.annotation.*;
|
73 |
import org.springframework.web.bind.annotation.*;
|
| 69 |
|
74 |
|
| 70 |
import javax.servlet.http.HttpServletRequest;
|
75 |
import javax.servlet.http.HttpServletRequest;
|
| 71 |
import javax.servlet.http.HttpServletResponse;
|
76 |
import javax.servlet.http.HttpServletResponse;
|
| 72 |
import java.io.ByteArrayInputStream;
|
77 |
import java.io.ByteArrayInputStream;
|
| Line 337... |
Line 342... |
| 337 |
customer.setLastName(userModel.getLastName());
|
342 |
customer.setLastName(userModel.getLastName());
|
| 338 |
customer.setMobileNumber(userModel.getMobile());
|
343 |
customer.setMobileNumber(userModel.getMobile());
|
| 339 |
return responseSender.ok(customerService.addCustomer(customer));
|
344 |
return responseSender.ok(customerService.addCustomer(customer));
|
| 340 |
}
|
345 |
}
|
| 341 |
|
346 |
|
| - |
|
347 |
@RequestMapping(value = "/checkplans", method = RequestMethod.GET)
|
| - |
|
348 |
public String getInsurancePrices(HttpServletRequest request, @RequestParam float price, Model model,
|
| - |
|
349 |
@RequestParam int itemId) throws ProfitMandiBusinessException {
|
| - |
|
350 |
logger.info("Request received at url : {}", request.getRequestURI());
|
| - |
|
351 |
|
| - |
|
352 |
try {
|
| - |
|
353 |
String response = String.valueOf(responseSender.ok(this.getPlans(price, itemId)));
|
| - |
|
354 |
return response;
|
| - |
|
355 |
} catch (Exception e) {
|
| - |
|
356 |
logger.info(e.getMessage(), e);
|
| - |
|
357 |
throw new ProfitMandiBusinessException("Plans", "Plans API", "Error formatting insurance plans");
|
| - |
|
358 |
}
|
| - |
|
359 |
|
| - |
|
360 |
|
| - |
|
361 |
}
|
| - |
|
362 |
|
| - |
|
363 |
@Autowired
|
| - |
|
364 |
InsuranceService insuranceService;
|
| - |
|
365 |
|
| - |
|
366 |
private Map<String, List<MobileInsurancePlan>> getPlans(float sellingPrice, int itemId)
|
| - |
|
367 |
throws ProfitMandiBusinessException {
|
| - |
|
368 |
try {
|
| - |
|
369 |
Map<String, List<MobileInsurancePlan>> productDurationPlans = insuranceService.getAllPlans(itemId,
|
| - |
|
370 |
sellingPrice);
|
| - |
|
371 |
return productDurationPlans;
|
| - |
|
372 |
} catch (Exception e) {
|
| - |
|
373 |
logger.info(e, e);
|
| - |
|
374 |
throw new ProfitMandiBusinessException("Fetch Insurance Plans", "Insurance",
|
| - |
|
375 |
"Could not fetch insurance Plans");
|
| - |
|
376 |
}
|
| - |
|
377 |
|
| - |
|
378 |
}
|
| - |
|
379 |
|
| 342 |
@RequestMapping(value = "/store/confirmOrder", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
380 |
@RequestMapping(value = "/store/confirmOrder", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 343 |
public ResponseEntity<?> confirmOrder(HttpServletRequest request, @RequestBody CreatePendingOrderRequest createPendingOrderRequest) throws Exception {
|
381 |
public ResponseEntity<?> confirmOrder(HttpServletRequest request, @RequestBody CreatePendingOrderRequest createPendingOrderRequest) throws Exception {
|
| 344 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
382 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 345 |
Integer storeId = userInfo.getRetailerId();
|
383 |
Integer storeId = userInfo.getRetailerId();
|
| 346 |
createPendingOrderRequest.setFofoId(storeId);
|
384 |
createPendingOrderRequest.setFofoId(storeId);
|
| Line 349... |
Line 387... |
| 349 |
pendingOrderItems.stream().forEach(x -> {
|
387 |
pendingOrderItems.stream().forEach(x -> {
|
| 350 |
CartItem ci = new CartItem();
|
388 |
CartItem ci = new CartItem();
|
| 351 |
ci.setItemId(x.getItemId());
|
389 |
ci.setItemId(x.getItemId());
|
| 352 |
ci.setQuantity(x.getQuantity());
|
390 |
ci.setQuantity(x.getQuantity());
|
| 353 |
ci.setSellingPrice(x.getSellingPrice());
|
391 |
ci.setSellingPrice(x.getSellingPrice());
|
| - |
|
392 |
ci.setExtendedWarrantyPrice(x.getExtendedWarrantyPrice());
|
| 354 |
cartItems.add(ci);
|
393 |
cartItems.add(ci);
|
| 355 |
});
|
394 |
});
|
| - |
|
395 |
logger.info("cartItems {}",cartItems);
|
| 356 |
CartResponse cr = this.validateCart(storeId, cartItems);
|
396 |
CartResponse cr = this.validateCart(storeId, cartItems);
|
| 357 |
if (cr.getCartMessageChanged() > 0 || cr.getTotalAmount() != createPendingOrderRequest.getTotalAmount()) {
|
397 |
if (cr.getCartMessageChanged() > 0 || cr.getTotalAmount() != createPendingOrderRequest.getTotalAmount()) {
|
| 358 |
return responseSender.badRequest("Invalid request");
|
398 |
return responseSender.badRequest("Invalid request");
|
| 359 |
}
|
399 |
}
|
| 360 |
|
400 |
|
| Line 679... |
Line 719... |
| 679 |
for (WebListing webListing : webListings) {
|
719 |
for (WebListing webListing : webListings) {
|
| 680 |
webListing.setFofoCatalogResponses(getDealResponses(userInfo, webListing));
|
720 |
webListing.setFofoCatalogResponses(getDealResponses(userInfo, webListing));
|
| 681 |
}
|
721 |
}
|
| 682 |
return responseSender.ok(webListings);
|
722 |
return responseSender.ok(webListings);
|
| 683 |
}
|
723 |
}
|
| - |
|
724 |
|
| - |
|
725 |
@Autowired
|
| - |
|
726 |
StateRepository stateRepository;
|
| - |
|
727 |
|
| - |
|
728 |
@RequestMapping(value = "/store/stateList", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
729 |
public ResponseEntity<?> getStateList(HttpServletRequest request) throws Exception {
|
| - |
|
730 |
List<State> states = stateRepository.selectAll();
|
| - |
|
731 |
return responseSender.ok(states);
|
| - |
|
732 |
}
|
| 684 |
/*@RequestMapping(value = "/store/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
733 |
/*@RequestMapping(value = "/store/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 685 |
public ResponseEntity<?> getStoresListing(HttpServletRequest request) throws Exception {
|
734 |
public ResponseEntity<?> getStoresListing(HttpServletRequest request) throws Exception {
|
| 686 |
List<WebListing> webListings = webListingRepository.selectAllWebListingByType(Optional.of(true), WebListingSource.store);
|
735 |
List<WebListing> webListings = webListingRepository.selectAllWebListingByType(Optional.of(true), WebListingSource.store);
|
| 687 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
736 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 688 |
Iterator<WebListing> webListingIterator = webListings.iterator();
|
737 |
Iterator<WebListing> webListingIterator = webListings.iterator();
|
| Line 769... |
Line 818... |
| 769 |
.get(itemsMap.get(cartItem.getItemId()).getCatalogItemId());
|
818 |
.get(itemsMap.get(cartItem.getItemId()).getCatalogItemId());
|
| 770 |
cashback = cashback == null ? 0 : cashback;
|
819 |
cashback = cashback == null ? 0 : cashback;
|
| 771 |
float itemSellingPrice = tagListing.getMop() - cashback;
|
820 |
float itemSellingPrice = tagListing.getMop() - cashback;
|
| 772 |
CartItemResponseModel cartItemResponseModel = new CartItemResponseModel();
|
821 |
CartItemResponseModel cartItemResponseModel = new CartItemResponseModel();
|
| 773 |
cartItemResponseModel.setSellingPrice(cartItem.getSellingPrice());
|
822 |
cartItemResponseModel.setSellingPrice(cartItem.getSellingPrice());
|
| - |
|
823 |
cartItemResponseModel.setExtendedWarrantyPrice(cartItem.getExtendedWarrantyPrice());
|
| 774 |
if (itemSellingPrice != cartItem.getSellingPrice()) {
|
824 |
if (itemSellingPrice != cartItem.getSellingPrice()) {
|
| 775 |
cartItemResponseModel.setSellingPrice(itemSellingPrice);
|
825 |
cartItemResponseModel.setSellingPrice(itemSellingPrice);
|
| 776 |
cartMessageChanged++;
|
826 |
cartMessageChanged++;
|
| 777 |
}
|
827 |
}
|
| 778 |
int estimate = -2;
|
828 |
int estimate = -2;
|
| Line 800... |
Line 850... |
| 800 |
if (estimate >= 0 && LocalTime.now().isAfter(CUTOFF_TIME)) {
|
850 |
if (estimate >= 0 && LocalTime.now().isAfter(CUTOFF_TIME)) {
|
| 801 |
estimate = estimate + 1;
|
851 |
estimate = estimate + 1;
|
| 802 |
promiseDeliveryTime = promiseDeliveryTime.plusDays(3);
|
852 |
promiseDeliveryTime = promiseDeliveryTime.plusDays(3);
|
| 803 |
}
|
853 |
}
|
| 804 |
totalQty += qtyRequired;
|
854 |
totalQty += qtyRequired;
|
| 805 |
totalAmount += qtyRequired * itemSellingPrice;
|
855 |
totalAmount += qtyRequired * itemSellingPrice + cartItem.getExtendedWarrantyPrice() ;
|
| 806 |
cartItemResponseModel.setEstimate(estimate);
|
856 |
cartItemResponseModel.setEstimate(estimate);
|
| 807 |
cartItemResponseModel.setTitle(item.getItemDescriptionNoColor());
|
857 |
cartItemResponseModel.setTitle(item.getItemDescriptionNoColor());
|
| 808 |
cartItemResponseModel.setItemId(cartItem.getItemId());
|
858 |
cartItemResponseModel.setItemId(cartItem.getItemId());
|
| 809 |
cartItemResponseModel.setMinBuyQuantity(1);
|
859 |
cartItemResponseModel.setMinBuyQuantity(1);
|
| 810 |
cartItemResponseModel.setQuantity(qtyRequired);
|
860 |
cartItemResponseModel.setQuantity(qtyRequired);
|