Beispiel #1
0
        public object GetOrderDetail(long id)
        {
            CheckUserLogin();
            OrderInfo order = ServiceProvider.Instance <IOrderService> .Create.GetOrder(id, CurrentUser.Id);

            var    orderService       = ServiceProvider.Instance <IOrderService> .Create;
            var    bonusService       = ServiceProvider.Instance <IShopBonusService> .Create;
            var    orderRefundService = ServiceProvider.Instance <IRefundService> .Create;
            var    bonusmodel         = bonusService.GetGrantByUserOrder(id, CurrentUser.Id);
            bool   hasBonus           = bonusmodel != null ? true : false;
            string shareHref          = "";
            string shareTitle         = "";
            string shareDetail        = "";

            if (hasBonus)
            {
                shareHref   = "http://" + HttpContext.Current.Request.Url.Host + "/m-weixin/shopbonus/index/" + bonusService.GetGrantIdByOrderId(id);
                shareTitle  = bonusmodel.Himall_ShopBonus.ShareTitle;
                shareDetail = bonusmodel.Himall_ShopBonus.ShareDetail;
            }
            var shopService    = ServiceProvider.Instance <IShopService> .Create;
            var productService = ServiceProvider.Instance <IProductService> .Create;
            var vshop          = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(order.ShopId);

            bool isCanApply = false;

            var customerServices = CustomerServiceApplication.GetMobileCustomerService(order.ShopId);
            var meiqia           = CustomerServiceApplication.GetPreSaleByShopId(order.ShopId).FirstOrDefault(p => p.Tool == CustomerServiceInfo.ServiceTool.MeiQia);

            if (meiqia != null)
            {
                customerServices.Insert(0, meiqia);
            }

            //获取订单商品项数据
            var orderDetail = new
            {
                ShopName   = shopService.GetShop(order.ShopId).ShopName,
                ShopId     = order.ShopId,
                OrderItems = order.OrderItemInfo.Select(item =>
                {
                    var productinfo = productService.GetProduct(item.ProductId);
                    if (order.OrderStatus == OrderInfo.OrderOperateStatus.WaitDelivery)
                    {
                        isCanApply = orderRefundService.CanApplyRefund(id, item.Id);
                    }
                    else
                    {
                        isCanApply = orderRefundService.CanApplyRefund(id, item.Id, false);
                    }

                    ProductTypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetType(productinfo.TypeId);
                    string colorAlias        = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                    string sizeAlias         = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                    string versionAlias      = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
                    return(new
                    {
                        ItemId = item.Id,
                        ProductId = item.ProductId,
                        ProductName = item.ProductName,
                        Count = item.Quantity,
                        Price = item.SalePrice,
                        //ProductImage = "http://" + Url.Request.RequestUri.Host + productService.GetProduct(item.ProductId).GetImage(ProductInfo.ImageSize.Size_100),
                        ProductImage = Core.HimallIO.GetRomoteProductSizeImage(productService.GetProduct(item.ProductId).RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_100),
                        color = item.Color,
                        size = item.Size,
                        version = item.Version,
                        IsCanRefund = isCanApply,
                        ColorAlias = colorAlias,
                        SizeAlias = sizeAlias,
                        VersionAlias = versionAlias,
                        EnabledRefundAmount = item.EnabledRefundAmount,
                    });
                })
            };
            //取拼团订单状态
            var fightGroupOrderInfo = ServiceProvider.Instance <IFightGroupService> .Create.GetFightGroupOrderStatusByOrderId(order.Id);

            var orderModel = new
            {
                Id                  = order.Id,
                OrderType           = order.OrderType,
                OrderTypeName       = order.OrderType.ToDescription(),
                Status              = order.OrderStatus.ToDescription(),
                JoinStatus          = fightGroupOrderInfo == null ? -2 : fightGroupOrderInfo.JoinStatus,
                ShipTo              = order.ShipTo,
                Phone               = order.CellPhone,
                Address             = order.RegionFullName + " " + order.Address,
                HasExpressStatus    = !string.IsNullOrWhiteSpace(order.ShipOrderNumber),
                ExpressCompanyName  = order.ExpressCompanyName,
                Freight             = order.Freight,
                IntegralDiscount    = order.IntegralDiscount,
                RealTotalAmount     = order.OrderTotalAmount,
                RefundTotalAmount   = order.RefundTotalAmount,
                OrderDate           = order.OrderDate.ToString("yyyy-MM-dd HH:mm:ss"),
                ShopName            = order.ShopName,
                VShopId             = vshop == null ? 0 : vshop.Id,
                commentCount        = order.OrderCommentInfo.Count(),
                ShopId              = order.ShopId,
                orderStatus         = (int)order.OrderStatus,
                Invoice             = order.InvoiceType.ToDescription(),
                InvoiceValue        = (int)order.InvoiceType,
                InvoiceContext      = order.InvoiceContext,
                InvoiceTitle        = order.InvoiceTitle,
                PaymentType         = order.PaymentType.ToDescription(),
                PaymentTypeValue    = (int)order.PaymentType,
                FullDiscount        = order.FullDiscount,
                DiscountAmount      = order.DiscountAmount,
                OrderRemarks        = string.IsNullOrEmpty(order.OrderRemarks) ? "" : order.OrderRemarks,
                HasBonus            = hasBonus,
                ShareHref           = shareHref,
                ShareTitle          = shareTitle,
                ShareDetail         = shareDetail,
                IsCanRefund         = (orderDetail.OrderItems.Where(e => e.IsCanRefund == false).Count() == 0) && !orderService.IsRefundTimeOut(order.Id),
                EnabledRefundAmount = order.OrderEnabledRefundAmount,
                HasAppendComment    = HasAppendComment(order),
                SelfTake            = order.DeliveryType == Himall.CommonModel.Enum.DeliveryType.SelfTake ? 1 : 0
            };

            #region 门店配送信息
            Himall.DTO.ShopBranch storeInfo = null;
            if (order.ShopBranchId.HasValue && order.ShopBranchId > 0)
            {
                storeInfo = Application.ShopBranchApplication.GetShopBranchById(order.ShopBranchId.Value);
            }
            #endregion
            return(Json(new { Success = "true", Order = orderModel, OrderItem = orderDetail.OrderItems, StoreInfo = storeInfo, CustomerServices = customerServices }));
        }
        /// <summary>
        /// 获取立即购买提交页面的数据
        /// </summary>
        /// <param name="skuIds">库存ID集合</param>
        /// <param name="counts">库存ID对应的数量</param>
        public object GetSubmitModel(string skuId, int count, long shippingAddressId = 0, string couponIds = "", sbyte productType = 0, long shopBranchId = 0)
        {
            if (productType == 0)
            {
                throw new HimallException("门店订单暂时不允许立即购买");
            }

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


            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 HimallException("该虚拟商品已过期,不支持下单");
                }
                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);
        }
        /// <summary>
        /// 获取购物车提交页面的数据
        /// </summary>
        /// <param name="cartItemIds">购物车物品id集合</param>
        /// <returns></returns>
        public object GetSubmitByCartModel(string cartItemIds = "", long shippingAddressId = 0, string couponIds = "")
        {
            CheckUserLogin();
            var coupons = CouponApplication.ConvertUsedCoupon(couponIds);
            var result  = OrderApplication.GetMobileSubmiteByCart(CurrentUserId, cartItemIds, shippingAddressId, coupons);

            //门店订单
            Himall.DTO.ShopBranch storeInfo = null;
            if (result.shopBranchInfo == null)
            {
                throw new HimallException("获取门店信息失败,不可提交非门店商品");
            }
            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);
        }
