diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Reports/ReportsPrintLogListItemDto.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Reports/ReportsPrintLogListItemDto.cs
index 42e8bb3..0281df2 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Reports/ReportsPrintLogListItemDto.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Reports/ReportsPrintLogListItemDto.cs
@@ -27,7 +27,7 @@ public class ReportsPrintLogListItemDto
/// 模板展示(尺寸 + 模板名)
public string TemplateText { get; set; } = "无";
- /// 打印时间展示(MM/dd/yy HH:mm)
+ /// 打印时间展示(MM/dd/yy,即 MM/DD/YY)
public string PrintedAt { get; set; } = "无";
/// 打印人姓名
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IReportsAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IReportsAppService.cs
index 9f3c617..8d0a88a 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IReportsAppService.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IReportsAppService.cs
@@ -13,7 +13,7 @@ public interface IReportsAppService : IApplicationService
{
///
/// Print Log 分页列表;角色 admin 可查全部,否则仅当前用户打印记录。
- /// 出参 printedAt、expiryDateText 统一为美式短日期 MM/dd/yy HH:mm(精确到分钟)。
+ /// 出参 printedAt、expiryDateText 日期部分统一为美式短日期 MM/dd/yy(MM/DD/YY);含时分时 MM/dd/yy HH:mm。
///
Task> GetPrintLogListAsync(ReportsPrintLogGetListInputVo input);
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelEntityPartnerScopeHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelEntityPartnerScopeHelper.cs
index 748d61e..4aa1d5a 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelEntityPartnerScopeHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelEntityPartnerScopeHelper.cs
@@ -138,7 +138,7 @@ public static class LabelEntityPartnerScopeHelper
}
///
- /// 保存 Company 适用范围(关联表 + AppliedPartnerType 列);未执行迁移脚本时 no-op。
+ /// 保存 Company 适用范围(关联表与 AppliedPartnerType 列独立探测与落库);未执行迁移脚本时 no-op。
///
public static async Task SavePartnerScopeAsync(
ISqlSugarClient db,
@@ -154,25 +154,54 @@ public static class LabelEntityPartnerScopeHelper
return;
}
+ var needsPartnerRows = NeedsPartnerRowPersistence(scope);
var schema = await GetSchemaStatusAsync(db);
- if (!HasPartnerScopeForKind(schema, kind))
+ var hasTable = HasPartnerTableForKind(schema, kind);
+ var hasColumn = HasPartnerColumnForKind(schema, kind);
+
+ if (!hasTable && !hasColumn)
{
- return;
+ if (needsPartnerRows)
+ {
+ schema = await RefreshSchemaCacheAsync(db);
+ hasTable = HasPartnerTableForKind(schema, kind);
+ hasColumn = HasPartnerColumnForKind(schema, kind);
+ }
+ else
+ {
+ return;
+ }
+ }
+ else if (needsPartnerRows && !hasTable)
+ {
+ schema = await RefreshSchemaCacheAsync(db);
+ hasTable = HasPartnerTableForKind(schema, kind);
+ hasColumn = HasPartnerColumnForKind(schema, kind);
}
- await DeletePartnerScopeRowsAsync(db, kind, entityId);
+ if (needsPartnerRows && !hasTable)
+ {
+ throw new UserFriendlyException(
+ "Company 适用范围关联表尚未就绪,请联系管理员执行数据库迁移(fl_label_entity_partner_scope.sql)后重试");
+ }
- if (string.Equals(scope.AppliedPartnerType, ScopeSpecified, StringComparison.OrdinalIgnoreCase)
- && scope.PartnerIds.Count > 0)
+ if (hasTable)
{
- await InsertPartnerRowsAsync(db, guidGenerator, kind, entityId, scope.PartnerIds, currentUserId, now);
+ await DeletePartnerScopeRowsCoreAsync(db, kind, entityId);
+ if (needsPartnerRows)
+ {
+ await InsertPartnerRowsAsync(db, guidGenerator, kind, entityId, scope.PartnerIds, currentUserId, now);
+ }
}
- await SetAppliedPartnerTypeAsync(db, kind, entityId, scope.AppliedPartnerType);
+ if (hasColumn)
+ {
+ await SetAppliedPartnerTypeAsync(db, kind, entityId, scope.AppliedPartnerType);
+ }
}
///
- /// 删除实体下 Company 关联行;未迁移 partner 表时跳过。
+ /// 删除实体下 Company 关联行;未迁移 partner 表时跳过(缓存过期时会刷新再试)。
///
public static async Task DeletePartnerScopeRowsAsync(
ISqlSugarClient db,
@@ -185,29 +214,19 @@ public static class LabelEntityPartnerScopeHelper
}
var schema = await GetSchemaStatusAsync(db);
- if (!HasPartnerTableForKind(schema, kind))
+ var hasTable = HasPartnerTableForKind(schema, kind);
+ if (!hasTable)
{
- return;
+ schema = await RefreshSchemaCacheAsync(db);
+ hasTable = HasPartnerTableForKind(schema, kind);
}
- switch (kind)
+ if (!hasTable)
{
- case LabelEntityPartnerKind.Type:
- await db.Deleteable()
- .Where(x => x.LabelTypeId == entityId)
- .ExecuteCommandAsync();
- break;
- case LabelEntityPartnerKind.Category:
- await db.Deleteable()
- .Where(x => x.CategoryId == entityId)
- .ExecuteCommandAsync();
- break;
- case LabelEntityPartnerKind.MultipleOption:
- await db.Deleteable()
- .Where(x => x.MultipleOptionId == entityId)
- .ExecuteCommandAsync();
- break;
+ return;
}
+
+ await DeletePartnerScopeRowsCoreAsync(db, kind, entityId);
}
///
@@ -234,9 +253,10 @@ public static class LabelEntityPartnerScopeHelper
}
var schema = await GetSchemaStatusAsync(db);
- var hasScope = HasPartnerScopeForKind(schema, kind);
+ var hasTable = HasPartnerTableForKind(schema, kind);
+ var hasColumn = HasPartnerColumnForKind(schema, kind);
- var partnerLinks = hasScope
+ var partnerLinks = hasTable
? await LoadPartnerLinksAsync(db, kind, ids)
: new List<(string EntityId, string PartnerId)>();
@@ -249,7 +269,7 @@ public static class LabelEntityPartnerScopeHelper
partnerLinks.Where(x => x.EntityId == entityId).Select(x => x.PartnerId).ToList());
var partnerType = pIds.Count > 0 ? ScopeSpecified : ScopeAll;
- if (hasScope)
+ if (hasColumn)
{
var storedType = await GetAppliedPartnerTypeAsync(db, kind, entityId);
if (!string.IsNullOrWhiteSpace(storedType))
@@ -261,6 +281,10 @@ public static class LabelEntityPartnerScopeHelper
partnerType = ScopeSpecified;
}
}
+ else if (pIds.Count > 0)
+ {
+ partnerType = ScopeSpecified;
+ }
var companyDisplay = string.Equals(partnerType, ScopeAll, StringComparison.OrdinalIgnoreCase)
? AllCompaniesDisplay
@@ -456,6 +480,41 @@ public static class LabelEntityPartnerScopeHelper
/// 单元测试或切换库后调用。
public static void ResetSchemaCacheForTests() => _cachedSchema = null;
+ private static bool NeedsPartnerRowPersistence(LabelEntityPartnerScopeSaveResult scope) =>
+ string.Equals(scope.AppliedPartnerType, ScopeSpecified, StringComparison.OrdinalIgnoreCase)
+ && scope.PartnerIds.Count > 0;
+
+ private static async Task RefreshSchemaCacheAsync(ISqlSugarClient db)
+ {
+ _cachedSchema = null;
+ return await GetSchemaStatusAsync(db);
+ }
+
+ private static async Task DeletePartnerScopeRowsCoreAsync(
+ ISqlSugarClient db,
+ LabelEntityPartnerKind kind,
+ string entityId)
+ {
+ switch (kind)
+ {
+ case LabelEntityPartnerKind.Type:
+ await db.Deleteable()
+ .Where(x => x.LabelTypeId == entityId)
+ .ExecuteCommandAsync();
+ break;
+ case LabelEntityPartnerKind.Category:
+ await db.Deleteable()
+ .Where(x => x.CategoryId == entityId)
+ .ExecuteCommandAsync();
+ break;
+ case LabelEntityPartnerKind.MultipleOption:
+ await db.Deleteable()
+ .Where(x => x.MultipleOptionId == entityId)
+ .ExecuteCommandAsync();
+ break;
+ }
+ }
+
private static void ValidatePartnerType(string type)
{
if (type != ScopeAll && type != ScopeSpecified)
@@ -514,9 +573,6 @@ public static class LabelEntityPartnerScopeHelper
return _cachedSchema;
}
- private static bool HasPartnerScopeForKind(LabelEntityPartnerScopeSchemaStatus schema, LabelEntityPartnerKind kind) =>
- HasPartnerTableForKind(schema, kind) && HasPartnerColumnForKind(schema, kind);
-
private static bool HasPartnerTableForKind(LabelEntityPartnerScopeSchemaStatus schema, LabelEntityPartnerKind kind) =>
kind switch
{
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeHelper.cs
index b453b3f..5c1e81d 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeHelper.cs
@@ -150,13 +150,29 @@ public static class LabelTemplateScopeHelper
string? currentUserId,
DateTime now)
{
- var hasExtendedScope = await LabelTemplateScopeSchemaHelper.HasPartnerRegionScopeTablesAsync(db);
+ var needsPartnerRows = string.Equals(scope.AppliedPartnerType, ScopeSpecified, StringComparison.OrdinalIgnoreCase)
+ && scope.PartnerIds.Count > 0;
+ var needsRegionRows = string.Equals(scope.AppliedRegionType, ScopeSpecified, StringComparison.OrdinalIgnoreCase)
+ && scope.RegionIds.Count > 0;
- if (hasExtendedScope)
+ var hasPartnerTable = await LabelTemplateScopeSchemaHelper.EnsurePartnerScopeTableAsync(db, needsPartnerRows);
+ var hasRegionTable = await LabelTemplateScopeSchemaHelper.EnsureRegionScopeTableAsync(db, needsRegionRows);
+
+ if (needsPartnerRows && !hasPartnerTable)
+ {
+ throw new UserFriendlyException(
+ "Company 适用范围关联表尚未就绪,请联系管理员执行数据库迁移(fl_label_template_scope.sql)后重试");
+ }
+
+ if (hasPartnerTable)
{
await db.Deleteable()
.Where(x => x.TemplateId == templateId)
.ExecuteCommandAsync();
+ }
+
+ if (hasRegionTable)
+ {
await db.Deleteable()
.Where(x => x.TemplateId == templateId)
.ExecuteCommandAsync();
@@ -166,9 +182,7 @@ public static class LabelTemplateScopeHelper
.Where(x => x.TemplateId == templateId)
.ExecuteCommandAsync();
- if (hasExtendedScope
- && string.Equals(scope.AppliedPartnerType, ScopeSpecified, StringComparison.OrdinalIgnoreCase)
- && scope.PartnerIds.Count > 0)
+ if (hasPartnerTable && needsPartnerRows)
{
var rows = scope.PartnerIds.Select(pid => new FlLabelTemplatePartnerDbEntity
{
@@ -181,9 +195,7 @@ public static class LabelTemplateScopeHelper
await db.Insertable(rows).ExecuteCommandAsync();
}
- if (hasExtendedScope
- && string.Equals(scope.AppliedRegionType, ScopeSpecified, StringComparison.OrdinalIgnoreCase)
- && scope.RegionIds.Count > 0)
+ if (hasRegionTable && needsRegionRows)
{
var rows = scope.RegionIds.Select(gid => new FlLabelTemplateRegionDbEntity
{
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeSchemaHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeSchemaHelper.cs
index 83faab5..2285075 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeSchemaHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeSchemaHelper.cs
@@ -116,6 +116,13 @@ public static class LabelTemplateScopeSchemaHelper
/// 单元测试或切换库后调用。
public static void ResetCacheForTests() => _cached = null;
+ /// 清除缓存并重新探测 schema(应用启动早于迁移脚本执行后调用)。
+ public static async Task RefreshStatusAsync(ISqlSugarClient db)
+ {
+ _cached = null;
+ return await GetStatusAsync(db);
+ }
+
///
/// 是否已创建 fl_label_template_partner 与 fl_label_template_region。
///
@@ -126,6 +133,46 @@ public static class LabelTemplateScopeSchemaHelper
}
///
+ /// 是否已创建 fl_label_template_partner;缓存未命中时刷新后再探测。
+ ///
+ public static async Task EnsurePartnerScopeTableAsync(ISqlSugarClient db, bool needsPartnerRows)
+ {
+ var status = await GetStatusAsync(db);
+ if (status.HasPartnerScopeTable)
+ {
+ return true;
+ }
+
+ if (!needsPartnerRows)
+ {
+ return false;
+ }
+
+ status = await RefreshStatusAsync(db);
+ return status.HasPartnerScopeTable;
+ }
+
+ ///
+ /// 是否已创建 fl_label_template_region;缓存未命中时刷新后再探测。
+ ///
+ public static async Task EnsureRegionScopeTableAsync(ISqlSugarClient db, bool needsRegionRows)
+ {
+ var status = await GetStatusAsync(db);
+ if (status.HasRegionScopeTable)
+ {
+ return true;
+ }
+
+ if (!needsRegionRows)
+ {
+ return false;
+ }
+
+ status = await RefreshStatusAsync(db);
+ return status.HasRegionScopeTable;
+ }
+
+ ///
/// 已迁移 scope 列时,写入 AppliedPartnerType / AppliedRegionType(未迁移则 no-op)。
///
public static async Task SetAppliedScopeTypesAsync(
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationScopeBindingHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationScopeBindingHelper.cs
index 1fe9817..a68f816 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationScopeBindingHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationScopeBindingHelper.cs
@@ -336,6 +336,34 @@ public static class LocationScopeBindingHelper
}
///
+ /// 标签类型/分类/多选项门店范围落库:仅按 Region/Location 合并,不因 Company(partner)展开并集。
+ ///
+ public static async Task> ResolveEntityLocationIdsForSaveAsync(
+ ISqlSugarClient db,
+ bool locationSpecified,
+ IReadOnlyList? regionIds,
+ IReadOnlyList? locationIds)
+ {
+ if (!locationSpecified)
+ {
+ return new List();
+ }
+
+ var merged = await MergeToLocationIdsAsync(
+ db,
+ (IReadOnlyList?)null,
+ regionIds,
+ locationIds);
+ if (merged.Count == 0)
+ {
+ throw new UserFriendlyException("指定适用区域或门店时,至少需要匹配到一个有效门店");
+ }
+
+ await ValidateLocationIdsExistAsync(db, merged);
+ return merged;
+ }
+
+ ///
/// 根据已绑定门店反推适用的 Company Id(fl_partner.Id)。
///
public static async Task> ResolvePartnerIdsFromLocationIdsAsync(
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/ReportsDateTimeDisplayHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/ReportsDateTimeDisplayHelper.cs
index ba86174..fedc54a 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/ReportsDateTimeDisplayHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/ReportsDateTimeDisplayHelper.cs
@@ -1,413 +1,217 @@
using System.Globalization;
-
-
namespace FoodLabeling.Application.Helpers;
-
-
///
-
-/// Reports Print Log 日期时间展示:统一为 MM/dd/yy HH:mm(精确到分钟)。
-
+/// Reports Print Log 日期展示:统一为美式短日期 MM/dd/yy(MM/DD/YY)。
///
-
public static class ReportsDateTimeDisplayHelper
-
{
+ /// 列表日期列统一格式(MM/DD/YY)。
+ public const string DateDisplayFormat = "MM/dd/yy";
- public const string DisplayFormat = "MM/dd/yy HH:mm";
-
+ /// 含时分时在同日期格式后追加 HH:mm。
+ public const string DateTimeDisplayFormat = "MM/dd/yy HH:mm";
+ /// 兼容旧引用。
+ public const string DisplayFormat = DateTimeDisplayFormat;
private static readonly string[] ExpiryParseFormats =
-
{
-
- DisplayFormat,
-
+ DateTimeDisplayFormat,
+ DateDisplayFormat,
"MM/dd/yy",
-
"MM/dd",
-
"yyyy-MM-dd H:mm",
-
"yyyy-MM-dd",
-
"yyyy/MM/dd HH:mm",
-
"yyyy/MM/dd",
-
"MM/dd/yyyy hh:mm tt",
-
"MM/dd/yyyy h:mm tt",
-
"MM/dd/yyyy HH:mm",
-
"MM/dd/yyyy",
-
"M/d/yyyy hh:mm tt",
-
"M/d/yyyy h:mm tt",
-
"M/d/yyyy",
-
"dd/MM/yyyy HH:mm",
-
"dd/MM/yyyy",
-
"d/M/yyyy HH:mm",
-
"d/M/yyyy",
-
};
-
-
- /// 打印时间展示(Printed at 列)
-
+ /// 打印时间展示(Printed at 列):统一 MM/DD/YY。
public static string FormatPrintedAt(DateTime printedAt)
-
{
-
if (printedAt == DateTime.MinValue)
-
{
-
return "无";
-
}
-
-
- return printedAt.ToString(DisplayFormat, CultureInfo.InvariantCulture);
-
+ return printedAt.ToString(DateDisplayFormat, CultureInfo.InvariantCulture);
}
-
-
- /// 保质期展示(Expiration 列):解析后统一为 。
-
+ /// 保质期展示(Expiration 列):解析后统一为 或含时分时 。
public static string FormatExpiryDisplay(string? raw, DateTime? anchor = null)
-
{
-
if (string.IsNullOrWhiteSpace(raw) || string.Equals(raw.Trim(), "无", StringComparison.Ordinal))
-
{
-
return "无";
-
}
-
-
var s = raw.Trim();
-
if (TryParseToDateTime(s, out var dt))
-
{
-
- return dt.ToString(DisplayFormat, CultureInfo.InvariantCulture);
-
+ return FormatExpiryDateTime(dt);
}
-
-
- if (anchor.HasValue && TryParsePartialDateTime(s, anchor.Value, out dt))
-
+ var reference = anchor ?? DateTime.Now;
+ if (TryParsePartialDateTime(s, reference, out dt))
{
-
- return dt.ToString(DisplayFormat, CultureInfo.InvariantCulture);
-
+ return FormatExpiryDateTime(dt);
}
-
-
return s;
-
}
-
-
/// 合并日期片段(如 07/09)与时间片段(如 11:56),缺少年份时用 anchor 补全。
-
public static string MergeDateAndTimeParts(string datePart, string timePart, DateTime anchor)
-
{
-
var date = datePart.Trim();
-
var time = timePart.Trim();
-
if (string.IsNullOrWhiteSpace(date))
-
{
-
return string.IsNullOrWhiteSpace(time) ? "无" : time;
-
}
-
-
if (!TryParsePartialDateTime(date, anchor, out var dt) && !TryParseToDateTime(date, out dt))
-
{
-
return string.IsNullOrWhiteSpace(time) ? date : $"{date} {time}";
-
}
-
-
if (!string.IsNullOrWhiteSpace(time))
-
{
-
var timeMatch = System.Text.RegularExpressions.Regex.Match(
-
time,
-
@"^(?\d{1,2}):(?\d{2})",
-
System.Text.RegularExpressions.RegexOptions.CultureInvariant);
-
if (timeMatch.Success &&
-
int.TryParse(timeMatch.Groups["h"].Value, out var h) &&
-
int.TryParse(timeMatch.Groups["m"].Value, out var m))
-
{
-
dt = new DateTime(dt.Year, dt.Month, dt.Day, h, m, 0, dt.Kind);
-
}
-
}
-
-
- return dt.ToString(DisplayFormat, CultureInfo.InvariantCulture);
-
+ return FormatExpiryDateTime(dt);
}
-
-
private static bool TryParsePartialDateTime(string s, DateTime anchor, out DateTime dt)
-
{
-
dt = default;
-
var text = s.Trim();
-
var timeMatch = System.Text.RegularExpressions.Regex.Match(
-
text,
-
@"^(?\d{1,2}/\d{1,2}(?:/\d{2,4})?)\s+(?
public string AvailabilityType { get; set; } = "ALL";
+
+ ///
+ /// 适用 Company 范围:ALL / SPECIFIED
+ ///
+ public string AppliedPartnerType { get; set; } = "ALL";
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlLabelMultipleOptionDbEntity.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlLabelMultipleOptionDbEntity.cs
index 231f746..c153dad 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlLabelMultipleOptionDbEntity.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlLabelMultipleOptionDbEntity.cs
@@ -34,5 +34,10 @@ public class FlLabelMultipleOptionDbEntity
/// 门店可用范围:ALL / SPECIFIED
///
public string AvailabilityType { get; set; } = "ALL";
+
+ ///
+ /// 适用 Company 范围:ALL / SPECIFIED
+ ///
+ public string AppliedPartnerType { get; set; } = "ALL";
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlLabelTypeDbEntity.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlLabelTypeDbEntity.cs
index aa92f95..1a7bccc 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlLabelTypeDbEntity.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlLabelTypeDbEntity.cs
@@ -32,5 +32,10 @@ public class FlLabelTypeDbEntity
/// 门店可用范围:ALL / SPECIFIED
///
public string AvailabilityType { get; set; } = "ALL";
+
+ ///
+ /// 适用 Company 范围:ALL / SPECIFIED
+ ///
+ public string AppliedPartnerType { get; set; } = "ALL";
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelCategoryAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelCategoryAppService.cs
index 0c23f30..4d6d0e8 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelCategoryAppService.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelCategoryAppService.cs
@@ -176,6 +176,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ
State = input.State,
ButtonAppearance = appearance,
AvailabilityType = availabilityType,
+ AppliedPartnerType = partnerScope.AppliedPartnerType,
OrderNum = input.OrderNum
};
@@ -219,6 +220,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ
entity.State = input.State;
entity.ButtonAppearance = appearance;
entity.AvailabilityType = availabilityType;
+ entity.AppliedPartnerType = partnerScope.AppliedPartnerType;
entity.OrderNum = input.OrderNum;
entity.LastModificationTime = DateTime.Now;
entity.LastModifierId = CurrentUser?.Id?.ToString();
@@ -305,37 +307,14 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ
throw new UserFriendlyException("门店可用范围不合法(ALL/SPECIFIED)");
}
- var partnerSpecified = string.Equals(
- partnerScope.AppliedPartnerType,
- LabelEntityPartnerScopeHelper.ScopeSpecified,
- StringComparison.OrdinalIgnoreCase);
var locationSpecified = string.Equals(availabilityType, "SPECIFIED", StringComparison.OrdinalIgnoreCase);
+ var savedLocationIds = await LocationScopeBindingHelper.ResolveEntityLocationIdsForSaveAsync(
+ _dbContext.SqlSugarClient,
+ locationSpecified,
+ regionIds,
+ explicitLocationIds);
- if (partnerSpecified || locationSpecified)
- {
- var merged = await LocationScopeBindingHelper.MergeToLocationIdsAsync(
- _dbContext.SqlSugarClient,
- partnerSpecified ? partnerScope.PartnerIds : null,
- locationSpecified ? regionIds : null,
- locationSpecified ? explicitLocationIds : null);
- if (merged.Count == 0)
- {
- throw new UserFriendlyException("指定适用范围后至少需要匹配到一个有效门店");
- }
-
- if (locationSpecified)
- {
- await LocationScopeBindingHelper.ValidateLocationIdsExistAsync(_dbContext.SqlSugarClient, merged);
- return (partnerScope, "SPECIFIED", merged);
- }
- }
-
- if (string.Equals(availabilityType, "ALL", StringComparison.OrdinalIgnoreCase))
- {
- return (partnerScope, "ALL", new List());
- }
-
- throw new UserFriendlyException("指定适用区域或门店时,至少需要匹配到一个有效门店");
+ return (partnerScope, locationSpecified ? "SPECIFIED" : "ALL", savedLocationIds);
}
private static List NormalizeRegionIds(LabelCategoryCreateInputVo input)
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelMultipleOptionAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelMultipleOptionAppService.cs
index e02596a..b68f5d9 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelMultipleOptionAppService.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelMultipleOptionAppService.cs
@@ -148,6 +148,7 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO
OptionValuesJson = input.OptionValuesJson?.Trim(),
State = input.State,
AvailabilityType = availabilityType,
+ AppliedPartnerType = partnerScope.AppliedPartnerType,
OrderNum = input.OrderNum
};
@@ -185,6 +186,7 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO
entity.OptionValuesJson = input.OptionValuesJson?.Trim();
entity.State = input.State;
entity.AvailabilityType = availabilityType;
+ entity.AppliedPartnerType = partnerScope.AppliedPartnerType;
entity.OrderNum = input.OrderNum;
entity.LastModificationTime = DateTime.Now;
entity.LastModifierId = CurrentUser?.Id?.ToString();
@@ -252,37 +254,14 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO
throw new UserFriendlyException("门店可用范围不合法(ALL/SPECIFIED)");
}
- var partnerSpecified = string.Equals(
- partnerScope.AppliedPartnerType,
- LabelEntityPartnerScopeHelper.ScopeSpecified,
- StringComparison.OrdinalIgnoreCase);
var locationSpecified = string.Equals(availabilityType, "SPECIFIED", StringComparison.OrdinalIgnoreCase);
+ var savedLocationIds = await LocationScopeBindingHelper.ResolveEntityLocationIdsForSaveAsync(
+ _dbContext.SqlSugarClient,
+ locationSpecified,
+ regionIds,
+ explicitLocationIds);
- if (partnerSpecified || locationSpecified)
- {
- var merged = await LocationScopeBindingHelper.MergeToLocationIdsAsync(
- _dbContext.SqlSugarClient,
- partnerSpecified ? partnerScope.PartnerIds : null,
- locationSpecified ? regionIds : null,
- locationSpecified ? explicitLocationIds : null);
- if (merged.Count == 0)
- {
- throw new UserFriendlyException("指定适用范围后至少需要匹配到一个有效门店");
- }
-
- if (locationSpecified)
- {
- await LocationScopeBindingHelper.ValidateLocationIdsExistAsync(_dbContext.SqlSugarClient, merged);
- return (partnerScope, "SPECIFIED", merged);
- }
- }
-
- if (string.Equals(availabilityType, "ALL", StringComparison.OrdinalIgnoreCase))
- {
- return (partnerScope, "ALL", new List());
- }
-
- throw new UserFriendlyException("指定适用区域或门店时,至少需要匹配到一个有效门店");
+ return (partnerScope, locationSpecified ? "SPECIFIED" : "ALL", savedLocationIds);
}
private async Task SaveMultipleOptionPartnerScopeAsync(
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelTypeAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelTypeAppService.cs
index 34ac840..7501f05 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelTypeAppService.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelTypeAppService.cs
@@ -155,6 +155,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService
TypeName = name,
State = input.State,
AvailabilityType = availabilityType,
+ AppliedPartnerType = partnerScope.AppliedPartnerType,
OrderNum = input.OrderNum
};
@@ -193,6 +194,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService
entity.TypeName = name;
entity.State = input.State;
entity.AvailabilityType = availabilityType;
+ entity.AppliedPartnerType = partnerScope.AppliedPartnerType;
entity.OrderNum = input.OrderNum;
entity.LastModificationTime = DateTime.Now;
entity.LastModifierId = CurrentUser?.Id?.ToString();
@@ -267,37 +269,14 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService
throw new UserFriendlyException("门店可用范围不合法(ALL/SPECIFIED)");
}
- var partnerSpecified = string.Equals(
- partnerScope.AppliedPartnerType,
- LabelEntityPartnerScopeHelper.ScopeSpecified,
- StringComparison.OrdinalIgnoreCase);
var locationSpecified = string.Equals(availabilityType, "SPECIFIED", StringComparison.OrdinalIgnoreCase);
+ var savedLocationIds = await LocationScopeBindingHelper.ResolveEntityLocationIdsForSaveAsync(
+ _dbContext.SqlSugarClient,
+ locationSpecified,
+ regionIds,
+ explicitLocationIds);
- if (partnerSpecified || locationSpecified)
- {
- var merged = await LocationScopeBindingHelper.MergeToLocationIdsAsync(
- _dbContext.SqlSugarClient,
- partnerSpecified ? partnerScope.PartnerIds : null,
- locationSpecified ? regionIds : null,
- locationSpecified ? explicitLocationIds : null);
- if (merged.Count == 0)
- {
- throw new UserFriendlyException("指定适用范围后至少需要匹配到一个有效门店");
- }
-
- if (locationSpecified)
- {
- await LocationScopeBindingHelper.ValidateLocationIdsExistAsync(_dbContext.SqlSugarClient, merged);
- return (partnerScope, "SPECIFIED", merged);
- }
- }
-
- if (string.Equals(availabilityType, "ALL", StringComparison.OrdinalIgnoreCase))
- {
- return (partnerScope, "ALL", new List());
- }
-
- throw new UserFriendlyException("指定适用区域或门店时,至少需要匹配到一个有效门店");
+ return (partnerScope, locationSpecified ? "SPECIFIED" : "ALL", savedLocationIds);
}
private async Task SaveTypePartnerScopeAsync(