Пример #1
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 });
        }
Пример #2
0
        public HttpResponseMessage Get()
        {
            var category = CategoryApplication.Get();
            var dto      = category.Select(p => new CategoryDTO(p));

            return(Request.CreateResponse(HttpStatusCode.OK, dto));
        }
Пример #3
0
        public JsonResult BatchDeleteCategory(string Ids)
        {
            int id;

            foreach (var idStr in Ids.Split('|'))
            {
                if (string.IsNullOrWhiteSpace(idStr))
                {
                    continue;
                }
                if (int.TryParse(idStr, out id))
                {
                    CategoryApplication.DeleteCategory(id);
                    // ServiceApplication.Create<IOperationLogService>().AddPlatformOperationLog(
                    //new LogInfo
                    //{
                    //    Date = DateTime.Now,
                    //    Description = "删除平台分类,Id=" + id,
                    //    IPAddress = Request.UserHostAddress,
                    //    PageUrl = "/Category/BatchDeleteCategory/" + id,
                    //    UserName = CurrentManager.UserName,
                    //    ShopId = 0

                    //});
                }
            }
            return(Json(new Result {
                success = true
            }, JsonRequestBehavior.AllowGet));
        }
Пример #4
0
        public ActionResult CashDepositRule()
        {
            var data       = _iCashDepositsService.GetCategoryCashDeposits();
            var categories = CategoryApplication.GetCategories();

            ViewBag.Categories = categories;

            #region 老套餐可能漏掉了一级分类保证金,这里同步下
            var cIds = categories.Where(t => t.ParentCategoryId == 0).Select(t => t.Id);
            if (cIds != null && cIds.Count() > 0)
            {
                var addIds = cIds.Except(data.Select(a => a.CategoryId));
                if (addIds != null && addIds.Count() > 0)
                {
                    foreach (var value in addIds)
                    {
                        CategoryCashDepositInfo addm = new CategoryCashDepositInfo();
                        addm.CategoryId = value;
                        CashDepositsApplication.AddCategoryCashDeposits(addm);
                    }
                    Log.Error("保证金少了一级分类Id:" + string.Join(",", addIds));
                    data = _iCashDepositsService.GetCategoryCashDeposits();//说明之前漏掉了重新读取最新的
                }
            }
            #endregion

            ViewBag.Categories = categories;
            return(View(data));
        }
Пример #5
0
        public JsonResult BatchDeleteCategory(string Ids)
        {
            int id;

            foreach (var idStr in Ids.Split('|'))
            {
                if (string.IsNullOrWhiteSpace(idStr))
                {
                    continue;
                }
                if (int.TryParse(idStr, out id))
                {
                    CategoryApplication.DeleteCategory(id);
                    // ServiceApplication.Create<IOperationLogService>().AddPlatformOperationLog(
                    //new LogInfo
                    //{
                    //    Date = DateTime.Now,
                    //    Description = "删除平台分类,Id=" + id,
                    //    IPAddress =  base.Request.HttpContext.Features.Get<IHttpConnectionFeature>()?.RemoteIpAddress.ToString(),
                    //    PageUrl = "/Category/BatchDeleteCategory/" + id,
                    //    UserName = CurrentManager.UserName,
                    //    ShopId = 0

                    //});
                }
            }
            return(Json(new Result {
                success = true
            }));
        }
Пример #6
0
 public void Convert(PostDTO source, Post target)
 {
     target.Title           = source.Title;
     target.Text            = source.Text;
     target.PublicationDate = source.PublicationDate;
     target.Category        = CategoryApplication.Get(source.Category);
     target.Author          = UserApplication.Get(source.Author);
     target.Slug            = source.Slug;
 }
