This commit is contained in:
xiaolipro 2026-04-21 17:54:52 +08:00
parent 4fa45b6944
commit 22bb8ab425
35 changed files with 222 additions and 443 deletions

View File

@ -1,5 +1,7 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AClient_002Ecs_002Fl_003AC_0021_003FUsers_003FBSI_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FSourcesCache_003Fc7d66b24252bb52da52d1262d99fd654ffc18aedde818f147c3daf6aee3e63_003FClient_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIAggregateRoot_002Ecs_002Fl_003AC_0021_003FUsers_003FBSI_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6015bad29db142679ead208ae4ecd55c7800_003F0e_003F66feb813_003FIAggregateRoot_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIAggregateRoot_002Ecs_002Fl_003AC_0021_003FUsers_003FBSI_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa1494e50f25d476db4fff59a546c2b857800_003F4e_003Fb27c424d_003FIAggregateRoot_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIAggregateRoot_00601_002Ecs_002Fl_003AC_0021_003FUsers_003FBSI_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6015bad29db142679ead208ae4ecd55c7800_003F9a_003Fea4337c7_003FIAggregateRoot_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIRepository_00601_002Ecs_002Fl_003AC_0021_003FUsers_003FBSI_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6015bad29db142679ead208ae4ecd55c7800_003F85_003Fa6db724e_003FIRepository_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIRepository_00601_002Ecs_002Fl_003AC_0021_003FUsers_003FBSI_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6015bad29db142679ead208ae4ecd55c7800_003F85_003Fa6db724e_003FIRepository_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIRepository_00601_002Ecs_002Fl_003AC_0021_003FUsers_003FBSI_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa1494e50f25d476db4fff59a546c2b857800_003Fcc_003F73f30804_003FIRepository_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>

View File

@ -55,7 +55,6 @@ public class AutoTriggerService : ApplicationService
[HttpPost("/channel/auto-trigger/create")]
public async Task CreateAsync(AutoTriggerSaveInput input)
{
var now = DateTime.Now;
var entity = new AutoTrigger
{
Status = input.Status,
@ -63,10 +62,7 @@ public class AutoTriggerService : ApplicationService
TriggerTiming = input.TriggerTiming,
TriggerCondition = input.TriggerCondition,
PromptMessage = input.PromptMessage,
Notifier = input.Notifier,
IsDeleted = false,
CreateTime = now,
CreateUserId = CurrentUser.GetId<int>()
Notifier = input.Notifier
};
await AutoTriggerRepository.InsertAsync(entity);
}
@ -92,8 +88,6 @@ public class AutoTriggerService : ApplicationService
entity.TriggerCondition = input.TriggerCondition;
entity.PromptMessage = input.PromptMessage;
entity.Notifier = input.Notifier;
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await AutoTriggerRepository.UpdateAsync(entity);
}
@ -112,10 +106,7 @@ public class AutoTriggerService : ApplicationService
public async Task DeleteAsync(IdInput input)
{
var entity = await GetEntityOrThrowAsync(input.Id);
entity.IsDeleted = true;
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await AutoTriggerRepository.UpdateAsync(entity);
await AutoTriggerRepository.DeleteAsync(entity);
}
/// <summary>
@ -134,8 +125,6 @@ public class AutoTriggerService : ApplicationService
{
var entity = await GetEntityOrThrowAsync(input.Id);
entity.Status = input.Status;
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await AutoTriggerRepository.UpdateAsync(entity);
}
@ -144,7 +133,6 @@ public class AutoTriggerService : ApplicationService
var operation = input.Operation?.Trim();
var triggerTiming = input.TriggerTiming?.Trim();
return entity =>
!entity.IsDeleted &&
(string.IsNullOrWhiteSpace(operation) || entity.Operation == operation) &&
(string.IsNullOrWhiteSpace(triggerTiming) || entity.TriggerTiming == triggerTiming);
}
@ -156,7 +144,7 @@ public class AutoTriggerService : ApplicationService
throw new BusinessException("自动触发不存在");
}
var entity = await AutoTriggerRepository.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id == id.Value);
var entity = await AutoTriggerRepository.FirstOrDefaultAsync(x => x.Id == id.Value);
if (entity == null)
{
throw new BusinessException("自动触发不存在");

View File

@ -59,16 +59,12 @@ public class KpiAreaService : ApplicationService
public async Task CreateAsync(KpiAreaSaveInput input)
{
await ValidateAreaNameAsync(input.AppKey, input.AreaType, input.Name, null);
var now = DateTime.Now;
var entity = new KpiArea
{
AppKey = input.AppKey,
AreaType = input.AreaType,
Name = input.Name,
SystemName = input.SystemName,
IsDeleted = false,
CreateTime = now,
CreateUserId = CurrentUser.GetId<int>()
SystemName = input.SystemName
};
await KpiAreaRepository.InsertAsync(entity);
}
@ -93,8 +89,6 @@ public class KpiAreaService : ApplicationService
entity.AreaType = input.AreaType;
entity.Name = input.Name;
entity.SystemName = input.SystemName;
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await KpiAreaRepository.UpdateAsync(entity);
}
@ -113,10 +107,7 @@ public class KpiAreaService : ApplicationService
public async Task DeleteAsync(IdInput input)
{
var entity = await GetAreaOrThrowAsync(input.Id);
entity.IsDeleted = true;
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await KpiAreaRepository.UpdateAsync(entity);
await KpiAreaRepository.DeleteAsync(entity);
}
/// <summary>
@ -160,7 +151,6 @@ public class KpiAreaService : ApplicationService
public async Task AddInfoAsync(KpiAreaInfoSaveInput input)
{
await GetAreaOrThrowAsync(input.AreaId);
var now = DateTime.Now;
await KpiAreaRepository.InsertInfoAsync(new KpiAreaInfo
{
AreaId = input.AreaId,
@ -169,10 +159,7 @@ public class KpiAreaService : ApplicationService
Province = input.Province,
City = input.City,
LeftPostcode = input.LeftPostcode,
RightPostcode = input.RightPostcode,
IsDeleted = false,
CreateTime = now,
CreateUserId = CurrentUser.GetId<int>()
RightPostcode = input.RightPostcode
});
}
@ -199,8 +186,6 @@ public class KpiAreaService : ApplicationService
entity.City = input.City;
entity.LeftPostcode = input.LeftPostcode;
entity.RightPostcode = input.RightPostcode;
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await KpiAreaRepository.UpdateInfoAsync(entity);
}
@ -227,7 +212,6 @@ public class KpiAreaService : ApplicationService
var appKey = input.AppKey?.Trim();
var areaType = input.AreaType?.Trim();
return entity =>
!entity.IsDeleted &&
(string.IsNullOrWhiteSpace(appKey) || entity.AppKey == appKey) &&
(string.IsNullOrWhiteSpace(areaType) || entity.AreaType == areaType);
}
@ -248,7 +232,7 @@ public class KpiAreaService : ApplicationService
throw new BusinessException("分区不存在");
}
var entity = await KpiAreaRepository.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id == id.Value);
var entity = await KpiAreaRepository.FirstOrDefaultAsync(x => x.Id == id.Value);
if (entity == null)
{
throw new BusinessException("分区不存在");

View File

@ -34,8 +34,6 @@ public class LabelTemplateService : ApplicationService
entity.Name = input.Name;
entity.TemplateType = input.TemplateType;
entity.TemplateJson = OmsDocHelper.SerializeJson(input.TemplateJson);
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await LabelTemplateRepository.UpdateAsync(entity);
}
else
@ -45,10 +43,7 @@ public class LabelTemplateService : ApplicationService
{
Name = input.Name,
TemplateType = input.TemplateType,
TemplateJson = OmsDocHelper.SerializeJson(input.TemplateJson),
IsDeleted = false,
CreateTime = DateTime.Now,
CreateUserId = CurrentUser.GetId<int>()
TemplateJson = OmsDocHelper.SerializeJson(input.TemplateJson)
};
entity = await LabelTemplateRepository.InsertAsync(entity);
}
@ -67,7 +62,7 @@ public class LabelTemplateService : ApplicationService
private async Task<LabelTemplate> GetEntityOrThrowAsync(long id)
{
var entity = await LabelTemplateRepository.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id == id);
var entity = await LabelTemplateRepository.FirstOrDefaultAsync(x => x.Id == id);
if (entity == null)
{
throw new BusinessException("标签模板不存在");

View File

@ -31,7 +31,7 @@ public partial class SalesProductService
throw new Fake.Application.BusinessException("销售产品不存在");
}
var entity = await SalesProductRepository.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id == id.Value);
var entity = await SalesProductRepository.FirstOrDefaultAsync(x => x.Id == id.Value);
if (entity == null)
{
throw new Fake.Application.BusinessException("销售产品不存在");
@ -102,7 +102,7 @@ public partial class SalesProductService
var channelIds = providers.Where(x => x.ServiceChannelId.HasValue).Select(x => x.ServiceChannelId!.Value).Distinct().ToArray();
var channels = channelIds.Length == 0
? []
: await ServiceChannelRepository.GetListAsync(x => !x.IsDeleted && channelIds.Contains(x.Id));
: await ServiceChannelRepository.GetListAsync(x => channelIds.Contains(x.Id));
var channelMap = channels.ToDictionary(x => x.Id, x => x.ChannelName);
return new SalesProductAllocationOutput
@ -199,10 +199,7 @@ public partial class SalesProductService
PublishUser = string.IsNullOrWhiteSpace(CurrentUser.UserName) ? CurrentUser.GetId<int>().ToString() : CurrentUser.UserName!,
PublishTime = DateTime.Now,
Description = description,
Content = OmsDocHelper.SerializeJson(snapshot),
IsDeleted = false,
CreateTime = DateTime.Now,
CreateUserId = CurrentUser.GetId<int>()
Content = OmsDocHelper.SerializeJson(snapshot)
});
}
@ -245,12 +242,8 @@ public partial class SalesProductService
// 规则回滚既恢复产品配置,也恢复排货服务商列表。
var product = await GetProductOrThrowAsync(input.SalesProductId);
ApplyProductInput(product, rulesSnapshot.Product);
product.UpdateTime = DateTime.Now;
product.UpdateUserId = CurrentUser.GetId<int>();
await SalesProductRepository.UpdateAsync(product);
var now = DateTime.Now;
var userId = CurrentUser.GetId<int>();
var providers = rulesSnapshot.Providers.Select(provider => new SalesProductAllocationProvider
{
SalesProductId = input.SalesProductId,
@ -258,10 +251,7 @@ public partial class SalesProductService
ProviderName = provider.ProviderName,
ServiceChannelId = provider.ServiceChannelId,
Weight = provider.Weight,
CustomerIds = OmsDocHelper.SerializeJson(provider.CustomerIds),
IsDeleted = false,
CreateTime = now,
CreateUserId = userId
CustomerIds = OmsDocHelper.SerializeJson(provider.CustomerIds)
}).ToList();
await SalesProductRepository.ReplaceAllocationProvidersAsync(input.SalesProductId, providers);
}
@ -361,21 +351,18 @@ public partial class SalesProductService
};
}
private static List<SalesProductPriceFactor> BuildSalesProductPriceFactors(IEnumerable<ChannelPriceFactorInput> inputs, DateTime now, int userId, long? priceId = null)
private static List<SalesProductPriceFactor> BuildSalesProductPriceFactors(IEnumerable<ChannelPriceFactorInput> inputs, long? priceId = null)
{
return inputs.Select(input => new SalesProductPriceFactor
{
PriceId = priceId ?? 0,
SerialNumber = input.SerialNumber,
Factor = input.Factor,
FactorValues = OmsDocHelper.SerializeJson(input.FactorValues),
IsDeleted = false,
CreateTime = now,
CreateUserId = userId
FactorValues = OmsDocHelper.SerializeJson(input.FactorValues)
}).ToList();
}
private static List<SalesProductPriceDetail> BuildSalesProductPriceDetails(IEnumerable<ChannelPriceDetailInput> inputs, DateTime now, int userId, long? priceId = null)
private static List<SalesProductPriceDetail> BuildSalesProductPriceDetails(IEnumerable<ChannelPriceDetailInput> inputs, long? priceId = null)
{
return inputs.Select(input => new SalesProductPriceDetail
{
@ -383,10 +370,7 @@ public partial class SalesProductService
FactorValuesJson = OmsDocHelper.SerializeJson(input.FactorValuesJson),
CalculationFormula = input.CalculationFormula,
CalculatedValue = input.CalculatedValue,
CustomerGroupValues = OmsDocHelper.SerializeJson(input.CustomerGroupValues),
IsDeleted = false,
CreateTime = now,
CreateUserId = userId
CustomerGroupValues = OmsDocHelper.SerializeJson(input.CustomerGroupValues)
}).ToList();
}

