|
|
@ -136,23 +136,50 @@ namespace Win.Sfs.SettleAccount.Bases |
|
|
|
[UnitOfWork(false)] |
|
|
|
public virtual async Task<string> ApprovalPassed(List<string> p_list) |
|
|
|
{ |
|
|
|
return await InvokePD(p_list, _service, false); |
|
|
|
return await InvokePD(p_list, _service); |
|
|
|
} |
|
|
|
[HttpPost] |
|
|
|
[UnitOfWork(false)] |
|
|
|
public virtual async Task<string> RejectAsync(List<string> p_list) |
|
|
|
{ |
|
|
|
return await InvokePD(p_list, _service, true); |
|
|
|
return await InvokePD(p_list, _service); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 调用扣减
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="p_list"></param>
|
|
|
|
/// <param name="p_service"></param>
|
|
|
|
/// <param name="isback"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
|
protected async Task<string> InvokePD(List<string> p_list, TaskJobService p_service, bool isback=false) |
|
|
|
{ |
|
|
|
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.已扣减) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"当前发票状态不是【客户已收票】或【已扣减状态】不能进行出库扣减或撤销扣减操作", "400"); |
|
|
|
} |
|
|
|
if (first.State == SettleBillState.客户已收票) |
|
|
|
{ |
|
|
|
isback = false; |
|
|
|
} |
|
|
|
if(first.State==SettleBillState.已扣减) |
|
|
|
{ |
|
|
|
isback = true; |
|
|
|
} |
|
|
|
var detailist = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList(); |
|
|
|
var first=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 =first.BusinessType.ToString() }); |
|
|
|
customConditionList.Add(new CustomCondition() { Name = "Type", Value =first1.BusinessType.ToString() }); |
|
|
|
if (isback == false) |
|
|
|
{ |
|
|
|
customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "out" }); |
|
|
@ -161,7 +188,6 @@ 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>(); |
|
|
|
if (isback == false) |
|
|
@ -172,8 +198,6 @@ namespace Win.Sfs.SettleAccount.Bases |
|
|
|
{ |
|
|
|
lst = ls.Where(p => (p.State == SettleBillState.已提交撤销扣减|| p.State == SettleBillState.客户已收票)).ToList(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (lst.Count() > 0) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("当前状态是已提交状态,不能重复已提交", "400"); |
|
|
@ -190,8 +214,7 @@ namespace Win.Sfs.SettleAccount.Bases |
|
|
|
} |
|
|
|
} |
|
|
|
await _repository.DbContext.BulkUpdateAsync(ls); |
|
|
|
|
|
|
|
var _taskid = await p_service.ExportEnqueueAsync($"{first.BusinessType.ToString()}待扣减任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PendingDeductionService), customConditionList, (rs) => |
|
|
|
var _taskid = await p_service.ExportEnqueueAsync($"{first1.BusinessType.ToString()}待扣减任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PendingDeductionService), customConditionList, (rs) => |
|
|
|
{ |
|
|
|
}); |
|
|
|
|
|
|
|