diff --git a/ds-wms-service/DS.WMS.CheckApi/Controllers/CheckBillController.cs b/ds-wms-service/DS.WMS.CheckApi/Controllers/CheckBillController.cs index 537930b1..5a0da71a 100644 --- a/ds-wms-service/DS.WMS.CheckApi/Controllers/CheckBillController.cs +++ b/ds-wms-service/DS.WMS.CheckApi/Controllers/CheckBillController.cs @@ -136,7 +136,18 @@ public class CheckBillController : ApiController var res = _invokeService.BatchDelCheckBillFeeRecords(req); return res; } - + /// + /// 对账列表批量删除 + /// + /// 主表Ids + /// + [HttpPost] + [Route("BatchDelCheckBill")] + public async Task BatchDelCheckBill([FromBody] IdModel req) + { + var res = await _invokeService.BatchDelCheckBill(req); + return res; + } /// /// 对账明细添加 /// diff --git a/ds-wms-service/DS.WMS.Core/Check/Interface/ICheckBillService.cs b/ds-wms-service/DS.WMS.Core/Check/Interface/ICheckBillService.cs index 4fce7077..8d68335d 100644 --- a/ds-wms-service/DS.WMS.Core/Check/Interface/ICheckBillService.cs +++ b/ds-wms-service/DS.WMS.Core/Check/Interface/ICheckBillService.cs @@ -73,7 +73,12 @@ namespace DS.WMS.Core.Check.Interface /// 主表Id及费用Ids /// public DataResult BatchDelCheckBillFeeRecords(IdModel req); - + /// + /// 对账列表批量删除 + /// + /// 主表Ids + /// + public Task BatchDelCheckBill(IdModel req); /// /// 对账明细添加 /// diff --git a/ds-wms-service/DS.WMS.Core/Check/Method/CheckBillService.cs b/ds-wms-service/DS.WMS.Core/Check/Method/CheckBillService.cs index 5a7a534a..d87e0a9f 100644 --- a/ds-wms-service/DS.WMS.Core/Check/Method/CheckBillService.cs +++ b/ds-wms-service/DS.WMS.Core/Check/Method/CheckBillService.cs @@ -448,7 +448,64 @@ namespace DS.WMS.Core.Check.Method } return DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess); } + /// + /// 对账列表批量删除 + /// + /// 主表Ids + /// + public async Task BatchDelCheckBill(IdModel req) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + if (req.Ids.Length == 0) + return DataResult.Failed("业务Ids不能为空"); + + if (tenantDb.Queryable().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().FirstAsync(x => x.Id == item); + //if (info.IsNull()) + // return DataResult.Failed("客户对账信息不存在"); + + var businessList = tenantDb.Queryable().Where(x => x.CheckId == item).ToList(); + if (businessList.Count > 0) + tenantDb.Deleteable(businessList).ExecuteCommand(); + var feeList = tenantDb.Queryable().Where(x => x.CheckId == item).ToList(); + + if (feeList.Count > 0) + { + #region 更新费用记录对账标识 + var feeIds = feeList.Select(x => x.FeeRecordId).Distinct().ToList(); + var feeRecords = tenantDb.Queryable().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)); + } + } /// /// 对账明细添加