View File

@ -81,12 +81,7 @@ public partial class SalesProductService : ApplicationService
public async Task CreateAsync(SalesProductSaveInput input)
{
await ValidateProductCodeAsync(input.ProductCode, null);
var entity = new SalesProduct
{
IsDeleted = false,
CreateTime = DateTime.Now,
CreateUserId = CurrentUser.GetId<int>()
};
var entity = new SalesProduct();
ApplyProductInput(entity, input);
await SalesProductRepository.InsertAsync(entity);
}
@ -108,8 +103,6 @@ public partial class SalesProductService : ApplicationService
var entity = await GetProductOrThrowAsync(input.Id);
await ValidateProductCodeAsync(input.ProductCode, entity.Id);
ApplyProductInput(entity, input);
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await SalesProductRepository.UpdateAsync(entity);
}
@ -128,10 +121,7 @@ public partial class SalesProductService : ApplicationService
public async Task DeleteAsync(IdInput input)
{
var entity = await GetProductOrThrowAsync(input.Id);
entity.IsDeleted = true;
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await SalesProductRepository.UpdateAsync(entity);
await SalesProductRepository.DeleteAsync(entity);
}
/// <summary>
@ -151,8 +141,6 @@ public partial class SalesProductService : ApplicationService
var entity = await GetProductOrThrowAsync(input.Id);
await ValidateProductCodeAsync(input.ProductCode, entity.Id);
ApplyProductInput(entity, input);
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await SalesProductRepository.UpdateAsync(entity);
}
@ -192,8 +180,6 @@ public partial class SalesProductService : ApplicationService
public async Task CreatePriceAsync(SalesProductPriceSaveInput input)
{
await GetProductOrThrowAsync(input.SalesProductId);
var now = DateTime.Now;
var userId = CurrentUser.GetId<int>();
await SalesProductRepository.InsertPriceAsync(
new SalesProductPrice
{
@ -205,13 +191,10 @@ public partial class SalesProductService : ApplicationService
CostUnit = input.CostUnit,
Currency = input.Currency,
ChargingTime = input.ChargingTime,
ChargingCondition = input.ChargingCondition,
IsDeleted = false,
CreateTime = now,
CreateUserId = userId
ChargingCondition = input.ChargingCondition
},
BuildSalesProductPriceFactors(input.Factors, now, userId),
BuildSalesProductPriceDetails(input.Details, now, userId));
BuildSalesProductPriceFactors(input.Factors),
BuildSalesProductPriceDetails(input.Details));
}
/// <summary>
@ -242,12 +225,10 @@ public partial class SalesProductService : ApplicationService
price.Currency = input.Currency;
price.ChargingTime = input.ChargingTime;
price.ChargingCondition = input.ChargingCondition;
price.UpdateTime = DateTime.Now;
price.UpdateUserId = CurrentUser.GetId<int>();
await SalesProductRepository.UpdatePriceAsync(
price,
BuildSalesProductPriceFactors(input.Factors, DateTime.Now, CurrentUser.GetId<int>()),
BuildSalesProductPriceDetails(input.Details, DateTime.Now, CurrentUser.GetId<int>()));
BuildSalesProductPriceFactors(input.Factors),
BuildSalesProductPriceDetails(input.Details));
}
/// <summary>
@ -301,8 +282,6 @@ public partial class SalesProductService : ApplicationService
public async Task SavePriceAsync(SalesProductPriceSaveAllInput input)
{
await GetProductOrThrowAsync(input.SalesProductId);
var now = DateTime.Now;
var userId = CurrentUser.GetId<int>();
var prices = new List<SalesProductPrice>();
var factors = new List<SalesProductPriceFactor>();
var details = new List<SalesProductPriceDetail>();
@ -323,13 +302,10 @@ public partial class SalesProductService : ApplicationService
CostUnit = priceInput.CostUnit,
Currency = priceInput.Currency,
ChargingTime = priceInput.ChargingTime,
ChargingCondition = priceInput.ChargingCondition,
IsDeleted = false,
CreateTime = now,
CreateUserId = userId
ChargingCondition = priceInput.ChargingCondition
});
factors.AddRange(BuildSalesProductPriceFactors(priceInput.Factors, now, userId, currentTempId));
details.AddRange(BuildSalesProductPriceDetails(priceInput.Details, now, userId, currentTempId));
factors.AddRange(BuildSalesProductPriceFactors(priceInput.Factors, currentTempId));
details.AddRange(BuildSalesProductPriceDetails(priceInput.Details, currentTempId));
}
await SalesProductRepository.ReplacePricesAsync(input.SalesProductId, prices, factors, details);
@ -372,12 +348,8 @@ public partial class SalesProductService : ApplicationService
{
var product = await GetProductOrThrowAsync(input.SalesProductId);
product.Scheme = input.Scheme;
product.UpdateTime = DateTime.Now;
product.UpdateUserId = CurrentUser.GetId<int>();
await SalesProductRepository.UpdateAsync(product);
var now = DateTime.Now;
var userId = CurrentUser.GetId<int>();
var providers = input.Providers.Select(provider => new SalesProductAllocationProvider
{
SalesProductId = input.SalesProductId,
@ -385,10 +357,7 @@ public partial class SalesProductService : ApplicationService
ProviderName = provider.ProviderName,
ServiceChannelId = provider.ServiceChannelId,
Weight = provider.Weight,
CustomerIds = OmsDocHelper.SerializeJson(provider.CustomerIds),
IsDeleted = false,
CreateTime = now,
CreateUserId = userId
CustomerIds = OmsDocHelper.SerializeJson(provider.CustomerIds)
}).ToList();
await SalesProductRepository.ReplaceAllocationProvidersAsync(input.SalesProductId, providers);
@ -470,10 +439,11 @@ public partial class SalesProductService : ApplicationService
{
var productGroup = input.ProductGroup?.Trim();
var keyword = input.Keyword?.Trim();
var hasIsActiveFilter = input.IsActive.HasValue;
var isActiveValue = input.IsActive.GetValueOrDefault();
return entity =>
!entity.IsDeleted &&
(string.IsNullOrWhiteSpace(productGroup) || entity.ProductGroup == productGroup) &&
(string.IsNullOrWhiteSpace(keyword) || entity.ProductCode.Contains(keyword) || entity.ProductName.Contains(keyword)) &&
(!input.IsActive.HasValue || entity.IsActive == input.IsActive.Value);
(!hasIsActiveFilter || entity.IsActive == isActiveValue);
}
}

View File

@ -38,7 +38,7 @@ public partial class ServiceChannelService
throw new Fake.Application.BusinessException("服务渠道不存在");
}
var entity = await ServiceChannelRepository.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id == id.Value);
var entity = await ServiceChannelRepository.FirstOrDefaultAsync(x => x.Id == id.Value);
if (entity == null)
{
throw new Fake.Application.BusinessException("服务渠道不存在");
@ -168,10 +168,7 @@ public partial class ServiceChannelService
PublishUser = string.IsNullOrWhiteSpace(CurrentUser.UserName) ? CurrentUser.GetId<int>().ToString() : CurrentUser.UserName!,
PublishTime = DateTime.Now,
Description = description,
Content = OmsDocHelper.SerializeJson(snapshot),
IsDeleted = false,
CreateTime = DateTime.Now,
CreateUserId = CurrentUser.GetId<int>()
Content = OmsDocHelper.SerializeJson(snapshot)
});
}
@ -213,8 +210,6 @@ public partial class ServiceChannelService
var entity = await GetEntityOrThrowAsync(input.ServiceChannelId);
ApplyInput(entity, rulesSnapshot.Channel);
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await ServiceChannelRepository.UpdateAsync(entity);
}
@ -303,21 +298,18 @@ public partial class ServiceChannelService
};
}
private static List<ServiceChannelPriceFactor> BuildPriceFactors(IEnumerable<ChannelPriceFactorInput> inputs, DateTime now, int userId, long? priceId = null)
private static List<ServiceChannelPriceFactor> BuildPriceFactors(IEnumerable<ChannelPriceFactorInput> inputs, long? priceId = null)
{
return inputs.Select(input => new ServiceChannelPriceFactor
{
PriceId = priceId ?? 0,
SerialNumber = input.SerialNumber,
Factor = input.Factor,
FactorValues = OmsDocHelper.SerializeJson(input.FactorValues),
IsDeleted = false,
CreateTime = now,
CreateUserId = userId
FactorValues = OmsDocHelper.SerializeJson(input.FactorValues)
}).ToList();
}
private static List<ServiceChannelPriceDetail> BuildPriceDetails(IEnumerable<ChannelPriceDetailInput> inputs, DateTime now, int userId, long? priceId = null)
private static List<ServiceChannelPriceDetail> BuildPriceDetails(IEnumerable<ChannelPriceDetailInput> inputs, long? priceId = null)
{
return inputs.Select(input => new ServiceChannelPriceDetail
{
@ -325,10 +317,7 @@ public partial class ServiceChannelService
FactorValuesJson = OmsDocHelper.SerializeJson(input.FactorValuesJson),
CalculationFormula = input.CalculationFormula,
CalculatedValue = input.CalculatedValue,
CustomerGroupValues = OmsDocHelper.SerializeJson(input.CustomerGroupValues),
IsDeleted = false,
CreateTime = now,
CreateUserId = userId
CustomerGroupValues = OmsDocHelper.SerializeJson(input.CustomerGroupValues)
}).ToList();
}

View File

@ -81,12 +81,7 @@ public partial class ServiceChannelService : ApplicationService
public async Task CreateAsync(ServiceChannelSaveInput input)
{
await ValidateChannelCodeAsync(input.ChannelCode, null);
var entity = new ServiceChannel
{
IsDeleted = false,
CreateTime = DateTime.Now,
CreateUserId = CurrentUser.GetId<int>()
};
var entity = new ServiceChannel();
ApplyInput(entity, input);
await ServiceChannelRepository.InsertAsync(entity);
}
@ -108,8 +103,6 @@ public partial class ServiceChannelService : ApplicationService
var entity = await GetEntityOrThrowAsync(input.Id);
await ValidateChannelCodeAsync(input.ChannelCode, entity.Id);
ApplyInput(entity, input);
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await ServiceChannelRepository.UpdateAsync(entity);
}
@ -128,10 +121,7 @@ public partial class ServiceChannelService : ApplicationService
public async Task DeleteAsync(IdInput input)
{
var entity = await GetEntityOrThrowAsync(input.Id);
entity.IsDeleted = true;
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await ServiceChannelRepository.UpdateAsync(entity);
await ServiceChannelRepository.DeleteAsync(entity);
}
/// <summary>
@ -151,8 +141,6 @@ public partial class ServiceChannelService : ApplicationService
var entity = await GetEntityOrThrowAsync(input.Id);
await ValidateChannelCodeAsync(input.ChannelCode, entity.Id);
ApplyInput(entity, input);
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await ServiceChannelRepository.UpdateAsync(entity);
}
@ -192,8 +180,6 @@ public partial class ServiceChannelService : ApplicationService
public async Task CreatePriceAsync(ServiceChannelPriceSaveInput input)
{
await GetEntityOrThrowAsync(input.ServiceChannelId);
var now = DateTime.Now;
var userId = CurrentUser.GetId<int>();
await ServiceChannelRepository.InsertPriceAsync(
new ServiceChannelPrice
{
@ -205,13 +191,10 @@ public partial class ServiceChannelService : ApplicationService
CostUnit = input.CostUnit,
Currency = input.Currency,
ChargingTime = input.ChargingTime,
ChargingCondition = input.ChargingCondition,
IsDeleted = false,
CreateTime = now,
CreateUserId = userId
ChargingCondition = input.ChargingCondition
},
BuildPriceFactors(input.Factors, now, userId),
BuildPriceDetails(input.Details, now, userId));
BuildPriceFactors(input.Factors),
BuildPriceDetails(input.Details));
}
/// <summary>
@ -242,12 +225,10 @@ public partial class ServiceChannelService : ApplicationService
price.Currency = input.Currency;
price.ChargingTime = input.ChargingTime;
price.ChargingCondition = input.ChargingCondition;
price.UpdateTime = DateTime.Now;
price.UpdateUserId = CurrentUser.GetId<int>();
await ServiceChannelRepository.UpdatePriceAsync(
price,
BuildPriceFactors(input.Factors, DateTime.Now, CurrentUser.GetId<int>()),
BuildPriceDetails(input.Details, DateTime.Now, CurrentUser.GetId<int>()));
BuildPriceFactors(input.Factors),
BuildPriceDetails(input.Details));
}
/// <summary>
@ -301,8 +282,6 @@ public partial class ServiceChannelService : ApplicationService
public async Task SavePriceAsync(ServiceChannelPriceSaveAllInput input)
{
await GetEntityOrThrowAsync(input.ServiceChannelId);
var now = DateTime.Now;
var userId = CurrentUser.GetId<int>();
var prices = new List<ServiceChannelPrice>();
var factors = new List<ServiceChannelPriceFactor>();
var details = new List<ServiceChannelPriceDetail>();
@ -323,13 +302,10 @@ public partial class ServiceChannelService : ApplicationService
CostUnit = priceInput.CostUnit,
Currency = priceInput.Currency,
ChargingTime = priceInput.ChargingTime,
ChargingCondition = priceInput.ChargingCondition,
IsDeleted = false,
CreateTime = now,
CreateUserId = userId
ChargingCondition = priceInput.ChargingCondition
});
factors.AddRange(BuildPriceFactors(priceInput.Factors, now, userId, currentTempId));
details.AddRange(BuildPriceDetails(priceInput.Details, now, userId, currentTempId));
factors.AddRange(BuildPriceFactors(priceInput.Factors, currentTempId));
details.AddRange(BuildPriceDetails(priceInput.Details, currentTempId));
}
await ServiceChannelRepository.ReplacePricesAsync(input.ServiceChannelId, prices, factors, details);
@ -410,10 +386,13 @@ public partial class ServiceChannelService : ApplicationService
private static Expression<Func<ServiceChannel, bool>> BuildListPredicate(ServiceChannelListInput input)
{
var keyword = input.Keyword?.Trim();
var hasGroupFilter = input.GroupId.HasValue;
var groupIdValue = input.GroupId.GetValueOrDefault();
var hasIsActiveFilter = input.IsActive.HasValue;
var isActiveValue = input.IsActive.GetValueOrDefault();
return entity =>
!entity.IsDeleted &&
(!input.GroupId.HasValue || entity.GroupId == input.GroupId.Value) &&
(!hasGroupFilter || entity.GroupId == groupIdValue) &&
(string.IsNullOrWhiteSpace(keyword) || entity.ChannelCode.Contains(keyword) || entity.ChannelName.Contains(keyword)) &&
(!input.IsActive.HasValue || entity.IsActive == input.IsActive.Value);
(!hasIsActiveFilter || entity.IsActive == isActiveValue);
}
}

