public void Cancel() { if (Status == OrderStatus.FullCanceled || Status == OrderStatus.PartialCanceled || Status == OrderStatus.Canceling) { throw new OrderIsCanceledException("订单已被取消"); } if (Status == OrderStatus.FullTransaction) { throw new OrderHasBeenDealException("订单已完全成交"); } Event @event = null; if (Status == OrderStatus.PartialTransaction) { @event = new PartialCancelOrderEvent { Id = Id, DateTime = DateTime.UtcNow }; } else { @event = new FullCancelOrderEvent { Id = Id, DateTime = DateTime.UtcNow }; } ApplyEvent(@event); }
public async Task Handle(FullCancelOrderEvent @event) { var state = await GetState(@event.Id); await messageBus.SendAsync(new OrderReportingMessage { Event = ClientAdapter.Messages.Orders.Events.FullCanceled, State = state }); }
public async Task Handle(FullCancelOrderEvent @event) { var transaction = new UpdateOrderStatusTransaction(); transaction.Id = @event.Id.ToString(); transaction.Status = (int)OrderStatus.FullCanceled; transaction.DateTime = @event.DateTime.DateTime; await bus.SendAsync(transaction); }
public void Handle(FullCancelOrderEvent @event) { Status = OrderStatus.FullCanceled; }