Пример #1
0
        public ActionResult Edit(long id)
        {
            var couponser = _iCouponService;
            var model     = couponser.GetCouponInfo(CurrentSellerManager.ShopId, id);

            if (model == null)
            {
                throw new MallException("错误的优惠券编号。");
            }
            if (model.IsSyncWeiXin == 1 && model.WXAuditStatus != (int)WXCardLogInfo.AuditStatusEnum.Audited)
            {
                throw new MallException("同步微信优惠券未审核通过时不可修改。");
            }

            model.FormIsSyncWeiXin = model.IsSyncWeiXin == 1;

            var viewmodel = new CouponViewModel();
            var products  = couponser.GetCouponProductsByCouponId(id);

            viewmodel.Coupon         = model;
            viewmodel.CouponProducts = products;
            viewmodel.Products       = ProductManagerApplication.GetProducts(products.Select(p => p.ProductId));
            viewmodel.Settings       = couponser.GetSettingsByCoupon(new System.Collections.Generic.List <long> {
                id
            });
            viewmodel.CanVshopIndex = CurrentSellerManager.VShopId > 0;
            var market = _iMarketService.GetMarketService(CurrentSellerManager.ShopId, MarketType.Coupon);

            viewmodel.EndTime = MarketApplication.GetServiceEndTime(market.Id);
            viewmodel.CanAddIntegralCoupon = couponser.CanAddIntegralCoupon(CurrentSellerManager.ShopId, id);
            return(View(viewmodel));
        }
Пример #2
0
        /// <summary>
        /// 获取限时购列表接口
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetLimitBuyList(int pageIndex, int pageSize)
        {
            #region 初始化查询Model
            FlashSaleQuery query = new FlashSaleQuery()
            {
                PageNo             = pageIndex,
                PageSize           = pageSize,
                IsPreheat          = true,
                CheckProductStatus = true,
                OrderKey           = 5, /* 排序项(1:默认,2:销量,3:价格,4 : 结束时间,5:状态 开始排前面) */
                AuditStatus        = FlashSaleInfo.FlashSaleStatus.Ongoing
            };

            #endregion
            var data = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetAll(query);

            var products = ProductManagerApplication.GetProducts(data.Models.Select(p => p.ProductId));
            var list     = data.Models.ToList().Select(item => {
                var product = products.FirstOrDefault(p => p.Id == item.ProductId);
                return(new
                {
                    CountDownId = item.Id,
                    ProductId = item.ProductId,
                    ProductName = product.ProductName,
                    SalePrice = product.MarketPrice.ToString("0.##"),      //各端统一取商品市场价
                    CountDownPrice = item.MinPrice,
                    CountDownType = DateTime.Now < item.BeginDate ? 1 : 2, //1=即将开始,2=立即抢购
                    ThumbnailUrl160 = Core.HimallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_220)
                });
            });
            return(JsonResult <dynamic>(list));
        }
Пример #3
0
        /// <summary>
        /// 添加SKU,并过滤已添加的
        /// </summary>
        /// <param name="pids"></param>
        /// <param name="shopBranchId"></param>
        /// <param name="shopId"></param>
        public static void AddProductSkus(List <long> pids, long shopBranchId, long shopId)
        {
            var products = ProductManagerApplication.GetProducts(pids, shopId);

            if (products.Count == 0)
            {
                throw new MessageException("未找到商品数据");
            }
            if (products.Any(d => d.IsOpenLadder))
            {
                throw new MessageException("不可添加阶梯价商品");
            }

            //查询已添加的SKU,用于添加时过滤
            var oldskus = Service.GetSkus(shopId, new List <long> {
                shopBranchId
            }, null).Select(e => e.SkuId);
            var allSkus        = ProductManagerApplication.GetSKUByProducts(products.Select(p => p.Id));
            var shopBranchSkus = new List <ShopBranchSkuInfo>();

            var skus = allSkus.Where(s => !oldskus.Any(sku => sku == s.Id)).Select(e => new ShopBranchSkuInfo
            {
                ProductId    = e.ProductId,
                SkuId        = e.Id,
                ShopId       = shopId,
                ShopBranchId = shopBranchId,
                Stock        = 0,
                CreateDate   = DateTime.Now
            });

            shopBranchSkus.AddRange(skus);
            Service.AddSkus(shopBranchSkus);
        }
Пример #4
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 });
        }
Пример #5
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 });
        }
Пример #6
0
        public object GetShopHome()
        {
            CheckUserLogin();

            DateTime nowDt = DateTime.Now;
            //三个月内预约单
            OrderQuery query = new OrderQuery()
            {
                ShopId = this.CurrentUser.ShopId, StartDate = nowDt.Date.AddDays(-nowDt.Day).AddMonths(-2), EndDate = nowDt
            };
            var orders            = OrderApplication.GetOrdersNoPage(query);
            var threeMonthAmounht = orders.Sum(e => e.ActualPayAmount);
            //从三个月的数据中统计本周的
            DateTime weekStartDt = nowDt.Date.AddDays(-(int)nowDt.DayOfWeek);
            var      weekAmount  = orders.Where(e => e.OrderDate >= weekStartDt).Sum(e => e.ActualPayAmount);
            //从三个月的数据中统计当天的
            var todayAmount = orders.Where(e => e.OrderDate.Date == nowDt.Date).Sum(e => e.ActualPayAmount);


            //近三天发布诊疗项目数
            ProductQuery productQuery = new ProductQuery();

            productQuery.AuditStatus = new[] { ProductInfo.ProductAuditStatus.Audited };
            productQuery.StartDate   = nowDt.Date.AddDays(-2);
            productQuery.EndDate     = nowDt;
            productQuery.PageNo      = 1;
            productQuery.PageSize    = int.MaxValue;

            var products     = ProductManagerApplication.GetProducts(productQuery).Models;
            var productCount = products.Select(e => e.Id).Count();

            RefundQuery refundQuery = new RefundQuery()
            {
                AuditStatus = OrderRefundInfo.OrderRefundAuditStatus.WaitAudit,
                PageNo      = 1,
                PageSize    = int.MaxValue
            };
            var refunds     = RefundApplication.GetOrderRefunds(refundQuery);
            var refundCount = refunds.Total;


            return(Json(new
            {
                success = true,
                data = new
                {
                    shopName = CurrentShopBranch.ShopBranchName,
                    todayAmount = todayAmount,
                    weekAmount = weekAmount,
                    threeMonthAmounht = threeMonthAmounht,
                    createProductCount = productCount,
                    refundCount = refundCount
                }
            }));
        }
Пример #7
0
        //TODO:DZY[171121]前台没看到调用代码
        public JsonResult LoadProducts(int page, int pageSize)
        {
            var homeProducts = ServiceApplication.Create <IMobileHomeProductsService>().GetMobileHomeProducts(0, Core.PlatformType.WeiXin, page, pageSize);
            var products     = ProductManagerApplication.GetProducts(homeProducts.Models.Select(p => p.ProductId));
            var model        = products.Select(item => new
            {
                name        = item.ProductName,
                id          = item.Id,
                image       = item.GetImage(ImageSize.Size_350),
                price       = item.MinSalePrice,
                marketPrice = item.MarketPrice
            });

            return(Json(model));
        }
Пример #8
0
        // GET: Web/Topic
        public ActionResult Detail(long id)
        {
            var topic = TopicApplication.GetTopic(id);

            if (topic == null)
            {
                //404页面
            }
            var model = new TopicViewModel();

            model.Topic          = topic;
            model.Modules        = TopicApplication.GetModules(id);
            model.ModuleProducts = TopicApplication.GetModuleProducts(model.Modules.Select(p => p.Id));
            model.Products       = ProductManagerApplication.GetProducts(model.ModuleProducts.Select(p => p.ProductId));
            ViewBag.Keyword      = SiteSettings.Keyword;
            return(View(model));
        }
