Пример #1
0
        /// <summary>
        /// 进入购物车提交页面
        /// </summary>
        /// <param name="cartItemIds">购物车物品id集合</param>
        public ActionResult SubmiteByCart(string cartItemIds, long shippingAddressId = 0, string couponIds = "")
        {
            var coupons = CouponApplication.ConvertUsedCoupon(couponIds);
            var result  = OrderApplication.GetMobileSubmiteByCart(UserId, cartItemIds, shippingAddressId, coupons);

            ViewBag.InvoiceContext   = result.InvoiceContext;
            ViewBag.InvoiceTitle     = result.InvoiceTitle;
            ViewBag.IsCashOnDelivery = result.IsCashOnDelivery;
            ViewBag.address          = null == result.Address || result.Address.NeedUpdate ? null : result.Address;
            ViewBag.ConfirmModel     = result;

            var orderTag = Guid.NewGuid().ToString("N");

            ViewBag.OrderTag    = orderTag;
            Session["OrderTag"] = orderTag;

            InitOrderSubmitModel(result);
            #region 是否开启门店授权
            ViewBag.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore;
            #endregion
            #region TDO:ZYF 3.2注释是否提供发票
            //bool ProvideInvoice = false;
            //if (result.products != null)
            //    ProvideInvoice = ShopApplication.HasProvideInvoice(result.products.Select(p => p.shopId).ToList());
            //ViewBag.ProvideInvoice = ProvideInvoice;
            #endregion

            bool canIntegralPerMoney = true, canCapital = true;
            CanDeductible(out canIntegralPerMoney, out canCapital);
            ViewBag.CanIntegralPerMoney = canIntegralPerMoney;
            ViewBag.CanCapital          = canCapital;
            return(View("submit"));
        }
Пример #2
0
        /// <summary>
        /// 提交订单页面显示
        /// </summary>
        /// <param name="cartItemIds">提交的购物车物品集合</param>
        /// <param name="regionId">客户送货区域标识</param>
        public ActionResult Submit(string cartItemIds, long?regionId, string CouponIds = "")
        {
            //Logo
            ViewBag.Logo = SiteSettings.Logo;//获取Logo
            ViewBag.Step = 2;
            //设置会员信息
            ViewBag.Member = CurrentUser;
            string cartInfo    = WebHelper.GetCookie(CookieKeysCollection.Mall_CART);
            var    coupons     = CouponApplication.ConvertUsedCoupon(CouponIds);
            var    submitModel = OrderApplication.Submit(cartItemIds, regionId, UserId, cartInfo, coupons);

            ViewBag.IsCashOnDelivery = submitModel.IsCashOnDelivery;
            ViewBag.IsLimitBuy       = submitModel.IsLimitBuy;

            InitOrderSubmitModel(submitModel);
            #region 是否开启门店授权
            ViewBag.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore;
            #endregion
            #region 是否提供发票
            //bool ProvideInvoice = false;
            //if (submitModel.products != null)
            //    ProvideInvoice = ShopApplication.HasProvideInvoice(submitModel.products.Select(p => p.shopId).ToList());
            //ViewBag.ProvideInvoice = ProvideInvoice;
            #endregion
            bool canIntegralPerMoney = true, canCapital = true;
            CanDeductible(out canIntegralPerMoney, out canCapital);
            ViewBag.CanIntegralPerMoney = canIntegralPerMoney;
            ViewBag.CanCapital          = canCapital;
            ViewBag.Keyword             = SiteSettings.Keyword;
            return(View(submitModel));
        }
