admin/src/Oms.Application/Monitor/MonitorRegionMapper.cs
zzh cde0ccb6b0 feat: 新增工作台与实时监控统计 API
- GET /order/workplace-stats 与 /order/workplace-trend 供工作台使用

- GET /monitor/overview 供实时监控页订单/客户/轨迹统计

- 扩展订单仓储聚合查询,status-counts 同步应用数据权限

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-04 18:24:48 +08:00

79 lines
3.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Oms.Domain.OrdersAggregate.Consts;
namespace Oms.Application.Monitor;
/// <summary>
/// 将目的国映射为监控页线路 key(us/eu/sea/au/jp/uk/other)。
/// </summary>
public static class MonitorRegionMapper
{
public static readonly string[] RegionKeys = ["us", "eu", "sea", "au", "jp", "uk"];
private static readonly HashSet<string> UsCodes = new(StringComparer.OrdinalIgnoreCase)
{
"US", "USA", "840",
};
private static readonly HashSet<string> UkCodes = new(StringComparer.OrdinalIgnoreCase)
{
"GB", "UK", "826",
};
private static readonly HashSet<string> AuCodes = new(StringComparer.OrdinalIgnoreCase)
{
"AU", "AUS", "036",
};
private static readonly HashSet<string> JpCodes = new(StringComparer.OrdinalIgnoreCase)
{
"JP", "JPN", "392",
};
private static readonly HashSet<string> EuCodes = new(StringComparer.OrdinalIgnoreCase)
{
"DE", "FR", "IT", "ES", "NL", "BE", "PL", "SE", "AT", "PT", "IE", "DK", "FI", "GR", "CZ", "RO", "HU", "SK",
"276", "250", "380", "724", "528", "056", "616", "752", "040", "620", "372", "208", "246", "203", "348", "642",
};
private static readonly HashSet<string> SeaCodes = new(StringComparer.OrdinalIgnoreCase)
{
"SG", "MY", "TH", "VN", "PH", "ID", "702", "458", "764", "704", "608", "360",
};
public static string MapCountryToRegion(string? countryCodeOrName)
{
var code = (countryCodeOrName ?? string.Empty).Trim();
if (string.IsNullOrWhiteSpace(code))
{
return "other";
}
if (UsCodes.Contains(code)) return "us";
if (UkCodes.Contains(code)) return "uk";
if (AuCodes.Contains(code)) return "au";
if (JpCodes.Contains(code)) return "jp";
if (EuCodes.Contains(code)) return "eu";
if (SeaCodes.Contains(code)) return "sea";
var upper = code.ToUpperInvariant();
if (upper.Contains("UNITED STATES") || upper == "美国") return "us";
if (upper.Contains("UNITED KINGDOM") || upper == "英国") return "uk";
if (upper.Contains("AUSTRALIA") || upper == "澳大利亚") return "au";
if (upper.Contains("JAPAN") || upper == "日本") return "jp";
if (upper.Contains("GERMANY") || upper.Contains("FRANCE") || upper == "德国" || upper == "法国") return "eu";
if (upper.Contains("SINGAPORE") || upper.Contains("MALAYSIA") || upper == "新加坡" || upper == "马来西亚") return "sea";
return "other";
}
public static bool IsDeliveredStatus(string? status) =>
string.Equals(status, OrderStatusCodes.DeliverySuccess, StringComparison.OrdinalIgnoreCase);
public static bool IsDeliveryFailedStatus(string? status) =>
string.Equals(status, OrderStatusCodes.DeliveryFailed, StringComparison.OrdinalIgnoreCase);
public static bool IsInTransitStatus(string? status) =>
string.Equals(status, OrderStatusCodes.Shipping, StringComparison.OrdinalIgnoreCase)
|| string.Equals(status, OrderStatusCodes.PendingOnline, StringComparison.OrdinalIgnoreCase);
}