diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs index fcf43679..ca88eca7 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs @@ -208,7 +208,14 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran var qty = balance.Qty + data.Qty; balance.InjectFrom(data); balance.Qty = qty; - this._balanceRepository.UpdateAsync(balance).Wait(); + if (balance.Qty == decimal.Zero) + { + await this._balanceRepository.DeleteAsync(balance).ConfigureAwait(false); + } + else + { + await this._balanceRepository.UpdateAsync(balance).ConfigureAwait(false); + } } await _logRepository.InsertAsync(log).ConfigureAwait(false); } @@ -253,7 +260,14 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran { var qty = balance.Qty - data.Qty; balance.Qty = qty; - this._balanceRepository.UpdateAsync(balance).Wait(); + if (balance.Qty == decimal.Zero) + { + await this._balanceRepository.DeleteAsync(balance).ConfigureAwait(false); + } + else + { + await this._balanceRepository.UpdateAsync(balance).ConfigureAwait(false); + } } await _logRepository.InsertAsync(log).ConfigureAwait(false); }