feat:商户管理

This commit is contained in:
2025-12-29 16:40:27 +08:00
parent 57f4c2d394
commit dd91c1010a
62 changed files with 10536 additions and 165 deletions

View File

@@ -1,5 +1,6 @@
using TakeoutSaaS.Application.App.Merchants.Dto;
using TakeoutSaaS.Domain.Merchants.Entities;
using TakeoutSaaS.Domain.Stores.Entities;
namespace TakeoutSaaS.Application.App.Merchants;
@@ -28,6 +29,53 @@ internal static class MerchantMapping
CreatedAt = merchant.CreatedAt
};
/// <summary>
/// 将商户实体映射为列表项 DTO。
/// </summary>
public static MerchantListItemDto ToListItemDto(Merchant merchant, string? tenantName, int storeCount) => new()
{
Id = merchant.Id,
TenantId = merchant.TenantId,
TenantName = tenantName,
Name = merchant.BrandName,
OperatingMode = merchant.OperatingMode,
LicenseNumber = merchant.BusinessLicenseNumber,
Status = merchant.Status,
IsFrozen = merchant.IsFrozen,
StoreCount = storeCount,
CreatedAt = merchant.CreatedAt,
UpdatedAt = merchant.UpdatedAt
};
/// <summary>
/// 将商户实体映射为详情 DTO。
/// </summary>
public static MerchantDetailDto ToDetailDto(Merchant merchant, string? tenantName, IReadOnlyList<StoreDto> stores) => new()
{
Id = merchant.Id,
TenantId = merchant.TenantId,
TenantName = tenantName,
Name = merchant.BrandName,
OperatingMode = merchant.OperatingMode,
LicenseNumber = merchant.BusinessLicenseNumber,
LegalRepresentative = merchant.LegalPerson,
RegisteredAddress = merchant.Address,
ContactPhone = merchant.ContactPhone,
ContactEmail = merchant.ContactEmail,
Status = merchant.Status,
IsFrozen = merchant.IsFrozen,
FrozenReason = merchant.FrozenReason,
FrozenAt = merchant.FrozenAt,
ApprovedBy = merchant.ApprovedBy,
ApprovedAt = merchant.ApprovedAt,
Stores = stores,
RowVersion = merchant.RowVersion,
CreatedAt = merchant.CreatedAt,
CreatedBy = merchant.CreatedBy,
UpdatedAt = merchant.UpdatedAt,
UpdatedBy = merchant.UpdatedBy
};
/// <summary>
/// 将商户证照实体映射为 DTO。
/// </summary>
@@ -76,12 +124,42 @@ internal static class MerchantMapping
Id = log.Id,
MerchantId = log.MerchantId,
Action = log.Action,
OperatorId = log.OperatorId,
Title = log.Title,
Description = log.Description,
OperatorName = log.OperatorName,
IpAddress = log.IpAddress,
CreatedAt = log.CreatedAt
};
/// <summary>
/// 将商户变更日志实体映射为 DTO。
/// </summary>
public static MerchantChangeLogDto ToDto(MerchantChangeLog log) => new()
{
Id = log.Id,
FieldName = log.FieldName,
OldValue = log.OldValue,
NewValue = log.NewValue,
ChangedBy = log.ChangedBy,
ChangedByName = log.ChangedByName,
ChangedAt = log.CreatedAt,
ChangeReason = log.ChangeReason
};
/// <summary>
/// 将门店实体映射为 DTO。
/// </summary>
public static StoreDto ToStoreDto(Store store) => new()
{
Id = store.Id,
Name = store.Name,
LicenseNumber = store.BusinessLicenseNumber,
ContactPhone = store.Phone,
Address = store.Address,
Status = store.Status
};
/// <summary>
/// 将商户分类实体映射为 DTO。
/// </summary>
@@ -119,4 +197,10 @@ internal static class MerchantMapping
/// <returns>分类 DTO 列表。</returns>
public static IReadOnlyList<MerchantCategoryDto> ToCategoryDtos(IEnumerable<MerchantCategory> categories)
=> categories.Select(ToDto).ToList();
/// <summary>
/// 将门店集合映射为 DTO 集合。
/// </summary>
public static IReadOnlyList<StoreDto> ToStoreDtos(IEnumerable<Store> stores)
=> stores.Select(ToStoreDto).ToList();
}