Пример #7
0
        public JsonResult GetProductList(string skey, int rows, int page, long categoryId = 0)
        {
            //查询条件
            DistributionProductQuery query = new DistributionProductQuery();

            query.ProductName = skey;
            query.PageSize    = rows;
            query.PageNo      = page;
            query.Status      = DistributionProductStatus.Normal;
            query.ShopId      = curshopid;
            if (categoryId != 0)
            {
                query.CategoryId = categoryId;
            }
            query.isShopCategory = true;

            var data     = DistributionApplication.GetProducts(query);
            var datalist = new List <DistributionProductListModel>();

            if (data.Models != null)
            {
                var products   = ProductManagerApplication.GetProductsByIds(data.Models.Select(p => p.ProductId).ToList());
                var categories = CategoryApplication.GetCategories();
                foreach (var item in data.Models)
                {
                    var product   = products.FirstOrDefault(p => p.Id == item.ProductId);
                    var categorie = categories.FirstOrDefault(p => p.Id == product.Id);
                    datalist.Add(new DistributionProductListModel
                    {
                        BrokerageId        = item.Id,
                        ProductId          = item.ProductId,
                        ProductName        = product.ProductName,
                        CategoryId         = product.CategoryId,
                        CategoryName       = GetProductShopCategorieName(product.Id),
                        ShopId             = item.ShopId,
                        BrokerageRate1     = item.BrokerageRate1,
                        BrokerageRate2     = item.BrokerageRate2,
                        BrokerageRate3     = item.BrokerageRate3,
                        MaxBrokerage       = item.MaxBrokerage,
                        MaxSalePrice       = item.MaxSalePrice,
                        MinSalePrice       = item.MinSalePrice,
                        NoSettlementAmount = item.NoSettlementAmount,
                        ProductStatus      = item.ProductStatus,
                        SaleAmount         = item.SaleAmount,
                        SaleCount          = item.SaleCount,
                        SettlementAmount   = item.SettlementAmount,
                        ShopName           = item.ShopName
                    });
                }
            }
            var result = new { rows = datalist, total = data.Total };

            return(Json(result));
        }
Пример #8
0
        /// <summary>
        /// 商品列表信息项转换
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        private product_list_model ProductInfoListMapChange(Entities.ProductInfo data)
        {
            product_list_model dresult = null;
            var prodata = data;

            dresult = new product_list_model();

            if (prodata == null)
            {
                throw new MallApiException(OpenApiErrorCode.Product_Not_Exists, "num_iid");
            }

            #region 装配信息
            dresult.num_iid    = (int)prodata.Id;
            dresult.outer_id   = prodata.ProductCode;
            dresult.brand_id   = (int)prodata.BrandId;
            dresult.brand_name = prodata.BrandName;
            dresult.cid        = (int)prodata.CategoryId;
            dresult.type_id    = (int)prodata.TypeId;

            var category = CategoryApplication.GetCategory(prodata.CategoryId);
            if (category != null)
            {
                dresult.cat_name = category.Name;
                var type = TypeApplication.GetType(category.TypeId);
                if (type != null)
                {
                    dresult.type_name = type.Name;
                }
            }
            dresult.price = prodata.MinSalePrice;
            var skus = ProductManagerApplication.GetSKUs(prodata.Id);
            if (skus.Count > 0)
            {
                dresult.num = (int)skus.Sum(d => d.Stock);
            }
            else
            {
                dresult.num = 0;
                dresult.num = prodata.Quantity;
            }
            dresult.title         = prodata.ProductName.Trim();
            dresult.list_time     = prodata.AddedDate;
            dresult.modified      = prodata.AddedDate;
            dresult.sold_quantity = (int)prodata.SaleCounts;
            dresult.pic_url       = new System.Collections.ArrayList();
            dresult.pic_url.Add(System.IO.Path.Combine(OpenAPIHelper.HostUrl, prodata.GetImage(ImageSize.Size_350, 1)));
            ProductStatus ps = GetProductStatus(prodata);
            dresult.approve_status = ps.ToString();
            #endregion

            return(dresult);
        }
