public JsonResult CancelItem(long id)
        {
            Result result = new Result();

            try
            {
                _iLimitTimeBuyService.Cancel(id);

                var info = _iLimitTimeBuyService.GetFlashSaleInfo(id);
                ProductManagerApplication.SaveCaculateMinPrice(info.ProductId, info.ShopId);
                result.success = true;
                result.msg     = "取消成功!";
            }
            catch (HimallException ex)
            {
                result.msg = ex.Message;
            }
            catch (Exception ex)
            {
                Log.Error("取消出错", ex);
                result.msg = "取消出错!";
            }
            return(Json(result));
        }
        public JsonResult AuditItem(long id)
        {
            Result result = new Result();

            try
            {
                _iLimitTimeBuyService.Pass(id);
                Cache.Remove(CacheKeyCollection.CACHE_LIMITPRODUCTS);
                var info = _iLimitTimeBuyService.GetFlashSaleInfo(id);
                ProductManagerApplication.SaveCaculateMinPrice(info.ProductId, info.ShopId);
                result.success = true;
                result.msg     = "审核成功!";
            }
            catch (HimallException ex)
            {
                result.msg = ex.Message;
            }
            catch (Exception ex)
            {
                Log.Error("审核出错", ex);
                result.msg = "审核出错!";
            }
            return(Json(result));
        }
        public FlashSaleModel Get(long id)
        {
            var model = DbFactory.Default.Get <FlashSaleInfo>().Where(p => p.Id == id).FirstOrDefault();

            if (model == null)
            {
                throw new MallException("活动不存在!");
            }
            var            product = ProductManagerApplication.GetProduct(model.ProductId);
            FlashSaleModel result  = new FlashSaleModel();

            result.Id                    = model.Id;
            result.Title                 = model.Title;
            result.ShopId                = model.ShopId;
            result.ProductId             = model.ProductId;
            result.Status                = model.Status;
            result.ProductName           = product.ProductName;
            result.ProductImg            = product.RelativePath;
            result.MarketPrice           = product.MarketPrice;
            result.StatusStr             = model.Status.ToDescription();
            result.BeginDate             = model.BeginDate.ToString("yyyy-MM-dd HH:mm");
            result.EndDate               = model.EndDate.ToString("yyyy-MM-dd HH:mm");
            result.LimitCountOfThePeople = model.LimitCountOfThePeople;
            result.SaleCount             = model.SaleCount;
            result.CategoryName          = model.CategoryName;
            result.MinPrice              = result.SkuMinPrice = result.SkuMaxPrice = model.MinPrice;
            result.Details               = new List <FlashSaleDetailModel>();

            var details = DbFactory.Default.Get <FlashSaleDetailInfo>().Where(p => p.FlashSaleId == result.Id).ToList();
            var skus    = DbFactory.Default.Get <SKUInfo>().Where(p => p.ProductId == model.ProductId).ToList();

            #region 阶梯商品价格--ZYF
            var price = GetMinLadderPrice(model.ProductId);
            #endregion
            if (details != null && details.Count() > 0)
            {
                result.SkuMinPrice = details.Min(t => t.Price);
                result.SkuMaxPrice = details.Max(t => t.Price);
            }

            foreach (var sku in skus)
            {
                var detail             = details.FirstOrDefault(p => p.SkuId == sku.Id);
                FlashSaleDetailModel d = new FlashSaleDetailModel();
                d.Id         = detail == null ? 0 : detail.Id;
                d.SkuId      = sku.Id;
                d.Price      = detail == null ? sku.SalePrice : (decimal)detail.Price;
                d.Color      = sku.Color;
                d.Size       = sku.Size;
                d.Version    = sku.Version;
                d.Stock      = (int)sku.Stock;
                d.TotalCount = detail == null ? 0 : Math.Min((int)sku.Stock, detail.TotalCount);
                d.CostPrice  = sku.CostPrice;
                d.SalePrice  = price > 0 ? price : sku.SalePrice;
                d.minMath    = 0;
                result.Details.Add(d);
            }
            result.Quantity = result.Details.Sum(a => a.TotalCount);

            //if( details != null )
            //{
            //    foreach( var detail in details )
            //    {
            //        var sku = context.SKUInfo.FirstOrDefault( p => p.Id == detail.SkuId );
            //        if( sku == null )
            //        {
            //            //如果sku为空,证明限时购的sku记录与商品的不一致
            //            //证明商品在限时购已存在的情况下修改了sku相关信息
            //            //暂时还没做处理
            //            break;
            //        }
            //        FlashSaleDetailModel d = new FlashSaleDetailModel();
            //        d.Id = detail.Id;
            //        d.SkuId = detail.SkuId;
            //        d.Price = ( decimal )detail.Price;
            //        d.Color = sku.Color;
            //        d.Size = sku.Size;
            //        d.Version = sku.Version;
            //        d.Stock = ( int )sku.Stock;
            //        d.CostPrice = sku.CostPrice;
            //        d.SalePrice = sku.SalePrice;
            //        result.Details.Add( d );
            //    }
            //}

            return(result);
        }
        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;
        }
        public object GetShopBranchHome()
        {
            try
            {
                CheckUserLogin();

                var now = DateTime.Now;

                var orderQuery = new OrderCountStatisticsQuery()
                {
                    ShopBranchId = CurrentShopBranch.Id,
                    Fields       = new List <OrderCountStatisticsFields> {
                        OrderCountStatisticsFields.ActualPayAmount
                    }
                };
                //三月内
                orderQuery.OrderDateBegin = new DateTime(now.Year, now.Month, 1).AddMonths(-2);
                var threeMonthAmount = StatisticApplication.GetOrderCount(orderQuery).TotalActualPayAmount;
                //本周
                orderQuery.OrderDateBegin = now.Date.AddDays(-(int)now.DayOfWeek);
                var weekAmount = StatisticApplication.GetOrderCount(orderQuery).TotalActualPayAmount;
                //今天
                orderQuery.OrderDateBegin = now.Date;
                var todayAmount = StatisticApplication.GetOrderCount(orderQuery).TotalActualPayAmount;


                //待自提订单数
                orderQuery = new OrderCountStatisticsQuery()
                {
                    ShopBranchId       = CurrentShopBranch.Id,
                    OrderOperateStatus = Entities.OrderInfo.OrderOperateStatus.WaitSelfPickUp,
                    Fields             = new List <OrderCountStatisticsFields> {
                        OrderCountStatisticsFields.OrderCount
                    }
                };
                var pickUpOrderCount = StatisticApplication.GetOrderCount(orderQuery).OrderCount;

                //近三天发布商品数
                var productCount = ProductManagerApplication.GetProductCount(new ProductQuery
                {
                    ShopBranchId = CurrentShopBranch.Id,
                    AuditStatus  = new[] { Entities.ProductInfo.ProductAuditStatus.Audited },
                    StartDate    = now.Date.AddDays(-2)
                });


                var vshop = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(CurrentShopBranch.ShopId);

                var logo = "/Images/branchapp.jpg";
                if (vshop != null && vshop.State == Entities.VShopInfo.VShopStates.Normal && !string.IsNullOrEmpty(vshop.WXLogo))
                {
                    logo = vshop.WXLogo;
                }
                var shopBranch       = ShopBranchApplication.GetShopBranchById(CurrentShopBranch.Id);
                var isShelvesProduct = false;
                if (shopBranch != null && shopBranch.Status == ShopBranchStatus.Normal)
                {
                    isShelvesProduct = shopBranch.IsShelvesProduct;
                }
                return(new
                {
                    success = true,
                    data = new
                    {
                        shopName = CurrentShopBranch.ShopBranchName,
                        todayAmount = todayAmount,
                        weekAmount = weekAmount,
                        threeMonthAmounht = threeMonthAmount,
                        createProductCount = productCount,
                        pickUpOrderCount = pickUpOrderCount,
                        logo = logo,
                        shopBranchId = CurrentShopBranch.Id,
                        IsShelvesProduct = isShelvesProduct
                    }
                });
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
                return(new { success = false, data = new { } });
            }
        }
Beispiel #6
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());
        }
Beispiel #7
0
        public void AddToCart(string skuId, int count, long memberId, long shopBranchId)
        {
            CheckSkuIdIsValid(skuId, shopBranchId);
            //判断库存
            var sku = ProductManagerApplication.GetSKU(skuId);

            if (sku == null)
            {
                throw new HimallException("错误的SKU");
            }
            if (count > sku.Stock)
            {
                throw new HimallException("库存不足");
            }
            var shopBranch = ShopBranchApplication.GetShopBranchById(shopBranchId);

            if (shopBranch == null)
            {
                throw new HimallException("错误的门店id");
            }
            var shopBranchSkuList = ShopBranchApplication.GetSkusByIds(shopBranchId, new List <string> {
                skuId
            });

            if (shopBranchSkuList == null || shopBranchSkuList.Count == 0)
            {
                throw new HimallException("门店没有该商品");
            }
            if (shopBranchSkuList[0].Status == ShopBranchSkuStatus.InStock)
            {
                throw new HimallException("此商品已下架");
            }

            if (memberId > 0)
            {
                CartApplication.AddToShopBranchCart(skuId, count, memberId, shopBranchId);
            }
            else
            {
                string cartInfo = WebHelper.GetCookie(CookieKeysCollection.HIMALL_CART_BRANCH);
                if (!string.IsNullOrWhiteSpace(cartInfo))
                {
                    string[] cartItems   = cartInfo.Split(',');
                    string   newCartInfo = string.Empty;
                    bool     exist       = false;
                    foreach (string cartItem in cartItems)
                    {
                        var cartItemParts = cartItem.Split(':');
                        if (cartItemParts[0] == skuId && cartItemParts[2] == shopBranchId.ToString())
                        {
                            newCartInfo += "," + skuId + ":" + (int.Parse(cartItemParts[1]) + count) + ":" + shopBranchId;
                            exist        = true;
                        }
                        else
                        {
                            newCartInfo += "," + cartItem;
                        }
                    }
                    if (!exist)
                    {
                        newCartInfo += "," + skuId + ":" + count + ":" + shopBranchId;
                    }

                    if (!string.IsNullOrWhiteSpace(newCartInfo))
                    {
                        newCartInfo = newCartInfo.Substring(1);
                    }
                    WebHelper.SetCookie(CookieKeysCollection.HIMALL_CART_BRANCH, newCartInfo);
                }
                else
                {
                    WebHelper.SetCookie(CookieKeysCollection.HIMALL_CART_BRANCH, string.Format("{0}:{1}:{2}", skuId, count, shopBranchId));
                }
            }
        }
Beispiel #8
0
        public object PostUpdateCartItem(CartUpdateCartItemModel value)
        {
            var productService = ServiceProvider.Instance <IProductService> .Create;

            CheckUserLogin();
            string Jsonstr      = value.jsonstr;
            var    datavalue    = Newtonsoft.Json.JsonConvert.DeserializeObject <UpdateCartSKusModel>(Jsonstr);
            var    cartService  = ServiceProvider.Instance <ICartService> .Create;
            var    ladderPrice  = 0m;
            long   productId    = 0;
            var    isOpenLadder = false;

            foreach (var sku in datavalue.skus)
            {
                Entities.SKUInfo skuinfo = OrderApplication.GetSkuByID(sku.skuId);
                if (skuinfo != null)
                {
                    var productInfo = ProductManagerApplication.GetProduct(skuinfo.ProductId);
                    if (productInfo != null)
                    {
                        if (productInfo.MaxBuyCount > 0 && sku.count > productInfo.MaxBuyCount && !productInfo.IsOpenLadder)
                        {
                            return(ErrorResult(string.Format("商品[{0}]限购{1}件", productInfo.ProductName, productInfo.MaxBuyCount), data: new { maxBuyCount = productInfo.MaxBuyCount }));
                            //throw new MallException(string.Format("每个ID限购{0}件", productInfo.MaxBuyCount));
                        }
                    }
                }
                cartService.UpdateCart(sku.skuId, sku.count, CurrentUser.Id);
                #region 阶梯价--张宇枫
                var skus    = CartApplication.GetCart(CurrentUser.Id);
                var skuItem = skus.Items.ToList().Find(i => i.SkuId == sku.skuId);
                productId = skuItem.ProductId;
                var product = ProductManagerApplication.GetProduct(productId);
                isOpenLadder = product.IsOpenLadder;
                if (isOpenLadder)
                {
                    var shop = ShopApplication.GetShop(product.ShopId);
                    var groupCartByProduct = skus.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();
                    var quantity =
                        groupCartByProduct.Where(i => i.Key == productId)
                        .ToList()
                        .Sum(cartitem => cartitem.Sum(i => i.Quantity));
                    ladderPrice = ProductManagerApplication.GetProductLadderPrice(skuItem.ProductId, quantity);
                    if (shop.IsSelf)
                    {
                        ladderPrice = CurrentUser.MemberDiscount * ladderPrice;
                    }
                }
                #endregion
            }
            var result = new
            {
                success = true,
                //d.Url = "http://" + Url.Request.RequestUri.Host + "/m-IOS/Order/SubmiteByCart";
                Url          = Core.MallIO.GetRomoteImagePath("/m-IOS/Order/SubmiteByCart"),
                Price        = ladderPrice.ToString("F2"),
                ProductId    = productId,
                IsOpenLadder = isOpenLadder ? 1 : 0,
            };
            return(result);
        }
