using Nop.Core; using Nop.Core.Domain.Customers; using Nop.Core.Domain.Discounts; namespace Nop.Services.Discounts; /// /// Discount service interface /// public partial interface IDiscountService { #region Discounts /// /// Delete discount /// /// Discount /// A task that represents the asynchronous operation Task DeleteDiscountAsync(Discount discount); /// /// Gets a discount /// /// Discount identifier /// /// A task that represents the asynchronous operation /// The task result contains the discount /// Task GetDiscountByIdAsync(int discountId); /// /// Gets all discounts /// /// Discount type; pass null to load all records /// Coupon code to find (exact match); pass null or empty to load all records /// Discount name; pass null or empty to load all records /// A value indicating whether to show expired and not started discounts /// Discount start date; pass null to load all records /// Discount end date; pass null to load all records /// A value indicating whether to get active discounts; "null" to load all discounts; "false" to load only inactive discounts; "true" to load only active discounts /// Vendor identifier; 0 to load all records /// /// A task that represents the asynchronous operation /// The task result contains the discounts /// Task> GetAllDiscountsAsync(DiscountType? discountType = null, string couponCode = null, string discountName = null, bool showHidden = false, DateTime? startDateUtc = null, DateTime? endDateUtc = null, bool? isActive = true, int vendorId = 0); /// /// Inserts a discount /// /// Discount /// A task that represents the asynchronous operation Task InsertDiscountAsync(Discount discount); /// /// Updates the discount /// /// Discount /// A task that represents the asynchronous operation Task UpdateDiscountAsync(Discount discount); /// /// Gets discounts applied to entity /// /// Type based on /// Entity which supports discounts () /// /// A task that represents the asynchronous operation /// The task result contains the list of discounts /// Task> GetAppliedDiscountsAsync(IDiscountSupported entity) where T : DiscountMapping; #endregion #region Discounts (caching) /// /// Gets the discount amount for the specified value /// /// Discount /// Amount /// The discount amount decimal GetDiscountAmount(Discount discount, decimal amount); /// /// Get preferred discount (with maximum discount value) /// /// A list of discounts to check /// Amount (initial value) /// Discount amount /// Preferred discount List GetPreferredDiscount(IList discounts, decimal amount, out decimal discountAmount); /// /// Check whether a list of discounts already contains a certain discount instance /// /// A list of discounts /// Discount to check /// Result bool ContainsDiscount(IList discounts, Discount discount); #endregion #region Discount requirements /// /// Get all discount requirements /// /// Discount identifier /// Whether to load top-level requirements only (without parent identifier) /// /// A task that represents the asynchronous operation /// The task result contains the requirements /// Task> GetAllDiscountRequirementsAsync(int discountId = 0, bool topLevelOnly = false); /// /// Get a discount requirement /// /// Discount requirement identifier /// A task that represents the asynchronous operation Task GetDiscountRequirementByIdAsync(int discountRequirementId); /// /// Gets child discount requirements /// /// Parent discount requirement /// A task that represents the asynchronous operation Task> GetDiscountRequirementsByParentAsync(DiscountRequirement discountRequirement); /// /// Delete discount requirement /// /// Discount requirement /// A value indicating whether to recursively delete child requirements /// A task that represents the asynchronous operation Task DeleteDiscountRequirementAsync(DiscountRequirement discountRequirement, bool recursively); /// /// Inserts a discount requirement /// /// Discount requirement /// A task that represents the asynchronous operation Task InsertDiscountRequirementAsync(DiscountRequirement discountRequirement); /// /// Updates a discount requirement /// /// Discount requirement /// A task that represents the asynchronous operation Task UpdateDiscountRequirementAsync(DiscountRequirement discountRequirement); #endregion #region Validation /// /// Validate discount /// /// Discount /// Customer /// Coupon codes to validate /// /// A task that represents the asynchronous operation /// The task result contains the discount validation result /// Task ValidateDiscountAsync(Discount discount, Customer customer, string[] couponCodesToValidate); #endregion #region Discount usage history /// /// Gets a discount usage history record /// /// Discount usage history record identifier /// /// A task that represents the asynchronous operation /// The task result contains the discount usage history /// Task GetDiscountUsageHistoryByIdAsync(int discountUsageHistoryId); /// /// Gets all discount usage history records /// /// Discount identifier; null to load all records /// Customer identifier; null to load all records /// Order identifier; null to load all records /// Include cancelled orders /// Page index /// Page size /// /// A task that represents the asynchronous operation /// The task result contains the discount usage history records /// Task> GetAllDiscountUsageHistoryAsync(int? discountId = null, int? customerId = null, int? orderId = null, bool includeCancelledOrders = true, int pageIndex = 0, int pageSize = int.MaxValue); /// /// Insert discount usage history record /// /// Discount usage history record /// A task that represents the asynchronous operation Task InsertDiscountUsageHistoryAsync(DiscountUsageHistory discountUsageHistory); /// /// Delete discount usage history record /// /// Discount usage history record /// A task that represents the asynchronous operation Task DeleteDiscountUsageHistoryAsync(DiscountUsageHistory discountUsageHistory); #endregion }