Search in sources :

Example 16 with Customer

use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.

the class ShippingQuoteByWeightTest method testGetCustomShippingQuotesByWeight.

@Ignore
public // @Test
void testGetCustomShippingQuotesByWeight() throws ServiceException {
    Language en = languageService.getByCode("en");
    Country country = countryService.getByCode("CA");
    Zone zone = zoneService.getByCode("QC");
    MerchantStore store = merchantService.getByCode(MerchantStore.DEFAULT_STORE);
    ProductType generalType = productTypeService.getProductType(ProductType.GENERAL_TYPE);
    // set valid store postal code
    store.setStorepostalcode("J4B-9J9");
    Product product = new Product();
    product.setProductHeight(new BigDecimal(4));
    product.setProductLength(new BigDecimal(3));
    product.setProductWidth(new BigDecimal(5));
    product.setProductWeight(new BigDecimal(8));
    product.setSku("TESTSKU");
    product.setType(generalType);
    product.setMerchantStore(store);
    // Product description
    ProductDescription description = new ProductDescription();
    description.setName("Product 1");
    description.setLanguage(en);
    description.setProduct(product);
    product.getDescriptions().add(description);
    productService.create(product);
    // productService.saveOrUpdate(product);
    // Availability
    ProductAvailability availability = new ProductAvailability();
    availability.setProductDateAvailable(new Date());
    availability.setProductQuantity(100);
    availability.setRegion("*");
    // associate with product
    availability.setProduct(product);
    product.getAvailabilities().add(availability);
    productAvailabilityService.create(availability);
    ProductPrice dprice = new ProductPrice();
    dprice.setDefaultPrice(true);
    dprice.setProductPriceAmount(new BigDecimal(29.99));
    dprice.setProductAvailability(availability);
    ProductPriceDescription dpd = new ProductPriceDescription();
    dpd.setName("Base price");
    dpd.setProductPrice(dprice);
    dpd.setLanguage(en);
    dprice.getDescriptions().add(dpd);
    availability.getPrices().add(dprice);
    productPriceService.create(dprice);
    // get product
    product = productService.getByCode("TESTSKU", en);
    // check the product
    Set<ProductAvailability> avails = product.getAvailabilities();
    for (ProductAvailability as : avails) {
        Set<ProductPrice> availabilityPrices = as.getPrices();
        for (ProductPrice ps : availabilityPrices) {
            System.out.println(ps.getProductPriceAmount().toString());
        }
    }
    // check availability
    Set<ProductPrice> availabilityPrices = availability.getPrices();
    for (ProductPrice ps : availabilityPrices) {
        System.out.println(ps.getProductPriceAmount().toString());
    }
    // configure shipping
    ShippingConfiguration shippingConfiguration = new ShippingConfiguration();
    // based on shipping or billing address
    shippingConfiguration.setShippingBasisType(ShippingBasisType.SHIPPING);
    shippingConfiguration.setShippingType(ShippingType.INTERNATIONAL);
    // individual item pricing or box packaging (see unit test above)
    shippingConfiguration.setShippingPackageType(ShippingPackageType.ITEM);
    // only if package type is package
    shippingConfiguration.setBoxHeight(5);
    shippingConfiguration.setBoxLength(5);
    shippingConfiguration.setBoxWidth(5);
    shippingConfiguration.setBoxWeight(1);
    shippingConfiguration.setMaxWeight(10);
    List<String> supportedCountries = new ArrayList<String>();
    supportedCountries.add("CA");
    supportedCountries.add("US");
    supportedCountries.add("UK");
    supportedCountries.add("FR");
    shippingService.setSupportedCountries(store, supportedCountries);
    CustomShippingQuotesConfiguration customConfiguration = new CustomShippingQuotesConfiguration();
    customConfiguration.setModuleCode("weightBased");
    customConfiguration.setActive(true);
    CustomShippingQuotesRegion northRegion = new CustomShippingQuotesRegion();
    northRegion.setCustomRegionName("NORTH");
    List<String> countries = new ArrayList<String>();
    countries.add("CA");
    countries.add("US");
    northRegion.setCountries(countries);
    CustomShippingQuoteWeightItem caQuote4 = new CustomShippingQuoteWeightItem();
    caQuote4.setMaximumWeight(4);
    caQuote4.setPrice(new BigDecimal(20));
    CustomShippingQuoteWeightItem caQuote10 = new CustomShippingQuoteWeightItem();
    caQuote10.setMaximumWeight(10);
    caQuote10.setPrice(new BigDecimal(50));
    CustomShippingQuoteWeightItem caQuote100 = new CustomShippingQuoteWeightItem();
    caQuote100.setMaximumWeight(100);
    caQuote100.setPrice(new BigDecimal(120));
    List<CustomShippingQuoteWeightItem> quotes = new ArrayList<CustomShippingQuoteWeightItem>();
    quotes.add(caQuote4);
    quotes.add(caQuote10);
    quotes.add(caQuote100);
    northRegion.setQuoteItems(quotes);
    customConfiguration.getRegions().add(northRegion);
    // create an integration configuration - USPS
    IntegrationConfiguration configuration = new IntegrationConfiguration();
    configuration.setActive(true);
    configuration.setEnvironment(Environment.TEST.name());
    configuration.setModuleCode("weightBased");
    // configure module
    shippingService.saveShippingConfiguration(shippingConfiguration, store);
    // create the basic configuration
    shippingService.saveShippingQuoteModuleConfiguration(configuration, store);
    // and the custom configuration
    shippingService.saveCustomShippingConfiguration("weightBased", customConfiguration, store);
    // now create ShippingProduct
    ShippingProduct shippingProduct1 = new ShippingProduct(product);
    FinalPrice price = pricingService.calculateProductPrice(product);
    shippingProduct1.setFinalPrice(price);
    List<ShippingProduct> shippingProducts = new ArrayList<ShippingProduct>();
    shippingProducts.add(shippingProduct1);
    Customer customer = new Customer();
    customer.setMerchantStore(store);
    customer.setEmailAddress("test@test.com");
    customer.setGender(CustomerGender.M);
    customer.setDefaultLanguage(en);
    customer.setAnonymous(true);
    customer.setCompany("ifactory");
    customer.setDateOfBirth(new Date());
    customer.setNick("My nick");
    customer.setPassword("123456");
    Delivery delivery = new Delivery();
    delivery.setAddress("Shipping address");
    delivery.setCity("Boucherville");
    delivery.setCountry(country);
    delivery.setZone(zone);
    delivery.setPostalCode("J5C-6J4");
    // overwrite delivery to US
    /*	    delivery.setPostalCode("90002");
	    delivery.setCountry(us);
	    Zone california = zoneService.getByCode("CA");
	    delivery.setZone(california);*/
    Billing billing = new Billing();
    billing.setAddress("Billing address");
    billing.setCountry(country);
    billing.setZone(zone);
    billing.setPostalCode("J4B-8J9");
    billing.setFirstName("Carl");
    billing.setLastName("Samson");
    customer.setBilling(billing);
    customer.setDelivery(delivery);
    customerService.create(customer);
    // for correlation
    Long dummyCartId = 0L;
    ShippingQuote shippingQuote = shippingService.getShippingQuote(dummyCartId, store, delivery, shippingProducts, en);
    Assert.notNull(shippingQuote);
}
Also used : Customer(com.salesmanager.core.model.customer.Customer) ArrayList(java.util.ArrayList) ShippingProduct(com.salesmanager.core.model.shipping.ShippingProduct) Product(com.salesmanager.core.model.catalog.product.Product) ProductPrice(com.salesmanager.core.model.catalog.product.price.ProductPrice) ShippingConfiguration(com.salesmanager.core.model.shipping.ShippingConfiguration) Language(com.salesmanager.core.model.reference.language.Language) ProductAvailability(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) CustomShippingQuoteWeightItem(com.salesmanager.core.modules.integration.shipping.model.CustomShippingQuoteWeightItem) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ProductPriceDescription(com.salesmanager.core.model.catalog.product.price.ProductPriceDescription) FinalPrice(com.salesmanager.core.model.catalog.product.price.FinalPrice) CustomShippingQuotesConfiguration(com.salesmanager.core.modules.integration.shipping.model.CustomShippingQuotesConfiguration) Zone(com.salesmanager.core.model.reference.zone.Zone) CustomShippingQuotesRegion(com.salesmanager.core.modules.integration.shipping.model.CustomShippingQuotesRegion) IntegrationConfiguration(com.salesmanager.core.model.system.IntegrationConfiguration) ProductType(com.salesmanager.core.model.catalog.product.type.ProductType) ShippingProduct(com.salesmanager.core.model.shipping.ShippingProduct) BigDecimal(java.math.BigDecimal) Date(java.util.Date) ShippingQuote(com.salesmanager.core.model.shipping.ShippingQuote) Billing(com.salesmanager.core.model.common.Billing) Country(com.salesmanager.core.model.reference.country.Country) ProductDescription(com.salesmanager.core.model.catalog.product.description.ProductDescription) Delivery(com.salesmanager.core.model.common.Delivery) Ignore(org.junit.Ignore)

