Example #1
0
 /// <summary>
 /// 转换成List
 /// </summary>
 public static List <Model.cart_items> ToList(List <Model.cart_keys> ls, int group_id)
 {
     if (ls != null)
     {
         List <Model.cart_items> iList = new List <Model.cart_items>();
         foreach (Model.cart_keys item in ls)
         {
             //查询文章的信息
             Model.article articleModel = new BLL.article().GetModel(item.channel_id, item.article_id);
             if (articleModel == null || !articleModel.fields.ContainsKey("sell_price"))
             {
                 continue;
             }
             //开始赋值
             Model.cart_items modelt = new Model.cart_items();
             modelt.channel_id = articleModel.channel_id;
             modelt.article_id = articleModel.id;
             if (articleModel.fields.ContainsKey("goods_no"))
             {
                 modelt.goods_no = articleModel.fields["goods_no"];
             }
             modelt.title      = articleModel.title;
             modelt.img_url    = articleModel.img_url;
             modelt.sell_price = ConvertTool.ToDecimal(articleModel.fields["sell_price"], 0);
             modelt.user_price = ConvertTool.ToDecimal(articleModel.fields["sell_price"], 0);
             if (articleModel.fields.ContainsKey("point"))
             {
                 modelt.point = ConvertTool.ToInt(articleModel.fields["point"], 0);
             }
             if (articleModel.fields.ContainsKey("stock_quantity"))
             {
                 modelt.stock_quantity = ConvertTool.ToInt(articleModel.fields["stock_quantity"], 0);
             }
             bool setStatus = false; //会员组价格赋值状态
             if (group_id > 0 && articleModel.group_price != null)
             {
                 Model.user_group_price userPriceModel = articleModel.group_price.Find(p => p.group_id == group_id);
                 if (userPriceModel != null)
                 {
                     setStatus         = true; //已赋值
                     modelt.user_price = userPriceModel.price;
                 }
             }
             //如果未曾有会员组价格则使用折扣价格
             if (group_id > 0 && !setStatus)
             {
                 int discount = new BLL.user_groups().GetDiscount(group_id);
                 if (discount > 0)
                 {
                     modelt.user_price = modelt.sell_price * discount / 100;
                 }
             }
             modelt.quantity = item.quantity;
             //添加入列表
             iList.Add(modelt);
         }
         return(iList);
     }
     return(null);
 }
Example #2
0
        public IList <Model.cart_items> GetList(string cart)
        {
            IDictionary <string, string> dic = GetCart(DTKeys.COOKIE_SHOPPING_CART) as Dictionary <string, string>;

            if (dic != null)
            {
                IList <Model.cart_items> iList = new List <Model.cart_items>();
                foreach (var item in dic)
                {
                    try
                    {
                        Model.article_goods model  = bll.GetGoodsModel(Utils.StrToInt(item.Key, 0));
                        Model.cart_items    modelt = new Model.cart_items();
                        if (model != null)
                        {
                            modelt.title    = model.title;
                            modelt.img_url  = model.img_url;
                            modelt.price    = model.sell_price;
                            modelt.id       = model.id;
                            modelt.quantity = Utils.StrToInt(item.Value, 0);
                        }
                        iList.Add(modelt);
                    }
                    catch (Exception eee) { }
                }
                return(iList);
            }
            return(null);
        }
Example #3
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 model = bll.GetModel(Convert.ToInt32(item.Key));
                    if (model == null || !model.fields.ContainsKey("sell_price"))
                    {
                        continue;
                    }
                    Model.cart_items modelt = new Model.cart_items();
                    modelt.id      = model.id;
                    modelt.title   = model.title;
                    modelt.img_url = model.img_url;
                    if (model.fields.ContainsKey("point"))
                    {
                        modelt.point = Utils.StrToInt(model.fields["point"], 0);
                    }
                    modelt.price      = Utils.StrToDecimal(model.fields["WholesalePrice"], 0);
                    modelt.user_price = Utils.StrToDecimal(model.fields["sell_price"], 0);
                    if (model.fields.ContainsKey("stock_quantity"))
                    {
                        modelt.stock_quantity = Utils.StrToInt(model.fields["stock_quantity"], 0);
                    }
                    if (model.fields.ContainsKey("english_name"))
                    {
                        modelt.english_name = model.fields["english_name"].ToString();
                    }
                    if (model.fields.ContainsKey("Barcode"))
                    {
                        modelt.Barcode = model.fields["Barcode"].ToString();
                    }
                    ////会员价格
                    //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;
                    //    }
                    //}
                    modelt.quantity = item.Value;
                    iList.Add(modelt);
                }
                return(iList);
            }
            return(null);
        }
