fix: 空SKU编码时改为自动生成避免冲突
All checks were successful
Build and Deploy TenantApi / build-and-deploy (push) Successful in 50s

This commit is contained in:
2026-02-25 10:00:48 +08:00
parent 474c0c88c0
commit 18af62e111

View File

@@ -147,7 +147,9 @@ public sealed class ProductSkuSaveService(TakeoutAppDbContext dbContext)
continue;
}
var generatedCode = normalizedSkuCode ?? GenerateUniqueSkuCode(productId, currentProductSkuCodes);
var generatedCode = !string.IsNullOrWhiteSpace(normalizedSkuCode)
? normalizedSkuCode
: GenerateUniqueSkuCode(productId, currentProductSkuCodes);
if (!plannedSkuCodes.Add(generatedCode))
{
throw new BusinessException(ErrorCodes.BadRequest, $"SKU 编码冲突: {generatedCode}");