Example 17 with Customer

use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.

the class CustomerTest method createCustomer.

@Test
public void createCustomer() throws ServiceException {
    Language en = languageService.getByCode("en");
    MerchantStore store = merchantService.getByCode(MerchantStore.DEFAULT_STORE);
    Country country = countryService.getByCode("CA");
    Zone zone = zoneService.getByCode("QC");
    /**
     * Core customer attributes *
     */
    Customer customer = new Customer();
    customer.setMerchantStore(store);
    customer.setEmailAddress("test@test.com");
    customer.setGender(CustomerGender.M);
    customer.setAnonymous(true);
    customer.setCompany("ifactory");
    customer.setDateOfBirth(new Date());
    customer.setNick("My nick");
    customer.setPassword("123456");
    customer.setDefaultLanguage(store.getDefaultLanguage());
    Delivery delivery = new Delivery();
    delivery.setAddress("Shipping address");
    delivery.setCountry(country);
    delivery.setZone(zone);
    Billing billing = new Billing();
    billing.setFirstName("John");
    billing.setLastName("Bossanova");
    billing.setAddress("Billing address");
    billing.setCountry(country);
    billing.setZone(zone);
    customer.setBilling(billing);
    customer.setDelivery(delivery);
    customerService.create(customer);
    customer = customerService.getById(customer.getId());
    // create an option value
    CustomerOptionValue yes = new CustomerOptionValue();
    yes.setCode("yes");
    yes.setMerchantStore(store);
    CustomerOptionValueDescription yesDescription = new CustomerOptionValueDescription();
    yesDescription.setLanguage(en);
    yesDescription.setCustomerOptionValue(yes);
    CustomerOptionValueDescription yes_sir = new CustomerOptionValueDescription();
    yes_sir.setCustomerOptionValue(yes);
    yes_sir.setDescription("Yes sir!");
    yes_sir.setName("Yes sir!");
    yes_sir.setLanguage(en);
    yes.getDescriptions().add(yes_sir);
    // needs to be saved before using it
    customerOptionValueService.create(yes);
    CustomerOptionValue no = new CustomerOptionValue();
    no.setCode("no");
    no.setMerchantStore(store);
    CustomerOptionValueDescription noDescription = new CustomerOptionValueDescription();
    noDescription.setLanguage(en);
    noDescription.setCustomerOptionValue(no);
    CustomerOptionValueDescription no_sir = new CustomerOptionValueDescription();
    no_sir.setCustomerOptionValue(no);
    no_sir.setDescription("Nope!");
    no_sir.setName("Nope!");
    no_sir.setLanguage(en);
    no.getDescriptions().add(no_sir);
    // needs to be saved before using it
    customerOptionValueService.create(no);
    // create a customer option to be used
    CustomerOption subscribedToMailingList = new CustomerOption();
    subscribedToMailingList.setActive(true);
    subscribedToMailingList.setPublicOption(true);
    subscribedToMailingList.setCode("subscribedToMailingList");
    subscribedToMailingList.setMerchantStore(store);
    CustomerOptionDescription mailingListDesciption = new CustomerOptionDescription();
    mailingListDesciption.setName("Subscribed to mailing list");
    mailingListDesciption.setDescription("Subscribed to mailing list");
    mailingListDesciption.setLanguage(en);
    mailingListDesciption.setCustomerOption(subscribedToMailingList);
    Set<CustomerOptionDescription> mailingListDesciptionList = new HashSet<CustomerOptionDescription>();
    mailingListDesciptionList.add(mailingListDesciption);
    subscribedToMailingList.setDescriptions(mailingListDesciptionList);
    customerOptionService.create(subscribedToMailingList);
    // create a customer option to be used
    CustomerOption hasReturnedItems = new CustomerOption();
    hasReturnedItems.setActive(true);
    hasReturnedItems.setPublicOption(true);
    hasReturnedItems.setCode("hasReturnedItems");
    hasReturnedItems.setMerchantStore(store);
    CustomerOptionDescription hasReturnedItemsDesciption = new CustomerOptionDescription();
    hasReturnedItemsDesciption.setName("Has returned items");
    hasReturnedItemsDesciption.setDescription("Has returned items");
    hasReturnedItemsDesciption.setLanguage(en);
    hasReturnedItemsDesciption.setCustomerOption(hasReturnedItems);
    Set<CustomerOptionDescription> hasReturnedItemsList = new HashSet<CustomerOptionDescription>();
    hasReturnedItemsList.add(hasReturnedItemsDesciption);
    hasReturnedItems.setDescriptions(hasReturnedItemsList);
    customerOptionService.create(hasReturnedItems);
    subscribedToMailingList.setSortOrder(3);
    customerOptionService.update(subscribedToMailingList);
    // --
    // now create an option set (association of a customer option with possible customer option values)
    // --
    // possible yes
    CustomerOptionSet mailingListSetYes = new CustomerOptionSet();
    mailingListSetYes.setSortOrder(0);
    mailingListSetYes.setCustomerOption(subscribedToMailingList);
    mailingListSetYes.setCustomerOptionValue(yes);
    customerOptionSetService.create(mailingListSetYes);
    // possible no
    CustomerOptionSet mailingListSetNo = new CustomerOptionSet();
    // mailingListSetNo.setPk(mailingListSetNoId);
    mailingListSetNo.setSortOrder(1);
    mailingListSetNo.setCustomerOption(subscribedToMailingList);
    mailingListSetNo.setCustomerOptionValue(no);
    customerOptionSetService.create(mailingListSetNo);
    // possible has returned items
    CustomerOptionSet hasReturnedItemsYes = new CustomerOptionSet();
    hasReturnedItemsYes.setSortOrder(0);
    hasReturnedItemsYes.setCustomerOption(hasReturnedItems);
    hasReturnedItemsYes.setCustomerOptionValue(yes);
    customerOptionSetService.create(hasReturnedItemsYes);
    subscribedToMailingList.setSortOrder(2);
    customerOptionService.update(subscribedToMailingList);
    CustomerOption option = customerOptionService.getById(subscribedToMailingList.getId());
    option.setSortOrder(4);
    customerOptionService.update(option);
    List<CustomerOptionSet> optionSetList = customerOptionSetService.listByStore(store, en);
    // Assert.assertEquals(3, optionSetList.size());
    System.out.println("Size of options : " + optionSetList.size());
    /**
     * Now create a customer option attribute
     * A customer attribute is a selected customer option set transformed to an
     * attribute for a given customer
     */
    CustomerAttribute customerAttributeMailingList = new CustomerAttribute();
    customerAttributeMailingList.setCustomer(customer);
    customerAttributeMailingList.setCustomerOption(subscribedToMailingList);
    customerAttributeMailingList.setCustomerOptionValue(no);
    customer.getAttributes().add(customerAttributeMailingList);
    customerService.save(customer);
    customerService.delete(customer);
}
Also used : CustomerOptionDescription(com.salesmanager.core.model.customer.attribute.CustomerOptionDescription) Customer(com.salesmanager.core.model.customer.Customer) Zone(com.salesmanager.core.model.reference.zone.Zone) CustomerOptionSet(com.salesmanager.core.model.customer.attribute.CustomerOptionSet) Date(java.util.Date) CustomerOption(com.salesmanager.core.model.customer.attribute.CustomerOption) CustomerOptionValue(com.salesmanager.core.model.customer.attribute.CustomerOptionValue) Language(com.salesmanager.core.model.reference.language.Language) CustomerAttribute(com.salesmanager.core.model.customer.attribute.CustomerAttribute) Billing(com.salesmanager.core.model.common.Billing) Country(com.salesmanager.core.model.reference.country.Country) CustomerOptionValueDescription(com.salesmanager.core.model.customer.attribute.CustomerOptionValueDescription) Delivery(com.salesmanager.core.model.common.Delivery) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 18 with Customer

