Search in sources :

Example 1 with OrderStatusHistory

use of com.salesmanager.core.model.order.orderstatus.OrderStatusHistory in project shopizer by shopizer-ecommerce.

the class PaymentServiceImpl method processRefund.

@Override
public Transaction processRefund(Order order, Customer customer, MerchantStore store, BigDecimal amount) throws ServiceException {
    Validate.notNull(customer);
    Validate.notNull(store);
    Validate.notNull(amount);
    Validate.notNull(order);
    Validate.notNull(order.getOrderTotal());
    BigDecimal orderTotal = order.getTotal();
    if (amount.doubleValue() > orderTotal.doubleValue()) {
        throw new ServiceException("Invalid amount, the refunded amount is greater than the total allowed");
    }
    String module = order.getPaymentModuleCode();
    Map<String, IntegrationConfiguration> modules = this.getPaymentModulesConfigured(store);
    if (modules == null) {
        throw new ServiceException("No payment module configured");
    }
    IntegrationConfiguration configuration = modules.get(module);
    if (configuration == null) {
        throw new ServiceException("Payment module " + module + " is not configured");
    }
    PaymentModule paymentModule = this.paymentModules.get(module);
    if (paymentModule == null) {
        throw new ServiceException("Payment module " + paymentModule + " does not exist");
    }
    boolean partial = false;
    if (amount.doubleValue() != order.getTotal().doubleValue()) {
        partial = true;
    }
    IntegrationModule integrationModule = getPaymentMethodByCode(store, module);
    // get the associated transaction
    Transaction refundable = transactionService.getRefundableTransaction(order);
    if (refundable == null) {
        throw new ServiceException("No refundable transaction for this order");
    }
    Transaction transaction = paymentModule.refund(partial, store, refundable, order, amount, configuration, integrationModule);
    transaction.setOrder(order);
    transactionService.create(transaction);
    OrderTotal refund = new OrderTotal();
    refund.setModule(Constants.OT_REFUND_MODULE_CODE);
    refund.setText(Constants.OT_REFUND_MODULE_CODE);
    refund.setTitle(Constants.OT_REFUND_MODULE_CODE);
    refund.setOrderTotalCode(Constants.OT_REFUND_MODULE_CODE);
    refund.setOrderTotalType(OrderTotalType.REFUND);
    refund.setValue(amount);
    refund.setSortOrder(100);
    refund.setOrder(order);
    order.getOrderTotal().add(refund);
    // update order total
    orderTotal = orderTotal.subtract(amount);
    // update ordertotal refund
    Set<OrderTotal> totals = order.getOrderTotal();
    for (OrderTotal total : totals) {
        if (total.getModule().equals(Constants.OT_TOTAL_MODULE_CODE)) {
            total.setValue(orderTotal);
        }
    }
    order.setTotal(orderTotal);
    order.setStatus(OrderStatus.REFUNDED);
    OrderStatusHistory orderHistory = new OrderStatusHistory();
    orderHistory.setOrder(order);
    orderHistory.setStatus(OrderStatus.REFUNDED);
    orderHistory.setDateAdded(new Date());
    order.getOrderHistory().add(orderHistory);
    orderService.saveOrUpdate(order);
    return transaction;
}
Also used : IntegrationConfiguration(com.salesmanager.core.model.system.IntegrationConfiguration) BigDecimal(java.math.BigDecimal) Date(java.util.Date) PaymentModule(com.salesmanager.core.modules.integration.payment.model.PaymentModule) ServiceException(com.salesmanager.core.business.exception.ServiceException) Transaction(com.salesmanager.core.model.payments.Transaction) OrderTotal(com.salesmanager.core.model.order.OrderTotal) OrderStatusHistory(com.salesmanager.core.model.order.orderstatus.OrderStatusHistory) IntegrationModule(com.salesmanager.core.model.system.IntegrationModule)

Example 2 with OrderStatusHistory

use of com.salesmanager.core.model.order.orderstatus.OrderStatusHistory 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)