Example #4
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 model = bll.GetModel(Convert.ToInt32(item.Key));
                    if (model == null || !model.fields.ContainsKey("sell_price"))
                    {
                        continue;
                    }
                    Model.cart_items modelt = new Model.cart_items();
                    modelt.id = model.id;
                    modelt.title = model.title;
                    modelt.img_url = model.img_url;
                    if (model.fields.ContainsKey("point"))
                    {
                        modelt.point = Utils.StrToInt(model.fields["point"], 0);
                    }
                    modelt.price = Utils.StrToDecimal(model.fields["sell_price"], 0);
                    modelt.user_price = Utils.StrToDecimal(model.fields["sell_price"], 0);
                    if (model.fields.ContainsKey("stock_quantity"))
                    {
                        modelt.stock_quantity = 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;
                        }
                    }
                    modelt.quantity = item.Value;
                    iList.Add(modelt);
                }
                return iList;
            }
            return null;
        }
Example #5
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);
        }
        /// <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 #7
0
        /// <summary>
        /// 获得购物车列表
        /// </summary>
        public static IList<Model.cart_items> GetList(int group_id)
        {
            IDictionary<string, int> dic = GetCart();
            if (dic==null || dic.Count <= 0)
            {
                 #region 获取数据库购物车
                Model.users model = new BasePage().GetUserInfo();
                if (model != null)
                {
                    BLL.cart cartbll = new BLL.cart();
                    DataTable dt = cartbll.GetList("UserID='" + model.id + "'").Tables[0];
                    if (dt.Rows.Count <= 0)
                    {
                        //return null;
                    }
                    else
                    {
                        dic = new Dictionary<string, int>();
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {

                            dic.Add(dt.Rows[i]["ProductName"].ToString(), int.Parse(dt.Rows[i]["Counts"].ToString()));

                        }

                    }

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

                foreach (var item in dic)
                {
                    BLL.article bll = new BLL.article();

                    //key:1547-27|120,28|122-55
                    int goods_id = Convert.ToInt32(item.Key.Split('-')[0]);
                    string standard = item.Key.Split('-')[1];

                    decimal unit_id = decimal.Parse(item.Key.Split('-')[2], 0);// Convert.ToDecimal(item.Key.Split('-')[2]);
                    Model.article model = bll.GetModel(Convert.ToInt32(goods_id));
                    if (model == null || !model.fields.ContainsKey("sell_price"))
                    {
                        continue;
                    }
                    string standard_value_ids = "";
                    string[] arr_standard = standard.Split(',');
                    foreach (string str in arr_standard)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            standard_value_ids += str.Split('|')[1] + ",";
                        }
                    }
                    if (!string.IsNullOrEmpty(standard_value_ids))
                    {
                        standard_value_ids = standard_value_ids.Substring(0, standard_value_ids.Length - 1);
                    }

                    Model.cart_items modelt = new Model.cart_items();
                    modelt.id = model.id;
                    modelt.title = model.title;
                    modelt.img_url = model.img_url;
                    modelt.standard = standard;
                    modelt.unit_id = unit_id;
                    if (model.fields.ContainsKey("point"))
                    {
                        modelt.point = Utils.StrToInt(model.fields["point"], 0);
                    }

                    modelt.price = Utils.StrToDecimal(model.fields["sell_price"], 0);
                    modelt.user_price = Utils.StrToDecimal(model.fields["sell_price"], 0);

                    //单位价格  -- 有单位  无会员 无规格
                    BLL.unit bll_unit = new BLL.unit();
                    Model.unit model_unit = bll_unit.GetModel(unit_id);
                    if (model_unit != null)
                    {
                        modelt.price = Utils.StrToDecimal(model.fields["sell_price"], 0) * model_unit.quantity * (model_unit.rate / 100);
                        modelt.user_price = Utils.StrToDecimal(model.fields["sell_price"], 0) * model_unit.quantity * (model_unit.rate / 100);
                    }

                    //规格价格  --有/无单位  无会员  有规格
                    BLL.standard_price bll_standard_price = new BLL.standard_price();

                    DataTable dt_standard_price = bll_standard_price.GetList("standard_value_ids='" + standard_value_ids + "' and good_id=" + goods_id).Tables[0];
                    if (dt_standard_price != null && dt_standard_price.Rows.Count > 0)
                    {
                        modelt.user_price = modelt.price = Utils.StrToDecimal(dt_standard_price.Rows[0]["sell_price"].ToString(), 0);
                        if (model_unit != null)
                        {
                            modelt.user_price = modelt.price = Utils.StrToDecimal(dt_standard_price.Rows[0]["sell_price"].ToString(), 0) * model_unit.quantity * (model_unit.rate / 100);
                        }
                    }

                    if (model.fields.ContainsKey("stock_quantity"))
                    {
                        modelt.stock_quantity = 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;
                            //有规格才有规格等级价格
                            if (dt_standard_price != null && dt_standard_price.Rows.Count > 0)
                            {
                                BLL.standard_group_price bll_standard_group_price = new BLL.standard_group_price();
                                DataTable dt_standard_group_price = bll_standard_group_price.GetList("good_id=" + goods_id + " and standard_price_id=" + dt_standard_price.Rows[0]["id"].ToString() + " and group_id=" + group_id).Tables[0];
                                //有规格会员价格
                                if (dt_standard_group_price != null && dt_standard_group_price.Rows.Count > 0)
                                {
                                    //规格会员价格  无单位-- 有规格 有会员
                                    modelt.user_price = Convert.ToDecimal(dt_standard_group_price.Rows[0]["group_price"]);
                                }

                            }
                            if (model_unit != null)
                            {
                                modelt.user_price = modelt.user_price * model_unit.quantity * (model_unit.rate / 100);
                            }
                        }
                    }
                    modelt.quantity = item.Value;
                    iList.Add(modelt);
                }
                return iList;
            }
            return null;
        }
