test #11
@ -1,7 +1,5 @@
|
|||||||
using System.Data;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Fake.Application;
|
using Fake.Application;
|
||||||
using Fake.UnitOfWork;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Oms.Application.Dtos.Channels;
|
using Oms.Application.Dtos.Channels;
|
||||||
@ -26,10 +24,9 @@ public partial class OrderService
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑订单详情(基本信息、发件人、收件人)。
|
/// 编辑订单详情(基本信息、发件人、收件人)。
|
||||||
/// 跟踪号变更时会写轨迹 Upsert Outbox,须事务性 UoW。
|
/// 跟踪号变更时同步调用轨迹 Upsert(不走 Outbox)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HttpPost("/order/update")]
|
[HttpPost("/order/update")]
|
||||||
[UnitOfWork(IsTransactional = true, IsolationLevel = IsolationLevel.ReadCommitted)]
|
|
||||||
public async Task<OrderOutput> UpdateOrderDetailAsync(OrderUpdateInput input)
|
public async Task<OrderOutput> UpdateOrderDetailAsync(OrderUpdateInput input)
|
||||||
{
|
{
|
||||||
var order = await GetOrderOrThrowAsync(input.Id);
|
var order = await GetOrderOrThrowAsync(input.Id);
|
||||||
@ -162,7 +159,7 @@ public partial class OrderService
|
|||||||
|
|
||||||
if (input.TrackNo != null)
|
if (input.TrackNo != null)
|
||||||
{
|
{
|
||||||
await EnqueueSmallBagTrackUpsertWhenTrackNoChangedAsync(order, previousTrackNo);
|
await SyncSmallBagTrackUpsertWhenTrackNoChangedAsync(order, previousTrackNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (await MapOrderOutputsAsync([order])).First();
|
return (await MapOrderOutputsAsync([order])).First();
|
||||||
|
|||||||
@ -3234,6 +3234,30 @@ public partial class OrderService
|
|||||||
await EnqueueSmallBagTrackUpsertAsync(order, customer: null, receiver: null, appendInitialTrack);
|
await EnqueueSmallBagTrackUpsertAsync(order, customer: null, receiver: null, appendInitialTrack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 跟踪号变更时同步 Upsert 轨迹(编辑订单详情用,避免依赖 Outbox/事务 UoW)。
|
||||||
|
/// 失败仅记日志,不阻断订单保存。
|
||||||
|
/// </summary>
|
||||||
|
private async Task SyncSmallBagTrackUpsertWhenTrackNoChangedAsync(
|
||||||
|
Order order,
|
||||||
|
string? previousTrackNo,
|
||||||
|
bool appendInitialTrack = true)
|
||||||
|
{
|
||||||
|
var next = order.TrackNo?.Trim() ?? string.Empty;
|
||||||
|
var prev = previousTrackNo?.Trim() ?? string.Empty;
|
||||||
|
if (string.IsNullOrWhiteSpace(next)
|
||||||
|
|| string.Equals(next, prev, StringComparison.Ordinal)
|
||||||
|
|| string.IsNullOrWhiteSpace(order.ServiceNo))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var request = await BuildSmallBagTrackUpsertRequestAsync(order);
|
||||||
|
request.AppendInitialTrackOnSuccess = appendInitialTrack;
|
||||||
|
ApplyTrackAuthorization(request);
|
||||||
|
await SmallBagTrackOrderClient.UpsertAsync(request);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task EnqueueLifecycleTrackAppendAsync(Order order, string trackCode)
|
private async Task EnqueueLifecycleTrackAppendAsync(Order order, string trackCode)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(order.ServiceNo))
|
if (string.IsNullOrWhiteSpace(order.ServiceNo))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user