diff --git a/src/TrackCenter.Application/AutoMapper/TrackPullAutoMapperProfile.cs b/src/TrackCenter.Application/AutoMapper/TrackPullAutoMapperProfile.cs index cd016f69..274531d5 100644 --- a/src/TrackCenter.Application/AutoMapper/TrackPullAutoMapperProfile.cs +++ b/src/TrackCenter.Application/AutoMapper/TrackPullAutoMapperProfile.cs @@ -24,6 +24,8 @@ public class TrackPullAutoMapperProfile : Profile CreateMap(MemberList.None); + CreateMap(MemberList.None); + CreateMap(MemberList.None); } } diff --git a/src/TrackCenter.Application/Dtos/TrackPull/EditTrackPullConfigInput.cs b/src/TrackCenter.Application/Dtos/TrackPull/EditTrackPullConfigInput.cs index 7049cb73..9cd953ae 100644 --- a/src/TrackCenter.Application/Dtos/TrackPull/EditTrackPullConfigInput.cs +++ b/src/TrackCenter.Application/Dtos/TrackPull/EditTrackPullConfigInput.cs @@ -1,3 +1,5 @@ +using TrackCenter.Domain.Aggregates.OrderAggregate; + namespace TrackCenter.Application.Dtos.TrackPull; public class EditTrackPullConfigInput @@ -12,17 +14,12 @@ public class EditTrackPullConfigInput /// /// 应用 /// - public string? AppKey { get; set; } + public string AppKey { get; set; } /// - /// 服务商id + /// 服务商code /// - public int? ServiceProviderId { get; set; } - - /// - /// 服务商拉取频率(分钟) - /// - public int PullInterval { get; set; } + public string ServiceProviderCode { get; set; } /// /// 解析方式,1取接口通返参映射后的,2取服务商原返参 @@ -78,4 +75,34 @@ public class EditTrackPullConfigInput /// 轨迹时区参数名 /// public string? TrackTimeZoneName { get; set; } + + /// + /// 客户 + /// + public string? Customer { get; set; } + + /// + /// 订单类型 + /// + public TrackOrderType OrderType { get; set; } + + /// + /// 开始轨迹code + /// + public string? StartTrackCode { get; set; } + + /// + /// 结束轨迹code + /// + public string? EndTrackCode { get; set; } + + /// + /// 开始前的静默(小时) + /// + public int SilenceBeforeStart { get; set; } + + /// + /// 结束后的静默(小时) + /// + public int SilenceAfterEnd { get; set; } } diff --git a/src/TrackCenter.Application/Dtos/TrackPull/EditTrackPullPriorityInput.cs b/src/TrackCenter.Application/Dtos/TrackPull/EditTrackPullPriorityInput.cs new file mode 100644 index 00000000..38852c4e --- /dev/null +++ b/src/TrackCenter.Application/Dtos/TrackPull/EditTrackPullPriorityInput.cs @@ -0,0 +1,38 @@ +using TrackCenter.Domain.Aggregates.TrackPullAggregate; + +namespace TrackCenter.Application.Dtos.TrackPull; + +public class EditTrackPullPriorityInput +{ + /// + /// 操作类型 + /// + public OptionTypeNoNull Options { get; set; } + + public int? Id { get; set; } + + /// + /// 轨迹拉取配置id + /// + public int? TrackPullConfigId { get; set; } + + /// + /// 客户 + /// + public string? Customer { get; set; } + + /// + /// 订单类型 + /// + public TrackOrderType? OrderType { get; set; } + + /// + /// 优先级 + /// + public string? Priority { get; set; } + + /// + /// 服务商拉取频率(分钟) + /// + public int? PullInterval { get; set; } +} diff --git a/src/TrackCenter.Application/Dtos/TrackPull/TrackPullParamConfigDto.cs b/src/TrackCenter.Application/Dtos/TrackPull/TrackPullParamConfigDto.cs index b79437f9..abf95d9e 100644 --- a/src/TrackCenter.Application/Dtos/TrackPull/TrackPullParamConfigDto.cs +++ b/src/TrackCenter.Application/Dtos/TrackPull/TrackPullParamConfigDto.cs @@ -1,3 +1,5 @@ +using TrackCenter.Domain.Aggregates.OrderAggregate; + namespace TrackCenter.Application.Dtos.TrackPull; public class TrackPullParamConfigDto @@ -66,4 +68,24 @@ public class TrackPullParamConfigDto /// 轨迹内容代码 /// public string? TrackContentCode { get; set; } + + /// + /// 开始轨迹code + /// + public string StartTrackCode { get; set; } = null!; + + /// + /// 结束轨迹code + /// + public string EndTrackCode { get; set; } = null!; + + /// + /// 开始前的静默(小时) + /// + public int SilenceBeforeStart { get; set; } + + /// + /// 结束后的静默(小时) + /// + public int SilenceAfterEnd { get; set; } } diff --git a/src/TrackCenter.Application/Dtos/TrackPull/TrackPullParamWithContentConfigDto.cs b/src/TrackCenter.Application/Dtos/TrackPull/TrackPullParamWithContentConfigDto.cs index 1c292901..d67706cd 100644 --- a/src/TrackCenter.Application/Dtos/TrackPull/TrackPullParamWithContentConfigDto.cs +++ b/src/TrackCenter.Application/Dtos/TrackPull/TrackPullParamWithContentConfigDto.cs @@ -5,4 +5,29 @@ public class TrackPullParamsWithContentDto public TrackPullParamConfigDto ParamConfig { get; set; } = new(); public List ContentConfigs { get; set; } = new(); + + //public List Priorities { get; set; } = new(); +} + +public class TrackPullPriorityDto +{ + /// + /// 客户 + /// + public string? Customer { get; set; } + + /// + /// 渠道 + /// + public string? Channel { get; set; } + + /// + /// 产品 + /// + public string? Product { get; set; } + + /// + /// 订单类型 + /// + public TrackOrderType OrderType { get; set; } } diff --git a/src/TrackCenter.Application/Queries/ProvideQueries.cs b/src/TrackCenter.Application/Queries/ProvideQueries.cs index d1fced33..3a586692 100644 --- a/src/TrackCenter.Application/Queries/ProvideQueries.cs +++ b/src/TrackCenter.Application/Queries/ProvideQueries.cs @@ -229,18 +229,4 @@ public class ProvideQueries : SqlSugarRootlessRepository, content.IsToMq = content.TrackFlags.Any(x => x.IsToMq); } } - - public async Task> GetAllPullConfigsAsync() - { - return await Context.Queryable() - .LeftJoin((a, b) => a.ServiceProviderId == b.Id) - .Select((a, b) => new TrackPullConfigVo - { - PullInterval = a.PullInterval, - ServiceProviderId = a.ServiceProviderId, - ServiceProviderCode = b.Code, - AppKey = a.AppKey - }) - .ToListAsync(); - } } diff --git a/src/TrackCenter.Application/Rabbit/TrackRefreshEventHandler.cs b/src/TrackCenter.Application/Rabbit/TrackRefreshEventHandler.cs index 2cc5510b..4509c758 100644 --- a/src/TrackCenter.Application/Rabbit/TrackRefreshEventHandler.cs +++ b/src/TrackCenter.Application/Rabbit/TrackRefreshEventHandler.cs @@ -80,9 +80,18 @@ public class TrackRefreshEventHandler : ITransientDependency, IRabbitHandler return; } + // 最优先级,最匹配的 权重 sort + + // 客户、渠道、产品 + // */*/* 全部 + // 客户A/渠道A/产品A + // 客户A + + // 客户A 渠道B 产品A + var config = await _trackPullCacheService.GetPullParamsWithContentAsync(attach.AppKey, attach.ServiceProviderCode); - if (config == null) + if (config is null) { _logger.LogWarning("请求id: {@RequestId},轨迹消费失败,找不到拉取配置:{@Attach}", attach.ToJson(), @event.RequestId); return; diff --git a/src/TrackCenter.Application/Services/ProvideServices/OrderService.cs b/src/TrackCenter.Application/Services/ProvideServices/OrderService.cs index 7e0cf29d..c16c796b 100644 --- a/src/TrackCenter.Application/Services/ProvideServices/OrderService.cs +++ b/src/TrackCenter.Application/Services/ProvideServices/OrderService.cs @@ -36,7 +36,7 @@ public partial class OrderService : ApplicationServiceBase } /// - /// 新增、更新订单(存在就更新) + /// 新增、更新小包(存在就更新) /// /// /// diff --git a/src/TrackCenter.Application/Services/ProvideServices/OrderServiceV2.cs b/src/TrackCenter.Application/Services/ProvideServices/OrderServiceV2.cs new file mode 100644 index 00000000..d4d16c8e --- /dev/null +++ b/src/TrackCenter.Application/Services/ProvideServices/OrderServiceV2.cs @@ -0,0 +1,275 @@ +using System.ComponentModel.DataAnnotations; +using InterfaceForward.Domain.Shared.Helpers; +using TrackCenter.Domain.Aggregates.OrderAggregate; +using TrackCenter.Domain.Aggregates.TrackPullAggregate; +using TrackCenter.Repository.Aggregates.OrderAggregate; + +namespace TrackCenter.Application.Services.ProvideServices; + +public class OrderServiceV2( + IOrderRepository orderRepository, + IOrderOperationRecordEsRepository orderOperationRecordEsRepository, + ITrackPullConfigRepository trackPullConfigRepository) + : ApplicationServiceBase +{ + /// + /// 新增、更新小包(存在就更新) + /// + /// + /// + [HttpPost("OrderV2/UpsertSmallBag")] + public async Task UpsertAsync(UpsertSmallBagInput input) + { + // 校验订单是否已存在,存在则更新 + var order = await orderRepository.GetFirstAsync(x => + x.AppKey == input.ApiCode && x.OrderType == TrackOrderType.小包 && x.OrderNo == input.OrderNo); + // 订单已存在则视为更新 + if (order != null) + { + order = await BuiltOrder(input); + + await orderRepository.UpdateOrderAsync(order); + + var index = new OrderOperationRecordIndex + { + OrderId = order.Id, + OrderNo = input.OrderNo, + OptionType = OrderOperationType.修改订单.ToString(), + Content = input.ToJson(), + CreateUserId = CurrentUserId, + CreateUserName = CurrentUser.UserName ?? string.Empty, + }; + + _ = orderOperationRecordEsRepository.AddAsync(index); + + return new IdBaseDto + { + Id = order.Id + }; + } + + order = await BuiltOrder(input); + var orderId = await orderRepository.CreateOrderAsync(order); + + // 写入操作日志 + var indexForAdd = new OrderOperationRecordIndex + { + OrderId = orderId, + OrderNo = input.OrderNo, + OptionType = nameof(OrderOperationType.创建订单), + Content = input.ToJson(), + CreateUserId = CurrentUserId, + CreateUserName = CurrentUser.UserName ?? string.Empty, + CreateTime = DateTime.Now + }; + _ = orderOperationRecordEsRepository.AddAsync(indexForAdd); + + + return new IdBaseDto + { + Id = orderId + }; + } + + private async Task BuiltOrder(UpsertSmallBagInput input) + { + var order = new OrderEntity + { + AppKey = input.ApiCode, + OrderType = TrackOrderType.小包, + OrderNo = input.OrderNo, + TrackNo = input.TrackNo, + ThirdPartyOrderNumber = input.OtherNo, + Customer = input.Client, + Channel = input.Channel, + ProductCode = input.Product, + + ArrivalCountry = input.Consignee.CountryCode, + ArrivalProvince = input.Consignee.Province, + ArrivalPostCode = input.Consignee.Postcode, + ArrivalCity = input.Consignee.City, + ArrivalEmail = input.Consignee.Email, + }; + + var config = await trackPullConfigRepository + .GetListAsync(x => x.AppKey == input.ApiCode + && x.ServiceProviderCode == input.ApiCode && x.OrderType == TrackOrderType.小包); + + order.OrderPullStatus = BuiltOrderPullStatus(config, order); + + return order; + } + + private static List BuiltOrderPullStatus( + List configs, + OrderEntity order) + { + if (configs.IsNullOrEmpty()) return []; + + TrackPullConfigEntity? selected = null; + var bestScore = -1; + + foreach (var config in configs) + { + if (!IsConfigApplicable(config, order)) + { + continue; + } + + var score = CalculateMatchScore(config, order); + if (score > bestScore) + { + bestScore = score; + selected = config; + } + } + + if (selected == null) throw new BusinessException(message: "没有一个拉取配置可以适用,请配置,否则无法拉取轨迹"); + + return [CreateOrderPullStatus(selected, order)]; + } + + private static bool IsConfigApplicable(TrackPullConfigEntity config, OrderEntity order) + { + return IsFieldApplicable(order.Customer, config.Customer) && + IsFieldApplicable(order.Channel, config.Channel) && + IsFieldApplicable(order.ProductCode, config.Product); + } + + private static bool IsFieldApplicable(string? orderValue, string? configValue) + { + if (string.IsNullOrWhiteSpace(configValue)) + { + return true; + } + + return string.Equals(configValue, orderValue, StringComparison.OrdinalIgnoreCase); + } + + private static int CalculateMatchScore(TrackPullConfigEntity config, OrderEntity order) + { + var score = 0; + + if (IsPreciseMatch(order.Customer, config.Customer)) + { + score++; + } + + if (IsPreciseMatch(order.Channel, config.Channel)) + { + score++; + } + + if (IsPreciseMatch(order.ProductCode, config.Product)) + { + score++; + } + + return score; + } + + private static bool IsPreciseMatch(string? orderValue, string? configValue) + { + return !string.IsNullOrWhiteSpace(configValue) && + string.Equals(configValue, orderValue, StringComparison.OrdinalIgnoreCase); + } + + private static OrderPullStatusEntity CreateOrderPullStatus(TrackPullConfigEntity config, OrderEntity order) + { + var status = new OrderPullStatusEntity + { + ServiceProviderCode = config.ServiceProviderCode, + OrderNo = order.OrderNo, + PullStatus = TrackPullStatus.Init, + StartTrackCode = config.StartTrackCode, + EndTrackCode = config.EndTrackCode, + SilenceBeforeStart = config.SilenceBeforeStart, + SilenceAfterEnd = config.SilenceAfterEnd, + StartTime = GlobalConst.MaxDateTime, + EndTime = GlobalConst.MaxDateTime + }; + + if (string.IsNullOrWhiteSpace(config.StartTrackCode)) + { + status.PullStatus = TrackPullStatus.SilenceBeforeStart; + status.StartTime = DateTime.Now.AddHours(config.SilenceBeforeStart); + } + + return status; + } +} + +public class UpsertSmallBagInput +{ + /// + /// 客户名称,或者code,必填 + /// + [Required] + public string Client { get; set; } + + /// + /// 客户单号,必填 + /// + [Required] + public string OrderNo { get; set; } + + /// + /// 尾程单号,必填 + /// + [Required] + public string TrackNo { get; set; } + + /// + /// 其他单号 + /// + public string OtherNo { get; set; } + + /// + /// 渠道名称,或者code + /// + public string Channel { get; set; } + + /// + /// 产品名称,或者code + /// + public string Product { get; set; } + + /// + /// 服务商code + /// + public string ApiCode { get; set; } + + /// + /// 收件人信息 + /// + public Consignee Consignee { get; set; } +} + +public class Consignee +{ + /// + /// 收件人国家,必填 + /// + [Required] + public string CountryCode { get; set; } + + /// + /// 收件人州省 + /// + public string Province { get; set; } + + /// + /// 收件人邮编 + /// + public string Postcode { get; set; } + + /// + /// 收件人城市 + /// + public string City { get; set; } + + /// + /// 收件人邮箱 + /// + public string Email { get; set; } +} diff --git a/src/TrackCenter.Application/Services/TimerTaskss/TrackPullTask.cs b/src/TrackCenter.Application/Services/TimerTaskss/TrackPullTask.cs index d0d184b4..34bd76e3 100644 --- a/src/TrackCenter.Application/Services/TimerTaskss/TrackPullTask.cs +++ b/src/TrackCenter.Application/Services/TimerTaskss/TrackPullTask.cs @@ -7,6 +7,7 @@ using TrackCenter.Application.Options; using TrackCenter.Application.Queries; using TrackCenter.Application.Services.TrackPull; using TrackCenter.Application.Track2InterfaceRelay; +using TrackCenter.Domain.Aggregates.TrackPullAggregate; using TrackCenter.Domain.Dtos.TrackPull; namespace TrackCenter.Application.Services.TimerTaskss; @@ -34,8 +35,14 @@ public class TrackPullTask : ApplicationServiceBase, ISingletonDependency { using var serviceScope = _serviceScopeFactory.CreateScope(); - var provideQueries = serviceScope.ServiceProvider.GetRequiredService(); - var configs = await provideQueries.GetAllPullConfigsAsync(); + var trackPullConfigRepository = serviceScope.ServiceProvider.GetRequiredService(); + var configs = await trackPullConfigRepository.GetListAsync(x => true, x => new TrackPullConfigVo + { + // todo:去读priority表,按照客户、订单类型、优先级拉 + PullInterval = 60, + ServiceProviderCode = x.ServiceProviderCode, + AppKey = x.AppKey + }); foreach (var config in configs) { diff --git a/src/TrackCenter.Application/Services/TrackPull/TrackPullService.cs b/src/TrackCenter.Application/Services/TrackPull/TrackPullService.cs index 0a649eca..38655b00 100644 --- a/src/TrackCenter.Application/Services/TrackPull/TrackPullService.cs +++ b/src/TrackCenter.Application/Services/TrackPull/TrackPullService.cs @@ -8,7 +8,6 @@ using TrackCenter.Domain.Dtos.TrackPull; using SqlSugar; using TrackCenter.Application.Helpers; using TrackCenter.Application.Options; -using TrackCenter.Repository; namespace TrackCenter.Application.Services.TrackPull; @@ -17,21 +16,12 @@ namespace TrackCenter.Application.Services.TrackPull; /// [ApiExplorerSettings(GroupName = "轨迹拉取")] [Route("/Track/PullConfig")] -public class TrackPullService : ApplicationServiceBase +public class TrackPullService( + ITrackPullConfigRepository trackPullConfigRepository, + TrackPullCacheService trackPullCacheService, + IOptionsMonitor options) + : ApplicationServiceBase { - private readonly IOptionsMonitor _options; - private readonly TrackPullCacheService _trackPullCacheService; - private readonly ITrackPullConfigRepository _trackPullConfigRepository; - - public TrackPullService( - ITrackPullConfigRepository trackPullConfigRepository, - TrackPullCacheService trackPullCacheService, IOptionsMonitor options) - { - _trackPullConfigRepository = trackPullConfigRepository; - _trackPullCacheService = trackPullCacheService; - _options = options; - } - /// /// 轨迹拉取配置列表 /// @@ -40,7 +30,7 @@ public class TrackPullService : ApplicationServiceBase [HttpPost("GetPage")] public async Task> GetPageAsync([FromBody] KeywordsInputVO input) { - return await _trackPullConfigRepository.GetPageAsync(input); + return await trackPullConfigRepository.GetPageAsync(input); } /// @@ -52,7 +42,7 @@ public class TrackPullService : ApplicationServiceBase public async Task> GetContentPageAsync( [FromBody] GetTrackPullContentPageInputVO input) { - return await _trackPullConfigRepository.GetContentPageAsync(input); + return await trackPullConfigRepository.GetContentPageAsync(input); } /// @@ -63,7 +53,7 @@ public class TrackPullService : ApplicationServiceBase [HttpGet("GetDetail")] public async Task GetDetailAsync(int id) { - var res = await _trackPullConfigRepository.GetDetailAsync(id); + var res = await trackPullConfigRepository.GetDetailAsync(id); if (res == null) { @@ -81,7 +71,7 @@ public class TrackPullService : ApplicationServiceBase [HttpGet("GetContentDetail")] public async Task GetContentDetailAsync(int id) { - return await _trackPullConfigRepository.GetContentDetailAsync(id); + return await trackPullConfigRepository.GetContentDetailAsync(id); } /// @@ -92,15 +82,17 @@ public class TrackPullService : ApplicationServiceBase [HttpPost("Edit")] public async Task EditAsync([FromBody] EditTrackPullConfigInput input) { - if (input.PullInterval < 60) input.PullInterval = 60; + //if (input.PullInterval < 60) input.PullInterval = 60; if (input.Options != OptionTypeNoNull.删除) { Expression> isAnyExp = x => - x.AppKey == input.AppKey && x.ServiceProviderId == input.ServiceProviderId; + x.AppKey == input.AppKey && + x.ServiceProviderCode == input.ServiceProviderCode && + x.OrderType == input.OrderType; if (input.Options == OptionTypeNoNull.修改) isAnyExp = isAnyExp.And(x => x.Id != input.Id); - if (await _trackPullConfigRepository.IsAnyAsync(isAnyExp)) + if (await trackPullConfigRepository.IsAnyAsync(isAnyExp)) throw new BusinessException("配置已经存在"); } @@ -112,7 +104,7 @@ public class TrackPullService : ApplicationServiceBase if (input.ParseMethod == (int) ParseMethod.InterfaceRelay) { - var paramsConfig = _options.CurrentValue; + var paramsConfig = options.CurrentValue; if (paramsConfig == null) { throw new BusinessException(message: "未找到接口通参数配置,联系管理员添加"); @@ -130,21 +122,21 @@ public class TrackPullService : ApplicationServiceBase trackPullEntity.TrackTimeZoneName = paramsConfig.TrackTimeZoneName; } - var id = await _trackPullConfigRepository.InsertReturnIdentityAsync(trackPullEntity); + var id = await trackPullConfigRepository.InsertReturnIdentityAsync(trackPullEntity); - await _trackPullCacheService.SetPullConfigAsync(id); + await trackPullCacheService.SetPullConfigAsync(id); } break; case OptionTypeNoNull.修改: { - var oldTrackPullEntity = await _trackPullConfigRepository.GetFirstAsync(x => x.Id == input.Id) ?? + var oldTrackPullEntity = await trackPullConfigRepository.GetFirstAsync(x => x.Id == input.Id) ?? throw new BusinessException("配置不存在"); ObjectMapper.Map(input, oldTrackPullEntity); if (input.ParseMethod == (int) ParseMethod.InterfaceRelay) { - var paramsConfig = _options.CurrentValue; + var paramsConfig = options.CurrentValue; if (paramsConfig == null) { throw new BusinessException(message: "未找到接口通参数配置,联系管理员添加"); @@ -162,20 +154,20 @@ public class TrackPullService : ApplicationServiceBase oldTrackPullEntity.TrackTimeZoneName = paramsConfig.TrackTimeZoneName; } - await _trackPullConfigRepository.UpdateAsync(oldTrackPullEntity); + await trackPullConfigRepository.UpdateAsync(oldTrackPullEntity); - await _trackPullCacheService.SetPullConfigAsync(input.Id!.Value); + await trackPullCacheService.SetPullConfigAsync(input.Id!.Value); } break; case OptionTypeNoNull.删除: using (var ts = TransacationHelper.GetReadCommitted()) { - await _trackPullConfigRepository.SoftDeleteAsync(x => x.Id == input.Id); + await trackPullConfigRepository.SoftDeleteAsync(x => x.Id == input.Id); - await _trackPullConfigRepository.SoftDeleteContentAsync(x => x.TrackPullConfigId == input.Id); + await trackPullConfigRepository.SoftDeleteContentAsync(x => x.TrackPullConfigId == input.Id); - await _trackPullCacheService.SetPullConfigAsync(input.Id!.Value); + await trackPullCacheService.SetPullConfigAsync(input.Id!.Value); ts.Complete(); } @@ -206,7 +198,7 @@ public class TrackPullService : ApplicationServiceBase isContentAnyExp = isContentAnyExp.And(x => x.Id != input.Id); } - if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => + if (await trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentId == input.TrackContentId))) throw new BusinessException("配置已存在"); @@ -218,7 +210,7 @@ public class TrackPullService : ApplicationServiceBase trackStatusValuesExp = trackStatusValuesExp.Or(x => SqlFunc.SplitIn(x.TrackStatusValue, item)); }); - if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(trackStatusValuesExp))) + if (await trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(trackStatusValuesExp))) throw new BusinessException(message: "配置已存在"); } @@ -230,7 +222,7 @@ public class TrackPullService : ApplicationServiceBase trackKeywordExp = trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item)); }); - if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(trackKeywordExp))) + if (await trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(trackKeywordExp))) throw new BusinessException(message: "配置已存在"); } } @@ -241,8 +233,8 @@ public class TrackPullService : ApplicationServiceBase { var entity = ObjectMapper.Map(input); - await _trackPullConfigRepository.InsertContentAsync(entity); - await _trackPullCacheService.SetPullConfigAsync(input.TrackPullConfigId!.Value); + await trackPullConfigRepository.InsertContentAsync(entity); + await trackPullCacheService.SetPullConfigAsync(input.TrackPullConfigId!.Value); break; } @@ -250,13 +242,13 @@ public class TrackPullService : ApplicationServiceBase case OptionTypeNoNull.修改: { var oldTrackPullContentEntity = - await _trackPullConfigRepository.GetContentByIdAsync(input.Id!.Value) ?? + await trackPullConfigRepository.GetContentByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: "找不到数据"); ObjectMapper.Map(input, oldTrackPullContentEntity); - await _trackPullConfigRepository.UpdateContentAsync(oldTrackPullContentEntity); - await _trackPullCacheService.SetPullConfigAsync(oldTrackPullContentEntity.TrackPullConfigId); + await trackPullConfigRepository.UpdateContentAsync(oldTrackPullContentEntity); + await trackPullCacheService.SetPullConfigAsync(oldTrackPullContentEntity.TrackPullConfigId); break; } @@ -264,11 +256,100 @@ public class TrackPullService : ApplicationServiceBase case OptionTypeNoNull.删除: { var oldTrackPullContentEntity = - await _trackPullConfigRepository.GetContentByIdAsync(input.Id!.Value) ?? + await trackPullConfigRepository.GetContentByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: "找不到数据"); - await _trackPullConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id); - await _trackPullCacheService.SetPullConfigAsync(oldTrackPullContentEntity.TrackPullConfigId); + await trackPullConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id); + await trackPullCacheService.SetPullConfigAsync(oldTrackPullContentEntity.TrackPullConfigId); + + break; + } + + default: + throw new ArgumentOutOfRangeException(); + } + + return true; + } + + /// + /// 轨迹拉取优先级配置列表 + /// + /// + /// + [HttpPost("GetPriorityPage")] + public async Task> GetPriorityPageAsync( + [FromBody] GetTrackPullPriorityPageInputVO input) + { + return await trackPullConfigRepository.GetPriorityPageAsync(input); + } + + /// + /// 轨迹拉取优先级配置详情 + /// + /// + /// + [HttpGet("GetPriorityDetail")] + public async Task GetPriorityDetailAsync(int id) + { + return await trackPullConfigRepository.GetPriorityDetailAsync(id); + } + + /// + /// 轨迹拉取优先级配置编辑 + /// + /// + /// + [HttpPost("EditPriority")] + public async Task EditPriorityAsync([FromBody] EditTrackPullPriorityInput input) + { + if (input.Options != OptionTypeNoNull.删除) + { + Expression> isPriorityAnyExp = x => + x.TrackPullConfigId == input.TrackPullConfigId && + x.Customer == input.Customer && + x.OrderType == input.OrderType; + + if (input.Options == OptionTypeNoNull.修改) + { + isPriorityAnyExp = isPriorityAnyExp.And(x => x.Id != input.Id); + } + + if (await trackPullConfigRepository.IsPriorityAnyAsync(isPriorityAnyExp)) + throw new BusinessException("配置已存在"); + } + + switch (input.Options) + { + case OptionTypeNoNull.新增: + { + var entity = ObjectMapper.Map(input); + + await trackPullConfigRepository.InsertPriorityAsync(entity); + + break; + } + + case OptionTypeNoNull.修改: + { + var oldTrackPullPriorityEntity = + await trackPullConfigRepository.GetPriorityByIdAsync(input.Id!.Value) ?? + throw new BusinessException(message: "找不到数据"); + + ObjectMapper.Map(input, oldTrackPullPriorityEntity); + + await trackPullConfigRepository.UpdatePriorityAsync(oldTrackPullPriorityEntity); + + break; + } + + case OptionTypeNoNull.删除: + { + var oldTrackPullPriorityEntity = + await trackPullConfigRepository.GetPriorityByIdAsync(input.Id!.Value) ?? + throw new BusinessException(message: "找不到数据"); + + await trackPullConfigRepository.SoftDeletePriorityAsync(x => x.Id == input.Id); break; } diff --git a/src/TrackCenter.Domain/Aggregates/OrderAggregate/OrderEntity.cs b/src/TrackCenter.Domain/Aggregates/OrderAggregate/OrderEntity.cs index 4583789a..bc0dd798 100644 --- a/src/TrackCenter.Domain/Aggregates/OrderAggregate/OrderEntity.cs +++ b/src/TrackCenter.Domain/Aggregates/OrderAggregate/OrderEntity.cs @@ -21,6 +21,12 @@ public class OrderEntity : FullAuditedAggregateRoot [SugarColumn(ColumnName = "OrderNo")] public string OrderNo { get; set; } = null!; + /// + /// 尾程单号 + /// + [SugarColumn(ColumnName = "TrackNo")] + public string TrackNo { get; set; } = null!; + /// /// 订单类型(主数据枚举TrackOrderType) /// @@ -117,6 +123,12 @@ public class OrderEntity : FullAuditedAggregateRoot [SugarColumn(ColumnName = "ArrivalPort")] public string? ArrivalPort { get; set; } + /// + /// 邮箱 + /// + [SugarColumn(ColumnName = "ArrivalEmail")] + public string? ArrivalEmail { get; set; } + /// /// 起运城市 /// @@ -195,11 +207,21 @@ public class OrderEntity : FullAuditedAggregateRoot [SugarColumn(ColumnName = "ThirdPartyOrderNumber")] public string? ThirdPartyOrderNumber { get; set; } - [SugarColumn(IsIgnore = true)] - public List OrderFlights { get; set; } + /// + /// 服务渠道 + /// + [SugarColumn(ColumnName = "Channel")] + public string? Channel { get; set; } - [SugarColumn(IsIgnore = true)] - public List OrderPullStatus { get; set; } + /// + /// 服务商代码 + /// + [SugarColumn(ColumnName = "ServiceProviderCode")] + public string? ServiceProviderCode { get; set; } + + [SugarColumn(IsIgnore = true)] public List OrderFlights { get; set; } = []; + + [SugarColumn(IsIgnore = true)] public List OrderPullStatus { get; set; } = []; public void ResetTrackInfo() { diff --git a/src/TrackCenter.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs b/src/TrackCenter.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs index d0512204..22d9b044 100644 --- a/src/TrackCenter.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs +++ b/src/TrackCenter.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs @@ -41,14 +41,39 @@ public interface ITrackPullConfigRepository : IBasicRepository Task GetContentDetailAsync(int id); + /// + /// 轨迹拉取优先级配置列表 + /// + /// + /// + Task> GetPriorityPageAsync(GetTrackPullPriorityPageInputVO input); + + /// + /// 轨迹拉取优先级配置详情 + /// + /// + /// + Task GetPriorityDetailAsync(int id); + Task InsertContentAsync(TrackPullContentConfigEntity insertObj); + Task InsertPriorityAsync(TrackPullPriorityEntity insertObj); + Task SoftDeleteContentAsync(Expression> whereExpression); + Task SoftDeletePriorityAsync(Expression> whereExpression); + Task GetContentByIdAsync(int id); + Task GetPriorityByIdAsync(int id); + Task UpdateContentAsync(TrackPullContentConfigEntity updateObj); + Task UpdatePriorityAsync(TrackPullPriorityEntity updateObj); + Task IsContentAnyAsync(Expression> whereExpression); + + Task IsPriorityAnyAsync(Expression> whereExpression); + Task FindIdAsync(string appKey, string serviceProviderCode); } diff --git a/src/TrackCenter.Domain/Aggregates/TrackPullAggregate/TrackPullConfigEntity.cs b/src/TrackCenter.Domain/Aggregates/TrackPullAggregate/TrackPullConfigEntity.cs index d3a59d5d..ff988646 100644 --- a/src/TrackCenter.Domain/Aggregates/TrackPullAggregate/TrackPullConfigEntity.cs +++ b/src/TrackCenter.Domain/Aggregates/TrackPullAggregate/TrackPullConfigEntity.cs @@ -21,16 +21,10 @@ public class TrackPullConfigEntity : FullAuditedAggregateRoot public string AppKey { get; set; } /// - /// 服务商id + /// 服务商代码 /// - [SugarColumn(ColumnName = "ServiceProviderId")] - public int ServiceProviderId { get; set; } - - /// - /// 服务商拉取频率(分钟) - /// - [SugarColumn(ColumnName = "PullInterval")] - public int PullInterval { get; set; } + [SugarColumn(ColumnName = "ServiceProviderCode")] + public string? ServiceProviderCode { get; set; } /// /// 解析方式,1取接口通返参映射后的,2取服务商原返参 @@ -97,4 +91,34 @@ public class TrackPullConfigEntity : FullAuditedAggregateRoot /// [SugarColumn(ColumnName = "TrackTimeZoneName")] public string? TrackTimeZoneName { get; set; } + + /// + /// 订单类型 + /// + [SugarColumn(ColumnName = "OrderType")] + public TrackOrderType OrderType { get; set; } + + /// + /// 开始轨迹code + /// + [SugarColumn(ColumnName = "StartTrackCode")] + public string StartTrackCode { get; set; } + + /// + /// 结束轨迹code + /// + [SugarColumn(ColumnName = "EndTrackCode")] + public string EndTrackCode { get; set; } + + /// + /// 开始前的静默(小时) + /// + [SugarColumn(ColumnName = "SilenceBeforeStart")] + public int SilenceBeforeStart { get; set; } + + /// + /// 结束后的静默(小时) + /// + [SugarColumn(ColumnName = "SilenceAfterEnd")] + public int SilenceAfterEnd { get; set; } } diff --git a/src/TrackCenter.Domain/Aggregates/TrackPullAggregate/TrackPullPriorityEntity.cs b/src/TrackCenter.Domain/Aggregates/TrackPullAggregate/TrackPullPriorityEntity.cs new file mode 100644 index 00000000..0bf59092 --- /dev/null +++ b/src/TrackCenter.Domain/Aggregates/TrackPullAggregate/TrackPullPriorityEntity.cs @@ -0,0 +1,40 @@ +using Fake.Domain.Entities.Auditing; + +namespace TrackCenter.Domain.Aggregates.TrackPullAggregate; + +/// +/// 轨迹拉取优先级配置表 +/// +[SugarTable("t_track_pull_priority_config")] +public class TrackPullPriorityEntity: FullAuditedEntity +{ + /// + /// 轨迹拉取配置id + /// + [SugarColumn(ColumnName = "TrackPullConfigId")] + public int TrackPullConfigId { get; set; } + + /// + /// 客户 + /// + [SugarColumn(ColumnName = "Customer")] + public string Customer { get; set; } + + /// + /// 订单类型 + /// + [SugarColumn(ColumnName = "OrderType")] + public TrackOrderType OrderType { get; set; } + + /// + /// 优先级 + /// + [SugarColumn(ColumnName = "优先级")] + public string Priority { get; set; } + + /// + /// 服务商拉取频率(分钟) + /// + [SugarColumn(ColumnName = "PullInterval")] + public int PullInterval { get; set; } +} diff --git a/src/TrackCenter.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs b/src/TrackCenter.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs index 85c5ca97..d35a5460 100644 --- a/src/TrackCenter.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs +++ b/src/TrackCenter.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs @@ -1,3 +1,5 @@ +using TrackCenter.Domain.Aggregates.OrderAggregate; + namespace TrackCenter.Domain.Dtos.TrackPull; public class GetTrackPullConfigDetailOutputVO @@ -14,11 +16,6 @@ public class GetTrackPullConfigDetailOutputVO /// public int ParseMethod { get; set; } - /// - /// 定时任务(分钟) - /// - public int PullInterval { get; set; } - /// /// 服务商id /// @@ -83,4 +80,29 @@ public class GetTrackPullConfigDetailOutputVO /// 轨迹明细路径 /// public string TrackDetailsPath { get; set; } + + /// + /// 订单类型 + /// + public TrackOrderType OrderType { get; set; } + + /// + /// 开始轨迹code + /// + public string StartTrackCode { get; set; } + + /// + /// 结束轨迹code + /// + public string EndTrackCode { get; set; } + + /// + /// 开始前的静默(小时) + /// + public int SilenceBeforeStart { get; set; } + + /// + /// 结束后的静默(小时) + /// + public int SilenceAfterEnd { get; set; } } diff --git a/src/TrackCenter.Domain/Dtos/TrackPull/GetTrackPullPriorityDetailOutputVO.cs b/src/TrackCenter.Domain/Dtos/TrackPull/GetTrackPullPriorityDetailOutputVO.cs new file mode 100644 index 00000000..8f28b111 --- /dev/null +++ b/src/TrackCenter.Domain/Dtos/TrackPull/GetTrackPullPriorityDetailOutputVO.cs @@ -0,0 +1,33 @@ +using TrackCenter.Domain.Aggregates.TrackPullAggregate; + +namespace TrackCenter.Domain.Dtos.TrackPull; + +public class GetTrackPullPriorityDetailOutputVO +{ + public int Id { get; set; } + + /// + /// 轨迹拉取配置id + /// + public int TrackPullConfigId { get; set; } + + /// + /// 客户 + /// + public string Customer { get; set; } + + /// + /// 订单类型 + /// + public TrackOrderType OrderType { get; set; } + + /// + /// 优先级 + /// + public string Priority { get; set; } + + /// + /// 服务商拉取频率(分钟) + /// + public int PullInterval { get; set; } +} diff --git a/src/TrackCenter.Domain/Dtos/TrackPull/GetTrackPullPriorityPageInputVO.cs b/src/TrackCenter.Domain/Dtos/TrackPull/GetTrackPullPriorityPageInputVO.cs new file mode 100644 index 00000000..43c7c93d --- /dev/null +++ b/src/TrackCenter.Domain/Dtos/TrackPull/GetTrackPullPriorityPageInputVO.cs @@ -0,0 +1,11 @@ +using TrackCenter.Domain.Aggregates.TrackPullAggregate; + +namespace TrackCenter.Domain.Dtos.TrackPull; + +public class GetTrackPullPriorityPageInputVO : PageInfoInput +{ + /// + /// 轨迹拉取配置id + /// + public int TrackPullConfigId { get; set; } +} diff --git a/src/TrackCenter.Domain/Dtos/TrackPull/GetTrackPullPriorityPageOutputVO.cs b/src/TrackCenter.Domain/Dtos/TrackPull/GetTrackPullPriorityPageOutputVO.cs new file mode 100644 index 00000000..e90688b7 --- /dev/null +++ b/src/TrackCenter.Domain/Dtos/TrackPull/GetTrackPullPriorityPageOutputVO.cs @@ -0,0 +1,36 @@ +using TrackCenter.Domain.Aggregates.TrackPullAggregate; + +namespace TrackCenter.Domain.Dtos.TrackPull; + +public class GetTrackPullPriorityPageOutputVO +{ + public int Id { get; set; } + + /// + /// 客户 + /// + public string Customer { get; set; } + + /// + /// 订单类型 + /// + public TrackOrderType OrderType { get; set; } + + /// + /// 优先级 + /// + public string Priority { get; set; } + + /// + /// 服务商拉取频率(分钟) + /// + public int PullInterval { get; set; } + + public DateTime CreateTime { get; set; } + + public string? CreateUser { get; set; } + + public string? UpdateUser { get; set; } + + public DateTime? UpdateTime { get; set; } +} diff --git a/src/TrackCenter.Domain/Dtos/TrackPull/TrackPullConfigVo.cs b/src/TrackCenter.Domain/Dtos/TrackPull/TrackPullConfigVo.cs index b35e5a9e..afa359ee 100644 --- a/src/TrackCenter.Domain/Dtos/TrackPull/TrackPullConfigVo.cs +++ b/src/TrackCenter.Domain/Dtos/TrackPull/TrackPullConfigVo.cs @@ -7,11 +7,6 @@ public class TrackPullConfigVo /// public int PullInterval { get; set; } - /// - /// 服务商id - /// - public int ServiceProviderId { get; set; } - /// /// 服务商code /// diff --git a/src/TrackCenter.Domain/Enums/TrackOrderType.cs b/src/TrackCenter.Domain/Enums/TrackOrderType.cs index a2a56e97..4890711f 100644 --- a/src/TrackCenter.Domain/Enums/TrackOrderType.cs +++ b/src/TrackCenter.Domain/Enums/TrackOrderType.cs @@ -4,5 +4,7 @@ public enum TrackOrderType { 小包 = 1, + 大包 = 2, + 主单 = 4, } diff --git a/src/TrackCenter.Domain/IBasicRepository.cs b/src/TrackCenter.Domain/IBasicRepository.cs index 42f0e193..7c4a038b 100644 --- a/src/TrackCenter.Domain/IBasicRepository.cs +++ b/src/TrackCenter.Domain/IBasicRepository.cs @@ -16,12 +16,6 @@ public interface IBasicRepository : IRepository where T : class, IAggregat Task GetFirstAsync(Expression> whereExpression,Expression> resultExpression); - /// - /// get list - /// - /// - /// - Task> GetListAsync(Expression> whereExpression); Task> GetListAsync(Expression> whereExpression,Expression> resultExpression); diff --git a/src/TrackCenter.Repository/Repositories/BasicRepository.cs b/src/TrackCenter.Repository/Repositories/BasicRepository.cs index 5f2eefcf..2ee5cd43 100644 --- a/src/TrackCenter.Repository/Repositories/BasicRepository.cs +++ b/src/TrackCenter.Repository/Repositories/BasicRepository.cs @@ -31,11 +31,6 @@ public class BasicRepository : SqlSugarRepository, I return await Context.Queryable().Where(whereExpression).Select(resultExpression).FirstAsync(); } - public async Task> GetListAsync(Expression> whereExpression) - { - return await AsQueryable().Where(whereExpression).ToListAsync(); - } - public async Task> GetListAsync(Expression> whereExpression, Expression> resultExpression) { diff --git a/src/TrackCenter.Repository/Repositories/OrderRepository.cs b/src/TrackCenter.Repository/Repositories/OrderRepository.cs index fddfc33f..d3f309c3 100644 --- a/src/TrackCenter.Repository/Repositories/OrderRepository.cs +++ b/src/TrackCenter.Repository/Repositories/OrderRepository.cs @@ -239,10 +239,10 @@ public class OrderRepository : BasicRepository, IOrderRepository, I await UpdateAsync(order, x => new { x.Customer, - x.AppKey + x.AppKey, }); - // 更新订单模板 + // 更新订单拉取状态 await Context.Deleteable().Where(x => x.OrderId == order.Id).ExecuteCommandAsync(); order.OrderPullStatus.ForEach(x => x.OrderId = order.Id); await Context.Insertable(order.OrderPullStatus).ExecuteCommandAsync(); diff --git a/src/TrackCenter.Repository/Repositories/TrackPullConfigRepository.cs b/src/TrackCenter.Repository/Repositories/TrackPullConfigRepository.cs index 6ad60fa5..61e53cfc 100644 --- a/src/TrackCenter.Repository/Repositories/TrackPullConfigRepository.cs +++ b/src/TrackCenter.Repository/Repositories/TrackPullConfigRepository.cs @@ -16,7 +16,7 @@ public class TrackPullConfigRepository : BasicRepository, { return await Context.Queryable() .LeftJoin((trackPull, system) => trackPull.AppKey == system.AppKey) - .LeftJoin((trackPull, system, service) => trackPull.ServiceProviderId == service.Id) + .LeftJoin((trackPull, system, service) => trackPull.ServiceProviderCode == service.Code) .WhereIF(!input.AppKey.IsNullOrWhiteSpace(), trackPull => trackPull.AppKey == input.AppKey) .WhereIF(!input.Keywords.IsNullOrWhiteSpace(), (trackPull, system, service) => service.Name.Contains(input.Keywords!)) @@ -81,7 +81,7 @@ public class TrackPullConfigRepository : BasicRepository, { return await AsQueryable() .LeftJoin((trackPull, system) => trackPull.AppKey == system.AppKey) - .LeftJoin((trackPull, system, service) => trackPull.ServiceProviderId == service.Id) + .LeftJoin((trackPull, system, service) => trackPull.ServiceProviderCode == service.Code) .Where(trackPull => trackPull.Id == id) .Select( (trackPull, system, service) => new GetTrackPullConfigDetailOutputVO @@ -91,6 +91,22 @@ public class TrackPullConfigRepository : BasicRepository, AppKey = system.AppKey, ServiceProviderId = service.Id, ServiceProviderCode = service.Code, + OrderNoName = trackPull.OrderNoName, + ParseMethod = (int)trackPull.ParseMethod, + TrackIsoTimeName = trackPull.TrackIsoTimeName, + TrackTimeName = trackPull.TrackTimeName, + TrackTimeZoneName = trackPull.TrackTimeZoneName, + TrackContentCodeName = trackPull.TrackContentCodeName, + TrackContentName = trackPull.TrackContentName, + TrackPlaceName = trackPull.TrackPlaceName, + TrackStatusName = trackPull.TrackStatusName, + OrderPath = trackPull.OrderPath, + TrackDetailsPath = trackPull.TrackDetailsPath, + OrderType = trackPull.OrderType, + StartTrackCode = trackPull.StartTrackCode, + EndTrackCode = trackPull.EndTrackCode, + SilenceBeforeStart = trackPull.SilenceBeforeStart, + SilenceAfterEnd = trackPull.SilenceAfterEnd }, true) .FirstAsync(); } @@ -122,12 +138,54 @@ public class TrackPullConfigRepository : BasicRepository, .SingleAsync(); } + public async Task> GetPriorityPageAsync(GetTrackPullPriorityPageInputVO input) + { + return await Context.Queryable() + .LeftJoin((x, creator) => x.CreateUserId == creator.UserId) + .LeftJoin((x, creator, modifier) => x.UpdateUserId == modifier.UserId) + .Where(x => x.TrackPullConfigId == input.TrackPullConfigId) + .OrderByDescending(x => x.Priority) + .Select((x, creator, modifier) => new GetTrackPullPriorityPageOutputVO + { + Id = x.Id, + Customer = x.Customer, + OrderType = x.OrderType, + Priority = x.Priority, + PullInterval = x.PullInterval, + CreateTime = x.CreateTime, + CreateUser = creator.Name, + UpdateUser = modifier.Name, + UpdateTime = x.UpdateTime + }) + .ToPagedListAsync(input.PageIndex, input.PageSize); + } + + public async Task GetPriorityDetailAsync(int id) + { + return await Context.Queryable() + .Where(x => x.Id == id) + .Select(x => new GetTrackPullPriorityDetailOutputVO + { + Id = x.Id, + TrackPullConfigId = x.TrackPullConfigId, + Customer = x.Customer, + OrderType = x.OrderType, + Priority = x.Priority, + PullInterval = x.PullInterval + }) + .SingleAsync(); + } public async Task InsertContentAsync(TrackPullContentConfigEntity insertObj) { return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0; } + public async Task InsertPriorityAsync(TrackPullPriorityEntity insertObj) + { + return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0; + } + public async Task SoftDeleteContentAsync(Expression> whereExpression) { return await Context.Updateable() @@ -136,27 +194,49 @@ public class TrackPullConfigRepository : BasicRepository, .ExecuteCommandHasChangeAsync(); } + public async Task SoftDeletePriorityAsync(Expression> whereExpression) + { + return await Context.Updateable() + .Where(whereExpression) + .SetColumns(nameof(ISoftDelete.IsDeleted), true) + .ExecuteCommandHasChangeAsync(); + } public async Task GetContentByIdAsync(int id) { return await Context.Queryable().InSingleAsync(id); } + public async Task GetPriorityByIdAsync(int id) + { + return await Context.Queryable().InSingleAsync(id); + } + public async Task UpdateContentAsync(TrackPullContentConfigEntity updateObj) { return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync(); } + public async Task UpdatePriorityAsync(TrackPullPriorityEntity updateObj) + { + return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync(); + } + public async Task IsContentAnyAsync(Expression> whereExpression) { return await Context.Queryable().Where(whereExpression).AnyAsync(); } + public async Task IsPriorityAnyAsync(Expression> whereExpression) + { + return await Context.Queryable().Where(whereExpression).AnyAsync(); + } + public async Task FindIdAsync(string appKey, string serviceProviderCode) { return await AsQueryable() - .LeftJoin((trackPull, service) => trackPull.ServiceProviderId == service.Id) - .Where((trackPull, service) => trackPull.AppKey == appKey && service.Code == serviceProviderCode) + .Where(trackPull => trackPull.AppKey == appKey + && trackPull.ServiceProviderCode == serviceProviderCode) .Select(trackPull => trackPull.Id) .FirstAsync(); }