Example #8
0
 /// <summary>
 /// 转换成List
 /// </summary>
 public static List<Model.cart_items> ToList(List<Model.cart_keys> ls, int group_id)
 {
     if (ls != null)
     {
         List<Model.cart_items> iList = new List<Model.cart_items>();
         foreach (Model.cart_keys item in ls)
         {
             //查询文章的信息
             Model.article articleModel = new BLL.article().GetModel(item.article_id);
             if (articleModel == null || !articleModel.fields.ContainsKey("sell_price"))
             {
                 continue;
             }
             //查询商品信息
             Model.article_goods goodsModel = articleModel.goods.Find(p => p.id == item.goods_id);
             if (articleModel.goods != null && articleModel.goods.Count > 0 && goodsModel == null)
             {
                 continue;
             }
             //开始赋值
             Model.cart_items modelt = new Model.cart_items();
             modelt.article_id = articleModel.id;
             if (articleModel.fields.ContainsKey("goods_no"))
             {
                 modelt.goods_no = articleModel.fields["goods_no"];
             }
             modelt.title = articleModel.title;
             modelt.img_url = articleModel.img_url;
             modelt.sell_price = Utils.StrToDecimal(articleModel.fields["sell_price"], 0);
             modelt.user_price = Utils.StrToDecimal(articleModel.fields["sell_price"], 0);
             if (articleModel.fields.ContainsKey("point"))
             {
                 modelt.point = Utils.StrToInt(articleModel.fields["point"], 0);
             }
             if (articleModel.fields.ContainsKey("stock_quantity"))
             {
                 modelt.stock_quantity = Utils.StrToInt(articleModel.fields["stock_quantity"], 0);
             }
             bool setStatus = false; //会员组价格赋值状态
             if (goodsModel != null)
             {
                 modelt.stock_quantity = goodsModel.stock_quantity; //库存
                 modelt.sell_price = goodsModel.sell_price; //商品价格
                 modelt.user_price = goodsModel.sell_price; //会员组价格
                 modelt.goods_id = goodsModel.id;
                 modelt.goods_no = goodsModel.goods_no;
                 modelt.spec_text = goodsModel.spec_text;
                 //会员组价格
                 if (group_id > 0 && goodsModel.group_prices != null)
                 {
                     Model.user_group_price userPriceModel = goodsModel.group_prices.Find(p => p.group_id == group_id);
                     if (userPriceModel != null)
                     {
                         setStatus = true; //已赋值
                         modelt.user_price = userPriceModel.price;
                     }
                 }
             }
             //如果未曾有会员组价格则使用折扣价格
             if (group_id > 0 && !setStatus)
             {
                 int discount = new BLL.user_groups().GetDiscount(group_id);
                 if (discount > 0)
                 {
                     modelt.user_price = modelt.sell_price * discount / 100;
                 }
             }
             modelt.quantity = item.quantity;
             //添加入列表
             iList.Add(modelt);
         }
         return iList;
     }
     return null;
 }