Пример #3
0
        /// <summary>
        /// 进入立即购买提交页面
        /// </summary>
        /// <param name="skuIds">库存ID集合</param>
        /// <param name="counts">库存ID对应的数量</param>
        /// <param name="GroupActionId">拼团活动编号</param>
        /// <param name="GroupId">拼团编号</param>
        public ActionResult Submit(string skuIds, string counts, int islimit = 0, long shippingAddressId = 0, string couponIds = "")
        {
            var coupons = CouponApplication.ConvertUsedCoupon(couponIds);
            var result  = OrderApplication.GetMobileSubmit(UserId, skuIds, counts, shippingAddressId, coupons);

            ViewBag.InvoiceContext   = result.InvoiceContext;
            ViewBag.InvoiceTitle     = result.InvoiceTitle;
            ViewBag.skuIds           = skuIds;
            ViewBag.counts           = counts;
            ViewBag.IsCashOnDelivery = result.IsCashOnDelivery;
            ViewBag.address          = null == result.Address || result.Address.NeedUpdate ? null : result.Address;
            ViewBag.ConfirmModel     = result;
            ViewBag.Islimit          = islimit == 1 ? true : false;

            var orderTag = Guid.NewGuid().ToString("N");

            ViewBag.OrderTag    = orderTag;
            Session["OrderTag"] = orderTag;

            InitOrderSubmitModel(result);
            #region 是否开启门店授权
            ViewBag.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore;
            #endregion

            #region TDO:ZYF 3.2注释是否提供发票
            //bool ProvideInvoice = false;
            //if (result.products != null)
            //    ProvideInvoice = ShopApplication.HasProvideInvoice(result.products.Select(p => p.shopId).ToList());
            //ViewBag.ProvideInvoice = ProvideInvoice;
            #endregion

            bool canIntegralPerMoney = true, canCapital = true;
            CanDeductible(out canIntegralPerMoney, out canCapital);
            ViewBag.CanIntegralPerMoney = canIntegralPerMoney;
            ViewBag.CanCapital          = canCapital;
            ViewBag.productType         = result.ProductType;
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;
            if (result.ProductType == 1)
            {
                var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(result.ProductId);
                if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value)
                {
                    throw new HimallException("该虚拟商品已过期,不支持下单");
                }
                if (result.products != null && result.products.Count > 0)
                {
                    var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(result.products.FirstOrDefault().shopId);
                    if (verificationShipper != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                        shipperTelPhone = verificationShipper.TelPhone;
                    }
                }
            }
            ViewBag.ShipperAddress  = shipperAddress;
            ViewBag.ShipperTelPhone = shipperTelPhone;
            return(View());
        }
Пример #4
0
        /// <summary>
        /// 点击立即购买调用的GET方法,但是重定向到了Submit页面
        /// </summary>
        /// <param name="skuIds">多个库存Id</param>
        /// <param name="counts">每个库存对应的数据量</param>
        /// <param name="regionId">客户收货地区的id</param>
        /// <param name="collpids">组合购Id集合</param>
        /// <returns>订单提交页面的数据</returns>
        public ActionResult SubmitByProductId(string skuIds, string counts, long?regionId, string collpids = null, string CouponIds = "", sbyte productType = 0, long productId = 0)
        {
            //Logo
            ViewBag.Logo = SiteSettings.Logo; //获取Logo
                                              //设置会员信息
            ViewBag.Member = CurrentUser;
            var coupons     = CouponApplication.ConvertUsedCoupon(CouponIds);
            var submitModel = OrderApplication.SubmitByProductId(UserId, skuIds, counts, regionId, collpids, coupons, productType);

            ViewBag.IsCashOnDelivery = submitModel.IsCashOnDelivery;
            ViewBag.IsLimitBuy       = submitModel.IsLimitBuy;

            InitOrderSubmitModel(submitModel);
            #region 是否开启门店授权
            ViewBag.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore;
            #endregion
            #region 是否提供发票
            //bool ProvideInvoice = false;
            //if (submitModel.products != null)
            //    ProvideInvoice = ShopApplication.HasProvideInvoice(submitModel.products.Select(p => p.shopId).ToList());
            //ViewBag.ProvideInvoice = ProvideInvoice;
            #endregion

            bool canIntegralPerMoney = true, canCapital = true;
            CanDeductible(out canIntegralPerMoney, out canCapital);
            ViewBag.CanIntegralPerMoney = canIntegralPerMoney;
            ViewBag.CanCapital          = canCapital;

            ViewBag.Keyword = SiteSettings.Keyword;
            if (productType == 1 && productId > 0)
            {
                submitModel.VirtualProductItemInfos = ProductManagerApplication.GetVirtualProductItemInfoByProductId(productId);
                var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(productId);
                if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value)
                {
                    throw new MallException("该虚拟商品已过期,不支持下单");
                }
            }
            submitModel.ProductType = productType;
            if (productType == 1 && submitModel.products != null && submitModel.products.Count > 0)
            {
                var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(submitModel.products.FirstOrDefault().shopId);
                if (verificationShipper != null)
                {
                    ViewBag.ShipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                    ViewBag.ShipperTelPhone = verificationShipper.TelPhone;
                }
            }
            return(View("Submit", submitModel));
        }
