Compare commits
No commits in common. "24dd1b0eff41a4448f896ab5e4e22459c60ea52a" and "e44704597cd95b5c6cd74045088b2f2e329b82e2" have entirely different histories.
24dd1b0eff
...
e44704597c
@ -23,9 +23,7 @@ public partial class OrderService
|
||||
x.AppKey == AppKey && x.OrderType == TrackOrderType.小包 && x.OrderNo == input.OrderNo);
|
||||
if (order != null)
|
||||
{
|
||||
var existing = order;
|
||||
order = await BuiltOrder(input);
|
||||
ApplyUpsertOntoExisting(order, existing, resetTrackInfoWhenTrackNoChanged: true);
|
||||
|
||||
await _orderRepository.UpdateOrderAsync(order);
|
||||
|
||||
@ -73,9 +71,7 @@ public partial class OrderService
|
||||
x.AppKey == AppKey && x.OrderType == TrackOrderType.大包 && x.OrderNo == input.BagNo);
|
||||
if (order != null)
|
||||
{
|
||||
var existing = order;
|
||||
order = await BuiltOrder(input);
|
||||
ApplyUpsertOntoExisting(order, existing, resetTrackInfoWhenTrackNoChanged: false);
|
||||
|
||||
await _orderRepository.UpdateOrderAsync(order);
|
||||
|
||||
@ -123,9 +119,7 @@ public partial class OrderService
|
||||
x.AppKey == AppKey && x.OrderType == TrackOrderType.主单 && x.OrderNo == input.MasterNo);
|
||||
if (order != null)
|
||||
{
|
||||
var existing = order;
|
||||
order = await BuiltOrder(input);
|
||||
ApplyUpsertOntoExisting(order, existing, resetTrackInfoWhenTrackNoChanged: false);
|
||||
|
||||
await _orderRepository.UpdateOrderAsync(order);
|
||||
|
||||
@ -266,41 +260,6 @@ public partial class OrderService
|
||||
return order;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合并到已有订单:保留 Id;跟踪号未变则保留轨迹摘要,变更则清空便于重拉。
|
||||
/// </summary>
|
||||
private static void ApplyUpsertOntoExisting(
|
||||
OrderEntity built,
|
||||
OrderEntity existing,
|
||||
bool resetTrackInfoWhenTrackNoChanged)
|
||||
{
|
||||
built.Id = existing.Id;
|
||||
|
||||
var previousTrackNo = existing.TrackNo?.Trim() ?? string.Empty;
|
||||
var nextTrackNo = built.TrackNo?.Trim() ?? string.Empty;
|
||||
var trackNoChanged = !string.Equals(previousTrackNo, nextTrackNo, StringComparison.Ordinal);
|
||||
|
||||
if (resetTrackInfoWhenTrackNoChanged && trackNoChanged)
|
||||
{
|
||||
built.ResetTrackInfo();
|
||||
return;
|
||||
}
|
||||
|
||||
built.IsCompleted = existing.IsCompleted;
|
||||
built.LatestPushTrackCode = existing.LatestPushTrackCode;
|
||||
built.LatestPushTime = existing.LatestPushTime;
|
||||
built.LatestPushError = existing.LatestPushError;
|
||||
built.LatestTrackStatus = existing.LatestTrackStatus;
|
||||
built.LatestTrackContent = existing.LatestTrackContent;
|
||||
built.LatestTrackEnContent = existing.LatestTrackEnContent;
|
||||
built.LatestTrackTime = existing.LatestTrackTime;
|
||||
built.LatestTrackTimeZone = existing.LatestTrackTimeZone;
|
||||
built.LatestTrackPlace = existing.LatestTrackPlace;
|
||||
built.EstimatedDeliveryDate = existing.EstimatedDeliveryDate;
|
||||
built.DestinationTimeZone = existing.DestinationTimeZone;
|
||||
built.QuestionType = existing.QuestionType;
|
||||
}
|
||||
|
||||
private static OrderPullStatusEntity CreateOrderPullStatus(TrackPullConfigEntity config, OrderEntity order)
|
||||
{
|
||||
var status = new OrderPullStatusEntity
|
||||
|
||||
@ -254,34 +254,11 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
{
|
||||
using var tran = TransactionHelper.GetReadCommitted();
|
||||
|
||||
// 注意:UpdateAsync(entity, cols) 的 cols 是 IgnoreColumns;
|
||||
// 指定要更新的列必须用 UpdateColumnAsync。
|
||||
await UpdateColumnAsync(order, x => new
|
||||
// 更新订单主表
|
||||
await UpdateAsync(order, x => new
|
||||
{
|
||||
x.Customer,
|
||||
x.AppKey,
|
||||
x.TrackNo,
|
||||
x.ThirdPartyOrderNumber,
|
||||
x.Channel,
|
||||
x.ProductCode,
|
||||
x.ServiceProviderCode,
|
||||
x.ArrivalCountry,
|
||||
x.ArrivalProvince,
|
||||
x.ArrivalPostCode,
|
||||
x.ArrivalCity,
|
||||
x.ArrivalEmail,
|
||||
x.LeaveCountry,
|
||||
x.LeaveCity,
|
||||
x.IsTransit,
|
||||
x.IsCompleted,
|
||||
x.LatestTrackStatus,
|
||||
x.LatestTrackContent,
|
||||
x.LatestTrackEnContent,
|
||||
x.LatestTrackTime,
|
||||
x.LatestTrackTimeZone,
|
||||
x.LatestTrackPlace,
|
||||
x.EstimatedDeliveryDate,
|
||||
x.DestinationTimeZone,
|
||||
});
|
||||
|
||||
// 更新订单拉取状态
|
||||
@ -303,33 +280,11 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
|
||||
try
|
||||
{
|
||||
// 更新订单主表(与 UpdateOrderAsync 字段对齐)
|
||||
// 更新订单主表
|
||||
await UpdateRangeAsync(orders, x => new
|
||||
{
|
||||
x.Customer,
|
||||
x.AppKey,
|
||||
x.TrackNo,
|
||||
x.ThirdPartyOrderNumber,
|
||||
x.Channel,
|
||||
x.ProductCode,
|
||||
x.ServiceProviderCode,
|
||||
x.ArrivalCountry,
|
||||
x.ArrivalProvince,
|
||||
x.ArrivalPostCode,
|
||||
x.ArrivalCity,
|
||||
x.ArrivalEmail,
|
||||
x.LeaveCountry,
|
||||
x.LeaveCity,
|
||||
x.IsTransit,
|
||||
x.IsCompleted,
|
||||
x.LatestTrackStatus,
|
||||
x.LatestTrackContent,
|
||||
x.LatestTrackEnContent,
|
||||
x.LatestTrackTime,
|
||||
x.LatestTrackTimeZone,
|
||||
x.LatestTrackPlace,
|
||||
x.EstimatedDeliveryDate,
|
||||
x.DestinationTimeZone,
|
||||
x.AppKey
|
||||
});
|
||||
|
||||
var orderIds = orders.Select(x => x.Id).ToHashSet();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user