Пример #1
0
        protected override void OnPreRender(EventArgs e)
        {
            var       calc          = new DiscountCalculatorCustom();
            var       ordersManager = OrdersManager.GetManager();
            CartOrder shoppingCart  = GetShoppingCartForUser(ordersManager);
            var       items         = new List <CartDiscount>();

            if (shoppingCart.UserId != null && shoppingCart.UserId != Guid.Empty)
            {
                var user  = UserManager.GetManager().GetUser((Guid)shoppingCart.UserId);
                var roles = RoleManager.GetManager().GetRolesForUser(user.Id).ToList();
                items = calc.GetNotApplicableCartDiscounts(shoppingCart, shoppingCart.SubTotalDisplay, user, roles).ToList();
            }
            else
            {
                items = calc.GetNotApplicableCartDiscounts(shoppingCart, shoppingCart.SubTotalDisplay, null, null).ToList();
            }
            if (items != null && items.Count > 0)
            {
                var sb = new StringBuilder();
                sb.Append("The following discounts are not applicable:");
                foreach (var item in items)
                {
                    sb.Append(item.Title);
                    sb.Append(", ");
                }
                sb.Length -= 2;
                this.MessageLabel.Text = sb.ToString();
            }

            base.OnPreRender(e);
        }
        private void AddEventToCart(Event currentEvent)
        {
            CatalogManager catalog = new CatalogManager();
            Product        product = catalog.GetProduct(ProductId);

            HttpCookie     cookie        = HttpContext.Current.Request.Cookies.Get("shoppingCartId");
            OrdersManager  orderm        = new OrdersManager();
            OptionsDetails optionDetails = new OptionsDetails();

            // Check if shopping cart cookie exists in the current request.
            if (cookie == null)                                               //if it does not exist...
            {
                CartOrder  cartItem       = orderm.CreateCartOrder();         //create a new cart order
                var        shoppingcartid = cartItem.Id;                      // that id is equal to the cookie value
                HttpCookie Cookie         = new HttpCookie("shoppingCartId"); //create a new shopping cart cookie
                DateTime   now            = DateTime.Now;                     // Set the cookie value.
                Cookie.Value   = shoppingcartid.ToString();                   // Set the cookie expiration date.
                Cookie.Expires = now.AddYears(1);                             // Add the cookie.
                HttpContext.Current.Response.Cookies.Add(Cookie);             //give cart item currency of USD because it cannot be null
                cartItem.Currency = "USD";                                    //add the product to the cart
                orderm.AddToCart(cartItem, product, optionDetails, 1);        //save all changes
                orderm.SaveChanges();
            }
            else //if the cookie does exist
            {
                Guid      guid     = new Guid(cookie.Value.ToString()); //get the cookie value as the guid
                CartOrder cartItem = orderm.GetCartOrder(guid);        //get the cart based on the cookie value
                orderm.AddToCart(cartItem, product, optionDetails, 1); // add the item to the cart
                orderm.SaveChanges();                                  //save changes
            }
        }
Пример #3
0
        public override decimal CalculateProductPrice(Telerik.Sitefinity.Ecommerce.Orders.Model.CartDetail detail, bool useExchangeRate)
        {
            decimal productPrice = detail.Price;

            if (detail.Sku == EcommerceOrderCalculatorCustom.DonationProductSku && productPrice == 0)
            {
                CartOrder cartOrder = detail.Parent;

                PropertyDescriptorCollection properties   = TypeDescriptor.GetProperties(cartOrder);
                PropertyDescriptor           property     = properties[EcommerceOrderCalculatorCustom.CartOrderDonationAmountFieldName];
                MetafieldPropertyDescriptor  metaProperty = property as MetafieldPropertyDescriptor;
                if (metaProperty != null)
                {
                    var val = metaProperty.GetValue(cartOrder);
                    if (val != null)
                    {
                        decimal donationAmount = decimal.Parse(val.ToString());
                        if (donationAmount != 0 && detail.Sku == EcommerceOrderCalculatorCustom.DonationProductSku)
                        {
                            detail.Price = donationAmount;

                            detail.BasePrice = detail.Price;
                            productPrice     = detail.Price;
                        }
                    }
                }
            }

            return(Convert(productPrice, useExchangeRate));
        }
