Class DefaultPricingTransactionService

java.lang.Object
com.broadleafcommerce.pricing.service.DefaultPricingTransactionService
All Implemented Interfaces:
PricingTransactionService

public class DefaultPricingTransactionService extends Object implements PricingTransactionService
  • Constructor Details

  • 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 interface PricingTransactionService
      Parameters:
      request - the RecordPriceDataUsageRequest containing the usages to record
      contextInfo - 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 for PriceData and PriceDataUsageDetail.

      This mainly includes adding back the PriceData.getAvailableQuantity() and archiving the PriceDataUsageDetails.

      Specified by:
      rollbackPriceDataUsages in interface PricingTransactionService
      Parameters:
      transactionRefType - the transactionReferenceType of the details to rollback
      transactionRefId - the transactionReferenceId of the details to rollback
      rollbackReason - the reason for rollback
      contextInfo - 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 to PriceDataUsageDetail identified by transactionRefType and transactionRefId
      Specified by:
      markPriceDataUsagesRevertible in interface PricingTransactionService
      Parameters:
      transactionRefType - the transactionRefType to restrict query
      transactionRefId - the transactionRefId to restrict query
      contextInfo - 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 for PriceData and PriceDataUsageDetail.

      This mainly includes adding back the PriceData.getAvailableQuantity() and archiving the PriceDataUsageDetails.

      Specified by:
      rollbackPriceDataUsagesByPriceDataId in interface PricingTransactionService
      Parameters:
      quantityByPriceDataIdMap - a map containing the entries that represent the quantity to be added back for a specific priceDataId
      rollbackReason - the reason for rollback
      contextInfo - 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 for PriceData and PriceDataUsageDetail where PriceDataUsageDetail are older than specified date and has flag revertible as true
      Specified by:
      rollbackExpiredPriceDataUsage in interface PricingTransactionService
      Parameters:
      outdatedPriceDataUsageDetailTimeout - - timeout that will be subtracted from NOW to get the moment when PriceDataUsageDetail is considered expired
      contextInfo - 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 the PriceDataUsageDetails with a specific rollback reason.
      Parameters:
      usageDetailsPage - the page of PriceDataUsageDetail
      rollbackReason - the reason why the PriceDataUsageDetail is being rolled back
      contextInfo - the context info
    • incrementAvailableQuantityForPriceData

      protected void incrementAvailableQuantityForPriceData(@NonNull @NonNull Map<String,Integer> quantityToIncrementByPriceDataId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Increments the PriceData.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 the PriceData.getAvailableQuantity() is to be incremented for a particular PriceData.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 a PriceDataUsageDetail based on the given usage.
      Parameters:
      request - the RecordPriceDataUsageRequest containing this usage
      usage - the PriceDataUsage
      Returns:
      a PriceDataUsageDetail based on the given usage.
    • getRollBackPriceDataUsageBatchSize

      protected int getRollBackPriceDataUsageBatchSize()
      Gets the batch size for rolling back the price data usages.
    • getPriceListService

      protected PriceListService<PriceList> getPriceListService()
    • getPriceDataService

      protected PriceDataService<PriceData> getPriceDataService()
    • getPriceDataUsageDetailService

      protected PriceDataUsageDetailService<PriceDataUsageDetail> getPriceDataUsageDetailService()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • setPricingCartProvider

      @Autowired public void setPricingCartProvider(PricingCartProvider pricingCartProvider)