Package de.hybris.platform.returns.impl
Class DefaultReturnService
- java.lang.Object
-
- de.hybris.platform.returns.impl.DefaultReturnService
-
- All Implemented Interfaces:
ReturnCallbackService
,ReturnService
- Direct Known Subclasses:
WarehousingReturnService
public class DefaultReturnService extends java.lang.Object implements ReturnService, ReturnCallbackService
Default implementation of "Returns handling". It offers ...- Configurable "Return Merchandise Authorization" aka "Return Material Authorization" (RMA) handling
- Replacement Order handling
- Refund handling incl. configurable calculation
- Configurable 'is returnable' check
-
-
Constructor Summary
Constructors Constructor Description DefaultReturnService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addReplacementOrderEntries(ReplacementOrderModel order, java.util.List<ReplacementEntryModel> replacements)
AddsReplacementOrderEntryModel
entries from the specifiedReplacementEntryModel
.RefundEntryModel
createRefund(ReturnRequestModel request, AbstractOrderEntryModel entry, java.lang.String notes, java.lang.Long expectedQuantity, ReturnAction action, RefundReason reason)
Creates a ReplRefundacement based on the assigned OrderEntry instanceReplacementEntryModel
createReplacement(ReturnRequestModel request, AbstractOrderEntryModel entry, java.lang.String notes, java.lang.Long expectedQuantity, ReturnAction action, ReplacementReason reason)
Creates a Replacement based on the assigned OrderEntry instanceReplacementOrderModel
createReplacementOrder(ReturnRequestModel request)
Creates aReplacementOrderModel
ReturnRequestModel
createReturnRequest(OrderModel order)
Creates an "authorization" object (@link ReturnRequest} for the order to be returned, if there doesn't exists one for that order so farjava.lang.String
createRMA(ReturnRequestModel request)
creates "Return Merchandise Authorization" aka "Return Material Authorization" (RMA) and assigns it to the assignedReturnRequestModel
java.util.Map<AbstractOrderEntryModel,java.lang.Long>
getAllReturnableEntries(OrderModel order)
Returns all returnableOrderEntry
's.protected FlexibleSearchService
getFlexibleSearchService()
protected RMAGenerator
getGenerator()
protected ModelService
getModelService()
protected OrderReturnRecordHandler
getModificationHandler()
OrderModel
getOrderByCode(java.lang.String code)
Returns an order by its codeOrderReturnRecordModel
getOrderReturnRecordForOrder(OrderModel order)
Gets order return record for a given order.protected RefundOrderProcessor
getRefundOrderProcessor()
protected RefundService
getRefundService()
ReplacementOrderModel
getReplacementOrder(java.lang.String rma)
Returns theReplacementOrderModel
by the specified 'RMA value'protected ReplacementOrderDao
getReplacementOrderDao()
protected ReplacementOrderProcessor
getReplacementOrderProcessor()
java.util.List<ReplacementEntryModel>
getReplacements(ReturnRequestModel request)
Returns all Replacements for the specified returns requestprotected java.util.List<ReturnableCheck>
getReturnableChecks()
protected ReturnActionRequestExecutor
getReturnActionRequestExecutor()
java.util.List<ReturnEntryModel>
getReturnEntries(ProductModel product)
Returns the ReturnsEntries for the specified productjava.util.List<ReturnEntryModel>
getReturnEntry(AbstractOrderEntryModel entry)
Returns the ReturnsEntries for the specified order entryprotected ReturnRequestDao
getReturnRequestDao()
java.util.List<ReturnRequestModel>
getReturnRequests(java.lang.String code)
Returns the "return request" for the specified orderprotected ReturnEntryProcessor
getReturnsEntryProcessor()
java.lang.String
getRMA(ReturnRequestModel request)
returns a "Return Merchandise Authorization" aka "Return Material Authorization" (RMA).boolean
isReturnable(OrderModel order, AbstractOrderEntryModel entry, long returnQuantity)
Determines if the product is 'returnable' by using the injectedReturnableCheck
implementations.void
onReturnApprovalResponse(ReturnActionResponse approvalResponse)
Callback method used by the adapter to pass approval operation result.void
onReturnCancelResponse(ReturnActionResponse cancelResponse)
Callback method used by the adapter to pass cancellation operation result.void
onReturnReceptionResponse(ReturnActionResponse receptionResponse)
Callback method used by the adapter to pass reception operation result.void
processRefundOrder(OrderModel order)
Here you have the chance to 'inject' your final Refund order processing.void
processReplacementOrder(ReplacementOrderModel order)
Here you have the chance to 'inject' your final Replacement order processing.void
processReturnEntries(java.util.List<ReturnEntryModel> entries)
Here you have the chance to 'inject' your final Returns Entry processing.void
requestManualPaymentReversalForReturnRequest(ReturnRequestModel returnRequest)
Request manual payment reversal for the (@link ReturnRequest}.void
requestManualTaxReversalForReturnRequest(ReturnRequestModel returnRequest)
Request manual tax reversal for the (@link ReturnRequest}.void
setFlexibleSearchService(FlexibleSearchService flexibleSearchService)
void
setGenerator(RMAGenerator generator)
void
setModelService(ModelService modelService)
void
setModificationHandler(OrderReturnRecordHandler modificationHandler)
void
setRefundOrderProcessor(RefundOrderProcessor refundOrderProcessor)
void
setRefundService(RefundService refundService)
void
setReplacementOrderDao(ReplacementOrderDao replacementOrderDao)
void
setReplacementOrderProcessor(ReplacementOrderProcessor replacementOrderProcessor)
void
setReturnableChecks(java.util.List<ReturnableCheck> returnableChecks)
void
setReturnActionRequestExecutor(ReturnActionRequestExecutor returnActionRequestExecutor)
void
setReturnRequestDao(ReturnRequestDao returnRequestDao)
void
setReturnsEntryProcessor(ReturnEntryProcessor returnEntryProcessor)
-
-
-
Method Detail
-
getRefundService
protected RefundService getRefundService()
- Returns:
- the configured refundService (calculation)
-
setRefundService
public void setRefundService(RefundService refundService)
- Parameters:
refundService
- the service to set
-
setReturnsEntryProcessor
public void setReturnsEntryProcessor(ReturnEntryProcessor returnEntryProcessor)
-
getReturnsEntryProcessor
protected ReturnEntryProcessor getReturnsEntryProcessor()
-
setReplacementOrderProcessor
public void setReplacementOrderProcessor(ReplacementOrderProcessor replacementOrderProcessor)
-
getReplacementOrderProcessor
protected ReplacementOrderProcessor getReplacementOrderProcessor()
-
setRefundOrderProcessor
public void setRefundOrderProcessor(RefundOrderProcessor refundOrderProcessor)
-
getRefundOrderProcessor
protected RefundOrderProcessor getRefundOrderProcessor()
-
getReturnableChecks
protected java.util.List<ReturnableCheck> getReturnableChecks()
- Returns:
- the returnableChecks
-
setReturnableChecks
public void setReturnableChecks(java.util.List<ReturnableCheck> returnableChecks)
- Parameters:
returnableChecks
- the strategiesList to set
-
setGenerator
public void setGenerator(RMAGenerator generator)
-
getGenerator
protected RMAGenerator getGenerator()
-
getRMA
public java.lang.String getRMA(ReturnRequestModel request)
returns a "Return Merchandise Authorization" aka "Return Material Authorization" (RMA).- Specified by:
getRMA
in interfaceReturnService
- Parameters:
request
- reference of the related ReturnsRequest- Returns:
- RMA
-
createRMA
public java.lang.String createRMA(ReturnRequestModel request)
creates "Return Merchandise Authorization" aka "Return Material Authorization" (RMA) and assigns it to the assignedReturnRequestModel
- Specified by:
createRMA
in interfaceReturnService
- Parameters:
request
- reference of the related "ReturnRequest" for which this RMA will be created- Returns:
- RMA
-
createReturnRequest
public ReturnRequestModel createReturnRequest(OrderModel order)
Creates an "authorization" object (@link ReturnRequest} for the order to be returned, if there doesn't exists one for that order so far- Specified by:
createReturnRequest
in interfaceReturnService
- Parameters:
order
- the order which should be returned- Returns:
- ReturnRequest instance, which will deliver among others the RMA code of every processed "return order".
-
getReturnRequests
public java.util.List<ReturnRequestModel> getReturnRequests(java.lang.String code)
Description copied from interface:ReturnService
Returns the "return request" for the specified order- Specified by:
getReturnRequests
in interfaceReturnService
- Parameters:
code
- code of the order we ask for the "return request"- Returns:
- "return request" of the order
-
getOrderByCode
public OrderModel getOrderByCode(java.lang.String code)
Returns an order by its code- Parameters:
code
- the code of the order- Returns:
- the order
-
getReplacementOrder
public ReplacementOrderModel getReplacementOrder(java.lang.String rma)
Description copied from interface:ReturnService
Returns theReplacementOrderModel
by the specified 'RMA value'- Specified by:
getReplacementOrder
in interfaceReturnService
- Parameters:
rma
- rma value- Returns:
- replacement order
-
createReplacementOrder
public ReplacementOrderModel createReplacementOrder(ReturnRequestModel request)
Creates aReplacementOrderModel
- Specified by:
createReplacementOrder
in interfaceReturnService
- Parameters:
request
- the returns request to which the order will be assigned- Returns:
- the Replacement Order'
-
createReplacement
public ReplacementEntryModel createReplacement(ReturnRequestModel request, AbstractOrderEntryModel entry, java.lang.String notes, java.lang.Long expectedQuantity, ReturnAction action, ReplacementReason reason)
Creates a Replacement based on the assigned OrderEntry instance- Specified by:
createReplacement
in interfaceReturnService
- Parameters:
request
- we use this for the verification process (order)entry
- the original OrderEntrynotes
- some notesexpectedQuantity
- the amount of products which the customer wants to return.action
- action which indicates if the 'returns process' will be executed immediately or is still on hold (waiting for the article to be send back)reason
- reason for the replacement- Returns:
- Replacement Entry instance
-
createRefund
public RefundEntryModel createRefund(ReturnRequestModel request, AbstractOrderEntryModel entry, java.lang.String notes, java.lang.Long expectedQuantity, ReturnAction action, RefundReason reason)
Creates a ReplRefundacement based on the assigned OrderEntry instance- Specified by:
createRefund
in interfaceReturnService
- Parameters:
request
- we use this for the verification process (order)entry
- the original OrderEntrynotes
- some notesexpectedQuantity
- the amount of products which the customer wants to got a refund.action
- action which indicates if the 'returns process' will be executed immediately or is still on hold (waiting for the article to be send back)reason
- reason for the refund- Returns:
- Refund entry instance
-
addReplacementOrderEntries
public void addReplacementOrderEntries(ReplacementOrderModel order, java.util.List<ReplacementEntryModel> replacements)
AddsReplacementOrderEntryModel
entries from the specifiedReplacementEntryModel
. Caution: This impl. only acceptsReplacementEntryModel
which are not on HOLDReturnAction
.- Specified by:
addReplacementOrderEntries
in interfaceReturnService
- Parameters:
order
- the replacement orderreplacements
- the 'replacement' entries (instances which are on HOLD will be ignored)
-
getReturnEntries
public java.util.List<ReturnEntryModel> getReturnEntries(ProductModel product)
Returns the ReturnsEntries for the specified product- Specified by:
getReturnEntries
in interfaceReturnService
- Parameters:
product
- the product- Returns:
- the ReturnsEntry
-
getReturnEntry
public java.util.List<ReturnEntryModel> getReturnEntry(AbstractOrderEntryModel entry)
Returns the ReturnsEntries for the specified order entry- Specified by:
getReturnEntry
in interfaceReturnService
- Parameters:
entry
- the OrderEntry- Returns:
- the ReturnsEntry
-
getReplacements
public java.util.List<ReplacementEntryModel> getReplacements(ReturnRequestModel request)
Returns all Replacements for the specified returns request- Specified by:
getReplacements
in interfaceReturnService
- Parameters:
request
- the ReturnRequestModel- Returns:
- the replacements
-
isReturnable
public boolean isReturnable(OrderModel order, AbstractOrderEntryModel entry, long returnQuantity)
Determines if the product is 'returnable' by using the injectedReturnableCheck
implementations. To be successful every strategy has to return 'true'. If no strategies were injected at all, 'true' will be returned as default.- Specified by:
isReturnable
in interfaceReturnService
- Parameters:
order
- the related original orderentry
- the ordered product which will be returnedreturnQuantity
- the quantity of entries to be returned- Returns:
- true if product is 'returnable'
-
getAllReturnableEntries
public java.util.Map<AbstractOrderEntryModel,java.lang.Long> getAllReturnableEntries(OrderModel order)
Returns all returnableOrderEntry
's. The algorithm returns the max. returnable quantity for every single(!) order entry.- Specified by:
getAllReturnableEntries
in interfaceReturnService
- Parameters:
order
- the related order- Returns:
- all returnable
OrderEntry
and their returnable quantity
-
getOrderReturnRecordForOrder
public OrderReturnRecordModel getOrderReturnRecordForOrder(OrderModel order) throws OrderReturnException
Description copied from interface:ReturnService
Gets order return record for a given order.- Specified by:
getOrderReturnRecordForOrder
in interfaceReturnService
- Parameters:
order
- instance ofOrderModel
to get the return record for- Returns:
- order return record for the given order
- Throws:
OrderReturnException
- in the case of error during service call
-
requestManualPaymentReversalForReturnRequest
public void requestManualPaymentReversalForReturnRequest(ReturnRequestModel returnRequest) throws OrderReturnException
Description copied from interface:ReturnService
Request manual payment reversal for the (@link ReturnRequest}.- Specified by:
requestManualPaymentReversalForReturnRequest
in interfaceReturnService
- Parameters:
returnRequest
- the return request for which payment should be manually reversed- Throws:
OrderReturnException
- in the case of error during service call
-
requestManualTaxReversalForReturnRequest
public void requestManualTaxReversalForReturnRequest(ReturnRequestModel returnRequest) throws OrderReturnException
Description copied from interface:ReturnService
Request manual tax reversal for the (@link ReturnRequest}.- Specified by:
requestManualTaxReversalForReturnRequest
in interfaceReturnService
- Parameters:
returnRequest
- the return request for which tax should be manually reversed- Throws:
OrderReturnException
- in the case of error during service call
-
processReturnEntries
public void processReturnEntries(java.util.List<ReturnEntryModel> entries)
Here you have the chance to 'inject' your final Returns Entry processing. For example for handling consignment creation- Specified by:
processReturnEntries
in interfaceReturnService
- Parameters:
entries
- the entries to be process
-
processReplacementOrder
public void processReplacementOrder(ReplacementOrderModel order)
Here you have the chance to 'inject' your final Replacement order processing. For example for handling consignment creation- Specified by:
processReplacementOrder
in interfaceReturnService
- Parameters:
order
- the order to be process
-
processRefundOrder
public void processRefundOrder(OrderModel order)
Here you have the chance to 'inject' your final Refund order processing. For example for handling consignment creation or initiating the final payment transaction.- Specified by:
processRefundOrder
in interfaceReturnService
- Parameters:
order
- the order to be process
-
onReturnApprovalResponse
public void onReturnApprovalResponse(ReturnActionResponse approvalResponse) throws OrderReturnException
Description copied from interface:ReturnCallbackService
Callback method used by the adapter to pass approval operation result. Adapter uses this method to provide feedback information how was the ReturnRequest approved (completely, partially, not at all).- Specified by:
onReturnApprovalResponse
in interfaceReturnCallbackService
- Parameters:
approvalResponse
- - instance ofReturnActionResponse
- Throws:
OrderReturnException
- in case of error
-
onReturnCancelResponse
public void onReturnCancelResponse(ReturnActionResponse cancelResponse) throws OrderReturnException
Description copied from interface:ReturnCallbackService
Callback method used by the adapter to pass cancellation operation result. Adapter uses this method to provide feedback information how was the ReturnRequest cancelled (completely, partially, not at all).- Specified by:
onReturnCancelResponse
in interfaceReturnCallbackService
- Parameters:
cancelResponse
- - instance ofReturnActionResponse
- Throws:
OrderReturnException
- in case of error
-
onReturnReceptionResponse
public void onReturnReceptionResponse(ReturnActionResponse receptionResponse) throws OrderReturnException
Description copied from interface:ReturnCallbackService
Callback method used by the adapter to pass reception operation result. Adapter uses this method to provide feedback information how was the ReturnRequest received (completely, partially, not at all).- Specified by:
onReturnReceptionResponse
in interfaceReturnCallbackService
- Parameters:
receptionResponse
- - instance ofReturnActionResponse
- Throws:
OrderReturnException
- in case of error
-
getFlexibleSearchService
protected FlexibleSearchService getFlexibleSearchService()
-
setFlexibleSearchService
public void setFlexibleSearchService(FlexibleSearchService flexibleSearchService)
-
getReturnActionRequestExecutor
protected ReturnActionRequestExecutor getReturnActionRequestExecutor()
-
setReturnActionRequestExecutor
public void setReturnActionRequestExecutor(ReturnActionRequestExecutor returnActionRequestExecutor)
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getReplacementOrderDao
protected ReplacementOrderDao getReplacementOrderDao()
-
setReplacementOrderDao
public void setReplacementOrderDao(ReplacementOrderDao replacementOrderDao)
-
getReturnRequestDao
protected ReturnRequestDao getReturnRequestDao()
-
setReturnRequestDao
public void setReturnRequestDao(ReturnRequestDao returnRequestDao)
-
getModificationHandler
protected OrderReturnRecordHandler getModificationHandler()
-
setModificationHandler
public void setModificationHandler(OrderReturnRecordHandler modificationHandler)
-
-