Exemplo n.º 1
0
        /// <summary>
        /// 添加商品到购物车
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage AddProductToShoppingCart()
        {
            HttpResponseMessage response = null;
            var result = false;

            try
            {
                Dictionary <string, int> dic = null;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        dic = WebCommom.HttpRequestBodyConvertToObj <Dictionary <string, int> >(ms);
                    }
                }
                if (dic.Count > 0)
                {
                    var userID    = dic["userID"];
                    var productID = dic["productID"];
                    var number    = dic["number"];
                    result = shoppingCartBll.Value.AddProductToShoppingCart(userID, productID, number);
                }
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(result);
            return(response);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 删除横幅
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage DeleteProduct()
        {
            HttpResponseMessage response = null;
            var result = false;

            try
            {
                var pID = 0;
                var str = "";
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    str = WebCommom.HttpRequestBodyConvertToStr(ms);//获取Request Body
                }

                if (!string.IsNullOrWhiteSpace(str))
                {
                    pID    = Convert.ToInt32(str);
                    result = bll.Value.DeleteProduct(pID);
                }
                if (result)
                {
                    lucene.Value.IndexPath = indexPath;
                    lucene.Value.DeleteDocument(Utilities.GetPropertyName <Product>(f => f.Name), pID.ToString());
                }
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(result);
            return(response);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 修改横幅
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage UpdateProduct()
        {
            HttpResponseMessage response = null;
            var result = false;

            try
            {
                Product product = null;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        product = WebCommom.HttpRequestBodyConvertToObj <Product>(ms);//获取转换后的Body
                    }
                }
                if (product != null)
                {
                    result = bll.Value.UpdateProduct(product);
                }
                if (result)//修改成功更新产品索引
                {
                    lucene.Value.IndexPath = indexPath;
                    lucene.Value.UpdateDocument(product, Utilities.GetPropertyName <Product>(f => f.PID), GetIndexField());
                }
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(result);
            return(response);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 删除品牌
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage DeleteBrand()
        {
            HttpResponseMessage response = null;

            try
            {
                var result = false;
                var str    = "";
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        str = WebCommom.HttpRequestBodyConvertToStr(ms);//获取Request Body
                    }
                }

                if (!string.IsNullOrWhiteSpace(str))
                {
                    var bID = Convert.ToInt32(str);
                    result = bll.Value.DeleteBrand(bID);
                }

                response = WebCommom.GetResponse(result);
            }
            catch (Exception ex)
            {
            }
            return(response);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 添加横幅
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage AddBanner()
        {
            HttpResponseMessage response = null;

            try
            {
                Banner banner = null;
                var    result = false;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        banner = WebCommom.HttpRequestBodyConvertToObj <Banner>(ms);
                    }
                }
                if (banner != null)
                {
                    result = bll.Value.AddBanner(banner);
                }
                response = WebCommom.GetResponse(result);
            }
            catch (Exception ex)
            {
            }
            return(response);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 修改品牌
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage UpdateBrand()
        {
            HttpResponseMessage response = null;

            try
            {
                Brand brand  = null;
                var   result = false;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        brand = WebCommom.HttpRequestBodyConvertToObj <Brand>(ms);//获取转换后的Body
                    }
                }

                if (brand != null)
                {
                    result = bll.Value.UpdateBrand(brand);
                }

                response = WebCommom.GetResponse(result);
            }
            catch (Exception ex)
            {
            }
            return(response);
        }
Exemplo n.º 7
0
        public HttpResponseMessage CreatePayOrder()
        {
            HttpResponseMessage response = null;
            PayOrder            payOrder = new PayOrder();

            try
            {
                List <Order> orders = null;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        var cText = WebCommom.HttpRequestBodyConvertToStr(ms);//密文
                        var pText = AES.AESDecrypt(cText, AESKey);
                        orders = JsonConvert.DeserializeObject <List <Order> >(pText);
                    }
                }
                if (orders != null)
                {
                    payOrder.Orders = orders;
                    payOrder.ID     = payOrderBll.Value.CreatePayOrder(payOrder);
                }
            }
            catch (Exception ex)
            {
            }
            var responseCText = AES.AESEncrypt(JsonConvert.SerializeObject(payOrder), AESKey);//返回密文

            response = WebCommom.GetResponse(responseCText);
            return(response);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 删除购物车商品
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage DeleteShoppingCartProduct()
        {
            HttpResponseMessage response = null;

            try
            {
                var pID    = new List <int>();
                var result = shoppingCartBll.Value.DeleteShoppingCartProduct(pID);
                response = WebCommom.GetResponse(result);
            }
            catch (Exception ex)
            {
            }
            return(response);
        }
