public void UpdateShopProductModuleProducts(long shopId, long id, IEnumerable <long> productIds)
        {
            ShopHomeModuleInfo shopHomeModuleInfo = context.ShopHomeModuleInfo.FirstOrDefault((ShopHomeModuleInfo item) => item.Id == id && item.ShopId == shopId);

            if (shopHomeModuleInfo == null)
            {
                throw new HimallException("在本店铺中未找到指定商品模块");
            }
            ShopHomeModuleProductInfo[] array = shopHomeModuleInfo.ShopHomeModuleProductInfo.ToArray();
            IEnumerable <long>          nums  =
                from item in array
                where !productIds.Contains(item.ProductId)
                select item.Id;
            IEnumerable <long> productId =
                from item in array
                select item.ProductId;
            IEnumerable <long> nums1 =
                from item in productIds
                where !productId.Contains(item)
                select item;

            context.ShopHomeModuleProductInfo.OrderBy((ShopHomeModuleProductInfo item) => nums.Contains(item.Id));
            foreach (long list in nums1.ToList())
            {
                ShopHomeModuleProductInfo shopHomeModuleProductInfo = new ShopHomeModuleProductInfo()
                {
                    ProductId    = list,
                    HomeModuleId = shopHomeModuleInfo.Id
                };
                context.ShopHomeModuleProductInfo.Add(shopHomeModuleProductInfo);
            }
            context.SaveChanges();
        }
Exemple #2
0
        public void AddShopProductModule(ShopHomeModuleInfo shopProductModuleInfo)
        {
            if (string.IsNullOrWhiteSpace(shopProductModuleInfo.Name))
            {
                throw new InvalidPropertyException("商品模块名称不能为空");
            }

            DbFactory.Default.Add(shopProductModuleInfo);
        }
 public void AddShopProductModule(ShopHomeModuleInfo shopProductModuleInfo)
 {
     if (string.IsNullOrWhiteSpace(shopProductModuleInfo.Name))
     {
         throw new InvalidPropertyException("商品模块名称不能为空");
     }
     context.ShopHomeModuleInfo.Add(shopProductModuleInfo);
     context.SaveChanges();
 }
        public void UpdateShopProductModuleName(long shopId, long id, string name)
        {
            ShopHomeModuleInfo shopHomeModuleInfo = context.ShopHomeModuleInfo.FirstOrDefault((ShopHomeModuleInfo item) => item.Id == id && item.ShopId == shopId);

            if (shopHomeModuleInfo == null)
            {
                throw new HimallException("在本店铺中未找到指定商品模块");
            }
            shopHomeModuleInfo.Name = name;
            context.SaveChanges();
        }
Exemple #5
0
        public void AddShopProductModuleTest()
        {
            var service        = Instance <IShopHomeModuleService> .Create;
            var shopHomeModule = new ShopHomeModuleInfo()
            {
                Name   = DateTime.Now.ToString("name_yyyyMMddHHmmss"),
                ShopId = SHOPID
            };

            service.AddShopProductModule(shopHomeModule);
        }
Exemple #6
0
        public ActionResult EditFloor(long?id = 0)
        {
            ShopHomeModuleInfo info = null;

            if (id != null && id > 0)
            {
                info = _iShopHomeModuleService.GetShopHomeModuleInfo(CurrentSellerManager.ShopId, ( int )id);
            }
            else
            {
                info = new ShopHomeModuleInfo();
            }
            return(View(info));
        }
Exemple #7
0
        public void GetShopHomeModuleInfoTest()
        {
            var service        = Instance <IShopHomeModuleService> .Create;
            var shopHomeModule = new ShopHomeModuleInfo()
            {
                Name   = DateTime.Now.ToString("name_yyyyMMddHHmmss"),
                ShopId = SHOPID
            };

            service.AddShopProductModule(shopHomeModule);

            var updatedShopHomeModule = service.GetShopHomeModuleInfo(SHOPID, shopHomeModule.Id);

            Assert.AreEqual(shopHomeModule.Name, updatedShopHomeModule.Name);
        }
        public JsonResult AddShopHomeModule(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new InvalidPropertyException("名称不能为空");
            }
            ShopHomeModuleInfo shopHomeModuleInfo = new ShopHomeModuleInfo()
            {
                ShopId = base.CurrentSellerManager.ShopId,
                Name   = name.Trim()
            };
            ShopHomeModuleInfo shopHomeModuleInfo1 = shopHomeModuleInfo;

            ServiceHelper.Create <IShopHomeModuleService>().AddShopProductModule(shopHomeModuleInfo1);
            return(Json(new { success = true, name = shopHomeModuleInfo1.Name, id = shopHomeModuleInfo1.Id }));
        }