Пример #9
0
        public JsonResult GetlimitTimeProducts(LimitTimeQuery query)
        {
            query.ShopId = this.CurrentShop.Id;//只取当前商家的限时购商品
            // var result =  EngineContext.Current.Resolve<ILimitTimeBuyService>().GetFlashSaleInfos(query);

            var result = EngineContext.Current.Resolve <ILimitTimeBuyService>().GetFlashSaleInfos(query);

            var products = ProductManagerApplication.GetProducts(result.Models.Select(p => p.ProductId));
            var shops    = ShopApplication.GetShops(result.Models.Select(p => p.ShopId));
            var market   = result.Models.Select(item =>
            {
                var product = products.FirstOrDefault(p => p.Id == item.ProductId);
                var shop    = shops.FirstOrDefault(p => p.Id == item.ShopId);
                var m       = new FlashSaleModel
                {
                    Id          = item.Id,
                    Title       = item.Title,
                    BeginDate   = item.BeginDate.ToString("yyyy-MM-dd"),
                    EndDate     = item.EndDate.ToString("yyyy-MM-dd"),
                    ShopName    = shop.ShopName,
                    ProductName = product.ProductName,
                    ProductId   = item.ProductId,
                    StatusStr   = item.Status.ToDescription()
                };
                if (item.Status != FlashSaleInfo.FlashSaleStatus.WaitForAuditing && item.Status != FlashSaleInfo.FlashSaleStatus.AuditFailed && item.BeginDate > DateTime.Now && item.EndDate < DateTime.Now)
                {
                    m.StatusStr = "进行中";
                }
                else if (item.Status != FlashSaleInfo.FlashSaleStatus.WaitForAuditing && item.Status != FlashSaleInfo.FlashSaleStatus.AuditFailed && item.BeginDate > DateTime.Now)
                {
                    m.StatusStr = "未开始";
                }
                m.SaleCount   = item.SaleCount;
                m.MinPrice    = item.MinPrice;
                m.MarketPrice = product.MarketPrice;
                m.ProductImg  = MallIO.GetProductSizeImage(product.ImagePath, 1, (int)ImageSize.Size_350);
                return(m);
            });
            var dataGrid = new DataGridModel <FlashSaleModel>()
            {
                rows = market, total = result.Total
            };

            return(Json(dataGrid));
        }
        public object GetProducts(
            string keywords = "", /* 搜索关键字 */
            long cid        = 0,  /* 分类ID */
            int pageNo      = 1,  /*页码*/
            int pageSize    = 10  /*每页显示数据量*/
            )
        {
            CheckUserLogin();
            ProductSearch model = new ProductSearch()
            {
                shopId           = CurrentShopBranch.ShopId,
                Keyword          = keywords,
                PageNumber       = pageNo,
                PageSize         = pageSize,
                CategoryId       = cid,
                shopBranchId     = CurrentShopBranch.Id,
                HasLadderProduct = true
            };

            model.AttrIds = new List <string>()
            {
            };
            var products = ProductManagerApplication.GetProducts(model);
            var skus     = ProductManagerApplication.GetSKUByProducts(products.Models.Select(p => p.Id));

            var product = products.Models.Select(item => new
            {
                id               = item.Id,
                name             = item.ProductName,
                price            = item.MinSalePrice,
                salesCount       = item.SaleCounts + Mall.Core.Helper.TypeHelper.ObjectToInt(item.VirtualSaleCounts),
                img              = Core.MallIO.GetRomoteProductSizeImage(item.RelativePath, 1, (int)ImageSize.Size_100),
                stock            = skus.Where(sku => sku.ProductId == item.Id).Sum(sku => (long?)sku.Stock).GetValueOrDefault(0),
                productCode      = item.ProductCode,
                isSaleCountOnOff = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1
            }).ToList();
            var result = new
            {
                success  = true,
                products = product,
                total    = products.Total
            };

            return(result);
        }
Пример #11
0
        public ActionResult AddFloor(long?id = 0)
        {
            var model = new ShopModuleViewModel();

            if (id.HasValue && id > 0)
            {
                model.Module         = _iShopHomeModuleService.GetShopHomeModuleInfo(CurrentSellerManager.ShopId, id.Value);
                model.ModuleProducts = _iShopHomeModuleService.GetProducts(new List <long> {
                    id.Value
                });
                model.Images = _iShopHomeModuleService.GetImages(new List <long> {
                    id.Value
                });
                model.Products = ProductManagerApplication.GetProducts(model.ModuleProducts.Select(p => p.ProductId));
            }

            return(View(model));
        }
        /// <summary>
        /// 门店查询诊所诊疗项目
        /// </summary>
        /// <param name="keywords"></param>
        /// <param name="pageNo"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public object GetProducts(
            string keywords = "", /* 搜索关键字 */
            long cid        = 0,  /* 分类ID */
            int pageNo      = 1,  /*页码*/
            int pageSize    = 10  /*每页显示数据量*/
            )
        {
            CheckUserLogin();
            ProductSearch model = new ProductSearch()
            {
                shopId       = CurrentShopBranch.ShopId,
                Keyword      = keywords,
                PageNumber   = pageNo,
                PageSize     = pageSize,
                CategoryId   = cid,
                shopBranchId = CurrentShopBranch.Id
            };

            model.AttrIds = new List <string>()
            {
            };
            var products = ProductManagerApplication.GetProducts(model);
            var skus     = SKUApplication.GetByProductIds(products.Models.Where(p => p.SKUS == null).Select(p => p.Id));
            var product  = products.Models.ToList().Select(item => new
            {
                id          = item.Id,
                name        = item.ProductName,
                price       = item.MinSalePrice,
                salesCount  = item.SaleCounts,
                img         = Core.HimallIO.GetRomoteProductSizeImage(item.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_100),
                stock       = item.SKUS == null ? skus.Where(sku => sku.ProductId == item.Id).Sum(sku => sku.Stock) : item.SKUS.Sum(e => e.Stock),
                productCode = item.ProductCode
            });
            var result = new
            {
                success  = true,
                products = product,
                total    = products.Total
            };

            return(Json(result));
        }
Пример #13
0
        public ActionResult Home(string catename = "")
        {
            List <SelectListItem> CateSelItem = new List <SelectListItem>();
            var cateArray = _iLimitTimeBuyService.GetServiceCategories();

            foreach (var cate in cateArray)
            {
                CateSelItem.Add(new SelectListItem {
                    Selected = false, Text = cate, Value = cate
                });
            }
            if (!string.IsNullOrWhiteSpace(catename))
            {
                var _tmp = CateSelItem.FirstOrDefault(c => c.Text.Equals(catename));
                if (_tmp != null)
                {
                    _tmp.Selected = true;
                }
            }
            var flashSaleConfig = _iLimitTimeBuyService.GetConfig();

            ViewBag.Preheat = flashSaleConfig.Preheat;
            ViewBag.Cate    = CateSelItem;
            #region 初始化查询Model
            FlashSaleQuery query = new FlashSaleQuery()
            {
                CategoryName       = catename,
                OrderKey           = 5, /* 排序项(1:默认,2:销量,3:价格,4 : 结束时间,5:状态 开始排前面) */
                IsPreheat          = true,
                PageNo             = 1,
                PageSize           = 14,
                AuditStatus        = FlashSaleInfo.FlashSaleStatus.Ongoing,
                CheckProductStatus = true
            };

            #endregion
            var model = _iLimitTimeBuyService.GetAll(query);

            ViewBag.Products = ProductManagerApplication.GetProducts(model.Models.Select(p => p.ProductId));
            return(View(model));
        }