Пример #4
0
        public async Task <ActionResult> SubmitOrder(CartOrder order)
        {
            ApplicationUser user = await GetCurrentUserAsync();

            OrderInfo orderFromDB = await _context.OrderInfo.Where(usr => usr.User.Id == user.Id)
                                    .Where(o => o.Id == order.Id).SingleOrDefaultAsync();

            if (ModelState.IsValid)
            {
                orderFromDB.Status   = Status.Received;
                orderFromDB.DateTime = System.DateTime.Now;
                await _context.SaveChangesAsync();
            }
            try
            {
                bool success = Notification.SendNotification(user.PhoneNumber, "Your order has been received."
                                                             + " Estimated time: 15mins depending on the queue. DO NOT REPLY! Data rates may apply");
                if (success)
                {
                    return(Json(true));
                }
            }
            catch (Exception e)
            {
                return(Json(false));
            }
            return(Json(false));
        }
Пример #5
0
        public void Save(CartOrder newCartOrder)
        {
            var sql = @"Insert into CartOrder(customerid)
                        Values(@customerid)";

            _dbConnection.Execute(sql, newCartOrder);
        }
Пример #6
0
        public async Task <ActionResult> RemoveItem(CartOrderMenuItem item)
        {
            ApplicationUser user = await GetCurrentUserAsync();

            OrderInfo cart = await _context.OrderInfo.Where(usr => usr.User.Id == user.Id)
                             .Where(s => s.Status == Models.Status.Cart).SingleOrDefaultAsync();

            CartOrder viewModelCart = OrderDeserialize(cart);

            if (ModelState.IsValid)
            {
                foreach (var menuitem in viewModelCart.CartOrderMenuItems)
                {
                    if (menuitem.MenuItem.Id == item.MenuItem.Id)
                    {
                        viewModelCart.CartOrderMenuItems.Remove(menuitem);
                        break;
                    }
                }
                OrderInfo temp = OrderSerialize(viewModelCart);
                cart.OrderMenuItems = temp.OrderMenuItems;
                cart.TotalPrice     = CalculateTotalPrice(viewModelCart);
                await _context.SaveChangesAsync();

                return(Json(true));
            }
            return(Json(false));
        }
        public ActionResult Delete(int id)
        {
            CartOrder cartOrder = _context.CartOrders.Find(id);

            _context.CartOrders.Remove(cartOrder);
            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #8
0
        protected override decimal GetDiscountTotal(CartOrder cartOrder, User user, List <Role> userRoles, bool useExchangeRate)
        {
            decimal totalBasePriceNoExchangeRate = GetTotalBasePriceNoExchangeRate(cartOrder);
            decimal exchangeRateSubTotal         = GetSubTotalTaxInclusive(cartOrder, useExchangeRate);
            decimal sumRoundedOrderDiscounts     = new DiscountCalculatorCustom().SumRoundedOrderDiscounts(cartOrder, exchangeRateSubTotal, totalBasePriceNoExchangeRate, user, userRoles, useExchangeRate);

            return(sumRoundedOrderDiscounts);
        }
 private static string ReplaceValuesInTemplate(string template, CheckoutState checkoutSate, CartOrder cartOrder)
 {
     var order = OrdersManager.GetManager().GetOrder(cartOrder.Id);
     if (order != null)
     {
         var orderConfirmationEmailTemplateFormatter = new OrderConfirmationEmailTemplateFormatter();
         return orderConfirmationEmailTemplateFormatter.ReplaceValuesInTemplate(template, checkoutSate, order);
     }
     return string.Empty;
 }
        internal static void SendOrderPlacedEmailToClientAndMerchant(CartOrder cartOrder, CheckoutState checkoutState,int orderNumber)
        {
            var messageBody = GetEmailMessageBody(cartOrder, checkoutState);
            if (string.IsNullOrEmpty(messageBody))
            {
                return;
            }

            string fromAddress = Config.Get<EcommerceConfig>().MerchantEmail;
            string subject = String.Format(Res.Get<OrdersResources>("OrderEmailSubject"), orderNumber);
            SendEmail(fromAddress, checkoutState.BillingEmail, subject, messageBody, true);
        }
        public HttpResponseMessage PutUpdateCartOrder(CartOrder cartorder)
        {
            var customerid = cartorder.CustomerId;

            if (customerid == 0)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid Action"));
            }
            _cartorderRepository.Update(cartorder);

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
        public HttpResponseMessage DeleteCartOrder(CartOrder cartorder)
        {
            var customerid = cartorder.CustomerId;

            if (customerid == 0)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Delete Cart Not Available"));
            }
            _cartorderRepository.Delete(cartorder);

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Пример #13
0
        public static void ProcessOrder()
        {
            CatalogManager catalogManager = CatalogManager.GetManager();
            OrdersManager  ordersManager  = OrdersManager.GetManager();

            Product product = catalogManager.GetProducts().Where(p => p.Title == ExistingProductTitle &&

                                                                 p.Status == ContentLifecycleStatus.Live).FirstOrDefault();


            CartOrder cartOrder = ordersManager.CreateCartOrder();

            cartOrder.OrderDate   = DateTime.Now;
            cartOrder.OrderStatus = OrderStatus.Pending;

            int orderNumber = ordersManager.GetOrders().LastOrDefault().OrderNumber + 1;

            cartOrder.OrderNumber   = orderNumber;
            cartOrder.OrderDate     = DateTime.Now;
            cartOrder.LastModified  = DateTime.Now;
            cartOrder.OrderAttempts = 0;

            var currency = Config.Get <EcommerceConfig>().DefaultCurrency;

            cartOrder.Currency = currency;

            Customer customer = ordersManager.GetCustomers().Where(c => c.CustomerFirstName == ExistingCustomerFirstName).FirstOrDefault();

            cartOrder.UserId = customer.Id;

            CartDetail orderDetail = new CartDetail();

            orderDetail.Id               = Guid.NewGuid();
            orderDetail.ProductId        = product.Id;
            orderDetail.Quantity         = 1;
            orderDetail.ProductAvailable = true;
            orderDetail.Price            = product.Price;
            orderDetail.IsShippable      = true;
            cartOrder.Details.Add(orderDetail);

            CheckoutState state = UpdateCheckoutState(customer, ordersManager, cartOrder);

            ordersManager.SaveChanges();

            EcommerceOrderCalculator calculator = new EcommerceOrderCalculator();

            calculator.CalculateAndSaveChanges(cartOrder);

            ordersManager.Checkout(cartOrder.Id, state, customer);
            ordersManager.SaveChanges();
            catalogManager.SaveChanges();
        }
        public IList <CartDiscount> GetNotApplicableCartDiscounts(CartOrder cartOrder, decimal subTotal, User user, List <Role> userRoles)
        {
            this.addToRemovedDiscountDictionary = true;
            this.removedDiscount = new Dictionary <Guid, IList <CartDiscount> >();
            this.GetApplicableCartDiscounts(cartOrder, subTotal, user, userRoles);
            if (removedDiscount.ContainsKey(cartOrder.Id))
            {
                var result = removedDiscount[cartOrder.Id];
                return(new List <CartDiscount>(result));
            }

            return(new List <CartDiscount>());
        }
Пример #15
0
        //bætir order í cart
        public void AddToCart(OrderInputModel order)
        {
            var newOrder = new CartOrder()
            {
                amount         = order.amount,
                UserId         = order.UserId,
                ExpirationTime = order.ExpirationTime,
                BookId         = order.BookId
            };

            db.Carts.Add(newOrder);
            db.SaveChanges();
        }
Пример #16
0
        public CartOrder GetShoppingCartForUser(OrdersManager ordersManager)
        {
            Guid      shoppingCartId = GetShoopingCartId();
            CartOrder shoppingCart   = ordersManager.TryGetCartOrder(shoppingCartId);

            if (shoppingCart == null)
            {
                shoppingCartId = Guid.NewGuid();
                shoppingCart   = ordersManager.CreateCartOrder(shoppingCartId, null);
            }

            return(shoppingCart);
        }
Пример #17
0
        // static string sqlconnstr = ConfigurationManager.ConnectionStrings["loginsql"].ConnectionString;
        public string AddCartOrder(CartOrder co)
        {
            co.COID       = RandomID.GetRandomID("CO");
            co.CreateTime = DateTime.Now;
            co.GLID       = RandomID.GetRandomID("GL");

            using (IDbConnection conn = new SqlConnection(sqlconnstr))
            {
                conn.Open();
                conn.Execute(@"insert cartorder(openid,coid,createtime,glid) values(@openid,@coid,@createtime,@glid)", new { @openid = co.Openid, @coid = co.COID, @createtime = co.CreateTime, @glid = co.GLID });
            }
            return(co.GLID);
        }
        public async Task InstantOrder(Order instantOrder, int productId, decimal euroSpend)
        {
            //Add the order to Order Table and save it
            await OrderSave(instantOrder);

            //Calculate realtime from ask table
            var quantityToBeOrdered = await RealTimePrice(productId, euroSpend);

            //Find current product price
            var product = await db.Products.FindAsync(productId);

            //Add to cartOrder table the new order
            CartOrder newCartOrder = new CartOrder
            {
                OrderId   = instantOrder.OrderID,
                ProductId = productId,
                Quantity  = quantityToBeOrdered
            };

            await CartOrderSave(newCartOrder);

            //if product not exist in portfolio insert it
            var check = db.PortFolio.FirstOrDefault(x => x.ProductId == productId && x.UserPortofolioId == instantOrder.UserOrderId);

            if (check != null)
            {
                //if exists the raise its coin quantity
                check.CoinsQuantity += newCartOrder.Quantity;
                db.PortFolio.Update(check); //update the table
                await db.SaveChangesAsync();
            }
            else
            {
                //insert new product to portfolio
                Portfolio newproduct = new Portfolio
                {
                    ProductId        = productId,
                    CoinsQuantity    = newCartOrder.Quantity,
                    UserPortofolioId = instantOrder.UserOrderId
                };
                db.PortFolio.Add(newproduct);
                await db.SaveChangesAsync();
            }
            //Reduse the Wallet amount by euroSpend in parameters
            //Find Client Wallet and reduse it
            var clientUser = await _userManager.FindByIdAsync(instantOrder.UserOrderId);

            clientUser.Wallet -= euroSpend;
            //Save the changes
            await _userManager.UpdateAsync(clientUser);
        }
        private static string GetEmailMessageBody(CartOrder cartOrder, CheckoutState checkoutSate)
        {
            Guid templateId = new Guid("f949cccb-c337-4d0e-ad1e-f35a466b01e8");
            ControlPresentation emailTemplate;

            using (var pageManager = PageManager.GetManager())
            {
                IQueryable<ControlPresentation> controlPresentations = pageManager.GetPresentationItems<ControlPresentation>();

                emailTemplate = controlPresentations.Where(tmpl => tmpl.Id == templateId).SingleOrDefault();
            }

            return emailTemplate != null ? ReplaceValuesInTemplate(emailTemplate.Data, checkoutSate, cartOrder) : "";
        }
        internal static void SendOrderPlacedEmailToClientAndMerchant(CartOrder cartOrder, CheckoutState checkoutState, int orderNumber)
        {
            var messageBody = GetEmailMessageBody(cartOrder, checkoutState);

            if (string.IsNullOrEmpty(messageBody))
            {
                return;
            }

            string fromAddress = Config.Get <EcommerceConfig>().MerchantEmail;
            string subject     = String.Format(Res.Get <OrdersResources>("OrderEmailSubject"), orderNumber);

            SendEmail(fromAddress, checkoutState.BillingEmail, subject, messageBody, true);
        }
        private static string GetEmailMessageBody(CartOrder cartOrder, CheckoutState checkoutSate)
        {
            Guid templateId = new Guid("f949cccb-c337-4d0e-ad1e-f35a466b01e8");
            ControlPresentation emailTemplate;

            using (var pageManager = PageManager.GetManager())
            {
                IQueryable <ControlPresentation> controlPresentations = pageManager.GetPresentationItems <ControlPresentation>();

                emailTemplate = controlPresentations.Where(tmpl => tmpl.Id == templateId).SingleOrDefault();
            }

            return(emailTemplate != null?ReplaceValuesInTemplate(emailTemplate.Data, checkoutSate, cartOrder) : "");
        }
        // GET: CartOrders/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CartOrder cartOrder = _context.CartOrders.Find(id);

            if (cartOrder == null)
            {
                return(HttpNotFound());
            }
            return(View(cartOrder));
        }
