This commit introduces a comprehensive variant management system and enhances the existing ProductVariant model with per-variant weight overrides and stock tracking, integrated across Admin Panel and TeleBot. Features Added: - Variant Collections: Reusable variant templates (e.g., "Standard Sizes") - Admin UI for managing variant collections (CRUD operations) - Dynamic variant editor with JavaScript-based UI - Per-variant weight and weight unit overrides - Per-variant stock level tracking - SalesLedger model for financial tracking ProductVariant Enhancements: - Added Weight (decimal, nullable) field for variant-specific weights - Added WeightUnit (enum, nullable) field for variant-specific units - Maintains backward compatibility with product-level weights TeleBot Integration: - Enhanced variant selection UI to display stock levels - Shows weight information with proper unit conversion (µg, g, oz, lb, ml, L) - Compact button format: "Medium (15 in stock, 350g)" - Real-time stock availability display Database Migrations: - 20250928014850_AddVariantCollectionsAndSalesLedger - 20250928155814_AddWeightToProductVariants Technical Changes: - Updated Product model to support VariantCollectionId and VariantsJson - Extended ProductService with variant collection operations - Enhanced OrderService to handle variant-specific pricing and weights - Updated LittleShop.Client DTOs to match server models - Added JavaScript dynamic variant form builder Files Modified: 15 Files Added: 17 Lines Changed: ~2000 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
namespace LittleShop.Client.Models;
|
|
|
|
public class Product
|
|
{
|
|
public Guid Id { get; set; }
|
|
public string Name { get; set; } = string.Empty;
|
|
public string? Description { get; set; }
|
|
public decimal Price { get; set; }
|
|
public decimal Weight { get; set; }
|
|
public int WeightUnit { get; set; }
|
|
public Guid CategoryId { get; set; }
|
|
public string? CategoryName { get; set; }
|
|
public bool IsActive { get; set; }
|
|
public List<ProductPhoto> Photos { get; set; } = new();
|
|
public List<ProductMultiBuy> MultiBuys { get; set; } = new();
|
|
public List<ProductVariant> Variants { get; set; } = new();
|
|
public DateTime CreatedAt { get; set; }
|
|
public DateTime UpdatedAt { get; set; }
|
|
}
|
|
|
|
public class ProductPhoto
|
|
{
|
|
public Guid Id { get; set; }
|
|
public string Url { get; set; } = string.Empty;
|
|
public string? AltText { get; set; }
|
|
public int SortOrder { get; set; }
|
|
}
|
|
|
|
public class ProductMultiBuy
|
|
{
|
|
public Guid Id { get; set; }
|
|
public Guid ProductId { get; set; }
|
|
public string Name { get; set; } = string.Empty;
|
|
public string? Description { get; set; }
|
|
public int Quantity { get; set; }
|
|
public decimal Price { get; set; }
|
|
public decimal PricePerUnit { get; set; }
|
|
public int SortOrder { get; set; }
|
|
public bool IsActive { get; set; }
|
|
}
|
|
|
|
public class ProductVariant
|
|
{
|
|
public Guid Id { get; set; }
|
|
public Guid ProductId { get; set; }
|
|
public string Name { get; set; } = string.Empty; // e.g., "Red", "Blue", "Vanilla"
|
|
public string VariantType { get; set; } = "Standard"; // e.g., "Color", "Flavor"
|
|
public int SortOrder { get; set; }
|
|
public int StockLevel { get; set; }
|
|
public decimal? Weight { get; set; } // Optional: override product weight
|
|
public int? WeightUnit { get; set; } // Optional: override product weight unit
|
|
public bool IsActive { get; set; }
|
|
} |