Пример #14
0
        public ActionResult GetData(int index, int size, string cname)
        {
            #region 初始化查询Model
            FlashSaleQuery query = new FlashSaleQuery()
            {
                ItemName           = cname,
                OrderKey           = 5, /* 排序项(1:默认,2:销量,3:价格,4 : 结束时间,5:状态 开始排前面) */
                IsPreheat          = true,
                PageNo             = index,
                PageSize           = size,
                AuditStatus        = FlashSaleInfo.FlashSaleStatus.Ongoing,
                CheckProductStatus = true
            };

            #endregion
            var obj      = _iLimitTimeBuyService.GetAll(query);
            var products = ProductManagerApplication.GetProducts(obj.Models.Select(p => p.ProductId));
            List <FlashSaleModel> list = new List <FlashSaleModel>();
            foreach (var model in obj.Models)
            {
                var            product = products.FirstOrDefault(p => p.Id == 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            = Mall.Core.MallIO.GetProductSizeImage(product.RelativePath, 1);
                result.MarketPrice           = product.MarketPrice;
                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              = model.MinPrice;
                list.Add(result);
            }
            return(Json(new { success = true, data = list, total = obj.Total }));
        }
Пример #15
0
        public JsonResult GetItemList(LimitTimeQuery query)
        {
            var service = _iLimitTimeBuyService;

            query.ShopId = CurrentSellerManager.ShopId;
            var result   = service.GetFlashSaleInfos(query);
            var list     = new List <FlashSaleModel>();
            var products = ProductManagerApplication.GetProducts(result.Models.Select(p => p.ProductId));

            foreach (var i in result.Models)
            {
                var product = products.FirstOrDefault(p => p.Id == i.ProductId);
                if (i.Status != FlashSaleInfo.FlashSaleStatus.WaitForAuditing && i.Status != FlashSaleInfo.FlashSaleStatus.AuditFailed && i.BeginDate > DateTime.Now && i.EndDate < DateTime.Now)
                {
                    i.Status = FlashSaleInfo.FlashSaleStatus.Ongoing;
                }
                else if (i.Status != FlashSaleInfo.FlashSaleStatus.WaitForAuditing && i.Status != FlashSaleInfo.FlashSaleStatus.AuditFailed && i.BeginDate > DateTime.Now)
                {
                    i.Status = FlashSaleInfo.FlashSaleStatus.NotBegin;
                }
                list.Add(new FlashSaleModel
                {
                    Id                    = i.Id,
                    BeginDate             = i.BeginDate.ToString("yyyy-MM-dd HH:mm"),
                    EndDate               = i.EndDate.ToString("yyyy-MM-dd HH:mm"),
                    ProductId             = i.ProductId,
                    SaleCount             = i.SaleCount,
                    ProductName           = product.ProductName,
                    StatusNum             = (int)i.Status,
                    StatusStr             = i.Status.ToDescription(),
                    LimitCountOfThePeople = i.LimitCountOfThePeople,
                    IsStarted             = (i.BeginDate > DateTime.Now)
                });
            }
            var model = new { rows = list, total = result.Total };

            return(Json(model));
        }
Пример #16
0
        public object GetLismitBuyList(int pageNo, int pageSize, string cateName = "")
        {
            #region 初始化查询Model
            FlashSaleQuery query = new FlashSaleQuery()
            {
                ItemName           = cateName,
                IsPreheat          = true,
                PageNo             = pageNo,
                PageSize           = pageSize,
                AuditStatus        = FlashSaleInfo.FlashSaleStatus.Ongoing,
                CheckProductStatus = true,
                OrderKey           = 5 /* 排序项(1:默认,2:销量,3:价格,4 : 结束时间,5:状态 开始排前面) */
            };

            #endregion

            var data = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetAll(query);

            var products = ProductManagerApplication.GetProducts(data.Models.Select(p => p.ProductId));



            var list = data.Models.Select(item => {
                var product = products.FirstOrDefault(p => p.Id == item.ProductId);
                return(new
                {
                    Id = item.Id,
                    ProductId = item.ProductId,
                    ProductImg = MallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)ImageSize.Size_350),
                    ProductName = product.ProductName,
                    MinPrice = item.MinPrice,
                    EndDate = item.EndDate,
                    MarketPrice = product.MarketPrice
                });
            }).ToList();

            return(new { success = true, total = data.Total, List = list });
        }
Пример #17
0
        public ActionResult Index(int pageSize = 10, int pageNo = 1)
        {
            var        model = _iProductService.GetUserConcernProducts(CurrentUser.Id, pageNo, pageSize);
            PagingInfo info  = new PagingInfo
            {
                CurrentPage  = pageNo,
                ItemsPerPage = pageSize,
                TotalItems   = model.Total
            };

            ViewBag.pageInfo = info;
            ViewBag.Keyword  = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword;
            ViewBag.Keywords = SiteSettings.HotKeyWords;
            if (model.Models.Count == 0 && pageNo > 1)
            {//如果当前页没有数据,跳转到前一页
                return(Redirect("/ProductConcern/Index?pageNo=" + (pageNo - 1)));
            }
            ViewBag.Products = ProductManagerApplication.GetProducts(model.Models.Select(p => p.ProductId));
            ViewBag.SKUs     = ProductManagerApplication.GetSKUsByProduct(model.Models.Select(p => p.ProductId));
            //TODO:FG 此实现待优化
            ViewBag.Comments = CommentApplication.GetCommentsByProduct(model.Models.Select(p => p.ProductId));
            return(View(model.Models));
        }
Пример #18
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);
        }
Пример #19
0
        /// <summary>
        /// 获取当前商家的商品列表
        /// </summary>
        /// <param name="start_modified"></param>
        /// <param name="end_modified"></param>
        /// <param name="approve_status"></param>
        /// <param name="q"></param>
        /// <param name="order_by"></param>
        /// <param name="page_no"></param>
        /// <param name="page_size"></param>
        /// <param name="app_key"></param>
        /// <returns></returns>
        public QueryPageModel <product_list_model> GetSoldProducts(DateTime?start_modified, DateTime?end_modified, string approve_status, string q, string order_by, int page_no, int page_size, string app_key)
        {
            InitShopInfo(app_key);


            var resultdata = new List <product_list_model>();

            #region 构建查询条件
            var query = new ProductQuery()
            {
                PageSize = page_size,
                PageNo   = page_no,
                KeyWords = q
            };
            query.ShopId = shopId;
            if (start_modified != null)
            {
                query.StartDate = start_modified;
            }
            if (end_modified != null)
            {
                query.EndDate = end_modified;
            }
            ProductStatus queryps = ProductStatus.In_Stock;
            if (!string.IsNullOrWhiteSpace(approve_status))
            {
                if (Enum.TryParse(approve_status, true, out queryps))
                {
                    switch (queryps)
                    {
                    case ProductStatus.In_Stock:
                        query.SaleStatus = Entities.ProductInfo.ProductSaleStatus.InStock;
                        break;

                    case ProductStatus.On_Sale:
                        query.SaleStatus  = Entities.ProductInfo.ProductSaleStatus.OnSale;
                        query.AuditStatus = new[] { Entities.ProductInfo.ProductAuditStatus.Audited };
                        break;

                    case ProductStatus.Un_Sale:
                        query.AuditStatus = new[] { Entities.ProductInfo.ProductAuditStatus.WaitForAuditing, Entities.ProductInfo.ProductAuditStatus.InfractionSaleOff };
                        break;

                    default:
                        throw new MallApiException(OpenApiErrorCode.Product_ApproveStatus_Faild, "approve_status");
                    }
                }
                else
                {
                    throw new MallApiException(OpenApiErrorCode.Product_ApproveStatus_Faild, "approve_status");
                }
            }
            if (!string.IsNullOrWhiteSpace(order_by))
            {
                bool _orderasc = true;
                if (order_by.IndexOf(":desc") > 0)
                {
                    _orderasc = false;
                }
                order_by        = order_by.Split(':')[0];
                query.OrderKey  = 1;
                query.OrderType = _orderasc;
                switch (order_by)
                {
                case "create_time":
                    query.OrderKey = 2;
                    break;

                case "sold_quantity":
                    query.OrderKey = 3;
                    break;
                }
            }
            #endregion

            var proqlist = ProductManagerApplication.GetProducts(query);
            return(new QueryPageModel <product_list_model>
            {
                Total = proqlist.Total,
                Models = ProductInfoListMapChange(proqlist.Models)
            });
        }
Пример #20
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));
        }
