public static void SetSessionOrderReciver(OrderReciver orderReciver, HttpSessionStateBase httpSessionState) { if (httpSessionState != null) { httpSessionState["ORDER_RECIVER"] = orderReciver; } }
public static OrderReciver GetSessionOrderReciver(HttpSessionStateBase httpSessionState) { OrderReciver orderReciver = new OrderReciver(); try { if (httpSessionState != null) { orderReciver = (OrderReciver)httpSessionState["ORDER_RECIVER"]; } } catch { } return(orderReciver); }
public ActionResult PaymentCheckOut(string recieveOrder, string buyerOrder, string note, long shopid, long payfrom, string TaxOrder) { ProductsBusiness productsBusiness = new ProductsBusiness(); var serializerSettings = new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.Objects }; var recieve = JsonConvert.DeserializeObject <List <string> >(recieveOrder, serializerSettings); var buyeror = JsonConvert.DeserializeObject <List <string> >(buyerOrder, serializerSettings); var taxOrder = JsonConvert.DeserializeObject <List <string> >(TaxOrder, serializerSettings); if (ModelState.IsValid) { var recieveadress = recieve[4]; var order = new Order(); order.FeeOfTranspot = 0; order.GramGood = 0; order.KmRoad = 0; order.TotalMoney = 0; order.IdPayForm = payfrom; order.IdShop = 0; order.NoteAboutOrder = note; var sesion = NlCheckout.GetSessionCard(Session); Member entity = SessionUtility.GetSessionMember(Session); LocationsBusiness locationsBusiness = new LocationsBusiness(); double moneytransport = 0; double totalmoney = 0; double totalGram = 0; List <OrderDetail> listOrderDetails = new List <OrderDetail>(); foreach (var item in sesion) { if (item.Product.MemberId == shopid) { var orderDetail = new OrderDetail(); orderDetail.IdOrder = order.Id; orderDetail.IdProduct = item.Product.Id; orderDetail.Price = (decimal)item.Product.Price; moneytransport += 0;// FuntionMember.CountMoneyTransport(0, item.Product.Weight * item.Quantity, recieve[3]); //Kiêm tra tinh chính xác đoạn này totalGram += item.Product.Weight; totalmoney += item.Product.Price + moneytransport; orderDetail.NameProduct = item.Product.ProductName; orderDetail.PathImage = item.Product.ProductImages.First(x => x.IsAvatar == 1).ImgSource; orderDetail.Quantity = item.Quantity; listOrderDetails.Add(orderDetail); } } NlCheckout.SetSessionOrderDetail(listOrderDetails, Session); var url = ""; order.TotalMoney = totalmoney; order.FeeOfTranspot = moneytransport; order.GramGood = totalGram; order.OrderDetails = listOrderDetails; order.Status = 0;// đơn hàng mới //Buyer Member member = SessionUtility.GetSessionMember(Session); var buyer = new OrderBuyer(); if (buyeror != null && buyeror.Any()) // lấy thông tin ngươi mua giông ng nhận hàng { buyer.Id = order.Id; buyer.Name = taxOrder[0]; buyer.PhoneNumber = buyeror[1]; buyer.Email = buyeror[2]; buyer.Address = taxOrder[1]; buyer.CMTND = taxOrder[2]; } else { buyer.Id = order.Id; buyer.Name = taxOrder[0]; buyer.PhoneNumber = recieve[1]; buyer.Email = recieve[2]; buyer.Address = taxOrder[1]; buyer.CMTND = taxOrder[2]; } buyer.CreateDate = DateTime.Now; if (member != null) { buyer.IdMember = member.Id;// người đăng nhập mua hàng } order.OrderBuyer = buyer; //Reciver var reciver = new OrderReciver(); reciver.Id = order.Id; reciver.Name = recieve[0]; reciver.PhoneNumber = recieve[1]; reciver.Email = recieve[2]; // reciver.Address = recieve[4]+", "+ recieve[3]; reciver.Address = recieve[4]; reciver.CreateDate = DateTime.Now; SessionUtility.SetSessionOrderReciver(reciver, Session); order.OrderReciver = reciver; #region Xoa san phâm trong sesion List <CartItem> listCartItems = new List <CartItem>(); foreach (var item in sesion) { if (item.Product.MemberId != shopid) { listCartItems.Add(item); } else { } } order.IdShop = null; ordersBusiness.AddNew(order); Session["Madonhang"] = order.Id; Session["TotalMoney"] = order.TotalMoney; NlCheckout.SetSessionCard(listCartItems, Session); #endregion Xoa san phâm trong sesion string body = ControllerExtensions.RenderRazorViewToString(this, "DetailCart", order); Function.ObjMailSend objmail = new Function.ObjMailSend(); var mailsend = new SystemSettingBusiness().GetDynamicQuery().First(x => x.Key == "mail_noreply"); var acount = mailsend.Value.Split('|'); objmail.FromMail = acount[0]; objmail.PassFromMail = acount[1]; objmail.ToMail = reciver.Email; Function.email_send(objmail, "[Noithatgoquy]Thông tin đơn hàng(" + DateTime.Now + ")", body); var car = NlCheckout.GetSessionCard(Session); if (payfrom == 200) { //thanh toan qua ngan luong string return_url = "https://wwww.vinaplaza.vn"; // Địa chỉ trả về string transaction_info = "info"; //Thông tin giao dịch string order_code = order.Id.ToString(); //Mã giỏ hàng string receiver = new NlCheckout().GetvalueAppsetting("acount_receiver"); //Tài khoản nhận tiền string price = totalmoney.ToString(); //Lấy giá của giỏ hàng BuyGroup365.Models.Member.NlCheckout nl = new BuyGroup365.Models.Member.NlCheckout(); //string url; url = nl.buildCheckoutUrl(return_url, receiver, transaction_info, order_code, price); //ImageButton imgBtn = new ImageButton(); //imgBtn.ImageUrl = "https://www.nganluong.vn/data/images/buttons/11.gif";//source file ảnh //imgBtn.PostBackUrl = url;//Gán địa chỉ url cho nút thanh toán // Response.Redirect(url); } else if (payfrom == 1) { //thanh toan qua bao kim } else { //nguoi mua va nguoi ban tu thuong luong gia ca } if (payfrom == 200) { return(Json(url, JsonRequestBehavior.AllowGet)); } else { if (car != null && car.Any()) { return(Json(1, JsonRequestBehavior.AllowGet)); } else { return(Json(1, JsonRequestBehavior.AllowGet)); // thay đôi lại luồng trước đây phân ra 2 trương hợp như thê này đê Render tới các page khác nhau } } // return Json(listCartItems, JsonRequestBehavior.AllowGet); } return(Json(0, JsonRequestBehavior.AllowGet)); }
public ActionResult Payment(double kmRoad, double gramGoods, double totalMoneyPay, double feeTranspotGood, string nameOfBuyer, string buyerPhone, string buyerEmail, string buyerAddress, string receiverName, string receiverPhone, string receiverEmail, string receiverAddress, long formPayGood, string receiverTown, string receiverPhuong, string note, long shopid) { // var id = Request.QueryString["sp"]; if (ModelState.IsValid) { // var shopId = long.Parse(Request.QueryString["sp"]); //var idShop = FakeModelCartItem().First().Product.IdShop; //Member entity = SessionUtility.GetSessionMember(Session); // List<long> listShop=new List<long>(); // var listoder = NlCheckout.GetSessionCard(Session); //foreach (var cartItem in listoder) //{ // var id = cartItem.Product.MemberId; // if (listShop.Exists(x => x.Equals(id))) // { // } // else // { // listShop.Add(id); // } //} //foreach (var idshop in listShop) //{ //} var order = new Order(); order.FeeOfTranspot = 0; order.GramGood = 0; order.KmRoad = kmRoad; order.TotalMoney = 0; order.IdPayForm = formPayGood; order.IdShop = shopid; order.NoteAboutOrder = note; // ordersBusiness.AddNew(order); if (formPayGood == 0) { //thanh toan qua ngan luong string return_url = "http://demo.nganluong.vn"; // Địa chỉ trả về string transaction_info = "Hãy lập trình thông tin của giao dịch của bạn vào đây"; //Thông tin giao dịch string order_code = order.Id.ToString(); //Mã giỏ hàng string receiver = "*****@*****.**"; //Tài khoản nhận tiền string price = totalMoneyPay.ToString(); //Lấy giá của giỏ hàng BuyGroup365.Models.Member.NlCheckout nl = new BuyGroup365.Models.Member.NlCheckout(); string url; url = nl.buildCheckoutUrl(return_url, receiver, transaction_info, order_code, price); //ImageButton imgBtn = new ImageButton(); //imgBtn.ImageUrl = "https://www.nganluong.vn/data/images/buttons/11.gif";//source file ảnh //imgBtn.PostBackUrl = url;//Gán địa chỉ url cho nút thanh toán order.UrlBtnPayNL = url; ordersBusiness.Edit(order); } else if (formPayGood == 1) { //thanh toan qua bao kim } else { //nguoi mua va nguoi ban tu thuong luong gia ca } //Order detail //var listItem = (List<CartItem>)Session[CartSession]; var sesion = NlCheckout.GetSessionCard(Session); Member entity = SessionUtility.GetSessionMember(Session); LocationsBusiness locationsBusiness = new LocationsBusiness(); double moneytransport = 0; double totalmoney = 0; double totalGram = 0; List <OrderDetail> listOrderDetails = new List <OrderDetail>(); foreach (var item in sesion) { if (item.Product.MemberId == shopid) { var orderDetail = new OrderDetail(); orderDetail.IdOrder = order.Id; orderDetail.IdProduct = item.Product.Id; orderDetail.Price = (decimal)item.Product.Price; moneytransport += FuntionMember.CountMoneyTransport(kmRoad, item.Product.Weight, receiverAddress); totalGram += item.Product.Weight; totalmoney += item.Product.Price + moneytransport; orderDetail.NameProduct = item.Product.ProductName; orderDetail.PathImage = item.Product.ProductImages.First(x => x.IsAvatar == 1).ImgSource; orderDetail.Quantity = item.Quantity; // var orderDetailDao = new OrderDetailDao(); // orderDetailBusiness.AddNew(orderDetail); listOrderDetails.Add(orderDetail); } } order.TotalMoney = totalmoney; order.FeeOfTranspot = totalMoneyPay; order.GramGood = totalGram; order.OrderDetails = listOrderDetails; // ordersBusiness.Edit(order); //Buyer Member member = SessionUtility.GetSessionMember(Session); var buyer = new OrderBuyer(); buyer.Id = order.Id; buyer.Name = nameOfBuyer; buyer.PhoneNumber = buyerPhone; buyer.Email = buyerEmail; buyer.Address = buyerAddress; buyer.CreateDate = DateTime.Now; if (member != null) { buyer.IdMember = member.Id;// người đăng nhập mua hàng } //var buyerDao = new BuyerDao(); //buyerDao.Insert(buyer); // orderBuyerBusiness.AddNew(buyer); order.OrderBuyer = buyer; //Reciver var reciver = new OrderReciver(); reciver.Id = order.Id; reciver.Name = receiverName; reciver.PhoneNumber = receiverPhone; reciver.Email = receiverEmail; reciver.Address = receiverTown + " - " + receiverPhuong + " - " + receiverAddress; reciver.CreateDate = DateTime.Now; //var reciverDao = new ReciverDao(); //reciverDao.Insert(reciver); order.OrderReciver = reciver; // orderReciverBusiness.AddNew(reciver); // var idShop = entity.Id; //Order //#region Xoa san phâm trong sesion //foreach (var item in sesion) //{ // if (item.Product.MemberId != shopid) // { // listCartItems.Add(item); // } // else // { // } //} //ordersBusiness.AddNew(order); //NlCheckout.SetSessionCard(listCartItems, Session); //#endregion Xoa san phâm trong sesion List <CartItem> listCartItems = new List <CartItem>(); listCartItems = NlCheckout.GetSessionCard(Session); string body = ControllerExtensions.RenderRazorViewToString(this, "DetailCart", order); Function.ObjMailSend objmail = new Function.ObjMailSend(); var mailsend = new SystemSettingBusiness().GetDynamicQuery().First(x => x.Key == "mail_noreply"); var acount = mailsend.Value.Split('|'); objmail.FromMail = acount[0]; objmail.PassFromMail = acount[1]; objmail.ToMail = reciver.Email; Function.email_send(objmail, "Thông tin đơn hàng(" + DateTime.Now + ")", body); return(Json(listCartItems, JsonRequestBehavior.AllowGet)); } return(Json(1)); }