Пример #5
0
        /// <summary>
        /// 进入购物车提交页面
        /// </summary>
        /// <param name="cartItemIds">购物车物品id集合</param>
        public ActionResult SubmiteByCart(string cartItemIds, long shippingAddressId = 0, string couponIds = "")
        {
            var coupons = CouponApplication.ConvertUsedCoupon(couponIds);
            var result  = OrderApplication.GetMobileSubmiteByCart(UserId, cartItemIds, shippingAddressId, coupons);

            ViewBag.InvoiceContext   = result.InvoiceContext;
            ViewBag.InvoiceTitle     = result.InvoiceTitle;
            ViewBag.IsCashOnDelivery = result.IsCashOnDelivery;
            ViewBag.address          = null == result.Address || result.Address.NeedUpdate ? null : result.Address;
            ViewBag.ConfirmModel     = result;
            if (result.products.Count == 0)
            {
                return(Redirect("/" + ViewBag.AreaName));
            }

            if (result.shopBranchInfo == null)
            {
                throw new MallException("获取门店信息失败,不可提交非门店商品");
            }


            var orderTag = Guid.NewGuid().ToString("N");

            ViewBag.OrderTag = orderTag;
            HttpContext.Session.Set <string>("OrderTag", orderTag);

            InitOrderSubmitModel(result);
            #region 是否开启门店授权
            ViewBag.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore;
            #endregion
            #region 是否提供发票
            bool ProvideInvoice = false;
            if (result.products != null)
            {
                ProvideInvoice = ShopApplication.HasProvideInvoice(result.products.Select(p => p.shopId).ToList());
            }
            ViewBag.ProvideInvoice = ProvideInvoice;
            #endregion

            bool canIntegralPerMoney = true, canCapital = true;
            CanDeductible(out canIntegralPerMoney, out canCapital);
            ViewBag.CanIntegralPerMoney = canIntegralPerMoney;
            ViewBag.CanCapital          = canCapital;
            ViewBag.productType         = 0;
            ViewBag.ShipperAddress      = "";
            ViewBag.ShipperTelPhone     = "";

            return(View("submit"));
        }
Пример #6
0
        public object GetSubmitModel(string cartItemIds, string productSku, WXSmallProgFromPageType fromPage, long buyAmount = 0, long shippingAddressId = 0, string couponIds = "", bool isStore = false, sbyte productType = 0, long shopBranchId = 0)
        {
            CheckUserLogin();
            var coupons = CouponApplication.ConvertUsedCoupon(couponIds);

            if (fromPage == WXSmallProgFromPageType.SignBuy)
            {
                if (!string.IsNullOrWhiteSpace(productSku))
                {
                    return(GetSubmitModelById(productSku, (int)buyAmount, shippingAddressId, coupons, isStore, productType, shopBranchId));
                }
            }
            if (fromPage == WXSmallProgFromPageType.Cart)
            {
                return(GetSubmitByCartModel(cartItemIds, shippingAddressId, coupons, isStore));
            }
            return(Json(ErrorResult <dynamic>(string.Empty)));
        }
