Пример #1
0
        public void AddItem(Guid productSkuID, string commodityName, decimal quantity, decimal price, decimal auxiliaryQuantity, string remark)
        {
            var item = new SaleOrderItem()
            {
                ProductSkuID      = productSkuID,
                Quantity          = quantity,
                Price             = price,
                Remark            = remark,
                AuxiliaryQuantity = auxiliaryQuantity,
                CommodityName     = commodityName
            };

            this.Items.Add(item);
            this.TotalAuxiliaryQuantity += item.AuxiliaryQuantity;
            this.TotalQuantity          += item.Quantity;
            this.TotalAmount            += item.Amount;
        }
Пример #2
0
 public void AddItem(Guid commodityID,Quantity quantity,decimal price,string remark)
 {
     var item=new SaleOrderItem(){CommodityID=commodityID,Quantity=quantity,Price=price,Remark=remark};
     this.Items.Add(item);
 }
Пример #3
0
        public void UpdateItems(Guid commodityID, decimal count, decimal weight, Guid unitID, decimal price)
        {
            SaleOrderItem existingItem = this.Items.FirstOrDefault(p => p.CommodityID == commodityID);
            if (existingItem == null)
            {
                existingItem = new SaleOrderItem();
                this.Items.Add(existingItem);
            }
            existingItem.CommodityID = commodityID;
            existingItem.Quantity += new Quantity(count, weight);
            existingItem.UnitID = unitID;
            existingItem.Price = price;

            if (existingItem.Quantity.Count == 0)
            {
                this.Items.Remove(existingItem);
            }
            if (existingItem.Quantity.IsNegative())
                throw new DomainException("订单数量不能小于零");
        }