diff --git a/src/Application/TakeoutSaaS.Application/App/Products/Handlers/CopyProductSpecTemplateCommandHandler.cs b/src/Application/TakeoutSaaS.Application/App/Products/Handlers/CopyProductSpecTemplateCommandHandler.cs index d9fabce..290f5b9 100644 --- a/src/Application/TakeoutSaaS.Application/App/Products/Handlers/CopyProductSpecTemplateCommandHandler.cs +++ b/src/Application/TakeoutSaaS.Application/App/Products/Handlers/CopyProductSpecTemplateCommandHandler.cs @@ -61,12 +61,15 @@ public sealed class CopyProductSpecTemplateCommandHandler( await productRepository.SaveChangesAsync(cancellationToken); // 4. 复制选项与关联商品。 - var sourceOptionsTask = productRepository.GetSpecTemplateOptionsByTemplateIdsAsync([source.Id], tenantId, cancellationToken); - var sourceRelationsTask = productRepository.GetSpecTemplateProductsByTemplateIdsAsync([source.Id], tenantId, request.StoreId, cancellationToken); - await Task.WhenAll(sourceOptionsTask, sourceRelationsTask); - - var sourceOptions = await sourceOptionsTask; - var sourceRelations = await sourceRelationsTask; + var sourceOptions = await productRepository.GetSpecTemplateOptionsByTemplateIdsAsync( + [source.Id], + tenantId, + cancellationToken); + var sourceRelations = await productRepository.GetSpecTemplateProductsByTemplateIdsAsync( + [source.Id], + tenantId, + request.StoreId, + cancellationToken); if (sourceOptions.Count > 0) { diff --git a/src/Application/TakeoutSaaS.Application/App/Products/Handlers/GetProductSpecTemplateListQueryHandler.cs b/src/Application/TakeoutSaaS.Application/App/Products/Handlers/GetProductSpecTemplateListQueryHandler.cs index 94883e2..a544d4d 100644 --- a/src/Application/TakeoutSaaS.Application/App/Products/Handlers/GetProductSpecTemplateListQueryHandler.cs +++ b/src/Application/TakeoutSaaS.Application/App/Products/Handlers/GetProductSpecTemplateListQueryHandler.cs @@ -55,15 +55,21 @@ public sealed class GetProductSpecTemplateListQueryHandler( } var templateIds = filteredList.Select(item => item.Id).ToList(); - var optionsTask = productRepository.GetSpecTemplateOptionsByTemplateIdsAsync(templateIds, tenantId, cancellationToken); - var relationsTask = productRepository.GetSpecTemplateProductsByTemplateIdsAsync(templateIds, tenantId, request.StoreId, cancellationToken); - await Task.WhenAll(optionsTask, relationsTask); + var options = await productRepository.GetSpecTemplateOptionsByTemplateIdsAsync( + templateIds, + tenantId, + cancellationToken); + var relations = await productRepository.GetSpecTemplateProductsByTemplateIdsAsync( + templateIds, + tenantId, + request.StoreId, + cancellationToken); // 4. 构建查找字典并映射 DTO。 - var optionsLookup = (await optionsTask) + var optionsLookup = options .GroupBy(x => x.TemplateId) .ToDictionary(group => group.Key, group => group.OrderBy(item => item.SortOrder).ThenBy(item => item.Id).ToList()); - var productIdsLookup = (await relationsTask) + var productIdsLookup = relations .GroupBy(x => x.TemplateId) .ToDictionary(group => group.Key, group => group.Select(item => item.ProductId).ToList());