Пример #7
0
        /// <summary>
        /// 组合购提交页面
        /// </summary>
        /// <param name="skuIds">多个库存Id</param>
        /// <param name="counts">每个库存对应的数据量</param>
        /// <param name="regionId">客户收货地区的id</param>
        /// <param name="collpids">组合购Id集合</param>
        /// <returns>订单提交页面的数据</returns>
        public ActionResult SubmitByProductId(string skuIds, string counts, long?regionId, string collpids = null, long shippingAddressId = 0, string couponIds = "")
        {
            var coupons = CouponApplication.ConvertUsedCoupon(couponIds);

            //Logo
            ViewBag.Logo = SiteSettings.Logo;//获取Logo
            //设置会员信息
            ViewBag.Member = CurrentUser;
            var result = OrderApplication.GetMobileCollocationBuy(UserId, skuIds, counts, regionId, collpids, shippingAddressId, coupons);

            ViewBag.collpids         = collpids;
            ViewBag.skuIds           = skuIds;
            ViewBag.counts           = counts;
            ViewBag.InvoiceContext   = result.InvoiceContext;
            ViewBag.InvoiceTitle     = result.InvoiceTitle;
            ViewBag.IsCashOnDelivery = result.IsCashOnDelivery;
            ViewBag.address          = null == result.Address || result.Address.NeedUpdate ? null : result.Address;
            ViewBag.ConfirmModel     = result;
            ViewBag.Islimit          = false;

            var orderTag = Guid.NewGuid().ToString("N");

            ViewBag.OrderTag = orderTag;
            HttpContext.Session.Set <string>("OrderTag", orderTag);

            InitOrderSubmitModel(result);
            #region 是否开启门店授权
            ViewBag.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore;
            #endregion

            #region TDO:ZYF 3.2注释是否提供发票
            //bool ProvideInvoice = false;
            //if (result.products != null)
            //    ProvideInvoice = ShopApplication.HasProvideInvoice(result.products.Select(p => p.shopId).ToList());
            //ViewBag.ProvideInvoice = ProvideInvoice;
            #endregion

            bool canIntegralPerMoney = true, canCapital = true;
            CanDeductible(out canIntegralPerMoney, out canCapital);
            ViewBag.CanIntegralPerMoney = canIntegralPerMoney;
            ViewBag.CanCapital          = canCapital;
            return(View("Submit"));
        }
Пример #8
0
        public object GetSubmitModel(string skuId, int count, long shippingAddressId = 0, string couponIds = "", sbyte productType = 0, long shopBranchId = 0)
        {
            if (productType == 0)
                throw new MallException("门店订单暂时不允许立即购买");

            //门店订单
            Mall.DTO.ShopBranch storeInfo = Application.ShopBranchApplication.GetShopBranchById(shopBranchId);
            if (storeInfo == null)
                throw new MallException("获取门店信息失败,不可提交非门店商品");


            CheckUserLogin();
            var coupons = CouponApplication.ConvertUsedCoupon(couponIds);
            var result = OrderApplication.GetMobileSubmit(CurrentUserId, skuId.ToString(), count.ToString(), shippingAddressId, coupons, shopBranchId);
            dynamic d = SuccessResult();

            bool canIntegralPerMoney = true, canCapital = true;
            CanDeductible(out canIntegralPerMoney, out canCapital);


            //解决循环引用的序列化的问题
            dynamic address = new System.Dynamic.ExpandoObject();
            if (result.Address != null)
            {
                var addDetail = result.Address.AddressDetail ?? "";
                var add = new
                {
                    Id = result.Address.Id,
                    ShipTo = result.Address.ShipTo,
                    Phone = result.Address.Phone,
                    Address = result.Address.RegionFullName + " " + result.Address.Address + " " + addDetail,
                    RegionId = result.Address.RegionId
                };
                address = add;
            }
            else
                address = null;

            //d.InvoiceContext = result.InvoiceContext;
            //d.InvoiceTitle = OrderApplication.GetInvoiceTitles(CurrentUserId);
            d.InvoiceContext = result.InvoiceContext;//发票类容
            d.InvoiceTitle = result.InvoiceTitle;//发票抬头
            d.cellPhone = result.cellPhone;//默认收票人手机
            d.email = result.email;//默认收票人邮箱
            d.vatInvoice = result.vatInvoice;//默认增值税发票
            d.invoiceName = result.invoiceName;//默认抬头(普通、电子)
            d.invoiceCode = result.invoiceCode;//默认税号(普通、电子)
            d.products = result.products;
            d.TotalAmount = result.totalAmount;
            d.Freight = result.Freight;
            d.orderAmount = result.orderAmount;
            d.IsCashOnDelivery = result.IsCashOnDelivery;
            d.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore;
            d.ProvideInvoice = ShopApplication.HasProvideInvoice(result.products.Select(s => s.shopId).Distinct().ToList());
            
            d.integralPerMoney = result.integralPerMoney;
            d.userIntegralMaxDeductible = result.userIntegralMaxDeductible;
            d.integralPerMoneyRate = result.integralPerMoneyRate;
            d.userIntegralMaxRate = SiteSettingApplication.SiteSettings.IntegralDeductibleRate;
            d.userIntegrals = result.userIntegrals;
            d.TotalMemberIntegral = result.memberIntegralInfo.AvailableIntegrals;
            d.canIntegralPerMoney = canIntegralPerMoney;
            d.canCapital = canCapital;
            d.capitalAmount = result.capitalAmount;
            d.productType = productType;
            d.shopBranchId = shopBranchId;
            d.shopBranchInfo = storeInfo;
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;
            if (productType == 1)
            {
                var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(result.ProductId);
                if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value)
                {
                    throw new MallException("该虚拟商品已过期,不支持下单");
                }
                if (storeInfo != null)
                {
                    shipperAddress = RegionApplication.GetFullName(storeInfo.AddressId)  + storeInfo.AddressDetail;//ShopBranchApplication.RenderAddress(storeInfo.AddressPath, storeInfo.AddressDetail, 2);
                    shipperTelPhone = storeInfo.ContactPhone;
                }
            }
            d.shipperAddress = shipperAddress;
            d.shipperTelPhone = shipperTelPhone;
            return d;
        }
