Package de.hybris.platform.refund.impl
Class DefaultRefundService
- java.lang.Object
-
- de.hybris.platform.refund.impl.DefaultRefundService
-
- All Implemented Interfaces:
RefundService
- Direct Known Subclasses:
WarehousingRefundService
public class DefaultRefundService extends java.lang.Object implements RefundService
Default implementation ofRefundService
Sample usage:// order creation final OrderModel order = orderService.placeOrder(cart, deliveryAddress, null, paymentInfo); // create 'returns request' final ReturnRequestModel request = returnService.createReturnRequest(order); // assign RMA to 'return request' returnService.createRMA(request); // based on the original order a 'preview' will be created, so that we can apply the refunds without modifying the original order. final OrderModel refundOrderPreview = refundService.createRefundOrderPreview(request, order); // ... after that we will apply the refunds on the preview of our order AND DON'T create a
OrderHistoryEntryModel
entry refundService.apply(Arrays.asList(refundEntry), refundOrderPreview), false); // afterwards, if the customer agrees with the offered refund, we would apply the refund on the original order AND create aOrderHistoryEntryModel
entry refundService.apply(Arrays.asList(refundEntry), order), true);
-
-
Constructor Summary
Constructors Constructor Description DefaultRefundService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(OrderModel previewOrder, ReturnRequestModel request)
Based on the assigned refund entries of the 'previewOrder'RefundService.createRefundOrderPreview(OrderModel)
, the 'finalOrder' will be recalculated and modification entries will be written.void
apply(java.util.List<RefundEntryModel> refunds, OrderModel order)
Based on the assigned refund entries the order will be recalculatedprotected OrderHistoryEntryModel
createOrderHistoryEntry(OrderModel processedOrder, OrderModel snapshot)
Creates a history entry for the 'processedOrder'.protected java.lang.String
createOrderHistoryEntryDescription(java.util.List<RefundEntryModel> refunds)
Generates a order history comment from the specified refunds by collecting the stored 'refund notes'OrderModel
createRefundOrderPreview(OrderModel original)
Create a "refund order" based on the specified order instance.protected CalculationService
getCalculationService()
protected AbstractOrderEntryModel
getEntry(AbstractOrderModel order, java.lang.Integer postion)
Returns the order entry at a specified position.protected FlexibleSearchService
getFlexibleSearchService()
protected ModelService
getModelService()
OrderReturnRecordHandler
getModificationHandler()
protected AbstractOrderEntryModel
getOrderEntry(RefundEntryModel refund, AbstractOrderModel order)
protected OrderHistoryService
getOrderHistoryService()
protected OrderService
getOrderService()
protected RefundDao
getRefundDao()
java.util.List<RefundEntryModel>
getRefunds(ReturnRequestModel request)
Returns the refunds for the specified ordervoid
setCalculationService(CalculationService calculationService)
void
setFlexibleSearchService(FlexibleSearchService flexibleSearchService)
void
setModelService(ModelService modelService)
void
setModificationHandler(OrderReturnRecordHandler modificationHandler)
void
setOrderHistoryService(OrderHistoryService orderHistoryService)
void
setOrderService(OrderService orderService)
void
setRefundDao(RefundDao refundDao)
-
-
-
Method Detail
-
setRefundDao
public void setRefundDao(RefundDao refundDao)
- Parameters:
refundDao
- the refundDao to set
-
setModificationHandler
public void setModificationHandler(OrderReturnRecordHandler modificationHandler)
- Parameters:
modificationHandler
- the modificationHandler to set
-
getModificationHandler
public OrderReturnRecordHandler getModificationHandler()
-
getOrderEntry
protected AbstractOrderEntryModel getOrderEntry(RefundEntryModel refund, AbstractOrderModel order)
-
createRefundOrderPreview
public OrderModel createRefundOrderPreview(OrderModel original)
Create a "refund order" based on the specified order instance. The returned refund order, will be a clone of the original one (seeOrderHistoryService.createHistorySnapshot(OrderModel)
. This new instance should be used for applying the refund. (see: RefundService#calculate)
Note:theReturnRequest
instance of the specified order will not be 'cloned' or 'referenced'.- Specified by:
createRefundOrderPreview
in interfaceRefundService
- Parameters:
original
- the original order- Returns:
- the refund order
-
apply
public void apply(java.util.List<RefundEntryModel> refunds, OrderModel order)
Based on the assigned refund entries the order will be recalculated- Specified by:
apply
in interfaceRefundService
- Parameters:
refunds
- the refunds for which the amount will be calculatedorder
- the refund order for which the refund will be calculated
-
apply
public void apply(OrderModel previewOrder, ReturnRequestModel request) throws OrderReturnRecordsHandlerException
Based on the assigned refund entries of the 'previewOrder'RefundService.createRefundOrderPreview(OrderModel)
, the 'finalOrder' will be recalculated and modification entries will be written.- Specified by:
apply
in interfaceRefundService
- Parameters:
previewOrder
- the order which holds the preview of refundrequest
- the request which holds the order for which the refunds will be calculated AND the "refund entries" which will be logged byOrderReturnRecordHandler
- Throws:
OrderReturnRecordsHandlerException
- in case of DAO error
-
createOrderHistoryEntryDescription
protected java.lang.String createOrderHistoryEntryDescription(java.util.List<RefundEntryModel> refunds)
Generates a order history comment from the specified refunds by collecting the stored 'refund notes'- Parameters:
refunds
- the refunds from which the nodes will be extracted- Returns:
- the generated order history comment
-
createOrderHistoryEntry
protected OrderHistoryEntryModel createOrderHistoryEntry(OrderModel processedOrder, OrderModel snapshot)
Creates a history entry for the 'processedOrder'.- Parameters:
processedOrder
- the 'modified' ordersnapshot
- the original of the order- Returns:
- the created order history entry
-
getEntry
protected AbstractOrderEntryModel getEntry(AbstractOrderModel order, java.lang.Integer postion)
Returns the order entry at a specified position.- Parameters:
postion
-- Returns:
- the related order entry (can be 'null')
- Throws:
JaloItemNotFoundException
-
getRefunds
public java.util.List<RefundEntryModel> getRefunds(ReturnRequestModel request)
Returns the refunds for the specified order- Specified by:
getRefunds
in interfaceRefundService
- Parameters:
request
- the request- Returns:
- the refunds
-
getRefundDao
protected RefundDao getRefundDao()
-
getOrderService
protected OrderService getOrderService()
-
setOrderService
public void setOrderService(OrderService orderService)
-
getCalculationService
protected CalculationService getCalculationService()
-
setCalculationService
public void setCalculationService(CalculationService calculationService)
-
getFlexibleSearchService
protected FlexibleSearchService getFlexibleSearchService()
-
setFlexibleSearchService
public void setFlexibleSearchService(FlexibleSearchService flexibleSearchService)
-
getOrderHistoryService
protected OrderHistoryService getOrderHistoryService()
-
setOrderHistoryService
public void setOrderHistoryService(OrderHistoryService orderHistoryService)
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
-