Пример #9
0
        ///购买力度
        public ActionResult ManagementPower(MemberStatisticsType?StatisticsType)
        {
            var pageModel = _iMemberLabelService.GetMemberLabelList(new LabelQuery()
            {
                PageSize = int.MaxValue
            });
            var LabelInfos = pageModel.Models.ToList();

            var categorys = CategoryApplication.GetCategoryByParentId(0);

            ViewBag.categorys      = categorys;
            ViewBag.StatisticsType = StatisticsType.HasValue ? (int)StatisticsType.Value : -1;
            return(View(LabelInfos));
        }
Пример #10
0
        public ActionResult ApplyDetail(long id)
        {
            var model      = _iShopService.GetBusinessCategoriesApplyInfo(id);
            var details    = _iShopService.GetBusinessCategoriesApplyDetails(id);
            var categories = CategoryApplication.GetCategories();

            foreach (var item in details)
            {
                var path = CategoryApplication.GetCategoryPath(categories, item.CategoryId);
                item.CatePath = string.Join(">", path.Select(p => p.Name));
            }
            ViewBag.Details = details;
            return(View(model));
        }
Пример #11
0
 public JsonResult DeleteCategoryById(long id)
 {
     CategoryApplication.DeleteCategory(id);             //用AOP来做
     //ServiceHelper.Create<IOperationLogService>().AddPlatformOperationLog(
     //       new LogInfo
     //       {
     //           Date = DateTime.Now,
     //           Description = "删除平台分类,Id=" + id,
     //           IPAddress = Request.UserHostAddress,
     //           PageUrl = "/Category/DeleteCategoryById/" + id,
     //           UserName = CurrentManager.UserName,
     //           ShopId = 0
     //       });
     return(Json(new { Successful = true }, JsonRequestBehavior.AllowGet));
 }
Пример #12
0
 public JsonResult BatchDeleteCategory(string Ids)
 {
     foreach (string str in Ids.Split(new char[] { '|' }))
     {
         int num;
         if (!string.IsNullOrWhiteSpace(str) && int.TryParse(str, out num))
         {
             CategoryApplication.DeleteCategory((long)num);
         }
     }
     BaseController.Result data = new BaseController.Result
     {
         success = true
     };
     return(base.Json(data, JsonRequestBehavior.AllowGet));
 }
Пример #13
0
        public HttpResponseMessage Post(CategoryDTO categoryDTO)
        {
            var category  = new Category();
            var converter = new CategoryConverter();

            converter.Convert(categoryDTO, category);

            try
            {
                CategoryApplication.Save(category);
                return(Request.CreateResponse(HttpStatusCode.OK, new Note("Categoria adicionado com sucesso", Note.NoteType.Success)));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, new Note("Não foi possível adicionar a categoria.", ex.Message, Note.NoteType.Error)));
            }
        }
Пример #14
0
        public JsonResult <Result <dynamic> > GetAllCategories()
        {
            var categories = CategoryApplication.GetMainCategory();
            var model      = categories.Where(p => p.IsShow).OrderBy(c => c.DisplaySequence).Select(c => new
            {
                cid  = c.Id,
                name = c.Name,
                subs = CategoryApplication.GetCategoryByParentId(c.Id).Select(a => new
                {
                    cid  = a.Id,
                    name = a.Name
                })
            }).ToList();
            var result = SuccessResult <dynamic>(data: model);

            return(Json(result));
        }
Пример #15
0
 public JsonResult DeleteCategoryById(long id)
 {
     CategoryApplication.DeleteCategory(id);                 //用AOP来做
     CashDepositsApplication.DeleteCategoryCashDeposits(id); //--bo.shu  2017-8-31  删除类型的同时 删除对应类型的保证金
     //ServiceApplication.Create<IOperationLogService>().AddPlatformOperationLog(
     //       new LogInfo
     //       {
     //           Date = DateTime.Now,
     //           Description = "删除平台分类,Id=" + id,
     //           IPAddress =  base.Request.HttpContext.Features.Get<IHttpConnectionFeature>()?.RemoteIpAddress.ToString(),
     //           PageUrl = "/Category/DeleteCategoryById/" + id,
     //           UserName = CurrentManager.UserName,
     //           ShopId = 0
     //       });
     return(Json(new Result {
         success = true
     }));
 }