Example 3 with OrderStatusHistory

use of com.salesmanager.core.model.order.orderstatus.OrderStatusHistory in project shopizer by shopizer-ecommerce.

the class PersistableOrderPopulator method populate.

@Override
public Order populate(PersistableOrder source, Order target, MerchantStore store, Language language) throws ConversionException {
    Validate.notNull(productService, "productService must be set");
    Validate.notNull(digitalProductService, "digitalProductService must be set");
    Validate.notNull(productAttributeService, "productAttributeService must be set");
    Validate.notNull(customerService, "customerService must be set");
    Validate.notNull(countryService, "countryService must be set");
    Validate.notNull(zoneService, "zoneService must be set");
    Validate.notNull(currencyService, "currencyService must be set");
    try {
        Map<String, Country> countriesMap = countryService.getCountriesMap(language);
        Map<String, Zone> zonesMap = zoneService.getZones(language);
        /**
         * customer *
         */
        PersistableCustomer customer = source.getCustomer();
        if (customer != null) {
            if (customer.getId() != null && customer.getId() > 0) {
                Customer modelCustomer = customerService.getById(customer.getId());
                if (modelCustomer == null) {
                    throw new ConversionException("Customer id " + customer.getId() + " does not exists");
                }
                if (modelCustomer.getMerchantStore().getId().intValue() != store.getId().intValue()) {
                    throw new ConversionException("Customer id " + customer.getId() + " does not exists for store " + store.getCode());
                }
                target.setCustomerId(modelCustomer.getId());
                target.setBilling(modelCustomer.getBilling());
                target.setDelivery(modelCustomer.getDelivery());
                target.setCustomerEmailAddress(source.getCustomer().getEmailAddress());
            }
        }
        target.setLocale(LocaleUtils.getLocale(store));
        CreditCard creditCard = source.getCreditCard();
        if (creditCard != null) {
            String maskedNumber = CreditCardUtils.maskCardNumber(creditCard.getCcNumber());
            creditCard.setCcNumber(maskedNumber);
            target.setCreditCard(creditCard);
        }
        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());
        }
        target.setCurrency(currency);
        target.setDatePurchased(source.getDatePurchased());
        // target.setCurrency(store.getCurrency());
        target.setCurrencyValue(new BigDecimal(0));
        target.setMerchant(store);
        target.setStatus(source.getOrderStatus());
        target.setPaymentModuleCode(source.getPaymentModule());
        target.setPaymentType(source.getPaymentType());
        target.setShippingModuleCode(source.getShippingModule());
        target.setCustomerAgreement(source.isCustomerAgreed());
        target.setConfirmedAddress(source.isConfirmedAddress());
        if (source.getPreviousOrderStatus() != null) {
            List<OrderStatus> orderStatusList = source.getPreviousOrderStatus();
            for (OrderStatus status : orderStatusList) {
                OrderStatusHistory statusHistory = new OrderStatusHistory();
                statusHistory.setStatus(status);
                statusHistory.setOrder(target);
                target.getOrderHistory().add(statusHistory);
            }
        }
        if (!StringUtils.isBlank(source.getComments())) {
            OrderStatusHistory statusHistory = new OrderStatusHistory();
            statusHistory.setStatus(null);
            statusHistory.setOrder(target);
            statusHistory.setComments(source.getComments());
            target.getOrderHistory().add(statusHistory);
        }
        List<PersistableOrderProduct> products = source.getOrderProductItems();
        if (CollectionUtils.isEmpty(products)) {
            throw new ConversionException("Requires at least 1 PersistableOrderProduct");
        }
        com.salesmanager.shop.populator.order.PersistableOrderProductPopulator orderProductPopulator = new PersistableOrderProductPopulator();
        orderProductPopulator.setProductAttributeService(productAttributeService);
        orderProductPopulator.setProductService(productService);
        orderProductPopulator.setDigitalProductService(digitalProductService);
        for (PersistableOrderProduct orderProduct : products) {
            OrderProduct modelOrderProduct = new OrderProduct();
            orderProductPopulator.populate(orderProduct, modelOrderProduct, store, language);
            target.getOrderProducts().add(modelOrderProduct);
        }
        List<OrderTotal> orderTotals = source.getTotals();
        if (CollectionUtils.isNotEmpty(orderTotals)) {
            for (OrderTotal total : orderTotals) {
                com.salesmanager.core.model.order.OrderTotal totalModel = new com.salesmanager.core.model.order.OrderTotal();
                totalModel.setModule(total.getModule());
                totalModel.setOrder(target);
                totalModel.setOrderTotalCode(total.getCode());
                totalModel.setTitle(total.getTitle());
                totalModel.setValue(total.getValue());
                target.getOrderTotal().add(totalModel);
            }
        }
    } catch (Exception e) {
        throw new ConversionException(e);
    }
    return target;
}
Also used : OrderProduct(com.salesmanager.core.model.order.orderproduct.OrderProduct) PersistableOrderProduct(com.salesmanager.shop.model.order.PersistableOrderProduct) Customer(com.salesmanager.core.model.customer.Customer) PersistableCustomer(com.salesmanager.shop.model.customer.PersistableCustomer) PersistableCustomer(com.salesmanager.shop.model.customer.PersistableCustomer) PersistableOrderProduct(com.salesmanager.shop.model.order.PersistableOrderProduct) OrderStatus(com.salesmanager.core.model.order.orderstatus.OrderStatus) Currency(com.salesmanager.core.model.reference.currency.Currency) ConversionException(com.salesmanager.core.business.exception.ConversionException) Zone(com.salesmanager.core.model.reference.zone.Zone) CreditCard(com.salesmanager.core.model.order.payment.CreditCard) ConversionException(com.salesmanager.core.business.exception.ConversionException) BigDecimal(java.math.BigDecimal) Country(com.salesmanager.core.model.reference.country.Country) OrderStatusHistory(com.salesmanager.core.model.order.orderstatus.OrderStatusHistory) OrderTotal(com.salesmanager.shop.model.order.total.OrderTotal)