Пример #21
0
        public object GetShopProducts(
            string status,        /* 销售中0, 仓库中1, 待审核2,违规下架3 */
            string keywords = "", /* 搜索关键字 */
            long cid        = 0,  /* 分类ID */
            int pageNo      = 1,  /*页码*/
            int pageSize    = 10  /*每页显示数据量*/
            )
        {
            CheckUserLogin();
            ProductQuery query = new ProductQuery
            {
                PageNo   = pageNo,
                PageSize = pageSize,
                KeyWords = keywords,
                ShopId   = CurrentShop.Id
            };

            if (!string.IsNullOrWhiteSpace(status))
            {
                switch (status)
                {
                case "0":
                    query.SaleStatus  = Entities.ProductInfo.ProductSaleStatus.OnSale;
                    query.AuditStatus = new Entities.ProductInfo.ProductAuditStatus[] { Entities.ProductInfo.ProductAuditStatus.Audited };
                    break;

                case "1":
                    query.SaleStatus  = Entities.ProductInfo.ProductSaleStatus.InStock;
                    query.AuditStatus = new Entities.ProductInfo.ProductAuditStatus[] { Entities.ProductInfo.ProductAuditStatus.Audited, Entities.ProductInfo.ProductAuditStatus.UnAudit, Entities.ProductInfo.ProductAuditStatus.WaitForAuditing };
                    break;

                case "2":
                    query.SaleStatus  = Entities.ProductInfo.ProductSaleStatus.OnSale;
                    query.AuditStatus = new Entities.ProductInfo.ProductAuditStatus[] { Entities.ProductInfo.ProductAuditStatus.WaitForAuditing };
                    break;

                case "3":
                    query.AuditStatus = new Entities.ProductInfo.ProductAuditStatus[] { Entities.ProductInfo.ProductAuditStatus.InfractionSaleOff };
                    break;
                }
            }

            if (cid > 0)
            {
                query.ShopCategoryId = cid;
            }
            //查询商品
            var products = ProductManagerApplication.GetProducts(query);
            var pids     = products.Models.Select(e => e.Id);
            var skus     = ProductManagerApplication.GetSKUByProducts(pids);
            //查询门店SKU库存
            var list = products.Models.Select(item =>
            {
                return(new
                {
                    id = item.Id,
                    name = item.ProductName,
                    price = item.MinSalePrice,
                    salesCount = item.SaleCounts,
                    img = Core.MallIO.GetRomoteProductSizeImage(item.RelativePath, 1, (int)CommonModel.ImageSize.Size_350),
                    stock = skus.Where(e => e.ProductId == item.Id).Sum(e => e.Stock),
                    productCode = item.ProductCode
                });
            });
            var result = new
            {
                success  = true,
                products = list,
                total    = products.Total,
            };

            return(result);
        }
Пример #22
0
        /// <summary>
        /// 查询商品
        /// </summary>
        /// <param name="timeStamp"></param>
        /// <param name="uCode"></param>
        /// <param name="mType"></param>
        /// <param name="Sign"></param>
        /// <param name="PageSize"></param>
        /// <param name="Page"></param>
        /// <param name="GoodsType"></param>
        /// <param name="OuterID"></param>
        /// <param name="GoodsName"></param>
        /// <returns></returns>
        public string findProduct(HttpContext context)
        {
            string uCode     = context.Request["uCode"];
            string PageSize  = context.Request["PageSize"];
            string Page      = context.Request["Page"];
            string GoodsType = context.Request["GoodsType"];
            string OuterID   = context.Request["OuterID"];
            string GoodsName = context.Request["GoodsName"];


            ProductQuery query      = new ProductQuery();
            int          page_size  = 0;
            int          page_index = 0;

            if (!string.IsNullOrEmpty(PageSize))
            {
                page_size = Convert.ToInt32(PageSize);
            }
            if (!string.IsNullOrEmpty(Page))
            {
                page_index = Convert.ToInt32(Page);
            }
            string type = null;
            string code = null;
            string name = null;

            Entities.ProductInfo.ProductSaleStatus status = new Entities.ProductInfo.ProductSaleStatus();
            if (!string.IsNullOrWhiteSpace(GoodsType)) //按类型
            {
                type = GoodsType;                      //1在售 2下架
                if (type.Equals("OnSale"))
                {
                    status = Entities.ProductInfo.ProductSaleStatus.OnSale;
                }
                else if (type.Equals("InStock"))
                {
                    status = Entities.ProductInfo.ProductSaleStatus.InStock;
                }
            }
            else if (!string.IsNullOrWhiteSpace(OuterID))//按商家编码
            {
                code = OuterID;
            }
            else if (!string.IsNullOrWhiteSpace(GoodsName))//按商品名称
            {
                name = GoodsName;
            }
            query.PageSize    = page_size;
            query.PageNo      = page_index;
            query.SaleStatus  = status;
            query.KeyWords    = name;
            query.ProductCode = code;
            query.ShopId      = 1;
            if (ServiceApplication.Create <IShopService>().GetshopInfoByCode(uCode) != null)
            {
                query.ShopId = ServiceApplication.Create <IShopService>().GetshopInfoByCode(uCode).ShopId; //根据uCode获取店铺信息
            }
            var           products = ProductManagerApplication.GetProducts(query);
            StringBuilder sb       = new StringBuilder();

            sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            try
            {
                sb.Append("<Goods>");
                foreach (var item in products.Models)
                {
                    sb.Append("<Ware>");

                    bool hasSku = ProductManagerApplication.HasSKU(item.Id);

                    int isSku = hasSku ? 1 : 0;
                    sb.Append(string.Format("<ItemID><![CDATA[{0}]]></ItemID>", item.Id));
                    sb.Append(string.Format("<ItemName><![CDATA[{0}]]></ItemName>", item.ProductName));
                    sb.Append(string.Format("<OuterID><![CDATA[{0}]]></OuterID>", item.ProductCode));
                    sb.Append(string.Format("<Price><![CDATA[{0}]]></Price>", item.MinSalePrice));
                    sb.Append(string.Format("<IsSku><![CDATA[{0}]]></IsSku>", isSku));
                    var skus = ProductManagerApplication.GetSKUs(item.Id);
                    sb.Append(string.Format("<Num><![CDATA[{0}]]></Num>", skus.Sum(d => d.Stock)));//总数
                    sb.Append("<Items>");
                    if (hasSku)
                    {
                        foreach (var sku in skus)
                        {
                            sb.Append("<Item>");
                            sb.Append(string.Format("<Unit><![CDATA[{0}]]></Unit>", sku.Color + " " + sku.Size + " " + sku.Version));
                            sb.Append(string.Format("<SkuOuterID><![CDATA[{0}]]></SkuOuterID>", sku.Sku));
                            sb.Append(string.Format("<SkuID><![CDATA[{0}]]></SkuID>", sku.Id));
                            sb.Append(string.Format("<Num><![CDATA[{0}]]></Num>", sku.Stock));
                            sb.Append(string.Format("<SkuPrice><![CDATA[{0}]]></SkuPrice>", sku.SalePrice));
                            sb.Append("</Item>");
                        }
                    }
                    sb.Append("</Items>");
                    sb.Append("</Ware>");
                }
                sb.Append("<Result>1</Result>");
                sb.Append(string.Format("<TotalCount>{0}</TotalCount>", products.Total));
                sb.Append("<Cause></Cause>");
                sb.Append("</Goods>");
            }
            catch (Exception ex)
            {
                sb.Clear();
                sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                sb.Append("<Rsp><Result>0</Result><Cause>" + ex.Message + "</Cause></Rsp>");
            }
            return(sb.ToString());
        }
