Пример #1
0
        public object GetSellerMobileHomePageProducts(long shopId, PlatformType platformType, int page, int rows, string brandName, long?categoryId = null)
        {
            var data      = MobileHomeProductApplication.GetSellerMobileHomePageProducts(shopId, platformType, page, rows, brandName, categoryId);
            var products  = ProductManagerApplication.GetProducts(data.Models.Select(p => p.ProductId));
            var brands    = BrandApplication.GetBrands(products.Select(p => p.BrandId).ToList());
            var categorys = ShopCategoryApplication.GetCategorysByProduct(products.Select(p => p.Id).ToList());

            var list = data.Models.Select(item =>
            {
                var product  = products.FirstOrDefault(p => p.Id == item.ProductId);
                var brand    = brands.FirstOrDefault(p => p.Id == product.BrandId);
                var category = categorys.FirstOrDefault(p => p.ProductId == product.Id);
                return(new
                {
                    id = item.Id,
                    productId = item.ProductId,
                    name = product.ProductName,
                    image = product.GetImage(ImageSize.Size_50),
                    price = product.MinSalePrice.ToString("F2"),
                    brand = brand?.Name ?? string.Empty,
                    sequence = item.Sequence,
                    categoryName = category?.ShopCategoryName ?? string.Empty,
                });
            });


            return(new { rows = list, total = data.Total });
        }
Пример #2
0
        // GET: Admin/Brand
        public JsonResult List(int page, int rows, string keyWords)
        {
            keyWords = keyWords.Trim();
            var result = _iBrandService.GetBrands(keyWords, page, rows);
            IEnumerable <BrandModel> brands = result.Models.ToArray().Select(item => {
                string shopName = string.Empty;
                var brandapply  = BrandApplication.GetShopBrandApply(item.Name);
                if (brandapply != null)
                {
                    //var shop = ShopApplication.GetShop(brandapply.ShopId);
                    shopName = "(商家新增品牌)";
                }
                return(new BrandModel()
                {
                    BrandName = item.Name,
                    BrandLogo = Core.HimallIO.GetImagePath(item.Logo),
                    ID = item.Id,
                    BrandDesc = item.Name + shopName
                                //AuditStatus = (int)item.AuditStatus
                });
            });
            DataGridModel <BrandModel> model = new DataGridModel <BrandModel>()
            {
                rows = brands, total = result.Total
            };

            return(Json(model));
        }
Пример #3
0
        public object GetMobileHomeProducts(long shopId, PlatformType platformType, int page, int rows, string keyWords, string shopName, long?categoryId = null)
        {
            var homeProducts = MobileHomeProductApplication.GetMobileHomePageProducts(shopId, platformType, page, rows, keyWords, shopName, categoryId);
            var products     = ProductManagerApplication.GetProducts(homeProducts.Models.Select(p => p.ProductId));
            var shops        = ShopApplication.GetShops(products.Select(p => p.ShopId));
            var brands       = BrandApplication.GetBrandsByIds(products.Select(p => p.BrandId));

            var model = homeProducts.Models.Select(item =>
            {
                var product = products.FirstOrDefault(p => p.Id == item.ProductId);
                var shop    = shops.FirstOrDefault(p => p.Id == product.ShopId);
                var brand   = brands.FirstOrDefault(p => p.Id == product.BrandId);
                return(new
                {
                    name = product.ProductName,
                    image = product.GetImage(ImageSize.Size_50),
                    price = product.MinSalePrice.ToString("F2"),
                    brand = brand?.Name ?? string.Empty,
                    sequence = item.Sequence,
                    categoryName = CategoryApplication.GetCategory(product.CategoryId).Name,
                    id = item.Id,
                    productId = item.ProductId,
                    shopName = shop?.ShopName ?? string.Empty
                });
            });

            return(new { rows = model, total = homeProducts.Total });
        }
