using TakeoutSaaS.Application.App.Stores.Dto; using TakeoutSaaS.Domain.Merchants.Entities; using TakeoutSaaS.Domain.Stores.Entities; namespace TakeoutSaaS.Application.App.Stores; /// /// 门店相关映射助手。 /// public static class StoreMapping { /// /// 映射门店 DTO。 /// /// 门店实体。 /// DTO。 public static StoreDto ToDto(Store store) => new() { Id = store.Id, TenantId = store.TenantId, MerchantId = store.MerchantId, Code = store.Code, Name = store.Name, Phone = store.Phone, ManagerName = store.ManagerName, Status = store.Status, SignboardImageUrl = store.SignboardImageUrl, OwnershipType = store.OwnershipType, AuditStatus = store.AuditStatus, BusinessStatus = store.BusinessStatus, ClosureReason = store.ClosureReason, ClosureReasonText = store.ClosureReasonText, CategoryId = store.CategoryId, RejectionReason = store.RejectionReason, SubmittedAt = store.SubmittedAt, ActivatedAt = store.ActivatedAt, ForceClosedAt = store.ForceClosedAt, ForceCloseReason = store.ForceCloseReason, Province = store.Province, City = store.City, District = store.District, Address = store.Address, Longitude = store.Longitude, Latitude = store.Latitude, Announcement = store.Announcement, Tags = store.Tags, DeliveryRadiusKm = store.DeliveryRadiusKm, SupportsDineIn = store.SupportsDineIn, SupportsPickup = store.SupportsPickup, SupportsDelivery = store.SupportsDelivery, SupportsReservation = store.SupportsReservation, SupportsQueueing = store.SupportsQueueing, CreatedAt = store.CreatedAt }; /// /// 映射门店费用 DTO。 /// /// 费用配置。 /// DTO。 public static StoreFeeDto ToDto(StoreFee fee) => new() { Id = fee.Id, StoreId = fee.StoreId, MinimumOrderAmount = fee.MinimumOrderAmount, DeliveryFee = fee.BaseDeliveryFee, PackagingFeeMode = fee.PackagingFeeMode, FixedPackagingFee = fee.FixedPackagingFee, FreeDeliveryThreshold = fee.FreeDeliveryThreshold, CreatedAt = fee.CreatedAt, UpdatedAt = fee.UpdatedAt }; /// /// 映射门店资质 DTO。 /// /// 资质实体。 /// DTO。 public static StoreQualificationDto ToDto(StoreQualification qualification) { var today = DateOnly.FromDateTime(DateTime.UtcNow); int? daysUntilExpiry = qualification.ExpiresAt.HasValue ? qualification.ExpiresAt.Value.DayNumber - today.DayNumber : null; return new StoreQualificationDto { Id = qualification.Id, StoreId = qualification.StoreId, QualificationType = qualification.QualificationType, FileUrl = qualification.FileUrl, DocumentNumber = qualification.DocumentNumber, IssuedAt = qualification.IssuedAt, ExpiresAt = qualification.ExpiresAt, IsExpired = qualification.IsExpired, IsExpiringSoon = qualification.IsExpiringSoon, DaysUntilExpiry = daysUntilExpiry, SortOrder = qualification.SortOrder, CreatedAt = qualification.CreatedAt, UpdatedAt = qualification.UpdatedAt }; } /// /// 映射营业时段 DTO。 /// /// 营业时段实体。 /// DTO。 public static StoreBusinessHourDto ToDto(StoreBusinessHour hour) => new() { Id = hour.Id, TenantId = hour.TenantId, StoreId = hour.StoreId, DayOfWeek = hour.DayOfWeek, HourType = hour.HourType, StartTime = hour.StartTime, EndTime = hour.EndTime, CapacityLimit = hour.CapacityLimit, Notes = hour.Notes, CreatedAt = hour.CreatedAt }; /// /// 映射配送区域 DTO。 /// /// 配送区域实体。 /// DTO。 public static StoreDeliveryZoneDto ToDto(StoreDeliveryZone zone) => new() { Id = zone.Id, TenantId = zone.TenantId, StoreId = zone.StoreId, ZoneName = zone.ZoneName, PolygonGeoJson = zone.PolygonGeoJson, MinimumOrderAmount = zone.MinimumOrderAmount, DeliveryFee = zone.DeliveryFee, EstimatedMinutes = zone.EstimatedMinutes, SortOrder = zone.SortOrder, CreatedAt = zone.CreatedAt }; /// /// 映射节假日 DTO。 /// /// 节假日实体。 /// DTO。 public static StoreHolidayDto ToDto(StoreHoliday holiday) => new() { Id = holiday.Id, TenantId = holiday.TenantId, StoreId = holiday.StoreId, Date = holiday.Date, EndDate = holiday.EndDate, IsAllDay = holiday.IsAllDay, StartTime = holiday.StartTime, EndTime = holiday.EndTime, OverrideType = holiday.OverrideType, IsClosed = holiday.IsClosed, Reason = holiday.Reason, CreatedAt = holiday.CreatedAt }; /// /// 映射桌台区域 DTO。 /// /// 区域实体。 /// DTO。 public static StoreTableAreaDto ToDto(StoreTableArea area) => new() { Id = area.Id, TenantId = area.TenantId, StoreId = area.StoreId, Name = area.Name, Description = area.Description, SortOrder = area.SortOrder, CreatedAt = area.CreatedAt }; /// /// 映射桌台 DTO。 /// /// 桌台实体。 /// DTO。 public static StoreTableDto ToDto(StoreTable table) => new() { Id = table.Id, TenantId = table.TenantId, StoreId = table.StoreId, AreaId = table.AreaId, TableCode = table.TableCode, Capacity = table.Capacity, Tags = table.Tags, Status = table.Status, QrCodeUrl = table.QrCodeUrl, CreatedAt = table.CreatedAt }; /// /// 映射排班 DTO。 /// /// 排班实体。 /// DTO。 public static StoreEmployeeShiftDto ToDto(StoreEmployeeShift shift) => new() { Id = shift.Id, TenantId = shift.TenantId, StoreId = shift.StoreId, StaffId = shift.StaffId, ShiftDate = shift.ShiftDate, StartTime = shift.StartTime, EndTime = shift.EndTime, RoleType = shift.RoleType, Notes = shift.Notes, CreatedAt = shift.CreatedAt }; /// /// 映射门店员工 DTO。 /// /// 员工实体。 /// DTO。 public static StoreStaffDto ToDto(MerchantStaff staff) => new() { Id = staff.Id, TenantId = staff.TenantId, MerchantId = staff.MerchantId, StoreId = staff.StoreId, Name = staff.Name, Phone = staff.Phone, Email = staff.Email, RoleType = staff.RoleType, Status = staff.Status }; }