View File

@ -62,10 +62,7 @@ public class WeightRoundingService : ApplicationService
await WeightRoundingRepository.InsertAsync(new WeightRounding
{
AppKey = input.AppKey,
Name = input.Name,
IsDeleted = false,
CreateTime = DateTime.Now,
CreateUserId = CurrentUser.GetId<int>()
Name = input.Name
});
}
@ -87,8 +84,6 @@ public class WeightRoundingService : ApplicationService
await ValidateNameAsync(input.AppKey, input.Name, entity.Id);
entity.AppKey = input.AppKey;
entity.Name = input.Name;
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await WeightRoundingRepository.UpdateAsync(entity);
}
@ -107,10 +102,7 @@ public class WeightRoundingService : ApplicationService
public async Task DeleteAsync(IdInput input)
{
var entity = await GetEntityOrThrowAsync(input.Id);
entity.IsDeleted = true;
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await WeightRoundingRepository.UpdateAsync(entity);
await WeightRoundingRepository.DeleteAsync(entity);
}
/// <summary>
@ -161,10 +153,7 @@ public class WeightRoundingService : ApplicationService
EndValue = input.EndValue,
Public = input.Public,
CustomerGroup1 = input.CustomerGroup1,
CustomerGroup2 = input.CustomerGroup2,
IsDeleted = false,
CreateTime = DateTime.Now,
CreateUserId = CurrentUser.GetId<int>()
CustomerGroup2 = input.CustomerGroup2
});
}
@ -190,8 +179,6 @@ public class WeightRoundingService : ApplicationService
entity.Public = input.Public;
entity.CustomerGroup1 = input.CustomerGroup1;
entity.CustomerGroup2 = input.CustomerGroup2;
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await WeightRoundingRepository.UpdateInfoAsync(entity);
}
@ -216,7 +203,7 @@ public class WeightRoundingService : ApplicationService
private static Expression<Func<WeightRounding, bool>> BuildPredicate(WeightRoundingListInput input)
{
var appKey = input.AppKey?.Trim();
return entity => !entity.IsDeleted && (string.IsNullOrWhiteSpace(appKey) || entity.AppKey == appKey);
return entity => string.IsNullOrWhiteSpace(appKey) || entity.AppKey == appKey;
}
private async Task ValidateNameAsync(string appKey, string name, long? id)
@ -235,7 +222,7 @@ public class WeightRoundingService : ApplicationService
throw new BusinessException("计重进位不存在");
}
var entity = await WeightRoundingRepository.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id == id.Value);
var entity = await WeightRoundingRepository.FirstOrDefaultAsync(x => x.Id == id.Value);
if (entity == null)
{
throw new BusinessException("计重进位不存在");

View File

@ -62,10 +62,7 @@ public class WeightRuleService : ApplicationService
await WeightRuleRepository.InsertAsync(new WeightRule
{
AppKey = input.AppKey,
Name = input.Name,
IsDeleted = false,
CreateTime = DateTime.Now,
CreateUserId = CurrentUser.GetId<int>()
Name = input.Name
});
}
@ -87,8 +84,6 @@ public class WeightRuleService : ApplicationService
await ValidateNameAsync(input.AppKey, input.Name, entity.Id);
entity.AppKey = input.AppKey;
entity.Name = input.Name;
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await WeightRuleRepository.UpdateAsync(entity);
}
@ -107,10 +102,7 @@ public class WeightRuleService : ApplicationService
public async Task DeleteAsync(IdInput input)
{
var entity = await GetEntityOrThrowAsync(input.Id);
entity.IsDeleted = true;
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await WeightRuleRepository.UpdateAsync(entity);
await WeightRuleRepository.DeleteAsync(entity);
}
/// <summary>
@ -160,10 +152,7 @@ public class WeightRuleService : ApplicationService
Client = input.Client,
Condition = input.Condition,
BillableWeight = input.BillableWeight,
VolumetricFactor = input.VolumetricFactor,
IsDeleted = false,
CreateTime = DateTime.Now,
CreateUserId = CurrentUser.GetId<int>()
VolumetricFactor = input.VolumetricFactor
});
}
@ -188,8 +177,6 @@ public class WeightRuleService : ApplicationService
entity.Condition = input.Condition;
entity.BillableWeight = input.BillableWeight;
entity.VolumetricFactor = input.VolumetricFactor;
entity.UpdateTime = DateTime.Now;
entity.UpdateUserId = CurrentUser.GetId<int>();
await WeightRuleRepository.UpdateInfoAsync(entity);
}
@ -214,7 +201,7 @@ public class WeightRuleService : ApplicationService
private static Expression<Func<WeightRule, bool>> BuildPredicate(WeightRuleListInput input)
{
var appKey = input.AppKey?.Trim();
return entity => !entity.IsDeleted && (string.IsNullOrWhiteSpace(appKey) || entity.AppKey == appKey);
return entity => string.IsNullOrWhiteSpace(appKey) || entity.AppKey == appKey;
}
private async Task ValidateNameAsync(string appKey, string name, long? id)
@ -233,7 +220,7 @@ public class WeightRuleService : ApplicationService
throw new BusinessException("计重规则不存在");
}
var entity = await WeightRuleRepository.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id == id.Value);
var entity = await WeightRuleRepository.FirstOrDefaultAsync(x => x.Id == id.Value);
if (entity == null)
{
throw new BusinessException("计重规则不存在");

View File

@ -92,15 +92,12 @@ public class CustomerService : ApplicationService
if (!string.IsNullOrWhiteSpace(input.Email))
{
var duplicatedEmail = await CustomerRepository.GetByEmailAsync(input.Email);
if (duplicatedEmail != null && !duplicatedEmail.IsDeleted)
if (duplicatedEmail != null)
{
throw new BusinessException("邮箱已存在");
}
}
var now = DateTime.Now;
var userId = CurrentUser.GetId<int>();
var entity = new Customer
{
CustomerCode = await GenerateCustomerCodeAsync(),
@ -114,10 +111,7 @@ public class CustomerService : ApplicationService
Remark = input.Remark,
Salesman = input.Salesman,
CustomerService = input.CustomerService,
CustomerGroup = input.CustomerGroup,
IsDeleted = false,
CreateUserId = userId,
CreateTime = now
CustomerGroup = input.CustomerGroup
};
await CustomerRepository.InsertAsync(entity);
@ -142,7 +136,7 @@ public class CustomerService : ApplicationService
if (!string.IsNullOrWhiteSpace(input.Email))
{
var duplicatedEmail = await CustomerRepository.GetByEmailAsync(input.Email);
if (duplicatedEmail != null && duplicatedEmail.Id != entity.Id && !duplicatedEmail.IsDeleted)
if (duplicatedEmail != null && duplicatedEmail.Id != entity.Id)
{
throw new BusinessException("邮箱已存在");
}
@ -155,8 +149,6 @@ public class CustomerService : ApplicationService
entity.Salesman = input.Salesman;
entity.CustomerService = input.CustomerService;
entity.CustomerGroup = input.CustomerGroup;
entity.UpdateUserId = CurrentUser.GetId<int>();
entity.UpdateTime = DateTime.Now;
await CustomerRepository.UpdateAsync(entity);
}
@ -176,10 +168,7 @@ public class CustomerService : ApplicationService
public async Task DeleteAsync(IdInput input)
{
var entity = await GetCustomerOrThrowAsync(input.Id);
entity.IsDeleted = true;
entity.UpdateUserId = CurrentUser.GetId<int>();
entity.UpdateTime = DateTime.Now;
await CustomerRepository.UpdateAsync(entity);
await CustomerRepository.DeleteAsync(entity);
}
/// <summary>
@ -198,8 +187,6 @@ public class CustomerService : ApplicationService
{
var entity = await GetCustomerOrThrowAsync(input.Id);
entity.Password = OmsPasswordHelper.ToMd5(input.NewPassword);
entity.UpdateUserId = CurrentUser.GetId<int>();
entity.UpdateTime = DateTime.Now;
await CustomerRepository.UpdateAsync(entity);
}
@ -208,22 +195,25 @@ public class CustomerService : ApplicationService
var keyword = input.Keyword?.Trim();
var salesman = input.Salesman?.Trim();
var customerService = input.CustomerService?.Trim();
var hasStatusFilter = input.Status.HasValue;
var statusValue = input.Status.GetValueOrDefault();
var hasCustomerGroupFilter = input.CustomerGroup.HasValue;
var customerGroupValue = input.CustomerGroup.GetValueOrDefault();
return customer =>
!customer.IsDeleted &&
(string.IsNullOrWhiteSpace(keyword) ||
customer.CustomerCode.Contains(keyword) ||
customer.Phone.Contains(keyword) ||
(customer.Email ?? string.Empty).Contains(keyword)) &&
(!input.Status.HasValue || customer.Status == input.Status.Value) &&
(!input.CustomerGroup.HasValue || customer.CustomerGroup == input.CustomerGroup.Value) &&
(!hasStatusFilter || customer.Status == statusValue) &&
(!hasCustomerGroupFilter || customer.CustomerGroup == customerGroupValue) &&
(string.IsNullOrWhiteSpace(salesman) || customer.Salesman == salesman) &&
(string.IsNullOrWhiteSpace(customerService) || customer.CustomerService == customerService);
}
private async Task<Customer> GetCustomerOrThrowAsync(long id)
{
var entity = await CustomerRepository.FirstOrDefaultAsync(x => x.Id == id && !x.IsDeleted);
var entity = await CustomerRepository.FirstOrDefaultAsync(x => x.Id == id);
if (entity == null)
{
throw new BusinessException("客户不存在");
@ -238,7 +228,7 @@ public class CustomerService : ApplicationService
{
var code = $"W{DateTime.Now:yyMMddHHmmss}{Random.Shared.Next(10, 99)}";
var exists = await CustomerRepository.GetByCustomerCodeAsync(code);
if (exists == null || exists.IsDeleted)
if (exists == null)
{
return code;
}

View File

@ -43,10 +43,7 @@ public class InboundRecordService : ApplicationService
DestinationCountry = input.DestinationCountry,
WarehouseId = input.WarehouseId,
OperateTime = now,
OperatorId = operatorId,
IsDeleted = false,
CreateUserId = CurrentUser.GetId<int>(),
CreateTime = now
OperatorId = operatorId
};
var savedEntity = await InboundRecordRepository.InsertAsync(entity);
@ -68,8 +65,10 @@ public class InboundRecordService : ApplicationService
[HttpGet("/operation/inbound/recent-list")]
public async Task<OmsItemsResult<InboundRecordOutput>> GetRecentListAsync([FromQuery] int limit = 20, [FromQuery] long? warehouseId = null)
{
var hasWarehouseFilter = warehouseId.HasValue;
var warehouseIdValue = warehouseId.GetValueOrDefault();
var entities = await InboundRecordRepository.GetPagedListAsync(
x => !x.IsDeleted && (!warehouseId.HasValue || x.WarehouseId == warehouseId),
x => !hasWarehouseFilter || x.WarehouseId == warehouseIdValue,
1,
limit <= 0 ? 20 : limit,
new Dictionary<string, bool> { [nameof(InboundRecord.OperateTime)] = false, [nameof(InboundRecord.Id)] = false });
@ -78,10 +77,10 @@ public class InboundRecordService : ApplicationService
var warehouseIds = entities.Where(x => x.WarehouseId.HasValue).Select(x => x.WarehouseId!.Value).Distinct().ToArray();
var products = salesProductIds.Length == 0
? []
: await SalesProductRepository.GetListAsync(x => !x.IsDeleted && salesProductIds.Contains(x.Id));
: await SalesProductRepository.GetListAsync(x => salesProductIds.Contains(x.Id));
var warehouses = warehouseIds.Length == 0
? []
: await WarehouseAddressRepository.GetListAsync(x => !x.IsDeleted && warehouseIds.Contains(x.Id));
: await WarehouseAddressRepository.GetListAsync(x => warehouseIds.Contains(x.Id));
var productMap = products.ToDictionary(x => x.Id);
var warehouseMap = warehouses.ToDictionary(x => x.Id);

View File

@ -33,7 +33,7 @@ public class LabelPrintService : ApplicationService
LabelTemplate? labelTemplate = null;
if (input.LabelTemplateId.HasValue)
{
labelTemplate = await LabelTemplateRepository.FirstOrDefaultAsync(x => x.Id == input.LabelTemplateId.Value && !x.IsDeleted);
labelTemplate = await LabelTemplateRepository.FirstOrDefaultAsync(x => x.Id == input.LabelTemplateId.Value);
if (labelTemplate == null)
{
throw new BusinessException("标签模板不存在");
@ -42,7 +42,7 @@ public class LabelPrintService : ApplicationService
else if (!string.IsNullOrWhiteSpace(input.TemplateType))
{
var list = await LabelTemplateRepository.GetListAsync(
x => !x.IsDeleted && x.TemplateType == input.TemplateType);
x => x.TemplateType == input.TemplateType);
labelTemplate = list.OrderByDescending(x => x.UpdateTime).ThenByDescending(x => x.Id).FirstOrDefault();
}
@ -79,10 +79,7 @@ public class LabelPrintService : ApplicationService
LabelTemplateId = labelTemplate?.Id ?? input.LabelTemplateId,
PrintSuccess = EnableStatus.Enabled,
PrintTime = now,
OperatorId = operatorId,
IsDeleted = false,
CreateUserId = CurrentUser.GetId<int>(),
CreateTime = now
OperatorId = operatorId
};
var savedEntity = await LabelPrintRecordRepository.InsertAsync(entity);
@ -107,8 +104,10 @@ public class LabelPrintService : ApplicationService
[HttpGet("/operation/print-label/recent-list")]
public async Task<OmsItemsResult<LabelPrintRecordOutput>> GetRecentListAsync([FromQuery] int limit = 20, [FromQuery] long? labelTemplateId = null)
{
var hasTemplateFilter = labelTemplateId.HasValue;
var labelTemplateIdValue = labelTemplateId.GetValueOrDefault();
var entities = await LabelPrintRecordRepository.GetPagedListAsync(
x => !x.IsDeleted && (!labelTemplateId.HasValue || x.LabelTemplateId == labelTemplateId),
x => !hasTemplateFilter || x.LabelTemplateId == labelTemplateIdValue,
1,
limit <= 0 ? 20 : limit,
new Dictionary<string, bool> { [nameof(LabelPrintRecord.PrintTime)] = false, [nameof(LabelPrintRecord.Id)] = false });
@ -116,7 +115,7 @@ public class LabelPrintService : ApplicationService
var templateIds = entities.Where(x => x.LabelTemplateId.HasValue).Select(x => x.LabelTemplateId!.Value).Distinct().ToArray();
var templates = templateIds.Length == 0
? []
: await LabelTemplateRepository.GetListAsync(x => !x.IsDeleted && templateIds.Contains(x.Id));
: await LabelTemplateRepository.GetListAsync(x => templateIds.Contains(x.Id));
var templateMap = templates.ToDictionary(x => x.Id);
var items = new List<LabelPrintRecordOutput>(entities.Count);
foreach (var entity in entities)
@ -149,7 +148,7 @@ public class LabelPrintService : ApplicationService
public async Task<OmsItemsResult<LabelTemplateDropdownOutput>> GetTemplateDropdownListAsync([FromQuery] string? templateType = null)
{
var entities = await LabelTemplateRepository.GetListAsync(
x => !x.IsDeleted && (string.IsNullOrWhiteSpace(templateType) || x.TemplateType == templateType));
x => string.IsNullOrWhiteSpace(templateType) || x.TemplateType == templateType);
var items = entities
.Select(entity => ObjectMapper.Map<LabelTemplate, LabelTemplateDropdownOutput>(entity))

View File

@ -35,10 +35,7 @@ public class OutboundRecordService : ApplicationService
WaybillNo = input.WaybillNo,
WarehouseId = input.WarehouseId,
OperateTime = now,
OperatorId = operatorId,
IsDeleted = false,
CreateUserId = CurrentUser.GetId<int>(),
CreateTime = now
OperatorId = operatorId
};
var savedEntity = await OutboundRecordRepository.InsertAsync(entity);
@ -60,8 +57,10 @@ public class OutboundRecordService : ApplicationService
[HttpGet("/operation/outbound/recent-list")]
public async Task<OmsItemsResult<OutboundRecordOutput>> GetRecentListAsync([FromQuery] int limit = 20, [FromQuery] long? warehouseId = null)
{
var hasWarehouseFilter = warehouseId.HasValue;
var warehouseIdValue = warehouseId.GetValueOrDefault();
var entities = await OutboundRecordRepository.GetPagedListAsync(
x => !x.IsDeleted && (!warehouseId.HasValue || x.WarehouseId == warehouseId),
x => !hasWarehouseFilter || x.WarehouseId == warehouseIdValue,
1,
limit <= 0 ? 20 : limit,
new Dictionary<string, bool> { [nameof(OutboundRecord.OperateTime)] = false, [nameof(OutboundRecord.Id)] = false });
@ -69,7 +68,7 @@ public class OutboundRecordService : ApplicationService
var warehouseIds = entities.Where(x => x.WarehouseId.HasValue).Select(x => x.WarehouseId!.Value).Distinct().ToArray();
var warehouses = warehouseIds.Length == 0
? []
: await WarehouseAddressRepository.GetListAsync(x => !x.IsDeleted && warehouseIds.Contains(x.Id));
: await WarehouseAddressRepository.GetListAsync(x => warehouseIds.Contains(x.Id));
var warehouseMap = warehouses.ToDictionary(x => x.Id);
var items = entities.Select(entity =>

View File

@ -29,7 +29,7 @@ public partial class OrderService
var weights = await OrderRepository.GetWeightsByOrderIdsAsync(orderIds);
var warehouses = warehouseIds.Length == 0
? []
: await WarehouseAddressRepository.GetListAsync(x => !x.IsDeleted && warehouseIds.Contains(x.Id));
: await WarehouseAddressRepository.GetListAsync(x => warehouseIds.Contains(x.Id));
var senderMap = senders.GroupBy(x => x.OrderId).ToDictionary(x => x.Key, x => x.First());
var recipientMap = recipients.GroupBy(x => x.OrderId).ToDictionary(x => x.Key, x => x.First());
@ -114,10 +114,9 @@ public partial class OrderService
private async Task<List<OrderPriceCheckOutput>> BuildPriceCheckOutputsAsync(OrderPriceCheckInput input)
{
var products = await SalesProductRepository.GetListAsync(
x => !x.IsDeleted &&
x.IsActive == Oms.Domain.Shared.Enums.EnableStatus.Enabled &&
x => x.IsActive == Oms.Domain.Shared.Enums.EnableStatus.Enabled &&
(string.IsNullOrWhiteSpace(input.ShippingMethod) || x.ProductName.Contains(input.ShippingMethod) || x.ProductCode.Contains(input.ShippingMethod)));
var warehouses = await WarehouseAddressRepository.GetListAsync(x => !x.IsDeleted);
var warehouses = await WarehouseAddressRepository.GetListAsync();
var warehouse = warehouses.OrderBy(x => x.Id).FirstOrDefault();
var volumetricWeight = input.Length.HasValue && input.Width.HasValue && input.Height.HasValue
? Math.Round((input.Length.Value * input.Width.Value * input.Height.Value) / 6000M, 3)
@ -153,7 +152,6 @@ public partial class OrderService
var pageSize = OmsDocHelper.NormalizePageSize(input.PageSize);
var keyword = input.Keyword?.Trim();
var predicate = (Expression<Func<OrderTemplate, bool>>)(x =>
!x.IsDeleted &&
(string.IsNullOrWhiteSpace(input.Type) || x.Type == input.Type) &&
(string.IsNullOrWhiteSpace(keyword) || x.Name.Contains(keyword) || (x.TemplateKey ?? string.Empty).Contains(keyword)));
@ -182,7 +180,7 @@ public partial class OrderService
private async Task<FileContentResult> BuildTemplateDownloadAsync(long templateId)
{
var template = await OrderTemplateRepository.FirstOrDefaultAsync(x => x.Id == templateId && !x.IsDeleted);
var template = await OrderTemplateRepository.FirstOrDefaultAsync(x => x.Id == templateId);
if (template == null)
{
throw new BusinessException("模板不存在");
@ -233,7 +231,7 @@ public partial class OrderService
throw new BusinessException("上传文件不能为空");
}
var template = await OrderTemplateRepository.FirstOrDefaultAsync(x => x.Id == input.TemplateId && !x.IsDeleted);
var template = await OrderTemplateRepository.FirstOrDefaultAsync(x => x.Id == input.TemplateId);
if (template == null)
{
throw new BusinessException("模板不存在");
@ -247,10 +245,7 @@ public partial class OrderService
FailCount = 0,
Status = "processing",
TemplateId = template.Id,
CustomerId = template.CustomerId,
IsDeleted = false,
CreateUserId = CurrentUser.GetId<int>(),
CreateTime = DateTime.Now
CustomerId = template.CustomerId
});
var quantity = 0;
@ -292,8 +287,6 @@ public partial class OrderService
task.SuccessCount = successCount;
task.FailCount = failCount;
task.Status = "completed";
task.UpdateUserId = CurrentUser.GetId<int>();
task.UpdateTime = DateTime.Now;
await OrderTaskRepository.UpdateAsync(task);
return new OrderUploadOutput { TaskId = task.Id };
}
@ -329,10 +322,7 @@ public partial class OrderService
IsCod = GetBoolCell(rowDict, "IsCod") ? (byte)1 : (byte)0,
IsIntercept = 0,
IsRemote = 0,
OrderStatus = OrderStatusCodes.PendingPayment,
IsDeleted = false,
CreateUserId = CurrentUser.GetId<int>(),
CreateTime = DateTime.Now
OrderStatus = OrderStatusCodes.PendingPayment
});
var weight = BuildForecastWeight(order.Id, rowDict);
@ -348,7 +338,6 @@ public partial class OrderService
var pageSize = OmsDocHelper.NormalizePageSize(input.PageSize);
var keyword = input.Keyword?.Trim();
var predicate = (Expression<Func<OrderTask, bool>>)(x =>
!x.IsDeleted &&
(string.IsNullOrWhiteSpace(input.Status) || x.Status == input.Status) &&
(string.IsNullOrWhiteSpace(keyword) || x.TaskName.Contains(keyword)));
var tasks = await OrderTaskRepository.GetPagedListAsync(
@ -376,7 +365,7 @@ public partial class OrderService
private async Task<OrderTaskDetailOutput> GetTaskDetailCoreAsync(long taskId)
{
var task = await OrderTaskRepository.FirstOrDefaultAsync(x => x.Id == taskId && !x.IsDeleted);
var task = await OrderTaskRepository.FirstOrDefaultAsync(x => x.Id == taskId);
if (task == null)
{
throw new BusinessException("任务不存在");
@ -465,10 +454,7 @@ public partial class OrderService
Quantity = input.Quantity,
IsIntercept = 0,
IsRemote = 0,
OrderStatus = OrderStatusCodes.PendingPayment,
IsDeleted = false,
CreateUserId = CurrentUser.GetId<int>(),
CreateTime = DateTime.Now
OrderStatus = OrderStatusCodes.PendingPayment
};
}
@ -493,10 +479,7 @@ public partial class OrderService
Phone = input.Sender.Phone,
TelePhone = input.Sender.TelePhone,
Email = input.Sender.Email,
IsDefault = 0,
IsDeleted = false,
CreateUserId = CurrentUser.GetId<int>(),
CreateTime = now
IsDefault = 0
});
order.SenderId = sender.Id;
}
@ -524,10 +507,7 @@ public partial class OrderService
CertificateType = input.Receiver.CertificateType,
CertificateNo = input.Receiver.CertificateNo,
Eori = input.Receiver.Eori,
Vat = input.Receiver.Vat,
IsDeleted = false,
CreateUserId = CurrentUser.GetId<int>(),
CreateTime = now
Vat = input.Receiver.Vat
});
order.RecipientId = recipient.Id;
}
@ -563,10 +543,7 @@ public partial class OrderService
SalesLink = x.SalesLink,
Model = x.Model,
Specifications = x.Specifications,
Comment = x.Comment,
IsDeleted = false,
CreateUserId = CurrentUser.GetId<int>(),
CreateTime = now
Comment = x.Comment
}));
}
@ -581,15 +558,10 @@ public partial class OrderService
ActualWeight = input.ActualWeight,
VolumetricWeight = input.VolumetricWeight,
ChargeableWeight = input.ChargeableWeight,
Cubic = input.Cubic,
IsDeleted = false,
CreateUserId = CurrentUser.GetId<int>(),
CreateTime = now
Cubic = input.Cubic
}
]);
order.UpdateUserId = CurrentUser.GetId<int>();
order.UpdateTime = now;
await OrderRepository.UpdateAsync(order);
}
@ -750,7 +722,6 @@ public partial class OrderService
RowNumber = rowNumber,
Reason = reason,
RawDataJson = JsonSerializer.Serialize(rawData),
IsDeleted = false,
CreateUserId = 0,
CreateTime = DateTime.Now
};
@ -786,10 +757,7 @@ public partial class OrderService
ActualWeight = actualWeight,
VolumetricWeight = volumetricWeight,
ChargeableWeight = chargeableWeight,
Cubic = cubic,
IsDeleted = false,
CreateUserId = CurrentUser.GetId<int>(),
CreateTime = DateTime.Now
Cubic = cubic
};
}
}