Exemple #9
0
        public JsonResult AddShopHomeModule(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new InvalidPropertyException("名称不能为空");
            }

            var shopHomeModule = new ShopHomeModuleInfo()
            {
                ShopId = CurrentSellerManager.ShopId,
                Name   = name.Trim()
            };

            _iShopHomeModuleService.AddShopProductModule(shopHomeModule);
            return(Json(new { success = true, name = shopHomeModule.Name, id = shopHomeModule.Id }));
        }
Exemple #10
0
        public void UpdateShopProductModuleProductsTest()
        {
            var service        = Instance <IShopHomeModuleService> .Create;
            var shopHomeModule = new ShopHomeModuleInfo()
            {
                Name   = DateTime.Now.ToString("name_yyyyMMddHHmmss"),
                ShopId = SHOPID
            };

            service.AddShopProductModule(shopHomeModule);

            var productIds = new long[] { 9, 10, 11, 12 };

            service.UpdateShopProductModuleProducts(SHOPID, shopHomeModule.Id, productIds);

            var updatedShopHomeModule = service.GetShopHomeModuleInfo(SHOPID, shopHomeModule.Id);

            Assert.AreEqual(productIds.Length, updatedShopHomeModule.ShopHomeModuleProductInfo.Count);
        }
Exemple #11
0
        public void SaveFloor(AddShopHomeModuleModel model)
        {
            if (model.Id <= 0) //新增
            {
                var rows  = DbFactory.Default.Get <ShopHomeModuleInfo>().Count();
                int count = rows > 0 ? DbFactory.Default.Get <ShopHomeModuleInfo>().Max <int>(p => p.DisplaySequence) : 0;
                ShopHomeModuleInfo main = new ShopHomeModuleInfo();
                main.Name            = model.Name;
                main.Url             = model.Url;
                main.ShopId          = model.ShopId;
                main.IsEnable        = true;
                main.DisplaySequence = count + 1;
                DbFactory.Default.Add(main);

                foreach (var p in model.Products)
                {
                    ShopHomeModuleProductInfo product = new ShopHomeModuleProductInfo();
                    product.HomeModuleId    = main.Id;
                    product.DisplaySequence = p.DisplaySequence;
                    product.ProductId       = p.ProductId;
                    DbFactory.Default.Add(product);
                }

                foreach (var t in model.TopImgs)
                {
                    var top = new ShopHomeModuleTopImgInfo();
                    top.HomeModuleId    = main.Id;
                    top.ImgPath         = t.ImgPath;
                    top.Url             = t.Url;
                    top.DisplaySequence = top.DisplaySequence;
                    DbFactory.Default.Add(top);
                }
            }
            else //修改
            {
                DbFactory.Default.Del <ShopHomeModuleProductInfo>(p => p.HomeModuleId == model.Id);
                DbFactory.Default.Del <ShopHomeModuleTopImgInfo>(p => p.HomeModuleId == model.Id);

                var main = DbFactory.Default.Get <ShopHomeModuleInfo>().Where(p => p.Id == model.Id).FirstOrDefault();
                main.Name = model.Name;
                main.Url  = model.Url;

                foreach (var p in model.Products)
                {
                    var product = new ShopHomeModuleProductInfo();
                    product.HomeModuleId    = main.Id;
                    product.DisplaySequence = p.DisplaySequence;
                    product.ProductId       = p.ProductId;
                    DbFactory.Default.Add(product);
                }

                foreach (var t in model.TopImgs)
                {
                    var top = new ShopHomeModuleTopImgInfo();
                    top.HomeModuleId    = main.Id;
                    top.ImgPath         = t.ImgPath;
                    top.Url             = t.Url;
                    top.DisplaySequence = top.DisplaySequence;
                    DbFactory.Default.Add(top);
                }
                DbFactory.Default.Update(main);
            }
        }
