Browse Source

更新扣减逻辑

master
学 赵 1 year ago
parent
commit
de73b69c2a
  1. 38
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs

38
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs

@ -140,7 +140,21 @@ namespace Win.Sfs.SettleAccount.Bases
[UnitOfWork(false)]
public virtual async Task<string> ApprovalPassed(List<string> p_list)
{
return await InvokePD(p_list, _service);
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.)
{
throw new UserFriendlyException($"扣减单状态不是【客户已收票】状态", "400");
}
return await InvokePD(invlist,p_list, _service, false);
}
[HttpPost]
[UnitOfWork(false)]
@ -150,7 +164,7 @@ namespace Win.Sfs.SettleAccount.Bases
var states = invlist.Select(p => p.State).Distinct().ToList();
if (states.Count > 1)
{
throw new UserFriendlyException($"发票不是同一状态", "400");
throw new UserFriendlyException($"扣减单不是同一状态", "400");
}
var first = invlist.FirstOrDefault();//发票状态
if (first.State == SettleBillState.)
@ -175,7 +189,11 @@ namespace Win.Sfs.SettleAccount.Bases
}
else
{
return await InvokePD(p_list, _service);
if (first.State != SettleBillState.)
{
throw new UserFriendlyException($"扣减单状态不是【已扣减】状态", "400");
}
return await InvokePD(invlist,p_list, _service,true);
}
}
@ -193,9 +211,10 @@ namespace Win.Sfs.SettleAccount.Bases
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
[UnitOfWork(false)]
protected async Task<string> InvokePD(List<string> p_list, TaskJobService p_service, bool isback=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=_repository.Where(p=>p_list.Contains(p.BillNum)).ToList();
var invlist = p_invs;
// var invlist=_repository.Where(p=>p_list.Contains(p.BillNum)).ToList();
var states= invlist.Select(p => p.State).Distinct().ToList();
if (states.Count > 1)
{
@ -209,14 +228,7 @@ namespace Win.Sfs.SettleAccount.Bases
}
if (first.State == SettleBillState.)
{
isback = false;
}
if(first.State==SettleBillState.)
{
isback = true;
}
var detailist = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList();
var first1=detailist.FirstOrDefault();
List<CustomCondition> customConditionList = new List<CustomCondition>();

Loading…
Cancel
Save