|
|
@ -276,53 +276,35 @@ namespace Win.Sfs.SettleAccount.Entities.Prices |
|
|
|
/// 修改实体
|
|
|
|
/// 修改作废状态
|
|
|
|
/// </summary>
|
|
|
|
//[HttpPost]
|
|
|
|
//public async Task<PriceListDto> UpdateListAsync(List<Guid> p_list)
|
|
|
|
//{
|
|
|
|
// foreach (var itm in p_list)
|
|
|
|
// {
|
|
|
|
// var entity = await _settleAccountDbContext.Set<PriceList>().FindAsync(itm).ConfigureAwait(false);
|
|
|
|
// entity.IsCancel = input.IsCancel;
|
|
|
|
// if (entity.IsCancel == false)
|
|
|
|
// {
|
|
|
|
// var existPriceList = _settleAccountDbContext.Set<PriceList>()
|
|
|
|
// .Where(t => t.LU == entity.LU)
|
|
|
|
// .Where(t => t.IsCancel == false)
|
|
|
|
// .Where(t => t.Id != entity.Id)
|
|
|
|
// .ToList();
|
|
|
|
|
|
|
|
// var existPrice = existPriceList.Find(t => (entity.BeginTime >= t.BeginTime && entity.BeginTime < t.EndTime) || (t.BeginTime >= entity.BeginTime && t.BeginTime < entity.EndTime));
|
|
|
|
// if (existPrice != null)
|
|
|
|
// {
|
|
|
|
// throw new UserFriendlyException($"无法启用!此记录启用时间区间与区间【{existPrice.BeginTime:yyyy-MM-dd}至{existPrice.EndTime:yyyy-MM-dd}】存在交集", "400");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
[HttpPost] |
|
|
|
public async Task<PriceListDto> UpdateListAsync(PriceListUpdateDto input) |
|
|
|
{ |
|
|
|
List<PriceList> plist = new List<PriceList>(); |
|
|
|
foreach (var itm in input.Guids) |
|
|
|
{ |
|
|
|
var entity = await _settleAccountDbContext.Set<PriceList>().FindAsync(itm).ConfigureAwait(false); |
|
|
|
entity.IsCancel = input.IsCancel; |
|
|
|
if (entity.IsCancel == false) |
|
|
|
{ |
|
|
|
var existPriceList = _settleAccountDbContext.Set<PriceList>() |
|
|
|
.Where(t => t.LU == entity.LU) |
|
|
|
.Where(t => t.IsCancel == false) |
|
|
|
.Where(t => t.Id != entity.Id) |
|
|
|
.ToList(); |
|
|
|
|
|
|
|
// var entity = await _settleAccountDbContext.Set<PriceList>().FindAsync(input.Id).ConfigureAwait(false);
|
|
|
|
// entity.IsCancel = input.IsCancel;
|
|
|
|
// if (entity.IsCancel == false)
|
|
|
|
// {
|
|
|
|
// var existPriceList = _settleAccountDbContext.Set<PriceList>()
|
|
|
|
// .Where(t => t.LU == entity.LU)
|
|
|
|
// .Where(t => t.IsCancel == false)
|
|
|
|
// .Where(t => t.Id != entity.Id)
|
|
|
|
// .ToList();
|
|
|
|
var existPrice = existPriceList.Find(t => (entity.BeginTime >= t.BeginTime && entity.BeginTime < t.EndTime) || (t.BeginTime >= entity.BeginTime && t.BeginTime < entity.EndTime)); |
|
|
|
if (existPrice != null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"无法启用!此记录启用时间区间与区间【{existPrice.BeginTime:yyyy-MM-dd}至{existPrice.EndTime:yyyy-MM-dd}】存在交集", "400"); |
|
|
|
} |
|
|
|
} |
|
|
|
plist.Add(entity); |
|
|
|
} |
|
|
|
|
|
|
|
// var existPrice = existPriceList.Find(t => (entity.BeginTime >= t.BeginTime && entity.BeginTime < t.EndTime) || (t.BeginTime >= entity.BeginTime && t.BeginTime < entity.EndTime));
|
|
|
|
// if (existPrice != null)
|
|
|
|
// {
|
|
|
|
// throw new UserFriendlyException($"无法启用!此记录启用时间区间与区间【{existPrice.BeginTime:yyyy-MM-dd}至{existPrice.EndTime:yyyy-MM-dd}】存在交集", "400");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false);
|
|
|
|
// var dto = ObjectMapper.Map<PriceList, PriceListDto>(entity);
|
|
|
|
// return dto;
|
|
|
|
//}
|
|
|
|
await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false); |
|
|
|
var dto = ObjectMapper.Map<PriceList, PriceListDto>(plist.FirstOrDefault()); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|