Beispiel #9
0
        // GET: Web/Shop
        // [OutputCache(VaryByParam = "id", Duration = ConstValues.PAGE_CACHE_DURATION)]
        public ActionResult Home(string id)
        {
            long shopId = 0;

            Entities.ShopInfo shopObj = null;

            //shopId 不是数字
            if (!long.TryParse(id, out shopId))
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
                //404 页面
            }

            //店铺Id不存在
            shopObj = _iShopService.GetShop(shopId);
            if (null == shopObj)
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
                //404 页面
            }

            #region 初始化Model

            ShopHomeModel model = new ShopHomeModel
            {
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Floors       = new List <ShopHomeFloor>(),
                Navignations = new List <Entities.BannerInfo>(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Slides       = new List <Entities.SlideAdInfo>(),
                Logo         = ""
            };


            #endregion

            #region 店铺信息

            var mark = ShopServiceMark.GetShopComprehensiveMark(shopObj.Id);
            model.Shop.Name              = shopObj.ShopName;
            model.Shop.CompanyName       = shopObj.CompanyName;
            model.Shop.Id                = shopObj.Id;
            model.Shop.PackMark          = mark.PackMark;
            model.Shop.ServiceMark       = mark.ServiceMark;
            model.Shop.ComprehensiveMark = mark.ComprehensiveMark;
            model.Shop.Phone             = shopObj.CompanyPhone;
            model.Shop.Address           = _iRegionService.GetFullName(shopObj.CompanyRegionId);
            model.Logo = shopObj.Logo;

            #endregion

            if (shopObj.IsSelf)
            {
                model.Shop.PackMark          = 5;
                model.Shop.ServiceMark       = 5;
                model.Shop.ComprehensiveMark = 5;
            }



            #region 导航和3个推荐商品

            //导航
            model.Navignations = _iNavigationService.GetSellerNavigations(shopObj.Id).ToList();

            //banner和3个推荐商品
            var list = _iSlideAdsService.GetImageAds(shopObj.Id).OrderBy(item => item.Id).ToList();
            model.ImageAds     = list.Where(p => !p.IsTransverseAD).ToList();
            model.TransverseAD = list.FirstOrDefault(p => p.IsTransverseAD);
            model.Slides       = _iSlideAdsService.GetSlidAds(shopObj.Id, Entities.SlideAdInfo.SlideAdType.ShopHome).ToList();

            #endregion

            #region 店铺分类

            var categories = _iShopCategoryService.GetShopCategory(shopObj.Id).Where(a => a.IsShow).ToList();//这里不好写到底层去,有些地方产品设计上不需要过滤
            foreach (var main in categories.Where(s => s.ParentCategoryId == 0))
            {
                var topC = new CategoryJsonModel()
                {
                    Name        = main.Name,
                    Id          = main.Id.ToString(),
                    SubCategory = new List <SecondLevelCategory>()
                };
                foreach (var secondItem in categories.Where(s => s.ParentCategoryId == main.Id))
                {
                    var secondC = new SecondLevelCategory()
                    {
                        Name = secondItem.Name,
                        Id   = secondItem.Id.ToString(),
                    };

                    topC.SubCategory.Add(secondC);
                }
                model.ShopCategory.Add(topC);
            }

            #endregion

            #region 楼层信息
            bool isSaleCountOnOff     = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1;
            var  shopHomeModules      = _iShopHomeModuleService.GetAllShopHomeModuleInfos(shopObj.Id).Where(a => a.IsEnable).OrderBy(p => p.DisplaySequence);
            ShopHomeFloorProduct info = null;
            var modules        = shopHomeModules.Select(p => p.Id).ToList();
            var imgs           = _iShopHomeModuleService.GetImages(modules);
            var moduleProducts = _iShopHomeModuleService.GetProducts(modules);
            var onSaleProducts = ProductManagerApplication.GetOnSaleProducts(moduleProducts.Select(p => p.ProductId).ToList());

            foreach (var item in shopHomeModules)
            {
                List <ShopHomeFloorProduct> products = new List <ShopHomeFloorProduct>();
                var moduleProduct = moduleProducts.Where(p => p.HomeModuleId == item.Id);
                foreach (var p in moduleProduct.OrderBy(p => p.DisplaySequence))
                {
                    var product = onSaleProducts.FirstOrDefault(x => x.Id == p.ProductId);
                    if (product == null)
                    {
                        continue;
                    }
                    info = new ShopHomeFloorProduct
                    {
                        Id    = product.Id,
                        Name  = product.ProductName,
                        Pic   = product.ImagePath,
                        Price = product.MinSalePrice.ToString("f2"),
                        //TODO:FG 循环查询销量 待优化
                        SaleCount = (int)_iProductService.GetProductVistInfo(product.Id).SaleCounts
                    };

                    if (isSaleCountOnOff)
                    {
                        info.SaleCount = info.SaleCount + (int)product.VirtualSaleCounts;
                    }
                    products.Add(info);
                }
                var topimgs = imgs
                              .Where(p => p.HomeModuleId == item.Id)
                              .OrderBy(p => p.DisplaySequence)
                              .Select(i => new ShopHomeFloorTopImg
                {
                    Url     = i.Url,
                    ImgPath = i.ImgPath
                }).ToList();

                model.Floors.Add(new ShopHomeFloor
                {
                    FloorName = item.Name,
                    FloorUrl  = item.Url,
                    Products  = products,
                    TopImgs   = topimgs
                });
            }
            #endregion

            #region 热门销售
            //热门销售不受平台销量开关影响
            var sale = _iProductService.GetHotSaleProduct(shopObj.Id, 5);
            if (sale != null)
            {
                HotProductInfo hotInfo = null;
                foreach (var item in sale.ToArray())
                {
                    hotInfo = new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.SaleCounts
                    };
                    hotInfo.SaleCount = hotInfo.SaleCount + Mall.Core.Helper.TypeHelper.ObjectToInt(item.VirtualSaleCounts);
                    model.HotSaleProducts.Add(hotInfo);
                }
            }

            #endregion

            #region 热门关注

            var hot = _iProductService.GetHotConcernedProduct(shopObj.Id, 5);
            if (hot != null)
            {
                HotProductInfo hot_Info = null;
                foreach (var item in hot.ToList())
                {
                    hot_Info = new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.ConcernedCount
                    };
                    model.HotAttentionProducts.Add(hot_Info);
                }
            }
            #endregion


            #region 微店二维码
            var    vshop    = _iVShopService.GetVShopByShopId(shopObj.Id);
            string vshopUrl = "";
            if (vshop != null)
            {
                vshopUrl = CurrentUrlHelper.CurrentUrlNoPort() + "/m-" + PlatformType.WeiXin.ToString() + "/vshop/detail/" + vshop.Id;
                CreateQR(model, vshop.StrLogo, vshopUrl);
            }
            else
            {
                vshopUrl = CurrentUrlHelper.CurrentUrlNoPort() + "/m-" + PlatformType.WeiXin.ToString();
                CreateQR(model, string.Empty, vshopUrl);
            }
            #endregion

            #region 店铺页脚
            model.Footer = _iShopHomeModuleService.GetFooter(shopObj.Id);
            #endregion

            ViewBag.IsExpired = _iShopService.IsExpiredShop(shopId);
            ViewBag.IsFreeze  = _iShopService.IsFreezeShop(shopId);

            //补充当前店铺红包功能
            ViewBag.isShopPage     = true;
            ViewBag.CurShopId      = shopId;
            TempData["isShopPage"] = true;
            TempData["CurShopId"]  = shopId;
            //统计店铺访问人数
            StatisticApplication.StatisticShopVisitUserCount(shopId);
            ViewBag.Keyword          = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword;
            ViewBag.Keywords         = SiteSettings.HotKeyWords;
            ViewBag.IsOpenTopImageAd = shopObj.IsOpenTopImageAd;
            return(View(model));
        }
        public ActionResult ShowSkuInfo(FightGroupActiveModel data)
        {
            if (data == null)
            {
                throw new HimallException("错误的活动信息");
            }
            ProductShowSkuInfoModel model = new ProductShowSkuInfoModel();

            model.MinSalePrice     = data.MiniGroupPrice;
            model.ProductImagePath = data.ProductImgPath;
            model.MaxBuyCount      = data.LimitQuantity.HasValue ? data.LimitQuantity.Value : 0;

            #region 商品规格
            Entities.TypeInfo typeInfo     = _iTypeService.GetTypeByProductId((long)data.ProductId);
            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;
            var product = ProductManagerApplication.GetProduct((long)data.ProductId);
            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;
            }
            model.ColorAlias   = colorAlias;
            model.SizeAlias    = sizeAlias;
            model.VersionAlias = versionAlias;

            if (data.ActiveItems != null && data.ActiveItems.Count() > 0)
            {
                model.StockAll = (int)data.ActiveItems.Where(p => p.SkuId.Contains(product.Id + "_")).Sum(p => p.ActiveStock);//总库存(它where一次是因为有效规格是“产品ID_”,过滤无效“{0}_”)
                long colorId = 0, sizeId = 0, versionId = 0;
                foreach (var sku in data.ActiveItems)
                {
                    var specs = sku.SkuId.Split('_');
                    if (specs.Count() > 0 && !string.IsNullOrEmpty(sku.Color))
                    {
                        if (long.TryParse(specs[1], out colorId))
                        {
                        }
                        if (colorId != 0)
                        {
                            if (!model.Color.Any(v => v.Value.Equals(sku.Color)))
                            {
                                var c = data.ActiveItems.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.ActiveStock);
                                model.Color.Add(new Himall.Web.Areas.Web.Models.ProductSKU
                                {
                                    //Name = "选择颜色",
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = sku.ShowPic
                                });
                            }
                        }
                    }
                    if (specs.Count() > 1)
                    {
                        if (long.TryParse(specs[2], out sizeId))
                        {
                        }
                        if (sizeId != 0 && !string.IsNullOrEmpty(sku.Size))
                        {
                            if (!model.Size.Any(v => v.Value.Equals(sku.Size)))
                            {
                                var ss = data.ActiveItems.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.ActiveStock);
                                model.Size.Add(new Himall.Web.Areas.Web.Models.ProductSKU
                                {
                                    //Name = "选择尺码",
                                    Name         = "选择" + sizeAlias,
                                    EnabledClass = ss != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = sizeId,
                                    Value         = sku.Size
                                });
                            }
                        }
                    }

                    if (specs.Count() > 2)
                    {
                        if (long.TryParse(specs[3], out versionId))
                        {
                        }
                        if (versionId != 0 && !string.IsNullOrEmpty(sku.Version))
                        {
                            if (!model.Version.Any(v => v.Value.Equals(sku.Version)))
                            {
                                var v = data.ActiveItems.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.ActiveStock);
                                model.Version.Add(new Himall.Web.Areas.Web.Models.ProductSKU
                                {
                                    //Name = "选择版本",
                                    Name         = "选择" + versionAlias,
                                    EnabledClass = v != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
            }
            #endregion

            return(View(model));
        }
Beispiel #11
0
        public object GetLimitBuyProduct(long id)
        {
            ProductDetailModelForMobie model = new ProductDetailModelForMobie()
            {
                Product = new ProductInfoModel(),
                Shop    = new ShopInfoModel(),
                Color   = new CollectionSKU(),
                Size    = new CollectionSKU(),
                Version = new CollectionSKU()
            };

            Entities.ProductInfo product = null;
            Entities.ShopInfo    shop    = null;
            FlashSaleModel       market  = null;

            market = ServiceProvider.Instance <ILimitTimeBuyService> .Create.Get(id);

            if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
            {
                //可能参数是商品ID
                market = market == null ? ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetFlaseSaleByProductId(id) : market;

                if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
                {
                    //跳转到404页面
                    throw new MallApiException("你所请求的限时购或者商品不存在!");
                }
            }

            if (market != null && (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing || DateTime.Parse(market.EndDate) < DateTime.Now))
            {
                return(new { success = true, IsValidLimitBuy = false });
            }

            model.MaxSaleCount = market.LimitCountOfThePeople;
            model.Title        = market.Title;

            product = ServiceProvider.Instance <IProductService> .Create.GetProduct(market.ProductId);

            bool hasSku = false;

            #region 商品SKU
            Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.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 skus = ProductManagerApplication.GetSKUs(product.Id);
            if (skus.Count > 0)
            {
                hasSku = true;
                long colorId = 0, sizeId = 0, versionId = 0;
                foreach (var sku in skus)
                {
                    var specs = sku.Id.Split('_');
                    if (specs.Count() > 0 && !string.IsNullOrEmpty(sku.Color))
                    {
                        if (long.TryParse(specs[1], out colorId))
                        {
                        }
                        if (colorId != 0)
                        {
                            if (!model.Color.Any(v => v.Value == sku.Color))
                            {
                                var c = skus.Where(s => s.Color == sku.Color).Sum(s => s.Stock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色" ,
                                    Name          = "选择" + colorAlias,
                                    EnabledClass  = c != 0 ? "enabled" : "disabled",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = sku.ShowPic
                                });
                            }
                        }
                    }
                    if (specs.Count() > 1 && !string.IsNullOrEmpty(sku.Size))
                    {
                        if (long.TryParse(specs[2], out sizeId))
                        {
                        }
                        if (sizeId != 0)
                        {
                            if (!model.Size.Any(v => v.Value.Equals(sku.Size)))
                            {
                                var ss = skus.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码" ,
                                    Name         = "选择" + sizeAlias,
                                    EnabledClass = ss != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = sizeId,
                                    Value         = sku.Size
                                });
                            }
                        }
                    }

                    if (specs.Count() > 2 && !string.IsNullOrEmpty(sku.Version))
                    {
                        if (long.TryParse(specs[3], out versionId))
                        {
                        }
                        if (versionId != 0)
                        {
                            if (!model.Version.Any(v => v.Value.Equals(sku.Version)))
                            {
                                var v = skus.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择版本" ,
                                    Name         = "选择" + versionAlias,
                                    EnabledClass = v != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
            }
            #endregion

            #region 店铺
            shop = ServiceProvider.Instance <IShopService> .Create.GetShop(product.ShopId);

            var mark = Web.Framework.ShopServiceMark.GetShopComprehensiveMark(shop.Id);
            model.Shop.PackMark          = mark.PackMark;
            model.Shop.ServiceMark       = mark.ServiceMark;
            model.Shop.ComprehensiveMark = mark.ComprehensiveMark;
            model.Shop.Name        = shop.ShopName;
            model.Shop.ProductMark = CommentApplication.GetProductAverageMark(product.Id);
            model.Shop.Id          = product.ShopId;
            model.Shop.FreeFreight = shop.FreeFreight;
            model.Shop.ProductNum  = ServiceProvider.Instance <IProductService> .Create.GetShopOnsaleProducts(product.ShopId);


            var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(product.ShopId);

            var productAndDescription = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescription);
            var sellerServiceAttitude = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitude);
            var sellerDeliverySpeed   = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeed);

            var productAndDescriptionPeer = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionPeer);
            var sellerServiceAttitudePeer = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudePeer);
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedPeer);



            decimal defaultValue = 5;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null)
            {
                model.Shop.ProductAndDescription = productAndDescription.CommentValue;
            }
            else
            {
                model.Shop.ProductAndDescription = defaultValue;
            }
            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null)
            {
                model.Shop.SellerServiceAttitude = sellerServiceAttitude.CommentValue;
            }
            else
            {
                model.Shop.SellerServiceAttitude = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null)
            {
                model.Shop.SellerDeliverySpeed = sellerDeliverySpeed.CommentValue;
            }
            else
            {
                model.Shop.SellerDeliverySpeed = defaultValue;
            }
            if (ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id) == null)
            {
                model.Shop.VShopId = -1;
            }
            else
            {
                model.Shop.VShopId = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id).Id;
            }

            //优惠券
            var result = GetCouponList(shop.Id);//取设置的优惠券
            if (result != null)
            {
                var couponCount = result.Count();
                model.Shop.CouponCount = couponCount;
            }
            #endregion

            #region 商品
            var consultations = ServiceProvider.Instance <IConsultationService> .Create.GetConsultations(product.Id);

            var  comments   = CommentApplication.GetCommentsByProduct(product.Id);
            var  total      = comments.Count;
            var  niceTotal  = comments.Count(item => item.ReviewMark >= 4);
            bool isFavorite = false;
            if (CurrentUser == null)
            {
                isFavorite = false;
            }
            else
            {
                isFavorite = ServiceProvider.Instance <IProductService> .Create.IsFavorite(product.Id, CurrentUser.Id);
            }
            var limitBuy = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetLimitTimeMarketItemByProductId(product.Id);

            var productImage = new List <string>();

            var env = EngineContext.Current.Resolve <IWebHostEnvironment>();

            for (int i = 1; i < 6; i++)
            {
                if (System.IO.File.Exists(env.ContentRootPath + product.RelativePath + string.Format("/{0}.png", i)))
                {
                    productImage.Add(Core.MallIO.GetRomoteImagePath(product.RelativePath + string.Format("/{0}.png", i)));
                }
            }
            var desc = ProductManagerApplication.GetProductDescription(product.Id);
            model.Product = new ProductInfoModel()
            {
                ProductId          = product.Id,
                CommentCount       = CommentApplication.GetCommentCountByProduct(product.Id),
                Consultations      = consultations.Count(),
                ImagePath          = productImage,
                IsFavorite         = isFavorite,
                MarketPrice        = market.MinPrice,
                MinSalePrice       = product.MinSalePrice,
                NicePercent        = model.Shop.ProductMark == 0 ? 100 : (int)((niceTotal / total) * 100),
                ProductName        = product.ProductName,
                ProductSaleStatus  = product.SaleStatus,
                AuditStatus        = product.AuditStatus,
                ShortDescription   = product.ShortDescription,
                ProductDescription = desc.ShowMobileDescription,
                MeasureUnit        = product.MeasureUnit,
                IsOnLimitBuy       = limitBuy != null,
                VideoPath          = string.IsNullOrWhiteSpace(product.VideoPath) ? string.Empty : Mall.Core.MallIO.GetRomoteImagePath(product.VideoPath),
            };
            #endregion

            LogProduct(market.ProductId);
            //统计商品浏览量、店铺浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);

            TimeSpan end    = new TimeSpan(DateTime.Parse(market.EndDate).Ticks);
            TimeSpan start  = new TimeSpan(DateTime.Now.Ticks);
            TimeSpan ts     = end.Subtract(start);
            var      second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;

            return(new
            {
                success = true,
                IsOnLimitBuy = true,
                HasSku = hasSku,
                MaxSaleCount = market.LimitCountOfThePeople,
                Title = market.Title,
                Second = second,
                Product = model.Product,
                Shop = model.Shop,
                Color = model.Color.OrderBy(p => p.SkuId),
                Size = model.Size.OrderBy(p => p.SkuId),
                Version = model.Version.OrderBy(p => p.SkuId),
                ColorAlias = colorAlias,
                SizeAlias = sizeAlias,
                VersionAlias = versionAlias
            });
        }