Exemple #12
0
        public ActionResult Home(string id)
        {
            int      i;
            long     num  = 0;
            ShopInfo shop = null;

            if (!long.TryParse(id, out num))
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            shop = ServiceHelper.Create <IShopService>().GetShop(num, false);
            if (shop == null)
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            ShopHomeModel shopHomeModel = new ShopHomeModel()
            {
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Floors       = new List <ShopHomeFloor>(),
                Navignations = new List <BannerInfo>(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Slides       = new List <SlideAdInfo>(),
                Logo         = ""
            };
            ShopHomeModel shopName = shopHomeModel;
            IQueryable <StatisticOrderCommentsInfo> shopStatisticOrderComments = ServiceHelper.Create <IShopService>().GetShopStatisticOrderComments(num);
            StatisticOrderCommentsInfo statisticOrderCommentsInfo = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 1
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo1 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 9
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo2 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 5
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo3 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 2
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo4 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 10
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo5 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 6
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo6 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 3
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo7 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 4
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo8 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 11
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo9 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 12
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo10 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 7
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo11 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 8
                select c).FirstOrDefault();
            int num1 = 5;

            if (statisticOrderCommentsInfo == null || statisticOrderCommentsInfo3 == null)
            {
                ViewBag.ProductAndDescription     = num1;
                ViewBag.ProductAndDescriptionPeer = num1;
                ViewBag.ProductAndDescriptionMin  = num1;
                ViewBag.ProductAndDescriptionMax  = num1;
            }
            else
            {
                ViewBag.ProductAndDescription     = statisticOrderCommentsInfo.CommentValue;
                ViewBag.ProductAndDescriptionPeer = statisticOrderCommentsInfo3.CommentValue;
                ViewBag.ProductAndDescriptionMin  = statisticOrderCommentsInfo7.CommentValue;
                ViewBag.ProductAndDescriptionMax  = statisticOrderCommentsInfo6.CommentValue;
            }
            if (statisticOrderCommentsInfo1 == null || statisticOrderCommentsInfo4 == null)
            {
                ViewBag.SellerServiceAttitude     = num1;
                ViewBag.SellerServiceAttitudePeer = num1;
                ViewBag.SellerServiceAttitudeMax  = num1;
                ViewBag.SellerServiceAttitudeMin  = num1;
            }
            else
            {
                ViewBag.SellerServiceAttitude     = statisticOrderCommentsInfo1.CommentValue;
                ViewBag.SellerServiceAttitudePeer = statisticOrderCommentsInfo4.CommentValue;
                ViewBag.SellerServiceAttitudeMax  = statisticOrderCommentsInfo8.CommentValue;
                ViewBag.SellerServiceAttitudeMin  = statisticOrderCommentsInfo9.CommentValue;
            }
            if (statisticOrderCommentsInfo5 == null || statisticOrderCommentsInfo2 == null)
            {
                ViewBag.SellerDeliverySpeed     = num1;
                ViewBag.SellerDeliverySpeedPeer = num1;
                ViewBag.SellerDeliverySpeedMax  = num1;
                ViewBag.sellerDeliverySpeedMin  = num1;
            }
            else
            {
                ViewBag.SellerDeliverySpeed     = statisticOrderCommentsInfo2.CommentValue;
                ViewBag.SellerDeliverySpeedPeer = statisticOrderCommentsInfo5.CommentValue;
                ViewBag.SellerDeliverySpeedMax  = statisticOrderCommentsInfo10.CommentValue;
                ViewBag.sellerDeliverySpeedMin  = statisticOrderCommentsInfo11.CommentValue;
            }
            ShopServiceMarkModel shopComprehensiveMark = ShopServiceMark.GetShopComprehensiveMark(shop.Id);

            shopName.Shop.Name              = shop.ShopName;
            shopName.Shop.CompanyName       = shop.CompanyName;
            shopName.Shop.Id                = shop.Id;
            shopName.Shop.PackMark          = shopComprehensiveMark.PackMark;
            shopName.Shop.ServiceMark       = shopComprehensiveMark.ServiceMark;
            shopName.Shop.ComprehensiveMark = shopComprehensiveMark.ComprehensiveMark;
            shopName.Shop.Phone             = shop.CompanyPhone;
            shopName.Shop.Address           = ServiceHelper.Create <IRegionService>().GetRegionFullName(shop.CompanyRegionId, " ");
            shopName.Logo         = shop.Logo;
            shopName.Navignations = ServiceHelper.Create <INavigationService>().GetSellerNavigations(shop.Id, PlatformType.PC).ToList();
            shopName.ImageAds     = (
                from item in ServiceHelper.Create <ISlideAdsService>().GetImageAds(shop.Id)
                orderby item.Id
                select item).ToList();
            shopName.Slides = ServiceHelper.Create <ISlideAdsService>().GetSlidAds(shop.Id, SlideAdInfo.SlideAdType.ShopHome).ToList();
            List <ShopCategoryInfo> list = ServiceHelper.Create <IShopCategoryService>().GetShopCategory(shop.Id).ToList();

            foreach (ShopCategoryInfo shopCategoryInfo in
                     from s in list
                     where s.ParentCategoryId == 0
                     select s)
            {
                CategoryJsonModel categoryJsonModel = new CategoryJsonModel()
                {
                    Name        = shopCategoryInfo.Name,
                    Id          = shopCategoryInfo.Id.ToString(),
                    SubCategory = new List <SecondLevelCategory>()
                };
                CategoryJsonModel categoryJsonModel1 = categoryJsonModel;
                foreach (ShopCategoryInfo shopCategoryInfo1 in
                         from s in list
                         where s.ParentCategoryId == shopCategoryInfo.Id
                         select s)
                {
                    SecondLevelCategory secondLevelCategory = new SecondLevelCategory()
                    {
                        Name = shopCategoryInfo1.Name,
                        Id   = shopCategoryInfo1.Id.ToString()
                    };
                    categoryJsonModel1.SubCategory.Add(secondLevelCategory);
                }
                shopName.ShopCategory.Add(categoryJsonModel1);
            }
            ShopHomeModuleInfo[] array = ServiceHelper.Create <IShopHomeModuleService>().GetAllShopHomeModuleInfos(shop.Id).ToArray();
            ShopHomeModuleInfo[] shopHomeModuleInfoArray = array;
            for (i = 0; i < shopHomeModuleInfoArray.Length; i++)
            {
                ShopHomeModuleInfo          shopHomeModuleInfo    = shopHomeModuleInfoArray[i];
                List <ShopHomeFloorProduct> shopHomeFloorProducts = new List <ShopHomeFloorProduct>();
                foreach (ShopHomeModuleProductInfo shopHomeModuleProductInfo in shopHomeModuleInfo.ShopHomeModuleProductInfo.ToList())
                {
                    ShopHomeFloorProduct shopHomeFloorProduct = new ShopHomeFloorProduct()
                    {
                        Id        = shopHomeModuleProductInfo.ProductId,
                        Name      = shopHomeModuleProductInfo.ProductInfo.ProductName,
                        Pic       = shopHomeModuleProductInfo.ProductInfo.ImagePath,
                        Price     = shopHomeModuleProductInfo.ProductInfo.MinSalePrice.ToString("f2"),
                        SaleCount = (int)ServiceHelper.Create <IProductService>().GetProductVistInfo(shopHomeModuleProductInfo.ProductInfo.Id, null).SaleCounts
                    };
                    shopHomeFloorProducts.Add(shopHomeFloorProduct);
                }
                ShopHomeFloor shopHomeFloor = new ShopHomeFloor()
                {
                    FloorName = shopHomeModuleInfo.Name,
                    Products  = shopHomeFloorProducts
                };
                shopName.Floors.Add(shopHomeFloor);
            }
            IQueryable <ProductInfo> hotSaleProduct = ServiceHelper.Create <IProductService>().GetHotSaleProduct(shop.Id, 5);

            if (hotSaleProduct != null)
            {
                ProductInfo[] productInfoArray = hotSaleProduct.ToArray();
                for (i = 0; i < productInfoArray.Length; i++)
                {
                    ProductInfo           productInfo     = productInfoArray[i];
                    List <HotProductInfo> hotSaleProducts = shopName.HotSaleProducts;
                    HotProductInfo        hotProductInfo  = new HotProductInfo()
                    {
                        ImgPath   = productInfo.ImagePath,
                        Name      = productInfo.ProductName,
                        Price     = productInfo.MinSalePrice,
                        Id        = productInfo.Id,
                        SaleCount = (int)productInfo.SaleCounts
                    };
                    hotSaleProducts.Add(hotProductInfo);
                }
            }
            IQueryable <ProductInfo> hotConcernedProduct = ServiceHelper.Create <IProductService>().GetHotConcernedProduct(shop.Id, 5);

            if (hotConcernedProduct != null)
            {
                foreach (ProductInfo list1 in hotConcernedProduct.ToList())
                {
                    List <HotProductInfo> hotAttentionProducts = shopName.HotAttentionProducts;
                    HotProductInfo        hotProductInfo1      = new HotProductInfo()
                    {
                        ImgPath   = list1.ImagePath,
                        Name      = list1.ProductName,
                        Price     = list1.MinSalePrice,
                        Id        = list1.Id,
                        SaleCount = list1.ConcernedCount
                    };
                    hotAttentionProducts.Add(hotProductInfo1);
                }
            }
            ServiceHelper.Create <IShopService>().LogShopVisti(shop.Id);
            ViewBag.IsExpired = ServiceHelper.Create <IShopService>().IsExpiredShop(num);
            return(View(shopName));
        }
