Search in sources :

Example 1 with Optin

use of com.salesmanager.core.model.system.optin.Optin in project shopizer by shopizer-ecommerce.

the class InitializationDatabaseImpl method createMerchant.

private void createMerchant() throws ServiceException {
    LOGGER.info(String.format("%s : Creating merchant ", name));
    Date date = new Date(System.currentTimeMillis());
    Language en = languageService.getByCode("en");
    Country ca = countryService.getByCode("CA");
    Currency currency = currencyService.getByCode("CAD");
    Zone qc = zoneService.getByCode("QC");
    List<Language> supportedLanguages = new ArrayList<Language>();
    supportedLanguages.add(en);
    // create a merchant
    MerchantStore store = new MerchantStore();
    store.setCountry(ca);
    store.setCurrency(currency);
    store.setDefaultLanguage(en);
    store.setInBusinessSince(date);
    store.setZone(qc);
    store.setStorename("Default store");
    store.setStorephone("888-888-8888");
    store.setCode(MerchantStore.DEFAULT_STORE);
    store.setStorecity("My city");
    store.setStoreaddress("1234 Street address");
    store.setStorepostalcode("H2H-2H2");
    store.setStoreEmailAddress("john@test.com");
    store.setDomainName("localhost:8080");
    store.setStoreTemplate("december");
    store.setRetailer(true);
    store.setLanguages(supportedLanguages);
    merchantService.create(store);
    TaxClass taxclass = new TaxClass(TaxClass.DEFAULT_TAX_CLASS);
    taxclass.setMerchantStore(store);
    taxClassService.create(taxclass);
    // create default manufacturer
    Manufacturer defaultManufacturer = new Manufacturer();
    defaultManufacturer.setCode("DEFAULT");
    defaultManufacturer.setMerchantStore(store);
    ManufacturerDescription manufacturerDescription = new ManufacturerDescription();
    manufacturerDescription.setLanguage(en);
    manufacturerDescription.setName("DEFAULT");
    manufacturerDescription.setManufacturer(defaultManufacturer);
    manufacturerDescription.setDescription("DEFAULT");
    defaultManufacturer.getDescriptions().add(manufacturerDescription);
    manufacturerService.create(defaultManufacturer);
    Optin newsletter = new Optin();
    newsletter.setCode(OptinType.NEWSLETTER.name());
    newsletter.setMerchant(store);
    newsletter.setOptinType(OptinType.NEWSLETTER);
    optinService.create(newsletter);
}
Also used : Language(com.salesmanager.core.model.reference.language.Language) Optin(com.salesmanager.core.model.system.optin.Optin) Zone(com.salesmanager.core.model.reference.zone.Zone) Currency(com.salesmanager.core.model.reference.currency.Currency) ArrayList(java.util.ArrayList) Manufacturer(com.salesmanager.core.model.catalog.product.manufacturer.Manufacturer) Country(com.salesmanager.core.model.reference.country.Country) ManufacturerDescription(com.salesmanager.core.model.catalog.product.manufacturer.ManufacturerDescription) TaxClass(com.salesmanager.core.model.tax.taxclass.TaxClass) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) Date(java.sql.Date)

Example 2 with Optin

use of com.salesmanager.core.model.system.optin.Optin in project shopizer by shopizer-ecommerce.

the class CustomerFacadeImpl method optinCustomer.

@Override
public void optinCustomer(PersistableCustomerOptin optin, MerchantStore store) {
    // check if customer optin exists
    Optin optinDef = getOptinByCode(store);
    CustomerOptin customerOptin = getCustomerOptinByEmailAddress(optin.getEmail(), store, OptinType.NEWSLETTER);
    if (customerOptin != null) {
        // exists update
        customerOptin.setEmail(optin.getEmail());
        customerOptin.setFirstName(optin.getFirstName());
        customerOptin.setLastName(optin.getLastName());
    } else {
        customerOptin = new com.salesmanager.core.model.system.optin.CustomerOptin();
        customerOptin.setEmail(optin.getEmail());
        customerOptin.setFirstName(optin.getFirstName());
        customerOptin.setLastName(optin.getLastName());
        customerOptin.setOptinDate(new Date());
        customerOptin.setOptin(optinDef);
        customerOptin.setMerchantStore(store);
    }
    saveCustomerOption(customerOptin);
}
Also used : Optin(com.salesmanager.core.model.system.optin.Optin) CustomerOptin(com.salesmanager.core.model.system.optin.CustomerOptin) PersistableCustomerOptin(com.salesmanager.shop.model.customer.optin.PersistableCustomerOptin) CustomerOptin(com.salesmanager.core.model.system.optin.CustomerOptin) CustomerOptin(com.salesmanager.core.model.system.optin.CustomerOptin) PersistableCustomerOptin(com.salesmanager.shop.model.customer.optin.PersistableCustomerOptin) Date(java.util.Date)

Example 3 with Optin

use of com.salesmanager.core.model.system.optin.Optin in project shopizer by shopizer-ecommerce.

the class OptinFacadeImpl method create.

@Override
public ReadableOptin create(PersistableOptin persistableOptin, MerchantStore merchantStore, Language language) {
    Optin optinEntity = persistableOptinConverter.convert(persistableOptin, merchantStore, language);
    Optin savedOptinEntity = createOptin(optinEntity);
    return readableOptinConverter.convert(savedOptinEntity, merchantStore, language);
}
Also used : ReadableOptin(com.salesmanager.shop.model.system.ReadableOptin) Optin(com.salesmanager.core.model.system.optin.Optin) PersistableOptin(com.salesmanager.shop.model.system.PersistableOptin)

Example 4 with Optin

use of com.salesmanager.core.model.system.optin.Optin in project shopizer by shopizer-ecommerce.

the class PersistableOptinMapper method convert.

@Override
public Optin convert(PersistableOptin source, MerchantStore store, Language language) {
    Optin optinEntity = new Optin();
    optinEntity.setCode(source.getCode());
    optinEntity.setDescription(source.getDescription());
    optinEntity.setOptinType(OptinType.valueOf(source.getOptinType()));
    optinEntity.setMerchant(store);
    return optinEntity;
}
Also used : Optin(com.salesmanager.core.model.system.optin.Optin) PersistableOptin(com.salesmanager.shop.model.system.PersistableOptin)

Aggregations

Optin (com.salesmanager.core.model.system.optin.Optin)4 PersistableOptin (com.salesmanager.shop.model.system.PersistableOptin)2 Manufacturer (com.salesmanager.core.model.catalog.product.manufacturer.Manufacturer)1 ManufacturerDescription (com.salesmanager.core.model.catalog.product.manufacturer.ManufacturerDescription)1 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)1 Country (com.salesmanager.core.model.reference.country.Country)1 Currency (com.salesmanager.core.model.reference.currency.Currency)1 Language (com.salesmanager.core.model.reference.language.Language)1 Zone (com.salesmanager.core.model.reference.zone.Zone)1 CustomerOptin (com.salesmanager.core.model.system.optin.CustomerOptin)1 TaxClass (com.salesmanager.core.model.tax.taxclass.TaxClass)1 PersistableCustomerOptin (com.salesmanager.shop.model.customer.optin.PersistableCustomerOptin)1 ReadableOptin (com.salesmanager.shop.model.system.ReadableOptin)1 Date (java.sql.Date)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1