Beispiel #12
0
        public JsonResult AddActive(FightGroupActiveModel model)
        {
            var result = new Result {
                success = false, msg = "未知错误", status = -1
            };
            FightGroupActiveModel data = new FightGroupActiveModel();

            if (model.EndTime.Date < DateTime.Now.Date)
            {
                throw new MallException("错误的结束时间");
            }
            if (model.EndTime.Date < model.StartTime.Date)
            {
                throw new MallException("错误的结束时间");
            }
            var market = MarketApplication.GetMarketService(CurrentSellerManager.ShopId, MarketType.FightGroup);

            if (market != null)
            {
                var endtime = MarketApplication.GetServiceEndTime(market.Id);
                var newEnd  = DateTime.Parse(endtime.ToString("yyyy-MM-dd") + " 23:59:59");
                if (newEnd < model.EndTime.Date)
                {
                    throw new MallException(string.Format("活动结束时间不得超过服务到期时间,<br/>您的服务到期时间为{0}", newEnd.ToString("yyyy-MM-dd HH:mm:ss")));
                }
            }
            else
            {
                throw new MallException("您没有订购此服务");
            }
            //数据有效性验证
            model.CheckValidation();
            if (!FightGroupApplication.ProductCanJoinActive(model.ProductId))
            {
                throw new MallException("该商品已参与拼团或其他营销活动,请重新选择");
            }

            var skudata = FightGroupApplication.GetNewActiveItems(model.ProductId).skulist;

            foreach (var item in model.ActiveItems)
            {
                var cursku = skudata.FirstOrDefault(d => d.SkuId == item.SkuId);
                if (cursku != null)
                {
                    if (item.ActiveStock > cursku.ProductStock)
                    {
                        throw new MallException(item.SkuName + "错误的活动库存");
                    }
                }
                else
                {
                    model.ActiveItems.Remove(item);
                }
            }
            if (ModelState.IsValid)
            {
                TryUpdateModelAsync(data);
                data.ShopId  = CurShopId;
                data.IconUrl = SaveActiveIcon(data.IconUrl);
                model        = data;
                FightGroupApplication.AddActive(data);

                ProductManagerApplication.SaveCaculateMinPrice(model.ProductId, CurrentShop.Id);
                result = new Result {
                    success = true, msg = "操作成功", status = 1
                };
            }
            else
            {
                result = new Result {
                    success = false, msg = "数据异常,请检查数据有效性", status = -1
                };
            }
            return(Json(result));
        }
Beispiel #13
0
        // GET: Web/Search/SearchAd
        /// <summary>
        ///  商品搜索页面
        /// </summary>
        /// <param name="keywords">搜索关键字</param>
        /// <param name="cid">分类ID</param>
        /// <param name="b_id">品牌ID</param>
        /// <param name="a_id">属性ID, 表现形式:attrId_attrValueId</param>
        /// <param name="orderKey">序项(1:默认,2:销量,3:价格,4:评论数,5:上架时间)</param>
        /// <param name="orderType">排序方式(1:升序,2:降序)</param>
        /// <param name="pageNo">页码</param>
        /// <param name="pageSize">每页显示数据量</param>
        /// <returns></returns>
        public ActionResult SearchAd(
            string keywords = "", /* 搜索关键字 */
            long cid        = 0,  /* 分类ID */
            long b_id       = 0,  /* 品牌ID */
            string a_id     = "", /* 属性值ID, 表现形式:valueid,valueid */
            int orderKey    = 1,  /* 排序项(1:默认,2:销量,3:价格,4:评论数,5:上架时间) */
            int orderType   = 1,  /* 排序方式(1:升序,2:降序) */
            int pageNo      = 1,  /*页码*/
            int pageSize    = 60  /*每页显示数据量*/
            )
        {
            try
            {
                var  siteSetingInfo = SiteSettingApplication.SiteSettings;
                bool isShow         = siteSetingInfo.ProductSaleCountOnOff == 1;
                if (string.IsNullOrEmpty(keywords) && cid <= 0 && b_id <= 0 && a_id == "")
                {
                    keywords = siteSetingInfo.Keyword;
                }

                #region 初始化查询Model
                SearchProductQuery model = new SearchProductQuery();
                model.ShopId  = 0;
                model.BrandId = b_id;
                if (cid != 0)
                {
                    var catelist = _iCategoryService.GetCategories();
                    var cate     = catelist.FirstOrDefault(r => r.Id == cid);
                    if (cate != null)
                    {
                        if (cate.Depth == 1)
                        {
                            model.FirstCateId = cid;
                        }
                        else if (cate.Depth == 2)
                        {
                            model.SecondCateId = cid;
                        }
                        else if (cate.Depth == 3)
                        {
                            model.ThirdCateId = cid;
                        }
                        ViewBag.pageTitle = cate.Name;
                    }
                }
                model.AttrValIds = a_id.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                model.Keyword    = keywords;
                model.OrderKey   = orderKey;
                model.OrderType  = orderType == 1;
                model.PageNumber = pageNo;
                model.PageSize   = pageSize;
                #endregion
                SearchProductResult result = _iSearchProductService.SearchProduct(model);
                int total = result.Total;

                //当查询的结果少于一页时用like进行补偿
                if (result.Total < pageSize)
                {
                    model.IsLikeSearch = true;
                    SearchProductResult result2 = _iSearchProductService.SearchProduct(model);
                    var idList1 = result.Data.Select(a => a.ProductId).ToList();
                    var nresult = result2.Data.Where(a => !idList1.Contains(a.ProductId)).ToList();
                    if (nresult.Count > 0)
                    {
                        result.Total += nresult.Count;
                        result.Data.AddRange(nresult);
                    }
                    //补充数据后,重新排序
                    Func <IEnumerable <ProductView>, IOrderedEnumerable <ProductView> > orderby     = null;
                    Func <IEnumerable <ProductView>, IOrderedEnumerable <ProductView> > orderByDesc = null;
                    switch (model.OrderKey)
                    {
                    case 2:
                        //order.Append(" ORDER BY SaleCount ");
                        orderby     = e => e.OrderBy(p => p.SaleCount + TypeHelper.ObjectToInt(p.VirtualSaleCounts));
                        orderByDesc = e => e.OrderByDescending(p => p.SaleCount + TypeHelper.ObjectToInt(p.VirtualSaleCounts));
                        break;

                    case 3:
                        //order.Append(" ORDER BY SalePrice ");
                        orderby     = e => e.OrderBy(p => p.SalePrice);
                        orderByDesc = e => e.OrderByDescending(p => p.SalePrice);
                        break;

                    case 4:
                        //order.Append(" ORDER BY Comments ");
                        orderby     = e => e.OrderBy(p => p.Comments);
                        orderByDesc = e => e.OrderByDescending(p => p.Comments);
                        break;

                    default:
                        //order.Append(" ORDER BY Id ");
                        //按最新的排序规则作为默认排序【序号越大,在前台展示的商品越靠前,序号一致时,优先销量排前,销量一致时,优先上架时间排前】
                        //orderby = e => e.OrderBy(p => p.ProductId);
                        if (isShow)
                        {    //底层已经将虚拟销量累加到销量中
                            orderByDesc = e => e.OrderByDescending(p => p.DisplaySequence).ThenByDescending(p => p.SaleCount).ThenByDescending(p => p.ProductId);
                        }
                        else
                        {
                            orderByDesc = e => e.OrderByDescending(p => p.DisplaySequence).ThenByDescending(p => p.ProductId);
                        }
                        break;
                    }
                    if (model.OrderKey > 1)
                    {
                        if (model.OrderType)
                        {
                            result.Data = orderby(result.Data).ToList();
                        }
                        else
                        {
                            result.Data = orderByDesc(result.Data).ToList();
                        }
                    }
                    else
                    {
                        result.Data = orderByDesc(result.Data).ToList();
                    }
                }
                if (result.Total == 0)
                {
                    ViewBag.BrowsedHistory = BrowseHistrory.GetBrowsingProducts(13, CurrentUser == null ? 0 : CurrentUser.Id);
                    var    category     = _iCategoryService.GetCategory(model.ThirdCateId);
                    string categoryName = category == null ? string.Empty : category.Name;
                    var    brand        = _iBrandService.GetBrand(b_id) ?? new Entities.BrandInfo();
                    string bname        = brand == null ? "" : brand.Name;
                    ViewBag.categoryName = categoryName;
                    ViewBag.bName        = bname;
                }
                total = result.Total;

                //补商品状态
                foreach (var item in result.Data)
                {
                    var _pro = _iProductService.GetProduct(item.ProductId);
                    var skus = ProductManagerApplication.GetSKUs(item.ProductId);
                    if (_pro == null || skus == null)
                    {
                        continue;
                    }
                    if (_pro.SaleStatus == Entities.ProductInfo.ProductSaleStatus.OnSale && _pro.AuditStatus == Entities.ProductInfo.ProductAuditStatus.Audited)
                    {
                        item.ShowStatus = 0;
                        if (skus.Sum(d => d.Stock) < 1)
                        {
                            item.ShowStatus = 2;
                        }
                    }
                    else
                    {
                        if (_pro.AuditStatus == Entities.ProductInfo.ProductAuditStatus.Audited && _pro.SaleStatus == Entities.ProductInfo.ProductSaleStatus.InStock)
                        {
                            item.ShowStatus = 3;
                        }
                        else
                        {
                            item.ShowStatus = 1;
                        }
                    }
                }

                if (Core.HimallIO.GetHimallIO().GetType().FullName.Equals("Himall.Strategy.OSS"))
                {
                    ViewBag.IsOss = true;
                }
                else
                {
                    ViewBag.IsOss = false;
                }

                ViewBag.keywords  = model.Keyword;
                ViewBag.cid       = cid;
                ViewBag.b_id      = b_id;
                ViewBag.a_id      = a_id;
                ViewBag.orderKey  = orderKey;
                ViewBag.orderType = orderType;

                #region 分页控制
                PagingInfo info = new PagingInfo
                {
                    CurrentPage  = model.PageNumber,
                    ItemsPerPage = pageSize,
                    TotalItems   = total
                };
                ViewBag.pageInfo = info;
                #endregion
                ViewBag.isSaleCountOnOff = isShow;

                return(View(result.Data));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #14
0
        public ActionResult Detail(string id)
        {
            LimitTimeBuyDetailModel detailModel = new LimitTimeBuyDetailModel();
            string price = "";

            #region 定义Model和变量

            LimitTimeProductDetailModel model = new LimitTimeProductDetailModel
            {
                MainId = long.Parse(id),
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Product      = new Entities.ProductInfo(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Color        = new CollectionSKU(),
                Size         = new CollectionSKU(),
                Version      = new CollectionSKU()
            };

            FlashSaleModel    market = null;
            Entities.ShopInfo shop   = null;

            long gid = 0, mid = 0;

            #endregion

            #region 商品Id不合法
            if (long.TryParse(id, out mid))
            {
            }
            if (mid == 0)
            {
                //跳转到出错页面
                return(RedirectToAction("Error404", "Error", new { area = "Mobile" }));
            }
            #endregion

            #region 初始化商品和店铺
            //参数是限时购活动ID
            try
            {
                market = _iLimitTimeBuyService.Get(mid);
            }
            catch
            {
                market = null;
            }
            if (market != null)
            {
                switch (market.Status)
                {
                case FlashSaleInfo.FlashSaleStatus.Ended:
                    return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));

                case FlashSaleInfo.FlashSaleStatus.Cancelled:
                    return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
                }

                model.FlashSale = market;
            }
            if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
            {
                //可能参数是商品ID
                market = market == null?_iLimitTimeBuyService.GetFlaseSaleByProductId(mid) : market;

                if (market == null)
                {
                    //跳转到404页面
                    return(RedirectToAction("Error404", "Error", new { area = "Mobile" }));
                }
                if (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
                {
                    return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
                }
                market = _iLimitTimeBuyService.Get(market.Id);
            }
            model.FlashSale = market;

            if (market != null && (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing || DateTime.Parse(market.EndDate) < DateTime.Now))
            {
                return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
            }

            model.MaxSaleCount = market.LimitCountOfThePeople;
            model.Title        = market.Title;

            shop = _iShopService.GetShop(market.ShopId);

            #endregion

            #region  存在的商品
            if (null == market || market.Id == 0)
            {
                //跳转到出错页面
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            #endregion

            #region 商品描述
            var product = _iProductService.GetProduct(market.ProductId);
            gid = market.ProductId;

            model.Product = product;
            var description = ProductManagerApplication.GetProductDescription(product.Id);
            model.ProductDescription = description.ShowMobileDescription;
            if (description.DescriptionPrefixId != 0)
            {
                var desc = _iProductDescriptionTemplateService
                           .GetTemplate(description.DescriptionPrefixId, product.ShopId);
                model.DescriptionPrefix = desc == null ? "" : desc.Content;
            }

            if (description.DescriptiondSuffixId != 0)
            {
                var desc = _iProductDescriptionTemplateService
                           .GetTemplate(description.DescriptiondSuffixId, product.ShopId);
                model.DescriptiondSuffix = desc == null ? "" : desc.Content;
            }

            var mark = ShopServiceMark.GetShopComprehensiveMark(shop.Id);
            model.Shop.PackMark          = mark.PackMark;
            model.Shop.ServiceMark       = mark.ServiceMark;
            model.Shop.ComprehensiveMark = mark.ComprehensiveMark;
            model.Shop.Name               = shop.ShopName;
            model.Shop.ProductMark        = CommentApplication.GetProductAverageMark(gid);
            model.Shop.Id                 = product.ShopId;
            model.Shop.FreeFreight        = shop.FreeFreight;
            detailModel.ProductNum        = _iProductService.GetShopOnsaleProducts(product.ShopId);
            detailModel.FavoriteShopCount = _iShopService.GetShopFavoritesCount(product.ShopId);
            if (CurrentUser == null)
            {
                detailModel.IsFavorite     = false;
                detailModel.IsFavoriteShop = false;
            }
            else
            {
                detailModel.IsFavorite = _iProductService.IsFavorite(product.Id, CurrentUser.Id);
                var favoriteShopIds = _iShopService.GetFavoriteShopInfos(CurrentUser.Id).Select(item => item.ShopId).ToArray();//获取已关注店铺
                detailModel.IsFavoriteShop = favoriteShopIds.Contains(product.ShopId);
            }
            #endregion

            #region 店铺分类

            var categories = _iShopCategoryService.GetShopCategory(product.ShopId);
            List <Entities.ShopCategoryInfo> allcate = categories.ToList();
            foreach (var main in allcate.Where(s => s.ParentCategoryId == 0))
            {
                var topC = new CategoryJsonModel()
                {
                    Name        = main.Name,
                    Id          = main.Id.ToString(),
                    SubCategory = new List <SecondLevelCategory>()
                };
                foreach (var secondItem in allcate.Where(s => s.ParentCategoryId == main.Id))
                {
                    var secondC = new SecondLevelCategory()
                    {
                        Name = secondItem.Name,
                        Id   = secondItem.Id.ToString(),
                    };

                    topC.SubCategory.Add(secondC);
                }
                model.ShopCategory.Add(topC);
            }

            #endregion

            #region 热门销售

            var sale = _iProductService.GetHotSaleProduct(shop.Id, 5);
            if (sale != null)
            {
                foreach (var item in sale.ToArray())
                {
                    model.HotSaleProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.SaleCounts + Mall.Core.Helper.TypeHelper.ObjectToInt(item.VirtualSaleCounts)
                    });
                }
            }

            #endregion

            #region 热门关注

            var hot = _iProductService.GetHotConcernedProduct(shop.Id, 5);
            if (hot != null)
            {
                foreach (var item in hot.ToArray())
                {
                    model.HotAttentionProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.ConcernedCount
                    });
                }
            }
            #endregion

            #region 商品规格

            Entities.TypeInfo typeInfo     = _iTypeService.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;
            }
            model.ColorAlias   = colorAlias;
            model.SizeAlias    = sizeAlias;
            model.VersionAlias = versionAlias;
            var skus = ProductManagerApplication.GetSKUs(product.Id);
            if (skus.Count > 0)
            {
                long colorId = 0, sizeId = 0, versionId = 0;
                foreach (var sku in skus)
                {
                    var specs = sku.Id.Split('_');
                    if (specs.Count() > 0 && !string.IsNullOrEmpty(sku.Color))
                    {
                        if (long.TryParse(specs[1], out colorId))
                        {
                        }
                        if (colorId != 0)
                        {
                            if (!model.Color.Any(v => v.Value.Equals(sku.Color)))
                            {
                                var c = skus.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色",
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = Core.MallIO.GetImagePath(sku.ShowPic)
                                });
                            }
                        }
                    }
                    if (specs.Count() > 1 && !string.IsNullOrEmpty(sku.Size))
                    {
                        if (long.TryParse(specs[2], out sizeId))
                        {
                        }
                        if (sizeId != 0)
                        {
                            if (!model.Size.Any(v => v.Value.Equals(sku.Size)))
                            {
                                var ss = skus.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码",
                                    Name         = "选择" + sizeAlias,
                                    EnabledClass = ss != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = sizeId,
                                    Value         = sku.Size
                                });
                            }
                        }
                    }

                    if (specs.Count() > 2 && !string.IsNullOrEmpty(sku.Version))
                    {
                        if (long.TryParse(specs[3], out versionId))
                        {
                        }
                        if (versionId != 0)
                        {
                            if (!model.Version.Any(v => v.Value.Equals(sku.Version)))
                            {
                                var v = skus.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择版本",
                                    Name         = "选择" + versionAlias,
                                    EnabledClass = v != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
                //var min = skus.Where(s => s.Stock >= 0).Min(s => s.SalePrice);
                //var max = skus.Where(s => s.Stock >= 0).Max(s => s.SalePrice);
                //if (min == 0 && max == 0)
                //{
                //    price = product.MinSalePrice.ToString("f2");
                //}
                //else if (max > min)
                //{
                //    price = string.Format("{0}-{1}", min.ToString("f2"), max.ToString("f2"));
                //}
                //else
                //{
                //    price = string.Format("{0}", min.ToString("f2"));
                //}
                price = ProductWebApplication.GetProductPriceStr2(product, skus);//最小价或区间价文本
            }
            detailModel.Price = string.IsNullOrWhiteSpace(price) ? product.MinSalePrice.ToString("f2") : price;
            #endregion

            #region 商品属性
            List <TypeAttributesModel> ProductAttrs = new List <TypeAttributesModel>();
            var prodAttrs = ProductManagerApplication.GetProductAttributes(product.Id);
            foreach (var attr in prodAttrs)
            {
                if (!ProductAttrs.Any(p => p.AttrId == attr.AttributeId))
                {
                    var attribute = _iTypeService.GetAttribute(attr.AttributeId);
                    var values    = _iTypeService.GetAttributeValues(attr.AttributeId);
                    TypeAttributesModel attrModel = new TypeAttributesModel()
                    {
                        AttrId     = attr.AttributeId,
                        AttrValues = new List <TypeAttrValue>(),
                        Name       = attribute.Name
                    };
                    foreach (var attrV in values)
                    {
                        if (prodAttrs.Any(p => p.ValueId == attrV.Id))
                        {
                            attrModel.AttrValues.Add(new TypeAttrValue
                            {
                                Id   = attrV.Id.ToString(),
                                Name = attrV.Value
                            });
                        }
                    }
                    ProductAttrs.Add(attrModel);
                }
                else
                {
                    var attrTemp = ProductAttrs.FirstOrDefault(p => p.AttrId == attr.AttributeId);
                    var values   = _iTypeService.GetAttributeValues(attr.AttributeId);
                    if (!attrTemp.AttrValues.Any(p => p.Id == attr.ValueId.ToString()))
                    {
                        attrTemp.AttrValues.Add(new TypeAttrValue
                        {
                            Id   = attr.ValueId.ToString(),
                            Name = values.FirstOrDefault(a => a.Id == attr.ValueId).Value
                        });
                    }
                }
            }
            detailModel.ProductAttrs = ProductAttrs;
            #endregion

            #region 获取评论、咨询数量

            var comments = CommentApplication.GetCommentsByProduct(product.Id);
            detailModel.CommentCount = comments.Count;

            var consultations = ServiceApplication.Create <IConsultationService>().GetConsultations(gid);

            var total     = comments.Count;
            var niceTotal = comments.Count(item => item.ReviewMark >= 4);
            detailModel.NicePercent   = (int)((niceTotal / (double)total) * 100);
            detailModel.Consultations = consultations.Count();

            if (_iVShopService.GetVShopByShopId(shop.Id) == null)
            {
                detailModel.VShopId = -1;
            }
            else
            {
                detailModel.VShopId = _iVShopService.GetVShopByShopId(shop.Id).Id;
            }
            #endregion

            #region 累加浏览次数、 加入历史记录
            //if (CurrentUser != null)
            //{
            //    BrowseHistrory.AddBrowsingProduct(product.Id, CurrentUser.Id);
            //}
            //else
            //{
            //    BrowseHistrory.AddBrowsingProduct(product.Id);
            //}
            //_iProductService.LogProductVisti(gid);
            #endregion

            #region 获取店铺的评价统计
            var shopStatisticOrderComments = _iShopService.GetShopStatisticOrderComments(product.ShopId);

            var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault();
            var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault();
            var sellerDeliverySpeed   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                         Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault();

            var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault();
            var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault();
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                             Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault();

            var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault();
            var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault();

            var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault();
            var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault();

            var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault();
            var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault();

            decimal defaultValue = 5;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null && !shop.IsSelf)
            {
                detailModel.ProductAndDescription     = productAndDescription.CommentValue;
                detailModel.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                detailModel.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                detailModel.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                detailModel.ProductAndDescription     = defaultValue;
                detailModel.ProductAndDescriptionPeer = defaultValue;
                detailModel.ProductAndDescriptionMin  = defaultValue;
                detailModel.ProductAndDescriptionMax  = defaultValue;
            }
            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null && !shop.IsSelf)
            {
                detailModel.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                detailModel.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                detailModel.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                detailModel.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                detailModel.SellerServiceAttitude     = defaultValue;
                detailModel.SellerServiceAttitudePeer = defaultValue;
                detailModel.SellerServiceAttitudeMax  = defaultValue;
                detailModel.SellerServiceAttitudeMin  = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null && !shop.IsSelf)
            {
                detailModel.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                detailModel.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                detailModel.SellerDeliverySpeedMax  = sellerDeliverySpeedMax != null ? sellerDeliverySpeedMax.CommentValue : 0;
                detailModel.sellerDeliverySpeedMin  = sellerDeliverySpeedMin != null ? sellerDeliverySpeedMin.CommentValue : 0;
            }
            else
            {
                detailModel.SellerDeliverySpeed     = defaultValue;
                detailModel.SellerDeliverySpeedPeer = defaultValue;
                detailModel.SellerDeliverySpeedMax  = defaultValue;
                detailModel.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion

            #region 是否收藏此商品
            if (CurrentUser != null && CurrentUser.Id > 0)
            {
                model.IsFavorite = _iProductService.IsFavorite(product.Id, CurrentUser.Id);
            }
            else
            {
                model.IsFavorite = false;
            }
            #endregion

            long vShopId;
            var  vshopinfo = _iVShopService.GetVShopByShopId(shop.Id);
            if (vshopinfo == null)
            {
                vShopId = -1;
            }
            else
            {
                vShopId = vshopinfo.Id;
            }
            detailModel.VShopId = vShopId;
            model.Shop.VShopId  = vShopId;

            model.VShopLog = _iVShopService.GetVShopLog(model.Shop.VShopId);
            if (string.IsNullOrWhiteSpace(model.VShopLog))
            {
                //throw new Mall.Core.MallException("店铺未开通微店功能");
                model.VShopLog = SiteSettings.WXLogo;
            }
            detailModel.Logined = (null != CurrentUser) ? 1 : 0;
            model.EnabledBuy    = product.AuditStatus == Entities.ProductInfo.ProductAuditStatus.Audited && DateTime.Parse(market.BeginDate) <= DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now && product.SaleStatus == Entities.ProductInfo.ProductSaleStatus.OnSale;
            int saleCounts = 0;
            saleCounts = market.SaleCount;
            if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) < DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now)
            {
                TimeSpan end   = new TimeSpan(DateTime.Parse(market.EndDate).Ticks);
                TimeSpan start = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts    = end.Subtract(start);
                detailModel.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;
            }
            else if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) > DateTime.Now)
            {
                TimeSpan end   = new TimeSpan(DateTime.Parse(market.BeginDate).Ticks);
                TimeSpan start = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts    = end.Subtract(start);
                detailModel.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;
                saleCounts         = Mall.Core.Helper.TypeHelper.ObjectToInt(product.SaleCounts) + Mall.Core.Helper.TypeHelper.ObjectToInt(product.VirtualSaleCounts);
            }
            ViewBag.DetailModel = detailModel;

            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(market.ShopId);
            ViewBag.CustomerServices = customerServices;

            //统计商品浏览量、店铺浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);

            model.IsSaleCountOnOff = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1;                                          //是否显示销量
            model.SaleCount        = saleCounts;                                                                                              //销量
            model.FreightTemplate  = FreightTemplateApplication.GetFreightTemplate(product.FreightTemplateId);
            model.Freight          = FreightTemplateApplication.GetFreightStr(market.ProductId, model.FreightTemplate, CurrentUser, product); //运费或免运费
            model.StockAll         = market.Quantity;

            return(View(model));
        }