use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.

the class AbstractCustomerServices method loadUserByUsername.

public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException, DataAccessException {
    Customer user = null;
    Collection<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
    try {
        LOGGER.debug("Loading user by user id: {}", userName);
        user = customerService.getByNick(userName);
        if (user == null) {
            // return null;
            throw new UsernameNotFoundException("User " + userName + " not found");
        }
        // required to login
        GrantedAuthority role = new SimpleGrantedAuthority(ROLE_PREFIX + Constants.PERMISSION_CUSTOMER_AUTHENTICATED);
        authorities.add(role);
        List<Integer> groupsId = new ArrayList<Integer>();
        List<Group> groups = user.getGroups();
        for (Group group : groups) {
            groupsId.add(group.getId());
        }
        if (CollectionUtils.isNotEmpty(groupsId)) {
            List<Permission> permissions = permissionService.getPermissions(groupsId);
            for (Permission permission : permissions) {
                GrantedAuthority auth = new SimpleGrantedAuthority(permission.getPermissionName());
                authorities.add(auth);
            }
        }
    } catch (ServiceException e) {
        LOGGER.error("Exception while querrying customer", e);
        throw new SecurityDataAccessException("Cannot authenticate customer", e);
    }
    return userDetails(userName, user, authorities);
}
Also used : UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) Group(com.salesmanager.core.model.user.Group) Customer(com.salesmanager.core.model.customer.Customer) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) GrantedAuthority(org.springframework.security.core.GrantedAuthority) SecurityDataAccessException(com.salesmanager.shop.admin.security.SecurityDataAccessException) ArrayList(java.util.ArrayList) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) ServiceException(com.salesmanager.core.business.exception.ServiceException) Permission(com.salesmanager.core.model.user.Permission)

