Beispiel #1
0
        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(PartialCancelOrderEvent @event)
        {
            var state = await GetState(@event.Id);

            await messageBus.SendAsync(new OrderReportingMessage
            {
                Event = ClientAdapter.Messages.Orders.Events.PartialCancel,
                State = state
            });
        }
        public async Task Handle(PartialCancelOrderEvent @event)
        {
            var transaction = new UpdateOrderStatusTransaction();

            transaction.Id       = @event.Id.ToString();
            transaction.Status   = (int)OrderStatus.PartialCanceled;
            transaction.DateTime = @event.DateTime.DateTime;

            await bus.SendAsync(transaction);
        }
Beispiel #4
0
 public void Handle(PartialCancelOrderEvent @event)
 {
     Status = OrderStatus.PartialCanceled;
 }