public object PostShopBranchInfo(DTO.ShopBranch model)
        {
            CheckUserLogin();

            ShopBranchApplication.UpdateShopBranch(model);
            return(new { success = true, msg = "更新成功!" });
        }
        /// <summary>
        /// 当前门店信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private DTO.ShopBranch GetShopBranchById(long id)
        {
            DTO.ShopBranch result   = null;
            string         cachekey = SB_CACHE_KEY_PREFIX + id;

            result = Cache.Get <DTO.ShopBranch>(cachekey);
            if (result == null)
            {
                result = ShopBranchApplication.GetShopBranchById(id);
                if (result != null && result.Id > 0)
                {
                    Cache.Insert <DTO.ShopBranch>(cachekey, result);
                }
            }
            return(result);
        }
Esempio n. 3
0
        private List <CartProductModel> PackageCartProducts(Mall.Entities.ShoppingCartInfo cart, decimal prodPrice, decimal discount, IProductService productService, IShopService shopService, IShopBranchService shopBranchService, IVShopService vshopService, ITypeService typeservice, bool isBranch = false)
        {
            List <CartProductModel> products = new List <CartProductModel>();
            var limitProducts = LimitTimeApplication.GetPriceByProducrIds(cart.Items.Select(e => e.ProductId).ToList());//限时购价格
            var groupCart     = cart.Items.Where(item => item.ShopBranchId == 0).Select(c =>
            {
                var cItem   = new Mall.Entities.ShoppingCartItem();
                var skuInfo = productService.GetSku(c.SkuId);
                if (skuInfo != null)
                {
                    cItem = c;
                }
                return(cItem);
            }).GroupBy(i => i.ProductId).ToList();

            foreach (var item in cart.Items)
            {
                var                        product       = ProductManagerApplication.GetProduct(item.ProductId);
                var                        shop          = shopService.GetShop(product.ShopId);
                DTO.ShopBranch             shopbranch    = null;
                Entities.ShopBranchSkuInfo shopbranchsku = null;
                if (item.ShopBranchId > 0)
                {
                    shopbranch    = ShopBranchApplication.GetShopBranchById(item.ShopBranchId);
                    shopbranchsku = shopBranchService.GetSkusByIds(item.ShopBranchId, new List <string> {
                        item.SkuId
                    }).FirstOrDefault();
                }

                if (null != shop)
                {
                    var vshop = vshopService.GetVShopByShopId(shop.Id);
                    var sku   = ProductManagerApplication.GetSKU(item.SkuId);
                    if (sku == null)
                    {
                        continue;
                    }
                    //处理限时购、会员折扣价格
                    var prod = limitProducts.FirstOrDefault(e => e.ProductId == item.ProductId);
                    prodPrice = sku.SalePrice;
                    if (prod != null && !isBranch)
                    {
                        prodPrice = prod.MinPrice;
                    }
                    else
                    {
                        if (shop.IsSelf)
                        {//官方自营店才计算会员折扣
                            prodPrice = sku.SalePrice * discount;
                        }
                    }
                    #region 阶梯价--张宇枫
                    //阶梯价
                    if (product.IsOpenLadder)
                    {
                        var quantity = groupCart.Where(i => i.Key == item.ProductId).ToList().Sum(cartitem => cartitem.Sum(i => i.Quantity));
                        prodPrice = ProductManagerApplication.GetProductLadderPrice(item.ProductId, quantity);
                        if (shop.IsSelf)
                        {
                            prodPrice = prodPrice * discount;
                        }
                    }
                    #endregion
                    Entities.TypeInfo typeInfo     = typeservice.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;
                    }
                    if (sku != null)
                    {
                        #region 正在参加限时抢购商品在购物车失效 TDO:ZYF
                        var isLimit = false;
                        //门店商品,在参加限时购,也可以正常购买
                        var limit = LimitTimeApplication.GetLimitTimeMarketItemByProductId(item.ProductId);
                        if (limit != null && !isBranch)
                        {
                            isLimit = limit.Status == Entities.FlashSaleInfo.FlashSaleStatus.Ongoing;
                        }
                        #endregion
                        var _tmp = new CartProductModel
                        {
                            CartItemId     = item.Id.ToString(),
                            SkuId          = item.SkuId,
                            Id             = product.Id.ToString(),
                            ImgUrl         = Core.MallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Mall.CommonModel.ImageSize.Size_150),
                            Name           = product.ProductName,
                            Price          = prodPrice.ToString("F2"),
                            Count          = item.Quantity.ToString(),
                            ShopId         = shop.Id.ToString(),
                            Size           = sku.Size,
                            Color          = sku.Color,
                            Version        = sku.Version,
                            VShopId        = vshop == null ? "0" : vshop.Id.ToString(),
                            ShopName       = shop.ShopName,
                            ShopLogo       = vshop == null ? "" : Core.MallIO.GetRomoteImagePath(vshop.StrLogo),
                            Url            = Core.MallIO.GetRomoteImagePath("/m-IOS/product/detail/") + item.ProductId,
                            ProductStatus  = isLimit ? 0 : (sku.Stock <= 0 ? ProductInfo.ProductSaleStatus.InStock.GetHashCode() : product.SaleStatus.GetHashCode()),
                            Status         = isLimit ? 1 : ProductManagerApplication.GetProductShowStatus(product, sku, shopbranch == null ? 1 : item.Quantity, shopbranch, shopbranchsku),// 0:正常;1:已失效;2:库存不足;3:已下架;
                            ColorAlias     = colorAlias,
                            SizeAlias      = sizeAlias,
                            VersionAlias   = versionAlias,
                            AddTime        = item.AddTime,
                            ShopBranchId   = item.ShopBranchId,
                            ShopBranchName = null == shopbranch ? "" : shopbranch.ShopBranchName,
                            ShopBranchLogo = null == shopbranch ? "" : Core.MallIO.GetRomoteImagePath(shopbranch.ShopImages)
                        };
                        products.Add(_tmp);
                    }
                }
            }
            return(products);
        }
        public object GetOrderDetail(long id)
        {
            CheckUserLogin();
            long shopid = CurrentUser.ShopId;

            var ordser = ServiceProvider.Instance <IOrderService> .Create;

            OrderInfo order = ordser.GetOrder(id);

            if (order == null || order.ShopId != shopid)
            {
                throw new HimallApiException("错误的预约单编号");
            }
            var bonusService       = ServiceProvider.Instance <IShopBonusService> .Create;
            var orderRefundService = ServiceProvider.Instance <IRefundService> .Create;
            var shopService        = ServiceProvider.Instance <IShopService> .Create;
            var productService     = ServiceProvider.Instance <IProductService> .Create;
            var vshop = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(order.ShopId);

            bool isCanApply = false;

            DTO.ShopBranch ShopBranchInfo = null;
            if (order.ShopBranchId.HasValue && order.ShopBranchId.Value > 0)
            {
                ShopBranchInfo = ShopBranchApplication.GetShopBranchById(order.ShopBranchId.Value);
            }
            //获取预约单诊疗项目项数据
            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
                    });
                })
            };
            var orderModel = new
            {
                Id                 = order.Id,
                OrderType          = order.OrderType,
                OrderTypeName      = order.OrderType.ToDescription(),
                Status             = order.OrderStatus.ToDescription(),
                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 - order.RefundTotalAmount,
                OrderDate          = order.OrderDate.ToString("yyyy-MM-dd HH:mm:ss"),
                ShopName           = order.ShopName,
                ShopBranchName     = (ShopBranchInfo != null ? ShopBranchInfo.ShopBranchName : ""),
                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       = order.OrderRemarks,
                DeliveryType       = order.DeliveryType
            };

            return(Json(new { Success = "true", Order = orderModel, OrderItem = orderDetail.OrderItems }));
        }
