feat:Initial commit

This commit is contained in:
elar1s
2025-09-25 22:21:41 +03:00
commit 02934b1fd9
35 changed files with 1267 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
namespace StoreService.Database.Entities;
/// <summary>
/// Category grouping store items.
/// </summary>
public class StoreCategory
{
#region Properties
public long Id { get; set; }
public string Title { get; set; } = string.Empty;
#endregion
#region Navigation
public ICollection<StoreItem> Items { get; set; } = new List<StoreItem>();
#endregion
}

View File

@@ -0,0 +1,36 @@
using System.Diagnostics.CodeAnalysis;
namespace StoreService.Database.Entities;
/// <summary>
/// Percentage discount that can apply to one or more store items within a time window.
/// </summary>
public class StoreDiscount
{
#region Properties
public long Id { get; set; }
public decimal Percentage { get; set; } // 0 - 100 (%)
public string? Description { get; set; }
public DateTime FromDate { get; set; }
public DateTime UntilDate { get; set; }
public bool IsCanceled { get; set; }
#endregion
#region Navigation
public ICollection<StoreDiscountItem> DiscountItems { get; set; } = new List<StoreDiscountItem>();
public ICollection<StoreOrderItemDiscount> OrderItemDiscounts { get; set; } = new List<StoreOrderItemDiscount>();
#endregion
#region Helpers
/// <summary>
/// Checks whether discount is active at provided moment (default: now) ignoring cancellation flag (if canceled returns false).
/// </summary>
public bool IsActive(DateTime? at = null)
{
if (IsCanceled) return false;
var moment = at ?? DateTime.UtcNow;
return moment >= FromDate && moment <= UntilDate;
}
#endregion
}

View File

@@ -0,0 +1,19 @@
namespace StoreService.Database.Entities;
/// <summary>
/// Join entity linking discounts to store items.
/// </summary>
public class StoreDiscountItem
{
#region Properties
public long Id { get; set; }
public long StoreDiscountId { get; set; }
public long StoreItemId { get; set; }
#endregion
#region Navigation
public StoreDiscount? Discount { get; set; }
public StoreItem? StoreItem { get; set; }
#endregion
}

View File

@@ -0,0 +1,25 @@
namespace StoreService.Database.Entities;
/// <summary>
/// Store item with pricing and purchase rules.
/// </summary>
public class StoreItem
{
#region Properties
public long Id { get; set; }
public long ItemId { get; set; } // FK to external Item service (not modeled here)
public long StoreCategoryId { get; set; } // FK to StoreCategory
public long? RankId { get; set; } // Minimum rank required to buy (external system)
public int ManaBuyPrice { get; set; }
public int ManaSellPrice { get; set; }
public bool UnlimitedPurchase { get; set; }
public int InventoryLimit { get; set; }
#endregion
#region Navigation
public StoreCategory? Category { get; set; }
public ICollection<StoreDiscountItem> DiscountItems { get; set; } = new List<StoreDiscountItem>();
public ICollection<StoreOrderItem> OrderItems { get; set; } = new List<StoreOrderItem>();
#endregion
}

View File

@@ -0,0 +1,20 @@
namespace StoreService.Database.Entities;
/// <summary>
/// Represents a purchase order created by a user.
/// </summary>
public class StoreOrder
{
#region Properties
public long Id { get; set; }
public long UserId { get; set; }
public DateTime CostUpdateDate { get; set; } = DateTime.UtcNow; // updated when prices recalculated
public DateTime? PaidDate { get; set; } // when payment succeeded
public bool ItemsRedeemed { get; set; } // becomes true once items granted to inventory
#endregion
#region Navigation
public ICollection<StoreOrderItem> OrderItems { get; set; } = new List<StoreOrderItem>();
#endregion
}

View File

@@ -0,0 +1,21 @@
namespace StoreService.Database.Entities;
/// <summary>
/// Item line inside an order with captured calculated price for history.
/// </summary>
public class StoreOrderItem
{
#region Properties
public long Id { get; set; }
public long StoreOrderId { get; set; }
public long StoreItemId { get; set; }
public int CalculatedPrice { get; set; }
#endregion
#region Navigation
public StoreOrder? Order { get; set; }
public StoreItem? StoreItem { get; set; }
public ICollection<StoreOrderItemDiscount> AppliedDiscounts { get; set; } = new List<StoreOrderItemDiscount>();
#endregion
}

View File

@@ -0,0 +1,19 @@
namespace StoreService.Database.Entities;
/// <summary>
/// Captures which discounts were applied to order items at purchase time.
/// </summary>
public class StoreOrderItemDiscount
{
#region Properties
public long Id { get; set; }
public long StoreOrderItemId { get; set; }
public long? StoreDiscountId { get; set; } // can be null if discount later removed but kept for history
#endregion
#region Navigation
public StoreOrderItem? OrderItem { get; set; }
public StoreDiscount? Discount { get; set; }
#endregion
}