public ActionResult GroupPurchaseEdit()
        {
            this.ViewData["texOtype"] = RequestBase.GetString("otype");
            BindControl bc = new BindControl();
            ViewData["IsHasFunRole"] = Rolemanager.IsHasFunRole(EmployeeBase.e_ID, "001001001");//是否拥有管理的权限
            Model.vm_GroupInfo model = new Model.vm_GroupInfo();

            if (RequestBase.GetString("otype") == "modify")
            {
                string ids = RequestBase.GetString("dli_id");
                ViewData["hfPId"] = ids;
                int id = int.Parse(ids.Split('|')[0]);

                model = new BLL.vm_GroupInfo().GetModel(id);
                ViewData["starttime"] = model.gp_StartTime;
                ViewData["endtime"] = model.gp_EndTime;
                ViewData["p_Name"] = model.p_Name;
                ViewData["p_ID"] = new BLL.GroupPurchaseBase().GetModel(id).sku_ID;
                return View(model);
            }
            else
            {
                string pids = RequestBase.GetString("dli_id");
                ViewData["hfPId"] = pids;
                return View();
            }
        }
        public void saveGPdetails(HttpContext context)
        {
            BLL.GroupPurchaseBase bll = new BLL.GroupPurchaseBase();

            bool isok = false;
            string pid, gpcount, gpprice, starttime, endtime, gplogo, gpslogan;
            pid = context.Request.QueryString["pid"].ToString();
            gpcount = context.Request.QueryString["gpcount"].ToString();
            gpprice = context.Request.QueryString["gpprice"].ToString();
            starttime = context.Request.QueryString["starttime"].ToString();
            endtime = context.Request.QueryString["endtime"].ToString();
            gplogo = context.Request.QueryString["gplogo"].ToString();
            gpslogan = context.Request.QueryString["gpslogan"].ToString();
            string otype = context.Request.QueryString["otype"].ToString();

            if (otype == "add")
            {
                Model.GroupPurchaseBase model = new Model.GroupPurchaseBase();
                model.gp_CreateBy = EmployeeInfo.e_ID;
                model.gp_CreateOn = DateTime.Now;
                model.gp_IsDel = false;
                model.gp_StatusCode = 0;
                model.sku_ID = int.Parse(pid);
                model.gp_EndTime = DateTime.Parse(endtime);
                model.gp_StartTime = DateTime.Parse(starttime);
                model.gp_pCount = int.Parse(gpcount);
                model.gp_pPric = decimal.Parse(gpprice);
                model.gp_SaleCount = 0;
                model.gp_Slogan = gpslogan;
                model.gp_Logo = gplogo;
                isok = bll.Add(model);
            }
            else
            {
                int id = int.Parse(context.Request.QueryString["id"].ToString());
                Model.GroupPurchaseBase model = bll.GetModel(id);
                model.gp_StartTime = DateTime.Parse(starttime);
                model.gp_EndTime = DateTime.Parse(endtime);
                model.gp_pCount = int.Parse(gpcount);
                model.gp_pPric = decimal.Parse(gpprice);
                model.sku_ID = int.Parse(pid);
                model.gp_Slogan = gpslogan;
                model.gp_Logo = gplogo;
                isok = bll.Update(model);
            }
            string result = isok ? "保存成功" : "保存失败";
            context.Response.Write(result);
        }
示例#3
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 public List<webs_YueyxShop.Model.vw_Orderpinfo> DataTableToList(DataTable dt)
 {
     List<webs_YueyxShop.Model.vw_Orderpinfo> modelList = new List<webs_YueyxShop.Model.vw_Orderpinfo>();
     int rowsCount = dt.Rows.Count;
     if (rowsCount > 0)
     {
         webs_YueyxShop.Model.vw_Orderpinfo model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new webs_YueyxShop.Model.vw_Orderpinfo();
             if (dt.Rows[n]["sku_Price"] != null && dt.Rows[n]["sku_Price"].ToString() != "")
             {
                 string sql = " sku_ID=" + dt.Rows[n]["sku_ID"] + " and gp_StatusCode=0 and gp_IsDel=0 and gp_EndTime > '" + DateTime.Now + "'";
                 var gplist = new BLL.GroupPurchaseBase().GetModelList(sql);
                 if (gplist.Count > 0)
                 {
                     model.sku_Price = decimal.Parse(gplist[0].gp_pPric.ToString());
                 }
                 else
                 {
                     model.sku_Price = decimal.Parse(dt.Rows[n]["sku_Price"].ToString());
                 }
             }
             if(dt.Rows[n]["b_ID"]!=null && dt.Rows[n]["b_ID"].ToString()!="")
             {
                 model.b_ID=int.Parse(dt.Rows[n]["b_ID"].ToString());
             }
             if(dt.Rows[n]["b_Name"]!=null && dt.Rows[n]["b_Name"].ToString()!="")
             {
             model.b_Name=dt.Rows[n]["b_Name"].ToString();
             }
             if(dt.Rows[n]["p_ID"]!=null && dt.Rows[n]["p_ID"].ToString()!="")
             {
                 model.p_ID=int.Parse(dt.Rows[n]["p_ID"].ToString());
             }
             if(dt.Rows[n]["p_Name"]!=null && dt.Rows[n]["p_Name"].ToString()!="")
             {
             model.p_Name=dt.Rows[n]["p_Name"].ToString();
             }
             if(dt.Rows[n]["p_ModifyOn"]!=null && dt.Rows[n]["p_ModifyOn"].ToString()!="")
             {
                 model.p_ModifyOn=DateTime.Parse(dt.Rows[n]["p_ModifyOn"].ToString());
             }
             if(dt.Rows[n]["p_ModifyBy"]!=null && dt.Rows[n]["p_ModifyBy"].ToString()!="")
             {
                 model.p_ModifyBy=new Guid(dt.Rows[n]["p_ModifyBy"].ToString());
             }
             if(dt.Rows[n]["p_StatusCode"]!=null && dt.Rows[n]["p_StatusCode"].ToString()!="")
             {
                 model.p_StatusCode=int.Parse(dt.Rows[n]["p_StatusCode"].ToString());
             }
             if(dt.Rows[n]["p_IsDel"]!=null && dt.Rows[n]["p_IsDel"].ToString()!="")
             {
                 if((dt.Rows[n]["p_IsDel"].ToString()=="1")||(dt.Rows[n]["p_IsDel"].ToString().ToLower()=="true"))
                 {
                 model.p_IsDel=true;
                 }
                 else
                 {
                     model.p_IsDel=false;
                 }
             }
             if(dt.Rows[n]["p_SellStatus"]!=null && dt.Rows[n]["p_SellStatus"].ToString()!="")
             {
                 model.p_SellStatus=int.Parse(dt.Rows[n]["p_SellStatus"].ToString());
             }
             if(dt.Rows[n]["pi_ID"]!=null && dt.Rows[n]["pi_ID"].ToString()!="")
             {
                 model.pi_ID=int.Parse(dt.Rows[n]["pi_ID"].ToString());
             }
             if(dt.Rows[n]["pi_Url"]!=null && dt.Rows[n]["pi_Url"].ToString()!="")
             {
             model.pi_Url=dt.Rows[n]["pi_Url"].ToString();
             }
             if(dt.Rows[n]["pi_Type"]!=null && dt.Rows[n]["pi_Type"].ToString()!="")
             {
                 if((dt.Rows[n]["pi_Type"].ToString()=="1")||(dt.Rows[n]["pi_Type"].ToString().ToLower()=="true"))
                 {
                 model.pi_Type=true;
                 }
                 else
                 {
                     model.pi_Type=false;
                 }
             }
             if(dt.Rows[n]["pi_isDel"]!=null && dt.Rows[n]["pi_isDel"].ToString()!="")
             {
                 if((dt.Rows[n]["pi_isDel"].ToString()=="1")||(dt.Rows[n]["pi_isDel"].ToString().ToLower()=="true"))
                 {
                 model.pi_isDel=true;
                 }
                 else
                 {
                     model.pi_isDel=false;
                 }
             }
             if(dt.Rows[n]["pi_StatusCode"]!=null && dt.Rows[n]["pi_StatusCode"].ToString()!="")
             {
                 model.pi_StatusCode=int.Parse(dt.Rows[n]["pi_StatusCode"].ToString());
             }
             if(dt.Rows[n]["p_MeasurementUnit"]!=null && dt.Rows[n]["p_MeasurementUnit"].ToString()!="")
             {
             model.p_MeasurementUnit=dt.Rows[n]["p_MeasurementUnit"].ToString();
             }
             if(dt.Rows[n]["pt_ID"]!=null && dt.Rows[n]["pt_ID"].ToString()!="")
             {
                 model.pt_ID=int.Parse(dt.Rows[n]["pt_ID"].ToString());
             }
             if(dt.Rows[n]["pt_Name"]!=null && dt.Rows[n]["pt_Name"].ToString()!="")
             {
             model.pt_Name=dt.Rows[n]["pt_Name"].ToString();
             }
             if(dt.Rows[n]["pt_ParentId"]!=null && dt.Rows[n]["pt_ParentId"].ToString()!="")
             {
                 model.pt_ParentId=int.Parse(dt.Rows[n]["pt_ParentId"].ToString());
             }
             if(dt.Rows[n]["pt_StatusCode"]!=null && dt.Rows[n]["pt_StatusCode"].ToString()!="")
             {
                 model.pt_StatusCode=int.Parse(dt.Rows[n]["pt_StatusCode"].ToString());
             }
             if(dt.Rows[n]["pt_CreatedBy"]!=null && dt.Rows[n]["pt_CreatedBy"].ToString()!="")
             {
                 model.pt_CreatedBy=new Guid(dt.Rows[n]["pt_CreatedBy"].ToString());
             }
             if(dt.Rows[n]["pt_CreatedOn"]!=null && dt.Rows[n]["pt_CreatedOn"].ToString()!="")
             {
                 model.pt_CreatedOn=DateTime.Parse(dt.Rows[n]["pt_CreatedOn"].ToString());
             }
             if(dt.Rows[n]["pt_IsDel"]!=null && dt.Rows[n]["pt_IsDel"].ToString()!="")
             {
                 if((dt.Rows[n]["pt_IsDel"].ToString()=="1")||(dt.Rows[n]["pt_IsDel"].ToString().ToLower()=="true"))
                 {
                 model.pt_IsDel=true;
                 }
                 else
                 {
                     model.pt_IsDel=false;
                 }
             }
             if(dt.Rows[n]["pt_ImgUrl"]!=null && dt.Rows[n]["pt_ImgUrl"].ToString()!="")
             {
             model.pt_ImgUrl=dt.Rows[n]["pt_ImgUrl"].ToString();
             }
             if(dt.Rows[n]["sku_ID"]!=null && dt.Rows[n]["sku_ID"].ToString()!="")
             {
                 model.sku_ID=int.Parse(dt.Rows[n]["sku_ID"].ToString());
             }
             //if(dt.Rows[n]["sku_Price"]!=null && dt.Rows[n]["sku_Price"].ToString()!="")
             //{
             //    model.sku_Price=decimal.Parse(dt.Rows[n]["sku_Price"].ToString());
             //}
             if(dt.Rows[n]["sku_CostPrice"]!=null && dt.Rows[n]["sku_CostPrice"].ToString()!="")
             {
                 model.sku_CostPrice=decimal.Parse(dt.Rows[n]["sku_CostPrice"].ToString());
             }
             if(dt.Rows[n]["sku_SalesCount"]!=null && dt.Rows[n]["sku_SalesCount"].ToString()!="")
             {
                 model.sku_SalesCount=int.Parse(dt.Rows[n]["sku_SalesCount"].ToString());
             }
             if(dt.Rows[n]["sku_Stock"]!=null && dt.Rows[n]["sku_Stock"].ToString()!="")
             {
                 model.sku_Stock=int.Parse(dt.Rows[n]["sku_Stock"].ToString());
             }
             if(dt.Rows[n]["sku_Code"]!=null && dt.Rows[n]["sku_Code"].ToString()!="")
             {
             model.sku_Code=dt.Rows[n]["sku_Code"].ToString();
             }
             if(dt.Rows[n]["sku_CreatedOn"]!=null && dt.Rows[n]["sku_CreatedOn"].ToString()!="")
             {
                 model.sku_CreatedOn=DateTime.Parse(dt.Rows[n]["sku_CreatedOn"].ToString());
             }
             if(dt.Rows[n]["sku_CreatedBy"]!=null && dt.Rows[n]["sku_CreatedBy"].ToString()!="")
             {
                 model.sku_CreatedBy=new Guid(dt.Rows[n]["sku_CreatedBy"].ToString());
             }
             if(dt.Rows[n]["sku_ModifyOn"]!=null && dt.Rows[n]["sku_ModifyOn"].ToString()!="")
             {
                 model.sku_ModifyOn=DateTime.Parse(dt.Rows[n]["sku_ModifyOn"].ToString());
             }
             if(dt.Rows[n]["sku_ModifyBy"]!=null && dt.Rows[n]["sku_ModifyBy"].ToString()!="")
             {
                 model.sku_ModifyBy=new Guid(dt.Rows[n]["sku_ModifyBy"].ToString());
             }
             if(dt.Rows[n]["sku_StatusCode"]!=null && dt.Rows[n]["sku_StatusCode"].ToString()!="")
             {
                 model.sku_StatusCode=int.Parse(dt.Rows[n]["sku_StatusCode"].ToString());
             }
             if(dt.Rows[n]["sku_IsDel"]!=null && dt.Rows[n]["sku_IsDel"].ToString()!="")
             {
                 if((dt.Rows[n]["sku_IsDel"].ToString()=="1")||(dt.Rows[n]["sku_IsDel"].ToString().ToLower()=="true"))
                 {
                 model.sku_IsDel=true;
                 }
                 else
                 {
                     model.sku_IsDel=false;
                 }
             }
             if(dt.Rows[n]["sku_scPric"]!=null && dt.Rows[n]["sku_scPric"].ToString()!="")
             {
                 model.sku_scPric=decimal.Parse(dt.Rows[n]["sku_scPric"].ToString());
             }
             if(dt.Rows[n]["sku_ismoren"]!=null && dt.Rows[n]["sku_ismoren"].ToString()!="")
             {
                 if((dt.Rows[n]["sku_ismoren"].ToString()=="1")||(dt.Rows[n]["sku_ismoren"].ToString().ToLower()=="true"))
                 {
                 model.sku_ismoren=true;
                 }
                 else
                 {
                     model.sku_ismoren=false;
                 }
             }
             if(dt.Rows[n]["p_Province"]!=null && dt.Rows[n]["p_Province"].ToString()!="")
             {
                 model.p_Province=int.Parse(dt.Rows[n]["p_Province"].ToString());
             }
             if(dt.Rows[n]["p_City"]!=null && dt.Rows[n]["p_City"].ToString()!="")
             {
                 model.p_City=int.Parse(dt.Rows[n]["p_City"].ToString());
             }
             if(dt.Rows[n]["p_County"]!=null && dt.Rows[n]["p_County"].ToString()!="")
             {
                 model.p_County=int.Parse(dt.Rows[n]["p_County"].ToString());
             }
             if(dt.Rows[n]["p_CreatedBy"]!=null && dt.Rows[n]["p_CreatedBy"].ToString()!="")
             {
                 model.p_CreatedBy=new Guid(dt.Rows[n]["p_CreatedBy"].ToString());
             }
             if(dt.Rows[n]["p_CreatedOn"]!=null && dt.Rows[n]["p_CreatedOn"].ToString()!="")
             {
                 model.p_CreatedOn=DateTime.Parse(dt.Rows[n]["p_CreatedOn"].ToString());
             }
             if(dt.Rows[n]["b_Key"]!=null && dt.Rows[n]["b_Key"].ToString()!="")
             {
             model.b_Key=dt.Rows[n]["b_Key"].ToString();
             }
             if(dt.Rows[n]["b_SiteUrl"]!=null && dt.Rows[n]["b_SiteUrl"].ToString()!="")
             {
             model.b_SiteUrl=dt.Rows[n]["b_SiteUrl"].ToString();
             }
             if(dt.Rows[n]["b_LogoUrl"]!=null && dt.Rows[n]["b_LogoUrl"].ToString()!="")
             {
             model.b_LogoUrl=dt.Rows[n]["b_LogoUrl"].ToString();
             }
             if(dt.Rows[n]["b_Sort"]!=null && dt.Rows[n]["b_Sort"].ToString()!="")
             {
                 model.b_Sort=int.Parse(dt.Rows[n]["b_Sort"].ToString());
             }
             if(dt.Rows[n]["b_CreatedOn"]!=null && dt.Rows[n]["b_CreatedOn"].ToString()!="")
             {
                 model.b_CreatedOn=DateTime.Parse(dt.Rows[n]["b_CreatedOn"].ToString());
             }
             if(dt.Rows[n]["b_CreatedBy"]!=null && dt.Rows[n]["b_CreatedBy"].ToString()!="")
             {
                 model.b_CreatedBy=new Guid(dt.Rows[n]["b_CreatedBy"].ToString());
             }
             if(dt.Rows[n]["b_StatusCode"]!=null && dt.Rows[n]["b_StatusCode"].ToString()!="")
             {
                 model.b_StatusCode=int.Parse(dt.Rows[n]["b_StatusCode"].ToString());
             }
             if(dt.Rows[n]["b_IsDel"]!=null && dt.Rows[n]["b_IsDel"].ToString()!="")
             {
                 if((dt.Rows[n]["b_IsDel"].ToString()=="1")||(dt.Rows[n]["b_IsDel"].ToString().ToLower()=="true"))
                 {
                 model.b_IsDel=true;
                 }
                 else
                 {
                     model.b_IsDel=false;
                 }
             }
             if(dt.Rows[n]["b_IsTui"]!=null && dt.Rows[n]["b_IsTui"].ToString()!="")
             {
                 if((dt.Rows[n]["b_IsTui"].ToString()=="1")||(dt.Rows[n]["b_IsTui"].ToString().ToLower()=="true"))
                 {
                 model.b_IsTui=true;
                 }
                 else
                 {
                     model.b_IsTui=false;
                 }
             }
             if(dt.Rows[n]["b_TuiImg"]!=null && dt.Rows[n]["b_TuiImg"].ToString()!="")
             {
                 model.b_TuiImg=(byte[])dt.Rows[n]["b_TuiImg"];
             }
             if(dt.Rows[n]["o_ID"]!=null && dt.Rows[n]["o_ID"].ToString()!="")
             {
                 model.o_ID=int.Parse(dt.Rows[n]["o_ID"].ToString());
             }
             if(dt.Rows[n]["c_ID"]!=null && dt.Rows[n]["c_ID"].ToString()!="")
             {
                 model.c_ID=int.Parse(dt.Rows[n]["c_ID"].ToString());
             }
             if(dt.Rows[n]["o_Code"]!=null && dt.Rows[n]["o_Code"].ToString()!="")
             {
             model.o_Code=dt.Rows[n]["o_Code"].ToString();
             }
             if(dt.Rows[n]["m_ID"]!=null && dt.Rows[n]["m_ID"].ToString()!="")
             {
                 model.m_ID=int.Parse(dt.Rows[n]["m_ID"].ToString());
             }
             if(dt.Rows[n]["o_CreateOn"]!=null && dt.Rows[n]["o_CreateOn"].ToString()!="")
             {
                 model.o_CreateOn=DateTime.Parse(dt.Rows[n]["o_CreateOn"].ToString());
             }
             if(dt.Rows[n]["o_Pric"]!=null && dt.Rows[n]["o_Pric"].ToString()!="")
             {
                 model.o_Pric=decimal.Parse(dt.Rows[n]["o_Pric"].ToString());
             }
             if (dt.Rows[n]["o_Zhek"] != null && dt.Rows[n]["o_Zhek"].ToString() != "")
             {
                 model.o_Zhek = decimal.Parse(dt.Rows[n]["o_Zhek"].ToString());
             }
             if (dt.Rows[n]["o_Score"] != null && dt.Rows[n]["o_Score"].ToString() != "")
             {
                 model.o_Score = int.Parse(dt.Rows[n]["o_Score"].ToString());
             }
             if(dt.Rows[n]["o_StatusCode"]!=null && dt.Rows[n]["o_StatusCode"].ToString()!="")
             {
                 model.o_StatusCode=int.Parse(dt.Rows[n]["o_StatusCode"].ToString());
             }
             if(dt.Rows[n]["o_Mark"]!=null && dt.Rows[n]["o_Mark"].ToString()!="")
             {
             model.o_Mark=dt.Rows[n]["o_Mark"].ToString();
             }
             if(dt.Rows[n]["o_IsDel"]!=null && dt.Rows[n]["o_IsDel"].ToString()!="")
             {
                 if((dt.Rows[n]["o_IsDel"].ToString()=="1")||(dt.Rows[n]["o_IsDel"].ToString().ToLower()=="true"))
                 {
                 model.o_IsDel=true;
                 }
                 else
                 {
                     model.o_IsDel=false;
                 }
             }
             if(dt.Rows[n]["pay_ID"]!=null && dt.Rows[n]["pay_ID"].ToString()!="")
             {
                 model.pay_ID=int.Parse(dt.Rows[n]["pay_ID"].ToString());
             }
             if(dt.Rows[n]["st_ID"]!=null && dt.Rows[n]["st_ID"].ToString()!="")
             {
                 model.st_ID=int.Parse(dt.Rows[n]["st_ID"].ToString());
             }
             if(dt.Rows[n]["os_ID"]!=null && dt.Rows[n]["os_ID"].ToString()!="")
             {
                 model.os_ID=int.Parse(dt.Rows[n]["os_ID"].ToString());
             }
             if (dt.Rows[n]["os_IsGP"] != null && dt.Rows[n]["os_IsGP"].ToString() != "")
             {
                 model.os_IsGP = bool.Parse(dt.Rows[n]["os_IsGP"].ToString());
             }
             if(dt.Rows[n]["os_pCount"]!=null && dt.Rows[n]["os_pCount"].ToString()!="")
             {
                 model.os_pCount=int.Parse(dt.Rows[n]["os_pCount"].ToString());
             }
             modelList.Add(model);
         }
     }
     return modelList;
 }
        /// <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;
            }
        }
 /// <summary>
 /// 团购
 /// </summary>
 /// <returns></returns>
 public object GetGroupPurchase()
 {
     BLL.GroupPurchaseBase groupPurchase = new BLL.GroupPurchaseBase();
     BLL.vm_GBDetails vm_GBDetails = new BLL.vm_GBDetails();
         DateTime thistime = DateTime.Now;
         var list = vm_GBDetails.GetModelList("p_IsDel=0 and p_StatusCode=0 and gp_IsDel=0 and gp_pCount-gp_SaleCount>0 and gp_StatusCode=0 and p_SellStatus=1 and gp_endtime>'" + thistime + "' order by gp_EndTime");
     ViewData["GroupPurchase"] = list;
     return ViewData["GroupPurchase"];
 }
 //最终购买
 public ActionResult zuizhongDetail()
 {
     List<Model.ProductBase> pinfo = pbll.GetpInfoByRecommendTypeId(1);
     ViewBag.zuizhong = pinfo.ToList();
     var groupbuy = new BLL.GroupPurchaseBase().GetModelList("  gp_StatusCode=0 and gp_IsDel=0 and gp_EndTime > '" + DateTime.Now + "'");
     return View(groupbuy.ToList());
 }
        public ActionResult ProDetail()
        {
            ViewData["skuid"] = skuid;
            string where = "";

            //添加历史浏览记录
            CookieHelper.AddandRepairGoodsToCookie("History", skuid);

            int zixunpageSize = 2;//每一页的行数
            int zixunpageNumber = 1;//当前页数
            if (skuid != "")
            {
                where = "  and sku_ID=" + int.Parse(skuid);
            }
            model.vmpinfolist = new BLL.vw_PInfo().GetModelList(" p_IsDel=0 and p_StatusCode=0 and p_SellStatus=1   " + where);//商品信息
            model.pimglist = new BLL.ProductImgBase().GetModelList(" sku_ID=" + int.Parse(skuid)+" and pi_IsDel=0 and pi_StatusCode=0");//图片列表
            model.productinfo = new BLL.ProductInfoBase().GetModelList(" p_ID=(select p_ID from SKUBase where sku_ID=" + skuid + ") and pin_StatusCode=0 and pin_IsDel=0 and pin_Type='商品介绍'");//商品介绍
            model.proattr = new BLL.ProductAttributesBase().GetModelListByskuId(" pad.sku_ID= " + int.Parse(skuid));//属性
            model.proattr2 = new BLL.ProductAttributesBase().GetModelListByPid(" and pa.pa_Type=2 and pa.pa_ID in(select pa_ID from ProductAttributeDetails where  sku_ID in (select sku_ID from SKUBase where p_ID=(select p_ID from SKUBase where sku_ID=" + int.Parse(skuid) + "))) and sku.sku_ID in (select sku_ID from SKUBase where p_ID=(select p_ID from SKUBase where sku_ID=" + int.Parse(skuid) + "))");//规格
            model.zhoupaihang = new BLL.vw_PInfo().getmodelListPH();
            //评论
            model.pinglun = new BLL.ProductAppraiseBase().GetModelListByskuId(" sku_ID=" + int.Parse(skuid) + "and pa_StatusCode=0 and pa_IsDel=0");
            if (model.pinglun.Count > 0)
            {
                ViewData["pingluncount"] = model.pinglun.Count;
                ViewData["tiao"] = int.Parse(model.pinglun[0].pavg.ToString()) * 20;//显示满意度的箭头所指的地方
                ViewData["xing"] = int.Parse(model.pinglun[0].pavg.ToString()) * 68 / 5;//显示满意度的箭头所指的地方
            }
            else
            {
                ViewData["pingluncount"] = "0";
            }

            //咨询
            model.prozixunall = new BLL.ProductConsultBase().GetModelListByskuId(" and sku_ID= " + int.Parse(skuid) + "and pc_StatusCode=0 and pc_IsDel=0");
            var zxall = new BLL.ProductConsultBase().GetModelListByskuId(" and sku_ID= " + int.Parse(skuid));
            ViewBag.zxall = zxall.ToPagedList(zixunpageNumber, zixunpageSize);
            ViewData["all"] = model.prozixunall.Count;

            model.prozixunp1 = new BLL.ProductConsultBase().GetModelListByskuId(" and sku_ID= " + int.Parse(skuid) + " and pc.pc_Type='促销活动提问'");
            var zx1 = new BLL.ProductConsultBase().GetModelListByskuId(" and sku_ID= " + int.Parse(skuid) + " and pc.pc_Type='促销活动提问'");
            ViewBag.zx1 = zx1.ToPagedList(zixunpageNumber, zixunpageSize);

            model.prozixunp2 = new BLL.ProductConsultBase().GetModelListByskuId(" and sku_ID= " + int.Parse(skuid) + " and pc.pc_Type='库存及物流提问'");
            var zx2 = new BLL.ProductConsultBase().GetModelListByskuId(" and sku_ID= " + int.Parse(skuid) + " and pc.pc_Type='库存及物流提问'");
            ViewBag.zx2 = zx2.ToPagedList(zixunpageNumber, zixunpageSize);

            model.prozixunp3 = new BLL.ProductConsultBase().GetModelListByskuId(" and sku_ID= " + int.Parse(skuid) + " and pc.pc_Type='售后提问'");
            var zx3 = new BLL.ProductConsultBase().GetModelListByskuId(" and sku_ID= " + int.Parse(skuid) + " and pc.pc_Type='售后提问'");
            ViewBag.zx3 = zx3.ToPagedList(zixunpageNumber, zixunpageSize);

            model.prozixunp4 = new BLL.ProductConsultBase().GetModelListByskuId(" and sku_ID= " + int.Parse(skuid) + " and pc.pc_Type='商品提问'");
            var zx4 = new BLL.ProductConsultBase().GetModelListByskuId(" and sku_ID= " + int.Parse(skuid) + " and pc.pc_Type='商品提问'");
            ViewBag.zx4 = zx4.ToPagedList(zixunpageNumber, zixunpageSize);
            ViewData["p1"] = model.prozixunp1.Count;
            ViewData["p2"] = model.prozixunp2.Count;
            ViewData["p3"] = model.prozixunp3.Count;
            ViewData["p4"] = model.prozixunp4.Count;
            if (model.vmpinfolist.Any())
            {
                ViewData["youhui"] = model.vmpinfolist[0].sku_scPric - model.vmpinfolist[0].sku_Price;
                if (LoginMember != null)
                {
                    var clist = new BLL.VipCollectionBase().GetModelList(" m_ID=" + (CookieEncrypt.DeserializeObject(System.Web.HttpContext.Current.Request.Cookies["UserInfo"].Value) as Model.MemberBase).m_ID + " and sku_ID=" + model.vmpinfolist[0].sku_ID + " and vc_IsDel=0");
                    if (clist.Count > 0)
                    {
                        ViewData["collect"] = true;
                    }
                    else
                    {
                        ViewData["collect"] = false;
                    }
                    ViewData["logon"] = true;
                }
                else
                {
                    ViewData["collect"] = false;
                    ViewData["logon"] = false;
                }
            }
            else
            {
                ViewData["youhui"] = 0;
            }
            var groupbuy = new BLL.GroupPurchaseBase().GetModelList(" sku_ID=" + skuid + " and gp_StatusCode=0 and gp_IsDel=0 and gp_EndTime > '" + DateTime.Now + "'");
            if (groupbuy.Count > 0)
            {
                ViewBag.tuan = groupbuy[0];
            }
            else
            {
                ViewBag.tuan = null; ;
            }

            var zixunshuoming = _newsBase.GetModelList(" n_Title='咨询说明'  and n_StatusCode=0 and n_IsDel=0");
            if (zixunshuoming != null && zixunshuoming.Any())
            {
                ViewBag.zixunshuoming = zixunshuoming[0].n_Content;
            }
            else
            {
                ViewBag.zixunshuoming = "暂无咨询说明";
            }
            return View(model);
        }
        public string insertintoCart()
        {
            int skuid = 0;
            int count = 0;
            int result = 0;
            bool result2=false;
            string mm = "";
            decimal pric = 0;
            if (!string.IsNullOrEmpty(RequestBase.GetString("skuid")))
            {
                skuid = int.Parse(RequestBase.GetString("skuid").ToString());
            }
            if (!string.IsNullOrEmpty(RequestBase.GetString("count")))
            {
                count = int.Parse(RequestBase.GetString("count").ToString());
            }
            if (LoginMember != null)
            {
                int mid = (CookieEncrypt.DeserializeObject(System.Web.HttpContext.Current.Request.Cookies["UserInfo"].Value) as Model.MemberBase).m_ID;
                Model.ShoppingCartBase scmodel = new ShoppingCartBase();
                Model.SKUBase skumodel = new BLL.SKUBase().GetModelList(" sku_ID=" + skuid)[0];
                if (skumodel.sku_Stock > 0)
                {
                    model.vmpinfolist = new BLL.vw_PInfo().GetModelList(" p_IsDel=0 and p_StatusCode=0 and p_SellStatus=1  and sku_ID= " + skuid);//商品信息
                    var sclist = new BLL.ShoppingCartBase().GetModelList(" m_ID=" + mid + " and sku_ID=" + skuid + " and sc_IsDel=0");
                    if (sclist.Count > 0)
                    {
                        Model.ShoppingCartBase upmodel = new BLL.ShoppingCartBase().GetModel(sclist[0].sc_ID);
                        //改数量
                        string sql = " sku_ID=" + skuid + " and gp_StatusCode=0 and gp_IsDel=0 and gp_EndTime > '" + DateTime.Now + "'";
                        var gplist = new BLL.GroupPurchaseBase().GetModelList(sql);
                        if (gplist.Count > 0)
                        {
                            upmodel.sc_pPric = decimal.Parse(gplist[0].gp_pPric.ToString());
                            upmodel.sc_IsGP = true;
                        }
                        else
                        {
                            if (model.vmpinfolist.Count>0)
                            upmodel.sc_pPric = decimal.Parse(model.vmpinfolist[0].sku_Price.ToString());
                            upmodel.sc_IsGP = false;
                        }
                        upmodel.sc_pCount += count;
                        //upmodel.sc_pPric = model.vmpinfolist[0].sku_Price;
                        upmodel.sc_CreateOn = DateTime.Now;
                        result2 = new BLL.ShoppingCartBase().Update(upmodel);

                    }
                    else
                    {
                        //添加
                        string sql = " sku_ID=" + skuid + " and gp_StatusCode=0 and gp_IsDel=0 and gp_EndTime > '" + DateTime.Now + "'";
                        var gplist = new BLL.GroupPurchaseBase().GetModelList(sql);
                        if (gplist.Count > 0)
                        {
                            scmodel.sc_pPric = decimal.Parse(gplist[0].gp_pPric.ToString());
                            scmodel.sc_IsGP = true;
                        }
                        else
                        {
                            if (model.vmpinfolist.Count > 0)
                                scmodel.sc_pPric = decimal.Parse(model.vmpinfolist[0].sku_Price.ToString());
                            scmodel.sc_IsGP = false;
                        }
                        scmodel.m_ID = mid;
                        scmodel.sc_pCount = count;
                        //scmodel.sc_pPric = pric;
                        scmodel.sc_CreateOn = DateTime.Now;
                        scmodel.sku_ID = skuid;
                        result = new BLL.ShoppingCartBase().Add(scmodel);
                    }
                    if (result > 0 || result2)
                    {
                        int? pcount = 0;
                        decimal? ppric;
                        decimal pricecount = 0;
                        int? allpcount = 0;
                        var scalllist = new BLL.ShoppingCartBase().GetModelList("  m_ID=" + mid + "and sc_IsDel=0");
                        //ViewData["pcount"] = sclist.Count;
                        foreach (var item in scalllist)
                        {
                            pcount = item.sc_pCount;
                            ppric = item.sc_pPric;
                            pricecount += decimal.Parse(((double)pcount * (double)ppric).ToString());
                            allpcount += pcount;
                        }
                        string html = "<div class=\"modal\" id=\"chart-modal\"><a class=\"close\"   id=\"close\" onclick=\"closeit()\">X</a><div class=\"yes-chart\"><div class=\"yes-icon alignleft\"></div><div class=\"chart-font alignright\"><dl><dt><strong>添加成功!</strong></dt><dd>购物车共有<span> " + allpcount + "</span>件商品,商品总价:<span>¥ " + pricecount + " </span></dd></dl><div class=\"clear\"></div><a class=\"total-chart\" href=\"/Chart/Chart\" style=\"width:140px;\">去购物车结算 ></a><a class=\"go-shop\" href=\"javascript:void(0)\" id=\"keepshopping\" onclick=\"closeit()\">继续购物</a></div><!--chart-font end--></div><!--yes-chart end-->";
                        return html;
                    }
                    else
                    {
                        mm = "fail";
                        return mm;
                    }
                }
                else
                {
                    string html = "<div class=\"modal\" id=\"chart-modal\"><a class=\"close\"   id=\"close\" onclick=\"closeit()\">X</a><div class=\"yes-chart\"><div class=\"yes-icon alignleft\"></div><div class=\"chart-font alignright\"><dl><dt><strong>库存不足,添加失败!</strong></dt></dl><div class=\"clear\"></div><a class=\"total-chart\" href=\"/Chart/Chart\" style=\"width:140px;\">去购物车结算 ></a><a class=\"go-shop\" href=\"javascript:void(0)\" id=\"keepshopping\" onclick=\"closeit()\">继续购物</a></div><!--chart-font end--></div><!--yes-chart end-->";
                    return html;
                    //<div class=\"clear\"></div><div class=\"shop-cont\"><h2>购买该商品的用户还购买了</h2><ul class=\"shop-list\"><li><div class=\"pro-img\"><a href=\"#\"><img src=\"images/products/proList_ad_01.jpg\" alt=\"产品图片\" /></a></div><p><a href=\"#\">SUMACO素玛哥牌多口味进口 ...</a></p><p><span>¥23.90</span><del>¥23.90</del></p></li><li><div class=\"pro-img\"><a href=\"#\"><img src=\"images/products/proList_ad_02.jpg\" alt=\"产品图片\" /></a></div><p><a href=\"#\">SUMACO素玛哥牌多口味进口 ...</a></p><p><span>¥23.90</span><del>¥23.90</del></p></li><li><div class=\"pro-img\"><a href=\"#\"><img src=\"images/products/proList_ad_03.jpg\" alt=\"产品图片\" /></a></div><p><a href=\"#\">SUMACO素玛哥牌多口味进口 ...</a></p><p><span>¥23.90</span><del>¥23.90</del></p></li><li><div class=\"pro-img\"><a href=\"#\"><img src=\"images/products/proList_ad_04.jpg\" alt=\"产品图片\" /></a></div><p><a href=\"#\">SUMACO素玛哥牌多口味进口 ...</a></p><p><span>¥23.90</span><del>¥23.90</del></p></li></ul></div><!--shop-cont end--></div><!--chart-modal end-->
                }
            }
            else
            {
                mm = "nologon";

                return mm;
            }
        }