View File

@ -161,9 +161,9 @@ public partial class OrderService : ApplicationService
public async Task DeleteAsync(OrderActionInput input)
{
var order = await GetOrderOrThrowAsync(input.Id);
order.IsDeleted = true;
order.OrderStatus = OrderStatusCodes.Deleted;
await UpdateOrderAsync(order);
await OrderRepository.UpdateAsync(order);
await OrderRepository.DeleteAsync(order);
}
/// <summary>
@ -387,7 +387,6 @@ public partial class OrderService : ApplicationService
var start = createTimeStart.Value;
var end = createTimeEnd.Value;
return order =>
!order.IsDeleted &&
(!hasStatusFilter || order.OrderStatus == status) &&
(!hasKeywordFilter ||
order.ServiceNo.Contains(keyword!) ||
@ -401,7 +400,6 @@ public partial class OrderService : ApplicationService
{
var start = createTimeStart.Value;
return order =>
!order.IsDeleted &&
(!hasStatusFilter || order.OrderStatus == status) &&
(!hasKeywordFilter ||
order.ServiceNo.Contains(keyword!) ||
@ -414,7 +412,6 @@ public partial class OrderService : ApplicationService
{
var end = createTimeEnd.Value;
return order =>
!order.IsDeleted &&
(!hasStatusFilter || order.OrderStatus == status) &&
(!hasKeywordFilter ||
order.ServiceNo.Contains(keyword!) ||
@ -424,7 +421,6 @@ public partial class OrderService : ApplicationService
}
return order =>
!order.IsDeleted &&
(!hasStatusFilter || order.OrderStatus == status) &&
(!hasKeywordFilter ||
order.ServiceNo.Contains(keyword!) ||
@ -434,7 +430,7 @@ public partial class OrderService : ApplicationService
private async Task<Order> GetOrderOrThrowAsync(long id)
{
var entity = await OrderRepository.FirstOrDefaultAsync(x => x.Id == id && !x.IsDeleted);
var entity = await OrderRepository.FirstOrDefaultAsync(x => x.Id == id);
if (entity == null)
{
throw new BusinessException("订单不存在");
@ -445,8 +441,6 @@ public partial class OrderService : ApplicationService
private async Task UpdateOrderAsync(Order entity)
{
entity.UpdateUserId = CurrentUser.GetId<int>();
entity.UpdateTime = DateTime.Now;
await OrderRepository.UpdateAsync(entity);
}
}

View File

@ -38,27 +38,22 @@ public class RechargeService : ApplicationService
throw new BusinessException("客户ID不能为空");
}
var customer = await CustomerRepository.FirstOrDefaultAsync(x => x.Id == customerId && !x.IsDeleted);
var customer = await CustomerRepository.FirstOrDefaultAsync(x => x.Id == customerId);
if (customer == null)
{
throw new BusinessException("客户不存在");
}
var now = DateTime.Now;
var userId = CurrentUser.GetId<int>();
var entity = new RechargeRecord
{
CustomerId = customer.Id,
SerialNumber = await GenerateSerialNumberAsync(),
RechargeTime = now,
RechargeTime = DateTime.Now,
PayType = input.PayType,
RechargeAmount = input.RechargeAmount,
RechargeScreenshot = input.RechargeScreenshot,
RechargeStatus = RechargeStatus.Pending,
Remark = input.Remark,
IsDeleted = false,
CreateUserId = userId,
CreateTime = now
Remark = input.Remark
};
var savedEntity = await RechargeRecordRepository.InsertAsync(entity);
@ -85,25 +80,20 @@ public class RechargeService : ApplicationService
throw new BusinessException("只有待审核记录才能审核通过");
}
var customer = await CustomerRepository.FirstOrDefaultAsync(x => x.Id == record.CustomerId && !x.IsDeleted);
var customer = await CustomerRepository.FirstOrDefaultAsync(x => x.Id == record.CustomerId);
if (customer == null)
{
throw new BusinessException("客户不存在");
}
var now = DateTime.Now;
var userId = CurrentUser.GetId<int>();
record.RechargeStatus = RechargeStatus.Approved;
record.Remark = input.Remark;
record.AuditTime = now;
record.AuditBy = CurrentUser.UserName;
record.UpdateUserId = userId;
record.UpdateTime = now;
customer.Balance += record.RechargeAmount;
customer.UpdateUserId = userId;
customer.UpdateTime = now;
await RechargeRecordRepository.UpdateAsync(record);
await CustomerRepository.UpdateAsync(customer);
@ -133,8 +123,6 @@ public class RechargeService : ApplicationService
record.Remark = input.Remark;
record.AuditTime = DateTime.Now;
record.AuditBy = CurrentUser.UserName;
record.UpdateUserId = CurrentUser.GetId<int>();
record.UpdateTime = DateTime.Now;
await RechargeRecordRepository.UpdateAsync(record);
}
@ -168,7 +156,7 @@ public class RechargeService : ApplicationService
var customerIds = entities.Select(x => x.CustomerId).Distinct().ToArray();
var customers = customerIds.Length == 0
? []
: await CustomerRepository.GetListAsync(x => !x.IsDeleted && customerIds.Contains(x.Id));
: await CustomerRepository.GetListAsync(x => customerIds.Contains(x.Id));
var customerMap = customers.ToDictionary(x => x.Id);
// 列表返回时补齐客户信息,避免前端为了展示字段额外发起关联查询。
@ -212,7 +200,7 @@ public class RechargeService : ApplicationService
var customerIds = records.Select(x => x.CustomerId).Distinct().ToArray();
var customers = customerIds.Length == 0
? []
: await CustomerRepository.GetListAsync(x => !x.IsDeleted && customerIds.Contains(x.Id));
: await CustomerRepository.GetListAsync(x => customerIds.Contains(x.Id));
var customerMap = customers.ToDictionary(x => x.Id);
var exportRows = records.Select(record => new
@ -258,7 +246,7 @@ public class RechargeService : ApplicationService
private async Task<RechargeRecord> GetRechargeRecordOrThrowAsync(long id)
{
var record = await RechargeRecordRepository.FirstOrDefaultAsync(x => x.Id == id && !x.IsDeleted);
var record = await RechargeRecordRepository.FirstOrDefaultAsync(x => x.Id == id);
if (record == null)
{
throw new BusinessException("充值记录不存在");
@ -346,7 +334,6 @@ public class RechargeService : ApplicationService
var start = startTime.Value;
var end = endTime.Value;
return record =>
!record.IsDeleted &&
(!hasCustomerFilter || record.CustomerId == customerIdValue) &&
(!hasStatusFilter || record.RechargeStatus == rechargeStatusValue) &&
(!hasSerialNumberFilter || record.SerialNumber.Contains(serialNumber!)) &&
@ -358,7 +345,6 @@ public class RechargeService : ApplicationService
{
var start = startTime.Value;
return record =>
!record.IsDeleted &&
(!hasCustomerFilter || record.CustomerId == customerIdValue) &&
(!hasStatusFilter || record.RechargeStatus == rechargeStatusValue) &&
(!hasSerialNumberFilter || record.SerialNumber.Contains(serialNumber!)) &&
@ -369,7 +355,6 @@ public class RechargeService : ApplicationService
{
var end = endTime.Value;
return record =>
!record.IsDeleted &&
(!hasCustomerFilter || record.CustomerId == customerIdValue) &&
(!hasStatusFilter || record.RechargeStatus == rechargeStatusValue) &&
(!hasSerialNumberFilter || record.SerialNumber.Contains(serialNumber!)) &&
@ -377,7 +362,6 @@ public class RechargeService : ApplicationService
}
return record =>
!record.IsDeleted &&
(!hasCustomerFilter || record.CustomerId == customerIdValue) &&
(!hasStatusFilter || record.RechargeStatus == rechargeStatusValue) &&
(!hasSerialNumberFilter || record.SerialNumber.Contains(serialNumber!));

View File

@ -92,7 +92,7 @@ public class WarehouseService : ApplicationService
public async Task CreateAsync(CreateWarehouseInput input)
{
var duplicatedWarehouse = await WarehouseAddressRepository.GetByWarehouseNameAsync(input.WarehouseName);
if (duplicatedWarehouse != null && !duplicatedWarehouse.IsDeleted)
if (duplicatedWarehouse != null)
{
throw new BusinessException("仓库名称已存在");
}
@ -106,10 +106,7 @@ public class WarehouseService : ApplicationService
ShippingAddress = input.ShippingAddress,
ServicePhone = input.ServicePhone,
ServiceWechat = input.ServiceWechat,
ServiceWechatFiles = JsonStringArrayHelper.Serialize(input.ServiceWechatFiles),
IsDeleted = false,
CreateUserId = CurrentUser.GetId<int>(),
CreateTime = DateTime.Now
ServiceWechatFiles = JsonStringArrayHelper.Serialize(input.ServiceWechatFiles)
};
await WarehouseAddressRepository.InsertAsync(entity);
@ -131,7 +128,7 @@ public class WarehouseService : ApplicationService
{
var entity = await GetWarehouseOrThrowAsync(input.Id);
var duplicatedWarehouse = await WarehouseAddressRepository.GetByWarehouseNameAsync(input.WarehouseName);
if (duplicatedWarehouse != null && duplicatedWarehouse.Id != entity.Id && !duplicatedWarehouse.IsDeleted)
if (duplicatedWarehouse != null && duplicatedWarehouse.Id != entity.Id)
{
throw new BusinessException("仓库名称已存在");
}
@ -144,8 +141,6 @@ public class WarehouseService : ApplicationService
entity.ServicePhone = input.ServicePhone;
entity.ServiceWechat = input.ServiceWechat;
entity.ServiceWechatFiles = JsonStringArrayHelper.Serialize(input.ServiceWechatFiles);
entity.UpdateUserId = CurrentUser.GetId<int>();
entity.UpdateTime = DateTime.Now;
await WarehouseAddressRepository.UpdateAsync(entity);
}
@ -165,10 +160,7 @@ public class WarehouseService : ApplicationService
public async Task DeleteAsync(IdInput input)
{
var entity = await GetWarehouseOrThrowAsync(input.Id);
entity.IsDeleted = true;
entity.UpdateUserId = CurrentUser.GetId<int>();
entity.UpdateTime = DateTime.Now;
await WarehouseAddressRepository.UpdateAsync(entity);
await WarehouseAddressRepository.DeleteAsync(entity);
}
private Expression<Func<WarehouseAddress, bool>> BuildPaginatedPredicate(WarehousePaginatedInput input)
@ -177,7 +169,6 @@ public class WarehouseService : ApplicationService
var warehouseType = input.WarehouseType?.Trim();
return warehouse =>
!warehouse.IsDeleted &&
(string.IsNullOrWhiteSpace(warehouseType) || warehouse.WarehouseType == warehouseType) &&
(string.IsNullOrWhiteSpace(keyword) ||
warehouse.WarehouseName.Contains(keyword) ||
@ -187,7 +178,7 @@ public class WarehouseService : ApplicationService
private async Task<WarehouseAddress> GetWarehouseOrThrowAsync(long id)
{
var entity = await WarehouseAddressRepository.FirstOrDefaultAsync(x => x.Id == id && !x.IsDeleted);
var entity = await WarehouseAddressRepository.FirstOrDefaultAsync(x => x.Id == id);
if (entity == null)
{
throw new BusinessException("仓库不存在");

View File

@ -10,7 +10,7 @@ public class AutoTriggerRepository : OmsSqlSugarRepository<AutoTrigger>, IAutoTr
{
public async Task<IReadOnlyCollection<AutoTrigger>> GetEnabledListAsync(CancellationToken cancellationToken = default)
{
var list = await GetListAsync(x => !x.IsDeleted && x.Status == EnableStatus.Enabled, cancellationToken: cancellationToken);
var list = await GetListAsync(x => x.Status == EnableStatus.Enabled, cancellationToken: cancellationToken);
return list;
}
}

View File

@ -9,19 +9,19 @@ public class KpiAreaRepository : OmsSqlSugarRepository<KpiArea>, IKpiAreaReposit
{
public Task<KpiArea?> GetByAppKeyTypeAndNameAsync(string appKey, string areaType, string name, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.AppKey == appKey && x.AreaType == areaType && x.Name == name, cancellationToken);
return FirstOrDefaultAsync(x => x.AppKey == appKey && x.AreaType == areaType && x.Name == name, cancellationToken);
}
public Task<bool> ExistsNameAsync(string appKey, string areaType, string name, CancellationToken cancellationToken = default)
{
return AnyAsync(x => !x.IsDeleted && x.AppKey == appKey && x.AreaType == areaType && x.Name == name, cancellationToken);
return AnyAsync(x => x.AppKey == appKey && x.AreaType == areaType && x.Name == name, cancellationToken);
}
public async Task<List<KpiAreaInfo>> GetInfosAsync(long areaId, int pageIndex, int pageSize, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<KpiAreaInfo>()
.Where(x => !x.IsDeleted && x.AreaId == areaId)
.Where(x => x.AreaId == areaId)
.OrderBy(x => x.Id, SqlSugar.OrderByType.Desc)
.ToPageListAsync(pageIndex, pageSize, cancellationToken);
}
@ -29,7 +29,7 @@ public class KpiAreaRepository : OmsSqlSugarRepository<KpiArea>, IKpiAreaReposit
public async Task<long> CountInfosAsync(long areaId, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<KpiAreaInfo>().Where(x => !x.IsDeleted && x.AreaId == areaId).CountAsync(cancellationToken);
return await db.Queryable<KpiAreaInfo>().Where(x => x.AreaId == areaId).CountAsync(cancellationToken);
}
public async Task<KpiAreaInfo> InsertInfoAsync(KpiAreaInfo info, CancellationToken cancellationToken = default)
@ -41,7 +41,7 @@ public class KpiAreaRepository : OmsSqlSugarRepository<KpiArea>, IKpiAreaReposit
public async Task<KpiAreaInfo?> GetInfoByIdAsync(long id, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<KpiAreaInfo>().FirstAsync(x => !x.IsDeleted && x.Id == id, cancellationToken);
return await db.Queryable<KpiAreaInfo>().FirstAsync(x => x.Id == id, cancellationToken);
}
public async Task UpdateInfoAsync(KpiAreaInfo info, CancellationToken cancellationToken = default)
@ -53,6 +53,6 @@ public class KpiAreaRepository : OmsSqlSugarRepository<KpiArea>, IKpiAreaReposit
public async Task DeleteInfoAsync(long id, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
await db.Updateable<KpiAreaInfo>().SetColumns(x => x.IsDeleted, true).Where(x => x.Id == id).ExecuteCommandAsync(cancellationToken);
await db.Deleteable<KpiAreaInfo>().Where(x => x.Id == id).ExecuteCommandAsync(cancellationToken);
}
}

View File

@ -10,12 +10,12 @@ public class LabelTemplateRepository : OmsSqlSugarRepository<LabelTemplate>, ILa
public Task<LabelTemplate?> GetByNameAndTypeAsync(string name, string? templateType, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(
x => !x.IsDeleted && x.Name == name && x.TemplateType == templateType,
x => x.Name == name && x.TemplateType == templateType,
cancellationToken);
}
public Task<bool> ExistsNameAsync(string name, string? templateType, CancellationToken cancellationToken = default)
{
return AnyAsync(x => !x.IsDeleted && x.Name == name && x.TemplateType == templateType, cancellationToken);
return AnyAsync(x => x.Name == name && x.TemplateType == templateType, cancellationToken);
}
}

View File

@ -10,19 +10,19 @@ public class SalesProductRepository : OmsSqlSugarRepository<SalesProduct>, ISale
{
public Task<SalesProduct?> GetByProductCodeAsync(string productCode, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.ProductCode == productCode, cancellationToken);
return FirstOrDefaultAsync(x => x.ProductCode == productCode, cancellationToken);
}
public Task<bool> HasProductCodeAsync(string productCode, CancellationToken cancellationToken = default)
{
return AnyAsync(x => !x.IsDeleted && x.ProductCode == productCode, cancellationToken);
return AnyAsync(x => x.ProductCode == productCode, cancellationToken);
}
public async Task<List<SalesProductPrice>> GetPricesAsync(long salesProductId, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<SalesProductPrice>()
.Where(x => !x.IsDeleted && x.SalesProductId == salesProductId)
.Where(x => x.SalesProductId == salesProductId)
.OrderBy(x => x.SerialNumber)
.ToListAsync(cancellationToken);
}
@ -31,7 +31,7 @@ public class SalesProductRepository : OmsSqlSugarRepository<SalesProduct>, ISale
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<SalesProductPrice>()
.FirstAsync(x => !x.IsDeleted && x.Id == id, cancellationToken);
.FirstAsync(x => x.Id == id, cancellationToken);
}
public async Task<List<SalesProductPriceFactor>> GetPriceFactorsAsync(IEnumerable<long> priceIds, CancellationToken cancellationToken = default)
@ -40,7 +40,7 @@ public class SalesProductRepository : OmsSqlSugarRepository<SalesProduct>, ISale
if (ids.Length == 0) return [];
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<SalesProductPriceFactor>()
.Where(x => !x.IsDeleted && ids.Contains(x.PriceId))
.Where(x => ids.Contains(x.PriceId))
.OrderBy(x => x.SerialNumber)
.ToListAsync(cancellationToken);
}
@ -51,7 +51,7 @@ public class SalesProductRepository : OmsSqlSugarRepository<SalesProduct>, ISale
if (ids.Length == 0) return [];
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<SalesProductPriceDetail>()
.Where(x => !x.IsDeleted && ids.Contains(x.PriceId))
.Where(x => ids.Contains(x.PriceId))
.ToListAsync(cancellationToken);
}
@ -68,13 +68,11 @@ public class SalesProductRepository : OmsSqlSugarRepository<SalesProduct>, ISale
{
var db = await GetDbContextAsync(cancellationToken);
await db.Updateable(price).ExecuteCommandAsync(cancellationToken);
await db.Updateable<SalesProductPriceFactor>()
.SetColumns(x => x.IsDeleted, true)
.Where(x => !x.IsDeleted && x.PriceId == price.Id)
await db.Deleteable<SalesProductPriceFactor>()
.Where(x => x.PriceId == price.Id)
.ExecuteCommandAsync(cancellationToken);
await db.Updateable<SalesProductPriceDetail>()
.SetColumns(x => x.IsDeleted, true)
.Where(x => !x.IsDeleted && x.PriceId == price.Id)
await db.Deleteable<SalesProductPriceDetail>()
.Where(x => x.PriceId == price.Id)
.ExecuteCommandAsync(cancellationToken);
await InsertPriceChildrenAsync(db, price.Id, factors, details, cancellationToken);
}
@ -82,16 +80,13 @@ public class SalesProductRepository : OmsSqlSugarRepository<SalesProduct>, ISale
public async Task DeletePriceAsync(long id, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
await db.Updateable<SalesProductPrice>()
.SetColumns(x => x.IsDeleted, true)
await db.Deleteable<SalesProductPrice>()
.Where(x => x.Id == id)
.ExecuteCommandAsync(cancellationToken);
await db.Updateable<SalesProductPriceFactor>()
.SetColumns(x => x.IsDeleted, true)
await db.Deleteable<SalesProductPriceFactor>()
.Where(x => x.PriceId == id)
.ExecuteCommandAsync(cancellationToken);
await db.Updateable<SalesProductPriceDetail>()
.SetColumns(x => x.IsDeleted, true)
await db.Deleteable<SalesProductPriceDetail>()
.Where(x => x.PriceId == id)
.ExecuteCommandAsync(cancellationToken);
}
@ -101,7 +96,7 @@ public class SalesProductRepository : OmsSqlSugarRepository<SalesProduct>, ISale
var db = await GetDbContextAsync(cancellationToken);
await db.Updateable<SalesProductPrice>()
.SetColumns(x => x.Status, status)
.Where(x => !x.IsDeleted && x.Id == id)
.Where(x => x.Id == id)
.ExecuteCommandAsync(cancellationToken);
}
@ -109,16 +104,16 @@ public class SalesProductRepository : OmsSqlSugarRepository<SalesProduct>, ISale
{
var db = await GetDbContextAsync(cancellationToken);
var oldPrices = await db.Queryable<SalesProductPrice>()
.Where(x => !x.IsDeleted && x.SalesProductId == salesProductId)
.Where(x => x.SalesProductId == salesProductId)
.ToListAsync(cancellationToken);
var oldPriceIds = oldPrices.Select(x => x.Id).ToArray();
if (oldPriceIds.Length > 0)
{
// 批量保存采用全量替换策略,旧价格树先统一软删,避免残留旧明细。
await db.Updateable<SalesProductPrice>().SetColumns(x => x.IsDeleted, true).Where(x => oldPriceIds.Contains(x.Id)).ExecuteCommandAsync(cancellationToken);
await db.Updateable<SalesProductPriceFactor>().SetColumns(x => x.IsDeleted, true).Where(x => oldPriceIds.Contains(x.PriceId)).ExecuteCommandAsync(cancellationToken);
await db.Updateable<SalesProductPriceDetail>().SetColumns(x => x.IsDeleted, true).Where(x => oldPriceIds.Contains(x.PriceId)).ExecuteCommandAsync(cancellationToken);
await db.Deleteable<SalesProductPrice>().Where(x => oldPriceIds.Contains(x.Id)).ExecuteCommandAsync(cancellationToken);
await db.Deleteable<SalesProductPriceFactor>().Where(x => oldPriceIds.Contains(x.PriceId)).ExecuteCommandAsync(cancellationToken);
await db.Deleteable<SalesProductPriceDetail>().Where(x => oldPriceIds.Contains(x.PriceId)).ExecuteCommandAsync(cancellationToken);
}
var priceList = prices.Select(x => new
@ -153,7 +148,7 @@ public class SalesProductRepository : OmsSqlSugarRepository<SalesProduct>, ISale
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<SalesProductAllocationProvider>()
.Where(x => !x.IsDeleted && x.SalesProductId == salesProductId)
.Where(x => x.SalesProductId == salesProductId)
.OrderBy(x => x.SerialNumber)
.ToListAsync(cancellationToken);
}
@ -161,8 +156,8 @@ public class SalesProductRepository : OmsSqlSugarRepository<SalesProduct>, ISale
public async Task ReplaceAllocationProvidersAsync(long salesProductId, IEnumerable<SalesProductAllocationProvider> providers, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
await db.Updateable<SalesProductAllocationProvider>().SetColumns(x => x.IsDeleted, true)
.Where(x => !x.IsDeleted && x.SalesProductId == salesProductId)
await db.Deleteable<SalesProductAllocationProvider>()
.Where(x => x.SalesProductId == salesProductId)
.ExecuteCommandAsync(cancellationToken);
var items = providers.Select(x => { x.Id = 0; x.SalesProductId = salesProductId; return x; }).ToArray();
if (items.Length > 0)
@ -175,7 +170,7 @@ public class SalesProductRepository : OmsSqlSugarRepository<SalesProduct>, ISale
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<SalesProductPublishRecord>()
.Where(x => !x.IsDeleted && x.SalesProductId == salesProductId && x.OperatorType == operatorType)
.Where(x => x.SalesProductId == salesProductId && x.OperatorType == operatorType)
.OrderBy(x => x.PublishTime, SqlSugar.OrderByType.Desc)
.ToPageListAsync(pageIndex, pageSize, cancellationToken);
}
@ -184,7 +179,7 @@ public class SalesProductRepository : OmsSqlSugarRepository<SalesProduct>, ISale
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<SalesProductPublishRecord>()
.Where(x => !x.IsDeleted && x.SalesProductId == salesProductId && x.OperatorType == operatorType)
.Where(x => x.SalesProductId == salesProductId && x.OperatorType == operatorType)
.CountAsync(cancellationToken);
}
@ -197,7 +192,7 @@ public class SalesProductRepository : OmsSqlSugarRepository<SalesProduct>, ISale
public async Task<SalesProductPublishRecord?> GetPublishRecordByIdAsync(long id, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<SalesProductPublishRecord>().FirstAsync(x => !x.IsDeleted && x.Id == id, cancellationToken);
return await db.Queryable<SalesProductPublishRecord>().FirstAsync(x => x.Id == id, cancellationToken);
}
private static async Task InsertPriceChildrenAsync(

View File

@ -10,25 +10,25 @@ public class ServiceChannelRepository : OmsSqlSugarRepository<ServiceChannel>, I
{
public Task<ServiceChannel?> GetByChannelCodeAsync(string channelCode, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.ChannelCode == channelCode, cancellationToken);
return FirstOrDefaultAsync(x => x.ChannelCode == channelCode, cancellationToken);
}
public Task<bool> HasChannelCodeAsync(string channelCode, CancellationToken cancellationToken = default)
{
return AnyAsync(x => !x.IsDeleted && x.ChannelCode == channelCode, cancellationToken);
return AnyAsync(x => x.ChannelCode == channelCode, cancellationToken);
}
public async Task<List<ServiceChannelGroup>> GetGroupsAsync(CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<ServiceChannelGroup>().Where(x => !x.IsDeleted).ToListAsync(cancellationToken);
return await db.Queryable<ServiceChannelGroup>().ToListAsync(cancellationToken);
}
public async Task<List<ServiceChannelPrice>> GetPricesAsync(long serviceChannelId, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<ServiceChannelPrice>()
.Where(x => !x.IsDeleted && x.ServiceChannelId == serviceChannelId)
.Where(x => x.ServiceChannelId == serviceChannelId)
.OrderBy(x => x.SerialNumber)
.ToListAsync(cancellationToken);
}
@ -37,7 +37,7 @@ public class ServiceChannelRepository : OmsSqlSugarRepository<ServiceChannel>, I
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<ServiceChannelPrice>()
.FirstAsync(x => !x.IsDeleted && x.Id == id, cancellationToken);
.FirstAsync(x => x.Id == id, cancellationToken);
}
public async Task<List<ServiceChannelPriceFactor>> GetPriceFactorsAsync(IEnumerable<long> priceIds, CancellationToken cancellationToken = default)
@ -46,7 +46,7 @@ public class ServiceChannelRepository : OmsSqlSugarRepository<ServiceChannel>, I
if (ids.Length == 0) return [];
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<ServiceChannelPriceFactor>()
.Where(x => !x.IsDeleted && ids.Contains(x.PriceId))
.Where(x => ids.Contains(x.PriceId))
.OrderBy(x => x.SerialNumber)
.ToListAsync(cancellationToken);
}
@ -57,7 +57,7 @@ public class ServiceChannelRepository : OmsSqlSugarRepository<ServiceChannel>, I
if (ids.Length == 0) return [];
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<ServiceChannelPriceDetail>()
.Where(x => !x.IsDeleted && ids.Contains(x.PriceId))
.Where(x => ids.Contains(x.PriceId))
.ToListAsync(cancellationToken);
}
@ -74,13 +74,11 @@ public class ServiceChannelRepository : OmsSqlSugarRepository<ServiceChannel>, I
{
var db = await GetDbContextAsync(cancellationToken);
await db.Updateable(price).ExecuteCommandAsync(cancellationToken);
await db.Updateable<ServiceChannelPriceFactor>()
.SetColumns(x => x.IsDeleted, true)
.Where(x => !x.IsDeleted && x.PriceId == price.Id)
await db.Deleteable<ServiceChannelPriceFactor>()
.Where(x => x.PriceId == price.Id)
.ExecuteCommandAsync(cancellationToken);
await db.Updateable<ServiceChannelPriceDetail>()
.SetColumns(x => x.IsDeleted, true)
.Where(x => !x.IsDeleted && x.PriceId == price.Id)
await db.Deleteable<ServiceChannelPriceDetail>()
.Where(x => x.PriceId == price.Id)
.ExecuteCommandAsync(cancellationToken);
await InsertPriceChildrenAsync(db, price.Id, factors, details, cancellationToken);
}
@ -88,16 +86,13 @@ public class ServiceChannelRepository : OmsSqlSugarRepository<ServiceChannel>, I
public async Task DeletePriceAsync(long id, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
await db.Updateable<ServiceChannelPrice>()
.SetColumns(x => x.IsDeleted, true)
await db.Deleteable<ServiceChannelPrice>()
.Where(x => x.Id == id)
.ExecuteCommandAsync(cancellationToken);
await db.Updateable<ServiceChannelPriceFactor>()
.SetColumns(x => x.IsDeleted, true)
await db.Deleteable<ServiceChannelPriceFactor>()
.Where(x => x.PriceId == id)
.ExecuteCommandAsync(cancellationToken);
await db.Updateable<ServiceChannelPriceDetail>()
.SetColumns(x => x.IsDeleted, true)
await db.Deleteable<ServiceChannelPriceDetail>()
.Where(x => x.PriceId == id)
.ExecuteCommandAsync(cancellationToken);
}
@ -107,7 +102,7 @@ public class ServiceChannelRepository : OmsSqlSugarRepository<ServiceChannel>, I
var db = await GetDbContextAsync(cancellationToken);
await db.Updateable<ServiceChannelPrice>()
.SetColumns(x => x.Status, status)
.Where(x => !x.IsDeleted && x.Id == id)
.Where(x => x.Id == id)
.ExecuteCommandAsync(cancellationToken);
}
@ -115,16 +110,16 @@ public class ServiceChannelRepository : OmsSqlSugarRepository<ServiceChannel>, I
{
var db = await GetDbContextAsync(cancellationToken);
var oldPrices = await db.Queryable<ServiceChannelPrice>()
.Where(x => !x.IsDeleted && x.ServiceChannelId == serviceChannelId)
.Where(x => x.ServiceChannelId == serviceChannelId)
.ToListAsync(cancellationToken);
var oldPriceIds = oldPrices.Select(x => x.Id).ToArray();
if (oldPriceIds.Length > 0)
{
// 批量保存时先整棵旧买价树软删,再写入新的快照数据。
await db.Updateable<ServiceChannelPrice>().SetColumns(x => x.IsDeleted, true).Where(x => oldPriceIds.Contains(x.Id)).ExecuteCommandAsync(cancellationToken);
await db.Updateable<ServiceChannelPriceFactor>().SetColumns(x => x.IsDeleted, true).Where(x => oldPriceIds.Contains(x.PriceId)).ExecuteCommandAsync(cancellationToken);
await db.Updateable<ServiceChannelPriceDetail>().SetColumns(x => x.IsDeleted, true).Where(x => oldPriceIds.Contains(x.PriceId)).ExecuteCommandAsync(cancellationToken);
await db.Deleteable<ServiceChannelPrice>().Where(x => oldPriceIds.Contains(x.Id)).ExecuteCommandAsync(cancellationToken);
await db.Deleteable<ServiceChannelPriceFactor>().Where(x => oldPriceIds.Contains(x.PriceId)).ExecuteCommandAsync(cancellationToken);
await db.Deleteable<ServiceChannelPriceDetail>().Where(x => oldPriceIds.Contains(x.PriceId)).ExecuteCommandAsync(cancellationToken);
}
var priceList = prices.Select(x => new
@ -159,7 +154,7 @@ public class ServiceChannelRepository : OmsSqlSugarRepository<ServiceChannel>, I
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<ServiceChannelPublishRecord>()
.Where(x => !x.IsDeleted && x.ServiceChannelId == serviceChannelId && x.OperatorType == operatorType)
.Where(x => x.ServiceChannelId == serviceChannelId && x.OperatorType == operatorType)
.OrderBy(x => x.PublishTime, SqlSugar.OrderByType.Desc)
.ToPageListAsync(pageIndex, pageSize, cancellationToken);
}
@ -168,7 +163,7 @@ public class ServiceChannelRepository : OmsSqlSugarRepository<ServiceChannel>, I
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<ServiceChannelPublishRecord>()
.Where(x => !x.IsDeleted && x.ServiceChannelId == serviceChannelId && x.OperatorType == operatorType)
.Where(x => x.ServiceChannelId == serviceChannelId && x.OperatorType == operatorType)
.CountAsync(cancellationToken);
}
@ -181,7 +176,7 @@ public class ServiceChannelRepository : OmsSqlSugarRepository<ServiceChannel>, I
public async Task<ServiceChannelPublishRecord?> GetPublishRecordByIdAsync(long id, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<ServiceChannelPublishRecord>().FirstAsync(x => !x.IsDeleted && x.Id == id, cancellationToken);
return await db.Queryable<ServiceChannelPublishRecord>().FirstAsync(x => x.Id == id, cancellationToken);
}
private static async Task InsertPriceChildrenAsync(

View File

@ -9,19 +9,19 @@ public class WeightRoundingRepository : OmsSqlSugarRepository<WeightRounding>, I
{
public Task<WeightRounding?> GetByAppKeyAndNameAsync(string appKey, string name, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.AppKey == appKey && x.Name == name, cancellationToken);
return FirstOrDefaultAsync(x => x.AppKey == appKey && x.Name == name, cancellationToken);
}
public Task<bool> ExistsNameAsync(string appKey, string name, CancellationToken cancellationToken = default)
{
return AnyAsync(x => !x.IsDeleted && x.AppKey == appKey && x.Name == name, cancellationToken);
return AnyAsync(x => x.AppKey == appKey && x.Name == name, cancellationToken);
}
public async Task<List<WeightRoundingInfo>> GetInfosAsync(long roundingId, int pageIndex, int pageSize, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<WeightRoundingInfo>()
.Where(x => !x.IsDeleted && x.RoundingId == roundingId)
.Where(x => x.RoundingId == roundingId)
.OrderBy(x => x.Id, SqlSugar.OrderByType.Desc)
.ToPageListAsync(pageIndex, pageSize, cancellationToken);
}
@ -29,7 +29,7 @@ public class WeightRoundingRepository : OmsSqlSugarRepository<WeightRounding>, I
public async Task<long> CountInfosAsync(long roundingId, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<WeightRoundingInfo>().Where(x => !x.IsDeleted && x.RoundingId == roundingId).CountAsync(cancellationToken);
return await db.Queryable<WeightRoundingInfo>().Where(x => x.RoundingId == roundingId).CountAsync(cancellationToken);
}
public async Task<WeightRoundingInfo> InsertInfoAsync(WeightRoundingInfo info, CancellationToken cancellationToken = default)
@ -41,7 +41,7 @@ public class WeightRoundingRepository : OmsSqlSugarRepository<WeightRounding>, I
public async Task<WeightRoundingInfo?> GetInfoByIdAsync(long id, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<WeightRoundingInfo>().FirstAsync(x => !x.IsDeleted && x.Id == id, cancellationToken);
return await db.Queryable<WeightRoundingInfo>().FirstAsync(x => x.Id == id, cancellationToken);
}
public async Task UpdateInfoAsync(WeightRoundingInfo info, CancellationToken cancellationToken = default)
@ -53,6 +53,6 @@ public class WeightRoundingRepository : OmsSqlSugarRepository<WeightRounding>, I
public async Task DeleteInfoAsync(long id, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
await db.Updateable<WeightRoundingInfo>().SetColumns(x => x.IsDeleted, true).Where(x => x.Id == id).ExecuteCommandAsync(cancellationToken);
await db.Deleteable<WeightRoundingInfo>().Where(x => x.Id == id).ExecuteCommandAsync(cancellationToken);
}
}

View File

@ -9,19 +9,19 @@ public class WeightRuleRepository : OmsSqlSugarRepository<WeightRule>, IWeightRu
{
public Task<WeightRule?> GetByAppKeyAndNameAsync(string appKey, string name, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.AppKey == appKey && x.Name == name, cancellationToken);
return FirstOrDefaultAsync(x => x.AppKey == appKey && x.Name == name, cancellationToken);
}
public Task<bool> ExistsNameAsync(string appKey, string name, CancellationToken cancellationToken = default)
{
return AnyAsync(x => !x.IsDeleted && x.AppKey == appKey && x.Name == name, cancellationToken);
return AnyAsync(x => x.AppKey == appKey && x.Name == name, cancellationToken);
}
public async Task<List<WeightRuleInfo>> GetInfosAsync(long ruleId, int pageIndex, int pageSize, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<WeightRuleInfo>()
.Where(x => !x.IsDeleted && x.RuleId == ruleId)
.Where(x => x.RuleId == ruleId)
.OrderBy(x => x.Id, SqlSugar.OrderByType.Desc)
.ToPageListAsync(pageIndex, pageSize, cancellationToken);
}
@ -29,7 +29,7 @@ public class WeightRuleRepository : OmsSqlSugarRepository<WeightRule>, IWeightRu
public async Task<long> CountInfosAsync(long ruleId, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<WeightRuleInfo>().Where(x => !x.IsDeleted && x.RuleId == ruleId).CountAsync(cancellationToken);
return await db.Queryable<WeightRuleInfo>().Where(x => x.RuleId == ruleId).CountAsync(cancellationToken);
}
public async Task<WeightRuleInfo> InsertInfoAsync(WeightRuleInfo info, CancellationToken cancellationToken = default)
@ -41,7 +41,7 @@ public class WeightRuleRepository : OmsSqlSugarRepository<WeightRule>, IWeightRu
public async Task<WeightRuleInfo?> GetInfoByIdAsync(long id, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<WeightRuleInfo>().FirstAsync(x => !x.IsDeleted && x.Id == id, cancellationToken);
return await db.Queryable<WeightRuleInfo>().FirstAsync(x => x.Id == id, cancellationToken);
}
public async Task UpdateInfoAsync(WeightRuleInfo info, CancellationToken cancellationToken = default)
@ -53,6 +53,6 @@ public class WeightRuleRepository : OmsSqlSugarRepository<WeightRule>, IWeightRu
public async Task DeleteInfoAsync(long id, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
await db.Updateable<WeightRuleInfo>().SetColumns(x => x.IsDeleted, true).Where(x => x.Id == id).ExecuteCommandAsync(cancellationToken);
await db.Deleteable<WeightRuleInfo>().Where(x => x.Id == id).ExecuteCommandAsync(cancellationToken);
}
}

