Exemplo n.º 1
0
        public JsonResult UpdateCartItem(string sku, string qty)
        {
            int ret = 0;
            //string sku = Request.Params["sku"].ToString();
            int q = ConvertHelper.ObjToInt(qty);

            if (!string.IsNullOrEmpty(sku) && base.CurrentUser != null)
            {
                if (base.CurrentUser.AccountInfo != null)
                {
                    ret = SALES_EBASKETService.UpdateEBasketQuantity(base.CurrentUser.AccountInfo.Account_no, base.CurrentUser.Id, sku, (float)q);
                }
            }
            if (ret > 0)
            {
                //ShoppingCart
                ViewBag.ShoppingCartModel = InitSalesEbasket(); //重新计算购物车信息

                return(Json(new { success = true, message = "successfull update to cart", shoppingCart = ViewBag.ShoppingCartModel }));
            }
            else
            {
                return(Json(new { success = false, message = "update cart failed." }));
            }
        }
Exemplo n.º 2
0
        protected int _AddCart(string pno, int qty)
        {
            int ret = 0;

            if (!string.IsNullOrEmpty(pno) && CurrentUser != null)
            {
                Domain.Models.Product.PROD_MASTER prod = PROD_MASTERService.GetProduct(pno);
                if (prod != null)
                {
                    if (CurrentUser.AccountInfo != null)
                    {
                        string unitPriceType = string.Empty;
                        double uPrice        = 0;
                        PROD_MASTERService.GetSellingPrice(prod.ProductNo, CurrentUser.AccountInfo.Account_no, out uPrice, out unitPriceType);
                        if (uPrice == 0)
                        {
                            uPrice = (double)prod.ListPrice;
                        }
                        var model = new SALES_EBASKETModel
                        {
                            ID          = Quick.Framework.Tool.CombHelper.NewComb().ToString(),
                            ContactID   = CurrentUser.Id,
                            CreateDate  = DateTime.Now,
                            Creator     = CurrentUser.AccountInfo.Account_no,
                            CustomerID  = CurrentUser.AccountInfo.Account_no,//request
                            ModiDate    = DateTime.Now,
                            Modifier    = CurrentUser.AccountInfo.Account_no,
                            ProductNo   = prod.ProductNo,
                            Quantity    = Convert.ToDouble(qty),
                            Unit        = prod.BaseUOFM,
                            UnitPrice   = uPrice,
                            UnitPType   = unitPriceType,
                            Status      = 0,
                            MakeOrderID = "",
                        };
                        if ((bool)CurrentUser.IsContractLimit && unitPriceType != "L") //only to purchase contract goods
                        {
                            if (unitPriceType == "S")                                  //Special Price
                            {
                                bool hasContractPrice = SALES_CONTRACTPRICEService.IsExist(CurrentUser.AccountInfo.Account_no, prod.ProductNo);
                                if (!hasContractPrice)
                                {
                                    return(-10);
                                    //return Json(new { success = false, message = "You need to purchase contract goods." });
                                }
                            }
                        }
                        ret = SALES_EBASKETService.ModificationCart(model); //成功了
                        //ret = SALES_EBASKETService.ModificationByProce(model);//有问题不可以使用
                    }
                }
            }
            return(ret);
        }
Exemplo n.º 3
0
        protected ShoppingCartViewModel InitSalesEbasket()
        {
            ShoppingCartViewModel cartModel = new ShoppingCartViewModel();

            //var user = SessionHelper.GetSession("CurrentSnellUser") as Rela_contact;
            if (CurrentUser != null)
            {
                string strWhere = string.Format("a.Status = 0 and a.ContactID = '{0}' and a.MakeOrderID = ''", CurrentUser.Id);
                var    list     = SALES_EBASKETService.QueryEntities(0, strWhere, "")
                                  //.Where(t => t.Status == 0 && t.ContactID == CurrentUser.Id && string.IsNullOrEmpty(t.MakeOrderID))
                                  .Select(t => new SALES_EBASKET_RelaModel
                {
                    StockType   = t.StockType,
                    StndCost    = t.StndCost,
                    UnitPrice   = t.UnitPrice,
                    Quantity    = t.Quantity,
                    Status      = t.Status,
                    ProductNo   = t.ProductNo,
                    Unit        = t.Unit,
                    UnitPType   = t.UnitPType,
                    ID          = t.ID,
                    ProductID   = t.ProductID,
                    ProductName = t.ProductName,
                    ProductPic  = t.ProductPic
                });

                StringBuilder sb            = new StringBuilder();
                StringBuilder sb_item       = new StringBuilder();
                int           item_count    = list.Count();
                double        item_subtotal = list.Sum(t => (t.Quantity * (double)t.UnitPrice));

                cartModel.ItemCount      = item_count;
                cartModel.CartTotal      = item_subtotal.ToString("N2");
                cartModel.Sales_Ebaskets = list;
                cartModel.Freight        = SALES_EBASKETService.GetUserFreight(item_subtotal);
                cartModel.Miscellaneous  = this.CurrentUser.Miscellaneous;
                cartModel.GST            = SYS_CONFIGService.GetCalculatedGst(cartModel.Freight, cartModel.Miscellaneous, item_subtotal);
                cartModel.Total          = item_subtotal + cartModel.Freight + cartModel.Miscellaneous + cartModel.GST;

                //Ben 2014-08-20 For the MinOrderValue
                if (CurrentUser.MinOrderValue > 0 && CurrentUser.MinOrderValue > item_subtotal)
                {
                    cartModel.Message = string.Format("We are unable to process as below ${0}/order threshold, please increase your order or contact the customers service team on 0800736557 to discuss options.", CurrentUser.MinOrderValue.ToString("N2"));
                }
                if (CurrentUser.MinOrderSize > 0 && CurrentUser.MinOrderSize > item_subtotal)
                {
                    cartModel.Misctitle = string.Format("Save ${1}! Simply by increasing your orders to ${0}, your small orders fee will be waived!", CurrentUser.MinOrderSize.ToString("N0"), CurrentUser.MinOrderMisc.ToString("N0"));
                }
            }
            return(cartModel);
        }
Exemplo n.º 4
0
        public JsonResult DeleCart(string id)
        {
            int ret = 0;

            if (!string.IsNullOrEmpty(id) && base.CurrentUser != null)
            {
                if (base.CurrentUser.AccountInfo != null)
                {
                    ret = SALES_EBASKETService.DeleteItem(id);
                }
            }
            if (ret > 0)
            {
                //ShoppingCart
                ViewBag.ShoppingCartModel = InitSalesEbasket(); //重新计算购物车信息

                return(Json(new { success = true, message = "successfull delete cart item", shoppingCart = ViewBag.ShoppingCartModel }));
            }
            else
            {
                return(Json(new { success = false, message = "delete cart item failed." }));
            }
        }