From e2afc4b4bceff9b2386ef7374b3d3a77c4996448 Mon Sep 17 00:00:00 2001 From: mahao Date: Fri, 15 Sep 2023 10:44:26 +0800 Subject: [PATCH] up --- .../Entities/Prices/PriceListAppService.cs | 9 ++++++++- .../Entities/Prices/PriceListAppServiceBJ.cs | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs index f36d3562..2299c805 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Shouldly; +using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Caching; using Win.Abp.Snowflakes; @@ -255,11 +256,17 @@ public class PriceListAppService : SettleAccountApplicationBase entity.IsCancel = input.IsCancel; if (entity.IsCancel == false) { - var ddd = _settleAccountDbContext.Set() + var existsPriceList = _settleAccountDbContext.Set() .Where(t => t.LU == entity.LU) .Where(t => t.IsCancel == false) .Where(t => t.Id != entity.Id) .ToList(); + + var existsPrice = existsPriceList.Find(t => (entity.BeginTime > t.BeginTime && entity.BeginTime < t.EndTime) || (t.BeginTime > entity.BeginTime && t.BeginTime < entity.EndTime)); + if (existsPrice != null) + { + throw new UserFriendlyException($"无法启用!此记录启用时间区间与区间【{existsPrice.BeginTime:yyyy-MM-dd}至{existsPrice.EndTime:yyyy-MM-dd}】存在交集", "400"); + } } _settleAccountDbContext.Set().Update(entity); var dto = ObjectMapper.Map(entity); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs index 63bed1c3..e8c89949 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Shouldly; +using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Caching; using Win.Abp.Snowflakes; @@ -211,6 +212,20 @@ public class PriceListAppServiceBJ : SettleAccountApplicationBase { var entity = await _settleAccountDbContext.Set().FindAsync(input.Id).ConfigureAwait(false); entity.IsCancel = input.IsCancel; + if (entity.IsCancel == false) + { + var existsPriceBjList = _settleAccountDbContext.Set() + .Where(t => t.LU == entity.LU) + .Where(t => t.IsCancel == false) + .Where(t => t.Id != entity.Id) + .ToList(); + + var existsPriceBj = existsPriceBjList.Find(t => (entity.BeginDate >= t.BeginDate && entity.BeginDate < t.EndDate) || (t.BeginDate >= entity.BeginDate && t.BeginDate < entity.EndDate)); + if (existsPriceBj != null) + { + throw new UserFriendlyException($"无法启用!此记录启用时间区间与区间【{existsPrice.BeginTime:yyyy-MM-dd}至{existsPrice.EndTime:yyyy-MM-dd}】存在交集", "400"); + } + } _settleAccountDbContext.Set().Update(entity); var dto = ObjectMapper.Map(entity); return dto;