Пример #23
0
        /// <summary>
        /// Serializes a view model and converts it to an Order
        /// </summary>
        /// <param name="model">Order view model</param>
        /// <returns>Table model from the database with serialized JSON</returns>
        private OrderInfo OrderSerialize(CartOrder model)
        {
            OrderInfo OrderInfoModel = new OrderInfo
            {
                Id         = model.Id,
                User       = model.User,
                DateTime   = model.DateTime,
                Status     = model.Status,
                TotalPrice = model.TotalPrice,
            };
            string json = JsonConvert.SerializeObject(model.CartOrderMenuItems);

            OrderInfoModel.OrderMenuItems = json;
            return(OrderInfoModel);
        }
        internal static void SendOrderPlacedEmailToClientAndMerchant(CartOrder cartOrder, CheckoutState checkoutState,int orderNumber)
        {
            var messageBody = GetEmailMessageBody(cartOrder, checkoutState);
            if (string.IsNullOrEmpty(messageBody))
            {
                //JMABase.WriteLogFile("Cannot send an email because there is no message body", "/ecommercelog.txt");
                return;
            }

            //JMABase.WriteLogFile("Message Body for email: " + messageBody, "/ecommercelog.txt");

            string fromAddress = Config.Get<EcommerceConfig>().MerchantEmail;
            string subject = String.Format(Res.Get<OrdersResources>("OrderEmailSubject"), orderNumber);
            SendEmail(fromAddress, checkoutState.BillingEmail, subject, messageBody, true);
        }