Example 4 with OrderStatusHistory

use of com.salesmanager.core.model.order.orderstatus.OrderStatusHistory in project shopizer by shopizer-ecommerce.

the class OrderFacadeImpl method processOrderModel.

/**
 * Commit an order
 * @param order
 * @param customer
 * @param transaction
 * @param store
 * @param language
 * @return
 * @throws ServiceException
 */
private Order processOrderModel(ShopOrder order, Customer customer, Transaction transaction, MerchantStore store, Language language) throws ServiceException {
    try {
        if (order.isShipToBillingAdress()) {
            // customer shipping is billing
            PersistableCustomer orderCustomer = order.getCustomer();
            Address billing = orderCustomer.getBilling();
            orderCustomer.setDelivery(billing);
        }
        Order modelOrder = new Order();
        modelOrder.setDatePurchased(new Date());
        modelOrder.setBilling(customer.getBilling());
        modelOrder.setDelivery(customer.getDelivery());
        modelOrder.setPaymentModuleCode(order.getPaymentModule());
        modelOrder.setPaymentType(PaymentType.valueOf(order.getPaymentMethodType()));
        modelOrder.setShippingModuleCode(order.getShippingModule());
        modelOrder.setCustomerAgreement(order.isCustomerAgreed());
        // set the store
        modelOrder.setLocale(LocaleUtils.getLocale(store));
        // locale based
        // on the
        // country for
        // order $
        // formatting
        List<ShoppingCartItem> shoppingCartItems = order.getShoppingCartItems();
        Set<OrderProduct> orderProducts = new LinkedHashSet<OrderProduct>();
        if (!StringUtils.isBlank(order.getComments())) {
            OrderStatusHistory statusHistory = new OrderStatusHistory();
            statusHistory.setStatus(OrderStatus.ORDERED);
            statusHistory.setOrder(modelOrder);
            statusHistory.setDateAdded(new Date());
            statusHistory.setComments(order.getComments());
            modelOrder.getOrderHistory().add(statusHistory);
        }
        OrderProductPopulator orderProductPopulator = new OrderProductPopulator();
        orderProductPopulator.setDigitalProductService(digitalProductService);
        orderProductPopulator.setProductAttributeService(productAttributeService);
        orderProductPopulator.setProductService(productService);
        String shoppingCartCode = null;
        for (ShoppingCartItem item : shoppingCartItems) {
            if (shoppingCartCode == null && item.getShoppingCart() != null) {
                shoppingCartCode = item.getShoppingCart().getShoppingCartCode();
            }
            /**
             * Before processing order quantity of item must be > 0
             */
            Product product = productService.getById(item.getProductId());
            if (product == null) {
                throw new ServiceException(ServiceException.EXCEPTION_INVENTORY_MISMATCH);
            }
            LOGGER.debug("Validate inventory");
            for (ProductAvailability availability : product.getAvailabilities()) {
                if (availability.getRegion().equals(Constants.ALL_REGIONS)) {
                    int qty = availability.getProductQuantity();
                    if (qty < item.getQuantity()) {
                        throw new ServiceException(ServiceException.EXCEPTION_INVENTORY_MISMATCH);
                    }
                }
            }
            OrderProduct orderProduct = new OrderProduct();
            orderProduct = orderProductPopulator.populate(item, orderProduct, store, language);
            orderProduct.setOrder(modelOrder);
            orderProducts.add(orderProduct);
        }
        modelOrder.setOrderProducts(orderProducts);
        OrderTotalSummary summary = order.getOrderTotalSummary();
        List<com.salesmanager.core.model.order.OrderTotal> totals = summary.getTotals();
        // re-order totals
        Collections.sort(totals, new Comparator<com.salesmanager.core.model.order.OrderTotal>() {

            public int compare(com.salesmanager.core.model.order.OrderTotal x, com.salesmanager.core.model.order.OrderTotal y) {
                if (x.getSortOrder() == y.getSortOrder())
                    return 0;
                return x.getSortOrder() < y.getSortOrder() ? -1 : 1;
            }
        });
        Set<com.salesmanager.core.model.order.OrderTotal> modelTotals = new LinkedHashSet<com.salesmanager.core.model.order.OrderTotal>();
        for (com.salesmanager.core.model.order.OrderTotal total : totals) {
            total.setOrder(modelOrder);
            modelTotals.add(total);
        }
        modelOrder.setOrderTotal(modelTotals);
        modelOrder.setTotal(order.getOrderTotalSummary().getTotal());
        // order misc objects
        modelOrder.setCurrency(store.getCurrency());
        modelOrder.setMerchant(store);
        // customer object
        orderCustomer(customer, modelOrder, language);
        // populate shipping information
        if (!StringUtils.isBlank(order.getShippingModule())) {
            modelOrder.setShippingModuleCode(order.getShippingModule());
        }
        String paymentType = order.getPaymentMethodType();
        Payment payment = new Payment();
        payment.setPaymentType(PaymentType.valueOf(paymentType));
        payment.setAmount(order.getOrderTotalSummary().getTotal());
        payment.setModuleName(order.getPaymentModule());
        payment.setCurrency(modelOrder.getCurrency());
        if (order.getPayment() != null && order.getPayment().get("paymentToken") != null) {
            // set
            // token
            String paymentToken = order.getPayment().get("paymentToken");
            Map<String, String> paymentMetaData = new HashMap<String, String>();
            payment.setPaymentMetaData(paymentMetaData);
            paymentMetaData.put("paymentToken", paymentToken);
        }
        if (PaymentType.CREDITCARD.name().equals(paymentType)) {
            payment = new CreditCardPayment();
            ((CreditCardPayment) payment).setCardOwner(order.getPayment().get("creditcard_card_holder"));
            ((CreditCardPayment) payment).setCredidCardValidationNumber(order.getPayment().get("creditcard_card_cvv"));
            ((CreditCardPayment) payment).setCreditCardNumber(order.getPayment().get("creditcard_card_number"));
            ((CreditCardPayment) payment).setExpirationMonth(order.getPayment().get("creditcard_card_expirationmonth"));
            ((CreditCardPayment) payment).setExpirationYear(order.getPayment().get("creditcard_card_expirationyear"));
            Map<String, String> paymentMetaData = order.getPayment();
            payment.setPaymentMetaData(paymentMetaData);
            payment.setPaymentType(PaymentType.valueOf(paymentType));
            payment.setAmount(order.getOrderTotalSummary().getTotal());
            payment.setModuleName(order.getPaymentModule());
            payment.setCurrency(modelOrder.getCurrency());
            CreditCardType creditCardType = null;
            String cardType = order.getPayment().get("creditcard_card_type");
            // supported credit cards
            if (CreditCardType.AMEX.name().equalsIgnoreCase(cardType)) {
                creditCardType = CreditCardType.AMEX;
            } else if (CreditCardType.VISA.name().equalsIgnoreCase(cardType)) {
                creditCardType = CreditCardType.VISA;
            } else if (CreditCardType.MASTERCARD.name().equalsIgnoreCase(cardType)) {
                creditCardType = CreditCardType.MASTERCARD;
            } else if (CreditCardType.DINERS.name().equalsIgnoreCase(cardType)) {
                creditCardType = CreditCardType.DINERS;
            } else if (CreditCardType.DISCOVERY.name().equalsIgnoreCase(cardType)) {
                creditCardType = CreditCardType.DISCOVERY;
            }
            ((CreditCardPayment) payment).setCreditCard(creditCardType);
            if (creditCardType != null) {
                CreditCard cc = new CreditCard();
                cc.setCardType(creditCardType);
                cc.setCcCvv(((CreditCardPayment) payment).getCredidCardValidationNumber());
                cc.setCcOwner(((CreditCardPayment) payment).getCardOwner());
                cc.setCcExpires(((CreditCardPayment) payment).getExpirationMonth() + "-" + ((CreditCardPayment) payment).getExpirationYear());
                // hash credit card number
                if (!StringUtils.isBlank(cc.getCcNumber())) {
                    String maskedNumber = CreditCardUtils.maskCardNumber(order.getPayment().get("creditcard_card_number"));
                    cc.setCcNumber(maskedNumber);
                    modelOrder.setCreditCard(cc);
                }
            }
        }
        if (PaymentType.PAYPAL.name().equals(paymentType)) {
            // check for previous transaction
            if (transaction == null) {
                throw new ServiceException("payment.error");
            }
            payment = new com.salesmanager.core.model.payments.PaypalPayment();
            ((com.salesmanager.core.model.payments.PaypalPayment) payment).setPayerId(transaction.getTransactionDetails().get("PAYERID"));
            ((com.salesmanager.core.model.payments.PaypalPayment) payment).setPaymentToken(transaction.getTransactionDetails().get("TOKEN"));
        }
        modelOrder.setShoppingCartCode(shoppingCartCode);
        modelOrder.setPaymentModuleCode(order.getPaymentModule());
        payment.setModuleName(order.getPaymentModule());
        if (transaction != null) {
            orderService.processOrder(modelOrder, customer, order.getShoppingCartItems(), summary, payment, store);
        } else {
            orderService.processOrder(modelOrder, customer, order.getShoppingCartItems(), summary, payment, transaction, store);
        }
        return modelOrder;
    } catch (ServiceException se) {
        // may be invalid credit card
        throw se;
    } catch (Exception e) {
        throw new ServiceException(e);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Address(com.salesmanager.shop.model.customer.address.Address) OrderProduct(com.salesmanager.core.model.order.orderproduct.OrderProduct) PersistableOrderProduct(com.salesmanager.shop.model.order.PersistableOrderProduct) ReadableOrderProduct(com.salesmanager.shop.model.order.ReadableOrderProduct) OrderProductPopulator(com.salesmanager.shop.populator.order.OrderProductPopulator) ReadableOrderProductPopulator(com.salesmanager.shop.populator.order.ReadableOrderProductPopulator) HashMap(java.util.HashMap) PersistableCustomer(com.salesmanager.shop.model.customer.PersistableCustomer) OrderTotalSummary(com.salesmanager.core.model.order.OrderTotalSummary) OrderProduct(com.salesmanager.core.model.order.orderproduct.OrderProduct) ShippingProduct(com.salesmanager.core.model.shipping.ShippingProduct) PersistableOrderProduct(com.salesmanager.shop.model.order.PersistableOrderProduct) Product(com.salesmanager.core.model.catalog.product.Product) ReadableOrderProduct(com.salesmanager.shop.model.order.ReadableOrderProduct) ProductAvailability(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) ShopOrder(com.salesmanager.shop.model.order.ShopOrder) Order(com.salesmanager.core.model.order.Order) CreditCardType(com.salesmanager.core.model.payments.CreditCardType) Date(java.util.Date) LocalDate(java.time.LocalDate) CreditCard(com.salesmanager.core.model.order.payment.CreditCard) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) ServiceException(com.salesmanager.core.business.exception.ServiceException) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) ConversionException(com.salesmanager.core.business.exception.ConversionException) CreditCardPayment(com.salesmanager.core.model.payments.CreditCardPayment) CreditCardPayment(com.salesmanager.core.model.payments.CreditCardPayment) Payment(com.salesmanager.core.model.payments.Payment) ServiceException(com.salesmanager.core.business.exception.ServiceException) ShoppingCartItem(com.salesmanager.core.model.shoppingcart.ShoppingCartItem) ReadableOrderStatusHistory(com.salesmanager.shop.model.order.history.ReadableOrderStatusHistory) PersistableOrderStatusHistory(com.salesmanager.shop.model.order.history.PersistableOrderStatusHistory) OrderStatusHistory(com.salesmanager.core.model.order.orderstatus.OrderStatusHistory) OrderTotal(com.salesmanager.shop.model.order.total.OrderTotal)

