diff --git a/src/WMS.Web.Domain/Services/OutStockService.cs b/src/WMS.Web.Domain/Services/OutStockService.cs index 4754d99f..93e61416 100644 --- a/src/WMS.Web.Domain/Services/OutStockService.cs +++ b/src/WMS.Web.Domain/Services/OutStockService.cs @@ -123,28 +123,29 @@ namespace WMS.Web.Domain.Services #endregion IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); - bool isRollback = false; + Result res_Rollback = Result.ReSuccess(); bool isSuccess = true; //修改库存 var res_Inventory = await _boxInventoryService.HandlBoxInventory(inventoryList, false); - if (!res_Inventory.IsSuccess) isRollback = true; - if (!isRollback) + if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory; + if (res_Rollback.IsSuccess) { entity = await _outStockRepositories.Add(entity, false); - if (entity == null) isRollback = true; + if (entity == null) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError); } - if (!isRollback) + if (res_Rollback.IsSuccess) { outStockTask = await _outStockTaskRepositories.Edit(outStockTask, false); - if (outStockTask == null) isRollback = true; + if (outStockTask == null) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError); } - if (!isRollback) + if (res_Rollback.IsSuccess) { var res_change = await _serialNumberService.OutStock(entity, loginInfo, false); - if (!res_change.IsSuccess) isRollback = true; + if (!res_change.IsSuccess) res_Rollback = res_change; } //提交事务 - isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction); + isSuccess = _transactionRepositories.CommitTransaction(res_Rollback.IsSuccess ? false : true, _transaction); + if (!res_Rollback.IsSuccess) return res_Rollback; if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);