View File

@ -9,26 +9,26 @@ public class CustomerRepository : OmsSqlSugarRepository<Customer>, ICustomerRepo
{
public Task<Customer?> GetByCustomerCodeAsync(string customerCode, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.CustomerCode == customerCode, cancellationToken);
return FirstOrDefaultAsync(x => x.CustomerCode == customerCode, cancellationToken);
}
public Task<Customer?> GetByPhoneAsync(string phone, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.Phone == phone, cancellationToken);
return FirstOrDefaultAsync(x => x.Phone == phone, cancellationToken);
}
public Task<Customer?> GetByEmailAsync(string email, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.Email == email, cancellationToken);
return FirstOrDefaultAsync(x => x.Email == email, cancellationToken);
}
public Task<Customer?> GetByWechatOpenidAsync(string wechatOpenid, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.WechatOpenid == wechatOpenid, cancellationToken);
return FirstOrDefaultAsync(x => x.WechatOpenid == wechatOpenid, cancellationToken);
}
public Task<bool> ExistsPhoneAsync(string phone, CancellationToken cancellationToken = default)
{
return AnyAsync(x => !x.IsDeleted && x.Phone == phone, cancellationToken);
return AnyAsync(x => x.Phone == phone, cancellationToken);
}
}

View File

@ -9,16 +9,16 @@ public class CustomerSubAccountRepository : OmsSqlSugarRepository<CustomerSubAcc
{
public Task<CustomerSubAccount?> GetBySubAccountCodeAsync(string subAccountCode, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.SubAccountCode == subAccountCode, cancellationToken);
return FirstOrDefaultAsync(x => x.SubAccountCode == subAccountCode, cancellationToken);
}
public Task<CustomerSubAccount?> GetBySubPhoneAsync(string subPhone, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.SubPhone == subPhone, cancellationToken);
return FirstOrDefaultAsync(x => x.SubPhone == subPhone, cancellationToken);
}
public Task<bool> ExistsSubPhoneAsync(string subPhone, CancellationToken cancellationToken = default)
{
return AnyAsync(x => !x.IsDeleted && x.SubPhone == subPhone, cancellationToken);
return AnyAsync(x => x.SubPhone == subPhone, cancellationToken);
}
}