Exemplo n.º 9
0
        public HttpResponseMessage GetProductReviewByProductID()
        {
            HttpResponseMessage  response = null;
            List <ProductReview> list     = null;

            try
            {
                var pID = WebCommom.HttpRequestBodyConvertToObj <int>(HttpContext.Current);
                list = reviewBll.Value.GetProductReviewByProductID(pID);
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(list);
            return(response);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 添加商品评论
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage AddProductReview()
        {
            HttpResponseMessage response = null;
            var result = false;

            try
            {
                var review = WebCommom.HttpRequestBodyConvertToObj <ProductReview>(HttpContext.Current);
                result = reviewBll.Value.AddProductReview(review);
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(result);
            return(response);
        }
Exemplo n.º 11
0
        public HttpResponseMessage UpdatePayOrder()
        {
            HttpResponseMessage response = null;
            var result = false;

            try
            {
                PayOrder payOrder = new PayOrder();
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        var cText = WebCommom.HttpRequestBodyConvertToStr(ms);//密文
                        var pText = AES.AESDecrypt(cText, AESKey);
                        payOrder = JsonConvert.DeserializeObject <PayOrder>(pText);
                    }
                }
                result = payOrderBll.Value.UdpatePayOrder(payOrder);
                #region   如果支付成功则通知店家发货(此处可改为异步处理)
                if (payOrder.TradeStatus == "")
                {
                    for (int i = 0; i < payOrder.Orders.Count; i++)
                    {
                        var storeStaff = storeStaffBll.Value.GetReceiveDeliveryStaff(payOrder.Orders[i].BuyProduct.Store.StoreID);
                        var phoneList  = new List <string>();
                        for (int j = 0; j < storeStaff.Count; j++)
                        {
                            phoneList.Add(storeStaff[j].Phone);
                        }
                        SMS sms = new SMS {
                        };
                        //  sms.ReceiveNo = phoneList;
                        //   sms.MSGContent = "";
                        CommomClass.HttpPost(GlobalDictionary.GetSysConfVal("AccountApiAddr"), JsonConvert.SerializeObject(sms));//通知店铺员工发货
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(result);
            return(response);
        }
Exemplo n.º 12
0
        public HttpResponseMessage CreateOrder()
        {
            List <Order>        resultList = new List <Order>();//创建成功的订单
            HttpResponseMessage response   = null;

            try
            {
                List <Order> list = null;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        var cText = WebCommom.HttpRequestBodyConvertToStr(ms); //密文
                        var pText = AES.AESDecrypt(cText, AESKey);             //明文
                        list = JsonConvert.DeserializeObject <List <Order> >(pText);
                    }
                }
                if (list != null)
                {
                    //  ProductStock_Cache p = new ProductStock_Cache();
                    //   var updateResult = p.UdpateStock(0, GetUpdateProdcut(list));//修改结果
                    //   resultList = GetSuccessOrder(updateResult, list);//获取修改成功的订单
                    #region 将订单加入到MQ,订单加入MQ之后则代表创建成功
                    //if (resultList.Count > 0)
                    //{
                    //    YunXiu.Commom.MQ.MSMQ mq = new YunXiu.Commom.MQ.MSMQ();
                    //    mq.MSMQIP = "192.168.9.32";
                    //    mq.MSMQName = "OrderQueue";
                    //    mq.MSG = JsonConvert.SerializeObject(resultList);
                    //    mq.SendToMSMQ();
                    //}
                    #endregion
                }
            }
            catch (Exception ex)
            {
            }
            var responseCText = AES.AESEncrypt(JsonConvert.SerializeObject(resultList), AESKey);//结果密文
            response = WebCommom.GetResponse(responseCText);
            return(response);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 添加商品
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage AddProduct()
        {
            HttpResponseMessage response = null;
            var result = false;

            try
            {
                Product product = null;
                var     id      = 0;//插入后返回的ID
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        product = WebCommom.HttpRequestBodyConvertToObj <Product>(ms);
                    }
                }
                if (product != null)
                {
                    id          = bll.Value.AddProduct(product);
                    product.PID = id;
                }
                if (id != 0)
                {
                    result = true;
                }
                if (result)//更新全文索引
                {
                    lucene.Value.IndexPath = indexPath;
                    lucene.Value.CreateIndexByData <Product>(new List <Product> {
                        product
                    }, GetIndexField(), false);
                }
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(result);
            return(response);
        }
Exemplo n.º 14
0
        public HttpResponseMessage BuyApply()
        {
            HttpResponseMessage response = null;
            var result = false;

            try
            {
                BuyApply buyApply = null;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        buyApply = WebCommom.HttpRequestBodyConvertToObj <BuyApply>(ms);
                    }
                }
                result = buyApplyBll.Value.CreateBuyApply(buyApply);
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(result);
            return(response);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 创建发货单
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage CreateInvoice()
        {
            HttpResponseMessage response = null;
            var result = false;

            try
            {
                Invoice invoice = null;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        invoice = WebCommom.HttpRequestBodyConvertToObj <Invoice>(ms);
                    }
                }
                result = invoiceBll.Value.CreateInvoice(invoice);
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(result);
            return(response);
        }