Пример #16
0
 public JsonResult DeleteCategoryById(long id)
 {
     CategoryApplication.DeleteCategory(id);                 //用AOP来做
     CashDepositsApplication.DeleteCategoryCashDeposits(id); //--bo.shu  2017-8-31  删除类型的同时 删除对应类型的保证金
     //ServiceApplication.Create<IOperationLogService>().AddPlatformOperationLog(
     //       new LogInfo
     //       {
     //           Date = DateTime.Now,
     //           Description = "删除平台分类,Id=" + id,
     //           IPAddress = Request.UserHostAddress,
     //           PageUrl = "/Category/DeleteCategoryById/" + id,
     //           UserName = CurrentManager.UserName,
     //           ShopId = 0
     //       });
     return(Json(new Result {
         success = true
     }, JsonRequestBehavior.AllowGet));
 }
Пример #17
0
        public HttpResponseMessage Put(Guid id, [FromBody] CategoryDTO categoryDTO)
        {
            var category = CategoryApplication.Get(id);

            if (category == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, new Note("Categoria não encontrado", Note.NoteType.Success)));
            }

            var converter = new CategoryConverter();

            converter.Convert(categoryDTO, category);

            try
            {
                CategoryApplication.Save(category);
                return(Request.CreateResponse(HttpStatusCode.OK, new Note("Categoria criado com sucesso", Note.NoteType.Success)));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, new Note("Não foi possível salvar a categoria", ex.Message, Note.NoteType.Error)));
            }
        }
Пример #18
0
        public HttpResponseMessage Get(string title)
        {
            var category = CategoryApplication.Get(title);

            return(Request.CreateResponse(HttpStatusCode.OK, category));
        }
Пример #19
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
        }
Пример #20
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
            }));
        }
