You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.7 KiB

2 years ago
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<SfsCompletedEntityEventData<PurchaseReceiptJob>>
{
private readonly IPurchaseReceiptNoteAppService _purchaseReceiptNoteAppService;
public PurchaseReceiptJobEventHandler(
IPurchaseReceiptNoteAppService purchaseReceiptNoteAppService
)
{
_purchaseReceiptNoteAppService = purchaseReceiptNoteAppService;
}
/// <summary>
/// 收货 成功后
/// </summary>
/// <param name="eventData"></param>
/// <returns></returns>
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsCompletedEntityEventData<PurchaseReceiptJob> eventData)
{
var entity = eventData.Entity;
//创建收货记录
await CreatePurchaseReceiptNoteAsync(entity).ConfigureAwait(false);
}
#region 私有
/// <summary>
/// 创建收货记录
/// </summary>
/// <returns></returns>
private async Task CreatePurchaseReceiptNoteAsync(PurchaseReceiptJob purchaseReceiptJob)
{
var createInput = ObjectMapper.Map<PurchaseReceiptJob, PurchaseReceiptNoteEditInput>(purchaseReceiptJob);
createInput.Details.RemoveAll(p => p.Qty == 0);
await _purchaseReceiptNoteAppService.CreateAsync(createInput).ConfigureAwait(false);
await Task.CompletedTask.ConfigureAwait(false);
}
#endregion
}