Beispiel #4
0
        public object GetOrderDetail(long id)
        {
            CheckUserLogin();
            OrderInfo order = ServiceProvider.Instance <IOrderService> .Create.GetOrder(id, CurrentUser.Id);

            var    orderService       = ServiceProvider.Instance <IOrderService> .Create;
            var    bonusService       = ServiceProvider.Instance <IShopBonusService> .Create;
            var    orderRefundService = ServiceProvider.Instance <IRefundService> .Create;
            var    bonusmodel         = bonusService.GetGrantByUserOrder(id, CurrentUser.Id);
            bool   hasBonus           = bonusmodel != null ? true : false;
            string shareHref          = "";
            string shareTitle         = "";
            string shareDetail        = "";
            string shareImg           = "";

            if (hasBonus)
            {
                shareHref = CurrentUrlHelper.CurrentUrlNoPort() + "/m-weixin/shopbonus/index/" + bonusService.GetGrantIdByOrderId(id);
                var bonus = ShopBonusApplication.GetBonus(bonusmodel.ShopBonusId);
                shareTitle  = bonus.ShareTitle;
                shareDetail = bonus.ShareDetail;
                shareImg    = HimallIO.GetRomoteImagePath(bonus.ShareImg);
            }
            var vshop = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(order.ShopId);

            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(order.ShopId);

            var shop        = ShopApplication.GetShop(order.ShopId);
            var orderItems  = OrderApplication.GetOrderItemsByOrderId(order.Id);
            var products    = ProductManagerApplication.GetProducts(orderItems.Select(p => p.ProductId));
            var refunds     = OrderApplication.GetOrderRefundsByOrder(order.Id);        //获取订单商品项数据
            var orderDetail = new
            {
                ShopId     = shop.Id,
                ShopName   = shop.ShopName,
                OrderItems = orderItems.Select(item =>
                {
                    var product  = products.FirstOrDefault(p => p.Id == item.ProductId);
                    var typeInfo = TypeApplication.GetType(product.TypeId);

                    string colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                    string sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                    string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
                    if (product != null)
                    {
                        colorAlias   = !string.IsNullOrWhiteSpace(product.ColorAlias) ? product.ColorAlias : colorAlias;
                        sizeAlias    = !string.IsNullOrWhiteSpace(product.SizeAlias) ? product.SizeAlias : sizeAlias;
                        versionAlias = !string.IsNullOrWhiteSpace(product.VersionAlias) ? product.VersionAlias : versionAlias;
                    }
                    var itemrefund   = refunds.FirstOrDefault(d => d.OrderItemId == item.Id && d.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund);
                    int?itemrefstate = (itemrefund == null ? null : (int?)itemrefund.SellerAuditStatus);
                    itemrefstate     = (itemrefstate > 4 ? (int?)itemrefund.ManagerConfirmStatus : itemrefstate);
                    var IsCanRefund  = OrderApplication.CanRefund(order, itemrefstate, itemId: item.Id);
                    return(new
                    {
                        ItemId = item.Id,
                        ProductId = item.ProductId,
                        ProductName = item.ProductName,
                        Count = item.Quantity,
                        Price = item.SalePrice,
                        ProductImage = Core.HimallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_100),
                        color = item.Color,
                        size = item.Size,
                        version = item.Version,
                        IsCanRefund = IsCanRefund,
                        ColorAlias = colorAlias,
                        SizeAlias = sizeAlias,
                        VersionAlias = versionAlias,
                        EnabledRefundAmount = item.EnabledRefundAmount,
                        OrderRefundId = (itemrefund == null ? 0 : itemrefund.Id),
                        RefundStats = itemrefstate
                    });
                })
            };
            //取拼团订单状态
            var fightGroupOrderInfo = ServiceProvider.Instance <IFightGroupService> .Create.GetFightGroupOrderStatusByOrderId(order.Id);

            var _ordrefobj = orderRefundService.GetOrderRefundByOrderId(order.Id) ?? new OrderRefundInfo {
                Id = 0
            };

            if (order.OrderStatus != OrderInfo.OrderOperateStatus.WaitDelivery && order.OrderStatus != OrderInfo.OrderOperateStatus.WaitSelfPickUp)
            {
                _ordrefobj = new OrderRefundInfo {
                    Id = 0
                };
            }
            int?ordrefstate = (_ordrefobj == null ? null : (int?)_ordrefobj.SellerAuditStatus);

            ordrefstate = (ordrefstate > 4 ? (int?)_ordrefobj.ManagerConfirmStatus : ordrefstate);

            var hasAppendComment = ServiceProvider.Instance <ICommentService> .Create.HasAppendComment(orderItems.FirstOrDefault().Id);

            var orderModel = new
            {
                Id                 = order.Id,
                OrderType          = order.OrderType,
                OrderTypeName      = order.OrderType.ToDescription(),
                Status             = order.OrderStatus.ToDescription(),
                JoinStatus         = fightGroupOrderInfo == null ? -2 : fightGroupOrderInfo.JoinStatus,
                ShipTo             = order.ShipTo,
                Phone              = order.CellPhone,
                Address            = order.RegionFullName + " " + order.Address,
                HasExpressStatus   = !string.IsNullOrWhiteSpace(order.ShipOrderNumber),
                ExpressCompanyName = order.ExpressCompanyName,
                Freight            = order.Freight,
                Tax                = order.Tax,
                IntegralDiscount   = order.IntegralDiscount,
                RealTotalAmount    = order.OrderTotalAmount,
                CapitalAmount      = order.CapitalAmount,
                RefundTotalAmount  = order.RefundTotalAmount,
                ProductTotalAmount = order.ProductTotalAmount,
                OrderPayAmount     = order.OrderPayAmount,//订单需要第三方支付的金额
                PaymentTypeName    = PaymentApplication.GetPaymentTypeDescById(order.PaymentTypeGateway) ?? order.PaymentTypeName,
                PaymentTypeDesc    = order.PaymentTypeDesc,
                OrderDate          = order.OrderDate.ToString("yyyy-MM-dd HH:mm:ss"),
                ShopName           = order.ShopName,
                VShopId            = vshop == null ? 0 : vshop.Id,
                commentCount       = OrderApplication.GetOrderCommentCount(order.Id),
                ShopId             = order.ShopId,
                orderStatus        = (int)order.OrderStatus,
                //Invoice = order.InvoiceType.ToDescription(),
                //InvoiceValue = (int)order.InvoiceType,
                //InvoiceContext = order.InvoiceContext,
                //InvoiceTitle = order.InvoiceTitle,
                //InvoiceCode = order.InvoiceCode,
                PaymentType         = order.PaymentType.ToDescription(),
                PaymentTypeValue    = (int)order.PaymentType,
                FullDiscount        = order.FullDiscount,
                DiscountAmount      = order.DiscountAmount,
                OrderRemarks        = string.IsNullOrEmpty(order.OrderRemarks) ? "" : order.OrderRemarks,
                HasBonus            = hasBonus,
                ShareHref           = shareHref,
                ShareTitle          = shareTitle,
                ShareDetail         = shareDetail,
                ShareImg            = shareImg,
                IsCanRefund         = !(orderDetail.OrderItems.Any(e => e.IsCanRefund == true)) && OrderApplication.CanRefund(order, ordrefstate, null),
                RefundStats         = ordrefstate,
                OrderRefundId       = _ordrefobj.Id > 0 ? _ordrefobj.Id : 0,
                EnabledRefundAmount = order.OrderEnabledRefundAmount,
                HasAppendComment    = hasAppendComment,
                SelfTake            = order.DeliveryType == Himall.CommonModel.DeliveryType.SelfTake ? 1 : 0,
                OrderInvoice        = OrderApplication.GetOrderInvoiceInfo(order.Id)
            };

            #region 门店配送信息
            Himall.DTO.ShopBranch storeInfo = null;
            if (order.ShopBranchId > 0)
            {
                storeInfo = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
            }
            #endregion
            #region 虚拟订单信息
            VirtualProductInfo virtualProductInfo = null;
            int            validityType = 0; string startDate = string.Empty, endDate = string.Empty;
            List <dynamic> orderVerificationCodes = null;
            List <dynamic> virtualOrderItemInfos  = null;
            bool           isCanRefundVirtual     = false;
            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                var orderItemInfo = orderItems.FirstOrDefault();
                if (orderItemInfo != null)
                {
                    virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId);
                    if (virtualProductInfo != null)
                    {
                        validityType = virtualProductInfo.ValidityType ? 1 : 0;
                        if (validityType == 1)
                        {
                            startDate = virtualProductInfo.StartDate.Value.ToString("yyyy-MM-dd");
                            endDate   = virtualProductInfo.EndDate.Value.ToString("yyyy-MM-dd");
                        }
                    }
                    var codes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>()
                    {
                        order.Id
                    });
                    orderVerificationCodes = codes.Select(p =>
                    {
                        return(new
                        {
                            VerificationCode = Regex.Replace(p.VerificationCode, @"(\d{4})", "$1 "),
                            Status = p.Status,
                            StatusText = p.Status.ToDescription(),
                            QRCode = GetQRCode(p.VerificationCode)
                        });
                    }).ToList <dynamic>();

                    var virtualItems = OrderApplication.GetVirtualOrderItemInfosByOrderId(order.Id);
                    virtualOrderItemInfos = virtualItems.Select(p =>
                    {
                        return(new
                        {
                            VirtualProductItemName = p.VirtualProductItemName,
                            Content = ReplaceImage(p.Content, p.VirtualProductItemType),
                            VirtualProductItemType = p.VirtualProductItemType
                        });
                    }).ToList <dynamic>();
                }
            }
            if (order.OrderStatus == Himall.Entities.OrderInfo.OrderOperateStatus.WaitVerification)
            {
                if (virtualProductInfo != null)
                {
                    if (virtualProductInfo.SupportRefundType == 2)
                    {
                        isCanRefundVirtual = true;
                    }
                    else if (virtualProductInfo.SupportRefundType == 1)
                    {
                        if (virtualProductInfo.EndDate.Value > DateTime.Now)
                        {
                            isCanRefundVirtual = true;
                        }
                    }
                    else if (virtualProductInfo.SupportRefundType == 3)
                    {
                        isCanRefundVirtual = false;
                    }

                    if (isCanRefundVirtual)
                    {
                        long num = orderVerificationCodes.Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification).Count();
                        if (num > 0)
                        {
                            isCanRefundVirtual = true;
                        }
                        else
                        {
                            isCanRefundVirtual = false;
                        }
                    }
                }
            }
            #endregion
            #region 虚拟订单核销地址信息
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;
            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                if (order.ShopBranchId > 0 && storeInfo != null)
                {
                    shipperAddress  = RegionApplication.GetFullName(storeInfo.AddressId) + " " + storeInfo.AddressDetail;
                    shipperTelPhone = storeInfo.ContactPhone;
                }
                else
                {
                    var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(order.ShopId);
                    if (verificationShipper != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                        shipperTelPhone = verificationShipper.TelPhone;
                    }
                }
            }
            #endregion
            return(new
            {
                success = true,
                Order = orderModel,
                OrderItem = orderDetail.OrderItems,
                StoreInfo = storeInfo,
                CustomerServices = customerServices,
                ValidityType = validityType,
                StartDate = startDate,
                EndDate = endDate,
                OrderVerificationCodes = orderVerificationCodes,
                VirtualOrderItemInfos = virtualOrderItemInfos,
                IsCanRefundVirtual = isCanRefundVirtual,
                ShipperAddress = shipperAddress,
                ShipperTelPhone = shipperTelPhone
            });
        }
