using System.Threading.Tasks; using Volo.Abp.EventBus; using Volo.Abp.Uow; using Win_in.Sfs.Shared.Event; using Win_in.Sfs.Wms.Job.Domain; using Win_in.Sfs.Wms.Store.Application.Contracts; // ReSharper disable AsyncApostle.ConfigureAwaitHighlighting namespace Win_in.Sfs.Wms.Job.Event.BusinessJob; public class PurchaseReceiptJobEventHandler : JobBusinessJobEventHandlerBase , ILocalEventHandler> { private readonly IPurchaseReceiptNoteAppService _purchaseReceiptNoteAppService; public PurchaseReceiptJobEventHandler( IPurchaseReceiptNoteAppService purchaseReceiptNoteAppService ) { _purchaseReceiptNoteAppService = purchaseReceiptNoteAppService; } /// /// 收货 成功后 /// /// /// [UnitOfWork] public virtual async Task HandleEventAsync(SfsCompletedEntityEventData eventData) { var entity = eventData.Entity; //创建收货记录 await CreatePurchaseReceiptNoteAsync(entity).ConfigureAwait(false); } #region 私有 /// /// 创建收货记录 /// /// private async Task CreatePurchaseReceiptNoteAsync(PurchaseReceiptJob purchaseReceiptJob) { var createInput = ObjectMapper.Map(purchaseReceiptJob); createInput.Details.RemoveAll(p => p.Qty == 0); await _purchaseReceiptNoteAppService.CreateAsync(createInput).ConfigureAwait(false); await Task.CompletedTask.ConfigureAwait(false); } #endregion }