View File

@ -10,7 +10,7 @@ public class InboundRecordRepository : OmsSqlSugarRepository<InboundRecord>, IIn
public async Task<InboundRecord?> GetLatestByWaybillNoAsync(string waybillNo, CancellationToken cancellationToken = default)
{
var list = await GetPagedListAsync(
x => !x.IsDeleted && x.WaybillNo == waybillNo,
x => x.WaybillNo == waybillNo,
1,
1,
new Dictionary<string, bool> { [nameof(InboundRecord.OperateTime)] = false, [nameof(InboundRecord.Id)] = false },

View File

@ -10,7 +10,7 @@ public class LabelPrintRecordRepository : OmsSqlSugarRepository<LabelPrintRecord
public async Task<LabelPrintRecord?> GetLatestByWaybillNoAsync(string waybillNo, CancellationToken cancellationToken = default)
{
var list = await GetPagedListAsync(
x => !x.IsDeleted && x.WaybillNo == waybillNo,
x => x.WaybillNo == waybillNo,
1,
1,
new Dictionary<string, bool> { [nameof(LabelPrintRecord.PrintTime)] = false, [nameof(LabelPrintRecord.Id)] = false },

View File

@ -10,7 +10,7 @@ public class OutboundRecordRepository : OmsSqlSugarRepository<OutboundRecord>, I
public async Task<OutboundRecord?> GetLatestByWaybillNoAsync(string waybillNo, CancellationToken cancellationToken = default)
{
var list = await GetPagedListAsync(
x => !x.IsDeleted && x.WaybillNo == waybillNo,
x => x.WaybillNo == waybillNo,
1,
1,
new Dictionary<string, bool> { [nameof(OutboundRecord.OperateTime)] = false, [nameof(OutboundRecord.Id)] = false },

View File

@ -9,27 +9,27 @@ public class OrderRepository : OmsSqlSugarRepository<Order>, IOrderRepository, I
{
public Task<Order?> GetByServiceNoAsync(string serviceNo, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.ServiceNo == serviceNo, cancellationToken);
return FirstOrDefaultAsync(x => x.ServiceNo == serviceNo, cancellationToken);
}
public Task<bool> HasServiceNoAsync(string serviceNo, CancellationToken cancellationToken = default)
{
return AnyAsync(x => !x.IsDeleted && x.ServiceNo == serviceNo, cancellationToken);
return AnyAsync(x => x.ServiceNo == serviceNo, cancellationToken);
}
public Task<Order?> GetByTrackNoAsync(string trackNo, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.TrackNo == trackNo, cancellationToken);
return FirstOrDefaultAsync(x => x.TrackNo == trackNo, cancellationToken);
}
public Task<Order?> GetByCustomerAndClientNoAsync(long customerId, string clientNo, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.CustomerId == customerId && x.ClientNo == clientNo, cancellationToken);
return FirstOrDefaultAsync(x => x.CustomerId == customerId && x.ClientNo == clientNo, cancellationToken);
}
public Task<Order?> GetByRequestIdAsync(string requestId, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.RequestId == requestId, cancellationToken);
return FirstOrDefaultAsync(x => x.RequestId == requestId, cancellationToken);
}
public async Task<List<OrderSender>> GetSendersByOrderIdsAsync(IEnumerable<long> orderIds, CancellationToken cancellationToken = default)
@ -42,7 +42,7 @@ public class OrderRepository : OmsSqlSugarRepository<Order>, IOrderRepository, I
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<OrderSender>()
.Where(x => !x.IsDeleted && ids.Contains(x.OrderId))
.Where(x => ids.Contains(x.OrderId))
.ToListAsync(cancellationToken);
}
@ -56,7 +56,7 @@ public class OrderRepository : OmsSqlSugarRepository<Order>, IOrderRepository, I
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<OrderRecipient>()
.Where(x => !x.IsDeleted && ids.Contains(x.OrderId))
.Where(x => ids.Contains(x.OrderId))
.ToListAsync(cancellationToken);
}
@ -70,7 +70,7 @@ public class OrderRepository : OmsSqlSugarRepository<Order>, IOrderRepository, I
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<OrderDeclaration>()
.Where(x => !x.IsDeleted && ids.Contains(x.OrderId))
.Where(x => ids.Contains(x.OrderId))
.ToListAsync(cancellationToken);
}
@ -84,7 +84,7 @@ public class OrderRepository : OmsSqlSugarRepository<Order>, IOrderRepository, I
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<OrderWeight>()
.Where(x => !x.IsDeleted && ids.Contains(x.OrderId))
.Where(x => ids.Contains(x.OrderId))
.ToListAsync(cancellationToken);
}

