public static bool 更新订单(订单 content, bool f = true) { return Mongo.更新(content, f); }
public ActionResult AddPurchaseInfo() { if (HttpContext.检查登录() != -1 && currentUser.GetType() == typeof(个人用户)) { string str = Request.Form["summary"]; string[] info = str.Split('|'); string tip1 = ""; bool exist = false; bool IsChengdu = false; for (int i = 0; i < info.Length - 1; i++)//限数量判断 { long id = long.Parse(info[i].Split(',')[1]); int sum = int.Parse(info[i].Split(',')[0]); if (id == 9147 && sum > 9) { exist = true; tip1 += "订单中存在限购9个的商品"; break; } } for (int i = 0; i < info.Length - 1; i++)//限成都市判断 { long id = long.Parse(info[i].Split(',')[1]); int sum = int.Parse(info[i].Split(',')[0]); 商品 sp = 商品管理.查找商品(long.Parse(info[i].Split(',')[1])); if (sp.销售信息.销售地域.城市 == "成都市" && sp.销售信息.销售地域.城市 != Request.Form["city"]) { IsChengdu = true; tip1 += "订单中存在仅限于成都市内供货的商品"; break; } } if (!exist && !IsChengdu) { var shopcar = 购物车管理.查询购物车(0, 0, Query<购物车>.Where(o => o.所属用户.用户ID == currentUser.Id)); var car = shopcar.First(); var shoplist = shopcar.Any() ? car.选购商品列表 : new List<购物车.选购商品>(); decimal weight = 0; decimal sum = 0;//使用优惠码前的总价格 decimal sumwithcode = 0;//使用优惠码后的总价格 订单 order = new 订单(); order.收货地址.省份 = Request.Form["province"]; order.收货地址.城市 = Request.Form["city"]; order.收货地址.区县 = Request.Form["area"]; order.联系人 = Request.Form["contactMan"]; order.联系电话 = Request.Form["phone"]; order.详细地址 = Request.Form["detail"]; order.订单所属用户.用户ID = currentUser.Id; for (int i = 0; i < info.Length - 1; i++) { 商品 sp = 商品管理.查找商品(long.Parse(info[i].Split(',')[1])); 商品订单 o = new 商品订单(); o.商品.商品ID = long.Parse(info[i].Split(',')[1]); o.数量 = int.Parse(info[i].Split(',')[0]); sum += int.Parse(info[i].Split(',')[0]) * sp.销售信息.价格; sumwithcode += int.Parse(info[i].Split(',')[0]) * sp.销售信息.军采价; order.商品订单列表.Add(o); weight += (decimal)(sp.商品信息.单位重量 * int.Parse(info[i].Split(',')[0])); //该商品已下单,从购物车里删除 var gd = shoplist.Find(p => p.商品.商品ID == long.Parse(info[i].Split(',')[1])); if (gd != null) { shoplist.Remove(gd); } } order.订单商品总价格 = sum; if (sumwithcode < 168) { if (Request.Form["province"] != "新疆维吾尔自治区" && Request.Form["province"] != "西藏自治区" && Request.Form["province"] != "海南省") { order.总运费 = 15; } else { order.总运费 = 15 + 15 * Math.Ceiling(weight); } } else { if (Request.Form["province"] == "新疆维吾尔自治区" || Request.Form["province"] == "西藏自治区" || Request.Form["province"] == "海南省") { order.总运费 = 15 + 15 * Math.Ceiling(weight); } } order.订单总付款 = sumwithcode + order.总运费; order.订单总价格 = sum + order.总运费; 购物车管理.更新购物车(car); 订单管理.添加订单(order); Session["Ginfo"] = ""; return Content("<script>alert('您已成功提交订单,可以到后台去支付订单');window.location='/个人用户后台/PurchaseInfo';</script>"); } else { return Content("<script>alert('" + tip1 + ",不能下订单');window.location='/个人用户后台/ShopCar';</script>"); } } else { return Content("<script>alert('目前购物功能只对个人用户开放!如果你不是个人用户,请先注册个人用户账号。');window.location='/注册/Register_Person';</script>"); } }
public static bool 添加订单(订单 content) { return Mongo.添加(content); }