public static decimal GetTruePrice(ProductInfo productInfo, int productAmount, UserInfo userInfo, string property, bool haveWholesalePurview) { if (!string.IsNullOrEmpty(property)) { ProductDataInfo info = ProductData.GetProductDataByPropertyValue(productInfo.ProductId, productInfo.TableName, property); productInfo.PriceInfo = info.PriceInfo; } if ((haveWholesalePurview && productInfo.EnableWholesale) && (productAmount >= productInfo.PriceInfo.NumberWholesale1)) { if (productAmount < productInfo.PriceInfo.NumberWholesale2) { return(productInfo.PriceInfo.PriceWholesale1); } if (productAmount < productInfo.PriceInfo.NumberWholesale3) { return(productInfo.PriceInfo.PriceWholesale2); } return(productInfo.PriceInfo.PriceWholesale3); } if (!userInfo.IsNull) { switch (UserGroups.GetUserGroupById(userInfo.GroupId).GroupType) { case GroupType.Register: return(GetGroupPrice(productInfo, userInfo, productInfo.PriceInfo.PriceMember, property)); case GroupType.Agent: return(GetGroupPrice(productInfo, userInfo, productInfo.PriceInfo.PriceAgent, property)); } return(productInfo.PriceInfo.Price); } return(productInfo.PriceInfo.Price); }
public static string GetOutOfStockProduct(int orderId) { IList <OrderItemInfo> infoListByOrderId = OrderItem.GetInfoListByOrderId(orderId); StringBuilder sb = new StringBuilder(); foreach (OrderItemInfo info in infoListByOrderId) { if (string.IsNullOrEmpty(info.TableName)) { PresentInfo presentById = Present.GetPresentById(info.ProductId); if (presentById.Stocks < info.Amount) { StringHelper.AppendString(sb, presentById.PresentName); } } else { ProductInfo productById = Product.GetProductById(info.ProductId, info.TableName); if (string.IsNullOrEmpty(info.Property)) { if (productById.Stocks < info.Amount) { StringHelper.AppendString(sb, productById.ProductName); } continue; } ProductDataInfo info4 = ProductData.GetProductDataByPropertyValue(productById.ProductId, productById.TableName, info.Property); if (!info4.IsNull && (info4.Stocks < info.Amount)) { StringHelper.AppendString(sb, productById.ProductName + "(" + info.Property + ")"); } } } return(sb.ToString()); }
public static bool IsEnableSale(int productId, string tableName, string propertyValue, string cartId) { s_ErrMsg = ""; ProductInfo productById = GetProductById(productId, tableName); if (productById.IsNull) { s_ErrMsg = "<li>找不到指定的商品!</li>"; return(false); } if (productById.ProductId == 0) { s_ErrMsg = "<li>找不到指定的商品!</li>"; return(false); } if (!productById.EnableSale) { s_ErrMsg = "<li>商品已经停止销售!</li>"; return(false); } s_ErrMsg = CheckEnableSingleSell(cartId, productById); if (string.IsNullOrEmpty(s_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; } s_ErrMsg = "<li>对不起,没有该商品!</li>"; } return(false); Label_00D3: if (productById.ProductType == ProductType.Promotion) { s_ErrMsg = "<li>促销商品不能直接购买!</li>"; return(false); } return(true); }
public List <SelectListItem> GetProductDataByProductType(int productType) { List <SelectListItem> list = new List <SelectListItem>(); foreach (product product in _data.GetProductsByTypeId(productType)) { ProductDataInfo productDataInfo = new ProductDataInfo() { Description = product.description, OrderCode = product.order_code, Price = product.price }; list.Add(new SelectListItem { Text = String.Format("{0} - {1}", product.order_code, product.description), Value = JsonConvert.SerializeObject(productDataInfo) }); } return(list); }
public bool Add(int productId, string tableName, ProductDataInfo dataInfo) { Parameters cmdParams = new Parameters(); cmdParams.AddInParameter("@ProductID", DbType.Int32, productId); cmdParams.AddInParameter("@Stocks", DbType.Int32, dataInfo.Stocks); cmdParams.AddInParameter("@AlarmNum", DbType.Int32, dataInfo.AlarmNum); cmdParams.AddInParameter("@TableName", DbType.String, tableName); cmdParams.AddInParameter("@PropertyValue", DbType.String, dataInfo.PropertyValue); cmdParams.AddInParameter("@Price", DbType.Decimal, dataInfo.PriceInfo.Price); cmdParams.AddInParameter("@PriceMember", DbType.Decimal, dataInfo.PriceInfo.PriceMember); cmdParams.AddInParameter("@PriceAgent", DbType.Decimal, dataInfo.PriceInfo.PriceAgent); cmdParams.AddInParameter("@PriceWholesale1", DbType.Decimal, dataInfo.PriceInfo.PriceWholesale1); cmdParams.AddInParameter("@PriceWholesale2", DbType.Decimal, dataInfo.PriceInfo.PriceWholesale2); cmdParams.AddInParameter("@PriceWholesale3", DbType.Decimal, dataInfo.PriceInfo.PriceWholesale3); cmdParams.AddInParameter("@NumberWholesale1", DbType.Int32, dataInfo.PriceInfo.NumberWholesale1); cmdParams.AddInParameter("@NumberWholesale2", DbType.Int32, dataInfo.PriceInfo.NumberWholesale2); cmdParams.AddInParameter("@NumberWholesale3", DbType.Int32, dataInfo.PriceInfo.NumberWholesale3); cmdParams.AddInParameter("@IsValid", DbType.Boolean, dataInfo.IsValid); return(DBHelper.ExecuteSql("INSERT INTO PE_ProductData(ProductID, TableName, Stocks, AlarmNum, PropertyValue, Price, Price_Member, Price_Agent, Price_Wholesale1, Price_Wholesale2, Price_Wholesale3, Number_Wholesale1, Number_Wholesale2, Number_Wholesale3, IsValid) VALUES(@ProductID, @TableName, @Stocks, @AlarmNum, @PropertyValue, @Price, @PriceMember, @PriceAgent, @PriceWholesale1, @PriceWholesale2, @PriceWholesale3, @NumberWholesale1, @NumberWholesale2, @NumberWholesale3, @IsValid)", cmdParams)); }
public bool Update(int productId, string tableName, ProductDataInfo info) { Parameters cmdParams = new Parameters(); cmdParams.AddInParameter("@ProductID", DbType.Int32, productId); cmdParams.AddInParameter("@TableName", DbType.String, tableName); cmdParams.AddInParameter("@Stocks", DbType.Int32, info.Stocks); cmdParams.AddInParameter("@AlarmNum", DbType.Int32, info.AlarmNum); if (string.IsNullOrEmpty(info.PropertyValue)) { return(DBHelper.ExecuteSql("UPDATE PE_ProductData SET Stocks = @Stocks, AlarmNum = @AlarmNum WHERE ProductId = @ProductId AND TableName = @TableName", cmdParams)); } cmdParams.AddInParameter("@PropertyValue", DbType.String, info.PropertyValue); cmdParams.AddInParameter("@PriceMember", DbType.Decimal, info.PriceInfo.PriceMember); cmdParams.AddInParameter("@PriceAgent", DbType.Decimal, info.PriceInfo.PriceAgent); cmdParams.AddInParameter("@PriceWholesale1", DbType.Decimal, info.PriceInfo.PriceWholesale1); cmdParams.AddInParameter("@PriceWholesale2", DbType.Decimal, info.PriceInfo.PriceWholesale2); cmdParams.AddInParameter("@PriceWholesale3", DbType.Decimal, info.PriceInfo.PriceWholesale3); cmdParams.AddInParameter("@NumberWholesale1", DbType.Int32, info.PriceInfo.NumberWholesale1); cmdParams.AddInParameter("@NumberWholesale2", DbType.Int32, info.PriceInfo.NumberWholesale2); cmdParams.AddInParameter("@NumberWholesale3", DbType.Int32, info.PriceInfo.NumberWholesale3); cmdParams.AddInParameter("@IsValid", DbType.Boolean, info.IsValid); return(DBHelper.ExecuteSql("UPDATE PE_ProductData SET Stocks = @Stocks, AlarmNum = @AlarmNum, PropertyValue = @PropertyValue, Price_Member = @PriceMember, Price_Agent = @PriceAgent, Price_Wholesale1 = @PriceWholesale1, Price_Wholesale2 = @PriceWholesale2, Price_Wholesale3 = @PriceWholesale3, Number_Wholesale1 = @NumberWholesale1, Number_Wholesale2 = @NumberWholesale2, Number_Wholesale3 = @NumberWholesale3, IsValid = @IsValid WHERE ProductId = @ProductId AND TableName = @TableName AND PropertyValue = @PropertyValue", cmdParams)); }
private static ProductDataInfo ProductDataFromrdr(NullableDataReader rdr) { ProductDataInfo info = new ProductDataInfo(); info.Id = rdr.GetInt32("ID"); info.ProductId = rdr.GetInt32("ProductId"); info.TableName = rdr.GetString("TableName"); info.PropertyValue = rdr.GetString("PropertyValue"); info.Stocks = rdr.GetInt32("Stocks"); info.OrderNum = rdr.GetInt32("OrderNum"); info.AlarmNum = rdr.GetInt32("AlarmNum"); info.BuyTimes = rdr.GetInt32("BuyTimes"); info.PriceInfo.NumberWholesale1 = rdr.GetInt32("Number_Wholesale1"); info.PriceInfo.NumberWholesale2 = rdr.GetInt32("Number_Wholesale2"); info.PriceInfo.NumberWholesale3 = rdr.GetInt32("Number_Wholesale3"); info.PriceInfo.Price = rdr.GetDecimal("Price"); info.PriceInfo.PriceAgent = rdr.GetDecimal("Price_Agent"); info.PriceInfo.PriceMember = rdr.GetDecimal("Price_Member"); info.PriceInfo.PriceWholesale1 = rdr.GetDecimal("Price_Wholesale1"); info.PriceInfo.PriceWholesale2 = rdr.GetDecimal("Price_Wholesale2"); info.PriceInfo.PriceWholesale3 = rdr.GetDecimal("Price_Wholesale3"); info.IsValid = rdr.GetBoolean("IsValid"); return(info); }
public static bool Add(int productId, string tableName, ProductDataInfo dataInfo) { return(dal.Add(productId, tableName, dataInfo)); }
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); }