View File

@ -9,19 +9,19 @@ public class OrderTaskRepository : OmsSqlSugarRepository<OrderTask>, IOrderTaskR
{
public Task<OrderTask?> GetByCustomerAndIdAsync(long customerId, long id, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.CustomerId == customerId && x.Id == id, cancellationToken);
return FirstOrDefaultAsync(x => x.CustomerId == customerId && x.Id == id, cancellationToken);
}
public Task<bool> ExistsAsync(long id, CancellationToken cancellationToken = default)
{
return AnyAsync(x => !x.IsDeleted && x.Id == id, cancellationToken);
return AnyAsync(x => x.Id == id, cancellationToken);
}
public async Task<List<OrderTaskFail>> GetFailListAsync(long taskId, CancellationToken cancellationToken = default)
{
var db = await GetDbContextAsync(cancellationToken);
return await db.Queryable<OrderTaskFail>()
.Where(x => !x.IsDeleted && x.TaskId == taskId)
.Where(x => x.TaskId == taskId)
.OrderBy(x => x.RowNumber)
.ToListAsync(cancellationToken);
}

View File

@ -9,11 +9,11 @@ public class OrderTemplateRepository : OmsSqlSugarRepository<OrderTemplate>, IOr
{
public Task<OrderTemplate?> GetByTypeAndTemplateKeyAsync(string type, string templateKey, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.Type == type && x.TemplateKey == templateKey, cancellationToken);
return FirstOrDefaultAsync(x => x.Type == type && x.TemplateKey == templateKey, cancellationToken);
}
public Task<OrderTemplate?> GetByCustomerAndNameAsync(long customerId, string name, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.CustomerId == customerId && x.Name == name, cancellationToken);
return FirstOrDefaultAsync(x => x.CustomerId == customerId && x.Name == name, cancellationToken);
}
}

