/// <summary> /// 购物车 /// </summary> /// <returns></returns> private string shopcartMethod() { string result = ""; string pid = Form["p_id"]; string p_chima = Form["p_chima"]; string p_yanse = Form["p_yanse"]; string p_commoditynum = Form["p_commoditynum"]; DataTable dtsku = new BLL.SKUBase().GetList(" sku_IsDel=0 and p_ID= "+pid).Tables[0]; string pt_id= new BLL.ProductBase().GetModel(int.Parse(pid)).pt_ID.ToString();//商品小类型 string ptp_id= new BLL.ProductTypeBase().GetModel(int.Parse(pt_id)).pt_ParentId.ToString();//商品大类型 if (System.Web.HttpContext.Current.Request.Cookies[":userlogin"] == null || System.Web.HttpContext.Current.Request.Cookies[":userlogin"].Value == "")//如果没有用户登录 { result = "{'result':'error_login'}"; } else {//如果有用户登录 Model.MemberBase mbmodel = CookieEncrypt.DeserializeObject(System.Web.HttpContext.Current.Request.Cookies[":userlogin"].Value) as MemberBase; if (ptp_id == "488" || ptp_id == "489") //是男鞋或女鞋 { if (p_chima == "0") { result = "{'result':'error_chima'}"; } else if (p_yanse == "0") { result = "{'result':'error_yanse'}"; } else { //尺码 颜色都选择后 写入购物车 Model.ShoppingCartBase scmodel = new ShoppingCartBase(); scmodel.sku_ID = int.Parse(dtsku.Rows[0]["sku_ID"].ToString()); scmodel.m_ID = mbmodel.m_ID; scmodel.sc_pCount =int.Parse( p_commoditynum); scmodel.sc_pPric = Convert.ToDecimal(dtsku.Rows[0]["sku_Price"]); scmodel.sc_CreateOn = DateTime.Now; scmodel.sc_IsDel = false; scmodel.sc_Status = false; scmodel.sc_IsGP = false; scmodel.sc_chima = p_chima; scmodel.sc_yanse = p_yanse; int re= new BLL.ShoppingCartBase().Add(scmodel); if (re > 0) { result = "{'result':'success'}"; } else { result = "{'result':'error_data'}"; } } } else//如果选择的商品不是鞋子那么尺码颜色设为0 { Model.ShoppingCartBase scmodel = new ShoppingCartBase(); scmodel.sku_ID = int.Parse(dtsku.Rows[0]["sku_id"].ToString()); scmodel.m_ID = mbmodel.m_ID; scmodel.sc_pCount = int.Parse(p_commoditynum); scmodel.sc_pPric = Convert.ToDecimal(dtsku.Rows[0]["sku_Price"]); scmodel.sc_CreateOn = DateTime.Now; scmodel.sc_IsDel = false; scmodel.sc_Status = false; scmodel.sc_IsGP = false; scmodel.sc_chima = p_chima; scmodel.sc_yanse = p_yanse; int re = new BLL.ShoppingCartBase().Add(scmodel); if (re > 0) { result = "{'result':'success'}"; } else { result = "{'result':'error_data'}"; } } } return result; }
public string insertintoCart() { int pid = 0; int count = 0; int result = 0; bool result2 = false; string mm = ""; decimal pric=0; if (!string.IsNullOrEmpty(RequestBase.GetString("skuid"))) { pid = int.Parse(RequestBase.GetString("skuid").ToString()); } if (!string.IsNullOrEmpty(RequestBase.GetString("pric"))) { pric = decimal.Parse(RequestBase.GetString("pric").ToString()); } if (!string.IsNullOrEmpty(RequestBase.GetString("count"))) { count = int.Parse(RequestBase.GetString("count").ToString()); } if (Request.Cookies["UserInfo"] != null) { int mid = (CookieEncrypt.DeserializeObject(System.Web.HttpContext.Current.Request.Cookies["UserInfo"].Value) as Model.MemberBase).m_ID; Model.ShoppingCartBase scmodel = new ShoppingCartBase(); var model = new ListModel(); model.vmgblist = new BLL.vm_GBDetails().GetModelList(" gp_isdel=0 and gp_statuscode=0 and sku_id=" + pid + " and gp_pCount-gp_SaleCount>0"); if (model.vmgblist.Count > 0) { var sclist = new BLL.ShoppingCartBase().GetModelList(" m_ID=" + mid + " and sku_ID=" + model.vmgblist[0].sku_ID + " and sc_IsDel=0 and sc_IsGP=1"); if (sclist.Count > 0) { Model.ShoppingCartBase upmodel = new BLL.ShoppingCartBase().GetModel(sclist[0].sc_ID); //改数量 upmodel.sc_pCount += count; upmodel.sc_pPric = pric; upmodel.sc_CreateOn = DateTime.Now; upmodel.sc_IsGP = true; result2 = new BLL.ShoppingCartBase().Update(upmodel); } else { //添加 scmodel.m_ID = mid; scmodel.sc_pCount = count; scmodel.sc_pPric = pric; scmodel.sc_CreateOn = DateTime.Now; scmodel.sku_ID = pid; scmodel.sc_IsGP = true; 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\">去购物车结算 ></a><a class=\"go-shop\" href=\"javascript:void(0)\" id=\"keepshopping\" onclick=\"closeit()\">继续购物</a></div><!--chart-font end--></div>"; 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=\"no-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\">去购物车结算 ></a><a class=\"go-shop\" href=\"javascript:void(0)\" id=\"keepshopping\" onclick=\"closeit()\">继续购物</a></div><!--chart-font end--></div>"; return html; } } else { mm = "nologon"; return mm; } }
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; } }