コード例 #1
0
        /// <summary>
        /// 从购物车中删除商品
        /// </summary>
        /// <param name="sellerId"></param>
        /// <param name="productId"></param>
        /// <returns></returns>
        public JsonResult DeleteGoodsFromCart(int sellerId, int productId)
        {
            CustomWebResult result = new CustomWebResult();
            var             user   = GetUser();

            if (user == null)
            {
                result.IsSuccess = false;
                result.Msg       = "请重新登陆";
                return(new JsonResult()
                {
                    Data = result
                });
            }

            string msg;

            if (BuyerShoppingCartBll.Delete(sellerId, user.BuyerId, productId, out msg))
            {
                result.IsSuccess = true;
                result.Msg       = "删除成功";
            }
            else
            {
                result.IsSuccess = false;
                result.Msg       = msg;
            }

            return(new JsonResult()
            {
                Data = result
            });
        }
コード例 #2
0
ファイル: ProductController.cs プロジェクト: Jeff-Bee/qdh
        /// <summary>
        /// 从购物车中删除商品
        /// </summary>
        /// <param name="sellerId"></param>
        /// <param name="productId"></param>
        /// <returns></returns>
        public JsonResult DeleteGoodsFromCart(int sellerId, int productId)
        {
            if (Session["IsGuest"] != null)
            {
                bool isGuest = (bool)Session["IsGuest"];
                if (isGuest)
                {
                    return(new JsonResult()
                    {
                        Data = new JsonResponseData()
                        {
                            IsSuccess = false, Msg = "该功能暂未开通"
                        }
                    });
                }
            }

            JsonResponseData result = new JsonResponseData();
            var user = GetUser();

            if (user == null)
            {
                result.IsSuccess = false;
                result.Msg       = "请重新登陆";
                return(new JsonResult()
                {
                    Data = result
                });
            }

            string msg;

            if (BuyerShoppingCartBll.Delete(sellerId, user.BuyerId, productId, out msg))
            {
                result.IsSuccess = true;
                result.Msg       = "删除成功";
            }
            else
            {
                result.IsSuccess = false;
                result.Msg       = msg;
            }

            return(new JsonResult()
            {
                Data = result
            });
        }
コード例 #3
0
ファイル: ProductController.cs プロジェクト: Jeff-Bee/qdh
        public JsonResult AddSellerOrdersToDb(string orderdetail)
        {
            if (Session["IsGuest"] != null)
            {
                bool isGuest = (bool)Session["IsGuest"];
                if (isGuest)
                {
                    return(new JsonResult()
                    {
                        Data = new JsonResponseData()
                        {
                            IsSuccess = false, Msg = "该功能暂未开通"
                        }
                    });
                }
            }


            JsonResponseData result = new JsonResponseData();
            var user = GetUser();

            if (user == null)
            {
                result.IsSuccess = false;
                result.Msg       = "请重新登陆";
                return(new JsonResult()
                {
                    Data = result
                });
            }


            var models =
                JsonConvert.DeserializeObject <List <SellerOrderDetailTinyViewModel> >(orderdetail);


            if (models == null)
            {
                result.IsSuccess = false;
                result.Msg       = "订单无效,无法提交";
                return(new JsonResult()
                {
                    Data = result
                });
            }

            models = models.Where(m => m.ProductQuantity > 0).ToList();


            if (models.Count == 0)
            {
                result.IsSuccess = false;
                result.Msg       = "什么也没有买~";
                return(new JsonResult()
                {
                    Data = result
                });
            }



            SellerOrderRun run = new SellerOrderRun()
            {
                Amount          = models.Sum(m => m.ProductQuantity * m.Price),
                BuyerId         = user.BuyerId,
                SellerId        = models.First().SellerId,
                OrderDate       = DateTime.Now,
                Code            = "",
                Config          = "",
                LDate           = DateTime.Now,
                RDate           = DateTime.Now,
                LMan            = user.BuyerId,
                RMan            = user.BuyerId,
                ProductQuantity = models.Sum(m => m.ProductQuantity)
            };

            int    orderId;
            string code;
            string msg;



            if (SellerOrderRunBll.Insert(run, out orderId, out code, out msg))
            {
                int index = 0;
                foreach (SellerOrderDetailTinyViewModel detailTinyViewModel in models)
                {
                    SellerOrderDetail detail = new SellerOrderDetail()
                    {
                        SellerId        = detailTinyViewModel.SellerId,
                        BuyerId         = user.BuyerId,
                        LMan            = user.BuyerId,
                        RMan            = user.BuyerId,
                        LDate           = DateTime.Now,
                        RDate           = DateTime.Now,
                        Index           = index++,
                        OrderId         = orderId,
                        ProductId       = detailTinyViewModel.ProductId,
                        ProductQuantity = detailTinyViewModel.ProductQuantity,
                        ProductName     = detailTinyViewModel.ProductName,
                        ProductPrice    = detailTinyViewModel.Price,
                        TotalPrice      = detailTinyViewModel.Price * detailTinyViewModel.ProductQuantity,
                        ProductUnit     = detailTinyViewModel.ProductUnit
                    };

                    SellerOrderDetailBll.Insert(detail);
                    BuyerShoppingCartBll.Delete(detail.SellerId, detail.BuyerId, detail.ProductId, out msg);
                }

                result.Msg       = "订单生成成功";
                result.IsSuccess = true;
            }
            else
            {
                result.Msg = "通讯异常,订单创建失败";
            }



            return(new JsonResult()
            {
                Data = result
            });
        }