Example 19 with Customer

use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.

the class PersistableProductReviewPopulator method populate.

@Override
public ProductReview populate(PersistableProductReview source, ProductReview target, MerchantStore store, Language language) throws ConversionException {
    Validate.notNull(customerService, "customerService cannot be null");
    Validate.notNull(productService, "productService cannot be null");
    Validate.notNull(languageService, "languageService cannot be null");
    Validate.notNull(source.getRating(), "Rating cannot bot be null");
    try {
        if (target == null) {
            target = new ProductReview();
        }
        Customer customer = customerService.getById(source.getCustomerId());
        // check if customer belongs to store
        if (customer == null || customer.getMerchantStore().getId().intValue() != store.getId().intValue()) {
            throw new ConversionException("Invalid customer id for the given store");
        }
        if (source.getDate() == null) {
            String date = DateUtil.formatDate(new Date());
            source.setDate(date);
        }
        target.setReviewDate(DateUtil.getDate(source.getDate()));
        target.setCustomer(customer);
        target.setReviewRating(source.getRating());
        Product product = productService.getById(source.getProductId());
        // check if product belongs to store
        if (product == null || product.getMerchantStore().getId().intValue() != store.getId().intValue()) {
            throw new ConversionException("Invalid product id for the given store");
        }
        target.setProduct(product);
        Language lang = languageService.getByCode(language.getCode());
        if (lang == null) {
            throw new ConversionException("Invalid language code, use iso codes (en, fr ...)");
        }
        ProductReviewDescription description = new ProductReviewDescription();
        description.setDescription(source.getDescription());
        description.setLanguage(lang);
        description.setName("-");
        description.setProductReview(target);
        Set<ProductReviewDescription> descriptions = new HashSet<ProductReviewDescription>();
        descriptions.add(description);
        target.setDescriptions(descriptions);
        return target;
    } catch (Exception e) {
        throw new ConversionException("Cannot populate ProductReview", e);
    }
}
Also used : ConversionException(com.salesmanager.core.business.exception.ConversionException) Language(com.salesmanager.core.model.reference.language.Language) Customer(com.salesmanager.core.model.customer.Customer) Product(com.salesmanager.core.model.catalog.product.Product) ProductReviewDescription(com.salesmanager.core.model.catalog.product.review.ProductReviewDescription) ProductReview(com.salesmanager.core.model.catalog.product.review.ProductReview) PersistableProductReview(com.salesmanager.shop.model.catalog.product.PersistableProductReview) Date(java.util.Date) ConversionException(com.salesmanager.core.business.exception.ConversionException) HashSet(java.util.HashSet)