Example #9
0
        /// <summary>
        /// 转换成List
        /// </summary>
        public static List <Model.cart_items> ToList(List <Model.cart_keys> ls, int group_id)
        {
            if (ls != null)
            {
                List <Model.cart_items> iList = new List <Model.cart_items>();
                foreach (Model.cart_keys item in ls)
                {
                    //查询文章的信息
                    Model.article articleModel = new BLL.article().GetModel(item.article_id);
                    if (articleModel == null || !articleModel.fields.ContainsKey("sell_price"))
                    {
                        continue;
                    }
                    //查询商品信息
                    Model.article_goods goodsModel = articleModel.goods.Find(p => p.id == item.goods_id);
                    if (articleModel.goods != null && articleModel.goods.Count > 0 && goodsModel == null)
                    {
                        continue;
                    }
                    //开始赋值
                    Model.cart_items modelt = new Model.cart_items();
                    modelt.article_id = articleModel.id;
                    if (articleModel.fields.ContainsKey("goods_no"))
                    {
                        modelt.goods_no = articleModel.fields["goods_no"];
                    }
                    modelt.title       = articleModel.title;
                    modelt.img_url     = articleModel.img_url;
                    modelt.seller_id   = articleModel.user_id;   //供应商id
                    modelt.seller_name = articleModel.user_name; //供应商name
                    modelt.sell_price  = Utils.StrToDecimal(articleModel.fields["sell_price"], 0);
                    modelt.user_price  = Utils.StrToDecimal(articleModel.fields["sell_price"], 0);
                    if (articleModel.fields.ContainsKey("point"))
                    {
                        modelt.point = Utils.StrToInt(articleModel.fields["point"], 0);
                    }
                    if (articleModel.fields.ContainsKey("stock_quantity"))
                    {
                        modelt.stock_quantity = Utils.StrToInt(articleModel.fields["stock_quantity"], 0);
                    }
                    bool setStatus = false; //会员组价格赋值状态
                    if (goodsModel != null)
                    {
                        modelt.stock_quantity = goodsModel.stock_quantity; //库存
                        modelt.sell_price     = goodsModel.sell_price;     //商品价格
                        modelt.user_price     = goodsModel.sell_price;     //会员组价格
                        modelt.goods_id       = goodsModel.id;
                        modelt.goods_no       = goodsModel.goods_no;
                        modelt.spec_text      = goodsModel.spec_text;
                        //会员组价格
                        if (group_id > 0 && goodsModel.group_prices != null)
                        {
                            Model.user_group_price userPriceModel = goodsModel.group_prices.Find(p => p.group_id == group_id);
                            if (userPriceModel != null)
                            {
                                setStatus         = true; //已赋值
                                modelt.user_price = userPriceModel.price;
                            }
                        }
                    }
                    //如果未曾有会员组价格则使用折扣价格
                    if (group_id > 0 && !setStatus)
                    {
                        int discount = new BLL.user_groups().GetDiscount(group_id);
                        if (discount > 0)
                        {
                            modelt.user_price = modelt.sell_price * discount / 100;
                        }
                    }
                    modelt.quantity = item.quantity;
                    modelt.use_date = item.use_date;//add by 赵成龙

                    //添加入列表
                    iList.Add(modelt);
                }
                return(iList);
            }
            return(null);
        }
