Example #1
0
        /// <summary>
        /// 获得购物车列表
        /// </summary>
        public static IList <Model.cart_items> GetList(int group_id)
        {
            IDictionary <string, int> dic = GetCart();

            if (dic != null)
            {
                IList <Model.cart_items> iList = new List <Model.cart_items>();

                foreach (var item in dic)
                {
                    BLL.article         bll   = new BLL.article();
                    Model.article_goods model = bll.GetGoodsModel(Convert.ToInt32(item.Key));
                    if (model == null)
                    {
                        continue;
                    }
                    Model.cart_items modelt = new Model.cart_items();
                    modelt.id             = model.id;
                    modelt.title          = model.title;
                    modelt.img_url        = model.img_url;
                    modelt.point          = model.point;
                    modelt.price          = model.sell_price;
                    modelt.user_price     = model.sell_price;
                    modelt.stock_quantity = model.stock_quantity;
                    //会员价格
                    if (model.goods_group_prices != null)
                    {
                        Model.goods_group_price gmodel = model.goods_group_prices.Find(p => p.group_id == group_id);
                        if (gmodel != null)
                        {
                            modelt.user_price = gmodel.price;
                        }
                    }
                    modelt.quantity = item.Value;
                    iList.Add(modelt);
                }
                return(iList);
            }
            return(null);
        }
Example #2
0
        /// <summary>
        /// 获得商品价格数据列表
        /// </summary>
        private List <Model.goods_group_price> GetGoodsGroupPriceList(int article_id)
        {
            List <Model.goods_group_price> modelList = new List <Model.goods_group_price>();

            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,article_id,group_id,price from dt_goods_group_price ");
            strSql.Append(" where article_id=" + article_id);
            DataTable dt = DbHelperSQL.Query(strSql.ToString()).Tables[0];

            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Model.goods_group_price model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.goods_group_price();
                    if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    if (dt.Rows[n]["article_id"] != null && dt.Rows[n]["article_id"].ToString() != "")
                    {
                        model.article_id = int.Parse(dt.Rows[n]["article_id"].ToString());
                    }
                    if (dt.Rows[n]["group_id"] != null && dt.Rows[n]["group_id"].ToString() != "")
                    {
                        model.group_id = int.Parse(dt.Rows[n]["group_id"].ToString());
                    }
                    if (dt.Rows[n]["price"] != null && dt.Rows[n]["price"].ToString() != "")
                    {
                        model.price = decimal.Parse(dt.Rows[n]["price"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
 /// <summary>
 /// 返回对应商品的会员价格
 /// </summary>
 /// <param name="goods_id">商品ID</param>
 /// <returns>Decimal</returns>
 protected decimal get_user_goods_price(int goods_id)
 {
     Model.users userModel = GetUserInfo();
     if (userModel == null)
     {
         return(-1);
     }
     Model.article_goods model = new BLL.article().GetGoodsModel(goods_id);
     if (model != null)
     {
         if (model.goods_group_prices != null)
         {
             Model.goods_group_price priceModel = model.goods_group_prices.Find(p => p.group_id == userModel.group_id);
             if (priceModel != null)
             {
                 return(priceModel.price);
             }
         }
         return(model.sell_price);
     }
     return(-1);
 }
Example #4
0
        /// <summary>
        /// �����Ʒ�۸������б�
        /// </summary>
        private List<Model.goods_group_price> GetGoodsGroupPriceList(int article_id)
        {
            List<Model.goods_group_price> modelList = new List<Model.goods_group_price>();

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select id,article_id,group_id,price from dt_goods_group_price ");
            strSql.Append(" where article_id=" + article_id);
            DataTable dt = DbHelperSQL.Query(strSql.ToString()).Tables[0];

            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.goods_group_price model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.goods_group_price();
                    if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    if (dt.Rows[n]["article_id"] != null && dt.Rows[n]["article_id"].ToString() != "")
                    {
                        model.article_id = int.Parse(dt.Rows[n]["article_id"].ToString());
                    }
                    if (dt.Rows[n]["group_id"] != null && dt.Rows[n]["group_id"].ToString() != "")
                    {
                        model.group_id = int.Parse(dt.Rows[n]["group_id"].ToString());
                    }
                    if (dt.Rows[n]["price"] != null && dt.Rows[n]["price"].ToString() != "")
                    {
                        model.price = decimal.Parse(dt.Rows[n]["price"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }