//将购买信息,存入购物车 private int AddCart(ProModel pro, M_UserInfo mu, string addition) { int proid = pro.ProID; int pronum = pro.Pronum; if (proid < 1 || pronum < 1) { function.WriteErrMsg("商品ID或数量异常"); } M_Cart cartMod = new M_Cart(); cartMod.Cartid = CartCookID; cartMod.StoreID = pro.StoreID; cartMod.ProID = proid; cartMod.Pronum = pronum; cartMod.userid = mu.UserID; cartMod.Username = mu.UserName; cartMod.Getip = EnviorHelper.GetUserIP(); cartMod.Addtime = DateTime.Now; cartMod.Additional = addition; cartMod.code = pro.code; cartMod.Proname = pro.ProName; cartMod.ID = cartBll.insert(cartMod); return(cartMod.ID); }
//根据传参将商品加入购物车后跳转(支持按商品ID,套装ID购买) private void AddToCart(M_UserInfo mu, M_Product proMod, int pronum) { if (pronum < 1) { pronum = 1; } if (proMod == null || proMod.ID < 1) { return; } //商品不存在 DataTable dt = DBCenter.Sel(proMod.TableName, "ID=" + proMod.ItemID); int tlpID = DataConvert.CLng(dt.Rows[0]["TlpID"]); //if (tlpID < 1) { function.WriteErrMsg("商品未绑定设计模板"); } //复制一份作为用户新建的记录 B_Logo_Design desBll = new B_Logo_Design(); M_Logo_Design desMod = desBll.SelReturnModel(tlpID); if (desMod == null) { desMod = new M_Logo_Design(); } M_Cart_Addition addMod = new M_Cart_Addition(); //if (desMod == null) { function.WriteErrMsg("商品未绑定模板"); } desMod.ID = 0; desMod.ZType = 0; desMod.CDate = DateTime.Now; desMod.UserID = mu.UserID; desMod.UserName = mu.UserName; //不经设计直接加入物车,则获取商品预览图片 string imgUrl = function.GetImgUrl(proMod.Thumbnails); //if (File.Exists(function.VToP(imgUrl))) //{ // desMod.PreviewImg = "data:image/png;base64," + ImgToBase64(imgUrl); //} desMod.PreviewImg = imgUrl; desMod.ID = desBll.Insert(desMod); //-----------------检测完成加入购物车 M_Cart cartMod = new M_Cart(); cartMod.Cartid = CartCookID; cartMod.StoreID = proMod.UserShopID; cartMod.ProID = proMod.ID; cartMod.Pronum = pronum; cartMod.userid = mu.UserID; cartMod.Username = mu.UserName; cartMod.FarePrice = proMod.LinPrice.ToString(); cartMod.AllMoney = (proMod.LinPrice * cartMod.Pronum); cartMod.ProAttr = desMod.ID.ToString(); cartMod.Proname = proMod.Proname; cartMod.Additional = JsonConvert.SerializeObject(addMod); int id = cartBll.insert(cartMod); }