Example 5 with OrderStatusHistory

use of com.salesmanager.core.model.order.orderstatus.OrderStatusHistory in project shopizer by shopizer-ecommerce.

the class OrderFacadeImpl method getReadableOrderHistory.

@Override
public List<ReadableOrderStatusHistory> getReadableOrderHistory(Long orderId, MerchantStore store, Language language) {
    Order order = orderService.getOrder(orderId, store);
    if (order == null) {
        throw new ResourceNotFoundException("Order id [" + orderId + "] not found for merchand [" + store.getId() + "]");
    }
    Set<OrderStatusHistory> historyList = order.getOrderHistory();
    List<ReadableOrderStatusHistory> returnList = historyList.stream().map(f -> mapToReadbleOrderStatusHistory(f)).collect(Collectors.toList());
    return returnList;
}
Also used : ShopOrder(com.salesmanager.shop.model.order.ShopOrder) Order(com.salesmanager.core.model.order.Order) ShoppingCart(com.salesmanager.core.model.shoppingcart.ShoppingCart) OrderEntity(com.salesmanager.shop.model.order.OrderEntity) DigitalProductService(com.salesmanager.core.business.services.catalog.product.file.DigitalProductService) OrderProduct(com.salesmanager.core.model.order.orderproduct.OrderProduct) ZonedDateTime(java.time.ZonedDateTime) ReadableOrderPopulator(com.salesmanager.shop.populator.order.ReadableOrderPopulator) Autowired(org.springframework.beans.factory.annotation.Autowired) Delivery(com.salesmanager.core.model.common.Delivery) StringUtils(org.apache.commons.lang3.StringUtils) ShippingQuote(com.salesmanager.core.model.shipping.ShippingQuote) BigDecimal(java.math.BigDecimal) ShippingProduct(com.salesmanager.core.model.shipping.ShippingProduct) Map(java.util.Map) PricingService(com.salesmanager.core.business.services.catalog.product.PricingService) TransactionService(com.salesmanager.core.business.services.payments.TransactionService) ShippingService(com.salesmanager.core.business.services.shipping.ShippingService) CreditCardType(com.salesmanager.core.model.payments.CreditCardType) CustomerFacade(com.salesmanager.shop.store.controller.customer.facade.CustomerFacade) FieldError(org.springframework.validation.FieldError) Set(java.util.Set) CreditCardPayment(com.salesmanager.core.model.payments.CreditCardPayment) ShoppingCartItemPopulator(com.salesmanager.shop.populator.order.ShoppingCartItemPopulator) ZoneId(java.time.ZoneId) PaymentService(com.salesmanager.core.business.services.payments.PaymentService) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) ShippingQuoteService(com.salesmanager.core.business.services.shipping.ShippingQuoteService) ShopOrder(com.salesmanager.shop.model.order.ShopOrder) ProductService(com.salesmanager.core.business.services.catalog.product.ProductService) OrderSummary(com.salesmanager.core.model.order.OrderSummary) Billing(com.salesmanager.core.model.common.Billing) CreditCardUtils(com.salesmanager.core.business.utils.CreditCardUtils) BindingResult(org.springframework.validation.BindingResult) OrderService(com.salesmanager.core.business.services.order.OrderService) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ShoppingCartFacade(com.salesmanager.shop.store.controller.shoppingCart.facade.ShoppingCartFacade) ArrayList(java.util.ArrayList) ZoneService(com.salesmanager.core.business.services.reference.zone.ZoneService) OrderTotalSummary(com.salesmanager.core.model.order.OrderTotalSummary) OrderAttribute(com.salesmanager.core.model.order.attributes.OrderAttribute) PersistableOrderProduct(com.salesmanager.shop.model.order.PersistableOrderProduct) Service(org.springframework.stereotype.Service) ProductAttributeService(com.salesmanager.core.business.services.catalog.product.attribute.ProductAttributeService) LinkedHashSet(java.util.LinkedHashSet) ShoppingCartService(com.salesmanager.core.business.services.shoppingcart.ShoppingCartService) Product(com.salesmanager.core.model.catalog.product.Product) Country(com.salesmanager.core.model.reference.country.Country) ReadableOrderProduct(com.salesmanager.shop.model.order.ReadableOrderProduct) EmailTemplatesUtils(com.salesmanager.shop.utils.EmailTemplatesUtils) Validate(org.apache.commons.lang3.Validate) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) CreditCard(com.salesmanager.core.model.order.payment.CreditCard) ServiceException(com.salesmanager.core.business.exception.ServiceException) ShoppingCartItem(com.salesmanager.core.model.shoppingcart.ShoppingCartItem) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ReadableTransaction(com.salesmanager.shop.model.order.transaction.ReadableTransaction) ObjectError(org.springframework.validation.ObjectError) Locale(java.util.Locale) OrderCriteria(com.salesmanager.core.model.order.OrderCriteria) OrderProductPopulator(com.salesmanager.shop.populator.order.OrderProductPopulator) OrderFacade(com.salesmanager.shop.store.controller.order.facade.OrderFacade) CountryService(com.salesmanager.core.business.services.reference.country.CountryService) OrderList(com.salesmanager.core.model.order.OrderList) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) ReadableOrderProductPopulator(com.salesmanager.shop.populator.order.ReadableOrderProductPopulator) ReadableCustomer(com.salesmanager.shop.model.customer.ReadableCustomer) ReadableOrderStatusHistory(com.salesmanager.shop.model.order.history.ReadableOrderStatusHistory) List(java.util.List) Payment(com.salesmanager.core.model.payments.Payment) LocaleUtils(com.salesmanager.shop.utils.LocaleUtils) PersistableOrderStatusHistory(com.salesmanager.shop.model.order.history.PersistableOrderStatusHistory) PersistableOrderApiPopulator(com.salesmanager.shop.populator.order.PersistableOrderApiPopulator) CoreConfiguration(com.salesmanager.core.business.utils.CoreConfiguration) LocalDate(java.time.LocalDate) ProductAvailability(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) Address(com.salesmanager.shop.model.customer.address.Address) OrderStatusHistory(com.salesmanager.core.model.order.orderstatus.OrderStatusHistory) Async(org.springframework.scheduling.annotation.Async) PersistableCustomerPopulator(com.salesmanager.shop.populator.customer.PersistableCustomerPopulator) Order(com.salesmanager.core.model.order.Order) DateUtil(com.salesmanager.shop.utils.DateUtil) HashMap(java.util.HashMap) TransactionType(com.salesmanager.core.model.payments.TransactionType) OrderTotal(com.salesmanager.shop.model.order.total.OrderTotal) PaymentType(com.salesmanager.core.model.payments.PaymentType) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Language(com.salesmanager.core.model.reference.language.Language) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) LabelUtils(com.salesmanager.shop.utils.LabelUtils) ReadableTransactionPopulator(com.salesmanager.shop.populator.order.transaction.ReadableTransactionPopulator) Qualifier(org.springframework.beans.factory.annotation.Qualifier) CustomerPopulator(com.salesmanager.shop.populator.customer.CustomerPopulator) PersistablePaymentPopulator(com.salesmanager.shop.populator.order.transaction.PersistablePaymentPopulator) Transaction(com.salesmanager.core.model.payments.Transaction) Constants(com.salesmanager.core.business.constants.Constants) Logger(org.slf4j.Logger) OrderStatus(com.salesmanager.core.model.order.orderstatus.OrderStatus) Customer(com.salesmanager.core.model.customer.Customer) ImageFilePath(com.salesmanager.shop.utils.ImageFilePath) PersistableCustomer(com.salesmanager.shop.model.customer.PersistableCustomer) ShippingSummary(com.salesmanager.core.model.shipping.ShippingSummary) ConversionException(com.salesmanager.core.business.exception.ConversionException) Comparator(java.util.Comparator) Collections(java.util.Collections) ReadableOrderStatusHistory(com.salesmanager.shop.model.order.history.ReadableOrderStatusHistory) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) ReadableOrderStatusHistory(com.salesmanager.shop.model.order.history.ReadableOrderStatusHistory) PersistableOrderStatusHistory(com.salesmanager.shop.model.order.history.PersistableOrderStatusHistory) OrderStatusHistory(com.salesmanager.core.model.order.orderstatus.OrderStatusHistory)