Пример #4
0
        public JsonResult GetBrands()
        {
            var result = BrandApplication.GetBrands("", 1, int.MaxValue).Models;
            var brands = result.Select(item => new
            {
                BrandName = item.Name,
                BrandLogo = Core.MallIO.GetImagePath(item.Logo),
                Id        = item.Id
            });

            return(Json(brands, true));
        }
Пример #5
0
        public JsonResult Apply(BrandApplyModel brand)
        {
            var shopId = CurrentSellerManager.ShopId;
            var model  = new Entities.ShopBrandApplyInfo();

            model.BrandId   = brand.BrandId;
            model.ApplyMode = brand.BrandMode == 1 ? (int)Himall.Entities.ShopBrandApplyInfo.BrandApplyMode.Exist : (int)Himall.Entities.ShopBrandApplyInfo.BrandApplyMode.New;
            if (brand.BrandMode == 1)
            {
                var m = _iBrandService.GetBrand(brand.BrandId);
                if (m == null)
                {
                    throw new Himall.Core.HimallException("品牌不存在,请刷新页面重新申请");
                }
                model.BrandName   = m.Name;
                model.Logo        = m.Logo;
                model.Description = m.Description;
            }
            else
            {
                if (brand.BrandDesc.Length > 200)
                {
                    return(Json(new Result()
                    {
                        success = false, msg = "简介过长!"
                    }));
                }
                model.BrandId     = 0;
                model.BrandName   = brand.BrandName.Trim();
                model.Logo        = brand.BrandLogo;
                model.Description = brand.BrandDesc;
            }

            model.Remark          = brand.Remark;
            model.AuthCertificate = brand.BrandAuthPic;
            model.ShopId          = shopId;
            model.ApplyTime       = DateTime.Now;

            var oldapply = _iBrandService.GetExistApply(shopId, model.BrandName);

            if (oldapply == null)
            {
                _iBrandService.ApplyBrand(model);
                return(Json(new Result()
                {
                    success = true, msg = "申请成功!"
                }));
            }
            else
            {
                var oBrand = BrandApplication.GetBrand(oldapply.BrandId);
                if (oBrand != null && oBrand.IsDeleted)
                {
                    model.Id = oldapply.Id;
                }
                else
                {
                    if (oldapply.AuditStatus == (int)Entities.ShopBrandApplyInfo.BrandAuditStatus.UnAudit)
                    {
                        return(Json(new Result()
                        {
                            success = false, msg = "该品牌正在审核中!"
                        }));
                    }
                    else if (oldapply.AuditStatus == (int)Entities.ShopBrandApplyInfo.BrandAuditStatus.Audited)
                    {
                        return(Json(new Result()
                        {
                            success = false, msg = "该品牌已存在,请选择申请已有品牌!"
                        }));
                    }
                }
                model.AuditStatus = 0;
                _iBrandService.UpdateApplyBrand(model);
                return(Json(new Result()
                {
                    success = true, msg = "申请成功!"
                }));
            }
        }