Beispiel #15
0
        public JsonResult GetCartProducts()
        {
            var memberId  = CurrentUser?.Id ?? 0;
            var cartItems = CartApplication.GetCartItems(memberId);
            var vshops    = VshopApplication.GetVShopsByShopIds(cartItems.Select(p => p.Shop.Id));
            var products  = cartItems.Select(item =>
            {
                var sku     = item.Sku;
                var product = item.Product;
                var shop    = item.Shop;
                var vshop   = vshops.FirstOrDefault(p => p.ShopId == shop.Id);

                var skuDetails = string.Empty;
                if (!string.IsNullOrWhiteSpace(sku.Size))
                {
                    skuDetails += sku.SizeAlias + ":" + sku.Size + "&nbsp;&nbsp;";
                }
                if (!string.IsNullOrWhiteSpace(sku.Color))
                {
                    skuDetails += sku.ColorAlias + ":" + sku.Color + "&nbsp;&nbsp;";
                }
                if (!string.IsNullOrWhiteSpace(sku.Version))
                {
                    skuDetails += sku.VersionAlias + ":" + sku.Version + "&nbsp;&nbsp;";
                }


                return(new
                {
                    cartItemId = item.ItemId,
                    skuId = sku.Id,
                    id = product.Id,
                    imgUrl = Himall.Core.HimallIO.GetProductSizeImage(product.RelativePath, 1, (int)ImageSize.Size_150),
                    name = product.ProductName,
                    price = sku.SalePrice,
                    count = item.Quantity,
                    shopId = shop.Id,
                    vshopId = vshop == null ? 0 : vshop.Id,
                    shopName = shop.ShopName,
                    shopLogo = vshop == null ? "" : vshop.Logo,
                    productstatus = item.IsLimit ? 0 : (sku.Stock <= 0 ? ProductInfo.ProductSaleStatus.InStock.GetHashCode() : product.SaleStatus.GetHashCode()),
                    status = item.IsLimit ? 1 : ProductManagerApplication.GetProductShowStatus(product, sku.Map <DTO.SKU>(), 1),   // 0:正常;1:已失效;2:库存不足;3:已下架;
                    Size = sku.Size,
                    Color = sku.Color,
                    Version = sku.Version,
                    ColorAlias = sku.ColorAlias,
                    SizeAlias = sku.SizeAlias,
                    VersionAlias = sku.VersionAlias,
                    skuDetails = skuDetails,
                    AddTime = item.AddTime,
                    minMath = ProductManagerApplication.GetProductLadderMinMath(product.Id)
                });
            }).OrderBy(p => p.status).ThenByDescending(o => o.AddTime).ToList();

            #region 门店购物车
            var  discount         = CurrentUser?.MemberDiscount ?? 1;
            var  branchCartHelper = new BranchCartHelper();
            long userId           = 0;
            if (CurrentUser != null)
            {
                userId = CurrentUser.Id;
            }
            var Branchcart     = branchCartHelper.GetCartNoCache(userId, 0);
            var shopBranchList = Branchcart.Items.Where(x => x.ShopBranchId > 0).Select(x => x.ShopBranchId).ToList();
            shopBranchList = shopBranchList.GroupBy(x => x).Select(x => x.First()).ToList();
            Dictionary <long, long> buyedCounts = null;
            if (userId > 0)
            {
                buyedCounts = new Dictionary <long, long>();
                buyedCounts = OrderApplication.GetProductBuyCount(userId, Branchcart.Items.Select(x => x.ProductId));
            }

            var branchProducts = PackageCartProducts(Branchcart, discount, true);
            var sbProducts     = branchProducts.OrderBy(p => p.status).ThenByDescending(item => item.AddTime);
            var shopBranchCart = sbProducts.GroupBy(item => item.shopBranchId);
            #endregion

            var cartModel = new { products = products, amount = products.Sum(item => item.price * item.count), totalCount = products.Sum(item => item.count), shopBranchCart = shopBranchCart };
            return(SuccessResult <dynamic>(data: cartModel));
        }
Beispiel #16
0
        public JsonResult GetShopBranchs(long shopId, long regionId, bool getParent, string[] skuIds, int[] counts, int page, int rows, long shippingAddressId)
        {
            ShippingAddressInfo userShippingAddress = ShippingAddressApplication.GetUserShippingAddress(shippingAddressId);
            int             streetId   = 0;
            int             districtId = 0;
            ShopBranchQuery query      = new ShopBranchQuery
            {
                ShopId   = shopId,
                PageNo   = page,
                PageSize = rows,
                Status   = 0
            };

            if (userShippingAddress != null)
            {
                query.FromLatLng = string.Format("{0},{1}", userShippingAddress.Latitude, userShippingAddress.Longitude);
                streetId         = userShippingAddress.RegionId;
                Region region = RegionApplication.GetRegion((long)userShippingAddress.RegionId, Region.RegionLevel.Town);
                if ((region != null) && (region.ParentId > 0))
                {
                    districtId = region.ParentId;
                }
                else
                {
                    districtId = streetId;
                    streetId   = 0;
                }
            }
            bool hasLatLng = false;

            if (!string.IsNullOrWhiteSpace(query.FromLatLng))
            {
                hasLatLng = query.FromLatLng.Split(new char[] { ',' }).Length == 2;
            }
            Region region2 = RegionApplication.GetRegion(regionId, getParent ? Region.RegionLevel.City : Region.RegionLevel.County);

            if (region2 != null)
            {
                query.AddressPath = region2.GetIdPath(",");
            }
            List <SKU> skuInfos = ProductManagerApplication.GetSKUs(skuIds);

            query.ProductIds = (from p in skuInfos select p.ProductId).ToArray <long>();
            QueryPageModel <ShopBranch> shopBranchsAll = ShopBranchApplication.GetShopBranchsAll(query);
            List <ShopBranchSkusInfo>   shopBranchSkus = ShopBranchApplication.GetSkus(shopId, from p in shopBranchsAll.Models select p.Id);

            shopBranchsAll.Models.ForEach(delegate(ShopBranch p)
            {
                p.Enabled = skuInfos.All <SKU>(skuInfo => shopBranchSkus.Any <ShopBranchSkusInfo>(sbSku => ((sbSku.ShopBranchId == p.Id) && (sbSku.Stock >= counts[skuInfos.IndexOf(skuInfo)])) && (sbSku.SkuId == skuInfo.Id)));
            });
            List <ShopBranch> source     = new List <ShopBranch>();
            List <long>       fillterIds = new List <long>();
            List <ShopBranch> list2      = (from p in shopBranchsAll.Models
                                            where (hasLatLng && p.Enabled) && ((p.Latitude > 0f) && (p.Longitude > 0f))
                                            orderby p.Distance
                                            select p).ToList <ShopBranch>();

            if ((list2 != null) && (list2.Count <ShopBranch>() > 0))
            {
                fillterIds.AddRange(from p in list2 select p.Id);
                source.AddRange(list2);
            }
            List <ShopBranch> list3 = (from p in shopBranchsAll.Models
                                       where (!fillterIds.Contains(p.Id) && p.Enabled) && p.AddressPath.Contains("," + streetId + ",")
                                       select p).ToList <ShopBranch>();

            if ((list3 != null) && (list3.Count <ShopBranch>() > 0))
            {
                fillterIds.AddRange(from p in list3 select p.Id);
                source.AddRange(list3);
            }
            List <ShopBranch> list4 = (from p in shopBranchsAll.Models
                                       where (!fillterIds.Contains(p.Id) && p.Enabled) && p.AddressPath.Contains("," + districtId + ",")
                                       select p).ToList <ShopBranch>();

            if ((list4 != null) && (list4.Count <ShopBranch>() > 0))
            {
                fillterIds.AddRange(from p in list4 select p.Id);
                source.AddRange(list4);
            }
            List <ShopBranch> list5 = (from p in shopBranchsAll.Models
                                       where !fillterIds.Contains(p.Id) && p.Enabled
                                       select p).ToList <ShopBranch>();

            if ((list5 != null) && (list5.Count <ShopBranch>() > 0))
            {
                fillterIds.AddRange(from p in list5 select p.Id);
                source.AddRange(list5);
            }
            List <ShopBranch> list6 = (from p in shopBranchsAll.Models
                                       where !fillterIds.Contains(p.Id)
                                       select p).ToList <ShopBranch>();

            if ((list6 != null) && (list6.Count <ShopBranch>() > 0))
            {
                source.AddRange(list6);
            }
            if (source.Count <ShopBranch>() != shopBranchsAll.Models.Count <ShopBranch>())
            {
                return(base.Json(new { Rows = "" }, true));
            }
            var data = new
            {
                Rows  = (from sb in source select new { ContactUser = sb.ContactUser, ContactPhone = sb.ContactPhone, AddressDetail = sb.AddressDetail, ShopBranchName = sb.ShopBranchName, Id = sb.Id, Enabled = sb.Enabled }).ToArray(),
                Total = source.Count
            };

            return(base.Json(data, true));
        }
Beispiel #17
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);
        }