Пример #21
0
        /// <summary>
        /// 商品信息转换
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        private product_item_model ProductInfoMapChange(Entities.ProductInfo data)
        {
            var prodata = data;

            if (prodata == null)
            {
                throw new MallApiException(OpenApiErrorCode.Product_Not_Exists, "num_iid");
            }
            product_item_model result = new product_item_model();

            #region 装配信息
            result.num_iid    = (int)prodata.Id;
            result.outer_id   = prodata.ProductCode;
            result.brand_id   = (int)prodata.BrandId;
            result.brand_name = prodata.BrandName;
            result.cid        = (int)prodata.CategoryId;
            result.type_id    = (int)prodata.TypeId;

            var category = CategoryApplication.GetCategory(prodata.CategoryId);
            var desc     = ProductManagerApplication.GetProductDescription(prodata.Id);
            if (category != null)
            {
                result.cat_name = category.Name;
                var type = TypeApplication.GetType(category.TypeId);
                if (type != null)
                {
                    result.type_name = type.Name;
                }
            }
            result.title            = prodata.ProductName.Trim();
            result.list_time        = prodata.AddedDate;
            result.modified         = prodata.AddedDate;
            result.display_sequence = (int)prodata.DisplaySequence;
            result.sold_quantity    = (int)prodata.SaleCounts;
            result.desc             = desc.Description;
            result.wap_desc         = desc.MobileDescription;
            result.pic_url.Add(System.IO.Path.Combine(OpenAPIHelper.HostUrl, prodata.GetImage(ImageSize.Size_350, 1)));
            ProductStatus ps = GetProductStatus(prodata);
            result.approve_status = ps.ToString();

            #region 商品属性填充
            var prodAttrs      = ProductManagerApplication.GetProductAttributes(prodata.Id);
            var prodAttrids    = prodAttrs.Select(d => d.AttributeId).ToList();
            var prodAttrValues = _iTypeService.GetAttributeValues(prodAttrids);
            result.props_name = "";
            if (prodAttrids.Count > 0)
            {
                List <string> propslst    = new List <string>();
                List <string> propsvallst = new List <string>();
                foreach (var curattid in prodAttrids)
                {
                    var item = prodAttrs.FirstOrDefault(d => d.AttributeId == curattid);
                    propsvallst.Clear();
                    var attribute = _iTypeService.GetAttribute(item.AttributeId);
                    var values    = prodAttrValues.Where(p => p.AttributeId == curattid);
                    foreach (var attrV in values)
                    {
                        if (prodAttrs.Any(p => p.ValueId == attrV.Id))
                        {
                            propsvallst.Add(attrV.Value);
                        }
                    }
                    propslst.Add(attribute.Name + "#cln#[" + string.Join(",", propsvallst.ToArray()) + "]");
                }
                result.props_name = string.Join("#scln#", propslst.ToArray());
            }
            #endregion

            #region  发货地区

            var prolocid = FreightTemplateApplication.GetFreightTemplate(prodata.FreightTemplateId).SourceAddress;
            result.location = "";

            var locpath = _iRegionService.GetFullName(prolocid, ",");
            result.location = "{'city':'#c#', 'state':'#p#'}";
            if (!string.IsNullOrWhiteSpace(locpath))
            {
                var _tmparr = locpath.Split(',');
                result.location = result.location.Replace("#p#", _tmparr[0]);
                if (_tmparr.Length > 1)
                {
                    result.location = result.location.Replace("#c#", _tmparr[1]);
                }
                else
                {
                    result.location = result.location.Replace("#c#", "");
                }
            }

            #endregion

            #region SKUS

            Entities.TypeInfo typeInfo     = _iTypeService.GetType(data.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 (prodata != null)
            {
                colorAlias   = !string.IsNullOrWhiteSpace(prodata.ColorAlias) ? prodata.ColorAlias : colorAlias;
                sizeAlias    = !string.IsNullOrWhiteSpace(prodata.SizeAlias) ? prodata.SizeAlias : sizeAlias;
                versionAlias = !string.IsNullOrWhiteSpace(prodata.VersionAlias) ? prodata.VersionAlias : versionAlias;
            }
            result.skus = new List <product_sku_model>();
            var skus = ProductManagerApplication.GetSKUs(prodata.Id);
            foreach (var item in skus)
            {
                product_sku_model skudata = new product_sku_model();
                skudata.sku_id       = item.Id;
                skudata.outer_sku_id = item.Sku;
                skudata.price        = item.SalePrice;
                skudata.quantity     = (int)item.Stock;
                //skudata.sku_properties_name = "颜色:" + item.Color + "尺寸:" + item.Size + "版本:" + item.Version;
                skudata.sku_properties_name = colorAlias + ":" + item.Color + " " + sizeAlias + ":" + item.Size + " " + versionAlias + ":" + item.Version;
                string sku_properties_name = item.Color + " " + item.Size + " " + item.Version;
                if (string.IsNullOrWhiteSpace(sku_properties_name))
                {
                    skudata.sku_properties_name = "";
                }
                if (!string.IsNullOrWhiteSpace(skudata.sku_properties_name))
                {
                    result.skus.Add(skudata);
                }
            }
            #endregion

            #endregion

            return(result);
        }
Пример #22
0
 public ProductsController(ProductApplication productApplication, CategoryApplication categoryApplication)
 {
     _productApplication  = productApplication;
     _categoryApplication = categoryApplication;
 }
Пример #23
0
        // GET: Mobile/Category
        public ActionResult Index()
        {
            var model = CategoryApplication.GetSubCategories();

            return(View(model));
        }
Пример #24
0
 public CategoryController(CategoryApplication categoryApplication, ICategoryRepository categoryRepository)
 {
     _categoryApplication = categoryApplication;
     _categoryRepository  = categoryRepository;
 }
Пример #25
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));
        }
