Esempio n. 1
0
        public JsonResult SubmitOrder(CommonModel.OrderPostModel model, string payPwd)
        {
            model.CurrentUser  = CurrentUser;
            model.PlatformType = (int)PlatformType.PC;
            if (string.IsNullOrEmpty(model.LatAndLng))
            {
                model.LatAndLng = "0,0";
            }
            var result = OrderApplication.SubmitOrder(model, payPwd);

            #region 处理虚拟订单项
            if (model.ProductType == 1 && model.VirtualProductItems != null && model.VirtualProductItems.Count() > 0)
            {
                var orderId = result.OrderIds.FirstOrDefault();
                if (orderId > 0)
                {
                    var orderItemInfo = OrderApplication.GetOrderItemsByOrderId(orderId).FirstOrDefault();
                    if (orderItemInfo != null)
                    {
                        var list = model.VirtualProductItems.ToList().Where(a => !string.IsNullOrWhiteSpace(a.Content)).ToList();//过滤空项
                        list.ForEach(a =>
                        {
                            a.OrderId     = orderId;
                            a.OrderItemId = orderItemInfo.Id;
                            if (a.VirtualProductItemType == (sbyte)Mall.Entities.ProductInfo.VirtualProductItemType.Picture)
                            {
                                a.Content = MoveImages(a.Content, CurrentUser.Id);
                            }
                        });
                        if (list.Count > 0)
                        {
                            OrderApplication.AddVirtualOrderItemInfo(list);
                        }
                    }
                }
            }
            #endregion

            return(Json(new { success = result.Success, orderIds = result.OrderIds, redirect = result.OrderTotal > 0 }));
        }
Esempio n. 2
0
        public JsonResult SubmitOrder(OrderPostModel model, string payPwd)
        {
            model.CurrentUser       = CurrentUser;
            model.PlatformType      = PlatformType.GetHashCode();
            model.IsShopbranchOrder = true;
            var result = OrderApplication.SubmitOrder(model, payPwd);

            OrderApplication.AddVshopBuyNumber(result.OrderIds);
            #region 处理虚拟订单项
            OrderApplication.AddVshopBuyNumber(result.OrderIds);
            if (model.ProductType == 1 && model.VirtualProductItems != null && model.VirtualProductItems.Count() > 0)
            {
                var orderId = result.OrderIds.FirstOrDefault();
                if (orderId > 0)
                {
                    var orderItemInfo = OrderApplication.GetOrderItemsByOrderId(orderId).FirstOrDefault();
                    if (orderItemInfo != null)
                    {
                        var list = model.VirtualProductItems.ToList().Where(a => !string.IsNullOrWhiteSpace(a.Content)).ToList();//过滤空项
                        list.ForEach(a =>
                        {
                            a.OrderId     = orderId;
                            a.OrderItemId = orderItemInfo.Id;
                            if (a.VirtualProductItemType == (sbyte)ProductInfo.VirtualProductItemType.Picture)
                            {
                                a.Content = MoveImages(a.Content, CurrentUser.Id);
                            }
                        });
                        if (list.Count > 0)
                        {
                            OrderApplication.AddVirtualOrderItemInfo(list);
                        }
                    }
                }
            }
            #endregion
            HttpContext.Session.Remove("OrderTag");
            return(Json <dynamic>(result.Success, data: new { orderIds = result.OrderIds, realTotalIsZero = result.OrderTotal == 0 }));
        }