Exemple #13
0
        public void SaveFloor(AddShopHomeModuleModel model)
        {
            if (model.Id <= 0)  //新增
            {
                var rows  = Context.ShopHomeModuleInfo.Count();
                int count = rows > 0 ? Context.ShopHomeModuleInfo.Max(p => p.DisplaySequence) : 0;
                ShopHomeModuleInfo main = new ShopHomeModuleInfo();
                main.Name            = model.Name;
                main.Url             = model.Url;
                main.ShopId          = model.ShopId;
                main.IsEnable        = true;
                main.DisplaySequence = count + 1;
                main = Context.ShopHomeModuleInfo.Add(main);
                Context.SaveChanges();

                foreach (var p in model.Products)
                {
                    ShopHomeModuleProductInfo product = new ShopHomeModuleProductInfo();
                    product.HomeModuleId    = main.Id;
                    product.DisplaySequence = p.DisplaySequence;
                    product.ProductId       = p.ProductId;
                    Context.ShopHomeModuleProductInfo.Add(product);
                }

                foreach (var t in model.TopImgs)
                {
                    ShopHomeModulesTopImgInfo top = new ShopHomeModulesTopImgInfo();
                    top.HomeModuleId    = main.Id;
                    top.ImgPath         = t.ImgPath;
                    top.Url             = t.Url;
                    top.DisplaySequence = top.DisplaySequence;
                    Context.ShopHomeModulesTopImgInfo.Add(top);
                }
                Context.SaveChanges();
            }
            else //修改
            {
                Context.ShopHomeModuleProductInfo.Remove(p => p.HomeModuleId == model.Id);
                Context.ShopHomeModulesTopImgInfo.Remove(p => p.HomeModuleId == model.Id);

                ShopHomeModuleInfo main = Context.ShopHomeModuleInfo.FirstOrDefault(p => p.Id == model.Id);
                main.Name = model.Name;
                main.Url  = model.Url;

                foreach (var p in model.Products)
                {
                    ShopHomeModuleProductInfo product = new ShopHomeModuleProductInfo();
                    product.HomeModuleId    = main.Id;
                    product.DisplaySequence = p.DisplaySequence;
                    product.ProductId       = p.ProductId;
                    Context.ShopHomeModuleProductInfo.Add(product);
                }

                foreach (var t in model.TopImgs)
                {
                    ShopHomeModulesTopImgInfo top = new ShopHomeModulesTopImgInfo();
                    top.HomeModuleId    = main.Id;
                    top.ImgPath         = t.ImgPath;
                    top.Url             = t.Url;
                    top.DisplaySequence = top.DisplaySequence;
                    Context.ShopHomeModulesTopImgInfo.Add(top);
                }
                Context.SaveChanges();
            }
        }