Пример #1
0
        public void InitOrderSnIncreasingNumber(int companyId, string storeId, string machineSn)
        {
            var num     = GetOrderSnIncreasingNumber(companyId, storeId, machineSn);
            var orderId = new OrderSn(companyId, storeId, machineSn);
            var currentIncreasingNumber = orderId.GetCurrentIncreasingNumber();

            if (num == 0 && currentIncreasingNumber == 0)
            {
                orderId.NextNumber();
            }
            else
            {
                orderId.ResetNumber(num);
            }
        }
Пример #2
0
        /// <summary>
        /// 初始订单
        /// </summary>
        /// <param name="shoppingcart"></param>
        /// <param name="marketingContexts"></param>
        public Order(Shoppingcart shoppingcart, IEnumerable <IOrderMarketingResult> marketingResults)
        {
            if (shoppingcart == null)
            {
                throw new OrderException("提交订单时,订单不能为空!");
            }
            if (marketingResults == null)
            {
                throw new OrderException("提交订单前,必须先运行促销!");
            }

            this.marketingResults = marketingResults;

            CreateDate        = DateTime.Now;
            Items             = new List <OrderItem>();
            this.shoppingcart = shoppingcart;
            CustomerId        = shoppingcart.CustomerId;
            CreateDate        = DateTime.Now;


            foreach (var item in shoppingcart.Items)
            {
                Items.Add(new OrderItem()
                {
                    MarketingPrice = item.MarketingPrice,
                    Number         = item.Number,
                    Product        = item.Product,
                    ManualPrice    = item.ManualPrice,
                    SaleState      = item.SaleState,
                    EditedPrice    = item.EditedPrice
                });
            }
            foreach (var item in marketingResults)
            {
                var items = item.GetGiftsOrTradeInItems();
                if (items != null && items.Any())
                {
                    Items.AddRange(items);
                }
            }
            Cashier = shoppingcart.Cashier;
            Guider  = shoppingcart.Guider;
            OrderId = new OrderSn(Cashier.CompanyId, Cashier.StoreId, Cashier.MachineSn);

            OrderState = OrderState.Created;
        }