Esempio n. 3
0
        public object PostSubmitOrder(OrderSubmitOrderModel value)
        {
            CheckUserLogin();
            if (value.CapitalAmount > 0 && !string.IsNullOrEmpty(value.PayPwd))
            {
                var flag = MemberApplication.VerificationPayPwd(CurrentUser.Id, value.PayPwd);
                if (!flag)
                {
                    throw new MallApiException("预存款支付密码错误");
                }
            }
            string skuIds = value.skuIds;
            string counts = value.counts;
            long recieveAddressId = value.recieveAddressId;
            string couponIds = value.couponIds;
            int integral = value.integral;

            bool isCashOnDelivery = value.isCashOnDelivery;
            int invoiceType = value.invoiceType;
            string invoiceTitle = value.invoiceTitle;
            string invoiceContext = value.invoiceContext;
            //end
            string orderRemarks = string.Empty;//value.orderRemarks;//订单备注

            OrderCreateModel model = new OrderCreateModel();
            var orderService = ServiceProvider.Instance<IOrderService>.Create;
            var productService = ServiceProvider.Instance<IProductService>.Create;
            var skuIdArr = skuIds.Split(',').Select(item => item.ToString());
            var countArr = counts.Split(',').Select(item => int.Parse(item));
            model.CouponIdsStr = CouponApplication.ConvertUsedCoupon(couponIds);
            IEnumerable<long> orderIds;
            model.PlatformType = PlatformType.Android;
            model.CurrentUser = CurrentUser;
            model.ReceiveAddressId = recieveAddressId;
            model.SkuIds = skuIdArr;
            model.Counts = countArr;
            model.Integral = integral;
            model.Capital = value.CapitalAmount;

            model.IsCashOnDelivery = isCashOnDelivery;
            model.Invoice = (InvoiceType)invoiceType;
            model.InvoiceContext = invoiceContext;
            model.InvoiceTitle = invoiceTitle;
            model.InvoiceCode = value.invoiceCode;

            CommonModel.OrderShop[] OrderShops = Newtonsoft.Json.JsonConvert.DeserializeObject<OrderShop[]>(value.jsonOrderShops);
            CommonModel.VirtualProductItem[] VirtualProductItems = Newtonsoft.Json.JsonConvert.DeserializeObject<VirtualProductItem[]>(value.VirtualProductItems);
            model.OrderShops = OrderShops;//用户APP选择门店自提时用到,2.5版本未支持门店自提
            model.OrderRemarks = OrderShops.Select(p => p.Remark).ToArray();
            //end
            model.IsShopbranchOrder = true;
            model.IsVirtual = value.ProductType == 1;
            if (model.IsVirtual && skuIdArr.Count() > 0)
            {
                var skuInfo = ProductManagerApplication.GetSKU(skuIdArr.FirstOrDefault());
                if (skuInfo != null)
                {
                    var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(skuInfo.ProductId);
                    if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value)
                    {
                        return ErrorResult("该虚拟商品已过期,不支持下单");
                    }
                }
            }
            try
            {
                //处理限时购
                if (skuIdArr.Count() == 1)
                {
                    var skuid = skuIdArr.ElementAt(0);
                    if (!string.IsNullOrWhiteSpace(skuid))
                    {
                        var sku = productService.GetSku(skuid);
                        bool isltmbuy = ServiceProvider.Instance<ILimitTimeBuyService>.Create.IsLimitTimeMarketItem(sku.ProductId);
                        model.IslimitBuy = isltmbuy;//标识为限时购计算价格按限时购价格核算
                    }
                }

                var orders = orderService.CreateOrder(model);
                orderIds = orders.Select(item => item.Id).ToArray();
                decimal orderTotals = orders.Sum(item => item.OrderTotalAmount);
                //orderIds = orderService.CreateOrder(CurrentUser.Id, skuIdArr, countArr, recieveAddressId, PlatformType);
                AddVshopBuyNumber(orderIds);//添加微店购买数量

                #region 处理虚拟订单项
                if (value.ProductType == 1 && VirtualProductItems != null && VirtualProductItems.Count() > 0)
                {
                    var orderId = orderIds.FirstOrDefault();
                    if (orderId > 0)
                    {
                        var orderItemInfo = OrderApplication.GetOrderItemsByOrderId(orderId).FirstOrDefault();
                        if (orderItemInfo != null)
                        {
                            var list = VirtualProductItems.ToList().Where(a => !string.IsNullOrWhiteSpace(a.Content)).ToList();//过滤空项
                            list.ForEach(a =>
                            {
                                a.OrderId = orderId;
                                a.OrderItemId = orderItemInfo.Id;
                                if (a.VirtualProductItemType == (sbyte)ProductInfo.VirtualProductItemType.Picture)
                                {
                                    a.Content = MoveImages(a.Content, CurrentUser.Id);
                                }
                            });
                            if (list.Count > 0)
                            {
                                OrderApplication.AddVirtualOrderItemInfo(list);
                            }
                        }
                    }
                }
                #endregion
                var _result = new { success = true, OrderIds = orderIds, RealTotalIsZero = orderTotals == 0 };
                return _result;
            }
            catch (MallException he)
            {
                return ErrorResult(he.Message);
            }
            catch (Exception ex)
            {
                return ErrorResult("提交订单异常");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 立即购买方式提交的订单
        /// </summary>
        /// <param name="value">数据</param>
        private object SubmitOrderById(OrderSubmitOrderModel value)
        {
            string skuIds           = value.skuIds;
            string counts           = value.counts;
            long   recieveAddressId = value.recieveAddressId;
            string couponIds        = value.couponIds;
            int    integral         = value.integral;

            bool   isCashOnDelivery = value.isCashOnDelivery;
            int    invoiceType      = value.invoiceType;
            string invoiceTitle     = value.invoiceTitle;
            string invoiceContext   = value.invoiceContext;
            //end
            string orderRemarks = string.Empty;//value.orderRemarks;//订单备注

            OrderCreateModel model = new OrderCreateModel();
            var orderService       = ServiceProvider.Instance <IOrderService> .Create;
            var productService     = ServiceProvider.Instance <IProductService> .Create;
            var skuIdArr           = skuIds.Split(',').Select(item => item.ToString());
            var countArr           = counts.Split(',').Select(item => int.Parse(item));

            model.CouponIdsStr = CouponApplication.ConvertUsedCoupon(couponIds);
            IEnumerable <long> orderIds;

            model.PlatformType     = PlatformType.WeiXinSmallProg;
            model.CurrentUser      = CurrentUser;
            model.ReceiveAddressId = recieveAddressId;
            model.SkuIds           = skuIdArr;
            model.Counts           = countArr;
            model.Integral         = integral;

            model.IsCashOnDelivery = isCashOnDelivery;
            model.Invoice          = (InvoiceType)invoiceType;
            model.InvoiceContext   = invoiceContext;
            model.InvoiceTitle     = invoiceTitle;

            model.formId  = value.formId;
            model.Capital = value.Capital;

            CommonModel.OrderShop[]          OrderShops          = Newtonsoft.Json.JsonConvert.DeserializeObject <OrderShop[]>(value.jsonOrderShops);
            CommonModel.VirtualProductItem[] VirtualProductItems = Newtonsoft.Json.JsonConvert.DeserializeObject <VirtualProductItem[]>(value.VirtualProductItems);
            model.OrderShops   = OrderShops;//用户APP选择门店自提时用到,2.5版本未支持门店自提
            model.OrderRemarks = OrderShops.Select(p => p.Remark).ToArray();
            //end

            if (value.isStore)
            {
                model.IsShopbranchOrder = true;
            }

            model.IsVirtual = value.ProductType == 1;
            if (model.IsVirtual && skuIdArr.Count() > 0)
            {
                var skuInfo = ProductManagerApplication.GetSKU(skuIdArr.FirstOrDefault());
                if (skuInfo != null)
                {
                    var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(skuInfo.ProductId);
                    if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value)
                    {
                        return(Json(ErrorResult <dynamic>("该虚拟商品已过期,不支持下单")));
                    }
                }
            }

            try
            {
                //处理限时购
                if (skuIdArr.Count() == 1)
                {
                    var skuid = skuIdArr.ElementAt(0);
                    if (!string.IsNullOrWhiteSpace(skuid))
                    {
                        var sku       = productService.GetSku(skuid);
                        var flashSale = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetLimitTimeMarketItemByProductId(sku.ProductId);

                        model.IslimitBuy  = flashSale != null;//标识为限时购计算价格按限时购价格核算
                        model.FlashSaleId = flashSale != null ? flashSale.Id : 0;
                    }
                }
                var orders = orderService.CreateOrder(model);
                orderIds = orders.Select(item => item.Id).ToArray();
                decimal orderTotals = orders.Where(d => d.PaymentType != Entities.OrderInfo.PaymentTypes.CashOnDelivery).Sum(item => item.OrderTotalAmount);
                //orderIds = orderService.CreateOrder(CurrentUser.Id, skuIdArr, countArr, recieveAddressId, PlatformType);
                AddVshopBuyNumber(orderIds);//添加微店购买数量

                #region 处理虚拟订单项
                if (value.ProductType == 1 && VirtualProductItems != null && VirtualProductItems.Count() > 0)
                {
                    var orderId = orderIds.FirstOrDefault();
                    if (orderId > 0)
                    {
                        var orderItemInfo = OrderApplication.GetOrderItemsByOrderId(orderId).FirstOrDefault();
                        if (orderItemInfo != null)
                        {
                            var list = VirtualProductItems.ToList().Where(a => !string.IsNullOrWhiteSpace(a.Content)).ToList();//过滤空项
                            list.ForEach(a =>
                            {
                                a.OrderId     = orderId;
                                a.OrderItemId = orderItemInfo.Id;
                                if (a.VirtualProductItemType == (sbyte)ProductInfo.VirtualProductItemType.Picture)
                                {
                                    a.Content = MoveImages(a.Content, CurrentUser.Id);
                                }
                            });
                            if (list.Count > 0)
                            {
                                OrderApplication.AddVirtualOrderItemInfo(list);
                            }
                        }
                    }
                }
                #endregion
                return(Json(new { OrderId = string.Join(",", orderIds), OrderTotal = orderTotals,
                                  RealTotalIsZero = (orderTotals - model.Capital) == 0, msg = "提交成功" }));
            }
            catch (MallException he)
            {
                return(Json(ErrorResult <dynamic>(he.Message)));
            }
        }