Beispiel #18
0
        public ActionResult Console()
        {
            //新首页开始
            HomeModel model  = new HomeModel();
            var       shopId = CurrentSellerManager.ShopId;
            /*店铺信息*/
            var shop = ShopApplication.GetShop(shopId);

            if (shop != null)
            {
                model.SellerConsoleModel = StatisticApplication.GetSellerConsoleModel(shopId);
                /*公告*/
                model.Articles      = _iArticleService.GetTopNArticle <ArticleInfo>(6, 4);
                ViewBag.Logo        = SiteSettingApplication.SiteSettings.MemberLogo;
                model.ShopId        = shop.Id;
                model.ShopLogo      = shop.Logo;
                model.ShopName      = shop.ShopName;
                model.ShopEndDate   = shop.EndDate.HasValue ? shop.EndDate.Value.ToString("yyyy-MM-dd") : string.Empty;
                model.ShopGradeName = model.SellerConsoleModel.ShopGrade;

                var shopStatisticOrderComments = _iShopService.GetShopStatisticOrderComments(CurrentSellerManager.ShopId);
                var productAndDescription      = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault();
                var sellerServiceAttitude      = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault();
                var sellerDeliverySpeed        = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault();

                var defaultValue = "5";
                //宝贝与描述
                model.ProductAndDescription = productAndDescription != null?string.Format("{0:F}", productAndDescription.CommentValue) : defaultValue;

                //卖家服务态度
                model.SellerServiceAttitude = sellerServiceAttitude != null?string.Format("{0:F}", sellerServiceAttitude.CommentValue) : defaultValue;

                //卖家发货速度
                model.SellerDeliverySpeed = sellerDeliverySpeed != null?string.Format("{0:F}", sellerDeliverySpeed.CommentValue) : defaultValue;

                //所有商品数
                model.ProductsNumberIng = model.SellerConsoleModel.ProductLimit.ToString();
                //发布商品数量
                model.ProductsNumber = model.SellerConsoleModel.ProductsCount.ToString();
                //使用空间
                model.UseSpace = model.SellerConsoleModel.ImageLimit.ToString();
                //正使用的空间
                model.UseSpaceing = model.SellerConsoleModel.ProductImages.ToString();
                //商品咨询
                model.OrderProductConsultation = model.SellerConsoleModel.ProductConsultations.ToString();
                //订单总数
                model.OrderCounts = model.SellerConsoleModel.OrderCounts.ToString();
                //待买家付款
                model.OrderWaitPay = model.SellerConsoleModel.WaitPayTrades.ToString();
                //待发货
                model.OrderWaitDelivery = model.SellerConsoleModel.WaitDeliveryTrades.ToString();
                //待回复评价
                model.OrderReplyComments = model.SellerConsoleModel.ProductComments.ToString();
                //待处理投诉
                model.OrderHandlingComplaints = model.SellerConsoleModel.Complaints.ToString();
                //待处理退款
                model.OrderWithRefund = model.SellerConsoleModel.RefundTrades.ToString();
                //待处理退货
                model.OrderWithRefundAndRGoods = model.SellerConsoleModel.RefundAndRGoodsTrades.ToString();
                //商品评价
                model.ProductsEvaluation = model.SellerConsoleModel.ProductsEvaluation.ToString();
                //授权品牌
                model.ProductsBrands = _iBrandService.GetShopBrandApplys(CurrentSellerManager.ShopId).Where(c => c.AuditStatus == 1).Count().ToString();
                //出售中
                model.ProductsOnSale = model.SellerConsoleModel.OnSaleProducts.ToString();
                //草稿箱
                model.ProductsInDraft = model.SellerConsoleModel.ProductsInDraft.ToString();
                //待审核
                model.ProductsWaitForAuditing = model.SellerConsoleModel.WaitForAuditingProducts.ToString();
                //审核未通过
                model.ProductsAuditFailed = model.SellerConsoleModel.AuditFailureProducts.ToString();
                //违规下架
                model.ProductsInfractionSaleOff = model.SellerConsoleModel.InfractionSaleOffProducts.ToString();
                //仓库中
                model.ProductsInStock = model.SellerConsoleModel.InStockProducts.ToString();
                //警戒库存数
                model.OverSafeStockProducts = ProductManagerApplication.GetOverSafeStockProducts(CurrentSellerManager.ShopId).ToString();
                DateTime startDate      = DateTime.Now.AddDays(-1).Date;
                DateTime endDate        = startDate.AddDays(1).AddMilliseconds(-1);
                var      statistic      = StatisticApplication.GetShopTradeStatistic(CurrentSellerManager.ShopId, null, startDate, endDate);
                var      lstEchartsData = new List <EchartsData>();
                if (statistic != null)
                {
                    ViewBag.VistiCounts   = statistic.VisitCounts;
                    ViewBag.OrderCounts   = statistic.OrderCount;
                    ViewBag.OrderPayCount = statistic.OrderPayCount;
                }
                else
                {
                    string zero = decimal.Zero.ToString();
                    ViewBag.VistiCounts   = zero;
                    ViewBag.OrderCounts   = zero;
                    ViewBag.OrderPayCount = zero;
                }
            }
            //新首页结束
            return(View(model));
        }
Beispiel #19
0
        public void AddToCart(string skuId, int count, long memberId)
        {
            CheckSkuIdIsValid(skuId);
            //判断库存
            var sku = ProductManagerApplication.GetSKU(skuId);

            if (sku == null)
            {
                throw new HimallException("错误的SKU");
            }
            if (count > sku.Stock)
            {
                throw new HimallException("库存不足");
            }
            #region 商品限购判断
            var prouctInfo = ProductManagerApplication.GetProduct(sku.ProductId);
            if (prouctInfo != null && prouctInfo.MaxBuyCount > 0 && !prouctInfo.IsOpenLadder)//商品有限购数量
            {
                var carInfo = CartApplication.GetCart(memberId);
                if (carInfo != null)
                {
                    var quantity = carInfo.Items.Where(p => p.ProductId == sku.ProductId).Sum(d => d.Quantity); //当前用户该商品已加入购物车数量
                    if (count + quantity > prouctInfo.MaxBuyCount)                                              //已有数量+新数量
                    {
                        throw new HimallException(string.Format("每个ID限购{0}件", prouctInfo.MaxBuyCount));
                    }
                }
            }
            #endregion

            if (memberId > 0)
            {
                CartApplication.AddToCart(skuId, count, memberId);
            }
            else
            {
                string cartInfo = WebHelper.GetCookie(CookieKeysCollection.HIMALL_CART);
                if (!string.IsNullOrWhiteSpace(cartInfo))
                {
                    string[] cartItems   = cartInfo.Split(',');
                    string   newCartInfo = string.Empty;
                    bool     exist       = false;
                    foreach (string cartItem in cartItems)
                    {
                        var cartItemParts = cartItem.Split(':');
                        if (cartItemParts[0] == skuId)
                        {
                            newCartInfo += "," + skuId + ":" + (int.Parse(cartItemParts[1]) + count);
                            exist        = true;
                        }
                        else
                        {
                            newCartInfo += "," + cartItem;
                        }
                    }
                    if (!exist)
                    {
                        newCartInfo += "," + skuId + ":" + count;
                    }

                    if (!string.IsNullOrWhiteSpace(newCartInfo))
                    {
                        newCartInfo = newCartInfo.Substring(1);
                    }
                    WebHelper.SetCookie(CookieKeysCollection.HIMALL_CART, newCartInfo);
                }
                else
                {
                    WebHelper.SetCookie(CookieKeysCollection.HIMALL_CART, string.Format("{0}:{1}", skuId, count));
                }
            }
        }
        /// <summary>
        /// 取用户在门店的购物车数量
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="branchIds"></param>
        /// <returns></returns>
        public static Dictionary <long, int> GetShopBranchCartItemCount(long userId, List <long> branchIds)
        {
            Dictionary <long, int> result = new Dictionary <long, int>();

            if (userId == 0)
            {
                return(result);
            }
            Mall.Entities.ShoppingCartInfo memberCartInfo = new Mall.Entities.ShoppingCartInfo();
            List <DTO.Product.Product>     onSaleProducts = new List <DTO.Product.Product>();

            if (userId > 0)
            {//如果已登陆取购物车数据
                memberCartInfo = CartApplication.GetShopBranchCart(userId);
                if (memberCartInfo != null)
                {
                    onSaleProducts = ProductManagerApplication.GetAllStatusProductByIds(memberCartInfo.Items.Select(e => e.ProductId)).ToList();
                }
            }

            Dictionary <long, long> buyedCounts = null;

            if (userId > 0)
            {
                buyedCounts = new Dictionary <long, long>();
                buyedCounts = OrderApplication.GetProductBuyCount(userId, memberCartInfo.Items.Select(x => x.ProductId));
            }
            var shopBranchSkuList = Service.GetSkusByBranchIds(branchIds, skuids: memberCartInfo.Items.Select(s => s.SkuId).ToList());

            foreach (var id in branchIds)
            {
                //var cartQuantity = memberCartInfo.Items.Where(c => c.ShopBranchId.HasValue && c.ShopBranchId.Value == query.shopBranchId).Sum(c => c.Quantity);
                //过滤购物车 无效商品
                var cartQuantity = memberCartInfo.Items.Where(c => c.ShopBranchId == id).Select(item =>
                {
                    var product       = onSaleProducts.FirstOrDefault(p => p.Id == item.ProductId);
                    var shopbranchsku = shopBranchSkuList.FirstOrDefault(x => x.ShopBranchId == id && x.SkuId == item.SkuId);
                    long stock        = shopbranchsku == null ? 0 : shopbranchsku.Stock;

                    if (stock > product.MaxBuyCount && product.MaxBuyCount != 0)
                    {
                        stock = product.MaxBuyCount;
                    }
                    if (product.MaxBuyCount > 0 && buyedCounts != null && buyedCounts.ContainsKey(item.ProductId))
                    {
                        long buynum = buyedCounts[item.ProductId];
                        stock       = stock - buynum;
                    }
                    var status = product.IsOpenLadder ? 1 : (shopbranchsku == null ? 1 : (shopbranchsku.Status == ShopBranchSkuStatus.Normal) ? (item.Quantity > stock ? 2 : 0) : 1);//0:正常;1:冻结;2:库存不足
                    if (status == 0)
                    {
                        return(item.Quantity);
                    }
                    else
                    {
                        return(0);
                    }
                }).Sum(count => count);
                if (cartQuantity > 0)
                {
                    result.Add(id, cartQuantity);
                }
            }
            return(result);
        }
Beispiel #21
0
        public JsonResult List(int page, int rows, string productName, bool?isReply = null, int Rank = -1, bool hasAppend = false)
        {
            if (!string.IsNullOrEmpty(productName))
            {
                productName = productName.Trim();
            }
            var orderItemService = _iOrderService;
            var iTypeService     = _iTypeService;
            var query            = new CommentQuery()
            {
                PageNo = page, PageSize = rows, HasAppend = hasAppend, ProductName = productName, Rank = Rank, ShopID = base.CurrentSellerManager.ShopId, IsReply = isReply
            };
            var result       = _iCommentService.GetComments(query);
            var orderItemIds = result.Models.Select(a => a.SubOrderId).ToList();

            var orderItems = orderItemService.GetOrderItemsByOrderItemId(orderItemIds).ToDictionary(item => item.Id, item => item);
            var comments   = result.Models.Select(item =>
            {
                var product = ProductManagerApplication.GetProduct(item.ProductId);
                return(new ProductCommentModel()
                {
                    CommentContent = item.ReviewContent,
                    CommentDate = item.ReviewDate,
                    ReplyContent = item.ReplyContent,
                    AppendContent = item.AppendContent,
                    AppendDate = item.AppendDate,
                    ReplyAppendDate = item.ReplyAppendDate,
                    CommentMark = item.ReviewMark,
                    ReplyDate = item.ReplyDate,
                    Id = item.Id,
                    ProductName = (product == null) ? "" : product.ProductName,
                    ProductId = item.ProductId,
                    ImagePath = orderItems[item.SubOrderId].ThumbnailsUrl,
                    UserName = item.UserName,
                    OderItemId = item.SubOrderId,
                    Color = "",
                    Version = "",
                    Size = "",
                    UserId = item.UserId
                });
            }).ToList();

            //TODO LRL 2015/08/06 从评价信息添加商品的规格信息
            foreach (var item in comments)
            {
                item.ImagePath = Core.MallIO.GetProductSizeImage(item.ImagePath, 1, (int)ImageSize.Size_100);
                if (item.OderItemId.HasValue)
                {
                    var obj = orderItemService.GetOrderItem(item.OderItemId.Value);
                    if (obj != null)
                    {
                        item.Color   = obj.Color;
                        item.Size    = obj.Size;
                        item.Version = obj.Version;
                        item.OrderId = obj.OrderId;

                        var member = MemberApplication.GetMember(item.UserId);
                        if (member != null)
                        {
                            item.UserName  = member.UserName;
                            item.UserPhone = member.CellPhone;
                        }
                    }
                }
                Entities.TypeInfo typeInfo = iTypeService.GetTypeByProductId(item.ProductId);
                item.ColorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                item.SizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                item.VersionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
                var productInfo = ProductManagerApplication.GetProduct(item.ProductId);
                if (productInfo != null)
                {
                    item.ColorAlias   = !string.IsNullOrWhiteSpace(productInfo.ColorAlias) ? productInfo.ColorAlias : item.ColorAlias;
                    item.SizeAlias    = !string.IsNullOrWhiteSpace(productInfo.SizeAlias) ? productInfo.SizeAlias : item.SizeAlias;
                    item.VersionAlias = !string.IsNullOrWhiteSpace(productInfo.VersionAlias) ? productInfo.VersionAlias : item.VersionAlias;
                }
            }
            DataGridModel <ProductCommentModel> model = new DataGridModel <ProductCommentModel>()
            {
                rows = comments, total = result.Total
            };

            return(Json(model));
        }
Beispiel #22
0
        public static void AddBrowsingProduct(long productId, long userId = 0)
        {
            List <ProductBrowsedHistoryModel> productIdList = new List <ProductBrowsedHistoryModel>();
            string productIds = Core.Helper.WebHelper.GetCookie(CookieKeysCollection.Mall_PRODUCT_BROWSING_HISTORY);

            if (!string.IsNullOrEmpty(productIds))
            {
                var arr = productIds.Split(',');
                foreach (var a in arr)
                {
                    var item = a.Split('#');
                    if (item.Length > 1)
                    {
                        productIdList.Add(new ProductBrowsedHistoryModel()
                        {
                            ProductId = long.Parse(item[0]), BrowseTime = DateTime.Parse(item[1])
                        });
                    }
                    else
                    {
                        productIdList.Add(new ProductBrowsedHistoryModel()
                        {
                            ProductId = long.Parse(item[0]), BrowseTime = DateTime.Now
                        });
                    }
                }
            }
            if (productIdList.Count < 20 && !productIdList.Any(a => a.ProductId == productId))
            {
                productIdList.Add(new ProductBrowsedHistoryModel()
                {
                    ProductId = productId, BrowseTime = DateTime.Now
                });
            }
            else if (productIdList.Count >= 20 && !productIdList.Any(a => a.ProductId == productId))
            {
                productIdList.RemoveAt(productIdList.Count - 1);
                productIdList.Add(new ProductBrowsedHistoryModel()
                {
                    ProductId = productId, BrowseTime = DateTime.Now
                });
            }
            else
            {
                var model = productIdList.Where(a => a.ProductId == productId).FirstOrDefault();
                productIdList.Remove(model);
                productIdList.Add(new ProductBrowsedHistoryModel()
                {
                    ProductId = productId, BrowseTime = DateTime.Now
                });
            }
            if (userId == 0)
            {
                var productsStr = "";
                foreach (var item in productIdList)
                {
                    productsStr += item.ProductId + "#" + item.BrowseTime.ToString() + ",";
                }
                Core.Helper.WebHelper.SetCookie(CookieKeysCollection.Mall_PRODUCT_BROWSING_HISTORY, productsStr.TrimEnd(','), DateTime.Now.AddDays(7));
            }
            else
            {
                foreach (var item in productIdList)
                {
                    try
                    {
                        ProductManagerApplication.AddBrowsingProduct(new Entities.BrowsingHistoryInfo
                        {
                            MemberId   = userId,
                            BrowseTime = item.BrowseTime,
                            ProductId  = item.ProductId
                        });
                    }
                    catch
                    {
                        continue;
                    }
                }
                Core.Helper.WebHelper.DeleteCookie(CookieKeysCollection.Mall_PRODUCT_BROWSING_HISTORY);
            }
        }
