コード例 #1
0
ファイル: Product.cs プロジェクト: wangtingwei/EasyOne-csharp
 public static int GetStockByProperty(int productid, string propertyValue)
 {
     return(ProductData.GetStockByProperty(productid, propertyValue));
 }
コード例 #2
0
ファイル: Product.cs プロジェクト: wangtingwei/EasyOne-csharp
        public static string CheckStocks(ProductInfo productInfo, string propertyValue, int amount, StringBuilder productIdInCart)
        {
            int    stocks = amount;
            string str    = string.Empty;

            str = CheckEnableSingleSell(productIdInCart, productInfo);
            if (string.IsNullOrEmpty(str))
            {
                if (!GetProductById(productInfo.ProductId).EnableBuyWhenOutofstock)
                {
                    if (productInfo.StocksProject == StocksProject.ActualStock)
                    {
                        if (string.IsNullOrEmpty(propertyValue))
                        {
                            if (productInfo.Stocks < amount)
                            {
                                stocks = productInfo.Stocks;
                            }
                        }
                        else
                        {
                            ProductDataInfo info = ProductData.GetProductDataByPropertyValue(productInfo.ProductId, productInfo.TableName, propertyValue);
                            if (!info.IsNull && (info.Stocks < amount))
                            {
                                stocks = info.Stocks;
                            }
                        }
                    }
                    else if (string.IsNullOrEmpty(propertyValue))
                    {
                        if ((productInfo.Stocks - productInfo.OrderNum) < amount)
                        {
                            stocks = productInfo.Stocks - productInfo.OrderNum;
                        }
                    }
                    else
                    {
                        ProductDataInfo info2 = ProductData.GetProductDataByPropertyValue(productInfo.ProductId, productInfo.TableName, propertyValue);
                        if (!info2.IsNull && ((info2.Stocks - info2.OrderNum) < amount))
                        {
                            stocks = info2.Stocks - info2.OrderNum;
                        }
                    }
                    if (stocks != amount)
                    {
                        str = string.Concat(new object[] { "您订购了", amount, productInfo.Unit, productInfo.ProductName, ",而此商品目前只有", stocks, productInfo.Unit, ",请重新调整您的购物车!" });
                    }
                }
                int num2 = Order.CountBuyNum(PEContext.Current.User.UserName, productInfo.ProductId);
                if (((productInfo.LimitNum > 0) && ((num2 + amount) > productInfo.LimitNum)) || ((productInfo.LimitNum > 0) && (amount > productInfo.LimitNum)))
                {
                    str = string.Concat(new object[] { "您订购了", amount, productInfo.Unit, productInfo.ProductName, ",曾经购买了", num2, productInfo.Unit, ",而此商品每人最多限购", productInfo.LimitNum, productInfo.Unit, ",请重新调整您的购物车!" });
                }
                ProductInfo productById = GetProductById(productInfo.ProductId);
                if ((productById.Minimum > 0) && (amount < productById.Minimum))
                {
                    str = string.Concat(new object[] { "您订购了", amount, productInfo.Unit, productInfo.ProductName, ",曾经购买了", num2, productInfo.Unit, ",而此商品每人最低购买量为", productById.Minimum, productInfo.Unit, ",请重新调整您的购物车!" });
                }
            }
            return(str);
        }
コード例 #3
0
ファイル: Product.cs プロジェクト: wangtingwei/EasyOne-csharp
        public static bool Add(int modelId, ProductInfo productInfo, IList <ProductDataInfo> productDataInfoList, IList <ProductPriceInfo> priceInfoList)
        {
            ModelInfo modelInfoById = ModelManager.GetModelInfoById(modelId);

            if (modelInfoById.IsNull)
            {
                return(false);
            }
            string tableName    = modelInfoById.TableName;
            int    newProductId = GetNewProductId();

            productInfo.ProductId = newProductId;
            bool flag     = true;
            int  num2     = 0;
            int  alarmNum = 0;

            foreach (ProductDataInfo info2 in productDataInfoList)
            {
                num2    += info2.Stocks;
                alarmNum = info2.AlarmNum;
            }
            productInfo.Stocks   = num2;
            productInfo.AlarmNum = alarmNum;
            flag = Add(modelId, tableName, productInfo);
            StockInfo stockInfo = new StockInfo();

            stockInfo.StockId  = StockManage.GetMaxId() + 1;
            stockInfo.StockNum = StockItem.GetInStockNum();
            DataRow[] rowArray = productInfo.Fields.Select("FieldName='Inputer'");
            if (rowArray.Length > 0)
            {
                stockInfo.Inputer = rowArray[0]["FieldValue"].ToString();
            }
            stockInfo.InputTime = DateTime.Now;
            stockInfo.StockType = StockType.InStock;
            stockInfo.Remark    = "商品库存初始";
            StockManage.Add(stockInfo);
            if (flag)
            {
                IList <StockItemInfo> infoList = new List <StockItemInfo>();
                if (!string.IsNullOrEmpty(productInfo.Properties))
                {
                    flag = ProductData.Add(newProductId, tableName, productDataInfoList);
                    foreach (ProductDataInfo info4 in productDataInfoList)
                    {
                        StockItemInfo item = new StockItemInfo();
                        item.ItemId      = StockItem.GetMaxId() + 1;
                        item.Amount      = info4.Stocks;
                        item.Price       = info4.PriceInfo.Price;
                        item.ProductId   = newProductId;
                        item.TableName   = tableName;
                        item.Property    = info4.PropertyValue;
                        item.StockId     = stockInfo.StockId;
                        item.ProductNum  = productInfo.ProductNum;
                        item.Unit        = productInfo.Unit;
                        item.ProductName = productInfo.ProductName;
                        infoList.Add(item);
                    }
                }
                else
                {
                    StockItemInfo info6 = new StockItemInfo();
                    info6.Amount      = productInfo.Stocks;
                    info6.Price       = productInfo.PriceInfo.Price;
                    info6.ProductId   = newProductId;
                    info6.TableName   = tableName;
                    info6.Property    = string.Empty;
                    info6.ProductNum  = productInfo.ProductNum;
                    info6.Unit        = productInfo.Unit;
                    info6.ProductName = productInfo.ProductName;
                    infoList.Add(info6);
                }
                StockItem.Add(infoList, stockInfo.StockId);
                if (((productInfo.PriceInfo.PriceMember == -1M) || (productInfo.PriceInfo.PriceAgent == -1M)) && (priceInfoList != null))
                {
                    flag = ProductPrice.Add(newProductId, tableName, priceInfoList);
                }
            }
            return(flag);
        }
コード例 #4
0
ファイル: Product.cs プロジェクト: wangtingwei/EasyOne-csharp
 public static bool AddOrderNum(int productId, string tableName, string property, int quantity)
 {
     return(ProductCommon.AddOrderNum(productId, tableName, quantity) && ProductData.AddOrderNum(productId, tableName, property, quantity));
 }