Example #10
0
        /// <summary>
        /// 獲得購物車列表
        /// </summary>
        public static IList <Model.cart_items> GetList(int group_id)
        {
            BLL.goods            bllgoods  = new BLL.goods();
            BLL.article          bll       = new BLL.article();
            BLL.user_group_price bll_group = new BLL.user_group_price();
            Tea.Model.users      _users    = new Tea.Web.UI.UserPage().GetUserInfo();

            IDictionary <string, int> dic = GetCart();

            if (dic != null)
            {
                int hong = 0, lv = 0;

                IList <Model.cart_items> i_List = new List <Model.cart_items>();
                string[] CartKey = new string[2];
                foreach (var item in dic)
                {
                    CartKey = item.Key.Split('_');
                    Model.cart_items modelt = new Model.cart_items();
                    if (CartKey.Length > 1)
                    {
                        Model.article model      = bll.GetModel(Convert.ToInt32(CartKey[0]));
                        Model.goods   modelgoods = bllgoods.GetModel(Convert.ToInt32(CartKey[1]));

                        if (model == null || modelgoods == null)
                        {
                            continue;
                        }
                        if (model.status != 0)
                        {
                            continue;
                        }
                        if (model.add_time > System.DateTime.Now || modelgoods.stock_quantity < 1)
                        {
                            continue;
                        }
                        if (model.xia_date != null && model.xia_date.Value.AddDays(1) < System.DateTime.Now)
                        {
                            continue;
                        }
                        modelt.ps          = model.call_index;
                        modelt.id          = model.id;
                        modelt.key         = item.Key;
                        modelt.title       = model.title;
                        modelt.sub_title   = model.sub_title;
                        modelt.img_url     = model.img_url;
                        modelt.goods_color = modelgoods.color;
                        modelt.goods_size  = modelgoods.size;
                        modelt.zhong       = modelgoods.zhong;
                        modelt.chang       = modelgoods.chang;
                        modelt.kuan        = modelgoods.kuan;
                        modelt.gao         = modelgoods.gao;
                        modelt.point       = model.point;
                        modelt.price       = modelgoods.market_price;
                        modelt.user_price  = modelgoods.sell_price;
                        if (modelgoods.yu_lock > 0)
                        {
                            Tea.Model.sales models = new Tea.BLL.sales().GetModel(modelgoods.yu_lock);
                            if (models != null && models.type == "2" && models.status == 1 && models.start_time < System.DateTime.Now && (models.end_time == null || models.end_time > System.DateTime.Now))
                            {
                                modelt.user_price = modelgoods.yu_num;
                            }
                        }
                        modelt.goodsid        = modelgoods.id;
                        modelt.goods_code     = modelgoods.goods_no;
                        modelt.stock_quantity = modelgoods.stock_quantity;
                        modelt.quantity       = item.Value;
                        modelt.sales_id       = modelgoods.yu_lock;
                        modelt.by             = model.wheresql;
                        modelt.hdcode         = model.guige;
                        if (model.is_msg == 0)
                        {
                            modelt.sales_name = "no";
                        }
                        modelt.psmoney = model.brand_id.ToString();
                        if (group_id > 0)
                        {
                            if (model.brand_id == 1)
                            {
                                if (_users != null && _users.group_id == 2)
                                {
                                    Model.user_group_price userPriceModel = bll_group.GetModel(modelt.goodsid, _users.id);
                                    if (userPriceModel != null)
                                    {
                                        modelt.user_price = userPriceModel.price;
                                    }
                                }
                            }
                            i_List.Add(modelt);
                        }
                        else
                        {
                            if (model.brand_id == 1 && group_id == -3)
                            {
                                if (_users != null && _users.group_id == 2)
                                {
                                    Model.user_group_price userPriceModel = bll_group.GetModel(modelt.goodsid, _users.id);
                                    if (userPriceModel != null)
                                    {
                                        modelt.user_price = userPriceModel.price;
                                        modelt.by         = "vip";
                                        i_List.Add(modelt);
                                    }
                                }
                            }

                            if (model.brand_id == 3 && group_id == -2)
                            {
                                i_List.Add(modelt);
                            }
                            if (model.brand_id != 3 && group_id == -1 && model.wheresql != "jiajia")
                            {
                                if (_users.group_id == 1)
                                {
                                    i_List.Add(modelt);
                                }
                                else
                                {
                                    Model.user_group_price userPriceModel = bll_group.GetModel(modelt.goodsid, _users.id);
                                    if (userPriceModel == null)
                                    {
                                        i_List.Add(modelt);
                                    }
                                }
                            }
                            try
                            {
                                if (model.wheresql == "jiajia" && group_id == -1 && Convert.ToInt32(CartKey[2]) == 1)
                                {
                                    i_List.Add(modelt);
                                }
                                if (model.wheresql == "jiajia" && group_id == -2 && Convert.ToInt32(CartKey[2]) == 2)
                                {
                                    i_List.Add(modelt);
                                }
                                if (model.wheresql == "jiajia" && group_id == -3 && Convert.ToInt32(CartKey[2]) == 3)
                                {
                                    i_List.Add(modelt);
                                }
                            }
                            catch (Exception eee)
                            {
                            }
                        }
                    }
                }
                return(i_List);
            }
            return(null);
        }
