refactor(store): remove fallback config behavior and expose isConfigured
All checks were successful
Build and Deploy TenantApi / build-and-deploy (push) Successful in 43s
All checks were successful
Build and Deploy TenantApi / build-and-deploy (push) Successful in 43s
This commit is contained in:
@@ -2,7 +2,6 @@ using MediatR;
|
||||
using TakeoutSaaS.Application.App.Stores;
|
||||
using TakeoutSaaS.Application.App.Stores.Dto;
|
||||
using TakeoutSaaS.Application.App.Stores.Queries;
|
||||
using TakeoutSaaS.Domain.Stores.Entities;
|
||||
using TakeoutSaaS.Domain.Stores.Repositories;
|
||||
using TakeoutSaaS.Shared.Abstractions.Constants;
|
||||
using TakeoutSaaS.Shared.Abstractions.Exceptions;
|
||||
@@ -31,25 +30,7 @@ public sealed class GetStoreFeeQueryHandler(
|
||||
|
||||
// 2. (空行后) 查询费用配置
|
||||
var fee = await storeRepository.GetStoreFeeAsync(request.StoreId, tenantId, cancellationToken);
|
||||
if (fee is null)
|
||||
{
|
||||
var fallback = new StoreFee
|
||||
{
|
||||
StoreId = request.StoreId,
|
||||
MinimumOrderAmount = 0m,
|
||||
BaseDeliveryFee = 0m,
|
||||
PackagingFeeMode = Domain.Stores.Enums.PackagingFeeMode.Fixed,
|
||||
OrderPackagingFeeMode = Domain.Stores.Enums.OrderPackagingFeeMode.Fixed,
|
||||
FixedPackagingFee = 0m,
|
||||
CutleryFeeEnabled = false,
|
||||
CutleryFeeAmount = 0m,
|
||||
RushFeeEnabled = false,
|
||||
RushFeeAmount = 0m
|
||||
};
|
||||
return StoreMapping.ToDto(fallback);
|
||||
}
|
||||
|
||||
// 3. (空行后) 返回结果
|
||||
return StoreMapping.ToDto(fee);
|
||||
return fee is null ? null : StoreMapping.ToDto(fee);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,29 +101,12 @@ public static class StoreListMapping
|
||||
result.Add(ServiceType.DineIn);
|
||||
}
|
||||
|
||||
// 2. 兜底默认展示配送服务
|
||||
if (result.Count == 0)
|
||||
{
|
||||
result.Add(ServiceType.Delivery);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string ResolveAddress(Store store)
|
||||
{
|
||||
// 1. 地址优先返回业务地址字段
|
||||
if (!string.IsNullOrWhiteSpace(store.Address))
|
||||
{
|
||||
return store.Address;
|
||||
}
|
||||
|
||||
// 2. 兜底拼接省市区
|
||||
var parts = new[] { store.Province, store.City, store.District }
|
||||
.Where(static part => !string.IsNullOrWhiteSpace(part))
|
||||
.ToArray();
|
||||
|
||||
return parts.Length == 0 ? string.Empty : string.Join(string.Empty, parts);
|
||||
return string.IsNullOrWhiteSpace(store.Address) ? string.Empty : store.Address;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user