/// <summary> /// 确定订单 /// </summary> /// <returns></returns> public ActionResult Confirm() { string email = Request.QueryString["mail"]; string id = Request.QueryString["id"]; string num = Request.QueryString["num"]; string random = Request.QueryString["t"]; ProductViewModel p = BProduct.SearchById(id); if (p == null) { return(View()); } double totalMoney = Convert.ToInt32(num) * p.Price; ViewBag.Email = email; ViewBag.Id = id; ViewBag.Num = num; ViewBag.Total = totalMoney; ViewBag.Name = p.Name; ViewBag.SinglePrice = p.Price; if (!ExisitCookie(email)) { HttpCookie cookie = new HttpCookie("cmail", email); cookie.Path = "/"; cookie.Domain = "1777ka.com"; cookie.Expires = DateTime.Now.AddYears(10); Response.Cookies.Add(cookie); } return(View()); }
/// <summary> /// 订单生成 /// </summary> /// <returns></returns> public ActionResult Order() { string proId = Request.Form["proId"]; string name = Request.Form["proName"]; string price = Request.Form["price"]; string num = Request.Form["num"]; string email = Request.Form["email"]; ProductViewModel model = BProduct.SearchById(proId); if (model == null) { return(Content("订单生成异常")); } double _price = Convert.ToDouble(price); int _num = Convert.ToInt32(num); if (model.Price != _price) { return(Content("订单生成异常(金额不符)")); } if (model.Name != name) { return(Content("订单生成异常(名称不符)")); } double totalPrice = _price * _num; string orderNo = DTHelper.GetCurrentTimeOrderNo(); //订单生成 OrderViewModel orderModel = new OrderViewModel(); orderModel.Count = _num; orderModel.NO = orderNo; orderModel.Price = _price; orderModel.Product_Id = Convert.ToInt32(proId); orderModel.Remark = email; orderModel.Type = Request.Form["paytype"]; orderModel.LocalStatus = "待支付"; orderModel.UpdateTime = DateTime.Now; BOrder.Insert(orderModel); string url = ""; if (orderModel.Type == "1") { NativePay nativePay = new NativePay(); //转化为以分为单位的金额 int money = Convert.ToInt32(totalPrice * 100); //生成扫码支付模式二url url = "https://www.baifubao.com/o2o/0/qrcode?size=4&text=" + nativePay.GetPayUrl(proId, money, name, orderNo); } else if (orderModel.Type == "2") { url = "/Zhifu/precreate.aspx?tid=" + orderNo; } else { } ViewBag.QR_url = url; ViewBag.Name = name; ViewBag.Num = _num; ViewBag.Total = totalPrice; ViewBag.tNo = orderNo; ViewBag.payType = Request.Form["paytype"]; return(View()); }