对账列表批量删除

dev
cjy 2 months ago
parent 9ae00984c3
commit 44ce57d41f

@ -136,7 +136,18 @@ public class CheckBillController : ApiController
var res = _invokeService.BatchDelCheckBillFeeRecords(req);
return res;
}
/// <summary>
/// 对账列表批量删除
/// </summary>
/// <param name="req">主表Ids</param>
/// <returns></returns>
[HttpPost]
[Route("BatchDelCheckBill")]
public async Task<DataResult> BatchDelCheckBill([FromBody] IdModel req)
{
var res = await _invokeService.BatchDelCheckBill(req);
return res;
}
/// <summary>
/// 对账明细添加
/// </summary>

@ -73,7 +73,12 @@ namespace DS.WMS.Core.Check.Interface
/// <param name="req">主表Id及费用Ids</param>
/// <returns></returns>
public DataResult BatchDelCheckBillFeeRecords(IdModel req);
/// <summary>
/// 对账列表批量删除
/// </summary>
/// <param name="req">主表Ids</param>
/// <returns></returns>
public Task<DataResult> BatchDelCheckBill(IdModel req);
/// <summary>
/// 对账明细添加
/// </summary>

@ -448,7 +448,64 @@ namespace DS.WMS.Core.Check.Method
}
return DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess);
}
/// <summary>
/// 对账列表批量删除
/// </summary>
/// <param name="req">主表Ids</param>
/// <returns></returns>
public async Task<DataResult> BatchDelCheckBill(IdModel req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Ids.Length == 0)
return DataResult.Failed("业务Ids不能为空");
if (tenantDb.Queryable<CheckBill>().Where(x => req.Ids.Contains(x.Id) && x.IsLocking == true).Any())
{
return DataResult.Failed("存在客户对账信息已锁定");
}
try
{
await tenantDb.Ado.BeginTranAsync();
foreach (var item in req.Ids)
{
var info = await tenantDb.Queryable<CheckBill>().FirstAsync(x => x.Id == item);
//if (info.IsNull())
// return DataResult.Failed("客户对账信息不存在");
var businessList = tenantDb.Queryable<CheckBillBusiness>().Where(x => x.CheckId == item).ToList();
if (businessList.Count > 0)
tenantDb.Deleteable(businessList).ExecuteCommand();
var feeList = tenantDb.Queryable<CheckBillFeeRecords>().Where(x => x.CheckId == item).ToList();
if (feeList.Count > 0)
{
#region 更新费用记录对账标识
var feeIds = feeList.Select(x => x.FeeRecordId).Distinct().ToList();
var feeRecords = tenantDb.Queryable<FeeRecord>().Where(x => feeIds.Contains(x.Id)).ToList();
foreach (var record in feeRecords)
{
//对账标识
record.IsDebit = false;
record.DebitNo = "";
}
//更新费用记录
tenantDb.Updateable(feeRecords).ExecuteCommand();
#endregion
tenantDb.Deleteable(feeList).ExecuteCommand();
}
}
await tenantDb.Ado.CommitTranAsync();
return DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess);
}
catch (Exception)
{
await tenantDb.Ado.RollbackTranAsync();
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
/// <summary>
/// 对账明细添加

Loading…
Cancel
Save