Beispiel #23
0
        public JsonResult GetShopBranchs(long shopId, long regionId, bool getParent, string[] skuIds, int[] counts, int page, int rows, long shippingAddressId)
        {
            var shippingAddressInfo = ShippingAddressApplication.GetUserShippingAddress(shippingAddressId);
            int streetId = 0, districtId = 0;//收货地址的街道、区域

            var query = new ShopBranchQuery()
            {
                ShopId   = shopId,
                PageNo   = page,
                PageSize = rows,
                Status   = ShopBranchStatus.Normal,
                ShopBranchProductStatus = ShopBranchSkuStatus.Normal
            };

            if (shippingAddressInfo != null)
            {
                query.FromLatLng = string.Format("{0},{1}", shippingAddressInfo.Latitude, shippingAddressInfo.Longitude); //需要收货地址的经纬度
                streetId         = shippingAddressInfo.RegionId;
                var parentAreaInfo = RegionApplication.GetRegion(shippingAddressInfo.RegionId, Region.RegionLevel.Town);  //判断当前区域是否为第四级
                if (parentAreaInfo != null && parentAreaInfo.ParentId > 0)
                {
                    districtId = parentAreaInfo.ParentId;
                }
                else
                {
                    districtId = streetId; streetId = 0;
                }
            }
            bool hasLatLng = false;

            if (!string.IsNullOrWhiteSpace(query.FromLatLng))
            {
                hasLatLng = query.FromLatLng.Split(',').Length == 2;
            }

            var region = RegionApplication.GetRegion(regionId, getParent ? Region.RegionLevel.City : Region.RegionLevel.County);

            if (region != null)
            {
                query.AddressPath = region.GetIdPath();
            }

            #region 旧排序规则
            //var skuInfos = ProductManagerApplication.GetSKUs(skuIds);

            //query.ProductIds = skuInfos.Select(p => p.ProductId).ToArray();
            //var data = ShopBranchApplication.GetShopBranchs(query);

            //var shopBranchSkus = ShopBranchApplication.GetSkus(shopId, data.Models.Select(p => p.Id));

            //var models = new
            //{
            //    Rows = data.Models.Select(sb => new
            //    {
            //        sb.ContactUser,
            //        sb.ContactPhone,
            //        sb.AddressDetail,
            //        sb.ShopBranchName,
            //        sb.Id,
            //        Enabled = skuInfos.All(skuInfo => shopBranchSkus.Any(sbSku => sbSku.ShopBranchId == sb.Id && sbSku.Stock >= counts[skuInfos.IndexOf(skuInfo)] && sbSku.SkuId == skuInfo.Id))
            //    }).OrderByDescending(p => p.Enabled).ToArray(),
            //    data.Total
            //};
            #endregion
            #region 3.0版本排序规则
            var skuInfos = ProductManagerApplication.GetSKUs(skuIds);
            query.ProductIds = skuInfos.Select(p => p.ProductId).ToArray();
            var data           = ShopBranchApplication.GetShopBranchsAll(query);
            var shopBranchSkus = ShopBranchApplication.GetSkus(shopId, data.Models.Select(p => p.Id).ToList());//获取该商家下具有订单内所有商品的门店状态正常数据,不考虑库存
            data.Models.ForEach(p =>
            {
                p.Enabled = skuInfos.All(skuInfo => shopBranchSkus.Any(sbSku => sbSku.ShopBranchId == p.Id && sbSku.Stock >= counts[skuInfos.IndexOf(skuInfo)] && sbSku.SkuId == skuInfo.Id));
            });

            List <ShopBranch> newList    = new List <ShopBranch>();
            List <long>       fillterIds = new List <long>();
            var currentList = data.Models.Where(p => hasLatLng && p.Enabled && (p.Latitude > 0 && p.Longitude > 0)).OrderBy(p => p.Distance).ToList();
            if (currentList != null && currentList.Count() > 0)
            {
                fillterIds.AddRange(currentList.Select(p => p.Id));
                newList.AddRange(currentList);
            }
            var currentList2 = data.Models.Where(p => !fillterIds.Contains(p.Id) && p.Enabled && p.AddressPath.Contains(CommonConst.ADDRESS_PATH_SPLIT + streetId + CommonConst.ADDRESS_PATH_SPLIT)).ToList();
            if (currentList2 != null && currentList2.Count() > 0)
            {
                fillterIds.AddRange(currentList2.Select(p => p.Id));
                newList.AddRange(currentList2);
            }
            var currentList3 = data.Models.Where(p => !fillterIds.Contains(p.Id) && p.Enabled && p.AddressPath.Contains(CommonConst.ADDRESS_PATH_SPLIT + districtId + CommonConst.ADDRESS_PATH_SPLIT)).ToList();
            if (currentList3 != null && currentList3.Count() > 0)
            {
                fillterIds.AddRange(currentList3.Select(p => p.Id));
                newList.AddRange(currentList3);
            }
            var currentList4 = data.Models.Where(p => !fillterIds.Contains(p.Id) && p.Enabled).ToList();//非同街、非同区,但一定会同市
            if (currentList4 != null && currentList4.Count() > 0)
            {
                fillterIds.AddRange(currentList4.Select(p => p.Id));
                newList.AddRange(currentList4);
            }
            var currentList5 = data.Models.Where(p => !fillterIds.Contains(p.Id)).ToList();//库存不足的排最后
            if (currentList5 != null && currentList5.Count() > 0)
            {
                newList.AddRange(currentList5);
            }
            if (newList.Count() != data.Models.Count())//如果新组合的数据与原数据数量不一致,则异常
            {
                return(Json <dynamic>(true, data: new { Rows = "" }, camelCase: true));
            }
            var needDistance = false;
            if (shippingAddressInfo != null && shippingAddressInfo.Latitude != 0 && shippingAddressInfo.Longitude != 0)
            {
                needDistance = true;
            }
            var models = new
            {
                Rows = newList.Select(sb => new
                {
                    sb.ContactUser,
                    sb.ContactPhone,
                    sb.AddressDetail,
                    sb.ShopBranchName,
                    sb.Id,
                    Enabled  = sb.Enabled,
                    Distance = needDistance ? RegionApplication.GetDistance(sb.Latitude, sb.Longitude, shippingAddressInfo.Latitude, shippingAddressInfo.Longitude) : 0
                }).ToArray(),
                Total = newList.Count
            };
            #endregion
            return(SuccessResult <dynamic>(data: models, camelCase: true));
        }
