using Domain.Entities.Store; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Persistence.Configurations.Store; public sealed class OrderRefundConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable(nameof(OrderRefund), t => t.HasComment("통합 환불 이력 (취소/반품/교환/환불)")); builder.HasKey(x => x.ID); builder.Property(x => x.OrderID).IsRequired(); builder.Property(x => x.Type).HasConversion().IsRequired().HasComment("유형 (1=Cancel, 2=Return, 3=Exchange, 4=Refund)"); builder.Property(x => x.ReasonType).HasConversion().IsRequired().HasDefaultValue(Domain.Entities.Store.ValueObject.RefundReasonType.Other).HasSentinel(default(Domain.Entities.Store.ValueObject.RefundReasonType)).HasComment("사유 유형 (1=ChangedMind, 2=OptionChange, 3=ProductDefect, 4=ProductInfoMismatch, 5=DeliveryDelay, 6=WrongDelivery, 7=Other)"); builder.Property(x => x.Status).HasConversion().IsRequired().HasComment("상태 (1=Requested, 2=Approved, 3=Rejected, 4=Completed)"); builder.Property(x => x.Amount).IsRequired(); builder.Property(x => x.Reason).HasMaxLength(500).IsRequired(); builder.Property(x => x.AdminMemo).HasMaxLength(500); builder.Property(x => x.AdminUserId).HasMaxLength(450); builder.Property(x => x.AdminEmail).HasMaxLength(256); builder.Property(x => x.RequestedAt).IsRequired(); builder.Property(x => x.ResolvedAt); builder.HasIndex(x => new { x.OrderID, x.Status }); builder.HasIndex(x => x.Status); } }