Пример #9
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("提交订单异常");
            }
        }
Пример #10
0
        public object GetSubmitByCartModel(string cartItemIds = "", long shippingAddressId = 0, string couponIds = "")
        {
            CheckUserLogin();
            var coupons = CouponApplication.ConvertUsedCoupon(couponIds);
            var result = OrderApplication.GetMobileSubmiteByCart(CurrentUserId, cartItemIds, shippingAddressId, coupons);
            //门店订单
            Mall.DTO.ShopBranch storeInfo = null;
            if (result.shopBranchInfo == null)
                throw new MallException("获取门店信息失败,不可提交非门店商品");
            else
            {
                storeInfo = Application.ShopBranchApplication.GetShopBranchById(result.shopBranchInfo.Id);
            }

            //解决循环引用的序列化的问题
            dynamic address = new System.Dynamic.ExpandoObject();
            if (result.Address != null)
            {
                var addDetail = result.Address.AddressDetail ?? "";
                var add = new
                {
                    Id = result.Address.Id,
                    ShipTo = result.Address.ShipTo,
                    Phone = result.Address.Phone,
                    Address = result.Address.RegionFullName + " " + result.Address.Address + " " + addDetail,
                    RegionId = result.Address.RegionId
                };
                address = add;
            }
            else
                address = null;

            bool canIntegralPerMoney = true, canCapital = true;
            CanDeductible(out canIntegralPerMoney, out canCapital);

            var _result = new
            {
                success = true,
                Address = address,
                IsCashOnDelivery = result.IsCashOnDelivery,
                InvoiceContext = result.InvoiceContext,
                InvoiceTitle = result.InvoiceTitle,
                cellPhone = result.cellPhone,
                email = result.email,
                vatInvoice = result.vatInvoice,
                invoiceName = result.invoiceName,//默认抬头(普通、电子)
                invoiceCode = result.invoiceCode,//默认税号(普通、电子)
                products = result.products,
                TotalAmount = result.totalAmount,
                Freight = result.Freight,
                orderAmount = result.orderAmount,
                shopBranchInfo = storeInfo,
                IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore,
                capitalAmount = result.capitalAmount,
                ProvideInvoice = ShopApplication.HasProvideInvoice(result.products.Select(s => s.shopId).Distinct().ToList()),

                integralPerMoney = result.integralPerMoney,
                userIntegralMaxDeductible = result.userIntegralMaxDeductible,
                integralPerMoneyRate = result.integralPerMoneyRate,
                userIntegralMaxRate = SiteSettingApplication.SiteSettings.IntegralDeductibleRate,
                userIntegrals = result.userIntegrals,
                TotalMemberIntegral = result.memberIntegralInfo.AvailableIntegrals,
                canIntegralPerMoney = canIntegralPerMoney,
                canCapital = canCapital
            };
            return _result;
        }
