diff --git a/src/Oms.Application/Services/Channels/SalesProductService.Helpers.cs b/src/Oms.Application/Services/Channels/SalesProductService.Helpers.cs
index 948094b..29d8f24 100644
--- a/src/Oms.Application/Services/Channels/SalesProductService.Helpers.cs
+++ b/src/Oms.Application/Services/Channels/SalesProductService.Helpers.cs
@@ -155,56 +155,70 @@ public partial class SalesProductService
};
}
+ ///
+ /// 组装规则发布快照(不落库),含黑名单/偏远/计重/进位明细。
+ ///
+ private async Task BuildRulesPublishSnapshotAsync(int salesProductId)
+ {
+ var product = await GetProductOrThrowAsync(salesProductId);
+ var rulesSnapshot = new SalesProductRulesPublishSnapshot
+ {
+ Product = MapProductToRulesSaveInput(product),
+ Providers = (await GetAllocationCoreAsync(salesProductId)).Providers
+ };
+ await RulesSnapshotHelper.ApplyRulesToSnapshotAsync(
+ rulesSnapshot,
+ product,
+ KpiAreaRepository,
+ WeightRuleRepository,
+ WeightRoundingRepository);
+ return rulesSnapshot;
+ }
+
+ ///
+ /// 组装价格发布快照(不落库)。
+ ///
+ private async Task BuildPricePublishSnapshotAsync(int salesProductId)
+ {
+ var product = await GetProductOrThrowAsync(salesProductId);
+ var priceSnapshot = new SalesProductPricePublishSnapshot
+ {
+ SalesProductId = salesProductId,
+ Prices = await GetPriceOutputsAsync(salesProductId)
+ };
+ await PriceAreaSnapshotHelper.ApplyPriceAreaToSnapshotAsync(priceSnapshot, product, KpiAreaRepository);
+ return priceSnapshot;
+ }
+
+ private static SalesProductSaveInput MapProductToRulesSaveInput(SalesProduct product) =>
+ new()
+ {
+ Id = product.Id,
+ ProductCode = product.ProductCode,
+ ProductName = product.ProductName,
+ ProductGroup = product.ProductGroup,
+ MinTimeliness = product.MinTimeliness,
+ MaxTimeliness = product.MaxTimeliness,
+ CustomerWaybill = product.CustomerWaybill,
+ BlacklistAreaId = product.BlacklistAreaId,
+ RemoteAreaId = product.RemoteAreaId,
+ PriceAreaId = product.PriceAreaId,
+ WeightRuleId = product.WeightRuleId,
+ WeightRoundingId = product.WeightRoundingId,
+ ProductDescription = product.ProductDescription,
+ PreStorageScript = product.PreStorageScript,
+ IsActive = product.IsActive,
+ Scheme = product.Scheme
+ };
+
///
/// 为当前配置生成发布快照。
///
private async Task CreatePublishRecordAsync(int salesProductId, string operatorType, string? description)
{
- var product = await GetProductOrThrowAsync(salesProductId);
- object snapshot;
- if (operatorType == PriceOperatorType)
- {
- var priceSnapshot = new SalesProductPricePublishSnapshot
- {
- SalesProductId = salesProductId,
- Prices = await GetPriceOutputsAsync(salesProductId)
- };
- await PriceAreaSnapshotHelper.ApplyPriceAreaToSnapshotAsync(priceSnapshot, product, KpiAreaRepository);
- snapshot = priceSnapshot;
- }
- else
- {
- var rulesSnapshot = new SalesProductRulesPublishSnapshot
- {
- Product = new SalesProductSaveInput
- {
- Id = product.Id,
- ProductCode = product.ProductCode,
- ProductName = product.ProductName,
- ProductGroup = product.ProductGroup,
- MinTimeliness = product.MinTimeliness,
- MaxTimeliness = product.MaxTimeliness,
- CustomerWaybill = product.CustomerWaybill,
- BlacklistAreaId = product.BlacklistAreaId,
- RemoteAreaId = product.RemoteAreaId,
- PriceAreaId = product.PriceAreaId,
- WeightRuleId = product.WeightRuleId,
- WeightRoundingId = product.WeightRoundingId,
- ProductDescription = product.ProductDescription,
- PreStorageScript = product.PreStorageScript,
- IsActive = product.IsActive,
- Scheme = product.Scheme
- },
- Providers = (await GetAllocationCoreAsync(salesProductId)).Providers
- };
- await RulesSnapshotHelper.ApplyRulesToSnapshotAsync(
- rulesSnapshot,
- product,
- KpiAreaRepository,
- WeightRuleRepository,
- WeightRoundingRepository);
- snapshot = rulesSnapshot;
- }
+ object snapshot = operatorType == PriceOperatorType
+ ? await BuildPricePublishSnapshotAsync(salesProductId)
+ : await BuildRulesPublishSnapshotAsync(salesProductId);
// Content 中保存完整快照,回滚时直接从快照恢复,避免依赖当前库内状态。
await SalesProductRepository.InsertPublishRecordAsync(new SalesProductPublishRecord
diff --git a/src/Oms.Application/Services/Channels/SalesProductService.cs b/src/Oms.Application/Services/Channels/SalesProductService.cs
index c55cfb5..c61690b 100644
--- a/src/Oms.Application/Services/Channels/SalesProductService.cs
+++ b/src/Oms.Application/Services/Channels/SalesProductService.cs
@@ -408,6 +408,18 @@ public partial class SalesProductService : ApplicationService
return GetPublishListAsync(input, RulesOperatorType);
}
+ ///
+ /// 预览即将发布的快照 JSON(不落库),用于核对黑名单/计重等是否已固化进 Content。
+ ///
+ [HttpGet("/channel/sales-product/publish/preview")]
+ public async Task