Пример #25
0
 public string QueryOrderGidByTrade(string trade)
 {
     if (_dao.IsContain(trade))
     {
         return(_dao.QuerySinglePayByTrade(trade).GID);
     }
     else
     {
         CartOrder co = _cdao.QueryCartByTrade(trade);
         if (co != null)
         {
             return(_cdao.QueryGoodList(co.GLID).GID);
         }
         return("");
     }
 }
Пример #26
0
        public async Task <ActionResult> ConfirmOrder([FromBody] CartOrder cartOrder, CancellationToken ct = default(CancellationToken))
        {
            try
            {
                if (cartOrder.userId == null || cartOrder.shippingAddress == null || cartOrder.paymentMethod == null)
                {
                    return(BadRequest());
                }

                return(StatusCode(201, await _Repository.ConfirmOrder(cartOrder.userId, cartOrder.shippingAddress, cartOrder.paymentMethod, ct)));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex));
            }
        }
        //public DiscountCalculatorCustom()
        //{
        //    if (removedDiscount == null)
        //    {
        //        removedDiscount = new Dictionary<Guid, IList<CartDiscount>>();
        //    }
        //}

        protected override IList <CartDiscount> GetApplicableCartDiscounts(CartOrder cartOrder, decimal subTotal, User user, List <Role> userRoles)
        {
            var all       = base.GetApplicableCartDiscounts(cartOrder, subTotal, user, userRoles);
            var discounts = all;

            if (discounts != null)
            {
                // Get Discount with specific code
                var discount = discounts
                               .Where(d => d.DiscountType == DiscountType.Coupon && d.ParentDiscount.CouponCode.Contains("code"))
                               .FirstOrDefault();

                if (discount != null)
                {
                    var identity = ClaimsManager.GetCurrentIdentity();
                    if (identity != null && identity.UserId != null && identity.UserId != Guid.Empty)
                    {
                        User currentUser = UserManager.GetManager().GetUser(identity.UserId);
                        if (new CustomerRetriever().IsNewCustomer(currentUser))
                        {
                            if (this.addToRemovedDiscountDictionary)
                            {
                                foreach (var item in discounts)
                                {
                                    AddToDictionary(cartOrder.Id, item);
                                }
                            }
                            // Apply only the coupon code discount
                            //for new customers and remove other discounts
                            discounts.Clear();
                            discounts.Add(discount);
                        }
                        else
                        {
                            if (this.addToRemovedDiscountDictionary)
                            {
                                AddToDictionary(cartOrder.Id, discount);
                            }
                            // Remove discount if not new customer
                            discounts.Remove(discount);
                        }
                    }
                }
            }

            return(discounts);
        }