Пример #23
0
        // GET: Web/LimitTimeBuy
        public ActionResult Home(
            string keywords = "", /* 搜索关键字 */
            string catename = "", /* 分类名*/
            int orderKey    = 5,  /* 排序项(1:默认,2:销量,3:价格,4 : 结束时间,5:状态) */
            int orderType   = 1,  /* 排序方式(1:升序,2:降序) */
            int isStart     = 0,  /*是否开始( 1 : 开始 , 2 : 未开始 )*/
            int pageNo      = 1,  /*页码*/
            int pageSize    = 60  /*每页显示数据量*/
            )
        {
            #region 初始化查询Model
            FlashSaleQuery model = new FlashSaleQuery()
            {
                ItemName           = keywords,
                OrderKey           = orderKey,
                OrderType          = orderType,
                CategoryName       = catename,
                IsStart            = isStart,
                IsPreheat          = true,
                PageNo             = pageNo,
                PageSize           = pageSize,
                AuditStatus        = FlashSaleInfo.FlashSaleStatus.Ongoing,
                CheckProductStatus = true
            };

            #endregion

            #region ViewBag

            List <SelectListItem> CateSelItem = new List <SelectListItem>();
            var cateArray = _iLimitTimeBuyService.GetServiceCategories();
            foreach (var cate in cateArray)
            {
                CateSelItem.Add(new SelectListItem {
                    Selected = false, Text = cate, Value = cate
                });
            }
            if (!string.IsNullOrWhiteSpace(catename))
            {
                var _tmp = CateSelItem.FirstOrDefault(c => c.Text.Equals(catename));
                if (_tmp != null)
                {
                    _tmp.Selected = true;
                }
            }

            ViewBag.Cate      = CateSelItem;
            ViewBag.keywords  = keywords;
            ViewBag.orderKey  = orderKey;
            ViewBag.orderType = orderType;
            ViewBag.catename  = catename;
            ViewBag.Logined   = (null != CurrentUser) ? 1 : 0;
            ViewBag.isStart   = isStart;
            ViewBag.Slide     = _iSlideAdsService.GetSlidAds(0, Entities.SlideAdInfo.SlideAdType.PlatformLimitTime);

            #endregion


            #region 查询商品

            //var itemsModel = _iLimitTimeBuyService.GetItemList(model);
            var itemsModel = _iLimitTimeBuyService.GetAll(model);
            int total      = itemsModel.Total;
            var items      = itemsModel.Models.ToArray();


            if (itemsModel.Total == 0)
            {
                ViewBag.keywords = keywords;
                return(View());
            }

            ViewBag.Products = ProductManagerApplication.GetProducts(items.Select(p => p.ProductId));
            #endregion


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

            return(View(items ?? new FlashSaleInfo[] { }));
        }
Пример #24
0
        public object GetVShop(long id, bool sv = false)
        {
            //Json(ErrorResult<int>("取消失败,该订单已删除或者不属于当前用户!"));
            var vshopService = ServiceProvider.Instance <IVShopService> .Create;
            var vshop        = vshopService.GetVShop(id);

            if (vshop == null)
            {
                return(ErrorResult <bool>("未开通微店!", code: -4));
            }
            if (vshop.State == Entities.VShopInfo.VShopStates.Close)
            {
                return(ErrorResult <bool>("商家暂未开通微店!", code: -5));
            }
            if (!vshop.IsOpen)
            {
                return(ErrorResult <bool>("此微店已关闭!", code: -3));
            }
            var s = ShopApplication.GetShop(vshop.ShopId);

            if (null != s && s.ShopStatus == Entities.ShopInfo.ShopAuditStatus.HasExpired)
            {
                return(ErrorResult <bool>("此店铺已过期!", code: -1));
            }
            //throw new MallApiException("此店铺已过期");
            if (null != s && s.ShopStatus == Entities.ShopInfo.ShopAuditStatus.Freeze)
            {
                return(ErrorResult <bool>("此店铺已冻结!", code: -2));
            }

            //throw new MallApiException("此店铺已冻结");

            //轮播图配置只有商家微店首页配置页面可配置,现在移动端都读的这个数据
            var slideImgs = ServiceProvider.Instance <ISlideAdsService> .Create.GetSlidAds(vshop.ShopId, Entities.SlideAdInfo.SlideAdType.VShopHome).ToList();

            //首页商品现在只有商家配置微信首页,APP读的也是这个数据所以平台类型选的的微信端
            var homeProducts = ServiceProvider.Instance <IMobileHomeProductsService> .Create.GetMobileHomeProducts(vshop.ShopId, PlatformType.WeiXin, 1, 8);

            #region 价格更新
            //会员折扣
            decimal discount   = 1M;
            long    SelfShopId = 0;
            if (CurrentUser != null)
            {
                discount = CurrentUser.MemberDiscount;
                var shopInfo = ShopApplication.GetSelfShop();
                SelfShopId = shopInfo.Id;
            }

            var limit = LimitTimeApplication.GetLimitProducts();
            var fight = FightGroupApplication.GetFightGroupPrice();

            var products    = new List <ProductItem>();
            var productData = ProductManagerApplication.GetProducts(homeProducts.Models.Select(p => p.ProductId));
            foreach (var item in homeProducts.Models)
            {
                var product = productData.FirstOrDefault(p => p.Id == item.ProductId);
                var pitem   = new ProductItem();
                pitem.Id          = item.ProductId;
                pitem.ImageUrl    = Core.MallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Mall.CommonModel.ImageSize.Size_350);
                pitem.Name        = product.ProductName;
                pitem.MarketPrice = product.MarketPrice;
                pitem.SalePrice   = product.MinSalePrice;
                if (item.ShopId == SelfShopId)
                {
                    pitem.SalePrice = product.MinSalePrice * discount;
                }
                var isLimit = limit.Where(r => r.ProductId == item.ProductId).FirstOrDefault();
                var isFight = fight.Where(r => r.ProductId == item.ProductId).FirstOrDefault();
                if (isLimit != null)
                {
                    pitem.SalePrice = isLimit.MinPrice;
                }
                if (isFight != null)
                {
                    pitem.SalePrice = isFight.ActivePrice;
                }
                products.Add(pitem);
            }
            #endregion
            var banner = ServiceProvider.Instance <INavigationService> .Create.GetSellerNavigations(vshop.ShopId, Core.PlatformType.WeiXin).ToList();

            var couponInfo = GetCouponList(vshop.ShopId);

            var SlideAds = slideImgs.ToArray().Select(item => new HomeSlideAdsModel()
            {
                ImageUrl = Core.MallIO.GetRomoteImagePath(item.ImageUrl), Url = item.Url
            });

            var Banner   = banner;
            var Products = products;

            bool favoriteShop = false;
            if (CurrentUser != null)
            {
                favoriteShop = ServiceProvider.Instance <IShopService> .Create.IsFavoriteShop(CurrentUser.Id, vshop.ShopId);
            }
            string followUrl = "";
            //快速关注
            var vshopSetting = ServiceProvider.Instance <IVShopService> .Create.GetVShopSetting(vshop.ShopId);

            if (vshopSetting != null)
            {
                followUrl = vshopSetting.FollowUrl;
            }
            var model = new
            {
                Id = vshop.Id,
                //Logo = "http://" + Url.Request.RequestUri.Host + vshop.Logo,
                Logo      = Core.MallIO.GetRomoteImagePath(vshop.StrLogo),
                Name      = vshop.Name,
                ShopId    = vshop.ShopId,
                Favorite  = favoriteShop,
                State     = vshop.State,
                FollowUrl = followUrl
            };

            // 客服
            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(vshop.ShopId);

            //统计访问量
            if (!sv)
            {
                vshopService.LogVisit(id);
                //统计店铺访问人数
                StatisticApplication.StatisticShopVisitUserCount(vshop.ShopId);
            }
            dynamic result = new ExpandoObject();
            result.VShop            = model;
            result.SlideImgs        = SlideAds;
            result.Products         = products;
            result.Banner           = banner;
            result.Coupon           = couponInfo;
            result.CustomerServices = customerServices;
            return(Json(new { result }));
        }
Пример #25
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));
        }
Пример #26
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
            }));
        }