Esempio n. 5
0
        /// <summary>
        /// 获取商品显示状态
        /// </summary>
        /// <param name="pro"></param>
        /// <param name="sku"></param>
        /// <param name="quantity"></param>
        /// <param name="sb"></param>
        /// <param name="sbsku"></param>
        /// <returns>状态值 0:正常;1:已失效;2:库存不足;3:已下架;</returns>
        public static int GetProductShowStatus(ProductInfo pro, DTO.SKU sku = null, int quantity = 1, DTO.ShopBranch sb = null, ShopBranchSkuInfo sbsku = null)
        {
            int result = 0;

            //己删除商品快速处理
            if (pro.IsDeleted)
            {
                return(1);
            }
            if (sb != null && pro.IsOpenLadder)
            {
                return(1);
            }
            if (sb != null && sbsku != null)
            {
                if (sbsku.Status == ShopBranchSkuStatus.Normal)
                {
                    if (sbsku.Stock < quantity)
                    {
                        result = 2;
                    }
                }
                else
                {
                    result = 3;
                }
                return(result);
            }
            if (pro.AuditStatus == ProductInfo.ProductAuditStatus.Audited && pro.SaleStatus == ProductInfo.ProductSaleStatus.OnSale)
            {
                result = 0;
                if (sku == null)
                {
                    var skus = GetSKUs(pro.Id);
                    if (skus.Sum(d => d.Stock) < quantity)
                    {
                        result = 2;
                    }
                }
                else
                {
                    if (sku.Stock < quantity)
                    {
                        result = 2;
                    }
                }
            }
            else
            {
                result = 3;
            }
            return(result);
        }
