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 PriceDataUsageDetailbuildPriceDataUsageDetail(@NonNull com.broadleafcommerce.pricing.client.domain.usage.RecordPriceDataUsageRequest request, @NonNull com.broadleafcommerce.pricing.client.domain.usage.PriceDataUsage usage) Builds aPriceDataUsageDetailbased on the given usage.protected PriceDataService<PriceData>protected PriceDataUsageDetailService<PriceDataUsageDetail>protected PriceListService<PriceList>protected intGets the batch size for rolling back the price data usages.protected com.broadleafcommerce.common.extension.TypeFactoryprotected voidincrementAvailableQuantityForPriceData(@NonNull Map<String, Integer> quantityToIncrementByPriceDataId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Increments thePriceData.getAvailableQuantity().voidmarkPriceDataUsagesRevertible(@NonNull String transactionRefType, @NonNull String transactionRefId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sets revertible=true toPriceDataUsageDetailidentified by transactionRefType and transactionRefIdcom.broadleafcommerce.pricing.client.domain.usage.RecordPriceDataUsageResponserecordPriceDataUsage(@NonNull com.broadleafcommerce.pricing.client.domain.usage.RecordPriceDataUsageRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Records price data usages.voidrollbackExpiredPriceDataUsage(Duration outdatedPriceDataUsageDetailTimeout, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Performs the rollback forPriceDataandPriceDataUsageDetailwherePriceDataUsageDetailare older than specified date and has flag revertible as trueprotected voidrollbackPriceDataUsageDetails(@NonNull org.springframework.data.domain.Page<PriceDataUsageDetail> usageDetailsPage, @NonNull String rollbackReason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Bulk archives all thePriceDataUsageDetails with a specific rollback reason.voidrollbackPriceDataUsages(@NonNull String transactionRefType, @NonNull String transactionRefId, @NonNull String rollbackReason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Performs the rollback forPriceDataandPriceDataUsageDetail.voidrollbackPriceDataUsagesByPriceDataId(@NonNull Map<String, Integer> quantityByPriceDataIdMap, @NonNull String rollbackReason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Performs the rollback forPriceDataandPriceDataUsageDetail.voidsetPricingCartProvider(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:PricingTransactionServiceRecords price data usages.If any one of the
PriceDataUsagesis 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:
recordPriceDataUsagein interfacePricingTransactionService- Parameters:
request- theRecordPriceDataUsageRequestcontaining the usages to recordcontextInfo- the context info- Returns:
- the
RecordPriceDataUsageResponserepresenting 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:PricingTransactionServicePerforms the rollback forPriceDataandPriceDataUsageDetail.This mainly includes adding back the
PriceData.getAvailableQuantity()and archiving thePriceDataUsageDetails.- Specified by:
rollbackPriceDataUsagesin 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:PricingTransactionServiceSets revertible=true toPriceDataUsageDetailidentified by transactionRefType and transactionRefId- Specified by:
markPriceDataUsagesRevertiblein 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:PricingTransactionServicePerforms the rollback forPriceDataandPriceDataUsageDetail.This mainly includes adding back the
PriceData.getAvailableQuantity()and archiving thePriceDataUsageDetails.- Specified by:
rollbackPriceDataUsagesByPriceDataIdin 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:PricingTransactionServicePerforms the rollback forPriceDataandPriceDataUsageDetailwherePriceDataUsageDetailare older than specified date and has flag revertible as true- Specified by:
rollbackExpiredPriceDataUsagein interfacePricingTransactionService- Parameters:
outdatedPriceDataUsageDetailTimeout- - timeout that will be subtracted from NOW to get the moment whenPriceDataUsageDetailis 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 thePriceDataUsageDetails with a specific rollback reason.- Parameters:
usageDetailsPage- the page ofPriceDataUsageDetailrollbackReason- the reason why thePriceDataUsageDetailis 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 aPriceDataUsageDetailbased on the given usage.- Parameters:
request- theRecordPriceDataUsageRequestcontaining this usageusage- thePriceDataUsage- Returns:
- a
PriceDataUsageDetailbased 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
-