Пример #1
0
 public JsonResult UpdateOrder(Common.Order obj)
 {
     try
     {
         OrdersBusiness orderBusiness = new OrdersBusiness();
         var            objentity     = orderBusiness.GetById(obj.Id);
         //objentity.Id = obj.Id;
         objentity.CreateDate     = obj.CreateDate;
         objentity.CreateBy       = obj.CreateBy;
         objentity.ModifyDate     = DateTime.Now;
         objentity.ModifyBy       = obj.ModifyBy;
         objentity.DateDeliver    = obj.DateDeliver;
         objentity.Status         = obj.Status;
         objentity.KmRoad         = obj.KmRoad;
         objentity.NoteAboutOrder = obj.NoteAboutOrder;
         objentity.GramGood       = obj.GramGood;
         objentity.IdPayForm      = obj.IdPayForm;
         objentity.IdShop         = obj.IdShop;
         objentity.TotalMoney     = obj.TotalMoney;
         objentity.FeeOfTranspot  = obj.FeeOfTranspot;
         objentity.UrlBtnPayNL    = obj.UrlBtnPayNL;
         orderBusiness.Edit(objentity);
         return(Json(1));//Cập nhật thành công
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #2
0
 public JsonResult UpdateOrder(long orderid, int status, int paid)
 {
     try
     {
         var order = _orderBussiness.GetById(orderid);
         order.Status = status;
         order.Paid   = paid;
         _orderBussiness.Edit(order);
         return(Json(1, JsonRequestBehavior.AllowGet));
     }
     catch (Exception)
     {
         //write log here
         return(Json(0, JsonRequestBehavior.AllowGet));
     }
 }
Пример #3
0
        public JsonResult UpdateStatus(long idOrderPost, int selectedItem)
        {
            try
            {
                OrdersBusiness orderBusiness = new OrdersBusiness();
                var            objentity     = orderBusiness.GetById(idOrderPost);

                objentity.Status = selectedItem;

                orderBusiness.Edit(objentity);
                return(Json(1));//Cập nhật thành công
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #4
0
        public Boolean UpdateOrder(String transaction_info, String order_code, String payment_id, String payment_type, String secure_code)
        {
            String secure_code_ws = this.GetMD5Hash(transaction_info + " " + order_code + " " + payment_id + " " + payment_type + " " + this.secure_pass);

            if (secure_code == secure_code_ws)
            {
                var business = new OrdersBusiness();
                var obj      = business.GetById(long.Parse(order_code));
                obj.Status = 2;// Đang chơ chuyên hàng, đa thanh toán online
                business.Edit(obj);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        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));
        }