Пример #6
0
        public JsonResult Browse(long?categoryId, int?auditStatus, string ids, int page, string keyWords, string shopName,
                                 int?saleStatus, bool?isShopCategory, int rows = 10, bool isLimitTimeBuy = false, bool showSku = false, long[] exceptProductIds = null)
        {
            var query = new ProductQuery()
            {
                PageSize         = rows,
                PageNo           = page,
                KeyWords         = keyWords,
                ShopName         = shopName,
                CategoryId       = isShopCategory.GetValueOrDefault() ? null : categoryId,
                ShopCategoryId   = isShopCategory.GetValueOrDefault() ? categoryId : null,
                Ids              = string.IsNullOrWhiteSpace(ids) ? null : ids.Split(',').Select(item => long.Parse(item)),
                ShopId           = CurrentSellerManager.ShopId,
                IsLimitTimeBuy   = isLimitTimeBuy,
                ExceptIds        = exceptProductIds,
                IsFilterStock    = false,
                HasLadderProduct = false,
                AuditStatus      = new[] { ProductInfo.ProductAuditStatus.Audited },
                SaleStatus       = ProductInfo.ProductSaleStatus.OnSale
            };

            var data   = ProductManagerApplication.GetProducts(query);
            var shops  = ShopApplication.GetShops(data.Models.Select(p => p.ShopId));
            var brands = BrandApplication.GetBrands(data.Models.Select(p => p.BrandId));
            var skus   = ProductManagerApplication.GetSKUByProducts(data.Models.Select(p => p.Id));

            var products = data.Models.Select(item =>
            {
                var brand    = brands.FirstOrDefault(p => p.Id == item.BrandId);
                var shop     = shops.FirstOrDefault(p => p.Id == item.ShopId);
                var cate     = CategoryApplication.GetCategory(item.CategoryId);
                var sku      = skus.Where(p => p.ProductId == item.Id);
                var limitAdd = LimitTimeApplication.IsAdd(item.Id);
                return(new
                {
                    name = item.ProductName,
                    brandName = brand?.Name ?? string.Empty,
                    categoryName = brand == null ? "" : cate.Name,
                    id = item.Id,
                    imgUrl = item.GetImage(ImageSize.Size_50),
                    price = item.MinSalePrice,
                    skus = !showSku ? null : sku.Select(a => new SKUModel()
                    {
                        Id = a.Id,
                        SalePrice = a.SalePrice,
                        Size = a.Size,
                        Stock = a.Stock,
                        Version = a.Version,
                        Color = a.Color,
                        Sku = a.Sku,
                        AutoId = a.AutoId,
                        ProductId = a.ProductId
                    }),
                    shopName = shop.ShopName,
                    isOpenLadder = item.IsOpenLadder,
                    isLimit = limitAdd
                });
            });

            var dataGrid = new
            {
                rows  = products,
                total = data.Total
            };

            return(Json(dataGrid));
        }
Пример #7
0
        public JsonResult List(long?categoryId, string brandName, string productCode, int?auditStatus, string ids, int page, int rows, string keyWords, string shopName, int?saleStatus, bool?isAsc, string sort = "", sbyte?productType = null)
        {
            var query = new ProductQuery()
            {
                PageSize    = rows,
                PageNo      = page,
                BrandName   = brandName,
                KeyWords    = keyWords,
                CategoryId  = categoryId,
                Ids         = string.IsNullOrWhiteSpace(ids) ? null : ids.Split(',').Select(item => long.Parse(item)),
                ShopName    = shopName,
                ProductCode = productCode,
                IsAsc       = isAsc.HasValue ? isAsc.Value : false,
                Sort        = sort
            };

            if (productType.HasValue && productType.Value > -1)
            {
                query.ProductType = productType.Value;
            }
            if (isAsc.HasValue && string.IsNullOrEmpty(query.Sort)) //如果按序号排序不为null
            {
                query.OrderKey  = 5;                                //4商家,5平台
                query.OrderType = isAsc.Value;
            }
            if (auditStatus.HasValue)
            {
                query.AuditStatus = new ProductInfo.ProductAuditStatus[] { (ProductInfo.ProductAuditStatus)auditStatus };
                if (auditStatus == (int)ProductInfo.ProductAuditStatus.WaitForAuditing)
                {
                    query.SaleStatus = ProductInfo.ProductSaleStatus.OnSale;
                }
            }
            if (saleStatus.HasValue)
            {
                query.SaleStatus = (ProductInfo.ProductSaleStatus)saleStatus;
            }

            var products = ProductManagerApplication.GetProducts(query);

            var brands     = BrandApplication.GetBrandsByIds(products.Models.Select(p => p.BrandId).ToList());
            var categories = CategoryApplication.GetCategories();
            var shops      = ShopApplication.GetShops(products.Models.Select(p => p.ShopId).ToList());

            var list = products.Models.Select(item =>
            {
                var description = ProductManagerApplication.GetProductDescription(item.Id);
                return(new ProductModel()
                {
                    //TODO:FG 循环内查询调用提取
                    name = item.ProductName,
                    brandName = brands.FirstOrDefault(p => p.Id == item.BrandId)?.Name ?? string.Empty,
                    categoryName = categories.FirstOrDefault(p => p.Id == item.CategoryId)?.Name ?? string.Empty,
                    id = item.Id,
                    imgUrl = item.GetImage(ImageSize.Size_50),
                    price = item.MinSalePrice,
                    state = item.ShowProductState,
                    auditStatus = (int)item.AuditStatus,
                    url = "",
                    auditReason = description?.AuditReason ?? string.Empty,
                    shopName = shops.FirstOrDefault(p => p.Id == item.ShopId)?.ShopName ?? string.Empty,
                    saleStatus = (int)item.SaleStatus,
                    productCode = item.ProductCode,
                    saleCounts = item.SaleCounts,
                    AddedDate = item.AddedDate.ToString("yyyy-MM-dd HH:mm"),
                    DisplaySequence = item.DisplaySequence,
                    VirtualSaleCounts = (int)item.VirtualSaleCounts,
                    ProductType = item.ProductType
                });
            });

            return(Json(new DataGridModel <ProductModel>()
            {
                rows = list, total = products.Total
            }));
        }
