Ejemplo n.º 1
0
        public string getGoodsImg(int goodsId)
        {
            string outresult = "{\"status\":0,\"info\":\"没有产品图片\"}";

            BLL.article_albums art = new BLL.article_albums();
            var info = art.GetModel(goodsId);

            if (info != null)
            {
                outresult = ObjectToJSON(info);
            }


            return(outresult);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获得购物车列表
        /// </summary>
        public static IList <Model.cart_items> GetList(int group_id)
        {
            IDictionary <string, string> dic = GetCart();

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

                foreach (var item in dic)
                {
                    BLL.article   bll   = new BLL.article();
                    Model.article model = bll.GetModel(Convert.ToInt32(item.Key));

                    if (model == null || !model.fields.ContainsKey("sell_price"))
                    {
                        continue;
                    }
                    string[]         strArray = item.Value.Split('|');
                    Model.cart_items modelt   = new Model.cart_items();
                    modelt.id    = model.id;
                    modelt.title = model.title;
                    //modelt.img_url = model.img_url;
                    //获取产品图片
                    DataTable dt  = new BLL.article_albums().GetList(1, " article_id=" + int.Parse((item.Key).ToString()) + " and category_id=1", " id").Tables[0];
                    var       img = "";
                    if (dt.Rows.Count > 0)
                    {
                        img            = dt.Rows[0]["original_path"].ToString();
                        modelt.img_url = img;
                    }
                    else
                    {
                        modelt.img_url = model.img_url;
                    }


                    modelt.quantity = strArray[0];
                    modelt.type     = strArray[1];
                    modelt.weight   = strArray[2];
                    modelt.price    = decimal.Parse(strArray[3]);
                    if (strArray[1] == "智能家居")
                    {
                        modelt.total_price = decimal.Parse(modelt.quantity) * modelt.price;
                    }
                    else
                    {
                        modelt.total_price = decimal.Parse(modelt.quantity) * modelt.price * decimal.Parse(modelt.weight);
                    }

                    totalmodel.payable_amount += modelt.total_price;
                    totalmodel.total_point    += modelt.point;

                    if (model.fields.ContainsKey("point"))
                    {
                        modelt.point = Vincent._DTcms.Utils.StrToInt(model.fields["point"], 0);
                    }
                    modelt.user_price = Vincent._DTcms.Utils.StrToDecimal(model.fields["sell_price"], 0);
                    if (model.fields.ContainsKey("stock_quantity"))
                    {
                        modelt.stock_quantity = Vincent._DTcms.Utils.StrToInt(model.fields["stock_quantity"], 0);
                    }
                    //会员价格
                    if (model.group_price != null)
                    {
                        Model.user_group_price gmodel = model.group_price.Find(p => p.group_id == group_id);
                        if (gmodel != null)
                        {
                            modelt.user_price = gmodel.price;
                        }
                    }
                    iList.Add(modelt);
                }
                return(iList);
            }
            return(null);
        }