Merge remote-tracking branch 'prod/test' into test
All checks were successful
Build and Deploy / deploy (push) Successful in 1m1s

This commit is contained in:
xiaolipro 2026-10-08 15:38:50 +08:00
commit 4cae065e17
11 changed files with 80 additions and 17 deletions

View File

@ -0,0 +1,6 @@
-- 轨迹拉取配置增加订单类型(小包/大包/主单),用于同一应用+服务商下按订单类型区分配置
-- 库:TrackCenter(t_track_pull_config)
-- MySQL;若 OrderType 列已存在可跳过
ALTER TABLE t_track_pull_config
ADD COLUMN OrderType INT NOT NULL DEFAULT 1 COMMENT '订单类型(TrackOrderType:1小包 2大包 4主单)' AFTER ServiceProviderCode;

View File

@ -80,6 +80,11 @@ public class Consignee
public class UpsertBigBagInput public class UpsertBigBagInput
{ {
/// <summary>
/// 服务商code
/// </summary>
public string ApiCode { get; set; }
/// <summary> /// <summary>
/// 客户名称,或者code,必填 /// 客户名称,或者code,必填
/// </summary> /// </summary>
@ -108,7 +113,7 @@ public class UpsertBigBagInput
public string Product { get; set; } public string Product { get; set; }
/// <summary> /// <summary>
/// 产品名称,或者code /// 目的国家二字码
/// </summary> /// </summary>
public string Country { get; set; } public string Country { get; set; }
} }

View File

@ -81,7 +81,7 @@ public class TrackRefreshEventHandler(
// 客户A 渠道B 产品A // 客户A 渠道B 产品A
var config = await trackPullCacheService.GetPullParamsWithContentAsync(attach.AppKey, var config = await trackPullCacheService.GetPullParamsWithContentAsync(attach.AppKey,
attach.ServiceProviderCode); attach.ServiceProviderCode, attach.OrderType);
if (config is null) if (config is null)
{ {
logger.LogWarning("请求id: {@RequestId},轨迹消费失败,找不到拉取配置:{@Attach}", attach.ToJson(), @event.RequestId); logger.LogWarning("请求id: {@RequestId},轨迹消费失败,找不到拉取配置:{@Attach}", attach.ToJson(), @event.RequestId);

View File

@ -179,7 +179,8 @@ public partial class OrderService
var config = await _trackPullConfigRepository var config = await _trackPullConfigRepository
.FirstOrDefaultAsync(x => x.AppKey == AppKey .FirstOrDefaultAsync(x => x.AppKey == AppKey
&& x.ServiceProviderCode == input.ApiCode); && x.ServiceProviderCode == input.ApiCode
&& x.OrderType == TrackOrderType.小包);
if (config == null) if (config == null)
{ {
@ -192,11 +193,12 @@ public partial class OrderService
return order; return order;
} }
private Task<OrderEntity> BuiltOrder(UpsertBigBagInput input) private async Task<OrderEntity> BuiltOrder(UpsertBigBagInput input)
{ {
var order = new OrderEntity var order = new OrderEntity
{ {
AppKey = AppKey!, AppKey = AppKey!,
ServiceProviderCode = input.ApiCode,
OrderType = TrackOrderType.大包, OrderType = TrackOrderType.大包,
OrderNo = input.BagNo, OrderNo = input.BagNo,
ThirdPartyOrderNumber = input.OtherNo, ThirdPartyOrderNumber = input.OtherNo,
@ -206,8 +208,25 @@ public partial class OrderService
ArrivalCountry = input.Country ArrivalCountry = input.Country
}; };
// tips: 2025-11-29 zzh 大包没有轨迹拉取能力 if (string.IsNullOrWhiteSpace(input.ApiCode))
return Task.FromResult(order); {
// 未传 apiCode 时保持兼容:不挂拉取配置
return order;
}
var config = await _trackPullConfigRepository
.FirstOrDefaultAsync(x => x.AppKey == AppKey
&& x.ServiceProviderCode == input.ApiCode
&& x.OrderType == TrackOrderType.大包);
if (config == null)
{
throw ProviderServiceActionResult.Exception("创建/更新失败",
"没有适用的大包拉取配置,请先配置轨迹拉取,否则无法拉取轨迹");
}
order.OrderPullStatus = [CreateOrderPullStatus(config, order)];
return order;
} }
private async Task<OrderEntity> BuiltOrder(UpsertMasterOrderInput input) private async Task<OrderEntity> BuiltOrder(UpsertMasterOrderInput input)
@ -227,7 +246,8 @@ public partial class OrderService
var config = await _trackPullConfigRepository var config = await _trackPullConfigRepository
.FirstOrDefaultAsync(x => x.AppKey == AppKey .FirstOrDefaultAsync(x => x.AppKey == AppKey
&& x.ServiceProviderCode == input.ApiCode); && x.ServiceProviderCode == input.ApiCode
&& x.OrderType == TrackOrderType.小包);
if (config == null) if (config == null)
{ {

View File

@ -20,12 +20,12 @@ public class TrackPullCacheService : ITransientDependency
$"{GlobalConst.TrackPullKeyPrefix}:{config.AppKey}:{config.ServiceProviderCode}:{config.Customer}"; $"{GlobalConst.TrackPullKeyPrefix}:{config.AppKey}:{config.ServiceProviderCode}:{config.Customer}";
public async Task<TrackPullParamsWithContentDto?> GetPullParamsWithContentAsync(string appKey, public async Task<TrackPullParamsWithContentDto?> GetPullParamsWithContentAsync(string appKey,
string serviceProviderCode) string serviceProviderCode, TrackOrderType orderType)
{ {
var data = await RedisHelper.Client.GetAsync<TrackPullParamsWithContentDto>(TrackPullContentKey( var data = await RedisHelper.Client.GetAsync<TrackPullParamsWithContentDto>(TrackPullContentKey(
appKey, serviceProviderCode)); appKey, serviceProviderCode, orderType));
var pullId = await _trackPullConfigRepository.FindIdAsync(appKey, serviceProviderCode); var pullId = await _trackPullConfigRepository.FindIdAsync(appKey, serviceProviderCode, orderType);
data ??= await SetPullConfigAsync(pullId); data ??= await SetPullConfigAsync(pullId);
return data; return data;
@ -53,12 +53,13 @@ public class TrackPullCacheService : ITransientDependency
trackPullContentList) trackPullContentList)
}; };
var key = TrackPullContentKey(trackPullConfigDetail.AppKey, trackPullConfigDetail.ServiceProviderCode); var key = TrackPullContentKey(trackPullConfigDetail.AppKey, trackPullConfigDetail.ServiceProviderCode,
trackPullConfigDetail.OrderType);
await RedisHelper.Client.SetAsync(key, data, TimeSpan.FromHours(24)); await RedisHelper.Client.SetAsync(key, data, TimeSpan.FromHours(24));
return data; return data;
} }
public static string TrackPullContentKey(string appKey, string serviceProviderCode) => public static string TrackPullContentKey(string appKey, string serviceProviderCode, TrackOrderType orderType) =>
$"{GlobalConst.TrackPullContentKeyPrefix}:{appKey}:{serviceProviderCode}"; $"{GlobalConst.TrackPullContentKeyPrefix}:{appKey}:{serviceProviderCode}:{(int)orderType}";
} }

View File

@ -83,9 +83,13 @@ public class TrackPullService(
if (input.Options != OptionTypeNoNull.删除) if (input.Options != OptionTypeNoNull.删除)
{ {
if (!Enum.IsDefined(typeof(TrackOrderType), input.OrderType))
throw new BusinessException("请选择订单类型");
Expression<Func<TrackPullConfigEntity, bool>> isAnyExp = x => Expression<Func<TrackPullConfigEntity, bool>> isAnyExp = x =>
x.AppKey == input.AppKey && x.AppKey == input.AppKey &&
x.ServiceProviderCode == input.ServiceProviderCode; x.ServiceProviderCode == input.ServiceProviderCode &&
x.OrderType == input.OrderType;
if (input.Options == OptionTypeNoNull.修改) isAnyExp = isAnyExp.And(x => x.Id != input.Id); if (input.Options == OptionTypeNoNull.修改) isAnyExp = isAnyExp.And(x => x.Id != input.Id);
if (await trackPullConfigRepository.IsAnyAsync(isAnyExp)) if (await trackPullConfigRepository.IsAnyAsync(isAnyExp))

View File

@ -75,5 +75,5 @@ public interface ITrackPullConfigRepository : IBasicRepository<TrackPullConfigEn
Task<bool> IsPriorityAnyAsync(Expression<Func<TrackPullPriorityEntity, bool>> whereExpression); Task<bool> IsPriorityAnyAsync(Expression<Func<TrackPullPriorityEntity, bool>> whereExpression);
Task<int> FindIdAsync(string appKey, string serviceProviderCode); Task<int> FindIdAsync(string appKey, string serviceProviderCode, TrackOrderType orderType);
} }

View File

@ -20,6 +20,12 @@ public class TrackPullConfigEntity : FullAuditedAggregateRoot<int, int>
[SugarColumn(ColumnName = "ServiceProviderCode")] [SugarColumn(ColumnName = "ServiceProviderCode")]
public string ServiceProviderCode { get; set; } public string ServiceProviderCode { get; set; }
/// <summary>
/// 订单类型(主数据枚举TrackOrderType)
/// </summary>
[SugarColumn(ColumnName = "OrderType")]
public TrackOrderType OrderType { get; set; }
/// <summary> /// <summary>
/// 开始轨迹code /// 开始轨迹code
/// </summary> /// </summary>

View File

@ -26,6 +26,11 @@ public class GetTrackPullConfigDetailOutputVO
/// </summary> /// </summary>
public string AppKey { get; set; } public string AppKey { get; set; }
/// <summary>
/// 订单类型(主数据枚举TrackOrderType)
/// </summary>
public TrackOrderType OrderType { get; set; }
/// <summary> /// <summary>
/// 轨迹扩展信息参数名集合(逗号分割) /// 轨迹扩展信息参数名集合(逗号分割)
/// </summary> /// </summary>

View File

@ -1,3 +1,5 @@
using TrackCenter.Domain.Enums;
namespace TrackCenter.Domain.Dtos.TrackPull; namespace TrackCenter.Domain.Dtos.TrackPull;
public class GetTrackPullConfigPageOutputVO public class GetTrackPullConfigPageOutputVO
@ -14,6 +16,11 @@ public class GetTrackPullConfigPageOutputVO
/// </summary> /// </summary>
public string ServiceProvider { get; set; } public string ServiceProvider { get; set; }
/// <summary>
/// 服务商code
/// </summary>
public string ServiceProviderCode { get; set; }
/// <summary> /// <summary>
/// 应用 /// 应用
/// </summary> /// </summary>
@ -23,4 +30,9 @@ public class GetTrackPullConfigPageOutputVO
/// 应用 /// 应用
/// </summary> /// </summary>
public string AppKey { get; set; } public string AppKey { get; set; }
/// <summary>
/// 订单类型(主数据枚举TrackOrderType)
/// </summary>
public TrackOrderType OrderType { get; set; }
} }

