|
|
@ -152,8 +152,6 @@ namespace Win.Sfs.SettleAccount.Bases |
|
|
|
throw new UserFriendlyException($"扣减单状态不是【客户已收票】状态", "400"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return await InvokePD(invlist,p_list, _service, false); |
|
|
|
} |
|
|
|
[HttpPost] |
|
|
@ -193,47 +191,45 @@ namespace Win.Sfs.SettleAccount.Bases |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"扣减单状态不是【已扣减】状态", "400"); |
|
|
|
} |
|
|
|
return await InvokePD(invlist,p_list, _service,true); |
|
|
|
return await InvokePD(invlist, p_list, _service, true); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 调用扣减
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="p_list"></param>
|
|
|
|
/// <param name="p_service"></param>
|
|
|
|
/// <param name="isback"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
|
[UnitOfWork(false)] |
|
|
|
protected async Task<string> InvokePD<T>(List<T> p_invs,List<string> p_list, TaskJobService p_service, bool isback=false) where T:PD_BASE_MAIN |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 调用扣减
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="p_list"></param>
|
|
|
|
/// <param name="p_service"></param>
|
|
|
|
/// <param name="isback"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
|
[UnitOfWork(false)] |
|
|
|
protected async Task<string> InvokePD<T>(List<T> p_invs, List<string> p_list, TaskJobService p_service, bool isback = false) where T : PD_BASE_MAIN |
|
|
|
{ |
|
|
|
var invlist = p_invs; |
|
|
|
// var invlist=_repository.Where(p=>p_list.Contains(p.BillNum)).ToList();
|
|
|
|
var states= invlist.Select(p => p.State).Distinct().ToList(); |
|
|
|
// var invlist=_repository.Where(p=>p_list.Contains(p.BillNum)).ToList();
|
|
|
|
var states = invlist.Select(p => p.State).Distinct().ToList(); |
|
|
|
if (states.Count > 1) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"发票不是同一状态", "400"); |
|
|
|
} |
|
|
|
var first = invlist.FirstOrDefault();//发票状态
|
|
|
|
|
|
|
|
if(first.State != SettleBillState.客户已收票 && first.State != SettleBillState.已扣减) |
|
|
|
if (first.State != SettleBillState.客户已收票 && first.State != SettleBillState.已扣减) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"当前发票状态不是【客户已收票】或【已扣减状态】不能进行出库扣减或撤销扣减操作", "400"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var detailist = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList(); |
|
|
|
var first1=detailist.FirstOrDefault(); |
|
|
|
var first1 = detailist.FirstOrDefault(); |
|
|
|
List<CustomCondition> customConditionList = new List<CustomCondition>(); |
|
|
|
customConditionList.Add(new CustomCondition() { Name = "BillNumList", Value = string.Join(",", p_list) }); |
|
|
|
customConditionList.Add(new CustomCondition() { Name = "Type", Value =first1.BusinessType.ToString() }); |
|
|
|
customConditionList.Add(new CustomCondition() { Name = "Type", Value = first1.BusinessType.ToString() }); |
|
|
|
if (isback == false) |
|
|
|
{ |
|
|
|
customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "out" }); |
|
|
@ -243,14 +239,14 @@ namespace Win.Sfs.SettleAccount.Bases |
|
|
|
customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "in" }); |
|
|
|
} |
|
|
|
var ls = _repository.Where(p => p_list.Contains(p.BillNum)).ToList(); |
|
|
|
var lst=new List<TEntity>(); |
|
|
|
var lst = new List<TEntity>(); |
|
|
|
if (isback == false) |
|
|
|
{ |
|
|
|
lst = ls.Where(p => (p.State == SettleBillState.已提交扣减 || p.State == SettleBillState.已扣减)).ToList(); |
|
|
|
lst = ls.Where(p => (p.State == SettleBillState.扣减进行中 || p.State == SettleBillState.已扣减)).ToList(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
lst = ls.Where(p => (p.State == SettleBillState.已提交撤销扣减|| p.State == SettleBillState.客户已收票)).ToList(); |
|
|
|
lst = ls.Where(p => (p.State == SettleBillState.撤销扣减进行中 || p.State == SettleBillState.客户已收票)).ToList(); |
|
|
|
} |
|
|
|
if (lst.Count() > 0) |
|
|
|
{ |
|
|
@ -260,11 +256,11 @@ namespace Win.Sfs.SettleAccount.Bases |
|
|
|
{ |
|
|
|
if (isback == false) |
|
|
|
{ |
|
|
|
item.State = SettleBillState.已提交扣减; |
|
|
|
item.State = SettleBillState.扣减进行中; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
item.State = SettleBillState.已提交撤销扣减; |
|
|
|
item.State = SettleBillState.撤销扣减进行中; |
|
|
|
} |
|
|
|
} |
|
|
|
await _repository.DbContext.BulkUpdateAsync(ls); |
|
|
|