Пример #28
0
        /// <summary>
        /// Calculates total price of order
        /// </summary>
        /// <param name="order">Order to calculate price for</param>
        /// <returns>Total price</returns>
        private double CalculateTotalPrice(CartOrder order)
        {
            double totalPrice = 0;

            foreach (var item in order.CartOrderMenuItems)
            {
                totalPrice += item.MenuItem.Price;
                if (item.AddOns != null)
                {
                    foreach (var addon in item.AddOns)
                    {
                        totalPrice += addon.Price;
                    }
                }
            }
            return(totalPrice);
        }
Пример #29
0
        /// <summary>
        /// Deserializes an Order and converts it to the view model
        /// </summary>
        /// <param name="model">Order from the databsase</param>
        /// <returns>View model of order with deserialized JSON for items in order</returns>
        private CartOrder OrderDeserialize(OrderInfo model)
        {
            CartOrder CartOrderModel = new CartOrder
            {
                Id                 = model.Id,
                User               = model.User,
                DateTime           = model.DateTime,
                Status             = model.Status,
                TotalPrice         = model.TotalPrice,
                CartOrderMenuItems = new List <CartOrderMenuItem>()
            };

            if (model.OrderMenuItems != null)
            {
                List <CartOrderMenuItem> CartOrderMenuItems = JsonConvert.DeserializeObject <List <CartOrderMenuItem> >(model.OrderMenuItems);
                CartOrderModel.CartOrderMenuItems = CartOrderMenuItems;
            }
            return(CartOrderModel);
        }