View File

@ -9,11 +9,11 @@ public class RechargeRecordRepository : OmsSqlSugarRepository<RechargeRecord>, I
{
public Task<RechargeRecord?> GetBySerialNumberAsync(string serialNumber, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.SerialNumber == serialNumber, cancellationToken);
return FirstOrDefaultAsync(x => x.SerialNumber == serialNumber, cancellationToken);
}
public Task<bool> ExistsSerialNumberAsync(string serialNumber, CancellationToken cancellationToken = default)
{
return AnyAsync(x => !x.IsDeleted && x.SerialNumber == serialNumber, cancellationToken);
return AnyAsync(x => x.SerialNumber == serialNumber, cancellationToken);
}
}

View File

@ -9,11 +9,11 @@ public class WarehouseAddressRepository : OmsSqlSugarRepository<WarehouseAddress
{
public Task<WarehouseAddress?> GetByWarehouseNameAsync(string warehouseName, CancellationToken cancellationToken = default)
{
return FirstOrDefaultAsync(x => !x.IsDeleted && x.WarehouseName == warehouseName, cancellationToken);
return FirstOrDefaultAsync(x => x.WarehouseName == warehouseName, cancellationToken);
}
public Task<bool> ExistsWarehouseNameAsync(string warehouseName, CancellationToken cancellationToken = default)
{
return AnyAsync(x => !x.IsDeleted && x.WarehouseName == warehouseName, cancellationToken);
return AnyAsync(x => x.WarehouseName == warehouseName, cancellationToken);
}
}