コード例 #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);
        }
コード例 #2
0
        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
            });
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public void Handle(FullCancelOrderEvent @event)
 {
     Status = OrderStatus.FullCanceled;
 }