Example 20 with Customer

use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.

the class PersistableOrderApiPopulator method populate.

@Override
public Order populate(PersistableOrder source, Order target, MerchantStore store, Language language) throws ConversionException {
    /*		Validate.notNull(currencyService,"currencyService must be set");
		Validate.notNull(customerService,"customerService must be set");
		Validate.notNull(shoppingCartService,"shoppingCartService must be set");
		Validate.notNull(productService,"productService must be set");
		Validate.notNull(productAttributeService,"productAttributeService must be set");
		Validate.notNull(digitalProductService,"digitalProductService must be set");*/
    Validate.notNull(source.getPayment(), "Payment cannot be null");
    try {
        if (target == null) {
            target = new Order();
        }
        // target.setLocale(LocaleUtils.getLocale(store));
        target.setLocale(LocaleUtils.getLocale(store));
        Currency currency = null;
        try {
            currency = currencyService.getByCode(source.getCurrency());
        } catch (Exception e) {
            throw new ConversionException("Currency not found for code " + source.getCurrency());
        }
        if (currency == null) {
            throw new ConversionException("Currency not found for code " + source.getCurrency());
        }
        // Customer
        Customer customer = null;
        if (source.getCustomerId() != null && source.getCustomerId().longValue() > 0) {
            Long customerId = source.getCustomerId();
            customer = customerService.getById(customerId);
            if (customer == null) {
                throw new ConversionException("Curstomer with id " + source.getCustomerId() + " does not exist");
            }
            target.setCustomerId(customerId);
        } else {
            if (source instanceof PersistableAnonymousOrder) {
                PersistableCustomer persistableCustomer = ((PersistableAnonymousOrder) source).getCustomer();
                customer = new Customer();
                customer = customerPopulator.populate(persistableCustomer, customer, store, language);
            } else {
                throw new ConversionException("Curstomer details or id not set in request");
            }
        }
        target.setCustomerEmailAddress(customer.getEmailAddress());
        Delivery delivery = customer.getDelivery();
        target.setDelivery(delivery);
        Billing billing = customer.getBilling();
        target.setBilling(billing);
        if (source.getAttributes() != null && source.getAttributes().size() > 0) {
            Set<OrderAttribute> attrs = new HashSet<OrderAttribute>();
            for (com.salesmanager.shop.model.order.OrderAttribute attribute : source.getAttributes()) {
                OrderAttribute attr = new OrderAttribute();
                attr.setKey(attribute.getKey());
                attr.setValue(attribute.getValue());
                attr.setOrder(target);
                attrs.add(attr);
            }
            target.setOrderAttributes(attrs);
        }
        target.setDatePurchased(new Date());
        target.setCurrency(currency);
        target.setCurrencyValue(new BigDecimal(0));
        target.setMerchant(store);
        target.setChannel(OrderChannel.API);
        // need this
        target.setStatus(OrderStatus.ORDERED);
        target.setPaymentModuleCode(source.getPayment().getPaymentModule());
        target.setPaymentType(PaymentType.valueOf(source.getPayment().getPaymentType()));
        target.setCustomerAgreement(source.isCustomerAgreement());
        // force this to true, cannot perform this activity from the API
        target.setConfirmedAddress(true);
        if (!StringUtils.isBlank(source.getComments())) {
            OrderStatusHistory statusHistory = new OrderStatusHistory();
            statusHistory.setStatus(null);
            statusHistory.setOrder(target);
            statusHistory.setComments(source.getComments());
            target.getOrderHistory().add(statusHistory);
        }
        return target;
    } catch (Exception e) {
        throw new ConversionException(e);
    }
}
Also used : PersistableAnonymousOrder(com.salesmanager.shop.model.order.v1.PersistableAnonymousOrder) Order(com.salesmanager.core.model.order.Order) PersistableOrder(com.salesmanager.shop.model.order.v1.PersistableOrder) ConversionException(com.salesmanager.core.business.exception.ConversionException) Customer(com.salesmanager.core.model.customer.Customer) PersistableCustomer(com.salesmanager.shop.model.customer.PersistableCustomer) PersistableCustomer(com.salesmanager.shop.model.customer.PersistableCustomer) ConversionException(com.salesmanager.core.business.exception.ConversionException) Date(java.util.Date) BigDecimal(java.math.BigDecimal) Currency(com.salesmanager.core.model.reference.currency.Currency) Billing(com.salesmanager.core.model.common.Billing) OrderAttribute(com.salesmanager.core.model.order.attributes.OrderAttribute) PersistableAnonymousOrder(com.salesmanager.shop.model.order.v1.PersistableAnonymousOrder) Delivery(com.salesmanager.core.model.common.Delivery) OrderStatusHistory(com.salesmanager.core.model.order.orderstatus.OrderStatusHistory) HashSet(java.util.HashSet)

Aggregations

Customer (com.salesmanager.core.model.customer.Customer)71 PersistableCustomer (com.salesmanager.shop.model.customer.PersistableCustomer)33 ReadableCustomer (com.salesmanager.shop.model.customer.ReadableCustomer)32 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)31 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)30 Language (com.salesmanager.core.model.reference.language.Language)26 ResourceNotFoundException (com.salesmanager.shop.store.api.exception.ResourceNotFoundException)17 ServiceRuntimeException (com.salesmanager.shop.store.api.exception.ServiceRuntimeException)17 ConversionException (com.salesmanager.core.business.exception.ConversionException)16 ServiceException (com.salesmanager.core.business.exception.ServiceException)16 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)16 ShoppingCart (com.salesmanager.core.model.shoppingcart.ShoppingCart)12 ApiImplicitParams (io.swagger.annotations.ApiImplicitParams)12 Authentication (org.springframework.security.core.Authentication)12 Date (java.util.Date)11 ConversionRuntimeException (com.salesmanager.shop.store.api.exception.ConversionRuntimeException)10 ArrayList (java.util.ArrayList)10 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)10 Product (com.salesmanager.core.model.catalog.product.Product)9 Country (com.salesmanager.core.model.reference.country.Country)9