Beispiel #5
0
        /// <summary>
        /// 获取立即购买提交页面的数据
        /// </summary>
        /// <param name="skuIds">库存ID集合</param>
        /// <param name="counts">库存ID对应的数量</param>
        JsonResult <Result <dynamic> > 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 HimallException("门店订单暂时不允许立即购买");
                }
                //门店订单
                Himall.DTO.ShopBranch storeInfo = Application.ShopBranchApplication.GetShopBranchById(shopBranchId);
                if (storeInfo == null)
                {
                    throw new HimallException("获取门店信息失败,不可提交非门店商品");
                }
                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 HimallException("该虚拟商品已过期,不支持下单");
                }
                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(JsonResult <dynamic>(d));
        }
Beispiel #6
0
        /// <summary>
        /// 获取购物车提交页面的数据
        /// </summary>
        /// <param name="cartItemIds">购物车物品id集合</param>
        /// <returns></returns>
        JsonResult <Result <dynamic> > GetSubmitByCartModel(string cartItemIds = "", long shippingAddressId = 0, IEnumerable <string[]> CouponIdsStr = null, bool isStore = false)
        {
            CheckUserLogin();
            var result = OrderApplication.GetMobileSubmiteByCart(CurrentUserId, cartItemIds, shippingAddressId, CouponIdsStr);

            Himall.DTO.ShopBranch storeInfo = null;
            if (isStore)
            {
                if (result.shopBranchInfo == null)
                {
                    throw new HimallException("获取门店信息失败,不可提交非门店商品");
                }
                else
                {
                    storeInfo = Application.ShopBranchApplication.GetShopBranchById(result.shopBranchInfo.Id);
                }
            }
            //解决循环引用的序列化的问题
            dynamic address = new System.Dynamic.ExpandoObject();

            if (result.Address != null)
            {
                var 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
                };
                address = add;
            }
            else
            {
                address = null;
            }

            bool canIntegralPerMoney = true, canCapital = true;

            CanDeductible(out canIntegralPerMoney, out canCapital);
            var data = new
            {
                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,
                IsOpenStore               = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore,
                integralPerMoney          = result.integralPerMoney,
                userIntegralMaxDeductible = result.userIntegralMaxDeductible,
                integralPerMoneyRate      = result.integralPerMoneyRate,
                userIntegralMaxRate       = SiteSettingApplication.SiteSettings.IntegralDeductibleRate,
                userIntegrals             = result.userIntegrals,
                TotalMemberIntegral       = result.memberIntegralInfo.AvailableIntegrals,
                canIntegralPerMoney       = canIntegralPerMoney,
                canCapital                = canCapital,
                capitalAmount             = result.capitalAmount,
                shopBranchInfo            = storeInfo,
                ProvideInvoice            = storeInfo == null ? false : ShopApplication.HasProvideInvoice(result.products.Select(s => s.shopId).Distinct().ToList())
            };

            return(JsonResult <dynamic>(data));
        }