Class DefaultPricingTransactionService
java.lang.Object
com.broadleafcommerce.pricing.service.DefaultPricingTransactionService
- All Implemented Interfaces:
PricingTransactionService
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultPricingTransactionService
(PriceListService<PriceList> priceListService, PriceDataService<PriceData> priceDataService, PriceDataUsageDetailService<PriceDataUsageDetail> priceDataUsageDetailService, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected PriceDataUsageDetail
buildPriceDataUsageDetail
(@NonNull com.broadleafcommerce.pricing.client.domain.usage.RecordPriceDataUsageRequest request, @NonNull com.broadleafcommerce.pricing.client.domain.usage.PriceDataUsage usage) Builds aPriceDataUsageDetail
based on the given usage.protected PriceDataService<PriceData>
protected PriceDataUsageDetailService<PriceDataUsageDetail>
protected PriceListService<PriceList>
protected int
Gets the batch size for rolling back the price data usages.protected com.broadleafcommerce.common.extension.TypeFactory
protected void
incrementAvailableQuantityForPriceData
(@NonNull Map<String, Integer> quantityToIncrementByPriceDataId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Increments thePriceData.getAvailableQuantity()
.void
markPriceDataUsagesRevertible
(@NonNull String transactionRefType, @NonNull String transactionRefId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sets revertible=true toPriceDataUsageDetail
identified by transactionRefType and transactionRefIdcom.broadleafcommerce.pricing.client.domain.usage.RecordPriceDataUsageResponse
recordPriceDataUsage
(@NonNull com.broadleafcommerce.pricing.client.domain.usage.RecordPriceDataUsageRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Records price data usages.void
rollbackExpiredPriceDataUsage
(Duration outdatedPriceDataUsageDetailTimeout, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Performs the rollback forPriceData
andPriceDataUsageDetail
wherePriceDataUsageDetail
are older than specified date and has flag revertible as trueprotected void
rollbackPriceDataUsageDetails
(@NonNull org.springframework.data.domain.Page<PriceDataUsageDetail> usageDetailsPage, @NonNull String rollbackReason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Bulk archives all thePriceDataUsageDetail
s with a specific rollback reason.void
rollbackPriceDataUsages
(@NonNull String transactionRefType, @NonNull String transactionRefId, @NonNull String rollbackReason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Performs the rollback forPriceData
andPriceDataUsageDetail
.void
rollbackPriceDataUsagesByPriceDataId
(@NonNull Map<String, Integer> quantityByPriceDataIdMap, @NonNull String rollbackReason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Performs the rollback forPriceData
andPriceDataUsageDetail
.void
setPricingCartProvider
(PricingCartProvider pricingCartProvider)
-
Constructor Details
-
DefaultPricingTransactionService
public DefaultPricingTransactionService(PriceListService<PriceList> priceListService, PriceDataService<PriceData> priceDataService, PriceDataUsageDetailService<PriceDataUsageDetail> priceDataUsageDetailService, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
recordPriceDataUsage
@Transactional("pricingTransactionManager") public com.broadleafcommerce.pricing.client.domain.usage.RecordPriceDataUsageResponse recordPriceDataUsage(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.usage.RecordPriceDataUsageRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PricingTransactionService
Records price data usages.If any one of the
PriceDataUsages
is no longer available or expired, then none are recorded.This is used for
price data that are limited by quantity
. For example, pricing events such as a flash sale may have limited quantity for a sale price.- Specified by:
recordPriceDataUsage
in interfacePricingTransactionService
- Parameters:
request
- theRecordPriceDataUsageRequest
containing the usages to recordcontextInfo
- the context info- Returns:
- the
RecordPriceDataUsageResponse
representing the result of recording the usages
-
rollbackPriceDataUsages
@Transactional("pricingTransactionManager") public void rollbackPriceDataUsages(@NonNull @NonNull String transactionRefType, @NonNull @NonNull String transactionRefId, @NonNull @NonNull String rollbackReason, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PricingTransactionService
Performs the rollback forPriceData
andPriceDataUsageDetail
.This mainly includes adding back the
PriceData.getAvailableQuantity()
and archiving thePriceDataUsageDetails
.- Specified by:
rollbackPriceDataUsages
in interfacePricingTransactionService
- Parameters:
transactionRefType
- the transactionReferenceType of the details to rollbacktransactionRefId
- the transactionReferenceId of the details to rollbackrollbackReason
- the reason for rollbackcontextInfo
- the context info
-
markPriceDataUsagesRevertible
@Transactional("pricingTransactionManager") public void markPriceDataUsagesRevertible(@NonNull @NonNull String transactionRefType, @NonNull @NonNull String transactionRefId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PricingTransactionService
Sets revertible=true toPriceDataUsageDetail
identified by transactionRefType and transactionRefId- Specified by:
markPriceDataUsagesRevertible
in interfacePricingTransactionService
- Parameters:
transactionRefType
- the transactionRefType to restrict querytransactionRefId
- the transactionRefId to restrict querycontextInfo
- the context info
-
rollbackPriceDataUsagesByPriceDataId
@Transactional("pricingTransactionManager") public void rollbackPriceDataUsagesByPriceDataId(@NonNull @NonNull Map<String, Integer> quantityByPriceDataIdMap, @NonNull @NonNull String rollbackReason, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PricingTransactionService
Performs the rollback forPriceData
andPriceDataUsageDetail
.This mainly includes adding back the
PriceData.getAvailableQuantity()
and archiving thePriceDataUsageDetails
.- Specified by:
rollbackPriceDataUsagesByPriceDataId
in interfacePricingTransactionService
- Parameters:
quantityByPriceDataIdMap
- a map containing the entries that represent the quantity to be added back for a specific priceDataIdrollbackReason
- the reason for rollbackcontextInfo
- the context info
-
rollbackExpiredPriceDataUsage
public void rollbackExpiredPriceDataUsage(Duration outdatedPriceDataUsageDetailTimeout, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PricingTransactionService
Performs the rollback forPriceData
andPriceDataUsageDetail
wherePriceDataUsageDetail
are older than specified date and has flag revertible as true- Specified by:
rollbackExpiredPriceDataUsage
in interfacePricingTransactionService
- Parameters:
outdatedPriceDataUsageDetailTimeout
- - timeout that will be subtracted from NOW to get the moment whenPriceDataUsageDetail
is considered expiredcontextInfo
- the context info
-
rollbackPriceDataUsageDetails
protected void rollbackPriceDataUsageDetails(@NonNull @NonNull org.springframework.data.domain.Page<PriceDataUsageDetail> usageDetailsPage, @NonNull @NonNull String rollbackReason, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Bulk archives all thePriceDataUsageDetail
s with a specific rollback reason.- Parameters:
usageDetailsPage
- the page ofPriceDataUsageDetail
rollbackReason
- the reason why thePriceDataUsageDetail
is being rolled backcontextInfo
- the context info
-
incrementAvailableQuantityForPriceData
protected void incrementAvailableQuantityForPriceData(@NonNull @NonNull Map<String, Integer> quantityToIncrementByPriceDataId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Increments thePriceData.getAvailableQuantity()
.This is typically used as part of the rollback process to replenish the available quantity due to workflow error or fulfillment cancellation.
- Parameters:
quantityToIncrementByPriceDataId
- a map containing the information about the amount by which thePriceData.getAvailableQuantity()
is to be incremented for a particularPriceData.getId()
contextInfo
- the context info
-
buildPriceDataUsageDetail
protected PriceDataUsageDetail buildPriceDataUsageDetail(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.usage.RecordPriceDataUsageRequest request, @NonNull @NonNull com.broadleafcommerce.pricing.client.domain.usage.PriceDataUsage usage) Builds aPriceDataUsageDetail
based on the given usage.- Parameters:
request
- theRecordPriceDataUsageRequest
containing this usageusage
- thePriceDataUsage
- Returns:
- a
PriceDataUsageDetail
based on the given usage.
-
getRollBackPriceDataUsageBatchSize
protected int getRollBackPriceDataUsageBatchSize()Gets the batch size for rolling back the price data usages. -
getPriceListService
-
getPriceDataService
-
getPriceDataUsageDetailService
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
setPricingCartProvider
-