Class OrderServiceImpl

  • All Implemented Interfaces:
    OrderService

    @Service
    public class OrderServiceImpl
    extends java.lang.Object
    implements OrderService
    • Constructor Detail

      • OrderServiceImpl

        public OrderServiceImpl()
    • Method Detail

      • createOrdersFromShoppingCart

        @Transactional
        public java.util.List<OrderDTO> createOrdersFromShoppingCart​(java.util.LinkedHashMap<java.lang.String,​java.lang.Object> params)
        Description copied from interface: OrderService
        Create list of orders from shopping cart. Orders include CommerceItem-s grouped by Seller. So for items CommerceItem1 (with Seller1), CommerceItem2 (with Seller1) and CommerceItem3 (with Seller2) will be created 2 Orders - with [CommerceItem1, CommerceItem2] and [CommerceItem3] respectively.
        Specified by:
        createOrdersFromShoppingCart in interface OrderService
        Parameters:
        params - params, including key-values: shippingAddress - id or Address fields as a map paymentMethod - id or PaymentMethod fields as a map
        Returns:
        list of Order DTOs
      • orderCheckout

        public java.util.List<OrderDTO> orderCheckout()
        Description copied from interface: OrderService
        Checkout the orders for the given shopping cart id.
        Specified by:
        orderCheckout in interface OrderService
        Returns:
        the list of OrderDTOs representing the checked out orders
      • sendOrderConfirmationEmail

        public void sendOrderConfirmationEmail​(java.util.LinkedHashMap<java.lang.String,​java.lang.Object> emailData)
        Description copied from interface: OrderService
        Sends a success email for the order.

        This method sends a success email for the order specified by the given email message.

        Specified by:
        sendOrderConfirmationEmail in interface OrderService
        Parameters:
        emailData - the email message object containing the details of the success email
      • getTax

        private Order.Tax getTax​(Seller buyer,
                                 Seller seller,
                                 java.util.Map<java.lang.String,​com.stripe.model.TaxRate> taxRates)
      • getOrCreateAddress

        private Address getOrCreateAddress​(java.util.LinkedHashMap<java.lang.String,​java.lang.Object> params,
                                           Seller buyer)
      • createInvoiceBuyerToVendor

        public Attachment createInvoiceBuyerToVendor​(java.lang.String orderId)
        Description copied from interface: OrderService
        This method make an invoice from buyer to vendor
        Specified by:
        createInvoiceBuyerToVendor in interface OrderService
        Parameters:
        orderId - order
        Returns:
        value as attachment
      • getOrCreatePaymentMethod

        private java.lang.String getOrCreatePaymentMethod​(java.util.Map<java.lang.String,​java.lang.String> pmParams)
      • createTimeLineList

        private java.util.List<OrderTimeLineBean> createTimeLineList​(java.lang.String orderId)
      • updateItems

        private void updateItems​(Order order,
                                 java.util.List<CommerceItem> items)
      • updateInventoriesLockedQuantity

        private boolean updateInventoriesLockedQuantity​(java.util.Map<CommerceItem,​Inventory> map,
                                                        boolean increase)
      • updateInventoriesOnShip

        private boolean updateInventoriesOnShip​(java.util.Map<CommerceItem,​Inventory> map)
      • removeOrder

        @Transactional
        public void removeOrder​(java.lang.String orderId)
        Description copied from interface: OrderService
        This method removes database entities.
        Specified by:
        removeOrder in interface OrderService
        Parameters:
        orderId - identification for database entity which will be removed
      • removeCommerceItemFromOrder

        @Transactional
        public boolean removeCommerceItemFromOrder​(java.lang.String orderId,
                                                   java.lang.String commerceItemId)
        Description copied from interface: OrderService
        This method removes relationship between database entities.
        Specified by:
        removeCommerceItemFromOrder in interface OrderService
        Parameters:
        orderId - identification for database entity which will be removed
        commerceItemId - identification for database entity which will be updated
        Returns:
        the status of the action, whether it was successful or not
      • getOrders

        @Transactional
        public java.util.List<OrderDTO> getOrders()
        Description copied from interface: OrderService
        Retrieves orders of current user.
        Specified by:
        getOrders in interface OrderService
        Returns:
        order
      • getOrder

        @Transactional
        public OrderDTO getOrder​(java.lang.String orderId)
        Description copied from interface: OrderService
        Gets order by id.
        Specified by:
        getOrder in interface OrderService
        Parameters:
        orderId - identification for filter and return data
        Returns:
        order DTO
      • approve

        public boolean approve​(java.lang.String orderId)
        Description copied from interface: OrderService
        Approves order.
        Specified by:
        approve in interface OrderService
        Parameters:
        orderId - order id
        Returns:
        true on success
      • pay

        @Transactional
        public PaymentStatus pay​(java.lang.String orderId)
        Description copied from interface: OrderService
        Commits payment for the order.
        Specified by:
        pay in interface OrderService
        Parameters:
        orderId - order id
        Returns:
        status of the payment
      • obtain3DSecureLink

        public java.lang.String obtain3DSecureLink​(java.lang.String orderId)
        Description copied from interface: OrderService
        Obtains a payment authorization link;
        Specified by:
        obtain3DSecureLink in interface OrderService
        Parameters:
        orderId - order id
        Returns:
        the link
      • ship

        public boolean ship​(java.lang.String orderId)
        Description copied from interface: OrderService
        Ships order.
        Specified by:
        ship in interface OrderService
        Parameters:
        orderId - order id
        Returns:
        true on success
      • deliver

        public boolean deliver​(java.lang.String orderId)
        Description copied from interface: OrderService
        Deliver order.
        Specified by:
        deliver in interface OrderService
        Parameters:
        orderId - order id
        Returns:
        true on success
      • payout

        public java.lang.String payout​(java.lang.String orderId)
        Description copied from interface: OrderService
        Commits payout.
        Specified by:
        payout in interface OrderService
        Parameters:
        orderId - order id
        Returns:
        status of the payout
      • cancel

        public boolean cancel​(java.lang.String orderId)
        Description copied from interface: OrderService
        Cancels an order.
        Specified by:
        cancel in interface OrderService
        Parameters:
        orderId - order id
        Returns:
        true on success
      • getOrderTimeLine

        public java.util.List<OrderTimeLineBean> getOrderTimeLine​(java.lang.String orderId)
        Description copied from interface: OrderService
        This method returns beans as list.
        Specified by:
        getOrderTimeLine in interface OrderService
        Parameters:
        orderId - identification for database entity which related beans list be returned
        Returns:
        beans as list
      • isUserParticipatesInOrder

        public boolean isUserParticipatesInOrder​(java.lang.String orderId,
                                                 boolean asVendor)
        Description copied from interface: OrderService
        This method checks is database entity belong to other database entity.
        Specified by:
        isUserParticipatesInOrder in interface OrderService
        Parameters:
        orderId - identification for database entity which will be checked
        asVendor - true - for checking as vendor, false - if as buyer
        Returns:
        value as boolean
      • getLastOrderTimelineBean

        public OrderTimeLineBean getLastOrderTimelineBean​(java.lang.String orderId)
        Description copied from interface: OrderService
        This method returns bean.
        Specified by:
        getLastOrderTimelineBean in interface OrderService
        Parameters:
        orderId - identification for database entity which found last bean and returned
        Returns:
        bean
      • addAttachment

        public boolean addAttachment​(java.lang.String orderId,
                                     Attachment attachment)
        Description copied from interface: OrderService
        Adds attachment to the last timeline.
        Specified by:
        addAttachment in interface OrderService
        Parameters:
        orderId - id of the order
        attachment - attachment
        Returns:
        success or not
      • removeAttachment

        public boolean removeAttachment​(java.lang.String orderId,
                                        java.lang.String attachmentName)
        Description copied from interface: OrderService
        Removes attachment from the last timeline.
        Specified by:
        removeAttachment in interface OrderService
        Parameters:
        orderId - id of the order
        attachmentName - attachment name
        Returns:
        success or not
      • canCancel

        private boolean canCancel​(OrderStatus status)
      • canAddAttachment

        public boolean canAddAttachment​(java.lang.String orderId)
        Description copied from interface: OrderService
        Checks if current user can add an Attachment.
        Specified by:
        canAddAttachment in interface OrderService
        Parameters:
        orderId - order ID
        Returns:
        true if the user has rights to add an attachment to the order.
      • changeAddress

        @Transactional
        public boolean changeAddress​(java.lang.String orderId,
                                     java.util.LinkedHashMap<java.lang.String,​java.lang.Object> params)
        Description copied from interface: OrderService
        Changes shipping address of the order.
        Specified by:
        changeAddress in interface OrderService
        Parameters:
        orderId - order id
        params - params of address
        Returns:
        true if successful
      • changePaymentMethod

        @Transactional
        public boolean changePaymentMethod​(java.lang.String orderId,
                                           java.util.LinkedHashMap<java.lang.String,​java.lang.String> pmParams)
        Description copied from interface: OrderService
        Changes payment method for the order's payment intent.
        Specified by:
        changePaymentMethod in interface OrderService
        Parameters:
        orderId - order id
        pmParams - params of a new payment intent
        Returns:
        true if successful
      • canChangeStatus

        public boolean canChangeStatus​(java.lang.String orderId)
        Description copied from interface: OrderService
        Checks if current user can change the status of given order.
        Specified by:
        canChangeStatus in interface OrderService
        Parameters:
        orderId - order
        Returns:
        true if user can change the status
      • mustAddAttachments

        public boolean mustAddAttachments​(java.lang.String orderId)
        Description copied from interface: OrderService
        Checks if attachments must be added on the current step but currently absent.
        Specified by:
        mustAddAttachments in interface OrderService
        Parameters:
        orderId - order
        Returns:
        true if attachments must be added
      • prepareItemsToShipment

        public boolean prepareItemsToShipment​(java.util.List<CommerceItem> items)
        Description copied from interface: OrderService
        This method does reserve for the items which are paid already.
        Specified by:
        prepareItemsToShipment in interface OrderService
        Parameters:
        items - commerce items which will be reserved
        Returns:
        true if it successful
      • getInvoiceTemplate

        public java.lang.String getInvoiceTemplate​(java.lang.String orderId)
        Description copied from interface: OrderService
        This method makes the process of compiling the invoice template
        Specified by:
        getInvoiceTemplate in interface OrderService
        Parameters:
        orderId - order
        Returns:
        compiled invoice template as a string
      • calculateTotalPrice

        public java.util.Map<java.lang.String,​java.lang.Object> calculateTotalPrice​(java.lang.String orderId)
        Description copied from interface: OrderService
        Sums prices of commerce items.
        Specified by:
        calculateTotalPrice in interface OrderService
        Parameters:
        orderId - order identifier
        Returns:
        items total amount as map-property
      • calculateTaxAmountPrice

        public java.util.Map<java.lang.String,​java.lang.Object> calculateTaxAmountPrice​(java.lang.String orderId)
        Description copied from interface: OrderService
        Calculates tax amount for order.
        Specified by:
        calculateTaxAmountPrice in interface OrderService
        Parameters:
        orderId - order identifier
        Returns:
        tax amount as map-property
      • calculateItemsTotalBruttoAmount

        public java.util.Map<java.lang.String,​java.lang.Object> calculateItemsTotalBruttoAmount​(java.lang.String orderId)
        Description copied from interface: OrderService
        Calculates total gross amount for order.
        Specified by:
        calculateItemsTotalBruttoAmount in interface OrderService
        Parameters:
        orderId - order identifier
        Returns:
        order gross amount as map-property
      • calculateServiceFeeBruttoAmount

        public java.util.Map<java.lang.String,​java.lang.Object> calculateServiceFeeBruttoAmount​(java.lang.String orderId)
        Description copied from interface: OrderService
        Calculates service fee for order.
        Specified by:
        calculateServiceFeeBruttoAmount in interface OrderService
        Parameters:
        orderId - order identifier
        Returns:
        service fee amount as map-property
      • calculatePayoutAmount

        public java.util.Map<java.lang.String,​java.lang.Object> calculatePayoutAmount​(java.lang.String orderId)
        Description copied from interface: OrderService
        Calculates payout amount for order.
        Specified by:
        calculatePayoutAmount in interface OrderService
        Parameters:
        orderId - order identifier
        Returns:
        payout amount as map-property