Search in sources :

Example 86 with MerchantStore

use of com.salesmanager.core.model.merchant.MerchantStore in project shopizer by shopizer-ecommerce.

the class ShoppingCartFacadeImpl method getShoppingCartData.

// @Override
public ShoppingCartData getShoppingCartData(ShoppingCart shoppingCartModel, Language language) throws Exception {
    Validate.notNull(shoppingCartModel, "Shopping Cart cannot be null");
    ShoppingCartDataPopulator shoppingCartDataPopulator = new ShoppingCartDataPopulator();
    shoppingCartDataPopulator.setShoppingCartCalculationService(shoppingCartCalculationService);
    shoppingCartDataPopulator.setPricingService(pricingService);
    shoppingCartDataPopulator.setimageUtils(imageUtils);
    // Language language = (Language) getKeyValue( Constants.LANGUAGE );
    MerchantStore merchantStore = (MerchantStore) getKeyValue(Constants.MERCHANT_STORE);
    return shoppingCartDataPopulator.populate(shoppingCartModel, merchantStore, language);
}
Also used : ShoppingCartDataPopulator(com.salesmanager.shop.populator.shoppingCart.ShoppingCartDataPopulator) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore)

Example 87 with MerchantStore

use of com.salesmanager.core.model.merchant.MerchantStore in project shopizer by shopizer-ecommerce.

the class StoreFacadeImpl method findAll.

@Override
public ReadableMerchantStoreList findAll(MerchantStoreCriteria criteria, Language language, int page, int count) {
    try {
        Page<MerchantStore> stores = null;
        List<ReadableMerchantStore> readableStores = new ArrayList<ReadableMerchantStore>();
        ReadableMerchantStoreList readableList = new ReadableMerchantStoreList();
        Optional<String> code = Optional.ofNullable(criteria.getStoreCode());
        Optional<String> name = Optional.ofNullable(criteria.getName());
        if (code.isPresent()) {
            stores = merchantStoreService.listByGroup(name, code.get(), page, count);
        } else {
            if (criteria.isRetailers()) {
                stores = merchantStoreService.listAllRetailers(name, page, count);
            } else {
                stores = merchantStoreService.listAll(name, page, count);
            }
        }
        if (!CollectionUtils.isEmpty(stores.getContent())) {
            for (MerchantStore store : stores) readableStores.add(convertMerchantStoreToReadableMerchantStore(language, store));
        }
        readableList.setData(readableStores);
        readableList.setRecordsTotal(stores.getTotalElements());
        readableList.setTotalPages(stores.getTotalPages());
        readableList.setNumber(stores.getSize());
        readableList.setRecordsFiltered(stores.getSize());
        return readableList;
    } catch (ServiceException e) {
        throw new ServiceRuntimeException("Error while finding all merchant", e);
    }
}
Also used : ReadableMerchantStore(com.salesmanager.shop.model.store.ReadableMerchantStore) ReadableMerchantStoreList(com.salesmanager.shop.model.store.ReadableMerchantStoreList) ServiceException(com.salesmanager.core.business.exception.ServiceException) ArrayList(java.util.ArrayList) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ReadableMerchantStore(com.salesmanager.shop.model.store.ReadableMerchantStore) PersistableMerchantStore(com.salesmanager.shop.model.store.PersistableMerchantStore) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException)

Example 88 with MerchantStore

use of com.salesmanager.core.model.merchant.MerchantStore in project shopizer by shopizer-ecommerce.

the class StoreFacadeImpl method update.

@Override
public void update(PersistableMerchantStore store) {
    Validate.notNull(store);
    MerchantStore mStore = mergePersistableMerchantStoreToMerchantStore(store, store.getCode(), languageService.defaultLanguage());
    updateMerchantStore(mStore);
}
Also used : MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ReadableMerchantStore(com.salesmanager.shop.model.store.ReadableMerchantStore) PersistableMerchantStore(com.salesmanager.shop.model.store.PersistableMerchantStore)

Example 89 with MerchantStore

use of com.salesmanager.core.model.merchant.MerchantStore in project shopizer by shopizer-ecommerce.

the class StoreFacadeImpl method convertPersistableMerchantStoreToMerchantStore.

private MerchantStore convertPersistableMerchantStoreToMerchantStore(PersistableMerchantStore store, Language language) {
    MerchantStore mStore = new MerchantStore();
    // set default values
    mStore.setWeightunitcode(MeasureUnit.KG.name());
    mStore.setSeizeunitcode(MeasureUnit.IN.name());
    try {
        mStore = persistableMerchantStorePopulator.populate(store, mStore, language);
    } catch (ConversionException e) {
        throw new ConversionRuntimeException(e);
    }
    return mStore;
}
Also used : ConversionException(com.salesmanager.core.business.exception.ConversionException) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ReadableMerchantStore(com.salesmanager.shop.model.store.ReadableMerchantStore) PersistableMerchantStore(com.salesmanager.shop.model.store.PersistableMerchantStore) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException)

Example 90 with MerchantStore

use of com.salesmanager.core.model.merchant.MerchantStore in project shopizer by shopizer-ecommerce.

the class StoreFacadeImpl method addStoreLogo.

@Override
public void addStoreLogo(String code, InputContentFile cmsContentImage) {
    MerchantStore store = getByCode(code);
    store.setStoreLogo(cmsContentImage.getFileName());
    saveMerchantStore(store);
    addLogoToStore(code, cmsContentImage);
}
Also used : MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ReadableMerchantStore(com.salesmanager.shop.model.store.ReadableMerchantStore) PersistableMerchantStore(com.salesmanager.shop.model.store.PersistableMerchantStore)

Aggregations

MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)171 Language (com.salesmanager.core.model.reference.language.Language)123 ServiceException (com.salesmanager.core.business.exception.ServiceException)72 List (java.util.List)65 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)62 ArrayList (java.util.ArrayList)61 ServiceRuntimeException (com.salesmanager.shop.store.api.exception.ServiceRuntimeException)60 Collectors (java.util.stream.Collectors)60 ResourceNotFoundException (com.salesmanager.shop.store.api.exception.ResourceNotFoundException)52 Autowired (org.springframework.beans.factory.annotation.Autowired)46 Product (com.salesmanager.core.model.catalog.product.Product)43 Service (org.springframework.stereotype.Service)37 Optional (java.util.Optional)35 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)35 Customer (com.salesmanager.core.model.customer.Customer)33 Logger (org.slf4j.Logger)33 LoggerFactory (org.slf4j.LoggerFactory)33 Inject (javax.inject.Inject)32 Validate (org.apache.commons.lang3.Validate)30 ConversionException (com.salesmanager.core.business.exception.ConversionException)27