Example #11
0
        protected void btnlogin_Click(object sender, ImageClickEventArgs e)
        {
            IDictionary <string, string> dic = GetCart(DTKeys.COOKIE_SHOPPING_CART) as Dictionary <string, string>;

            cartModel = GetTotal(DTKeys.COOKIE_SHOPPING_CART);
            if (dic == null)
            {
                Response.Redirect("productJPlist.aspx");
            }
            Model.orders model = new Model.orders();
            model.order_no        = hideNo.Value;
            model.user_id         = WEBUserCurrent.UserID;
            model.user_name       = WEBUserCurrent.UserName;
            model.payment_id      = string.IsNullOrEmpty(ddlzhifu.SelectedValue) ? 0 : int.Parse(ddlzhifu.SelectedValue);     //付款類型
            model.distribution_id = string.IsNullOrEmpty(ddlpeisong.SelectedValue) ? 0 : int.Parse(ddlpeisong.SelectedValue); //配送類型
            model.accept_name     = txtusername.Value;
            model.post_code       = txtyoubian.Value;
            model.telphone        = txtlianxidianhua.Value;
            model.mobile          = txtphone.Value;
            model.address         = txtdizhi.Value;
            model.message         = txtliuyan.Value;



            model.payable_freight = decimal.Parse(Fee);             //應付運費
            model.real_freight    = decimal.Parse(Fee);             //實付運費

            model.payment_fee = 0;                                  //付款手續費
            model.point       = Utils.StringToNum(hidePoint.Value); //獲得的積分
            model.add_time    = DateTime.Now;
            model.order_goods = new List <order_goods>();
            decimal Price = 0m; decimal GoodsPrice = 0, GoodToablPrice = 0;

            if (dic != null)
            {
                IList <Model.cart_items> iList = new List <Model.cart_items>();
                foreach (var item in dic)
                {
                    try
                    {
                        Model.article_goods modelPro = bll.GetGoodsModel(Utils.StrToInt(item.Key, 0));
                        Model.cart_items    modelt   = new Model.cart_items();
                        if (model != null)
                        {
                            int ProductID  = modelPro.id;
                            int ShopNumber = Utils.StrToInt(item.Value, 0);
                            Model.article_goods modelpro = bll.GetGoodsModel(ProductID);
                            Price           = modelpro.sell_price;
                            GoodsPrice      = ShopNumber * Price;
                            GoodToablPrice += GoodsPrice;


                            Model.order_goods detail = new Model.order_goods();
                            detail.goods_id    = ProductID;
                            detail.goods_name  = modelPro.title;
                            detail.goods_price = modelPro.sell_price;
                            detail.point       = Utils.StringToNum(hidePoint.Value);
                            detail.quantity    = ShopNumber;
                            detail.real_price  = modelpro.market_price;
                            model.order_goods.Add(detail);
                        }
                    }
                    catch (Exception eee) { }
                }
            }
            #region 算折扣
            string  aa = Request.Form["chkPoint"];
            decimal PousePrice = 0, LastPrice = 0;
            if (!string.IsNullOrEmpty(aa))
            {
                PousePrice = GoodToablPrice - decimal.Parse(hidePoint.Value);
                //model.payable_amount = model.order_amount;
                //model.real_amount = model.order_amount;
            }
            else
            {
                PousePrice = GoodToablPrice;
            }
            #endregion

            #region 算运费
            if (hideFee.Value == "2")
            {
                decimal FeeLv = TwoTypeFee;
                if (PousePrice >= FeeLv)
                {
                    LastPrice             = PousePrice;
                    model.payable_freight = 0; //應付運費
                    model.real_freight    = 0; //實付運費
                }
                else
                {
                    LastPrice = PousePrice + decimal.Parse(Fee);  //訂單總金額
                }
            }
            else
            {
                LastPrice = PousePrice + decimal.Parse(Fee);  //訂單總金額
            }
            #endregion

            model.order_amount   = LastPrice; //訂單總金額
            model.payable_amount = LastPrice; //應付商品總金額
            model.real_amount    = LastPrice; //實付商品總金額


            #region 清空购物车
            Clear(DTKeys.COOKIE_SHOPPING_CART, "0");
            #endregion 清空购物车

            //普通訂單的情況下修改狀態
            if (!string.IsNullOrEmpty(Request.QueryString["cjid"]))
            {
                int                 id           = Convert.ToInt32(Request.QueryString["cjid"]);
                BLL.article         bll          = new BLL.article();
                Model.article_goods productmodel = bll.GetGoodsModel(id);
                bll.UpdateField(id, "Status=3");
                model.status = 6;
            }
            int    bk  = bllorder.Add(model);
            string Url = "pay.aspx?";
            Url += "paymenttype=" + ddlzhifu.SelectedValue + "";
            Url += "&id=" + bk + "";
            // string UserUrl = "userinfo.aspx";
            if (bk > 0)
            {
                //setEmail(model.order_no);
                UpUserPoint(PousePrice);
                int Uid = WEBUserCurrent.UserID;
                User.UpJianPoint(Uid, Utils.StringToNum(hidePoint.Value));
                AddAmount(LastPrice);
                this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('送出訂單成功,請牢記訂單號:" + model.order_no + "');window.location.href = '" + Url + "';</script>");
                // Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "pay", "window.open('" + Url + "');window.location.href='" + UserUrl + "';", true);

                //Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "pay", "window.open('" + Url + "');", true);

                //Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "transfer", "window.location.href='" + UserUrl + "';", true);
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('送出失敗,請重新送出');window.location.href = '" + Url + "';</script>");
            }
        }
