示例#1
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));
        }
示例#2
0
        /// <summary>
        /// 获取立即购买提交页面的数据
        /// </summary>
        /// <param name="skuIds">库存ID集合</param>
        /// <param name="counts">库存ID对应的数量</param>
        object GetSubmitModelById(string skuId, int count, long shippingAddressId = 0, IEnumerable <string[]> CouponIdsStr = null, bool isStore = false, sbyte productType = 0, long shopBranchId = 0)
        {
            CheckUserLogin();
            dynamic d          = new System.Dynamic.ExpandoObject();
            var     siteconfig = SiteSettingApplication.SiteSettings;

            var     result = OrderApplication.GetMobileSubmit(CurrentUserId, skuId.ToString(), count.ToString(), shippingAddressId, CouponIdsStr, shopBranchId);
            dynamic add    = new System.Dynamic.ExpandoObject();

            if (result.Address != null)
            {
                add = new
                {
                    ShippingId     = result.Address.Id,
                    ShipTo         = result.Address.ShipTo,
                    CellPhone      = result.Address.Phone,
                    FullRegionName = result.Address.RegionFullName,
                    FullAddress    = result.Address.RegionFullName + " " + result.Address.Address + " " + result.Address.AddressDetail,
                    Address        = result.Address.Address,
                    RegionId       = result.Address.RegionId
                };
            }
            else
            {
                add = null;
            }
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;

            if (isStore)
            {
                if (productType == 0)
                {
                    throw new MallException("门店订单暂时不允许立即购买");
                }
                //门店订单
                Mall.DTO.ShopBranch storeInfo = Application.ShopBranchApplication.GetShopBranchById(shopBranchId);
                if (storeInfo == null)
                {
                    throw new MallException("获取门店信息失败,不可提交非门店商品");
                }
                d.shopBranchId   = shopBranchId;
                d.shopBranchInfo = storeInfo;
                if (storeInfo != null)
                {
                    shipperAddress  = RegionApplication.GetFullName(storeInfo.AddressId) + storeInfo.AddressDetail;
                    shipperTelPhone = storeInfo.ContactPhone;
                }
            }
            d.ProductType = productType;
            if (result.ProductType == 1)
            {
                d.VirtualProductItemInfos = ProductManagerApplication.GetVirtualProductItemInfoByProductId(result.ProductId);
                var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(result.ProductId);
                if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value)
                {
                    throw new MallException("该虚拟商品已过期,不支持下单");
                }
                if (result.products != null && result.products.Count > 0 && !isStore)
                {
                    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;
            bool canIntegralPerMoney = true, canCapital = true;

            CanDeductible(out canIntegralPerMoney, out 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.TotalAmount               = result.totalAmount;
            d.Freight                   = result.Freight;
            d.orderAmount               = result.orderAmount;
            d.IsCashOnDelivery          = result.IsCashOnDelivery;
            d.IsOpenStore               = siteconfig.IsOpenStore;
            d.Address                   = add;
            d.integralPerMoney          = result.integralPerMoney;
            d.userIntegralMaxDeductible = result.userIntegralMaxDeductible;
            d.integralPerMoneyRate      = result.integralPerMoneyRate;
            d.userIntegralMaxRate       = siteconfig.IntegralDeductibleRate;
            d.userIntegrals             = result.userIntegrals;
            d.TotalMemberIntegral       = result.memberIntegralInfo.AvailableIntegrals;
            d.canIntegralPerMoney       = canIntegralPerMoney;
            d.canCapital                = canCapital;
            d.capitalAmount             = result.capitalAmount;

            return(Json(d));
        }