Beispiel #1
0
 // 将当前的购物车中的项目转换为订单项
 public OrderItem ConvertToOrderItem()
 {
     var orderItem = new OrderItem
     {
         Id = Guid.NewGuid(),
         Product = this.Product,
         Quantity = this.Quantity
     };
     return orderItem;
 }
Beispiel #2
0
 /// <summary>
 /// 团购直接下单、待付款
 /// </summary>
 /// <param name="user"></param>
 /// <param name="product"></param>
 /// <param name="count"></param>
 /// <returns></returns>
 public Order CreateOrderDirect(User user, NativeProduct product, int count)
 {
     var order = new Order();
     if (count == 0 || product == null)
     {
         throw new InvalidOperationException("没有任何商品购买");
     }
     order.OrderItems = new List<OrderItem>();
     var orderItem = new OrderItem();
     orderItem.Id = Guid.NewGuid();
     orderItem.Product = product;
     orderItem.Quantity = count;
     orderItem.Order = order;
     order.OrderItems.Add(orderItem);
     order.User = user;
     order.DeliveryAddress = user.DeliveryAddress;
     order.Status = DictOrderStatus.创建;//先创建订单,付款需要用到订单号
     _orderRepository.Add(order);
     _repositoryContext.Commit();
     return order;
 }
Beispiel #3
0
 /// <summary>
 /// 根据商品ID和商品数量创建订单项
 /// </summary>
 /// <param name="product"></param>
 /// <param name="quantity"></param>
 /// <returns></returns>
 public OrderItem CreateOrderItemByProductId()
 {
     var productRepository = ServiceLocator.Instance.GetService<IProductRepository>();
     var product = productRepository.GetByKey(this.Product.Id);
     var orderItem = new OrderItem
     {
         Id = Guid.NewGuid(),
         Product = product,
         Quantity = this.Quantity
     };
     return orderItem;
 }