use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.
the class OrderFacadeImpl method calculateOrderTotal.
@Override
public OrderTotalSummary calculateOrderTotal(MerchantStore store, com.salesmanager.shop.model.order.v0.PersistableOrder order, Language language) throws Exception {
List<PersistableOrderProduct> orderProducts = order.getOrderProductItems();
ShoppingCartItemPopulator populator = new ShoppingCartItemPopulator();
populator.setProductAttributeService(productAttributeService);
populator.setProductService(productService);
populator.setShoppingCartService(shoppingCartService);
List<ShoppingCartItem> items = new ArrayList<ShoppingCartItem>();
for (PersistableOrderProduct orderProduct : orderProducts) {
ShoppingCartItem item = populator.populate(orderProduct, new ShoppingCartItem(), store, language);
items.add(item);
}
Customer customer = customer(order.getCustomer(), store, language);
OrderTotalSummary summary = this.calculateOrderTotal(store, customer, order, language);
return summary;
}
use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.
the class ShoppingCartApi method getByCustomer.
@Deprecated
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/auth/customer/{id}/cart", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "Get a shopping cart by customer id. Customer must be authenticated", notes = "", produces = "application/json", response = ReadableShoppingCart.class)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
// customer
@ResponseBody
public // customer
ReadableShoppingCart getByCustomer(// customer
@PathVariable Long id, // cart code
@RequestParam Optional<String> cart, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language, HttpServletRequest request, HttpServletResponse response) {
Principal principal = request.getUserPrincipal();
// lookup customer
Customer customer = customerService.getById(id);
if (customer == null) {
throw new ResourceNotFoundException("No Customer found for id [" + id + "]");
}
customerFacadev1.authorize(customer, principal);
ReadableShoppingCart readableCart = shoppingCartFacadev1.get(cart, id, merchantStore, language);
if (readableCart == null) {
throw new ResourceNotFoundException("No cart found for customerid [" + id + "]");
}
return readableCart;
}
use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.
the class ShoppingCartApi method getByCustomer.
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/auth/customer/cart", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "Get a shopping cart by authenticated customer", notes = "", produces = "application/json", response = ReadableShoppingCart.class)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
@ResponseBody
public ReadableShoppingCart getByCustomer(// cart code
@RequestParam Optional<String> cart, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language, HttpServletRequest request, HttpServletResponse response) {
Principal principal = request.getUserPrincipal();
Customer customer = null;
try {
customer = customerFacade.getCustomerByUserName(principal.getName(), merchantStore);
} catch (Exception e) {
throw new ServiceRuntimeException("Exception while getting customer [ " + principal.getName() + "]");
}
if (customer == null) {
throw new ResourceNotFoundException("No Customer found for principal[" + principal.getName() + "]");
}
customerFacadev1.authorize(customer, principal);
ReadableShoppingCart readableCart = shoppingCartFacadev1.get(cart, customer.getId(), merchantStore, language);
if (readableCart == null) {
throw new ResourceNotFoundException("No cart found for customer [" + principal.getName() + "]");
}
return readableCart;
}
use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method getCustomerDataByUserName.
/**
* Method used to fetch customer based on the username and storecode. Customer username is unique
* to each store.
*
* @param userName
* @param store
* @throws ConversionException
*/
@Override
public CustomerEntity getCustomerDataByUserName(final String userName, final MerchantStore store, final Language language) throws Exception {
LOG.info("Fetching customer with userName" + userName);
Customer customer = customerService.getByNick(userName);
if (customer != null) {
LOG.info("Found customer, converting to CustomerEntity");
try {
CustomerEntityPopulator customerEntityPopulator = new CustomerEntityPopulator();
// store, language
return customerEntityPopulator.populate(customer, store, language);
} catch (ConversionException ex) {
LOG.error("Error while converting Customer to CustomerEntity", ex);
throw new Exception(ex);
}
}
return null;
}
use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method getAllCustomerReviewsByReviewed.
@Override
public List<ReadableCustomerReview> getAllCustomerReviewsByReviewed(Long customerId, MerchantStore store, Language language) {
// customer exist
Customer customer = getCustomerById(customerId);
Validate.notNull(customer, "Reviewed customer cannot be null");
return customerReviewService.getByReviewedCustomer(customer).stream().map(customerReview -> convertCustomerReviewToReadableCustomerReview(customerReview, store, language)).collect(Collectors.toList());
}
Aggregations