private void Handle(OrderPlacedEvent evnt) { _total = evnt.OrderTotal; _status = OrderStatus.Placed; _userId = evnt.UserId; _registrantId = evnt.UserId; _payInfo = new PayInfo(0, 0); _expressAddressInfo = evnt.ExpressAddressInfo; _reservationExpirationDate = evnt.ReservationExpirationDate; }
private void Handle(OrderPlacedEvent evnt) { _id = evnt.AggregateRootId; _total = evnt.OrderTotal; _status = OrderStatus.Placed; _userId = evnt.UserId; _registrantId = evnt.UserId; _expressAddressInfo = evnt.ExpressAddressInfo; _reservationExpirationDate = evnt.ReservationExpirationDate; }
private static readonly TimeSpan PollInterval = TimeSpan.FromMinutes(2);//每半小时轮询付款状态 public Order(Guid id, Guid userId, ExpressAddressInfo expressAddressInfo, IEnumerable <SpecificationQuantity> specifications, IPricingService pricingService) : base(id) { Ensure.NotEmptyGuid(id, nameof(id)); Ensure.NotNull(specifications, nameof(specifications)); Ensure.NotNull(pricingService, nameof(pricingService)); if (!specifications.Any()) { throw new ArgumentException("订单的商品不能为空"); } var orderTotal = pricingService.CalculateTotal(specifications); ApplyEvent(new OrderPlacedEvent(userId, expressAddressInfo, orderTotal, DateTime.Now.Add(ConfigSettings.ReservationAutoExpiration))); }