Пример #11
0
        /// <summary>
        /// 进入立即购买提交页面
        /// </summary>
        /// <param name="skuIds">库存ID集合</param>
        /// <param name="counts">库存ID对应的数量</param>
        /// <param name="GroupActionId">拼团活动编号</param>
        /// <param name="GroupId">拼团编号</param>
        public ActionResult Submit(string skuIds, string counts, int islimit = 0, long shippingAddressId = 0, string couponIds = "", sbyte productType = 0, long shopBranchId = 0)
        {
            if (productType == 0)
            {
                throw new MallException("门店订单不支持立即购买");
            }

            var coupons = CouponApplication.ConvertUsedCoupon(couponIds);
            var result  = OrderApplication.GetMobileSubmit(UserId, skuIds, counts, shippingAddressId, coupons, shopBranchId);

            ViewBag.InvoiceContext   = result.InvoiceContext;
            ViewBag.InvoiceTitle     = result.InvoiceTitle;
            ViewBag.skuIds           = skuIds;
            ViewBag.counts           = counts;
            ViewBag.IsCashOnDelivery = result.IsCashOnDelivery;
            ViewBag.address          = null == result.Address || result.Address.NeedUpdate ? null : result.Address;
            if (result.products != null)
            {
                var bid = result.products.FirstOrDefault().ShopBranchId;
                result.shopBranchInfo = ShopBranchApplication.GetShopBranchInfoById(bid);
            }
            ViewBag.ConfirmModel = result;
            ViewBag.Islimit      = islimit == 1 ? true : false;

            string orderTag = Guid.NewGuid().ToString("N");

            ViewBag.OrderTag = orderTag;
            //Session["OrderTag"] = orderTag;

            base.HttpContext.Session.Set <string>("OrderTag", orderTag);

            InitOrderSubmitModel(result);
            #region 是否开启门店授权
            ViewBag.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore;
            #endregion

            #region 是否提供发票
            bool ProvideInvoice = false;
            if (result.products != null)
            {
                ProvideInvoice = ShopApplication.HasProvideInvoice(result.products.Select(p => p.shopId).ToList());
            }
            ViewBag.ProvideInvoice = ProvideInvoice;
            #endregion

            bool canIntegralPerMoney = true, canCapital = true;
            CanDeductible(out canIntegralPerMoney, out canCapital);
            ViewBag.CanIntegralPerMoney = canIntegralPerMoney;
            ViewBag.CanCapital          = canCapital;
            ViewBag.productType         = productType;
            ViewBag.shopBranchId        = shopBranchId;
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;
            if (productType == 1)
            {
                var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(result.ProductId);
                if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value)
                {
                    throw new MallException("该虚拟商品已过期,不支持下单");
                }
                if (result.shopBranchInfo != null)
                {
                    shipperAddress  = RegionApplication.GetFullName(result.shopBranchInfo.AddressId) + result.shopBranchInfo.AddressDetail;
                    shipperTelPhone = result.shopBranchInfo.ContactPhone;
                }
            }
            ViewBag.ShipperAddress  = shipperAddress;
            ViewBag.ShipperTelPhone = shipperTelPhone;
            return(View());
        }