Example #12
0
        /// <summary>
        /// 獲得購物車列表
        /// </summary>
        public static IList <Model.cart_items> GetList(int group_id, int uid)
        {
            BLL.goods            bllgoods  = new BLL.goods();
            BLL.article          bll       = new BLL.article();
            BLL.user_group_price bll_group = new BLL.user_group_price();
            Tea.Model.users      _users    = new BLL.users().GetModel(uid);

            IDictionary <string, int> dic = GetCart();

            if (dic != null)
            {
                int hong = 0, lv = 0;

                IList <Model.cart_items> i_List = new List <Model.cart_items>();
                string[] CartKey = new string[2];
                foreach (var item in dic)
                {
                    CartKey = item.Key.Split('_');
                    Model.cart_items modelt = new Model.cart_items();
                    if (CartKey.Length > 1)
                    {
                        Model.article model      = bll.GetModel(Convert.ToInt32(CartKey[0]));
                        Model.goods   modelgoods = bllgoods.GetModel(Convert.ToInt32(CartKey[1]));

                        if (model == null || modelgoods == null)
                        {
                            continue;
                        }
                        modelt.ps             = model.call_index;
                        modelt.id             = model.id;
                        modelt.key            = item.Key;
                        modelt.title          = model.title;
                        modelt.sub_title      = model.sub_title;
                        modelt.img_url        = model.img_url;
                        modelt.goods_color    = modelgoods.color;
                        modelt.goods_size     = modelgoods.size;
                        modelt.zhong          = modelgoods.zhong;
                        modelt.chang          = modelgoods.chang;
                        modelt.kuan           = modelgoods.kuan;
                        modelt.gao            = modelgoods.gao;
                        modelt.point          = model.point;
                        modelt.price          = modelgoods.market_price;
                        modelt.user_price     = modelgoods.sell_price;
                        modelt.goodsid        = modelgoods.id;
                        modelt.goods_code     = modelgoods.goods_no;
                        modelt.stock_quantity = modelgoods.stock_quantity;
                        modelt.quantity       = item.Value;
                        modelt.sales_id       = modelgoods.yu_lock;
                        modelt.by             = model.wheresql;
                        modelt.psmoney        = model.brand_id.ToString();
                        if (group_id > 0)
                        {
                            if (model.brand_id == 1)
                            {
                                if (_users != null && _users.group_id == 2)
                                {
                                    Model.user_group_price userPriceModel = bll_group.GetModel(modelt.goodsid, _users.id);
                                    if (userPriceModel != null)
                                    {
                                        modelt.user_price = userPriceModel.price;
                                    }
                                }
                            }
                            i_List.Add(modelt);
                        }
                        else
                        {
                            if (model.brand_id == 1 && group_id == -3)
                            {
                                if (_users != null && _users.group_id == 2)
                                {
                                    Model.user_group_price userPriceModel = bll_group.GetModel(modelt.goodsid, _users.id);
                                    if (userPriceModel != null)
                                    {
                                        modelt.user_price = userPriceModel.price;
                                        modelt.by         = "vip";
                                        i_List.Add(modelt);
                                    }
                                }
                            }

                            if (model.brand_id == 3 && group_id == -2)
                            {
                                i_List.Add(modelt);
                            }
                            if (model.brand_id != 3 && group_id == -1)
                            {
                                if (_users.group_id == 1)
                                {
                                    i_List.Add(modelt);
                                }
                                else
                                {
                                    Model.user_group_price userPriceModel = bll_group.GetModel(modelt.goodsid, _users.id);
                                    if (userPriceModel == null)
                                    {
                                        i_List.Add(modelt);
                                    }
                                }
                            }
                        }
                    }
                }
                return(i_List);
            }
            return(null);
        }
Example #13
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);
        }
Example #14
0
        /// <summary>
        /// 获得购物车列表
        /// </summary>
        public static IList <Model.cart_items> GetList(int group_id)
        {
            IDictionary <string, int> dic = GetCart();

            if (dic == null || dic.Count <= 0)
            {
                #region 获取数据库购物车
                Model.users model = new BasePage().GetUserInfo();
                if (model != null)
                {
                    BLL.cart  cartbll = new BLL.cart();
                    DataTable dt      = cartbll.GetList("UserID='" + model.id + "'").Tables[0];
                    if (dt.Rows.Count <= 0)
                    {
                        //return null;
                    }
                    else
                    {
                        dic = new Dictionary <string, int>();
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            dic.Add(dt.Rows[i]["ProductName"].ToString(), int.Parse(dt.Rows[i]["Counts"].ToString()));
                        }
                    }
                }
                #endregion
            }
            if (dic != null)
            {
                IList <Model.cart_items> iList = new List <Model.cart_items>();

                foreach (var item in dic)
                {
                    BLL.article bll = new BLL.article();


                    //key:1547-27|120,28|122-55
                    int    goods_id = Convert.ToInt32(item.Key.Split('-')[0]);
                    string standard = item.Key.Split('-')[1];

                    decimal       unit_id = decimal.Parse(item.Key.Split('-')[2], 0);// Convert.ToDecimal(item.Key.Split('-')[2]);
                    Model.article model   = bll.GetModel(Convert.ToInt32(goods_id));
                    if (model == null || !model.fields.ContainsKey("sell_price"))
                    {
                        continue;
                    }
                    string   standard_value_ids = "";
                    string[] arr_standard       = standard.Split(',');
                    foreach (string str in arr_standard)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            standard_value_ids += str.Split('|')[1] + ",";
                        }
                    }
                    if (!string.IsNullOrEmpty(standard_value_ids))
                    {
                        standard_value_ids = standard_value_ids.Substring(0, standard_value_ids.Length - 1);
                    }

                    Model.cart_items modelt = new Model.cart_items();
                    modelt.id       = model.id;
                    modelt.title    = model.title;
                    modelt.img_url  = model.img_url;
                    modelt.standard = standard;
                    modelt.unit_id  = unit_id;
                    if (model.fields.ContainsKey("point"))
                    {
                        modelt.point = Utils.StrToInt(model.fields["point"], 0);
                    }

                    modelt.price      = Utils.StrToDecimal(model.fields["sell_price"], 0);
                    modelt.user_price = Utils.StrToDecimal(model.fields["sell_price"], 0);

                    //单位价格  -- 有单位  无会员 无规格
                    BLL.unit   bll_unit   = new BLL.unit();
                    Model.unit model_unit = bll_unit.GetModel(unit_id);
                    if (model_unit != null)
                    {
                        modelt.price      = Utils.StrToDecimal(model.fields["sell_price"], 0) * model_unit.quantity * (model_unit.rate / 100);
                        modelt.user_price = Utils.StrToDecimal(model.fields["sell_price"], 0) * model_unit.quantity * (model_unit.rate / 100);
                    }

                    //规格价格  --有/无单位  无会员  有规格
                    BLL.standard_price bll_standard_price = new BLL.standard_price();

                    DataTable dt_standard_price = bll_standard_price.GetList("standard_value_ids='" + standard_value_ids + "' and good_id=" + goods_id).Tables[0];
                    if (dt_standard_price != null && dt_standard_price.Rows.Count > 0)
                    {
                        modelt.user_price = modelt.price = Utils.StrToDecimal(dt_standard_price.Rows[0]["sell_price"].ToString(), 0);
                        if (model_unit != null)
                        {
                            modelt.user_price = modelt.price = Utils.StrToDecimal(dt_standard_price.Rows[0]["sell_price"].ToString(), 0) * model_unit.quantity * (model_unit.rate / 100);
                        }
                    }


                    if (model.fields.ContainsKey("stock_quantity"))
                    {
                        modelt.stock_quantity = 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;
                            //有规格才有规格等级价格
                            if (dt_standard_price != null && dt_standard_price.Rows.Count > 0)
                            {
                                BLL.standard_group_price bll_standard_group_price = new BLL.standard_group_price();
                                DataTable dt_standard_group_price = bll_standard_group_price.GetList("good_id=" + goods_id + " and standard_price_id=" + dt_standard_price.Rows[0]["id"].ToString() + " and group_id=" + group_id).Tables[0];
                                //有规格会员价格
                                if (dt_standard_group_price != null && dt_standard_group_price.Rows.Count > 0)
                                {
                                    //规格会员价格  无单位-- 有规格 有会员
                                    modelt.user_price = Convert.ToDecimal(dt_standard_group_price.Rows[0]["group_price"]);
                                }
                            }
                            if (model_unit != null)
                            {
                                modelt.user_price = modelt.user_price * model_unit.quantity * (model_unit.rate / 100);
                            }
                        }
                    }
                    modelt.quantity = item.Value;
                    iList.Add(modelt);
                }
                return(iList);
            }
            return(null);
        }