Пример #27
0
        public object GetOrderDetail(long id)
        {
            CheckUserLogin();
            OrderInfo order = ServiceProvider.Instance <IOrderService> .Create.GetOrder(id, CurrentUser.Id);

            var    orderService       = ServiceProvider.Instance <IOrderService> .Create;
            var    bonusService       = ServiceProvider.Instance <IShopBonusService> .Create;
            var    orderRefundService = ServiceProvider.Instance <IRefundService> .Create;
            var    bonusmodel         = bonusService.GetGrantByUserOrder(id, CurrentUser.Id);
            bool   hasBonus           = bonusmodel != null ? true : false;
            string shareHref          = "";
            string shareTitle         = "";
            string shareDetail        = "";
            string shareImg           = "";

            if (hasBonus)
            {
                shareHref = CurrentUrlHelper.CurrentUrlNoPort() + "/m-weixin/shopbonus/index/" + bonusService.GetGrantIdByOrderId(id);
                var bonus = ShopBonusApplication.GetBonus(bonusmodel.ShopBonusId);
                shareTitle  = bonus.ShareTitle;
                shareDetail = bonus.ShareDetail;
                shareImg    = HimallIO.GetRomoteImagePath(bonus.ShareImg);
            }
            var vshop = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(order.ShopId);

            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(order.ShopId);

            var shop        = ShopApplication.GetShop(order.ShopId);
            var orderItems  = OrderApplication.GetOrderItemsByOrderId(order.Id);
            var products    = ProductManagerApplication.GetProducts(orderItems.Select(p => p.ProductId));
            var refunds     = OrderApplication.GetOrderRefundsByOrder(order.Id);        //获取订单商品项数据
            var orderDetail = new
            {
                ShopId     = shop.Id,
                ShopName   = shop.ShopName,
                OrderItems = orderItems.Select(item =>
                {
                    var product  = products.FirstOrDefault(p => p.Id == item.ProductId);
                    var typeInfo = TypeApplication.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 itemrefund   = refunds.FirstOrDefault(d => d.OrderItemId == item.Id && d.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund);
                    int?itemrefstate = (itemrefund == null ? null : (int?)itemrefund.SellerAuditStatus);
                    itemrefstate     = (itemrefstate > 4 ? (int?)itemrefund.ManagerConfirmStatus : itemrefstate);
                    var IsCanRefund  = OrderApplication.CanRefund(order, itemrefstate, itemId: item.Id);
                    return(new
                    {
                        ItemId = item.Id,
                        ProductId = item.ProductId,
                        ProductName = item.ProductName,
                        Count = item.Quantity,
                        Price = item.SalePrice,
                        ProductImage = Core.HimallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_100),
                        color = item.Color,
                        size = item.Size,
                        version = item.Version,
                        IsCanRefund = IsCanRefund,
                        ColorAlias = colorAlias,
                        SizeAlias = sizeAlias,
                        VersionAlias = versionAlias,
                        EnabledRefundAmount = item.EnabledRefundAmount,
                        OrderRefundId = (itemrefund == null ? 0 : itemrefund.Id),
                        RefundStats = itemrefstate
                    });
                })
            };
            //取拼团订单状态
            var fightGroupOrderInfo = ServiceProvider.Instance <IFightGroupService> .Create.GetFightGroupOrderStatusByOrderId(order.Id);

            var _ordrefobj = orderRefundService.GetOrderRefundByOrderId(order.Id) ?? new OrderRefundInfo {
                Id = 0
            };

            if (order.OrderStatus != OrderInfo.OrderOperateStatus.WaitDelivery && order.OrderStatus != OrderInfo.OrderOperateStatus.WaitSelfPickUp)
            {
                _ordrefobj = new OrderRefundInfo {
                    Id = 0
                };
            }
            int?ordrefstate = (_ordrefobj == null ? null : (int?)_ordrefobj.SellerAuditStatus);

            ordrefstate = (ordrefstate > 4 ? (int?)_ordrefobj.ManagerConfirmStatus : ordrefstate);

            var hasAppendComment = ServiceProvider.Instance <ICommentService> .Create.HasAppendComment(orderItems.FirstOrDefault().Id);

            var orderModel = new
            {
                Id                 = order.Id,
                OrderType          = order.OrderType,
                OrderTypeName      = order.OrderType.ToDescription(),
                Status             = order.OrderStatus.ToDescription(),
                JoinStatus         = fightGroupOrderInfo == null ? -2 : fightGroupOrderInfo.JoinStatus,
                ShipTo             = order.ShipTo,
                Phone              = order.CellPhone,
                Address            = order.RegionFullName + " " + order.Address,
                HasExpressStatus   = !string.IsNullOrWhiteSpace(order.ShipOrderNumber),
                ExpressCompanyName = order.ExpressCompanyName,
                Freight            = order.Freight,
                Tax                = order.Tax,
                IntegralDiscount   = order.IntegralDiscount,
                RealTotalAmount    = order.OrderTotalAmount,
                CapitalAmount      = order.CapitalAmount,
                RefundTotalAmount  = order.RefundTotalAmount,
                ProductTotalAmount = order.ProductTotalAmount,
                OrderPayAmount     = order.OrderPayAmount,//订单需要第三方支付的金额
                PaymentTypeName    = PaymentApplication.GetPaymentTypeDescById(order.PaymentTypeGateway) ?? order.PaymentTypeName,
                PaymentTypeDesc    = order.PaymentTypeDesc,
                OrderDate          = order.OrderDate.ToString("yyyy-MM-dd HH:mm:ss"),
                ShopName           = order.ShopName,
                VShopId            = vshop == null ? 0 : vshop.Id,
                commentCount       = OrderApplication.GetOrderCommentCount(order.Id),
                ShopId             = order.ShopId,
                orderStatus        = (int)order.OrderStatus,
                //Invoice = order.InvoiceType.ToDescription(),
                //InvoiceValue = (int)order.InvoiceType,
                //InvoiceContext = order.InvoiceContext,
                //InvoiceTitle = order.InvoiceTitle,
                //InvoiceCode = order.InvoiceCode,
                PaymentType         = order.PaymentType.ToDescription(),
                PaymentTypeValue    = (int)order.PaymentType,
                FullDiscount        = order.FullDiscount,
                DiscountAmount      = order.DiscountAmount,
                OrderRemarks        = string.IsNullOrEmpty(order.OrderRemarks) ? "" : order.OrderRemarks,
                HasBonus            = hasBonus,
                ShareHref           = shareHref,
                ShareTitle          = shareTitle,
                ShareDetail         = shareDetail,
                ShareImg            = shareImg,
                IsCanRefund         = !(orderDetail.OrderItems.Any(e => e.IsCanRefund == true)) && OrderApplication.CanRefund(order, ordrefstate, null),
                RefundStats         = ordrefstate,
                OrderRefundId       = _ordrefobj.Id > 0 ? _ordrefobj.Id : 0,
                EnabledRefundAmount = order.OrderEnabledRefundAmount,
                HasAppendComment    = hasAppendComment,
                SelfTake            = order.DeliveryType == Himall.CommonModel.DeliveryType.SelfTake ? 1 : 0,
                OrderInvoice        = OrderApplication.GetOrderInvoiceInfo(order.Id)
            };

            #region 门店配送信息
            Himall.DTO.ShopBranch storeInfo = null;
            if (order.ShopBranchId > 0)
            {
                storeInfo = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
            }
            #endregion
            #region 虚拟订单信息
            VirtualProductInfo virtualProductInfo = null;
            int            validityType = 0; string startDate = string.Empty, endDate = string.Empty;
            List <dynamic> orderVerificationCodes = null;
            List <dynamic> virtualOrderItemInfos  = null;
            bool           isCanRefundVirtual     = false;
            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                var orderItemInfo = orderItems.FirstOrDefault();
                if (orderItemInfo != null)
                {
                    virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId);
                    if (virtualProductInfo != null)
                    {
                        validityType = virtualProductInfo.ValidityType ? 1 : 0;
                        if (validityType == 1)
                        {
                            startDate = virtualProductInfo.StartDate.Value.ToString("yyyy-MM-dd");
                            endDate   = virtualProductInfo.EndDate.Value.ToString("yyyy-MM-dd");
                        }
                    }
                    var codes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>()
                    {
                        order.Id
                    });
                    orderVerificationCodes = codes.Select(p =>
                    {
                        return(new
                        {
                            VerificationCode = Regex.Replace(p.VerificationCode, @"(\d{4})", "$1 "),
                            Status = p.Status,
                            StatusText = p.Status.ToDescription(),
                            QRCode = GetQRCode(p.VerificationCode)
                        });
                    }).ToList <dynamic>();

                    var virtualItems = OrderApplication.GetVirtualOrderItemInfosByOrderId(order.Id);
                    virtualOrderItemInfos = virtualItems.Select(p =>
                    {
                        return(new
                        {
                            VirtualProductItemName = p.VirtualProductItemName,
                            Content = ReplaceImage(p.Content, p.VirtualProductItemType),
                            VirtualProductItemType = p.VirtualProductItemType
                        });
                    }).ToList <dynamic>();
                }
            }
            if (order.OrderStatus == Himall.Entities.OrderInfo.OrderOperateStatus.WaitVerification)
            {
                if (virtualProductInfo != null)
                {
                    if (virtualProductInfo.SupportRefundType == 2)
                    {
                        isCanRefundVirtual = true;
                    }
                    else if (virtualProductInfo.SupportRefundType == 1)
                    {
                        if (virtualProductInfo.EndDate.Value > DateTime.Now)
                        {
                            isCanRefundVirtual = true;
                        }
                    }
                    else if (virtualProductInfo.SupportRefundType == 3)
                    {
                        isCanRefundVirtual = false;
                    }

                    if (isCanRefundVirtual)
                    {
                        long num = orderVerificationCodes.Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification).Count();
                        if (num > 0)
                        {
                            isCanRefundVirtual = true;
                        }
                        else
                        {
                            isCanRefundVirtual = false;
                        }
                    }
                }
            }
            #endregion
            #region 虚拟订单核销地址信息
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;
            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                if (order.ShopBranchId > 0 && storeInfo != null)
                {
                    shipperAddress  = RegionApplication.GetFullName(storeInfo.AddressId) + " " + storeInfo.AddressDetail;
                    shipperTelPhone = storeInfo.ContactPhone;
                }
                else
                {
                    var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(order.ShopId);
                    if (verificationShipper != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                        shipperTelPhone = verificationShipper.TelPhone;
                    }
                }
            }
            #endregion
            return(new
            {
                success = true,
                Order = orderModel,
                OrderItem = orderDetail.OrderItems,
                StoreInfo = storeInfo,
                CustomerServices = customerServices,
                ValidityType = validityType,
                StartDate = startDate,
                EndDate = endDate,
                OrderVerificationCodes = orderVerificationCodes,
                VirtualOrderItemInfos = virtualOrderItemInfos,
                IsCanRefundVirtual = isCanRefundVirtual,
                ShipperAddress = shipperAddress,
                ShipperTelPhone = shipperTelPhone
            });
        }