Пример #12
0
        /// <summary>
        /// 购物车方式提交的订单
        /// </summary>
        /// <param name="value">数据</param>
        private object SubmitOrderByCart(OrderSubmitOrderByCartModel value)
        {
            string cartItemIds      = value.cartItemIds;
            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;

            OrderCreateModel model = new OrderCreateModel();
            List <OrderInfo> infos = new List <OrderInfo>();

            var orderService = ServiceProvider.Instance <IOrderService> .Create;
            IEnumerable <long> orderIds;

            model.PlatformType     = PlatformType.WeiXinSmallProg;
            model.CurrentUser      = CurrentUser;
            model.ReceiveAddressId = recieveAddressId;
            model.Integral         = integral;

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

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

            if (value.isStore)
            {
                model.IsShopbranchOrder = true;
            }
            //end
            CommonModel.OrderShop[] OrderShops = Newtonsoft.Json.JsonConvert.DeserializeObject <OrderShop[]>(value.jsonOrderShops);
            model.OrderShops   = OrderShops;//用户APP选择门店自提时用到,2.5版本未支持门店自提
            model.OrderRemarks = OrderShops.Select(p => p.Remark).ToArray();
            try
            {
                var cartItemIdsArr = cartItemIds.Split(',').Select(item => long.Parse(item)).ToArray();
                //根据购物车项补充sku数据
                var cartItems = CartApplication.GetCartItems(cartItemIdsArr);
                model.SkuIds = cartItems.Select(e => e.SkuId).ToList();
                model.Counts = cartItems.Select(e => e.Quantity).ToList();

                model.CartItemIds  = cartItemIdsArr;
                model.CouponIdsStr = CouponApplication.ConvertUsedCoupon(couponIds);

                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);

                return(Json(new { OrderId = string.Join(",", orderIds), OrderTotal = orderTotals,
                                  RealTotalIsZero = (orderTotals - model.Capital) == 0, msg = "提交成功" }));
            }
            catch (MallException he)
            {
                return(Json(ErrorResult <dynamic>(he.Message)));
            }
        }
Пример #13
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)));
            }
        }
Пример #14
0
        /// <summary>
        /// 获取立即购买提交页面的数据
        /// </summary>
        /// <param name="skuIds">库存ID集合</param>
        /// <param name="counts">库存ID对应的数量</param>
        public object GetSubmitModel(string skuId, int count, long shippingAddressId = 0, string couponIds = "")
        {
            CheckUserLogin();
            var     coupons = CouponApplication.ConvertUsedCoupon(couponIds);
            var     result  = OrderApplication.GetMobileSubmit(CurrentUserId, skuId.ToString(), count.ToString(), shippingAddressId, coupons);
            dynamic d       = SuccessResult();

            if (result.Address != null && !result.Address.NeedUpdate)
            {
                var addDetail = result.Address.AddressDetail ?? "";
                var add       = new
                {
                    Id       = result.Address.Id,
                    ShipTo   = result.Address.ShipTo,
                    Phone    = result.Address.Phone,
                    Address  = result.Address.RegionFullName + " " + result.Address.Address + " " + addDetail,
                    RegionId = result.Address.RegionId
                };
                d.Address = add;
            }
            else
            {
                d.Address = null;
            }

            bool canIntegralPerMoney = true, canCapital = true;

            CanDeductible(out canIntegralPerMoney, out canCapital);

            d.canIntegralPerMoney = canIntegralPerMoney;
            d.canCapital          = canCapital;
            //发票信息
            d.InvoiceContext   = result.InvoiceContext; //发票类容
            d.InvoiceTitle     = result.InvoiceTitle;   //发票抬头
            d.cellPhone        = result.cellPhone;      //默认收票人手机
            d.email            = result.email;          //默认收票人邮箱
            d.vatInvoice       = result.vatInvoice;     //默认增值税发票
            d.invoiceName      = result.invoiceName;    //默认抬头(普通、电子)
            d.invoiceCode      = result.invoiceCode;    //默认税号(普通、电子)
            d.products         = result.products;
            d.capitalAmount    = result.capitalAmount;
            d.TotalAmount      = result.totalAmount;
            d.Freight          = result.Freight;
            d.orderAmount      = result.orderAmount;
            d.IsCashOnDelivery = result.IsCashOnDelivery;
            d.IsOpenStore      = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore;
            d.ProvideInvoice   = ShopApplication.HasProvideInvoice(result.products.Select(s => s.shopId).Distinct().ToList());

            d.integralPerMoney          = result.integralPerMoney;
            d.userIntegralMaxDeductible = result.userIntegralMaxDeductible;
            d.integralPerMoneyRate      = result.integralPerMoneyRate;
            d.userIntegralMaxRate       = SiteSettingApplication.SiteSettings.IntegralDeductibleRate;
            d.userIntegrals             = result.userIntegrals;
            d.TotalMemberIntegral       = result.memberIntegralInfo.AvailableIntegrals;
            d.productType = result.ProductType;
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;

            if (result.ProductType == 1)
            {
                var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(result.ProductId);
                if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value)
                {
                    throw new HimallException("该虚拟商品已过期,不支持下单");
                }
                if (result.products != null && result.products.Count > 0)
                {
                    var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(result.products.FirstOrDefault().shopId);//虚拟订单支持立即购买所以商家只有一个
                    if (verificationShipper != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                        shipperTelPhone = verificationShipper.TelPhone;
                    }
                }
            }
            d.shipperAddress  = shipperAddress;
            d.shipperTelPhone = shipperTelPhone;
            return(d);
        }