Пример #30
0
        public async Task <ActionResult> EditItem(CartOrderMenuItem item)
        {
            ApplicationUser user = await GetCurrentUserAsync();

            OrderInfo cart = await _context.OrderInfo.Where(usr => usr.User.Id == user.Id)
                             .Where(s => s.Status == Models.Status.Cart).SingleOrDefaultAsync();

            CartOrder viewModelCart = OrderDeserialize(cart);

            if (ModelState.IsValid)
            {
                //CartOrderMenuItem menuitem = viewModelCart.CartOrderMenuItems.Find(i => i.MenuItem.Id == item.MenuItem.Id);
                //menuitem.MenuItem.MenuItemIngredients = item.MenuItem.MenuItemIngredients;
                viewModelCart.TotalPrice = 0;
                foreach (var menuitem in viewModelCart.CartOrderMenuItems)
                {
                    if (menuitem.MenuItem.Id == item.MenuItem.Id)
                    {
                        menuitem.MenuItem.MenuItemIngredients = item.MenuItem.MenuItemIngredients;
                        menuitem.AddOns        = item.AddOns;
                        menuitem.MenuItem.Size = item.MenuItem.Size;
                    }
                    // Calculate total price
                    viewModelCart.TotalPrice += menuitem.MenuItem.Price;
                    if (menuitem.AddOns != null)
                    {
                        foreach (var addon in menuitem.AddOns)
                        {
                            viewModelCart.TotalPrice += addon.Price;
                        }
                    }
                }
                OrderInfo temp = OrderSerialize(viewModelCart);
                cart.OrderMenuItems = temp.OrderMenuItems;
                cart.TotalPrice     = temp.TotalPrice;
                await _context.SaveChangesAsync();

                return(Json(true));
            }
            return(Json(false));
        }
Пример #31
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Log.Info(this.GetType().ToString(), "page load");
            if (!IsPostBack)
            {
                //string GoodId = Request["GoodId"];
                JsApiPay jsApiPay = new JsApiPay(this);
                //jsApiPay.QueryId = GoodId;


                try
                {
                    //调用【网页授权获取用户信息】接口获取用户的openid和access_token
                    jsApiPay.GetOpenidAndAccessToken();

                    //获取收货地址js函数入口参数
                    wxEditAddrParam     = jsApiPay.GetEditAddressParameters();
                    ViewState["openid"] = jsApiPay.openid;
                    string            openid = jsApiPay.openid;
                    ShoppingCarServer server = new ShoppingCarServer();
                    Carlist   = server.QueryShoppingCar(openid);
                    Goodslist = server.QueryGoods(openid);
                    //dic.Add(jsApiPay.openid,goodid);
                    CartOrder car = new CartOrder();
                    car.Openid = ViewState["openid"].ToString();
                    CartOrderServer server1 = new CartOrderServer();
                    Session["glid"] = server1.GetGLid(car);
                }
                catch (Exception ex)
                {
                    Response.Write("<span style='color:#FF0000;font-size:20px'>" + "页面加载出错,请重试" + ex.Message + "</span>");
                    Button1.Visible = false;
                    //  Button2.Visible = false;
                    //Label1.Visible = false;
                    // Label2.Visible = false;
                }
            }
        }