View File

@ -5,6 +5,7 @@ using TrackCenter.Domain.Aggregates.TrackPullAggregate;
using TrackCenter.Domain.Aggregates.TrackStatusAggregate; using TrackCenter.Domain.Aggregates.TrackStatusAggregate;
using TrackCenter.Domain.Dtos.Common; using TrackCenter.Domain.Dtos.Common;
using TrackCenter.Domain.Dtos.TrackPull; using TrackCenter.Domain.Dtos.TrackPull;
using TrackCenter.Domain.Enums;
using TrackCenter.Domain.VEntities; using TrackCenter.Domain.VEntities;
namespace TrackCenter.Repository.Repositories; namespace TrackCenter.Repository.Repositories;
@ -27,6 +28,8 @@ public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>,
AppKey = system.AppKey, AppKey = system.AppKey,
App = system.Name, App = system.Name,
ServiceProvider = service.Name, ServiceProvider = service.Name,
ServiceProviderCode = service.Code,
OrderType = trackPull.OrderType,
CreateTime = trackPull.CreateTime CreateTime = trackPull.CreateTime
}) })
.ToPagedListAsync(input.PageIndex, input.PageSize); .ToPagedListAsync(input.PageIndex, input.PageSize);
@ -216,11 +219,12 @@ public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>,
return await Context.Queryable<TrackPullPriorityEntity>().Where(whereExpression).AnyAsync(); return await Context.Queryable<TrackPullPriorityEntity>().Where(whereExpression).AnyAsync();
} }
public async Task<int> FindIdAsync(string appKey, string serviceProviderCode) public async Task<int> FindIdAsync(string appKey, string serviceProviderCode, TrackOrderType orderType)
{ {
return await AsQueryable() return await AsQueryable()
.Where(trackPull => trackPull.AppKey == appKey .Where(trackPull => trackPull.AppKey == appKey
&& trackPull.ServiceProviderCode == serviceProviderCode) && trackPull.ServiceProviderCode == serviceProviderCode
&& trackPull.OrderType == orderType)
.Select(trackPull => trackPull.Id) .Select(trackPull => trackPull.Id)
.FirstAsync(); .FirstAsync();
} }