Esempio n. 6
0
        public object GetOrderDetail(long id)
        {
            CheckUserLogin();
            long shopid = CurrentUser.ShopId;

            var ordser = ServiceProvider.Instance <IOrderService> .Create;

            Entities.OrderInfo order = ordser.GetOrder(id);
            if (order == null || order.ShopId != shopid)
            {
                throw new HimallApiException("错误的订单编号");
            }
            var bonusService       = ServiceProvider.Instance <IShopBonusService> .Create;
            var orderRefundService = ServiceProvider.Instance <IRefundService> .Create;
            var shopService        = ServiceProvider.Instance <IShopService> .Create;
            var productService     = ServiceProvider.Instance <IProductService> .Create;
            var vshop = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(order.ShopId);

            bool isCanApply = false;

            DTO.ShopBranch ShopBranchInfo = null;
            if (order.ShopBranchId > 0)
            {
                ShopBranchInfo = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
            }

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

                    Entities.TypeInfo 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;
                    if (productinfo != null)
                    {
                        colorAlias   = !string.IsNullOrWhiteSpace(productinfo.ColorAlias) ? productinfo.ColorAlias : colorAlias;
                        sizeAlias    = !string.IsNullOrWhiteSpace(productinfo.SizeAlias) ? productinfo.SizeAlias : sizeAlias;
                        versionAlias = !string.IsNullOrWhiteSpace(productinfo.VersionAlias) ? productinfo.VersionAlias : 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
                    });
                })
            };
            VirtualProductInfo virtualProductInfo = null;
            List <dynamic>     codes        = null;
            List <dynamic>     virtualItems = null;

            int validityType = 0; string startDate = string.Empty, endDate = string.Empty;

            if (order.OrderType == OrderInfo.OrderTypes.Virtual && orderDetail.OrderItems != null)
            {
                virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderDetail.OrderItems.FirstOrDefault().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 verificationCodes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>()
                {
                    order.Id
                });
                if (verificationCodes != null)
                {
                    verificationCodes.ForEach(a =>
                    {
                        if (a.Status == OrderInfo.VerificationCodeStatus.WaitVerification || a.Status == OrderInfo.VerificationCodeStatus.Refund)
                        {
                            a.VerificationCode = System.Text.RegularExpressions.Regex.Replace(a.VerificationCode, "(\\d{4})\\d{4}(\\d{4})", "$1****$2");
                        }
                        a.VerificationCode = System.Text.RegularExpressions.Regex.Replace(a.VerificationCode, @"(\d{4})", "$1 ");
                    });
                }
                codes = verificationCodes.Select(p =>
                {
                    return(new
                    {
                        VerificationCode = p.VerificationCode,
                        Status = p.Status,
                        StatusText = p.Status.ToDescription()
                    });
                }).ToList <dynamic>();

                var virtualOrderItems = OrderApplication.GetVirtualOrderItemInfosByOrderId(order.Id);
                virtualItems = virtualOrderItems.Select(p =>
                {
                    return(new
                    {
                        VirtualProductItemName = p.VirtualProductItemName,
                        VirtualProductItemType = p.VirtualProductItemType,
                        Content = ReplaceImage(p.Content, p.VirtualProductItemType)
                    });
                }).ToList <dynamic>();
            }
            var orderModel = new
            {
                Id                 = order.Id,
                OrderType          = order.OrderType,
                OrderTypeName      = order.OrderType.ToDescription(),
                Status             = order.OrderStatus.ToDescription(),
                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 - order.RefundTotalAmount,
                CapitalAmount      = order.CapitalAmount,
                RefundTotalAmount  = order.RefundTotalAmount,
                ProductTotalAmount = order.ProductTotalAmount,
                OrderDate          = order.OrderDate.ToString("yyyy-MM-dd HH:mm:ss"),
                ShopName           = order.ShopName,
                ShopBranchName     = (ShopBranchInfo != null ? ShopBranchInfo.ShopBranchName : ""),
                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,
                PaymentType      = order.PaymentType.ToDescription(),
                PaymentTypeDesc  = order.PaymentTypeDesc,
                OrderPayAmount   = order.OrderPayAmount,
                PaymentTypeName  = PaymentApplication.GetPaymentTypeDescById(order.PaymentTypeGateway) ?? order.PaymentTypeName,
                PaymentTypeValue = (int)order.PaymentType,
                FullDiscount     = order.FullDiscount,
                DiscountAmount   = order.DiscountAmount,
                OrderRemarks     = order.OrderRemarks,
                DeliveryType     = order.DeliveryType,
                //InvoiceCode = order.InvoiceCode,
                OrderInvoice = OrderApplication.GetOrderInvoiceInfo(order.Id)
            };

            return(new { success = true, Order = orderModel, OrderItem = orderDetail.OrderItems, VerificationCodes = codes, VirtualOrderItems = virtualItems, StartDate = startDate, EndDate = endDate, ValidityType = validityType });
        }