Пример #32
0
        protected override decimal GetWithoutShippingTax(CartOrder cartOrder, User user, List <Role> userRoles, bool useExchangeRate)
        {
            decimal taxOnTotalBasePrice = GetPreDiscountTax(cartOrder, useExchangeRate);
            decimal totalBasePrice      = GetSubTotalWithoutTaxes(cartOrder, useExchangeRate);

            decimal totalBasePriceNoExchangeRate = GetTotalBasePriceNoExchangeRate(cartOrder);

            decimal discountTotal = new DiscountCalculatorCustom().CalculateAndApplyOrderDiscounts(cartOrder, totalBasePriceNoExchangeRate, user, userRoles, useExchangeRate);

            decimal withoutShippingTax = 0;
            var     taxDisplayMode     = EcommerceSettings.Taxes.TaxDisplayMode;

            if (taxDisplayMode == EcommerceConstants.OrdersConstants.ExcludingTax)
            {
                withoutShippingTax = EcommerceOrderCalculatorCustom.TaxIncludingDiscount(taxOnTotalBasePrice, totalBasePrice, discountTotal);
            }
            else
            {
                withoutShippingTax = taxOnTotalBasePrice;
            }

            return(withoutShippingTax);
        }
Пример #33
0
        /// <summary>
        /// 购物车订单
        /// </summary>
        /// <returns></returns>
        public ActionResult cartOrder()
        {
            string       username = Session["username"].ToString();
            var          ItemAt   = new CartOrder();
            SqlParameter user     = new SqlParameter("@username", username);
            var          cart     = musicDB.Database.SqlQuery <tb_cart>(
                "exec proc_userid @username", user
                ).Single();
            int cartID = cart.cartId;//根据username 找购物车ID

            ViewData["cartid"] = cartID;
            ItemAt.vc          = musicDB.view_cartItem.Where(vc => vc.cartid == cartID).ToList();
            ItemAt.at          = (from at in musicDB.tb_artist
                                  select at).OrderByDescending(x => x.artistId).Skip(4).Take(4).ToList();
            //显示订单信息到前台
            double sum = 0;

            foreach (view_cartItem v in ItemAt.vc)
            {
                sum += v.quantity * v.price;//计算总价
            }
            ViewData["total"] = sum;
            return(View(ItemAt));
        }
Пример #34
0
        /// <summary>
        /// Adds single menu item to cart
        /// </summary>
        /// <param name="id">Id of the item being added</param>
        /// <returns>Redirects user to cart</returns>
        // POST: CustomerMenu/PostMenuItemToCart/5
        public async Task <IActionResult> PostMenuItemToCart(int id)
        {
            ApplicationUser user = await GetCurrentUserAsync();

            MenuItem menuItem = await _context.MenuItem.Include(ing => ing.MenuItemIngredients).ThenInclude(ing => ing.Ingredient).SingleOrDefaultAsync(mi => mi.Id == id);

            OrderInfo cart = await _context.OrderInfo.Where(usr => usr.User.Id == user.Id).Where(s => s.Status == Models.Status.Cart).SingleOrDefaultAsync();

            Subcategory subcategory = await _context.Subcategory.Include(a => a.AddOns).SingleOrDefaultAsync(s => s.Id == menuItem.SubcategoryId);

            if (cart == null)
            {
                cart = AddNewOrderToDatabase(user);
            }
            // Adds menu item to the Order(Cart)
            CartOrder viewModelCart = OrderDeserialize(cart);

            viewModelCart.CartOrderMenuItems.Add(ConvertToOrderMenuItem(menuItem, subcategory));
            cart.OrderMenuItems = OrderSerialize(viewModelCart).OrderMenuItems;
            cart.TotalPrice    += menuItem.Price;
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(CustomerMenuController.Cart), "CustomerMenu", null));
        }