/// <summary> /// 返回购物车商品总数 /// </summary> /// <returns>Int</returns> protected int get_cart_quantity() { int group_id = 0; Model.users userModel = GetUserInfo(); if (userModel != null) { group_id = userModel.group_id; } Model.cart_total cartModel = Web.UI.ShopCart.GetTotal(group_id); return(cartModel.total_quantity); }
/// <summary> /// 显示购物车中的产品 /// </summary> private void Show_Car() { try { repddata.DataSource = get_cart_list(string.Empty); repddata.DataBind(); cartModel = GetTotal(DTKeys.COOKIE_SHOPPING_CART); } catch (Exception ex) { DTcms.Common.Utils.MakeFile(ex.ToString(), ex.StackTrace); } }
/// <summary> /// 将在Init事件执行 /// </summary> protected void shopping_Init(object sender, EventArgs e) { int group_id = 0; userModel = GetUserInfo(); if (userModel != null) { group_id = userModel.group_id; } if (action == "confirm" && userModel == null) { //自动跳转URL HttpContext.Current.Response.Redirect(linkurl("login1", HttpContext.Current.Request.RawUrl)); } cartModel = Web.UI.ShopCart.GetTotal(group_id); }
/// <summary> /// 统计购物车 /// </summary> public static Model.cart_total GetTotal(List <Model.cart_items> ls) { Model.cart_total model = new Model.cart_total(); if (ls != null) { foreach (Model.cart_items modelt in ls) { model.total_num++; model.total_quantity += modelt.quantity; model.payable_amount += modelt.sell_price * modelt.quantity; model.real_amount += modelt.user_price * modelt.quantity; model.total_point += modelt.point * modelt.quantity; } } return(model); }
/// <summary> /// 将在Init事件执行 /// </summary> protected void shopping_Init(object sender, EventArgs e) { int group_id = 0; userModel = GetUserInfo(); if (userModel != null) { group_id = userModel.group_id; } if (action == "confirm" && userModel == null) { //自动跳转URL HttpContext.Current.Response.Redirect(linkurl("login")); } cartModel = Web.UI.ShopCart.GetTotal(group_id); }
public static Model.cart_total GetTotalNew(int user_id) { Model.cart_total model = new Model.cart_total(); BLL.shop_log shop = new BLL.shop_log(); DataSet ds = shop.GetDList(" s.user_id=" + user_id, ""); if (ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { foreach (DataRow dr in ds.Tables[0].Rows) { model.order_quantity++; model.total_quantity += Convert.ToInt16(dr["quantity"]); model.real_amount += Convert.ToInt16(dr["price"]); } } return(model); }
public static Model.cart_total GetTotal(int group_id) { Model.cart_total model = new Model.cart_total(); IList <Model.cart_items> iList = GetList(group_id); if (iList != null) { foreach (Model.cart_items modelt in iList) { model.total_num++; model.total_quantity += modelt.quantity; model.payable_amount += modelt.price * modelt.quantity; model.real_amount += modelt.user_price * modelt.quantity; model.total_point += modelt.point * modelt.quantity; } } return(model); }
public static decimal zhe_num_jian_zhe(int group_id, string sid) { decimal moeny = 0; Model.cart_total model = new Model.cart_total(); IList <Model.cart_items> i_List = GetList(group_id); if (i_List != null) { foreach (Model.cart_items modelt in i_List) { if (modelt.sales_id.ToString() == sid) { moeny = moeny + (modelt.user_price * modelt.quantity); } } } return(moeny); }
public static int zhe_num_jian(int group_id, string sid) { int num = 0; Model.cart_total model = new Model.cart_total(); IList <Model.cart_items> i_List = GetList(group_id); if (i_List != null) { foreach (Model.cart_items modelt in i_List) { if (modelt.sales_id.ToString() == sid) { num = num + modelt.quantity; } } } return(num); }
public static int zhe_num(int group_id, string sid) { decimal num = 0; Model.cart_total model = new Model.cart_total(); IList <Model.cart_items> i_List = GetList(group_id); if (i_List != null) { foreach (Model.cart_items modelt in i_List) { if (modelt.sales_id.ToString() == sid) { num = num + (modelt.user_price * modelt.quantity); } } } return(int.Parse(num.ToString("0."))); }
/// <summary> /// 将在Init事件执行 /// </summary> protected void shopping_Init(object sender, EventArgs e) { int group_id = 0; userModel = GetUserInfo(); if (userModel != null) { group_id = userModel.group_id; } if (action == "confirm" && userModel == null) { userModel = new Model.users(); if (orderConfig.anonymous == 0) { //自动跳转URL HttpContext.Current.Response.Redirect(linkurl("login")); } } cartModel = Web.UI.ShopCart.GetTotal(group_id); }
/// <summary> /// 将在Init事件执行 /// </summary> protected void cart_Init(object sender, EventArgs e) { int group_id = 0; //会员组ID Model.users userModel = GetUserInfo(); //会员信息 if (userModel != null) { group_id = userModel.group_id; //如果是已登录则将会员组ID赋值 } goodsList = ShopCart.GetList(group_id); //商品列表 if (goodsList != null) { goodsTotal = ShopCart.GetTotal(goodsList); //商品统计 } else { goodsList = new List<Model.cart_items>(); goodsTotal = new Model.cart_total(); } }
/// <summary> /// 将在Init事件执行 /// </summary> protected void cart_Init(object sender, EventArgs e) { int group_id = 0; //会员组ID Model.users userModel = GetUserInfo(); //会员信息 if (userModel != null) { group_id = userModel.group_id; //如果是已登录则将会员组ID赋值 } goodsList = ShopCart.GetList(group_id); //商品列表 if (goodsList != null) { goodsTotal = ShopCart.GetTotal(goodsList); //商品统计 } else { goodsList = new List <Model.cart_items>(); goodsTotal = new Model.cart_total(); } }
/// <summary> /// 将在Init事件执行 /// </summary> protected void shopping_Init(object sender, EventArgs e) { int group_id = 0; userModel = GetUserInfo(); if (userModel != null) { group_id = userModel.group_id; } if (action == "confirm" && userModel == null) { userModel = new Model.users(); userModel.user_name = "Guest"; //if (orderConfig.anonymous == 0) //{ // //自动跳转URL // HttpContext.Current.Response.Redirect(linkurl("login")); //} } cartModel = Web.UI.ShopCart.GetTotalNew(userModel.id); }
public Model.cart_total GetTotal(string cart) { decimal c = 0, k = 0, g = 0; Model.cart_total model = new Model.cart_total(); IList <Model.cart_items> iList = GetList(cart); if (iList != null) { foreach (Model.cart_items modelt in iList) { model.total_quantity += modelt.quantity; model.payable_amount += modelt.price * modelt.quantity; model.real_amount += modelt.user_price * modelt.quantity; model.total_point += modelt.point * modelt.quantity; } model.payable_amount += Utils.StrToDecimal(Fee, 0); model.real_amount += Utils.StrToDecimal(Fee, 0); model.total_num = int.Parse(c.ToString()) + int.Parse(k.ToString()) + int.Parse(g.ToString()); } return(model); }
/// <summary> /// 将在Init事件执行 /// </summary> protected void shopping_Init(object sender, EventArgs e) { int group_id = 0; //会员组ID userModel = GetUserInfo(); //获取会员信息 if (userModel == null) { //如果不支持匿名购物则跳转到登录页面 if (orderConfig.anonymous == 0) { HttpContext.Current.Response.Redirect(linkurl("login")); //自动跳转URL } } else { group_id = userModel.group_id; } //获取商品列表 if (string.IsNullOrEmpty(goodsJsonValue)) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("对不起,无法获取您要购买的商品!"))); return; } try { List<Model.cart_keys> ls = (List<Model.cart_keys>)JsonHelper.JSONToObject<List<Model.cart_keys>>(goodsJsonValue); goodsList = ShopCart.ToList(ls, group_id); //商品列表 goodsTotal = ShopCart.GetTotal(goodsList); //商品统计 } catch { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("对不起,商品的传输参数有误!"))); return; } }
/// <summary> /// 将在Init事件执行 /// </summary> protected void shopping_Init(object sender, EventArgs e) { int group_id = 0; //会员组ID userModel = GetUserInfo(); //获取会员信息 if (userModel == null) { //如果不支持匿名购物则跳转到登录页面 if (orderConfig.anonymous == 0) { HttpContext.Current.Response.Redirect(linkurl("login")); //自动跳转URL } } else { group_id = userModel.group_id; } //获取商品列表 if (string.IsNullOrEmpty(goodsJsonValue)) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("对不起,无法获取您要购买的商品!"))); return; } try { List <Model.cart_keys> ls = (List <Model.cart_keys>)JsonHelper.JSONToObject <List <Model.cart_keys> >(goodsJsonValue); goodsList = ShopCart.ToList(ls, group_id); //商品列表 goodsTotal = ShopCart.GetTotal(goodsList); //商品统计 } catch { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("对不起,商品的传输参数有误!"))); return; } }
/// <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); }
/// <summary> /// 显示购物车中的产品 /// </summary> private void Show_Car() { repddata.DataSource = get_cart_list(string.Empty); repddata.DataBind(); cartModel = GetTotal(DTKeys.COOKIE_SHOPPING_CART); decimal decimalTotal = 0; //decimalTotal = decimalTotal + decimal.Parse(Fee); TotalPrice = decimalTotal.ToString("0.00"); double zhekouPrice = double.Parse(((decimal.Parse(TotalPrice) * 15) / 100).ToString()); string result = zhekouPrice.ToString("#0"); int ZheKoupoints = Utils.StringToNum(result); int UID = WEBUserCurrent.UserID; if (!string.IsNullOrEmpty(UID.ToString())) { BLL.users User = new BLL.users(); Model.users mod = new Model.users(); mod = User.GetModel(UID); if (mod != null) { point = mod.point.ToString(); pointMoney = point; if (ZheKoupoints >= 150) { ZheKoupoints = 150; } if (mod.point > ZheKoupoints) { pointMoney = ZheKoupoints.ToString(); } else { pointMoney = point; } hidePoint.Value = pointMoney; BLL.point_log pointsLog = new BLL.point_log(); Model.point_log model = new Model.point_log(); model.user_id = UID; model.user_name = orderNo; model.value = Utils.StringToNum(pointMoney); model.remark = "購物時折抵點數"; model.add_time = DateTime.Now; model.type = 2;//2標誌點數是減少 int m = pointsLog.Add(model); } } shengyu = (cartModel.payable_amount - decimal.Parse(pointMoney) + decimal.Parse(Fee)).ToString(); PousePrice = (decimal.Parse(TotalPrice) + decimal.Parse(Fee)).ToString(); if (hideFee.Value == "2") { decimal FeeLv = TwoTypeFee; if (decimal.Parse(TotalPrice) >= FeeLv) { PousePrice = TotalPrice; shengyu = (decimal.Parse(TotalPrice) - decimal.Parse(pointMoney)).ToString(); } } }
public static Model.cart_total GetTotal(int group_id) { Model.cart_total model = new Model.cart_total(); IList<Model.cart_items> iList = GetList(group_id); if (iList != null) { foreach (Model.cart_items modelt in iList) { model.total_num++; model.total_quantity += modelt.quantity; model.payable_amount += modelt.price * modelt.quantity; model.real_amount += modelt.user_price * modelt.quantity; model.total_point += modelt.point * modelt.quantity; } } return model; }
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>"); } }
public static Model.cart_total GetTotal(int group_id) { string by = "", sid1 = "0", gid = "0"; int g = 0, zz = 0; int a = 0, b = 0; decimal zc = 0, k = 0, c = 0; Model.cart_total model = new Model.cart_total(); IList <Model.cart_items> i_List = GetList(group_id); if (i_List != null) { foreach (Model.cart_items modelt in i_List) { model.total_num++; model.total_quantity += modelt.quantity; if (modelt.point == 0) { model.payable_amount += modelt.price * modelt.quantity; model.real_amount += modelt.user_price * modelt.quantity; } if (modelt.by == "point") { model.total_point += modelt.point * modelt.quantity; } //model.total_moneyback += modelt.money_back * modelt.quantity; if (modelt.chang > c) { c = modelt.chang; model.total_chang = modelt.chang; } if (modelt.kuan > k) { k = modelt.kuan; model.total_kuan = modelt.kuan; } model.total_gao += modelt.gao * modelt.quantity; model.total_zhong += modelt.zhong * modelt.quantity; if (modelt.point == 0 && modelt.sales_id > 0) { sid1 = sid1 + "," + modelt.sales_id; } gid = gid + "," + modelt.goodsid; if (modelt.psmoney == "2") { IList _list = new ArrayList(); if (!_list.Contains(modelt.id)) { _list.Add(modelt.id); } if (_list.Count > 0) { model.brand_id = 2; } } if (modelt.sales_name == "no") { a = 1; } if (string.IsNullOrEmpty(modelt.sales_name)) { b = 1; } } if (a == 1) { model.brandid = 3; } } zc = model.total_kuan * model.total_gao * model.total_chang; decimal zcall = zc / 6000; if (zcall > model.total_zhong) { model.total_num_zhe = zcall; } else { model.total_num_zhe = model.total_zhong; } int moenynum1 = 0, moenynum2 = 0, moenynum3 = 0; string sales_str = ""; //滿件 if (sid1.Length > 2) { DataSet ds = Tea.DBUtility.DbHelperSQL.Query("select id from shop_sales where id in(" + sid1 + ") and status=1 and datediff(day,start_time,getdate())>=0 and datediff(day,end_time,getdate())<=0 group by id"); foreach (DataRow dr in ds.Tables[0].Rows) { int num = zhe_num_jian(group_id, dr["id"].ToString()); decimal pnum = zhe_num_jian_zhe(group_id, dr["id"].ToString()); DataSet d_s = Tea.DBUtility.DbHelperSQL.Query("select top 1 * from view_goods_sales where main_id=" + dr["id"].ToString() + " and parent_id<=" + num + " order by parent_id desc"); if (d_s.Tables[0].Rows.Count > 0) { // if (d_s.Tables[0].Rows[0]["scompany"].ToString() == "2") { sales_str = sales_str + d_s.Tables[0].Rows[0]["stitle"].ToString() + " 滿" + decimal.Parse(d_s.Tables[0].Rows[0]["parent_id"].ToString()).ToString("0.") + "件減" + d_s.Tables[0].Rows[0]["goods_id"].ToString() + "元";// +"|"; decimal listm = decimal.Parse(d_s.Tables[0].Rows[0]["goods_id"].ToString()); moenynum1 = moenynum1 + int.Parse(listm.ToString("0.")); } else { sales_str = sales_str + d_s.Tables[0].Rows[0]["stitle"].ToString() + " 滿" + decimal.Parse(d_s.Tables[0].Rows[0]["parent_id"].ToString()).ToString("0.") + "件折扣" + d_s.Tables[0].Rows[0]["goods_id"].ToString() + "%";// +"|"; decimal listm = decimal.Parse(d_s.Tables[0].Rows[0]["goods_id"].ToString()); moenynum1 = moenynum1 + Utils.StrToInt((pnum * (100 - Utils.StrToInt(listm.ToString("0."), 0)) / 100).ToString(), 0); } } } } Model.orderconfig oconfig = new BLL.orderconfig().loadConfig(); if (oconfig.qgbegin < System.DateTime.Now && oconfig.qgend.Value.AddDays(1) > System.DateTime.Now) { if (oconfig.qgtype == 1 && oconfig.quanguan < 100) { moenynum2 = Utils.StrToInt(model.real_amount.ToString("0."), 0) - Utils.StrToInt((model.real_amount * oconfig.quanguan / 100).ToString(), 0); } if (oconfig.qgtype == 2 && oconfig.quanguanjin > 0) { moenynum2 = oconfig.quanguanjin; } } if (model.real_amount > oconfig.maned && oconfig.mebegin < System.DateTime.Now && oconfig.meend.Value.AddDays(1) > System.DateTime.Now) { if (oconfig.metype == 1 && oconfig.zhekou < 100) { moenynum3 = Utils.StrToInt(model.real_amount.ToString("0."), 0) - Utils.StrToInt((model.real_amount * oconfig.zhekou / 100).ToString(), 0); } if (oconfig.metype == 2 && oconfig.zkjin > 0) { moenynum3 = oconfig.zkjin; } } if (moenynum1 > moenynum2 && moenynum1 > moenynum3) { model.total_moneyback = moenynum1; model.sales_str = sales_str; } if (moenynum2 > moenynum1 && moenynum2 > moenynum3) { model.total_moneyback = moenynum2; if (oconfig.qgtype == 1) { sales_str = "全館折扣" + oconfig.quanguan + "%"; } if (oconfig.qgtype == 2) { sales_str = "全館折扣" + oconfig.quanguanjin + "元"; } model.sales_str = sales_str; } if (moenynum3 > moenynum1 && moenynum3 > moenynum2) { model.total_moneyback = moenynum3; if (oconfig.metype == 1) { model.sales_str = "滿額折扣滿" + oconfig.maned + "元折扣" + oconfig.zhekou + "%"; } if (oconfig.metype == 2) { model.sales_str = "滿額折扣滿" + oconfig.maned + "元折扣" + oconfig.zkjin + "元"; } } model.by = sid1; model.total_num_str = gid; return(model); }
/// <summary> /// 统计购物车 /// </summary> public static Model.cart_total GetTotal(List<Model.cart_items> ls) { Model.cart_total model = new Model.cart_total(); if (ls != null) { foreach (Model.cart_items modelt in ls) { model.total_num++; model.total_quantity += modelt.quantity; model.payable_amount += modelt.sell_price * modelt.quantity; model.real_amount += modelt.user_price * modelt.quantity; model.total_point += modelt.point * modelt.quantity; } } return model; }
public static Model.cart_total GetTotal(int group_id, int uid) { string by = "", sid1 = "0", gid = "0"; int g = 0, zz = 0; decimal zc = 0, k = 0, c = 0; Model.cart_total model = new Model.cart_total(); IList <Model.cart_items> i_List = GetList(group_id, uid); if (i_List != null) { foreach (Model.cart_items modelt in i_List) { model.total_num++; model.total_quantity += modelt.quantity; if (modelt.point == 0) { model.payable_amount += modelt.price * modelt.quantity; model.real_amount += modelt.user_price * modelt.quantity; } model.total_point += modelt.point * modelt.quantity; //model.total_moneyback += modelt.money_back * modelt.quantity; if (modelt.chang > c) { c = modelt.chang; model.total_chang = modelt.chang; } if (modelt.kuan > k) { k = modelt.kuan; model.total_kuan = modelt.kuan; } model.total_gao += modelt.gao * modelt.quantity; model.total_zhong += modelt.zhong * modelt.quantity; if (modelt.point == 0 && modelt.sales_id > 0) { sid1 = sid1 + "," + modelt.sales_id; } gid = gid + "," + modelt.goodsid; if (modelt.psmoney == "2") { model.brandid = 2; } } } zc = model.total_kuan * model.total_gao * model.total_chang; decimal zcall = zc / 6000; if (zcall > model.total_zhong) { model.total_num_zhe = zcall; } else { model.total_num_zhe = model.total_zhong; } int moenynum1 = 0; string sales_str = ""; //滿件 if (sid1.Length > 2) { DataSet ds = Tea.DBUtility.DbHelperSQL.Query("select id from shop_sales where id in(" + sid1 + ") and status=1 and datediff(day,start_time,getdate())>=0 and datediff(day,end_time,getdate())<=0 group by id"); foreach (DataRow dr in ds.Tables[0].Rows) { int num = zhe_num_jian(group_id, dr["id"].ToString()); DataSet d_s = Tea.DBUtility.DbHelperSQL.Query("select top 1 * from shop_goods_sales where main_id=" + dr["id"].ToString() + " and parent_id<=" + num + " order by parent_id desc"); if (d_s.Tables[0].Rows.Count > 0) { sales_str = sales_str + "滿" + decimal.Parse(d_s.Tables[0].Rows[0]["parent_id"].ToString()).ToString("0.") + "件減" + d_s.Tables[0].Rows[0]["goods_id"].ToString();// +"|"; decimal listm = decimal.Parse(d_s.Tables[0].Rows[0]["goods_id"].ToString()); moenynum1 = moenynum1 + int.Parse(listm.ToString("0.")); } } } model.by = sid1; model.total_moneyback = moenynum1; model.sales_str = sales_str; model.total_num_str = gid; return(model); }