Beispiel #24
0
        public static List <ProductBrowsedHistoryModel> GetBrowsingProducts(int num, long userId = 0)
        {
            List <ProductBrowsedHistoryModel> productIdList = new List <ProductBrowsedHistoryModel>();
            string productIds = Core.Helper.WebHelper.GetCookie(CookieKeysCollection.Mall_PRODUCT_BROWSING_HISTORY);

            if (!string.IsNullOrEmpty(productIds))
            {
                var arr = productIds.Split(',');
                foreach (var a in arr)
                {
                    var item = a.Split('#');
                    if (item.Length > 1)
                    {
                        productIdList.Add(new ProductBrowsedHistoryModel()
                        {
                            ProductId = long.Parse(item[0]), BrowseTime = DateTime.Parse(item[1])
                        });
                    }
                    else
                    {
                        productIdList.Add(new ProductBrowsedHistoryModel()
                        {
                            ProductId = long.Parse(item[0]), BrowseTime = DateTime.Now
                        });
                    }
                }
            }

            var ids = productIdList.Select(p => p.ProductId).ToList();
            List <FlashSalePrice> flashSaleList = LimitTimeApplication.GetPriceByProducrIds(ids);

            List <ProductBrowsedHistoryModel> model = new List <ProductBrowsedHistoryModel>();

            if (userId == 0)
            {
                var products = ProductManagerApplication.GetProductByIds(productIdList.Select(a => a.ProductId))
                               .Where(d => d.SaleStatus == Entities.ProductInfo.ProductSaleStatus.OnSale &&
                                      d.AuditStatus == Entities.ProductInfo.ProductAuditStatus.Audited).ToArray()
                               .Select(a => new ProductBrowsedHistoryModel()
                {
                    ImagePath    = Core.MallIO.GetProductSizeImage(a.RelativePath, 1, (int)ImageSize.Size_100),
                    ProductId    = a.Id,
                    ProductName  = a.ProductName,
                    ProductPrice = GetRealPrice(flashSaleList, a.Id, a.MinSalePrice),
                    ShopId       = a.ShopId
                }).ToList();


                return(products.OrderByDescending(a => a.BrowseTime).ToList());
            }
            else
            {
                foreach (var m in productIdList)
                {
                    AddBrowsingProduct(m.ProductId, userId);
                }
                var browsing = ProductManagerApplication.GetBrowsingProducts(userId);
                var products = ProductManagerApplication.GetOnSaleProducts(browsing.Select(p => p.ProductId).ToList());
                browsing = browsing.Where(p => products.Select(o => o.Id).Contains(p.ProductId)).ToList();
                model    =
                    browsing.OrderByDescending(a => a.BrowseTime).Take(num)
                    .Select(a => {
                    var product = products.FirstOrDefault(p => p.Id == a.ProductId);
                    return(new ProductBrowsedHistoryModel()
                    {
                        ImagePath = Core.MallIO.GetProductSizeImage(product.RelativePath, 1, (int)ImageSize.Size_100),
                        ProductId = a.ProductId,
                        ProductName = product.ProductName,
                        ProductPrice = GetRealPrice(flashSaleList, a.ProductId, product.MinSalePrice),
                        BrowseTime = a.BrowseTime,
                        ShopId = product.ShopId
                    });
                }).ToList();
            }
            return(model);
        }
        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("提交订单异常");
            }
        }
        /// <summary>
        /// 拼团活动商品详情
        /// </summary>
        /// <param name="id">拼团活动ID</param>
        /// /// <param name="grouId">团活动ID</param>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetActiveDetail(long id, long grouId = 0, bool isFirst = true, string ids = "")
        {
            var userList = new List <FightGroupOrderInfo>();
            var data     = FightGroupApplication.GetActive(id, true, true);
            FightGroupActiveModel result = data;

            //先初始化拼团商品主图
            result.InitProductImages();
            var imgpath = data.ProductImgPath;

            if (result != null)
            {
                result.IsEnd = true;
                if (data.EndTime.Date >= DateTime.Now.Date)
                {
                    result.IsEnd = false;
                }
                //商品图片地址修正
                result.ProductDefaultImage = HimallIO.GetRomoteProductSizeImage(imgpath, 1, (int)ImageSize.Size_350);
                result.ProductImgPath      = HimallIO.GetRomoteProductSizeImage(imgpath, 1);
            }
            if (result.ProductImages != null)
            {//将主图相对路径处理为绝对路径
                result.ProductImages = result.ProductImages.Select(e => HimallIO.GetRomoteImagePath(e)).ToList();
            }

            if (!string.IsNullOrWhiteSpace(result.IconUrl))
            {
                result.IconUrl = Himall.Core.HimallIO.GetRomoteImagePath(result.IconUrl);
            }
            bool IsUserEnter = false;
            long currentUser = 0;

            if (CurrentUser != null)
            {
                currentUser = CurrentUser.Id;
            }
            if (grouId > 0)//获取已参团的用户
            {
                userList = ServiceProvider.Instance <IFightGroupService> .Create.GetActiveUsers(id, grouId);

                foreach (var item in userList)
                {
                    item.Photo        = !string.IsNullOrWhiteSpace(item.Photo) ? Core.HimallIO.GetRomoteImagePath(item.Photo) : "";
                    item.HeadUserIcon = !string.IsNullOrWhiteSpace(item.HeadUserIcon) ? Core.HimallIO.GetRomoteImagePath(item.HeadUserIcon) : "";
                    if (currentUser.Equals(item.OrderUserId))
                    {
                        IsUserEnter = true;
                    }
                }
            }
            #region 商品规格
            var product = ProductManagerApplication.GetProduct((long)result.ProductId);

            ProductShowSkuInfoModel model = new ProductShowSkuInfoModel();
            model.MinSalePrice     = data.MiniSalePrice;
            model.ProductImagePath = string.IsNullOrWhiteSpace(imgpath) ? "" : HimallIO.GetRomoteProductSizeImage(imgpath, 1, (int)Himall.CommonModel.ImageSize.Size_350);

            List <SKUDataModel> skudata = data.ActiveItems.Where(d => d.ActiveStock > 0).Select(d => new SKUDataModel
            {
                SkuId     = d.SkuId,
                Color     = d.Color,
                Size      = d.Size,
                Version   = d.Version,
                Stock     = (int)d.ActiveStock,
                CostPrice = d.ProductCostPrice,
                SalePrice = d.ProductPrice,
                Price     = d.ActivePrice,
            }).ToList();

            Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.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;
            }
            model.ColorAlias   = colorAlias;
            model.SizeAlias    = sizeAlias;
            model.VersionAlias = versionAlias;

            if (result.ActiveItems != null && result.ActiveItems.Count() > 0)
            {
                long colorId = 0, sizeId = 0, versionId = 0;
                var  skus = ProductManagerApplication.GetSKUs((long)result.ProductId);
                foreach (var sku in result.ActiveItems)
                {
                    var specs = sku.SkuId.Split('_');
                    if (specs.Count() > 0 && !string.IsNullOrEmpty(sku.Color))
                    {
                        if (long.TryParse(specs[1], out colorId))
                        {
                        }
                        if (colorId != 0)
                        {
                            if (!model.Color.Any(v => v.Value.Equals(sku.Color)))
                            {
                                var c = result.ActiveItems.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.ActiveStock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色",
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? " " : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = string.IsNullOrWhiteSpace(sku.ShowPic) ? "" : Core.HimallIO.GetRomoteImagePath(sku.ShowPic)
                                });
                            }
                        }
                    }
                    if (specs.Count() > 1 && !string.IsNullOrEmpty(sku.Size))
                    {
                        if (long.TryParse(specs[2], out sizeId))
                        {
                        }
                        if (sizeId != 0)
                        {
                            if (!model.Size.Any(v => v.Value.Equals(sku.Size)))
                            {
                                var ss = result.ActiveItems.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.ActiveStock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码",
                                    Name          = "选择" + sizeAlias,
                                    EnabledClass  = ss != 0 ? "enabled" : "disabled",
                                    SelectedClass = "",
                                    SkuId         = sizeId,
                                    Value         = sku.Size
                                });
                            }
                        }
                    }

                    if (specs.Count() > 2 && !string.IsNullOrEmpty(sku.Version))
                    {
                        if (long.TryParse(specs[3], out versionId))
                        {
                        }
                        if (versionId != 0)
                        {
                            if (!model.Version.Any(v => v.Value.Equals(sku.Version)))
                            {
                                var v = result.ActiveItems.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.ActiveStock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择规格",
                                    Name          = "选择" + versionAlias,
                                    EnabledClass  = v != 0 ? "enabled" : "disabled",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
            }
            #endregion

            var cashDepositModel = CashDepositsApplication.GetCashDepositsObligation((long)result.ProductId);//提供服务(消费者保障、七天无理由、及时发货)

            var GroupsData = new List <FightGroupsListModel>();
            List <FightGroupBuildStatus> stlist = new List <FightGroupBuildStatus>();
            stlist.Add(FightGroupBuildStatus.Ongoing);
            GroupsData = FightGroupApplication.GetGroups(id, stlist, null, null, 1, 10).Models.ToList();
            foreach (var item in GroupsData)
            {
                TimeSpan mid = item.AddGroupTime.AddHours((double)item.LimitedHour) - DateTime.Now;
                item.Seconds         = (int)mid.TotalSeconds;
                item.EndHourOrMinute = item.ShowHourOrMinute(item.GetEndHour);
                item.HeadUserIcon    = !string.IsNullOrWhiteSpace(item.HeadUserIcon) ? Core.HimallIO.GetRomoteImagePath(item.HeadUserIcon) : "";
            }

            #region 商品评论
            ProductCommentShowModel modelSay = new ProductCommentShowModel();
            modelSay.ProductId = (long)result.ProductId;
            var productSay = ProductManagerApplication.GetProduct((long)result.ProductId);
            modelSay.CommentList       = new List <ProductDetailCommentModel>();
            modelSay.IsShowColumnTitle = true;
            modelSay.IsShowCommentList = true;

            if (productSay == null)
            {
                //跳转到404页面
                throw new Core.HimallException("商品不存在");
            }
            var comments = CommentApplication.GetCommentsByProduct(product.Id);
            modelSay.CommentCount = comments.Count;
            if (comments.Count > 0)
            {
                var comment   = comments.OrderByDescending(a => a.ReviewDate).FirstOrDefault();
                var orderItem = OrderApplication.GetOrderItem(comment.SubOrderId);
                var order     = OrderApplication.GetOrder(orderItem.OrderId);
                modelSay.CommentList = comments.OrderByDescending(a => a.ReviewDate)
                                       .Take(1)
                                       .Select(c => {
                    var images = CommentApplication.GetProductCommentImagesByCommentIds(new List <long> {
                        c.Id
                    });
                    return(new ProductDetailCommentModel
                    {
                        Sku = ServiceProvider.Instance <IProductService> .Create.GetSkuString(orderItem.SkuId),
                        UserName = c.UserName,
                        ReviewContent = c.ReviewContent,
                        AppendContent = c.AppendContent,
                        AppendDate = c.AppendDate,
                        ReplyAppendContent = c.ReplyAppendContent,
                        ReplyAppendDate = c.ReplyAppendDate,
                        FinshDate = order.FinishDate,
                        Images = images.Where(a => a.CommentType == 0).Select(a => a.CommentImage).ToList(),
                        AppendImages = images.Where(a => a.CommentType == 1).Select(a => a.CommentImage).ToList(),
                        ReviewDate = c.ReviewDate,
                        ReplyContent = string.IsNullOrWhiteSpace(c.ReplyContent) ? "暂无回复" : c.ReplyContent,
                        ReplyDate = c.ReplyDate,
                        ReviewMark = c.ReviewMark,
                        BuyDate = order.OrderDate
                    });
                }).ToList();
                foreach (var citem in modelSay.CommentList)
                {
                    if (citem.Images.Count > 0)
                    {
                        for (var _imgn = 0; _imgn < citem.Images.Count; _imgn++)
                        {
                            citem.Images[_imgn] = Himall.Core.HimallIO.GetRomoteImagePath(citem.Images[_imgn]);
                        }
                    }
                    if (citem.AppendImages.Count > 0)
                    {
                        for (var _imgn = 0; _imgn < citem.AppendImages.Count; _imgn++)
                        {
                            citem.AppendImages[_imgn] = Himall.Core.HimallIO.GetRomoteImagePath(citem.AppendImages[_imgn]);
                        }
                    }
                }
            }
            #endregion

            #region 店铺信息
            VShopShowShopScoreModel modelShopScore = new VShopShowShopScoreModel();
            modelShopScore.ShopId = result.ShopId;
            var shop = ServiceProvider.Instance <IShopService> .Create.GetShop(result.ShopId);

            if (shop == null)
            {
                throw new HimallException("错误的店铺信息");
            }

            modelShopScore.ShopName = shop.ShopName;

            #region 获取店铺的评价统计
            var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(result.ShopId);

            var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault();
            var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault();
            var sellerDeliverySpeed   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                         Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault();

            var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault();
            var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault();
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                             Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault();

            var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault();
            var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault();

            var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault();
            var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault();

            var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault();
            var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault();

            decimal defaultValue = 5;

            modelShopScore.SellerServiceAttitude     = defaultValue;
            modelShopScore.SellerServiceAttitudePeer = defaultValue;
            modelShopScore.SellerServiceAttitudeMax  = defaultValue;
            modelShopScore.SellerServiceAttitudeMin  = defaultValue;

            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null && !shop.IsSelf)
            {
                modelShopScore.ProductAndDescription     = productAndDescription.CommentValue;
                modelShopScore.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                modelShopScore.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                modelShopScore.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                modelShopScore.ProductAndDescription     = defaultValue;
                modelShopScore.ProductAndDescriptionPeer = defaultValue;
                modelShopScore.ProductAndDescriptionMin  = defaultValue;
                modelShopScore.ProductAndDescriptionMax  = defaultValue;
            }

            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null && !shop.IsSelf)
            {
                modelShopScore.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                modelShopScore.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                modelShopScore.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                modelShopScore.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                modelShopScore.SellerServiceAttitude     = defaultValue;
                modelShopScore.SellerServiceAttitudePeer = defaultValue;
                modelShopScore.SellerServiceAttitudeMax  = defaultValue;
                modelShopScore.SellerServiceAttitudeMin  = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null && !shop.IsSelf)
            {
                modelShopScore.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                modelShopScore.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                modelShopScore.SellerDeliverySpeedMax  = sellerDeliverySpeedMax != null ? sellerDeliverySpeedMax.CommentValue : 0;
                modelShopScore.sellerDeliverySpeedMin  = sellerDeliverySpeedMin != null ? sellerDeliverySpeedMin.CommentValue : 0;
            }
            else
            {
                modelShopScore.SellerDeliverySpeed     = defaultValue;
                modelShopScore.SellerDeliverySpeedPeer = defaultValue;
                modelShopScore.SellerDeliverySpeedMax  = defaultValue;
                modelShopScore.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion

            modelShopScore.ProductNum = ServiceProvider.Instance <IProductService> .Create.GetShopOnsaleProducts(result.ShopId);

            modelShopScore.IsFavoriteShop    = false;
            modelShopScore.FavoriteShopCount = ServiceProvider.Instance <IShopService> .Create.GetShopFavoritesCount(result.ShopId);

            if (CurrentUser != null)
            {
                modelShopScore.IsFavoriteShop = ServiceProvider.Instance <IShopService> .Create.GetFavoriteShopInfos(CurrentUser.Id).Any(d => d.ShopId == result.ShopId);
            }

            long vShopId;
            var  vshopinfo = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id);

            if (vshopinfo == null)
            {
                vShopId = -1;
            }
            else
            {
                vShopId = vshopinfo.Id;
            }
            modelShopScore.VShopId  = vShopId;
            modelShopScore.VShopLog = ServiceProvider.Instance <IVShopService> .Create.GetVShopLog(vShopId);

            if (!string.IsNullOrWhiteSpace(modelShopScore.VShopLog))
            {
                modelShopScore.VShopLog = Himall.Core.HimallIO.GetRomoteImagePath(modelShopScore.VShopLog);
            }

            // 客服
            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(shop.Id);
            #endregion
            #region 根据运费模板获取发货地址
            var    freightTemplateService = ServiceApplication.Create <IFreightTemplateService>();
            var    template       = freightTemplateService.GetFreightTemplate(product.FreightTemplateId);
            string productAddress = string.Empty;
            if (template != null)
            {
                var fullName = ServiceApplication.Create <IRegionService>().GetFullName(template.SourceAddress);
                if (fullName != null)
                {
                    var ass = fullName.Split(' ');
                    if (ass.Length >= 2)
                    {
                        productAddress = ass[0] + " " + ass[1];
                    }
                    else
                    {
                        productAddress = ass[0];
                    }
                }
            }

            var ProductAddress  = productAddress;
            var FreightTemplate = template;
            #endregion

            #region 获取店铺优惠信息
            VShopShowPromotionModel modelVshop = new VShopShowPromotionModel();
            modelVshop.ShopId = result.ShopId;
            var shopInfo = ServiceProvider.Instance <IShopService> .Create.GetShop(result.ShopId);

            if (shopInfo == null)
            {
                throw new HimallException("错误的店铺编号");
            }

            modelVshop.FreeFreight = shop.FreeFreight;


            var bonus = ServiceApplication.Create <IShopBonusService>().GetByShopId(result.ShopId);
            if (bonus != null)
            {
                modelVshop.BonusCount             = bonus.Count;
                modelVshop.BonusGrantPrice        = bonus.GrantPrice;
                modelVshop.BonusRandomAmountStart = bonus.RandomAmountStart;
                modelVshop.BonusRandomAmountEnd   = bonus.RandomAmountEnd;
            }
            FullDiscountActive fullDiscount = null;
            //var fullDiscount = FullDiscountApplication.GetOngoingActiveByProductId(id, shop.Id);
            #endregion
            //商品描述

            var description = ProductManagerApplication.GetProductDescription(result.ProductId);
            if (description == null)
            {
                throw new HimallException("错误的商品编号");
            }

            string DescriptionPrefix = "", DescriptiondSuffix = "";
            var    iprodestempser = ServiceApplication.Create <IProductDescriptionTemplateService>();
            if (description.DescriptionPrefixId != 0)
            {
                var desc = iprodestempser.GetTemplate(description.DescriptionPrefixId, product.ShopId);
                DescriptionPrefix = desc == null ? "" : desc.MobileContent;
            }

            if (description.DescriptiondSuffixId != 0)
            {
                var desc = iprodestempser.GetTemplate(description.DescriptiondSuffixId, product.ShopId);
                DescriptiondSuffix = desc == null ? "" : desc.MobileContent;
            }
            var productDescription = DescriptionPrefix + description.ShowMobileDescription + DescriptiondSuffix;
            //统计商品浏览量、店铺浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);

            AutoMapper.Mapper.CreateMap <FightGroupActiveModel, FightGroupActiveResult>();
            var     fightGroupData = AutoMapper.Mapper.Map <FightGroupActiveResult>(result);
            decimal discount       = 1M;
            if (CurrentUser != null)
            {
                discount = CurrentUser.MemberDiscount;
            }
            var shopItem = ShopApplication.GetShop(result.ShopId);
            fightGroupData.MiniSalePrice = shopItem.IsSelf ? fightGroupData.MiniSalePrice * discount : fightGroupData.MiniSalePrice;

            string loadShowPrice = string.Empty;//app拼团详细页加载时显示的区间价
            loadShowPrice = fightGroupData.MiniSalePrice.ToString("f2");

            if (fightGroupData != null && fightGroupData.ActiveItems.Count() > 0)
            {
                decimal min = fightGroupData.ActiveItems.Min(s => s.ActivePrice);
                decimal max = fightGroupData.ActiveItems.Max(s => s.ActivePrice);
                loadShowPrice = (min < max) ? (min.ToString("f2") + " - " + max.ToString("f2")) : min.ToString("f2");
            }

            var _result = new
            {
                success        = true,
                FightGroupData = fightGroupData,
                ShowSkuInfo    = new
                {
                    ColorAlias       = model.ColorAlias,
                    SizeAlias        = model.SizeAlias,
                    VersionAlias     = model.VersionAlias,
                    MinSalePrice     = model.MinSalePrice,
                    ProductImagePath = model.ProductImagePath,
                    Color            = model.Color.OrderByDescending(p => p.SkuId),
                    Size             = model.Size.OrderByDescending(p => p.SkuId),
                    Version          = model.Version.OrderByDescending(p => p.SkuId)
                },
                ShowPromotion       = modelVshop,
                fullDiscount        = fullDiscount,
                ShowNewCanJoinGroup = GroupsData,
                ProductCommentShow  = modelSay,
                ProductDescription  = productDescription.Replace("src=\"/Storage/", "src=\"" + Core.HimallIO.GetRomoteImagePath("/Storage") + "/"),
                ShopScore           = modelShopScore,
                CashDepositsServer  = cashDepositModel,
                ProductAddress      = ProductAddress,
                //Free = FreightTemplate.IsFree == FreightTemplateType.Free ? "免运费" : "",
                userList              = userList,
                IsUserEnter           = IsUserEnter,
                SkuData               = skudata,
                CustomerServices      = customerServices,
                IsOpenLadder          = product.IsOpenLadder,
                VideoPath             = string.IsNullOrWhiteSpace(product.VideoPath) ? string.Empty : Himall.Core.HimallIO.GetRomoteImagePath(product.VideoPath),
                LoadShowPrice         = loadShowPrice,                                                                                                           //商品时区间价
                ProductSaleCountOnOff = (SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1),                                                        //是否显示销量
                SaleCounts            = data.ActiveItems.Sum(d => d.BuyCount),                                                                                   //销量
                FreightStr            = FreightTemplateApplication.GetFreightStr(product.Id, FreightTemplate, CurrentUser, product),                             //运费多少或免运费
                SendTime              = (FreightTemplate != null && !string.IsNullOrEmpty(FreightTemplate.SendTime) ? (FreightTemplate.SendTime + "h内发货") : ""), //运费模板发货时间
            };
            return(JsonResult <dynamic>(_result));
        }
        public object GetShopBranchs(long shopId, bool getParent, string skuIds, string counts, int page, int rows, long shippingAddressId, long regionId)
        {
            string[] _skuIds = skuIds.Split(',');
            int[] _counts = counts.Split(',').Select(p => Mall.Core.Helper.TypeHelper.ObjectToInt(p)).ToArray();

            var shippingAddressInfo = ShippingAddressApplication.GetUserShippingAddress(shippingAddressId);
            int streetId = 0, districtId = 0;//收货地址的街道、区域

            var query = new ShopBranchQuery()
            {
                ShopId = shopId,
                PageNo = page,
                PageSize = rows,
                Status = CommonModel.ShopBranchStatus.Normal,
                ShopBranchProductStatus = ShopBranchSkuStatus.Normal
            };
            if (shippingAddressInfo != null)
            {
                query.FromLatLng = string.Format("{0},{1}", shippingAddressInfo.Latitude, shippingAddressInfo.Longitude);//需要收货地址的经纬度
                streetId = shippingAddressInfo.RegionId;
                var parentAreaInfo = RegionApplication.GetRegion(shippingAddressInfo.RegionId, Region.RegionLevel.Town);//判断当前区域是否为第四级
                if (parentAreaInfo != null && parentAreaInfo.ParentId > 0) districtId = parentAreaInfo.ParentId;
                else { districtId = streetId; streetId = 0; }
            }
            bool hasLatLng = false;
            if (!string.IsNullOrWhiteSpace(query.FromLatLng)) hasLatLng = query.FromLatLng.Split(',').Length == 2;

            var region = RegionApplication.GetRegion(regionId, getParent ? CommonModel.Region.RegionLevel.City : CommonModel.Region.RegionLevel.County);//同城内门店
            if (region != null) query.AddressPath = region.GetIdPath();

            #region 3.0版本排序规则
            var skuInfos = ProductManagerApplication.GetSKUs(_skuIds);
            query.ProductIds = skuInfos.Select(p => p.ProductId).ToArray();
            var data = ShopBranchApplication.GetShopBranchsAll(query);
            var shopBranchSkus = ShopBranchApplication.GetSkus(shopId, data.Models.Select(p => p.Id).ToList());//获取该商家下具有订单内所有商品的门店状态正常数据,不考虑库存
            data.Models.ForEach(p =>
            {
                p.Enabled = skuInfos.All(skuInfo => shopBranchSkus.Any(sbSku => sbSku.ShopBranchId == p.Id && sbSku.Stock >= _counts[skuInfos.IndexOf(skuInfo)] && sbSku.SkuId == skuInfo.Id));
            });

            List<Mall.DTO.ShopBranch> newList = new List<Mall.DTO.ShopBranch>();
            List<long> fillterIds = new List<long>();
            var currentList = data.Models.Where(p => hasLatLng && p.Enabled && (p.Latitude > 0 && p.Longitude > 0)).OrderBy(p => p.Distance).ToList();
            if (currentList != null && currentList.Count() > 0)
            {
                fillterIds.AddRange(currentList.Select(p => p.Id));
                newList.AddRange(currentList);
            }
            var currentList2 = data.Models.Where(p => !fillterIds.Contains(p.Id) && p.Enabled && p.AddressPath.Contains(CommonConst.ADDRESS_PATH_SPLIT + streetId + CommonConst.ADDRESS_PATH_SPLIT)).ToList();
            if (currentList2 != null && currentList2.Count() > 0)
            {
                fillterIds.AddRange(currentList2.Select(p => p.Id));
                newList.AddRange(currentList2);
            }
            var currentList3 = data.Models.Where(p => !fillterIds.Contains(p.Id) && p.Enabled && p.AddressPath.Contains(CommonConst.ADDRESS_PATH_SPLIT + districtId + CommonConst.ADDRESS_PATH_SPLIT)).ToList();
            if (currentList3 != null && currentList3.Count() > 0)
            {
                fillterIds.AddRange(currentList3.Select(p => p.Id));
                newList.AddRange(currentList3);
            }
            var currentList4 = data.Models.Where(p => !fillterIds.Contains(p.Id) && p.Enabled).ToList();//非同街、非同区,但一定会同市
            if (currentList4 != null && currentList4.Count() > 0)
            {
                fillterIds.AddRange(currentList4.Select(p => p.Id));
                newList.AddRange(currentList4);
            }
            var currentList5 = data.Models.Where(p => !fillterIds.Contains(p.Id)).ToList();//库存不足的排最后
            if (currentList5 != null && currentList5.Count() > 0)
            {
                newList.AddRange(currentList5);
            }
            if (newList.Count() != data.Models.Count())//如果新组合的数据与原数据数量不一致
            {
                return new
                {
                    success = false
                };
            }
            var needDistance = false;
            if (shippingAddressInfo != null && shippingAddressInfo.Latitude!=0 && shippingAddressInfo.Longitude!=0)
            {
                needDistance = true;
            }
            var storeList = newList.Select(sb =>
            {
                return new
                {
                    ContactUser = sb.ContactUser,
                    ContactPhone = sb.ContactPhone,
                    AddressDetail = sb.AddressDetail,
                    ShopBranchName = sb.ShopBranchName,
                    Id = sb.Id,
                    Enabled = sb.Enabled,
                    Distance = needDistance ? RegionApplication.GetDistance(sb.Latitude, sb.Longitude, shippingAddressInfo.Latitude, shippingAddressInfo.Longitude) : 0
                };
            });

            #endregion

            var result = new
            {
                success = true,
                StoreList = storeList
            };
            return result;
        }