Пример #28
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
        }
Пример #29
0
        public object GetVShopHome(int pageNo, int pageSize)
        {
            dynamic      result   = new System.Dynamic.ExpandoObject();
            TopShopModel topVShop = new TopShopModel();
            var          service  = ServiceProvider.Instance <IVShopService> .Create;
            var          topShop  = service.GetTopShop();

            if (topShop != null)
            {
                var query = new ProductQuery()
                {
                    PageSize    = 3,
                    PageNo      = 1,
                    ShopId      = topShop.ShopId,
                    AuditStatus = new Entities.ProductInfo.ProductAuditStatus[] { Entities.ProductInfo.ProductAuditStatus.Audited },
                    SaleStatus  = Entities.ProductInfo.ProductSaleStatus.OnSale
                };
                var products        = ProductManagerApplication.GetProducts(query).Models;
                var topShopProducts = products.ToArray().Select(item => new HomeProduct()
                {
                    Id          = item.Id.ToString(),
                    ImageUrl    = Core.MallIO.GetRomoteProductSizeImage(item.RelativePath, 1, (int)Mall.CommonModel.ImageSize.Size_350),
                    MarketPrice = item.MarketPrice.ToString(),
                    Name        = item.ProductName,
                    SalePrice   = item.MinSalePrice.ToString(),
                    Url         = Core.MallIO.GetRomoteImagePath("/m-IOS/product/detail/") + item.Id
                });
                topVShop.Success  = "true";
                topVShop.ShopName = topShop.Name;
                topVShop.VShopId  = topShop.Id.ToString();
                topVShop.ShopId   = topShop.ShopId.ToString();
                topVShop.ShopLogo = Core.MallIO.GetRomoteImagePath(topShop.StrLogo);
                if (!string.IsNullOrEmpty(topShop.Tags))
                {
                    if (topShop.Tags.Contains(";"))
                    {
                        topVShop.Tag1 = topShop.Tags.Split(';')[0];
                        topVShop.Tag2 = topShop.Tags.Split(';')[1];
                    }
                    else
                    {
                        topVShop.Tag1 = topShop.Tags;
                        topVShop.Tag2 = "";
                    }
                }


                topVShop.Products = topShopProducts;//主推店铺的商品
                topVShop.Url      = Core.MallIO.GetRomoteImagePath("/m-IOS/vshop/detail/") + topShop.Id;
                if (CurrentUser != null)
                {
                    var favoriteTShopIds = ServiceProvider.Instance <IShopService> .Create.GetFavoriteShopInfos(CurrentUser.Id).Select(item => item.ShopId).ToArray();//获取已关注店铺

                    topVShop.IsFavorite = favoriteTShopIds.Contains(topShop.ShopId) ? true : false;
                }
                topVShop.productCount   = ShopApplication.GetShopProductCount(topShop.ShopId);
                topVShop.FavoritesCount = ServiceProvider.Instance <IShopService> .Create.GetShopFavoritesCount(topShop.ShopId);//关注人数
            }


            int total    = 0;
            var hotShops = ServiceProvider.Instance <IVShopService> .Create.GetHotShops(pageNo, pageSize, out total).ToArray();//获取热门微店

            var homeProductService = ServiceProvider.Instance <IMobileHomeProductsService> .Create;

            long[] favoriteShopIds = new long[] { };
            if (CurrentUser != null)
            {
                favoriteShopIds = ServiceProvider.Instance <IShopService> .Create.GetFavoriteShopInfos(CurrentUser.Id).Select(item => item.ShopId).ToArray();
            }
            var model = hotShops.Select(item =>
            {
                var queryModel = new ProductQuery()
                {
                    PageSize = 3,
                    PageNo   = 1,
                    ShopId   = item.ShopId,
                    OrderKey = 4//微店推荐3个商品按商家商品序号排
                };
                queryModel.AuditStatus = new Entities.ProductInfo.ProductAuditStatus[] { Entities.ProductInfo.ProductAuditStatus.Audited };
                queryModel.SaleStatus  = Entities.ProductInfo.ProductSaleStatus.OnSale;
                var products           = ProductManagerApplication.GetProducts(queryModel).Models;
                string tempTag1        = "";
                string tempTag2        = "";
                if (!string.IsNullOrEmpty(item.Tags))
                {
                    if (item.Tags.Contains(";"))
                    {
                        tempTag1 = item.Tags.Split(';')[0];
                        tempTag2 = item.Tags.Split(';')[1];
                    }
                    else
                    {
                        tempTag1 = item.Tags;
                    }
                }
                return(new
                {
                    VShopId = item.Id.ToString(),
                    ShopName = item.Name,
                    ShopLogo = Core.MallIO.GetRomoteImagePath(item.StrLogo),
                    Tag1 = tempTag1,
                    Tag2 = tempTag2,
                    Products = products.Select(t => new
                    {
                        Id = t ? .Id.ToString() ?? string.Empty,
                        Name = t.ProductName,
                        ImageUrl = Core.MallIO.GetRomoteProductSizeImage(t.RelativePath, 1, (int)Mall.CommonModel.ImageSize.Size_220),
                        SalePrice = t.MinSalePrice,
                        Url = Core.MallIO.GetRomoteImagePath("/m-IOS/product/detail/") + t.Id
                    }),
                    IsFavorite = favoriteShopIds.Contains(item.ShopId) ? true : false,
                    ShopId = item.ShopId.ToString(),
                    Url = Core.MallIO.GetRomoteImagePath("/m-IOS/vshop/detail/") + item.Id,
                    productCount = ShopApplication.GetShopProductCount(item.ShopId),
                    FavoritesCount = ServiceProvider.Instance <IShopService> .Create.GetShopFavoritesCount(item.ShopId)//关注人数
                });
            });

            result.success  = true;
            result.total    = total;
            result.HotShop  = model;
            result.TopVShop = topVShop;
            return(result);
        }
