⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 product.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
📖 第 1 页 / 共 3 页
字号:
            {
                splitor = '|';
            }
            IList<string> list = new List<string>(attrList[0].Split(new char[] { '|' }));
            for (int i = 1; i < attrList.Count; i++)
            {
                list = JoinPart(list, attrList[i].Split(new char[] { '|' }), splitor.Value);
            }
            return list;
        }

        public static IList<string> GetProductPropertiesList(string properties, char? splitor)
        {
            if (string.IsNullOrEmpty(properties))
            {
                return new List<string>();
            }
            IList<string> attrList = new List<string>();
            foreach (string str in properties.Split(new char[] { '\n' }))
            {
                attrList.Add(str.Substring(str.LastIndexOf('$') + 1));
            }
            return GetProductPropertiesList(attrList, splitor);
        }

        public static IList<ProductDetailInfo> GetProductsList(int startRowIndexId, int maxNumberRows, int searchType, string field, string keyword, int modelId)
        {
            return dal.GetProductsList(startRowIndexId, maxNumberRows, searchType, DataSecurity.FilterBadChar(field), DataSecurity.FilterBadChar(keyword), modelId);
        }

        public static IList<ProductDetailInfo> GetProductsList(int startRowIndexId, int maxNumberRows, string searchType, string keyword, int nodeId, int listType, int status)
        {
            string nodeIds = "";
            if (nodeId > 0)
            {
                NodeInfo cacheNodeById = PowerEasy.Contents.Nodes.GetCacheNodeById(nodeId);
                if (!cacheNodeById.IsNull)
                {
                    nodeIds = cacheNodeById.ArrChildId;
                }
            }
            return dal.GetProductsList(startRowIndexId, maxNumberRows, DataSecurity.FilterBadChar(searchType), DataSecurity.FilterBadChar(keyword), nodeIds, listType, status);
        }

        public static int GetTotalOfAllProducts(string searchType, string keyword, int nodeId, int listType, int status)
        {
            return dal.GetTotalOfAllProducts();
        }

        public static int GetTotalOfProducts()
        {
            return dal.GetTotalOfProducts();
        }

        public static IList<string> GetUnitList()
        {
            return ProductCommon.GetUnitList();
        }

        public static int GetWholesaleProductTotal(int searchType, string field, string keyword, int modelId)
        {
            return dal.GetTotalOfAllProducts();
        }

        public static bool IsEnableSale(int productId, string tableName, string propertyValue, string cartId)
        {
            m_ErrMsg = "";
            ProductInfo productById = GetProductById(productId, tableName);
            if (productById.IsNull)
            {
                m_ErrMsg = "<li>找不到指定的商品!</li>";
                return false;
            }
            if (productById.ProductId == 0)
            {
                m_ErrMsg = "<li>找不到指定的商品!</li>";
                return false;
            }
            if (!productById.EnableSale)
            {
                m_ErrMsg = "<li>商品已经停止销售!</li>";
                return false;
            }
            m_ErrMsg = CheckEnableSingleSell(cartId, productById);
            if (string.IsNullOrEmpty(m_ErrMsg))
            {
                if (string.IsNullOrEmpty(propertyValue))
                {
                    if (!productById.EnableBuyWhenOutofstock && !IsEnoughStock(productById.StocksProject, productById.Stocks, productById.OrderNum))
                    {
                        return false;
                    }
                    goto Label_00D3;
                }
                ProductDataInfo info2 = ProductData.GetProductDataByPropertyValue(productId, tableName, propertyValue);
                if (!info2.IsNull)
                {
                    if (!productById.EnableBuyWhenOutofstock && !IsEnoughStock(productById.StocksProject, info2.Stocks, info2.OrderNum))
                    {
                        return false;
                    }
                    goto Label_00D3;
                }
                m_ErrMsg = "<li>对不起,没有该商品!</li>";
            }
            return false;
        Label_00D3:
            if (productById.ProductType == ProductType.Promotion)
            {
                m_ErrMsg = "<li>促销商品不能直接购买!</li>";
                return false;
            }
            return true;
        }

        private static bool IsEnoughStock(StocksProject stocksProject, int stocks, int orderNum)
        {
            int num;
            bool flag = true;
            if (stocksProject == StocksProject.ActualStock)
            {
                num = stocks;
            }
            else
            {
                num = stocks - orderNum;
            }
            if (num <= 0)
            {
                m_ErrMsg = "<li>实在对不起,此商品已经暂时售罄!</li>";
                flag = false;
            }
            return flag;
        }

        public static bool IsExistSameProductNum(string productNum)
        {
            return ProductCommon.IsExistSameProductNum(productNum);
        }

        private static IList<string> JoinPart(IList<string> part1, string[] part2, char splitor)
        {
            IList<string> list = new List<string>();
            foreach (string str in part1)
            {
                foreach (string str2 in part2)
                {
                    list.Add(str.Trim() + splitor + str2.Trim());
                }
            }
            return list;
        }

        public static bool SetBest(string generalIdList, bool enableBest)
        {
            if (!DataValidator.IsValidId(generalIdList))
            {
                return false;
            }
            return dal.SetBest(generalIdList, enableBest);
        }

        public static bool SetElite(string generalIdList, int eliteLevel)
        {
            if (!DataValidator.IsValidId(generalIdList))
            {
                return false;
            }
            return dal.SetElite(generalIdList, eliteLevel);
        }

        public static bool SetHot(string generalIdList, bool enableHot)
        {
            if (!DataValidator.IsValidId(generalIdList))
            {
                return false;
            }
            return dal.SetHot(generalIdList, enableHot);
        }

        public static bool SetNew(string generalIdList, bool enableNew)
        {
            if (!DataValidator.IsValidId(generalIdList))
            {
                return false;
            }
            return dal.SetNew(generalIdList, enableNew);
        }

        public static bool SetSale(string generalIdList, bool enableSale)
        {
            if (!DataValidator.IsValidId(generalIdList))
            {
                return false;
            }
            return dal.SetSale(generalIdList, enableSale);
        }

        public static string ShowProductType(int saleType)
        {
            switch (saleType)
            {
                case 1:
                    return "";

                case 2:
                    return " (换购)";

                case 3:
                    return " (赠送)";

                case 4:
                    return " (批发)";
            }
            return "";
        }

        public static bool Update(int generalId, ProductInfo productInfo, IList<ProductDataInfo> dataInfoList, IList<ProductPriceInfo> priceInfoList)
        {
            PowerEasy.Model.Contents.CommonModelInfo commonModelInfoById = ContentManage.GetCommonModelInfoById(generalId);
            if (commonModelInfoById.IsNull)
            {
                return false;
            }
            productInfo.ProductId = commonModelInfoById.ItemId;
            string tableName = commonModelInfoById.TableName;
            if (commonModelInfoById.LinkType == 1)
            {
                return dalContentManage.UpdateCommonModel(generalId, productInfo.Fields);
            }
            int num = 0;
            int num2 = 0;
            foreach (ProductDataInfo info2 in dataInfoList)
            {
                num += info2.Stocks;
                num2 += info2.AlarmNum;
            }
            if (num > 0)
            {
                productInfo.Stocks = num;
            }
            if (num2 > 0)
            {
                productInfo.AlarmNum = num2;
            }
            DoHtmlEncode(productInfo);
            if (!dalContentManage.UpdateCommonModel(generalId, productInfo.Fields) || !ProductCommon.Update(productInfo, tableName))
            {
                return false;
            }
            dal.Update(productInfo, tableName);
            if (!string.IsNullOrEmpty(productInfo.Properties) && !ProductData.Update(productInfo.ProductId, tableName, dataInfoList))
            {
                return false;
            }
            return ((priceInfoList == null) || ProductPrice.Update(productInfo.ProductId, tableName, priceInfoList));
        }

        public PowerEasy.Model.Contents.CommonModelInfo CommonModelInfo
        {
            get
            {
                return this.m_CommonModelInfo;
            }
        }

        public static string ErrMsgOfEnableSale
        {
            get
            {
                return m_ErrMsg;
            }
        }

        public static string MessgeOfBatchImport
        {
            get
            {
                return m_MessgeOfBatchImport;
            }
        }

        public IList<ProductDataInfo> ProductDataInfoList
        {
            get
            {
                if (this.m_ProductInfoData == null)
                {
                    return null;
                }
                return ProductData.GetListByProduct(this.m_ProductInfoData.ProductId, this.m_ProductInfoData.TableName);
            }
        }

        public ProductInfo ProductInfoData
        {
            get
            {
                return this.m_ProductInfoData;
            }
        }

        public IList<ProductPriceInfo> ProductPriceInfoList
        {
            get
            {
                if (this.m_ProductInfoData == null)
                {
                    return null;
                }
                return ProductPrice.GetProductPriceById(this.m_ProductInfoData.ProductId, this.m_ProductInfoData.TableName);
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -