/// <summary>
 /// 获取购物车商品数量
 /// </summary>
 public int GetChartCount()
 {
     int count = 0;
     BLL.ShoppingCartBase cart = new BLL.ShoppingCartBase();
     var list = cart.GetModelList(" sc_IsDel = 0 and m_ID = " + LoginMember.m_ID);
     if (list != null)
     {
         count = list.Sum(m => m.sc_pCount.Value);
     }
     return count;
 }
        //下方菜单
        public ActionResult bottomMenu()
        {
            int count = 0;
            BLL.ShoppingCartBase cart = new BLL.ShoppingCartBase();
            if (LoginMember != null)
            {
                var list = cart.GetModelList(" sc_IsDel = 0 and m_ID = " + LoginMember.m_ID);
                if (list != null)
                {
                    count = list.Sum(m => m.sc_pCount.Value);
                }
            }

                ViewData["count"] = count;
                return View();
        }
예제 #3
0
 /// <summary>
 /// 获取购物车数据
 /// </summary>
 /// <returns>有数据返回true</returns>
 public bool GetChartList()
 {
     //会员ID
     if (LoginMember != null)
     {
         BLL.ShoppingCartBase shop = new BLL.ShoppingCartBase();
         var list = shop.GetModelList(" sc_Status = 0 and sc_IsDel = 0 and m_ID = " + LoginMember.m_ID);
         //获取SKU Id列表
         string ids = "";
         foreach (var model in list)
         {
             if (!string.IsNullOrWhiteSpace(ids))
             {
                 ids += ",";
             }
             ids += model.sku_ID;
         }
         if (!string.IsNullOrWhiteSpace(ids))
         {
             var dt = new BLL.SKUBase().GetSKUDetial(" and sku_ID in (" + ids + ")", true);
             if (dt != null && dt.Rows.Count != 0)
             {
                 dt.Columns.Add("sc_pCount", Type.GetType("System.Int32"));//商品数量
                 dt.Columns.Add("sc_pCountStatus", Type.GetType("System.String"));//商品库存状态
                 dt.Columns.Add("sc_IsGP", Type.GetType("System.Boolean"));//团购标识
                 foreach (DataRow row in dt.Rows)
                 {
                     var model = list.Where(m => m.sku_ID == Convert.ToInt32(row["sku_ID"])).FirstOrDefault();
                     if (model != null)
                     {
                         row["sc_pCount"] = model.sc_pCount;
                         string sql = " sku_ID = " + row["sku_ID"] + " and gp_IsDel = 0 and gp_StatusCode = 0 and gp_EndTime > '" + DateTime.Now + "' and gp_pCount-gp_SaleCount>0";
                         if (model.sc_IsGP)
                         {
                             //团购
                             var gpBase = _gpBase.GetModelList(sql).FirstOrDefault();
                             if (gpBase != null)
                             {
                                 //团购取团购价格
                                 row["sku_Price"] = gpBase.gp_pPric;
                                 row["sc_IsGP"] = true;
                                 if (model.sc_pCount <= gpBase.gp_pCount - gpBase.gp_SaleCount)
                                 {
                                     row["sc_pCountStatus"] = "有货";
                                 }
                                 else
                                 {
                                     row["sc_pCountStatus"] = "库存不足";
                                 }
                             }
                             else
                             {
                                 row["sc_pCountStatus"] = "团购结束";
                             }
                         }
                         else
                         {
                             row["sc_IsGP"] = false;
                             //库存
                             var skuBase = _skuBase.GetModel(Convert.ToInt32(row["sku_ID"]));
                             if (model.sc_pCount <= skuBase.sku_Stock)
                             {
                                 row["sc_pCountStatus"] = "有货";
                             }
                             else
                             {
                                 row["sc_pCountStatus"] = "库存不足";
                             }
                         }
                     }
                 }
                 ViewData["chartList"] = dt;
                 return true;
             }
         }
         return false;
     }
     else
     {
         Response.Redirect("/wapLogin/Login");
         return false;
     }
 }
        /// <summary>
        /// 生成订单详细
        /// </summary>
        public void CreateOrderSKUDetail(int orderID)
        {
            try
            {
                var context = System.Web.HttpContext.Current;
                string mID = context.Request.Params["mID"];
                string ids = context.Request.Params["ids"];
                BLL.ShoppingCartBase shop = new BLL.ShoppingCartBase();
                string idslist = ids.Trim(',');
                var list = shop.GetModelList(" sc_IsDel = 0 and m_ID = " + mID + " and sku_ID in (" + idslist + ")");
                BLL.OrderSKUDetail bos = new BLL.OrderSKUDetail();
                BLL.ShoppingCartBase bscb = new BLL.ShoppingCartBase();
                BLL.GroupPurchaseBase bgpb = new BLL.GroupPurchaseBase();
                BLL.SKUBase bskuB = new BLL.SKUBase();

                foreach (var model in list)
                {
                    //生成订单详情
                    Model.OrderSKUDetail mosd = new Model.OrderSKUDetail();
                    mosd.o_ID = orderID;
                    mosd.os_pCount = model.sc_pCount;
                    mosd.sku_ID = model.sku_ID;
                    mosd.os_IsGP = model.sc_IsGP;
                    mosd.os_Price = model.sc_pPric;
                    mosd.os_chima=model.sc_chima;
                    mosd.os_yanse=model.sc_yanse;
                    //更改购物车状态
                    bscb.ChangeStatus(true, Convert.ToInt32(mID), model.sku_ID.ToString());
                    //减少库存,增加售出数量
                    var msku = bskuB.GetModel(model.sku_ID.Value);
                    msku.sku_Stock = msku.sku_Stock - model.sc_pCount;
                    msku.sku_SalesCount = msku.sku_SalesCount+ model.sc_pCount.Value;
                    //判断库存
                    if (msku.sku_Stock < 0)
                    {
                        throw new Exception("库存不足");
                    }

                    bskuB.Update(msku);
                    if (model.sc_IsGP)
                    {
                        //增加团购卖出数量
                        string sql = " sku_ID = " + model.sku_ID.Value + " and gp_IsDel = 0 and gp_StatusCode = 0 and gp_StartTime <= '" + DateTime.Now + "' and gp_EndTime >= '" + DateTime.Now + "'";
                        var mgp = bgpb.GetModelList(sql).FirstOrDefault();
                        if (mgp != null)
                        {
                            mgp.gp_SaleCount += model.sc_pCount.Value;
                            if (mgp.gp_SaleCount > mgp.gp_pCount.Value)
                            {
                                throw new Exception("库存不足");
                            }
                            bgpb.Update(mgp);
                        }
                    }
                    bos.Add(mosd);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #5
0
        /// <summary>
        /// 加载商品清单
        /// </summary>
        //public object GetProductsList(string ids)
        //{
        //    ids = ids.Trim(',');
        //    //会员ID
        //    BLL.ShoppingCartBase shop = new BLL.ShoppingCartBase();
        //    var list = shop.GetModelList(" sc_IsDel = 0 and m_ID = " + mimodel.m_ID + "and sku_ID in (" + ids + ")");
        //    if (!string.IsNullOrWhiteSpace(ids))
        //    {
        //        var dt = new BLL.SKUBase().GetSKUDetial(" and sku_ID in (" + ids + ")", true);
        //        if (dt != null)
        //        {
        //            dt.Columns.Add("sc_pCount", Type.GetType("System.Int32"));//商品数量
        //            dt.Columns.Add("sc_pCountStatus", Type.GetType("System.String"));//商品库存状态
        //            dt.Columns.Add("sc_IsGP", Type.GetType("System.Boolean"));//团购标识
        //            foreach (DataRow row in dt.Rows)
        //            {
        //                var model = list.Where(m => m.sku_ID == Convert.ToInt32(row["sku_ID"])).FirstOrDefault();
        //                if (model != null)
        //                {
        //                    row["sc_pCount"] = model.sc_pCount;
        //                    string sql = " sku_ID = " + row["sku_ID"] + " and gp_IsDel = 0 and gp_StatusCode = 0 and gp_StartTime <= '" + DateTime.Now + "' and gp_EndTime >= '" + DateTime.Now + "'";
        //                    //团购
        //                    var gpBase = _gpBase.GetModelList(sql).FirstOrDefault();
        //                    if (gpBase != null)
        //                    {
        //                        //团购取团购价格
        //                        row["sku_Price"] = gpBase.gp_pPric;
        //                        row["sc_IsGP"] = true;
        //                        if (model.sc_pCount <= gpBase.gp_pCount - gpBase.gp_SaleCount)
        //                        {
        //                            row["sc_pCountStatus"] = "有货";
        //                        }
        //                        else
        //                        {
        //                            row["sc_pCountStatus"] = "库存不足";
        //                        }
        //                    }
        //                    else
        //                    {
        //                        row["sc_IsGP"] = false;
        //                        //库存
        //                        var skuBase = _skuBase.GetModel(Convert.ToInt32(row["sku_ID"]));
        //                        if (model.sc_pCount <= skuBase.sku_Stock)
        //                        {
        //                            row["sc_pCountStatus"] = "有货";
        //                        }
        //                        else
        //                        {
        //                            row["sc_pCountStatus"] = "库存不足";
        //                        }
        //                    }
        //                }
        //            }
        //        }
        //        ViewData["OrderProducts"] = dt;
        //    }
        //    return ViewData["OrderProducts"];
        //}
        public object GetProductsList(string ids)
        {
            ids = ids.Trim(',');
            //会员ID
            BLL.ShoppingCartBase shop = new BLL.ShoppingCartBase();
            var list = shop.GetModelList(" sc_IsDel = 0 and m_ID = " + mimodel.m_ID + "and sku_ID in (" + ids + ")");

            if (!string.IsNullOrWhiteSpace(ids))
            {
                //var dt = new BLL.SKUBase().GetSKUDetial(" and sku_ID in (" + ids + ")", true);
                var dt = new BLL.ShoppingCartBase().GetList(" sc_isdel=0 and sc_Status=0 and sc_IsGP=0 and m_ID="+mimodel.m_ID).Tables[0];
                if (dt != null)
                {
                    dt.Columns.Add("sc_pCount2", Type.GetType("System.Int32"));//商品数量
                    dt.Columns.Add("sc_pCountStatus", Type.GetType("System.String"));//商品库存状态
                    dt.Columns.Add("sc_IsGP2", Type.GetType("System.Boolean"));//团购标识
                    foreach (DataRow row in dt.Rows)
                    {
                        var model = list.Where(m => m.sc_ID == Convert.ToInt32(row["sc_ID"])).FirstOrDefault();
                        if (model != null)
                        {
                            row["sc_pCount2"] = model.sc_pCount;
                            string sql = " sku_ID = " + row["sku_ID"] + " and gp_IsDel = 0 and gp_StatusCode = 0 and gp_StartTime <= '" + DateTime.Now + "' and gp_EndTime >= '" + DateTime.Now + "'";
                            //团购
                            var gpBase = _gpBase.GetModelList(sql).FirstOrDefault();
                            if (gpBase != null)
                            {
                                //团购取团购价格
                                row["sku_Price"] = gpBase.gp_pPric;
                                row["sc_IsGP2"] = true;
                                if (model.sc_pCount <= gpBase.gp_pCount - gpBase.gp_SaleCount)
                                {
                                    row["sc_pCountStatus"] = "有货";
                                }
                                else
                                {
                                    row["sc_pCountStatus"] = "库存不足";
                                }
                            }
                            else
                            {
                                row["sc_IsGP2"] = false;
                                //库存
                                var skuBase = _skuBase.GetModel(Convert.ToInt32(row["sku_ID"]));
                                if (model.sc_pCount <= skuBase.sku_Stock)
                                {
                                    row["sc_pCountStatus"] = "有货";
                                }
                                else
                                {
                                    row["sc_pCountStatus"] = "库存不足";
                                }
                            }
                        }
                    }
                }
                ViewData["OrderProducts"] = dt;
            }
            return ViewData["OrderProducts"];
        }