Пример #30
0
        public string DownloadProduct(HttpContext context)
        {
            string  bizcontent = context.Request["bizcontent"];
            JObject jo         = (JObject)JsonConvert.DeserializeObject(bizcontent);
            int     PageIndex  = GetJObjectValue <int>(jo, "PageIndex");

            if (PageIndex < 1)
            {
                PageIndex = 1;
            }
            int PageSize = GetJObjectValue <int>(jo, "PageSize");

            if (PageSize < 1)
            {
                PageSize = 10;
            }

            ProductQuery query = new ProductQuery
            {
                PageSize = PageSize,
                PageNo   = PageIndex,
                ShopId   = CurShopId
            };

            long ProductId = 0;

            if (jo["ProductId"] != null)
            {
                long.TryParse("", out ProductId);
            }
            if (ProductId > 0)
            {
                query.Ids = new long[] { ProductId };
            }
            string ProductName = GetJObjectValue <string>(jo, "ProductName");

            if (!string.IsNullOrWhiteSpace(ProductName))
            {
                query.KeyWords = ProductName;
            }
            string QStatus = GetJObjectValue <string>(jo, "Status");

            switch (QStatus)
            {
            case "JH_01":
                //已上架商品
                query.SaleStatus  = ProductInfo.ProductSaleStatus.OnSale;
                query.AuditStatus = new ProductInfo.ProductAuditStatus[] { ProductInfo.ProductAuditStatus.Audited };
                break;

            case "JH_02":
                //已下架商品(违规下架)
                query.AuditStatus = new ProductInfo.ProductAuditStatus[] { ProductInfo.ProductAuditStatus.InfractionSaleOff };
                break;

            case "JH_03":
                //已售罄商品(超过警界库存)
                query.OverSafeStock = true;
                break;

            case "JH_04":
                //未通过审核
                query.AuditStatus = new ProductInfo.ProductAuditStatus[] { Entities.ProductInfo.ProductAuditStatus.AuditFailed };
                break;

            case "JH_05":
                //审核中商品
                query.AuditStatus = new ProductInfo.ProductAuditStatus[] { Entities.ProductInfo.ProductAuditStatus.WaitForAuditing };
                break;

            case "JH_06":
                //即将上架商品(仓库)
                query.SaleStatus = ProductInfo.ProductSaleStatus.InStock;
                break;
            }
            var _iTypeService = ObjectContainer.Current.Resolve <Himall.IServices.ITypeService>();

            var           data = ProductManagerApplication.GetProducts(query);
            StringBuilder sb   = new StringBuilder();

            sb.Append("{");
            sb.Append("\"code\":" + "\"" + "10000" + "\"");
            sb.Append(",\"message\":" + "\"" + "SUCCESS" + "\"");
            sb.Append(",\"totalcount\":" + "\"" + data.Total + "\"");
            sb.Append(",\"goodslist\":");
            sb.Append("[");
            int curitemnum = 0;
            var allskus    = ProductManagerApplication.GetSKUByProducts(data.Models.Select(d => d.Id));

            foreach (var item in data.Models)
            {
                var skus = allskus.Where(p => p.ProductId == item.Id);
                if (curitemnum > 0)
                {
                    sb.Append(",");
                }
                sb.Append("{");
                sb.Append("\"PlatProductID\":" + "\"" + item.Id + "\"");
                sb.Append(",\"name\":" + "\"" + item.ProductName + "\"");
                sb.Append(",\"OuterID\":" + "\"" + item.Id + "\"");
                sb.Append(",\"price\":" + "\"" + item.MinSalePrice + "\"");
                sb.Append(",\"num\":" + "\"" + skus.Sum(d => d.Stock) + "\"");
                sb.Append(",\"pictureurl\":" + "\"" + HimallIO.GetProductSizeImage(item.ImagePath, 1, ImageSize.Size_400.GetHashCode()) + "\"");
                sb.Append(",\"whsecode\":" + "\"" + "" + "\"");
                sb.Append(",\"attrbutes\":");
                sb.Append("[");
                #region 商品属性填充
                var prodAttrs   = ProductManagerApplication.GetProductAttributes(item.Id);
                var prodAttrids = prodAttrs.Select(d => d.AttributeId).Distinct().ToList();

                if (prodAttrids.Count > 0)
                {
                    List <string> propslst    = new List <string>();
                    List <string> propsvallst = new List <string>();
                    int           curattrnum  = 0;
                    foreach (var curattid in prodAttrids)
                    {
                        var attr = prodAttrs.FirstOrDefault(d => d.AttributeId == curattid);
                        propsvallst.Clear();
                        var values    = _iTypeService.GetAttributeValues(curattid);
                        var attribute = _iTypeService.GetAttribute(curattid);
                        foreach (var attrV in values)
                        {
                            if (prodAttrs.Any(p => p.ValueId == attrV.Id))
                            {
                                if (curattrnum > 0)
                                {
                                    sb.Append(",");
                                }
                                sb.Append("{");
                                sb.Append("\"name\":\"" + attribute.Name + "\"");
                                sb.Append(",\"value\":\"" + attrV.Value + "\"");
                                sb.Append(",\"attributeid\":\"" + attrV.Id + "\"");
                                sb.Append(",\"iscustom\":\"1\"");
                                sb.Append("}");
                                propsvallst.Add(attrV.Value);
                                curattrnum++;
                            }
                        }
                    }
                }
                #endregion
                sb.Append("]");

                sb.Append(",\"skus\":");
                sb.Append("[");
                #region SKUS

                var    typeInfo     = TypeApplication.GetProductType(item.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 (item != null)
                {
                    colorAlias   = !string.IsNullOrWhiteSpace(item.ColorAlias) ? item.ColorAlias : colorAlias;
                    sizeAlias    = !string.IsNullOrWhiteSpace(item.SizeAlias) ? item.SizeAlias : sizeAlias;
                    versionAlias = !string.IsNullOrWhiteSpace(item.VersionAlias) ? item.VersionAlias : versionAlias;
                }
                int curskunum = 0;
                foreach (var skuitem in skus)
                {
                    if (curskunum > 0)
                    {
                        sb.Append(",");
                    }
                    string sku_properties_all_name = colorAlias + ":" + skuitem.Color + " " + sizeAlias + ":" + skuitem.Size + versionAlias + " " + ":" + skuitem.Version;
                    string sku_properties_name     = skuitem.Color + " " + skuitem.Size + " " + skuitem.Version;
                    string skuOuterID = skuitem.Sku;
                    if (string.IsNullOrWhiteSpace(skuOuterID))
                    {
                        skuOuterID = item.ProductCode;
                    }
                    sb.Append("{");
                    sb.Append("\"SkuID\":" + "\"" + skuitem.Id + "\"");
                    sb.Append(",\"skuOuterID\":" + "\"" + skuOuterID + "\"");
                    sb.Append(",\"skuprice\":" + "\"" + skuitem.SalePrice + "\"");
                    sb.Append(",\"skuQuantity\":" + "\"" + skuitem.Stock + "\"");
                    sb.Append(",\"skuname\":" + "\"" + skuitem.Sku + "\"");
                    sb.Append(",\"skuproperty\":" + "\"" + "" + "\"");
                    sb.Append(",\"skupictureurl\":" + "\"" + "" + "\"");
                    sb.Append("}");
                    curskunum++;
                }
                #endregion
                sb.Append("]");
                sb.Append("}");
                curitemnum++;
            }
            sb.Append("]");
            sb.Append("}");
            return(sb.ToString());
        }