Aggregations

OrderStatusHistory (com.salesmanager.core.model.order.orderstatus.OrderStatusHistory)10 Date (java.util.Date)8 ServiceException (com.salesmanager.core.business.exception.ServiceException)7 ConversionException (com.salesmanager.core.business.exception.ConversionException)5 Order (com.salesmanager.core.model.order.Order)5 OrderProduct (com.salesmanager.core.model.order.orderproduct.OrderProduct)5 BigDecimal (java.math.BigDecimal)5 Product (com.salesmanager.core.model.catalog.product.Product)4 ProductAvailability (com.salesmanager.core.model.catalog.product.availability.ProductAvailability)4 Customer (com.salesmanager.core.model.customer.Customer)4 OrderStatus (com.salesmanager.core.model.order.orderstatus.OrderStatus)4 CreditCard (com.salesmanager.core.model.order.payment.CreditCard)4 Transaction (com.salesmanager.core.model.payments.Transaction)4 PersistableCustomer (com.salesmanager.shop.model.customer.PersistableCustomer)4 PersistableOrderStatusHistory (com.salesmanager.shop.model.order.history.PersistableOrderStatusHistory)4 ReadableOrderStatusHistory (com.salesmanager.shop.model.order.history.ReadableOrderStatusHistory)4 LocalDate (java.time.LocalDate)4 HashSet (java.util.HashSet)4 Billing (com.salesmanager.core.model.common.Billing)3 Delivery (com.salesmanager.core.model.common.Delivery)3