admin/src/Oms.Application/Shared/WarehouseCustomerHelper.cs
zzh c2c03f63e3 feat: 店铺平台 OAuth 配置迁入其他配置页
运行时优先读 t_system_other_config,修正管理端客户提示文案,并提供配置种子 SQL。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-16 11:03:02 +08:00

50 lines
1.8 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 Fake.Application;
using Fake.Users;
using Oms.Domain.CustomersAggregate.Repositories;
namespace Oms.Application.Shared;
/// <summary>
/// 仓储模块客户上下文解析。
/// </summary>
public static class WarehouseCustomerHelper
{
/// <summary>
/// 列表/汇总查询用的客户 ID:客户登录强制为自身;管理员未传或传入 ≤0 时返回 null(查询全部)。
/// </summary>
public static async Task<int?> ResolveListCustomerIdAsync(
ICustomerRepository customerRepository,
ICurrentUser currentUser,
int? requestedCustomerId = null)
{
var normalizedRequest = requestedCustomerId is > 0 ? requestedCustomerId : null;
return await OmsSessionHelper.ResolveListCustomerIdAsync(
customerRepository,
currentUser,
normalizedRequest);
}
/// <summary>
/// 写入/删除等必须明确客户归属的操作:客户登录强制为自身;管理员须传有效 customerId(>0)。
/// </summary>
public static async Task<int> ResolveRequiredCustomerIdAsync(
ICustomerRepository customerRepository,
ICurrentUser currentUser,
int? requestedCustomerId = null)
{
var customerId = await ResolveListCustomerIdAsync(customerRepository, currentUser, requestedCustomerId);
if (!customerId.HasValue || customerId.Value <= 0)
{
throw new BusinessException("客户ID不能为空(管理端请先选择客户)");
}
return customerId.Value;
}
public static (bool HasFilter, int Value) ToCustomerFilter(int? customerId) =>
(customerId.HasValue, customerId.GetValueOrDefault());
public static string GenerateInboundNoticeNo() =>
$"IN{DateTime.Now:yyyyMMddHHmmss}{Random.Shared.Next(1000, 9999)}";
}