use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method checkIfUserExists.
/**
* <p>
* Method to check if given user exists for given username under given store. System treat
* username as unique for a given store, customer is not allowed to use same username twice for a
* given store, however it can be used for different stores.
* </p>
*
* @param userName Customer slected userName
* @param store store for which customer want to register
* @return boolean flag indicating if user exists for given store or not
* @throws Exception
*/
@Override
public boolean checkIfUserExists(final String userName, final MerchantStore store) throws Exception {
if (StringUtils.isNotBlank(userName) && store != null) {
Customer customer = customerService.getByNick(userName, store.getId());
if (customer != null) {
LOG.info("Customer with userName {} already exists for store {} ", userName, store.getStorename());
return true;
}
LOG.info("No customer found with userName {} for store {} ", userName, store.getStorename());
return false;
}
LOG.info("Either userName is empty or we have not found any value for store");
return false;
}
use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method convertCustomerListToReadableCustomerList.
private ReadableCustomerList convertCustomerListToReadableCustomerList(CustomerList customerList, MerchantStore store, Language language) {
List<ReadableCustomer> readableCustomers = customerList.getCustomers().stream().map(customer -> convertCustomerToReadableCustomer(customer, store, language)).collect(Collectors.toList());
ReadableCustomerList readableCustomerList = new ReadableCustomerList();
readableCustomerList.setCustomers(readableCustomers);
readableCustomerList.setTotalPages(Math.toIntExact(customerList.getTotalCount()));
return readableCustomerList;
}
use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method deleteByNick.
@Override
public void deleteByNick(String userName) {
Customer customer = getByNick(userName);
delete(customer);
}
use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method getByUserName.
@Override
public ReadableCustomer getByUserName(String userName, MerchantStore merchantStore, Language language) {
Validate.notNull(userName, "Username cannot be null");
Validate.notNull(merchantStore, "MerchantStore cannot be null");
Customer customerModel = getCustomerByNickAndStoreId(userName, merchantStore);
return convertCustomerToReadableCustomer(customerModel, merchantStore, language);
}
use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method getAddress.
@Override
public Address getAddress(Long userId, final MerchantStore merchantStore, boolean isBillingAddress) throws Exception {
LOG.info("Fetching customer for id {} ", userId);
Address address = null;
final Customer customerModel = customerService.getById(userId);
if (customerModel == null) {
LOG.error("Customer with ID {} does not exists..", userId);
// throw new CustomerNotFoundException( "customer with given id does not exists" );
throw new Exception("customer with given id does not exists");
}
if (isBillingAddress) {
LOG.info("getting billing address..");
CustomerBillingAddressPopulator billingAddressPopulator = new CustomerBillingAddressPopulator();
address = billingAddressPopulator.populate(customerModel, merchantStore, merchantStore.getDefaultLanguage());
address.setBillingAddress(true);
return address;
}
LOG.info("getting Delivery address..");
CustomerDeliveryAddressPopulator deliveryAddressPopulator = new CustomerDeliveryAddressPopulator();
return deliveryAddressPopulator.populate(customerModel, merchantStore, merchantStore.getDefaultLanguage());
}
Aggregations