diff --git a/src/Oms.Application/Dtos/Orders/CustomerSenderAddressDtos.cs b/src/Oms.Application/Dtos/Orders/CustomerSenderAddressDtos.cs
index e8797e8..da181ec 100644
--- a/src/Oms.Application/Dtos/Orders/CustomerSenderAddressDtos.cs
+++ b/src/Oms.Application/Dtos/Orders/CustomerSenderAddressDtos.cs
@@ -13,6 +13,12 @@ public class CustomerSenderAddressPaginatedInput
[Newtonsoft.Json.JsonProperty("pageSize")]
public int PageSize { get; set; } = 30;
+ ///
+ /// 客户 ID(管理端可选;不传则查全部)。
+ ///
+ [Newtonsoft.Json.JsonProperty("customerId")]
+ public int? CustomerId { get; set; }
+
///
/// 地址类型:all / sender / return / receiver。
///
@@ -31,6 +37,11 @@ public class CustomerSenderAddressPaginatedInput
///
public class CreateCustomerSenderAddressInput
{
+ ///
+ /// 客户 ID(管理端代操作必传;客户门户可省略)。
+ ///
+ public int? CustomerId { get; set; }
+
///
/// 地址类型:sender 发件 / return 退件 / receiver 收件。
///
@@ -158,6 +169,11 @@ public class CustomerSenderAddressOutput
///
public class OrderPickupCreateInput
{
+ ///
+ /// 客户 ID(管理端代创建必传;客户门户可省略)。
+ ///
+ public int? CustomerId { get; set; }
+
public string? RequestId { get; set; }
public string? ClientNo { get; set; }
diff --git a/src/Oms.Application/Dtos/Orders/OrderPaginatedInput.cs b/src/Oms.Application/Dtos/Orders/OrderPaginatedInput.cs
index eaf3cf0..90a4787 100644
--- a/src/Oms.Application/Dtos/Orders/OrderPaginatedInput.cs
+++ b/src/Oms.Application/Dtos/Orders/OrderPaginatedInput.cs
@@ -38,6 +38,13 @@ public class OrderPaginatedInput
[global::System.Text.Json.Serialization.JsonPropertyName("orderSource")]
public string? OrderSource { get; set; }
+ ///
+ /// 客户 ID(管理端可选;不传则查全部)。
+ ///
+ [Newtonsoft.Json.JsonProperty("customerId")]
+ [global::System.Text.Json.Serialization.JsonPropertyName("customerId")]
+ public int? CustomerId { get; set; }
+
///
/// 关键词。
///
diff --git a/src/Oms.Application/Services/Orders/OrderService.Pickup.cs b/src/Oms.Application/Services/Orders/OrderService.Pickup.cs
index 42c3e5b..e31fe88 100644
--- a/src/Oms.Application/Services/Orders/OrderService.Pickup.cs
+++ b/src/Oms.Application/Services/Orders/OrderService.Pickup.cs
@@ -45,8 +45,11 @@ public partial class OrderService
throw new BusinessException("揽收时间不能为空");
}
- var customer = await OmsSessionHelper.ResolveSessionCustomerAsync(CustomerRepository, CurrentUser);
- var senderAddress = await CustomerSenderAddressRepository.GetOwnedAsync(input.SenderAddressId, customer.Id);
+ var customerId = await WarehouseCustomerHelper.ResolveRequiredCustomerIdAsync(
+ CustomerRepository,
+ CurrentUser,
+ input.CustomerId);
+ var senderAddress = await CustomerSenderAddressRepository.GetOwnedAsync(input.SenderAddressId, customerId);
if (senderAddress == null)
{
throw new BusinessException("发件地址不存在");
@@ -77,7 +80,7 @@ public partial class OrderService
input,
senderAddress,
warehouse,
- customer.Id,
+ customerId,
senderCountryCode);
return await CreateParcelCoreAsync(
diff --git a/src/Oms.Application/Services/Orders/OrderService.SenderAddress.cs b/src/Oms.Application/Services/Orders/OrderService.SenderAddress.cs
index a0ae85c..c05d4e7 100644
--- a/src/Oms.Application/Services/Orders/OrderService.SenderAddress.cs
+++ b/src/Oms.Application/Services/Orders/OrderService.SenderAddress.cs
@@ -17,26 +17,27 @@ public partial class OrderService
///
/// 客户地址分页列表(发件/退件/收件)。
+ /// 管理端未传 customerId 时查询全部;客户门户仅查自身。
///
[HttpPost("/order/sender-address/list")]
public async Task> GetSenderAddressListAsync(
[FromBody] CustomerSenderAddressPaginatedInput input)
{
- var customer = await OmsSessionHelper.ResolveSessionCustomerAsync(CustomerRepository, CurrentUser);
+ var customerId = await WarehouseCustomerHelper.ResolveListCustomerIdAsync(
+ CustomerRepository,
+ CurrentUser,
+ input.CustomerId);
var pageIndex = OmsDocHelper.NormalizePage(input.Page);
var pageSize = OmsDocHelper.NormalizePageSize(input.PageSize);
- var predicate = BuildSenderAddressPredicate(customer.Id, input);
+ var predicate = BuildSenderAddressPredicate(customerId, input);
- var entities = await CustomerSenderAddressRepository.GetPagedListAsync(
+ // 避免 Fake GetPagedListAsync(sorting) 丢失 Where / SqlSugar 错误翻译表达式
+ var (entities, total) = await RepositoryPageHelper.GetPageAsync(
+ CustomerSenderAddressRepository,
predicate,
pageIndex,
pageSize,
- new Dictionary
- {
- [nameof(CustomerSenderAddress.IsDefault)] = false,
- [nameof(CustomerSenderAddress.Id)] = false
- });
- var total = await CustomerSenderAddressRepository.CountAsync(predicate);
+ q => q.OrderByDescending(x => x.IsDefault).ThenByDescending(x => x.Id));
var countryMap = await LoadCountryCodeMapAsync(entities.Select(x => x.Country).Where(x => x.HasValue).Select(x => x!.Value));
return new OmsPageResult
@@ -50,9 +51,11 @@ public partial class OrderService
/// 客户地址详情。
///
[HttpGet("/order/sender-address/detail")]
- public async Task GetSenderAddressDetailAsync([FromQuery] int id)
+ public async Task GetSenderAddressDetailAsync(
+ [FromQuery] int id,
+ [FromQuery] int? customerId = null)
{
- var entity = await GetOwnedSenderAddressOrThrowAsync(id);
+ var entity = await GetOwnedSenderAddressOrThrowAsync(id, customerId);
var countryMap = await LoadCountryCodeMapAsync(entity.Country.HasValue ? [entity.Country.Value] : []);
return MapSenderAddressOutput(entity, countryMap);
}
@@ -63,19 +66,22 @@ public partial class OrderService
[HttpPost("/order/sender-address/create")]
public async Task