Пример #8
0
        public ActionResult ExportToExcel(long?categoryId = null, string brandName = "", string productCode = "", int?auditStatus = null, string ids = "", string keyWords = "", string shopName = "", int?saleStatus = null, sbyte?productType = null)
        {
            var query = new ProductQuery()
            {
                PageSize           = int.MaxValue,
                PageNo             = 1,
                BrandName          = brandName,
                KeyWords           = keyWords,
                CategoryId         = categoryId,
                Ids                = string.IsNullOrWhiteSpace(ids) ? null : ids.Split(',').Select(item => long.Parse(item)),
                ShopName           = shopName,
                ProductCode        = productCode,
                NotIncludedInDraft = true
            };

            if (productType.HasValue && productType.Value > -1)
            {
                query.ProductType = productType.Value;
            }
            if (auditStatus.HasValue)
            {
                query.AuditStatus = new ProductInfo.ProductAuditStatus[] { (ProductInfo.ProductAuditStatus)auditStatus };
                if (auditStatus == (int)ProductInfo.ProductAuditStatus.WaitForAuditing)
                {
                    query.SaleStatus = ProductInfo.ProductSaleStatus.OnSale;
                }
            }
            if (saleStatus.HasValue)
            {
                query.SaleStatus = (ProductInfo.ProductSaleStatus)saleStatus;
            }


            var data = ProductManagerApplication.GetProducts(query);

            #region 先查询到列表,便于下面循环读取
            List <CategoryInfo>                 listproductcate = new List <CategoryInfo>();            //商品分类
            List <BrandInfo>                    listbrand       = new List <BrandInfo>();               //品牌
            List <FreightTemplateInfo>          listtemplate    = new List <FreightTemplateInfo>();     //运费模板
            List <Mall.DTO.ProductShopCategory> listshopcate    = new List <DTO.ProductShopCategory>(); //商铺分类
            Dictionary <long, string>           shopnames       = new Dictionary <long, string>();
            if (data.Models != null)
            {
                List <long> cateids = data.Models.Select(p => p.CategoryId).ToList();
                listproductcate = CategoryApplication.GetCateogryListByIds(cateids);//平台分类
                if (listproductcate == null)
                {
                    listproductcate = new List <CategoryInfo>();
                }

                List <long> templateIds = data.Models.Select(p => p.FreightTemplateId).ToList();
                listtemplate = FreightTemplateApplication.GetFreightTemplateList(templateIds);//运费模板
                if (listtemplate == null)
                {
                    listtemplate = new List <FreightTemplateInfo>();              //实例下便免下面循环里判断空
                }
                IEnumerable <long> brandIds = data.Models.Select(p => p.BrandId); //品牌
                listbrand = BrandApplication.GetBrands(brandIds);
                if (listbrand == null)
                {
                    listbrand = new List <BrandInfo>();
                }

                List <long> productids = data.Models.Select(p => p.Id).ToList();//商铺分类
                listshopcate = ShopCategoryApplication.GetCategorysByProduct(productids);
                if (listshopcate == null)
                {
                    listshopcate = new List <DTO.ProductShopCategory>();
                }

                List <long> shopids = data.Models.Select(p => p.ShopId).ToList();
                shopnames = ShopApplication.GetShopNames(shopids);
                if (shopnames == null)
                {
                    shopnames = new Dictionary <long, string>();
                }
            }
            #endregion

            var products = data.Models.Select(item =>
            {
                var desc = ProductManagerApplication.GetProductDescription(item.Id);
                var skus = _iProductService.GetSKUs(item.Id);

                var brand        = (item.BrandId <= 0) ? null : listbrand.Where(p => p.Id == item.BrandId).FirstOrDefault();                        //品牌
                var freightTem   = (item.FreightTemplateId <= 0) ? null : listtemplate.Where(p => p.Id == item.FreightTemplateId).FirstOrDefault(); //运费模板
                var platFormCate = (item.CategoryId <= 0) ? null : listproductcate.Where(p => p.Id == item.CategoryId).FirstOrDefault();            //平台分类
                var shopcate     = listshopcate.Where(p => p.ProductId == item.Id).FirstOrDefault();                                                //商铺分类

                return(new ProductModel()
                {
                    //TODO:FG 循环内查询调用(大数据量)
                    name = item.ProductName,
                    brandName = brand == null ? "" : brand.Name,
                    id = item.Id,
                    imgUrl = item.GetImage(ImageSize.Size_50),
                    price = item.MinSalePrice,
                    state = item.ShowProductState,
                    auditStatus = (int)item.AuditStatus,
                    url = "",
                    auditReason = desc?.AuditReason ?? string.Empty,
                    //shopName = shopService.GetShopBasicInfo(item.ShopId) == null ? "" : shopService.GetShopBasicInfo(item.ShopId).ShopName,
                    shopName = shopnames[item.ShopId],
                    saleStatus = (int)item.SaleStatus,
                    productCode = item.ProductCode,

                    categoryName = platFormCate == null ? "" : platFormCate.Name,         //平台分类
                    ShopCategoryName = shopcate == null ? "" : shopcate.ShopCategoryName, //商家分类
                    AuditStatusText = (item.AuditStatus == ProductInfo.ProductAuditStatus.Audited ? "已审核" : "待审核"),
                    MeasureUnit = item.MeasureUnit,
                    HasSKU = item.HasSKU,
                    SKUInfo = skus,
                    FreightTemplateName = freightTem == null ? "" : freightTem.Name,                                                       //运费模板名称
                    IsOpenLadder = item.IsOpenLadder,                                                                                      //是否开启阶梯批发
                    ProductLadderPrice = ProductManagerApplication.GetLadderPriceInfosByProductId(item.Id, item.IsOpenLadder),
                    ProductTypeName = item.ProductType == 1 ? "虚拟商品" : "实物商品",                                                             //商品类型(虚拟或实物)
                    VirtualProduct = (item.ProductType == 1 ? ProductManagerApplication.GetVirtualProductInfoByProductId(item.Id) : null), //虚拟商品
                    AuditReason = desc == null?"":desc.AuditReason,                                                                        //审核备注
                    AddedDate = item.AddedDate.ToString(),                                                                                 //发布日期
                    MarketPrice = item.MarketPrice,                                                                                        //市场价
                });
            });

            #region 构建Excel文档
            ViewData.Model = products;
            string viewHtml = RenderPartialViewToString(this, "ExportProductinfo");
            return(File(System.Text.Encoding.UTF8.GetBytes(viewHtml), "application/ms-excel", string.Format("平台商品信息_{0}.xls", DateTime.Now.ToString("yyyy-MM-dd"))));

            #endregion
        }