Beispiel #28
0
        //APP首页配置共用于安卓和IOS,这里的平台类型写的为IOS,安卓调用首页接口数据时平台类型也选IOS
        public APPHome Get(int pageNo, int pageSize)
        {
            var slideImageSettings = ServiceProvider.Instance <ISlideAdsService> .Create.GetSlidAds(0, Entities.SlideAdInfo.SlideAdType.IOSShopHome);

            var images = ServiceProvider.Instance <ISlideAdsService> .Create.GetImageAds(0, Himall.CommonModel.ImageAdsType.APPSpecial).ToList();

            var     mhproser      = ServiceProvider.Instance <IMobileHomeProductsService> .Create;
            var     data          = mhproser.GetMobileHomeProducts(0, PlatformType.IOS, pageNo, pageSize);
            var     totalProducts = data.Total;
            var     homeProducts  = data.Models;
            decimal discount      = 1M;

            if (CurrentUser != null)
            {
                discount = CurrentUser.MemberDiscount;
            }
            var products = new List <HomeProduct>();

            var limitService = ServiceProvider.Instance <ILimitTimeBuyService> .Create;
            var fight        = FightGroupApplication.GetFightGroupPrice();
            var allProducts  = ProductManagerApplication.GetProducts(homeProducts.Select(p => p.ProductId));
            var allShops     = ShopApplication.GetShops(allProducts.Select(p => p.ShopId));

            foreach (var item in homeProducts)
            {
                var     limitBuy     = limitService.GetLimitTimeMarketItemByProductId(item.ProductId);
                var     product      = allProducts.FirstOrDefault(p => p.Id == item.ProductId);
                var     shop         = allShops.FirstOrDefault(p => p.Id == product.ShopId);
                decimal minSalePrice = shop.IsSelf ? product.MinSalePrice * discount : product.MinSalePrice;
                if (limitBuy != null)
                {
                    minSalePrice = limitBuy.MinPrice; //限时购不打折
                }
                var  isFight  = fight.Where(r => r.ProductId == item.ProductId).FirstOrDefault();
                long activeId = 0;
                if (isFight != null)
                {
                    minSalePrice = isFight.ActivePrice;
                    activeId     = isFight.ActiveId;
                }
                products.Add(new HomeProduct()
                {
                    Id           = item.ProductId.ToString(),
                    ImageUrl     = HimallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)CommonModel.ImageSize.Size_220),
                    Name         = product.ProductName,
                    MarketPrice  = product.MarketPrice.ToString(),
                    SalePrice    = minSalePrice.ToString("f2"),
                    Discount     = product.MarketPrice <= 0 ? "0" : (minSalePrice / product.MarketPrice).ToString("0.0"),
                    Url          = Core.HimallIO.GetRomoteImagePath("/m-ios/product/detail/" + item.ProductId),
                    FightGroupId = activeId
                });
            }

            var iconSettings = ServiceProvider.Instance <ISlideAdsService> .Create.GetSlidAds(0, Entities.SlideAdInfo.SlideAdType.APPIcon);

            var icon = iconSettings.ToArray().Select(item => new HomeSlides {
                Desc = item.Description, ImageUrl = Core.HimallIO.GetRomoteImagePath(item.ImageUrl), Url = item.Url
            });

            var services = CustomerServiceApplication.GetPlatformCustomerService(true, true);
            //var meiqia = CustomerServiceApplication.GetPlatformCustomerService(true, false).FirstOrDefault(p => p.Tool == Entities.CustomerServiceInfo.ServiceTool.MeiQia);
            //if (meiqia != null)
            //    services.Insert(0, meiqia);

            APPHome appHome = new APPHome();

            appHome.success = true;
            //2017年9月1号 商城首页接口修改(把原广告图片的去掉,只保留商品)
            appHome.TotalProduct = totalProducts;
            appHome.Icon         = icon;
            //appHome.Slide = slides;//轮播图数组
            //appHome.Topic = homeImage;//专题数组
            appHome.Product          = products;
            appHome.CustomerServices = services;
            return(appHome);
        }
        private List <OrderRefundApiModel> FullModel(List <OrderRefund> refunds)
        {
            var orders     = Application.OrderApplication.GetOrders(refunds.Select(p => p.OrderId));
            var orderItems = Application.OrderApplication.GetOrderItemsByOrderId(refunds.Select(p => p.OrderId));
            var members    = Application.MemberApplication.GetMembers(orders.Select(p => p.UserId).ToList());

            AutoMapper.Mapper.CreateMap <OrderRefund, OrderRefundApiModel>();
            var result = refunds.Select(item =>
            {
                var orditems = new List <DTO.OrderItem>();
                var order    = orders.FirstOrDefault(o => o.Id == item.OrderId);

                if (item.RefundMode == OrderRefundInfo.OrderRefundMode.OrderRefund)
                {
                    orditems = orderItems.Where(d => d.OrderId == item.OrderId).ToList();
                }
                else
                {
                    orditems.Add(orderItems.FirstOrDefault(oi => oi.Id == item.OrderItemId));
                }
                foreach (var orderItem in orditems)
                {
                    orderItem.ThumbnailsUrl    = HimallIO.GetRomoteProductSizeImage(orderItem.ThumbnailsUrl, 1, (int)Himall.CommonModel.ImageSize.Size_100);
                    Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetTypeByProductId(orderItem.ProductId);
                    orderItem.ColorAlias       = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                    orderItem.SizeAlias        = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                    orderItem.VersionAlias     = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
                    orderItem.ShipTo           = order.ShipTo;
                    orderItem.CellPhone        = order.CellPhone;
                    orderItem.RegionFullName   = order.RegionFullName;
                    orderItem.Address          = order.Address;
                    var productInfo            = ProductManagerApplication.GetProduct(orderItem.ProductId);
                    if (productInfo != null)
                    {
                        orderItem.ColorAlias   = !string.IsNullOrWhiteSpace(productInfo.ColorAlias) ? productInfo.ColorAlias : orderItem.ColorAlias;
                        orderItem.SizeAlias    = !string.IsNullOrWhiteSpace(productInfo.SizeAlias) ? productInfo.SizeAlias : orderItem.SizeAlias;
                        orderItem.VersionAlias = !string.IsNullOrWhiteSpace(productInfo.VersionAlias) ? productInfo.VersionAlias : orderItem.VersionAlias;
                    }
                }
                var member = members.FirstOrDefault(m => m.Id == order.UserId);

                var model    = item.Map <OrderRefundApiModel>();
                model.Status = item.SellerAuditStatus == OrderRefundInfo.OrderRefundAuditStatus.Audited ? (int)item.ManagerConfirmStatus : (int)item.SellerAuditStatus;
                //model.StatusDescription = item.SellerAuditStatus == OrderRefundInfo.OrderRefundAuditStatus.Audited ? item.ManagerConfirmStatus.ToDescription() : ((CommonModel.Enum.OrderRefundShopAuditStatus)item.SellerAuditStatus).ToDescription();
                model.StatusDescription = item.SellerAuditStatus == OrderRefundInfo.OrderRefundAuditStatus.Audited ? item.ManagerConfirmStatus.ToDescription() : (order.ShopBranchId > 0 ?
                                                                                                                                                                  ((CommonModel.Enum.OrderRefundShopAuditStatus)item.SellerAuditStatus).ToDescription() : item.SellerAuditStatus.ToDescription());
                //model.UserName = member == null ? "" : member.RealName;
                //model.UserCellPhone = member == null ? "" : member.CellPhone;
                model.IsShopBranchOrder = item.IsShopBranchOrder;
                if (item.IsShopBranchOrder)
                {
                    model.StatusDescription = model.StatusDescription.Replace("商家", "门店");
                    model.RefundStatus      = model.RefundStatus.Replace("商家", "门店");
                }
                model.UserName        = item.ContactPerson;
                model.UserCellPhone   = item.ContactCellPhone;
                model.OrderItem       = orditems;
                model.CertPics        = new string[3];
                model.CertPics[0]     = HimallIO.GetRomoteImagePath(model.CertPic1);
                model.CertPics[1]     = HimallIO.GetRomoteImagePath(model.CertPic2);
                model.CertPics[2]     = HimallIO.GetRomoteImagePath(model.CertPic3);
                string shopBranchName = order.ShopName;
                if (order.ShopBranchId > 0)
                {
                    var shopBranchInfo = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
                    if (shopBranchInfo != null)
                    {
                        shopBranchName = shopBranchInfo.ShopBranchName;
                    }
                }
                model.ShopName         = shopBranchName;
                model.ReasonDetail     = item.ReasonDetail;
                model.OrderTotalAmount = order.OrderTotalAmount;

                return(model);
            });

            return(result.ToList());
        }
        public object GetShopBranchs(long shopId, bool getParent, string skuIds, string counts, int page, int rows, long shippingAddressId, long regionId)
        {
            string[]            strArray            = skuIds.Split(',');
            int[]               _counts             = Enumerable.ToArray <int>(Enumerable.Select <string, int>((IEnumerable <string>)counts.Split(','), (Func <string, int>)(p => TypeHelper.ObjectToInt((object)p))));
            ShippingAddressInfo userShippingAddress = ShippingAddressApplication.GetUserShippingAddress(shippingAddressId);
            int             streetId        = 0;
            int             districtId      = 0;
            ShopBranchQuery shopBranchQuery = new ShopBranchQuery();

            shopBranchQuery.ShopId   = shopId;
            shopBranchQuery.PageNo   = page;
            shopBranchQuery.PageSize = rows;
            shopBranchQuery.Status   = new ShopBranchStatus?(ShopBranchStatus.Normal);
            ShopBranchQuery query = shopBranchQuery;

            if (userShippingAddress != null)
            {
                query.FromLatLng = string.Format("{0},{1}", (object)userShippingAddress.Latitude, (object)userShippingAddress.Longitude);
                streetId         = userShippingAddress.RegionId;
                Region region = RegionApplication.GetRegion((long)userShippingAddress.RegionId, Region.RegionLevel.Town);
                if (region != null && region.ParentId > 0)
                {
                    districtId = region.ParentId;
                }
                else
                {
                    districtId = streetId;
                    streetId   = 0;
                }
            }
            bool hasLatLng = false;

            if (!string.IsNullOrWhiteSpace(query.FromLatLng))
            {
                hasLatLng = (query.FromLatLng.Split(',').Length == 2 ? 1 : 0) != 0;
            }
            Region region1 = RegionApplication.GetRegion(regionId, getParent ? Region.RegionLevel.City : Region.RegionLevel.County);

            if (region1 != null)
            {
                query.AddressPath = region1.GetIdPath(",");
            }
            List <SKU> skuInfos = ProductManagerApplication.GetSKUs((IEnumerable <string>)strArray);

            query.ProductIds = Enumerable.ToArray <long>(Enumerable.Select <SKU, long>((IEnumerable <SKU>)skuInfos, (Func <SKU, long>)(p => p.ProductId)));
            QueryPageModel <ShopBranch> shopBranchsAll = ShopBranchApplication.GetShopBranchsAll(query);
            List <ShopBranchSkusInfo>   shopBranchSkus = ShopBranchApplication.GetSkus(shopId, Enumerable.Select <ShopBranch, long>((IEnumerable <ShopBranch>)shopBranchsAll.Models, (Func <ShopBranch, long>)(p => p.Id)));

            shopBranchsAll.Models.ForEach((Action <ShopBranch>)(p => p.Enabled = Enumerable.All <SKU>((IEnumerable <SKU>)skuInfos, (Func <SKU, bool>)(skuInfo => Enumerable.Any <ShopBranchSkusInfo>((IEnumerable <ShopBranchSkusInfo>)shopBranchSkus, (Func <ShopBranchSkusInfo, bool>)(sbSku => sbSku.ShopBranchId == p.Id && sbSku.Stock >= _counts[skuInfos.IndexOf(skuInfo)] && sbSku.SkuId == skuInfo.Id))))));
            List <ShopBranch> list1      = new List <ShopBranch>();
            List <long>       fillterIds = new List <long>();
            List <ShopBranch> list2      = Enumerable.ToList <ShopBranch>((IEnumerable <ShopBranch>)Enumerable.OrderBy <ShopBranch, double>(Enumerable.Where <ShopBranch>((IEnumerable <ShopBranch>)shopBranchsAll.Models, (Func <ShopBranch, bool>)(p => hasLatLng && p.Enabled && ((double)p.Latitude > 0.0 && (double)p.Longitude > 0.0))), (Func <ShopBranch, double>)(p => p.Distance)));

            if (list2 != null && Enumerable.Count <ShopBranch>((IEnumerable <ShopBranch>)list2) > 0)
            {
                fillterIds.AddRange(Enumerable.Select <ShopBranch, long>((IEnumerable <ShopBranch>)list2, (Func <ShopBranch, long>)(p => p.Id)));
                list1.AddRange((IEnumerable <ShopBranch>)list2);
            }
            List <ShopBranch> list3 = Enumerable.ToList <ShopBranch>(Enumerable.Where <ShopBranch>((IEnumerable <ShopBranch>)shopBranchsAll.Models, (Func <ShopBranch, bool>)(p => !fillterIds.Contains(p.Id) && p.Enabled && p.AddressPath.Contains("," + (object)streetId + ","))));

            if (list3 != null && Enumerable.Count <ShopBranch>((IEnumerable <ShopBranch>)list3) > 0)
            {
                fillterIds.AddRange(Enumerable.Select <ShopBranch, long>((IEnumerable <ShopBranch>)list3, (Func <ShopBranch, long>)(p => p.Id)));
                list1.AddRange((IEnumerable <ShopBranch>)list3);
            }
            List <ShopBranch> list4 = Enumerable.ToList <ShopBranch>(Enumerable.Where <ShopBranch>((IEnumerable <ShopBranch>)shopBranchsAll.Models, (Func <ShopBranch, bool>)(p => !fillterIds.Contains(p.Id) && p.Enabled && p.AddressPath.Contains("," + (object)districtId + ","))));

            if (list4 != null && Enumerable.Count <ShopBranch>((IEnumerable <ShopBranch>)list4) > 0)
            {
                fillterIds.AddRange(Enumerable.Select <ShopBranch, long>((IEnumerable <ShopBranch>)list4, (Func <ShopBranch, long>)(p => p.Id)));
                list1.AddRange((IEnumerable <ShopBranch>)list4);
            }
            List <ShopBranch> list5 = Enumerable.ToList <ShopBranch>(Enumerable.Where <ShopBranch>((IEnumerable <ShopBranch>)shopBranchsAll.Models, (Func <ShopBranch, bool>)(p => !fillterIds.Contains(p.Id) && p.Enabled)));

            if (list5 != null && Enumerable.Count <ShopBranch>((IEnumerable <ShopBranch>)list5) > 0)
            {
                fillterIds.AddRange(Enumerable.Select <ShopBranch, long>((IEnumerable <ShopBranch>)list5, (Func <ShopBranch, long>)(p => p.Id)));
                list1.AddRange((IEnumerable <ShopBranch>)list5);
            }
            List <ShopBranch> list6 = Enumerable.ToList <ShopBranch>(Enumerable.Where <ShopBranch>((IEnumerable <ShopBranch>)shopBranchsAll.Models, (Func <ShopBranch, bool>)(p => !fillterIds.Contains(p.Id))));

            if (list6 != null && Enumerable.Count <ShopBranch>((IEnumerable <ShopBranch>)list6) > 0)
            {
                list1.AddRange((IEnumerable <ShopBranch>)list6);
            }
            if (Enumerable.Count <ShopBranch>((IEnumerable <ShopBranch>)list1) != Enumerable.Count <ShopBranch>((IEnumerable <ShopBranch>)shopBranchsAll.Models))
            {
                return((object)this.Json(new
                {
                    Success = false
                }));
            }
            var content = new
            {
                Success   = true,
                StoreList = Enumerable.Select((IEnumerable <ShopBranch>)list1, sb =>
                {
                    var fAnonymousType37 = new
                    {
                        ContactUser    = sb.ContactUser,
                        ContactPhone   = sb.ContactPhone,
                        AddressDetail  = sb.AddressDetail,
                        ShopBranchName = sb.ShopBranchName,
                        Id             = sb.Id,
                        Enabled        = sb.Enabled
                    };
                    return(fAnonymousType37);
                })
            };

            return((object)this.Json(content));
        }