Пример #15
0
        /// <summary>
        /// 购物车方式提交的订单
        /// </summary>
        /// <param name="value">数据</param>
        public object PostSubmitOrderByCart(OrderSubmitOrderByCartModel value)
        {
            CheckUserLogin();
            if (value.CapitalAmount > 0 && !string.IsNullOrEmpty(value.PayPwd))
            {
                var flag = MemberApplication.VerificationPayPwd(CurrentUser.Id, value.PayPwd);
                if (!flag)
                {
                    return(ErrorResult("预存款支付密码错误"));
                }
            }
            string cartItemIds      = value.cartItemIds;
            long   recieveAddressId = value.recieveAddressId;
            string couponIds        = value.couponIds;
            int    integral         = value.integral;

            decimal capitalAmount = value.CapitalAmount;

            bool   isCashOnDelivery = value.isCashOnDelivery;
            int    invoiceType      = value.invoiceType;
            string invoiceTitle     = value.invoiceTitle;
            string invoiceContext   = value.invoiceContext;
            string invoiceCode      = value.invoiceCode;

            OrderCreateModel model = new OrderCreateModel();
            var orderService       = ServiceProvider.Instance <IOrderService> .Create;
            IEnumerable <long> orderIds;

            model.PlatformType     = PlatformType.Android;
            model.CurrentUser      = CurrentUser;
            model.ReceiveAddressId = recieveAddressId;
            model.Integral         = integral;

            model.Capital = capitalAmount;//预存款

            model.IsCashOnDelivery = isCashOnDelivery;
            model.Invoice          = (InvoiceType)invoiceType;
            model.InvoiceContext   = invoiceContext;
            model.InvoiceTitle     = invoiceTitle;
            model.InvoiceCode      = invoiceCode;
            //end
            CommonModel.OrderShop[] OrderShops = Newtonsoft.Json.JsonConvert.DeserializeObject <OrderShop[]>(value.jsonOrderShops);
            model.OrderShops   = OrderShops;//用户APP选择门店自提时用到,2.5版本未支持门店自提
            model.OrderRemarks = OrderShops.Select(p => p.Remark).ToArray();
            try
            {
                var cartItemIdsArr = cartItemIds.Split(',').Select(item => long.Parse(item)).ToArray();
                //根据购物车项补充sku数据
                var cartItems = CartApplication.GetCartItems(cartItemIdsArr);
                model.SkuIds = cartItems.Select(e => e.SkuId).ToList();
                model.Counts = cartItems.Select(e => e.Quantity).ToList();

                model.CartItemIds  = cartItemIdsArr;
                model.CouponIdsStr = CouponApplication.ConvertUsedCoupon(couponIds);
                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);
                return(new { success = true, OrderIds = orderIds, RealTotalIsZero = orderTotals == 0 });
            }
            catch (HimallException he)
            {
                return(ErrorResult(he.Message));
            }
            catch (Exception ex)
            {
                return(ErrorResult("提交订单异常"));
            }
        }