protected void shopping_Init(object sender, EventArgs e) { int group_id = 0; this.userModel = this.GetUserInfo(); if (this.userModel == null) { if (this.orderConfig.anonymous == 0) { HttpContext.Current.Response.Redirect(this.linkurl("login")); } } else { group_id = this.userModel.group_id; } if (string.IsNullOrEmpty(this.goodsJsonValue)) { HttpContext.Current.Response.Redirect(this.linkurl("error", (object)("?msg=" + Utils.UrlEncode("对不起,无法获取您要购买的商品!")))); } else { try { this.goodsList = ShopCart.ToList(JsonHelper.JSONToObject <List <cart_keys> >(this.goodsJsonValue), group_id); this.goodsTotal = ShopCart.GetTotal(this.goodsList); } catch { HttpContext.Current.Response.Redirect(this.linkurl("error", (object)("?msg=" + Utils.UrlEncode("对不起,商品的传输参数有误!")))); } } }
private void RptBind() { ShopCart bll = new ShopCart(); IList <cart_items> ls1 = bll.get_cart_list(); this.rptList.DataSource = ls1; this.rptList.DataBind(); cart_total cartModel = ShopCart.GetTotal(); total_quantity.Text = cartModel.total_quantity.ToString(); payable_amount.Text = cartModel.payable_amount.ToString(); payable_amount1.Text = cartModel.payable_amount.ToString(); }
public static cart_total GetTotal() { cart_total model = new cart_total(); IList <cart_items> iList = GetList(); if (iList != null) { foreach (cart_items modelt in iList) { model.total_num++; model.total_quantity += modelt.quantity; model.payable_amount += modelt.price * modelt.quantity; } } return(model); }
public static cart_total GetTotal(List <cart_items> ls) { cart_total cartTotal = new cart_total(); if (ls != null) { foreach (cart_items l in ls) { ++cartTotal.total_num; cartTotal.total_quantity += l.quantity; cartTotal.payable_amount += l.sell_price * (Decimal)l.quantity; cartTotal.real_amount += l.user_price * (Decimal)l.quantity; cartTotal.total_point += l.point * l.quantity; } } return(cartTotal); }
protected void cart_Init(object sender, EventArgs e) { int group_id = 0; users userInfo = this.GetUserInfo(); if (userInfo != null) { group_id = userInfo.group_id; } this.goodsList = ShopCart.GetList(group_id); if (this.goodsList != null) { this.goodsTotal = ShopCart.GetTotal(this.goodsList); } else { this.goodsList = new List <cart_items>(); this.goodsTotal = new cart_total(); } }
//提交订单 protected void btnSubmit_Click(object sender, EventArgs e) { int user_id = 0; int depot_category_id = 0; int depot_id = 0; string user_name = string.Empty; user_id = Convert.ToInt32(Session["AID"]); depot_category_id = Convert.ToInt32(Session["DepotCatID"]); depot_id = Convert.ToInt32(Session["DepotID"]); user_name = Session["AdminName"].ToString(); //检查购物车商品 IList <cart_items> iList = ShopCart.GetList(); if (iList == null) { mym.JscriptMsg(this.Page, "对不起,购物车为空,无法结算!", "", "Error"); return; } //统计购物车 cart_total cartModel = ShopCart.GetTotal(); //判断是否有商品 if (cartModel.payable_amount == 0) { mym.JscriptMsg(this.Page, "对不起,购物车为空,无法结算!", "", "Error"); return; } //保存订单======================================================================= ps_orders model = new ps_orders(); model.order_no = Utils.GetOrderNumber(); //订单号B开头为商品订单 model.user_id = user_id; model.depot_category_id = depot_category_id; model.depot_id = depot_id; model.user_name = user_name; model.payment_id = 1;//未支付 model.message = message.Text; model.payable_amount = cartModel.payable_amount; model.real_amount = 0; //订单总金额=实付商品金额 model.order_amount = cartModel.payable_amount; model.add_time = DateTime.Now; if (model.Add() == 0) { mym.JscriptMsg(this.Page, "订单保存过程中发生错误,请重新提交!", "", "Error"); return; } //商品详细列表 ps_order_goods gls = new ps_order_goods(); ps_here_depot my = new ps_here_depot(); foreach (cart_items item in iList) { my.GetModel(item.id); gls.order_id = model.GetMaxId(); gls.goods_id = item.id; gls.goods_title = item.title; gls.goods_price = my.go_price; gls.real_price = item.price; gls.quantity = item.quantity; gls.product_category_id = item.product_category_id; gls.dw = item.dw; gls.Add(); } //清空购物车 ShopCart.Clear("0"); //提交成功,返回URL mym.JscriptMsg(this.Page, "恭喜您,订单已成功提交!", "my_order.aspx", "Success"); return; }