Пример #26
0
 public CategoriesController(CategoryApplication categoryApplication)
 {
     _categoryApplication = categoryApplication;
 }
Пример #27
0
        /// <summary>
        /// 商品分类
        /// </summary>
        /// <returns></returns>
        public ActionResult DistributionMarketCategory()
        {
            var model = CategoryApplication.GetSubCategories();

            return(View(model));
        }
Пример #28
0
        public ActionResult Index(string keywords = "", long categoryId = 0, long brandId = 0, int orderBy = 0, int pageNo = 1, int pageSize = 40)
        {
            var query = new ShopQuery
            {
                ShopName   = keywords,
                CategoryId = categoryId,
                BrandId    = brandId,
                PageNo     = pageNo,
                PageSize   = pageSize,
                Status     = Entities.ShopInfo.ShopAuditStatus.Open
            };

            if (orderBy == 1)
            {
                query.Sort = "OrderCount";
            }
            var result = new ShopSearchViewModel
            {
                Keywords         = keywords,
                CategoryId       = categoryId,
                BrandId          = brandId,
                Shops            = new List <Shop>(),
                OrderBy          = orderBy,
                IsSaleCountOnOff = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1
            };

            var shopData = _iShopService.GetShops(query);
            var shops    = shopData.Models;

            if (shopData.Total == 0)
            {
                return(View(result));
            }

            result.Pager = new PagingInfo
            {
                CurrentPage  = pageNo,
                ItemsPerPage = pageSize,
                TotalItems   = shopData.Total
            };
            result.Total = shopData.Total;


            var statisticList = ShopApplication.GetStatisticOrderComment(shops.Select(p => p.Id).ToList());

            var productQuery = new ProductQuery
            {
                PageNo   = 1,
                PageSize = 4,
                OnSale   = true,
                IsAsc    = false,
                Sort     = "displaysale",
            };

            foreach (var item in shops)
            {
                var shop = new Shop();
                shop.Id       = item.Id;
                shop.ShopName = item.ShopName;
                //销量
                shop.SaleCount = (int)ShopApplication.GetShopDisplaySales(item.Id);
                var statistic = statisticList.FirstOrDefault(p => p.ShopId == item.Id);
                //宝贝与描述
                shop.ProductAndDescription = string.Format("{00:F}", statistic.ProductAndDescription);
                //卖家服务态度
                shop.SellerServiceAttitude = string.Format("{00:F}", statistic.SellerServiceAttitude);
                //卖家发货速度
                shop.SellerDeliverySpeed = string.Format("{00:F}", statistic.SellerDeliverySpeed);

                //查询商品
                productQuery.ShopId = item.Id;
                var products = ProductManagerApplication.GetProducts(productQuery);
                shop.ProductCount = products.Total;
                shop.Products     = products.Models.Select(p => new Product {
                    Id         = p.Id,
                    Image      = MallIO.GetProductSizeImage(p.ImagePath, 1, (int)ImageSize.Size_150),
                    Price      = p.MinSalePrice,
                    CategoryId = p.CategoryId,
                }).ToList();
                shop.Logo = item.Logo;
                result.Shops.Add(shop);
            }

            //经营品牌
            var shopBrands = ShopApplication.GetShopBrands(shops.Select(p => p.Id).ToList());

            result.Brands = shopBrands.GroupBy(p => p.BrandId).ToDictionary(k => k.Key, v => v.FirstOrDefault().BrandName);

            //经营类型
            var CategoryIds = result.Shops.SelectMany(s => s.Products.Select(p => p.CategoryId));

            result.Categorys = CategoryApplication.GetCategories()
                               .Where(p => CategoryIds.Contains(p.Id))
                               .ToDictionary(k => k.Id, v => v.Name);

            return(View(result));
        }
Пример #29
0
        public HttpResponseMessage Get(Guid id)
        {
            var category = CategoryApplication.Get(id);

            return(Request.CreateResponse(HttpStatusCode.OK, category));
        }