public JsonResult GetMemberChartByMonth(int year = 0, int month = 0, DateTime?begin = null, DateTime?end = null) { var chart = new LineChartDataModel <int>(); if (begin.HasValue && end.HasValue) { chart = StatisticApplication.GetNewMemberChartByRange(begin.Value, end.Value); } else { if (year == 0) { year = DateTime.Now.Year; } if (month == 0) { month = DateTime.Now.Month; } chart = StatisticApplication.GetNewMemberChartByMonth(year, month); } return(Json(new { success = true, chart = chart }, JsonRequestBehavior.AllowGet)); }
public JsonResult GetAreaMapBySearch(SaleDimension dimension, int year = 0, int month = 0, DateTime?begin = null, DateTime?end = null) { if (begin.HasValue && end.HasValue) { end = end.Value.AddDays(1); var data = StatisticApplication.GetAreaOrderChart(dimension, begin.Value, end.Value); return(Json(new { success = true, chart = data }, true)); } else { if (year == 0) { year = DateTime.Now.Year; } if (month == 0) { month = DateTime.Now.Month; } var data = StatisticApplication.GetAreaOrderChart(dimension, year, month); return(Json(new { success = true, chart = data }, true)); } }
/// <summary> /// 个人中心主页 /// </summary> /// <returns></returns> public new JsonResult <Result <dynamic> > GetUser() { CheckUserLogin(); dynamic d = new System.Dynamic.ExpandoObject(); long id = CurrentUser.Id; var member = MemberApplication.GetMember(id); DistributorInfo currentDistributor = DistributionApplication.GetDistributor(member.Id); d.UserName = member.UserName; //用户名 d.RealName = member.RealName; //真实姓名 d.Nick = member.Nick; //昵称 d.UserId = member.Id.ToString(); d.CellPhone = member.CellPhone; //绑定的手机号码 d.Photo = String.IsNullOrEmpty(member.Photo) ? "" : HimallIO.GetRomoteImagePath(member.Photo); //头像 var statistic = StatisticApplication.GetMemberOrderStatistic(id, true); d.AllOrders = statistic.OrderCount; d.WaitingForPay = statistic.WaitingForPay; d.WaitingForRecieve = statistic.WaitingForRecieve + OrderApplication.GetWaitConsumptionOrderNumByUserId(id); d.WaitingForDelivery = statistic.WaitingForDelivery; d.WaitingForComments = statistic.WaitingForComments; d.RefundOrders = statistic.RefundCount; d.FavoriteShop = ShopApplication.GetUserConcernShopsCount(member.Id); //收藏的店铺数 d.FavoriteProduct = FavoriteApplication.GetFavoriteCountByUser(member.Id); //收藏的商品数 d.Counpon = MemberApplication.GetAvailableCouponCount(id); d.Integral = MemberIntegralApplication.GetAvailableIntegral(member.Id); //我的积分 d.Balance = MemberCapitalApplication.GetBalanceByUserId(member.Id); //我的资产 d.IsOpenRechargePresent = SiteSettingApplication.SiteSettings.IsOpenRechargePresent; var phone = SiteSettingApplication.SiteSettings.SitePhone; d.ServicePhone = string.IsNullOrEmpty(phone) ? "" : phone; d.IsDistributor = (currentDistributor != null && currentDistributor.DistributionStatus == (int)DistributorStatus.Audited); return(JsonResult <dynamic>(d)); }
public ActionResult TradeStatistic() { var yesterday = DateTime.Now.Date.AddDays(-1); var platTradeStatistic = StatisticApplication.GetShopTradeStatistic(CurrentSellerManager.ShopId, null, yesterday, yesterday); #region 是否开启门店授权 bool isOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore; if (isOpenStore) { #region 商家下所有门店 var data = ShopBranchApplication.GetShopBranchsAll(new ShopBranchQuery() { ShopId = CurrentSellerManager.ShopId }); ViewBag.StoreList = data.Models; #endregion } ViewBag.IsOpenStore = isOpenStore; var shop = ShopApplication.GetShop(CurrentSellerManager.ShopId); ViewBag.ShopName = shop.ShopName; #endregion return(View(platTradeStatistic)); }
public JsonResult GetSaleRankingChart(string day = "", int year = 0, int month = 0, int weekIndex = 0, SaleDimension dimension = SaleDimension.Count) { var model = new LineChartDataModel <int>(); if (!string.IsNullOrWhiteSpace(day)) { DateTime date = DateTime.Parse(day); StatisticApplication.GetProductSaleRankingChart(0, date, date, dimension, 15); } else { if (year == 0) { year = DateTime.Now.Year; } if (month == 0) { month = DateTime.Now.Month; } StatisticApplication.GetProductSaleRankingChart(0, year, month, weekIndex, dimension, 15); } return(Json(new { success = true, chart = model })); }
public JsonResult GetShopFlowChartByMonth(int year = 0, int month = 0, DateTime?begin = null, DateTime?end = null) { var shop = CurrentSellerManager.ShopId; if (begin.HasValue && end.HasValue) { var data = StatisticApplication.GetShopFlowChart(shop, begin.Value, end.Value); return(Json(new { success = true, chart = data }, JsonRequestBehavior.AllowGet)); } else { if (year == 0) { year = DateTime.Now.Year; } if (month == 0) { month = DateTime.Now.Month; } var data = StatisticApplication.GetShopFlowChart(shop, year, month); return(Json(new { success = true, chart = data }, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetShopSaleChartByMonth(int year = 0, int month = 0, DateTime?begin = null, DateTime?end = null) { var shop = CurrentSellerManager.ShopId; if (begin.HasValue && end.HasValue) { var data = StatisticApplication.GetShopSaleCountChartByRange(shop, string.Format("{0}至{1}店铺总销量", begin.Value.ToString("yyyy-MM-dd"), end.Value.ToString("yyyy-MM-dd")), begin.Value, end.Value); return(Json(new { success = true, chart = data }, JsonRequestBehavior.AllowGet)); } else { if (year == 0) { year = DateTime.Now.Year; } if (month == 0) { month = DateTime.Now.Month; } var data = StatisticApplication.GetShopSaleCountChartByMonth(shop, year, month); return(Json(new { success = true, chart = data }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Console() { //新首页开始 HomeModel model = new HomeModel(); var shopId = CurrentSellerManager.ShopId; /*店铺信息*/ var shop = ShopApplication.GetShop(shopId); if (shop != null) { model.SellerConsoleModel = StatisticApplication.GetSellerConsoleModel(shopId); /*公告*/ model.Articles = _iArticleService.GetTopNArticle <ArticleInfo>(6, 4); ViewBag.Logo = SiteSettingApplication.SiteSettings.MemberLogo; model.ShopId = shop.Id; model.ShopLogo = shop.Logo; model.ShopName = shop.ShopName; model.ShopEndDate = shop.EndDate.HasValue ? shop.EndDate.Value.ToString("yyyy-MM-dd") : string.Empty; model.ShopGradeName = model.SellerConsoleModel.ShopGrade; var shopStatisticOrderComments = _iShopService.GetShopStatisticOrderComments(CurrentSellerManager.ShopId); var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault(); var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault(); var sellerDeliverySpeed = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault(); var defaultValue = "5"; //宝贝与描述 model.ProductAndDescription = productAndDescription != null?string.Format("{0:F}", productAndDescription.CommentValue) : defaultValue; //卖家服务态度 model.SellerServiceAttitude = sellerServiceAttitude != null?string.Format("{0:F}", sellerServiceAttitude.CommentValue) : defaultValue; //卖家发货速度 model.SellerDeliverySpeed = sellerDeliverySpeed != null?string.Format("{0:F}", sellerDeliverySpeed.CommentValue) : defaultValue; //所有商品数 model.ProductsNumberIng = model.SellerConsoleModel.ProductLimit.ToString(); //发布商品数量 model.ProductsNumber = model.SellerConsoleModel.ProductsCount.ToString(); //使用空间 model.UseSpace = model.SellerConsoleModel.ImageLimit.ToString(); //正使用的空间 model.UseSpaceing = model.SellerConsoleModel.ProductImages.ToString(); //商品咨询 model.OrderProductConsultation = model.SellerConsoleModel.ProductConsultations.ToString(); //订单总数 model.OrderCounts = model.SellerConsoleModel.OrderCounts.ToString(); //待买家付款 model.OrderWaitPay = model.SellerConsoleModel.WaitPayTrades.ToString(); //待发货 model.OrderWaitDelivery = model.SellerConsoleModel.WaitDeliveryTrades.ToString(); //待回复评价 model.OrderReplyComments = model.SellerConsoleModel.ProductComments.ToString(); //待处理投诉 model.OrderHandlingComplaints = model.SellerConsoleModel.Complaints.ToString(); //待处理退款 model.OrderWithRefund = model.SellerConsoleModel.RefundTrades.ToString(); //待处理退货 model.OrderWithRefundAndRGoods = model.SellerConsoleModel.RefundAndRGoodsTrades.ToString(); //商品评价 model.ProductsEvaluation = model.SellerConsoleModel.ProductsEvaluation.ToString(); //授权品牌 model.ProductsBrands = _iBrandService.GetShopBrandApplys(CurrentSellerManager.ShopId).Where(c => c.AuditStatus == 1).Count().ToString(); //出售中 model.ProductsOnSale = model.SellerConsoleModel.OnSaleProducts.ToString(); //草稿箱 model.ProductsInDraft = model.SellerConsoleModel.ProductsInDraft.ToString(); //待审核 model.ProductsWaitForAuditing = model.SellerConsoleModel.WaitForAuditingProducts.ToString(); //审核未通过 model.ProductsAuditFailed = model.SellerConsoleModel.AuditFailureProducts.ToString(); //违规下架 model.ProductsInfractionSaleOff = model.SellerConsoleModel.InfractionSaleOffProducts.ToString(); //仓库中 model.ProductsInStock = model.SellerConsoleModel.InStockProducts.ToString(); //警戒库存数 model.OverSafeStockProducts = ProductManagerApplication.GetOverSafeStockProducts(CurrentSellerManager.ShopId).ToString(); DateTime startDate = DateTime.Now.AddDays(-1).Date; DateTime endDate = startDate.AddDays(1).AddMilliseconds(-1); var statistic = StatisticApplication.GetShopTradeStatistic(CurrentSellerManager.ShopId, null, startDate, endDate); var lstEchartsData = new List <EchartsData>(); if (statistic != null) { ViewBag.VistiCounts = statistic.VisitCounts; ViewBag.OrderCounts = statistic.OrderCount; ViewBag.OrderPayCount = statistic.OrderPayCount; } else { string zero = decimal.Zero.ToString(); ViewBag.VistiCounts = zero; ViewBag.OrderCounts = zero; ViewBag.OrderPayCount = zero; } } //新首页结束 return(View(model)); }
// GET: Web/Shop // [OutputCache(VaryByParam = "id", Duration = ConstValues.PAGE_CACHE_DURATION)] public ActionResult Home(string id) { long shopId = 0; Entities.ShopInfo shopObj = null; //shopId 不是数字 if (!long.TryParse(id, out shopId)) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); //404 页面 } //店铺Id不存在 shopObj = _iShopService.GetShop(shopId); if (null == shopObj) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); //404 页面 } #region 初始化Model ShopHomeModel model = new ShopHomeModel { HotAttentionProducts = new List <HotProductInfo>(), HotSaleProducts = new List <HotProductInfo>(), Floors = new List <ShopHomeFloor>(), Navignations = new List <Entities.BannerInfo>(), Shop = new ShopInfoModel(), ShopCategory = new List <CategoryJsonModel>(), Slides = new List <Entities.SlideAdInfo>(), Logo = "" }; #endregion #region 店铺信息 var mark = ShopServiceMark.GetShopComprehensiveMark(shopObj.Id); model.Shop.Name = shopObj.ShopName; model.Shop.CompanyName = shopObj.CompanyName; model.Shop.Id = shopObj.Id; model.Shop.PackMark = mark.PackMark; model.Shop.ServiceMark = mark.ServiceMark; model.Shop.ComprehensiveMark = mark.ComprehensiveMark; model.Shop.Phone = shopObj.CompanyPhone; model.Shop.Address = _iRegionService.GetFullName(shopObj.CompanyRegionId); model.Logo = shopObj.Logo; #endregion if (shopObj.IsSelf) { model.Shop.PackMark = 5; model.Shop.ServiceMark = 5; model.Shop.ComprehensiveMark = 5; } #region 导航和3个推荐商品 //导航 model.Navignations = _iNavigationService.GetSellerNavigations(shopObj.Id).ToList(); //banner和3个推荐商品 var list = _iSlideAdsService.GetImageAds(shopObj.Id).OrderBy(item => item.Id).ToList(); model.ImageAds = list.Where(p => !p.IsTransverseAD).ToList(); model.TransverseAD = list.FirstOrDefault(p => p.IsTransverseAD); model.Slides = _iSlideAdsService.GetSlidAds(shopObj.Id, Entities.SlideAdInfo.SlideAdType.ShopHome).ToList(); #endregion #region 店铺分类 var categories = _iShopCategoryService.GetShopCategory(shopObj.Id).Where(a => a.IsShow).ToList();//这里不好写到底层去,有些地方产品设计上不需要过滤 foreach (var main in categories.Where(s => s.ParentCategoryId == 0)) { var topC = new CategoryJsonModel() { Name = main.Name, Id = main.Id.ToString(), SubCategory = new List <SecondLevelCategory>() }; foreach (var secondItem in categories.Where(s => s.ParentCategoryId == main.Id)) { var secondC = new SecondLevelCategory() { Name = secondItem.Name, Id = secondItem.Id.ToString(), }; topC.SubCategory.Add(secondC); } model.ShopCategory.Add(topC); } #endregion #region 楼层信息 bool isSaleCountOnOff = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1; var shopHomeModules = _iShopHomeModuleService.GetAllShopHomeModuleInfos(shopObj.Id).Where(a => a.IsEnable).OrderBy(p => p.DisplaySequence); ShopHomeFloorProduct info = null; var modules = shopHomeModules.Select(p => p.Id).ToList(); var imgs = _iShopHomeModuleService.GetImages(modules); var moduleProducts = _iShopHomeModuleService.GetProducts(modules); var onSaleProducts = ProductManagerApplication.GetOnSaleProducts(moduleProducts.Select(p => p.ProductId).ToList()); foreach (var item in shopHomeModules) { List <ShopHomeFloorProduct> products = new List <ShopHomeFloorProduct>(); var moduleProduct = moduleProducts.Where(p => p.HomeModuleId == item.Id); foreach (var p in moduleProduct.OrderBy(p => p.DisplaySequence)) { var product = onSaleProducts.FirstOrDefault(x => x.Id == p.ProductId); if (product == null) { continue; } info = new ShopHomeFloorProduct { Id = product.Id, Name = product.ProductName, Pic = product.ImagePath, Price = product.MinSalePrice.ToString("f2"), //TODO:FG 循环查询销量 待优化 SaleCount = (int)_iProductService.GetProductVistInfo(product.Id).SaleCounts }; if (isSaleCountOnOff) { info.SaleCount = info.SaleCount + (int)product.VirtualSaleCounts; } products.Add(info); } var topimgs = imgs .Where(p => p.HomeModuleId == item.Id) .OrderBy(p => p.DisplaySequence) .Select(i => new ShopHomeFloorTopImg { Url = i.Url, ImgPath = i.ImgPath }).ToList(); model.Floors.Add(new ShopHomeFloor { FloorName = item.Name, FloorUrl = item.Url, Products = products, TopImgs = topimgs }); } #endregion #region 热门销售 //热门销售不受平台销量开关影响 var sale = _iProductService.GetHotSaleProduct(shopObj.Id, 5); if (sale != null) { HotProductInfo hotInfo = null; foreach (var item in sale.ToArray()) { hotInfo = new HotProductInfo { ImgPath = item.ImagePath, Name = item.ProductName, Price = item.MinSalePrice, Id = item.Id, SaleCount = (int)item.SaleCounts }; hotInfo.SaleCount = hotInfo.SaleCount + Mall.Core.Helper.TypeHelper.ObjectToInt(item.VirtualSaleCounts); model.HotSaleProducts.Add(hotInfo); } } #endregion #region 热门关注 var hot = _iProductService.GetHotConcernedProduct(shopObj.Id, 5); if (hot != null) { HotProductInfo hot_Info = null; foreach (var item in hot.ToList()) { hot_Info = new HotProductInfo { ImgPath = item.ImagePath, Name = item.ProductName, Price = item.MinSalePrice, Id = item.Id, SaleCount = (int)item.ConcernedCount }; model.HotAttentionProducts.Add(hot_Info); } } #endregion #region 微店二维码 var vshop = _iVShopService.GetVShopByShopId(shopObj.Id); string vshopUrl = ""; if (vshop != null) { vshopUrl = CurrentUrlHelper.CurrentUrlNoPort() + "/m-" + PlatformType.WeiXin.ToString() + "/vshop/detail/" + vshop.Id; CreateQR(model, vshop.StrLogo, vshopUrl); } else { vshopUrl = CurrentUrlHelper.CurrentUrlNoPort() + "/m-" + PlatformType.WeiXin.ToString(); CreateQR(model, string.Empty, vshopUrl); } #endregion #region 店铺页脚 model.Footer = _iShopHomeModuleService.GetFooter(shopObj.Id); #endregion ViewBag.IsExpired = _iShopService.IsExpiredShop(shopId); ViewBag.IsFreeze = _iShopService.IsFreezeShop(shopId); //补充当前店铺红包功能 ViewBag.isShopPage = true; ViewBag.CurShopId = shopId; TempData["isShopPage"] = true; TempData["CurShopId"] = shopId; //统计店铺访问人数 StatisticApplication.StatisticShopVisitUserCount(shopId); ViewBag.Keyword = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword; ViewBag.Keywords = SiteSettings.HotKeyWords; ViewBag.IsOpenTopImageAd = shopObj.IsOpenTopImageAd; return(View(model)); }
/// <summary> /// 拼团活动详情 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Detail(long id) { FightGroupActiveModel data = FightGroupApplication.GetActive(id, false); if (data == null) { throw new HimallException("错误的活动信息"); } data.InitProductImages(); AutoMapper.Mapper.CreateMap <FightGroupActiveModel, FightGroupActiveDetailModel>(); FightGroupActiveDetailModel model = AutoMapper.Mapper.Map <FightGroupActiveDetailModel>(data); decimal discount = 1M; if (CurrentUser != null) { discount = CurrentUser.MemberDiscount; } ViewBag.Discount = discount; var shopInfo = ShopApplication.GetShop(model.ShopId); ViewBag.IsSelf = shopInfo.IsSelf; //AutoMapper.Mapper.CreateMap<FightGroupActiveModel, FightGroupActiveResult>(); //var fightGroupData = AutoMapper.Mapper.Map<FightGroupActiveResult>(model); model.ShareUrl = string.Format("{0}/m-{1}/FightGroup/Detail/{2}", CurrentUrlHelper.CurrentUrlNoPort(), "WeiXin", data.Id); model.ShareTitle = data.ActiveStatus == FightGroupActiveStatus.WillStart ? "限时限量火拼 即将开始" : "限时限量火拼 正在进行"; model.ShareImage = data.ProductDefaultImage; if (!string.IsNullOrWhiteSpace(model.ShareImage)) { if (model.ShareImage.Substring(0, 4) != "http") { model.ShareImage = HimallIO.GetRomoteImagePath(model.ShareImage); } } model.ShareDesc = data.ProductName; if (!string.IsNullOrWhiteSpace(data.ProductShortDescription)) { model.ShareDesc += ",(" + data.ProductShortDescription + ")"; } if (model.ProductId > 0) { //统计商品浏览量、店铺浏览人数 StatisticApplication.StatisticVisitCount(model.ProductId, model.ShopId); } var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(model.ShopId); ViewBag.CustomerServices = customerServices; var bonus = ServiceApplication.Create <IShopBonusService>().GetByShopId(model.ShopId); if (bonus != null) { model.BonusCount = bonus.Count; model.BonusGrantPrice = bonus.GrantPrice; model.BonusRandomAmountStart = bonus.RandomAmountStart; model.BonusRandomAmountEnd = bonus.RandomAmountEnd; } var fullDiscount = FullDiscountApplication.GetOngoingActiveByProductId(id, model.ShopId); model.FullDiscount = fullDiscount; model.IsSaleCountOnOff = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1; //是否显示销量 model.SaleVolume = data.ActiveItems.Sum(d => d.BuyCount); //销量 model.FreightTemplate = FreightTemplateApplication.GetFreightTemplate(model.FreightTemplateId); //运费模板 model.FreightStr = FreightTemplateApplication.GetFreightStr(model.ProductId, model.FreightTemplate, CurrentUser); //运费或免运费 return(View(model)); }
public object GetLimitBuyProduct(long id) { ProductDetailModelForMobie model = new ProductDetailModelForMobie() { Product = new ProductInfoModel(), Shop = new ShopInfoModel(), Color = new CollectionSKU(), Size = new CollectionSKU(), Version = new CollectionSKU() }; Entities.ProductInfo product = null; Entities.ShopInfo shop = null; FlashSaleModel market = null; market = ServiceProvider.Instance <ILimitTimeBuyService> .Create.Get(id); if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing) { //可能参数是商品ID market = market == null ? ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetFlaseSaleByProductId(id) : market; if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing) { //跳转到404页面 throw new MallApiException("你所请求的限时购或者商品不存在!"); } } if (market != null && (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing || DateTime.Parse(market.EndDate) < DateTime.Now)) { return(new { success = true, IsValidLimitBuy = false }); } model.MaxSaleCount = market.LimitCountOfThePeople; model.Title = market.Title; product = ServiceProvider.Instance <IProductService> .Create.GetProduct(market.ProductId); bool hasSku = false; #region 商品SKU Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetType(product.TypeId); string colorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; string sizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; if (product != null) { colorAlias = !string.IsNullOrWhiteSpace(product.ColorAlias) ? product.ColorAlias : colorAlias; sizeAlias = !string.IsNullOrWhiteSpace(product.SizeAlias) ? product.SizeAlias : sizeAlias; versionAlias = !string.IsNullOrWhiteSpace(product.VersionAlias) ? product.VersionAlias : versionAlias; } var skus = ProductManagerApplication.GetSKUs(product.Id); if (skus.Count > 0) { hasSku = true; long colorId = 0, sizeId = 0, versionId = 0; foreach (var sku in skus) { var specs = sku.Id.Split('_'); if (specs.Count() > 0 && !string.IsNullOrEmpty(sku.Color)) { if (long.TryParse(specs[1], out colorId)) { } if (colorId != 0) { if (!model.Color.Any(v => v.Value == sku.Color)) { var c = skus.Where(s => s.Color == sku.Color).Sum(s => s.Stock); model.Color.Add(new ProductSKU { //Name = "选择颜色" , Name = "选择" + colorAlias, EnabledClass = c != 0 ? "enabled" : "disabled", SelectedClass = "", SkuId = colorId, Value = sku.Color, Img = sku.ShowPic }); } } } if (specs.Count() > 1 && !string.IsNullOrEmpty(sku.Size)) { if (long.TryParse(specs[2], out sizeId)) { } if (sizeId != 0) { if (!model.Size.Any(v => v.Value.Equals(sku.Size))) { var ss = skus.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock); model.Size.Add(new ProductSKU { //Name = "选择尺码" , Name = "选择" + sizeAlias, EnabledClass = ss != 0 ? "enabled" : "disabled", //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "", SelectedClass = "", SkuId = sizeId, Value = sku.Size }); } } } if (specs.Count() > 2 && !string.IsNullOrEmpty(sku.Version)) { if (long.TryParse(specs[3], out versionId)) { } if (versionId != 0) { if (!model.Version.Any(v => v.Value.Equals(sku.Version))) { var v = skus.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock); model.Version.Add(new ProductSKU { //Name = "选择版本" , Name = "选择" + versionAlias, EnabledClass = v != 0 ? "enabled" : "disabled", //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "", SelectedClass = "", SkuId = versionId, Value = sku.Version }); } } } } } #endregion #region 店铺 shop = ServiceProvider.Instance <IShopService> .Create.GetShop(product.ShopId); var mark = Web.Framework.ShopServiceMark.GetShopComprehensiveMark(shop.Id); model.Shop.PackMark = mark.PackMark; model.Shop.ServiceMark = mark.ServiceMark; model.Shop.ComprehensiveMark = mark.ComprehensiveMark; model.Shop.Name = shop.ShopName; model.Shop.ProductMark = CommentApplication.GetProductAverageMark(product.Id); model.Shop.Id = product.ShopId; model.Shop.FreeFreight = shop.FreeFreight; model.Shop.ProductNum = ServiceProvider.Instance <IProductService> .Create.GetShopOnsaleProducts(product.ShopId); var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(product.ShopId); var productAndDescription = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescription); var sellerServiceAttitude = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitude); var sellerDeliverySpeed = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeed); var productAndDescriptionPeer = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionPeer); var sellerServiceAttitudePeer = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudePeer); var sellerDeliverySpeedPeer = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedPeer); decimal defaultValue = 5; //宝贝与描述 if (productAndDescription != null && productAndDescriptionPeer != null) { model.Shop.ProductAndDescription = productAndDescription.CommentValue; } else { model.Shop.ProductAndDescription = defaultValue; } //卖家服务态度 if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null) { model.Shop.SellerServiceAttitude = sellerServiceAttitude.CommentValue; } else { model.Shop.SellerServiceAttitude = defaultValue; } //卖家发货速度 if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null) { model.Shop.SellerDeliverySpeed = sellerDeliverySpeed.CommentValue; } else { model.Shop.SellerDeliverySpeed = defaultValue; } if (ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id) == null) { model.Shop.VShopId = -1; } else { model.Shop.VShopId = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id).Id; } //优惠券 var result = GetCouponList(shop.Id);//取设置的优惠券 if (result != null) { var couponCount = result.Count(); model.Shop.CouponCount = couponCount; } #endregion #region 商品 var consultations = ServiceProvider.Instance <IConsultationService> .Create.GetConsultations(product.Id); var comments = CommentApplication.GetCommentsByProduct(product.Id); var total = comments.Count; var niceTotal = comments.Count(item => item.ReviewMark >= 4); bool isFavorite = false; if (CurrentUser == null) { isFavorite = false; } else { isFavorite = ServiceProvider.Instance <IProductService> .Create.IsFavorite(product.Id, CurrentUser.Id); } var limitBuy = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetLimitTimeMarketItemByProductId(product.Id); var productImage = new List <string>(); var env = EngineContext.Current.Resolve <IWebHostEnvironment>(); for (int i = 1; i < 6; i++) { if (System.IO.File.Exists(env.ContentRootPath + product.RelativePath + string.Format("/{0}.png", i))) { productImage.Add(Core.MallIO.GetRomoteImagePath(product.RelativePath + string.Format("/{0}.png", i))); } } var desc = ProductManagerApplication.GetProductDescription(product.Id); model.Product = new ProductInfoModel() { ProductId = product.Id, CommentCount = CommentApplication.GetCommentCountByProduct(product.Id), Consultations = consultations.Count(), ImagePath = productImage, IsFavorite = isFavorite, MarketPrice = market.MinPrice, MinSalePrice = product.MinSalePrice, NicePercent = model.Shop.ProductMark == 0 ? 100 : (int)((niceTotal / total) * 100), ProductName = product.ProductName, ProductSaleStatus = product.SaleStatus, AuditStatus = product.AuditStatus, ShortDescription = product.ShortDescription, ProductDescription = desc.ShowMobileDescription, MeasureUnit = product.MeasureUnit, IsOnLimitBuy = limitBuy != null, VideoPath = string.IsNullOrWhiteSpace(product.VideoPath) ? string.Empty : Mall.Core.MallIO.GetRomoteImagePath(product.VideoPath), }; #endregion LogProduct(market.ProductId); //统计商品浏览量、店铺浏览人数 StatisticApplication.StatisticVisitCount(product.Id, product.ShopId); TimeSpan end = new TimeSpan(DateTime.Parse(market.EndDate).Ticks); TimeSpan start = new TimeSpan(DateTime.Now.Ticks); TimeSpan ts = end.Subtract(start); var second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds; return(new { success = true, IsOnLimitBuy = true, HasSku = hasSku, MaxSaleCount = market.LimitCountOfThePeople, Title = market.Title, Second = second, Product = model.Product, Shop = model.Shop, Color = model.Color.OrderBy(p => p.SkuId), Size = model.Size.OrderBy(p => p.SkuId), Version = model.Version.OrderBy(p => p.SkuId), ColorAlias = colorAlias, SizeAlias = sizeAlias, VersionAlias = versionAlias }); }
public object GetVShop(long id, bool sv = false) { var vshopService = ServiceProvider.Instance <IVShopService> .Create; var vshop = vshopService.GetVShop(id); //轮播图配置只有诊所微店首页配置页面可配置,现在移动端都读的这个数据 var slideImgs = ServiceProvider.Instance <ISlideAdsService> .Create.GetSlidAds(vshop.ShopId, SlideAdInfo.SlideAdType.VShopHome).ToList(); //首页诊疗项目现在只有诊所配置微信首页,APP读的也是这个数据所以平台类型选的的微信端 var homeProducts = ServiceProvider.Instance <IMobileHomeProductsService> .Create.GetMobileHomePageProducts(vshop.ShopId, Himall.Core.PlatformType.WeiXin).OrderBy(item => item.Sequence).ThenByDescending(o => o.Id).Take(8); var products = homeProducts.ToArray().Select(item => new ProductItem() { Id = item.ProductId, //ImageUrl = "http://" + Url.Request.RequestUri.Host + item.Himall_Products.GetImage(Model.ProductInfo.ImageSize.Size_350), ImageUrl = Core.HimallIO.GetRomoteProductSizeImage(item.Himall_Products.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_350), Name = item.Himall_Products.ProductName, MarketPrice = item.Himall_Products.MarketPrice, SalePrice = item.Himall_Products.MinSalePrice }); 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 = "http://" + Url.Request.RequestUri.Host + item.ImageUrl, Url = item.Url }); var SlideAds = slideImgs.ToArray().Select(item => new HomeSlideAdsModel() { ImageUrl = Core.HimallIO.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.HimallIO.GetRomoteImagePath(vshop.Logo), Name = vshop.Name, ShopId = vshop.ShopId, Favorite = favoriteShop, State = vshop.State, FollowUrl = followUrl }; // 客服 var customerServices = CustomerServiceApplication.GetMobileCustomerService(vshop.ShopId); var meiqia = CustomerServiceApplication.GetPreSaleByShopId(vshop.ShopId).FirstOrDefault(p => p.Tool == CustomerServiceInfo.ServiceTool.MeiQia); if (meiqia != null) { customerServices.Insert(0, meiqia); } //统计访问量 if (!sv) { vshopService.LogVisit(id); //统计诊所访问人数 StatisticApplication.StatisticShopVisitUserCount(vshop.ShopId); } return(Json(new { Success = "True", VShop = model, SlideImgs = SlideAds, Products = products, Banner = banner, Coupon = couponInfo, CustomerServices = customerServices })); }
public ActionResult Home(string id) { long shopId = 0; ShopInfo shopObj = null; //shopId 不是数字 if (!long.TryParse(id, out shopId)) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); //404 页面 } //店铺Id不存在 shopObj = _iShopService.GetShop(shopId); if (null == shopObj) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); //404 页面 } #region 初始化Model ShopHomeModel model = new ShopHomeModel { HotAttentionProducts = new List <HotProductInfo>(), HotSaleProducts = new List <HotProductInfo>(), Floors = new List <ShopHomeFloor>(), Navignations = new List <BannerInfo>(), Shop = new ShopInfoModel(), ShopCategory = new List <CategoryJsonModel>(), Slides = new List <SlideAdInfo>(), Logo = "" }; #endregion #region 店铺信息 var mark = ShopServiceMark.GetShopComprehensiveMark(shopObj.Id); model.Shop.Name = shopObj.ShopName; model.Shop.CompanyName = shopObj.CompanyName; model.Shop.Id = shopObj.Id; model.Shop.PackMark = mark.PackMark; model.Shop.ServiceMark = mark.ServiceMark; model.Shop.ComprehensiveMark = mark.ComprehensiveMark; model.Shop.Phone = shopObj.CompanyPhone; model.Shop.Address = _iRegionService.GetFullName(shopObj.CompanyRegionId); model.Logo = shopObj.Logo; #endregion if (shopObj.IsSelf) { model.Shop.PackMark = 5; model.Shop.ServiceMark = 5; model.Shop.ComprehensiveMark = 5; } #region 导航和3个推荐商品 //导航 model.Navignations = _iNavigationService.GetSellerNavigations(shopObj.Id).ToList(); //banner和3个推荐商品 var list = _iSlideAdsService.GetImageAds(shopObj.Id).OrderBy(item => item.Id).ToList(); model.ImageAds = list.Where(p => !p.IsTransverseAD).ToList(); model.TransverseAD = list.FirstOrDefault(p => p.IsTransverseAD); model.Slides = _iSlideAdsService.GetSlidAds(shopObj.Id, SlideAdInfo.SlideAdType.ShopHome).ToList(); #endregion #region 店铺分类 var categories = _iShopCategoryService.GetShopCategory(shopObj.Id).ToList(); foreach (var main in categories.Where(s => s.ParentCategoryId == 0)) { var topC = new CategoryJsonModel() { Name = main.Name, Id = main.Id.ToString(), SubCategory = new List <SecondLevelCategory>() }; foreach (var secondItem in categories.Where(s => s.ParentCategoryId == main.Id)) { var secondC = new SecondLevelCategory() { Name = secondItem.Name, Id = secondItem.Id.ToString(), }; topC.SubCategory.Add(secondC); } model.ShopCategory.Add(topC); } #endregion #region 楼层信息 var shopHomeModules = _iShopHomeModuleService.GetAllShopHomeModuleInfos(shopObj.Id).Where(a => a.IsEnable).ToArray().OrderBy(p => p.DisplaySequence); foreach (var item in shopHomeModules) { List <ShopHomeFloorProduct> products = new List <ShopHomeFloorProduct>(); foreach (var p in item.ShopHomeModuleProductInfo.Where(d => d.ProductInfo.AuditStatus == ProductInfo.ProductAuditStatus.Audited && d.ProductInfo.SaleStatus == ProductInfo.ProductSaleStatus.OnSale).ToList().OrderBy(p => p.DisplaySequence)) { products.Add(new ShopHomeFloorProduct { Id = p.ProductId, Name = p.ProductInfo.ProductName, Pic = p.ProductInfo.ImagePath, Price = p.ProductInfo.MinSalePrice.ToString("f2"), SaleCount = (int)_iProductService.GetProductVistInfo(p.ProductInfo.Id).SaleCounts }); } List <ShopHomeFloorTopImg> topimgs = new List <ShopHomeFloorTopImg>(); foreach (var i in item.Himall_ShopHomeModulesTopImg.ToList().OrderBy(p => p.DisplaySequence)) { topimgs.Add(new ShopHomeFloorTopImg { Url = i.Url, ImgPath = i.ImgPath }); } ShopHomeFloor floor = new ShopHomeFloor { FloorName = item.Name, FloorUrl = item.Url, Products = products, TopImgs = topimgs }; model.Floors.Add(floor); } #endregion #region 热门销售 var sale = _iProductService.GetHotSaleProduct(shopObj.Id, 5); if (sale != null) { foreach (var item in sale.ToArray()) { model.HotSaleProducts.Add(new HotProductInfo { ImgPath = item.ImagePath, Name = item.ProductName, Price = item.MinSalePrice, Id = item.Id, SaleCount = (int)item.SaleCounts }); } } #endregion #region 热门关注 var hot = _iProductService.GetHotConcernedProduct(shopObj.Id, 5); if (hot != null) { foreach (var item in hot.ToList()) { model.HotAttentionProducts.Add(new HotProductInfo { ImgPath = item.ImagePath, Name = item.ProductName, Price = item.MinSalePrice, Id = item.Id, SaleCount = (int)item.ConcernedCount }); } } #endregion #region 累加浏览次数 _iShopService.LogShopVisti(shopObj.Id); #endregion #region 微店二维码 var vshop = _iVShopService.GetVShopByShopId(shopObj.Id); string vshopUrl = ""; if (vshop != null) { vshopUrl = "http://" + HttpContext.Request.Url.Host + "/m-" + PlatformType.WeiXin.ToString() + "/vshop/detail/" + vshop.Id; CreateQR(model, vshop.Logo, vshopUrl); } else { vshopUrl = "http://" + HttpContext.Request.Url.Host + "/m-" + PlatformType.WeiXin.ToString(); CreateQR(model, string.Empty, vshopUrl); } #endregion #region 店铺页脚 model.Footer = _iShopHomeModuleService.GetFooter(shopObj.Id); #endregion ViewBag.IsExpired = _iShopService.IsExpiredShop(shopId); ViewBag.IsFreeze = _iShopService.IsFreezeShop(shopId); //补充当前店铺红包功能 ViewBag.isShopPage = true; ViewBag.CurShopId = shopId; TempData["isShopPage"] = true; TempData["CurShopId"] = shopId; //统计店铺访问人数 StatisticApplication.StatisticShopVisitUserCount(shopId); return(View(model)); }
public ActionResult Home() { UserCenterHomeModel viewModel = new UserCenterHomeModel(); viewModel.userCenterModel = MemberApplication.GetUserCenterModel(CurrentUser.Id); viewModel.UserName = CurrentUser.Nick == "" ? CurrentUser.UserName : CurrentUser.Nick; viewModel.Logo = CurrentUser.Photo; var items = _iCartService.GetCart(CurrentUser.Id).Items.OrderByDescending(a => a.AddTime).Select(p => p.ProductId).Take(3).ToArray(); viewModel.ShoppingCartItems = ProductManagerApplication.GetProductByIds(items).ToArray(); var UnEvaluatProducts = _iCommentService.GetUnEvaluatProducts(CurrentUser.Id).ToArray(); viewModel.UnEvaluatProductsNum = UnEvaluatProducts.Count(); viewModel.Top3UnEvaluatProducts = UnEvaluatProducts.Take(3).ToArray(); viewModel.Top3RecommendProducts = _iProductService.GetPlatHotSaleProductByNearShop(8, CurrentUser.Id).ToArray(); viewModel.BrowsingProducts = BrowseHistrory.GetBrowsingProducts(4, CurrentUser == null ? 0 : CurrentUser.Id); var messagePlugins = PluginsManagement.GetPlugins <IMessagePlugin>(); var data = messagePlugins.Select(item => new PluginsInfo { ShortName = item.Biz.ShortName, PluginId = item.PluginInfo.PluginId, Enable = item.PluginInfo.Enable, IsSettingsValid = item.Biz.IsSettingsValid, IsBind = !string.IsNullOrEmpty(_iMessageService.GetDestination(CurrentUser.Id, item.PluginInfo.PluginId, Entities.MemberContactInfo.UserTypes.General)) }); viewModel.BindContactInfo = data; var statistic = StatisticApplication.GetMemberOrderStatistic(CurrentUser.Id); viewModel.OrderCount = statistic.OrderCount; viewModel.OrderWaitReceiving = statistic.WaitingForRecieve; viewModel.OrderWaitPay = statistic.WaitingForPay; viewModel.OrderEvaluationStatus = statistic.WaitingForComments; viewModel.Balance = MemberCapitalApplication.GetBalanceByUserId(CurrentUser.Id); //TODO:[YZG]增加账户安全等级 MemberAccountSafety memberAccountSafety = new MemberAccountSafety { AccountSafetyLevel = 1 }; if (CurrentUser.PayPwd != null) { memberAccountSafety.PayPassword = true; memberAccountSafety.AccountSafetyLevel += 1; } var ImessageService = _iMessageService; foreach (var messagePlugin in data) { if (messagePlugin.PluginId.IndexOf("SMS") > 0) { if (messagePlugin.IsBind) { memberAccountSafety.BindPhone = true; memberAccountSafety.AccountSafetyLevel += 1; } } else { if (messagePlugin.IsBind) { memberAccountSafety.BindEmail = true; memberAccountSafety.AccountSafetyLevel += 1; } } } viewModel.memberAccountSafety = memberAccountSafety; ViewBag.Keyword = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword; ViewBag.Keywords = SiteSettings.HotKeyWords; return(View(viewModel)); }
public JsonResult GetProductSaleStatisticList(ProductStatisticQuery query) { var model = StatisticApplication.GetProductSales(query); return(Json(model)); }
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 })); }
public ActionResult Detail(string id) { LimitTimeBuyDetailModel detailModel = new LimitTimeBuyDetailModel(); string price = ""; #region 定义Model和变量 LimitTimeProductDetailModel model = new LimitTimeProductDetailModel { MainId = long.Parse(id), HotAttentionProducts = new List <HotProductInfo>(), HotSaleProducts = new List <HotProductInfo>(), Product = new Entities.ProductInfo(), Shop = new ShopInfoModel(), ShopCategory = new List <CategoryJsonModel>(), Color = new CollectionSKU(), Size = new CollectionSKU(), Version = new CollectionSKU() }; FlashSaleModel market = null; Entities.ShopInfo shop = null; long gid = 0, mid = 0; #endregion #region 商品Id不合法 if (long.TryParse(id, out mid)) { } if (mid == 0) { //跳转到出错页面 return(RedirectToAction("Error404", "Error", new { area = "Mobile" })); } #endregion #region 初始化商品和店铺 //参数是限时购活动ID try { market = _iLimitTimeBuyService.Get(mid); } catch { market = null; } if (market != null) { switch (market.Status) { case FlashSaleInfo.FlashSaleStatus.Ended: return(RedirectToAction("Detail", "Product", new { id = market.ProductId })); case FlashSaleInfo.FlashSaleStatus.Cancelled: return(RedirectToAction("Detail", "Product", new { id = market.ProductId })); } model.FlashSale = market; } if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing) { //可能参数是商品ID market = market == null?_iLimitTimeBuyService.GetFlaseSaleByProductId(mid) : market; if (market == null) { //跳转到404页面 return(RedirectToAction("Error404", "Error", new { area = "Mobile" })); } if (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing) { return(RedirectToAction("Detail", "Product", new { id = market.ProductId })); } market = _iLimitTimeBuyService.Get(market.Id); } model.FlashSale = market; if (market != null && (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing || DateTime.Parse(market.EndDate) < DateTime.Now)) { return(RedirectToAction("Detail", "Product", new { id = market.ProductId })); } model.MaxSaleCount = market.LimitCountOfThePeople; model.Title = market.Title; shop = _iShopService.GetShop(market.ShopId); #endregion #region 存在的商品 if (null == market || market.Id == 0) { //跳转到出错页面 return(RedirectToAction("Error404", "Error", new { area = "Web" })); } #endregion #region 商品描述 var product = _iProductService.GetProduct(market.ProductId); gid = market.ProductId; model.Product = product; var description = ProductManagerApplication.GetProductDescription(product.Id); model.ProductDescription = description.ShowMobileDescription; if (description.DescriptionPrefixId != 0) { var desc = _iProductDescriptionTemplateService .GetTemplate(description.DescriptionPrefixId, product.ShopId); model.DescriptionPrefix = desc == null ? "" : desc.Content; } if (description.DescriptiondSuffixId != 0) { var desc = _iProductDescriptionTemplateService .GetTemplate(description.DescriptiondSuffixId, product.ShopId); model.DescriptiondSuffix = desc == null ? "" : desc.Content; } var mark = ShopServiceMark.GetShopComprehensiveMark(shop.Id); model.Shop.PackMark = mark.PackMark; model.Shop.ServiceMark = mark.ServiceMark; model.Shop.ComprehensiveMark = mark.ComprehensiveMark; model.Shop.Name = shop.ShopName; model.Shop.ProductMark = CommentApplication.GetProductAverageMark(gid); model.Shop.Id = product.ShopId; model.Shop.FreeFreight = shop.FreeFreight; detailModel.ProductNum = _iProductService.GetShopOnsaleProducts(product.ShopId); detailModel.FavoriteShopCount = _iShopService.GetShopFavoritesCount(product.ShopId); if (CurrentUser == null) { detailModel.IsFavorite = false; detailModel.IsFavoriteShop = false; } else { detailModel.IsFavorite = _iProductService.IsFavorite(product.Id, CurrentUser.Id); var favoriteShopIds = _iShopService.GetFavoriteShopInfos(CurrentUser.Id).Select(item => item.ShopId).ToArray();//获取已关注店铺 detailModel.IsFavoriteShop = favoriteShopIds.Contains(product.ShopId); } #endregion #region 店铺分类 var categories = _iShopCategoryService.GetShopCategory(product.ShopId); List <Entities.ShopCategoryInfo> allcate = categories.ToList(); foreach (var main in allcate.Where(s => s.ParentCategoryId == 0)) { var topC = new CategoryJsonModel() { Name = main.Name, Id = main.Id.ToString(), SubCategory = new List <SecondLevelCategory>() }; foreach (var secondItem in allcate.Where(s => s.ParentCategoryId == main.Id)) { var secondC = new SecondLevelCategory() { Name = secondItem.Name, Id = secondItem.Id.ToString(), }; topC.SubCategory.Add(secondC); } model.ShopCategory.Add(topC); } #endregion #region 热门销售 var sale = _iProductService.GetHotSaleProduct(shop.Id, 5); if (sale != null) { foreach (var item in sale.ToArray()) { model.HotSaleProducts.Add(new HotProductInfo { ImgPath = item.ImagePath, Name = item.ProductName, Price = item.MinSalePrice, Id = item.Id, SaleCount = (int)item.SaleCounts + Mall.Core.Helper.TypeHelper.ObjectToInt(item.VirtualSaleCounts) }); } } #endregion #region 热门关注 var hot = _iProductService.GetHotConcernedProduct(shop.Id, 5); if (hot != null) { foreach (var item in hot.ToArray()) { model.HotAttentionProducts.Add(new HotProductInfo { ImgPath = item.ImagePath, Name = item.ProductName, Price = item.MinSalePrice, Id = item.Id, SaleCount = (int)item.ConcernedCount }); } } #endregion #region 商品规格 Entities.TypeInfo typeInfo = _iTypeService.GetType(product.TypeId); string colorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; string sizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; if (product != null) { colorAlias = !string.IsNullOrWhiteSpace(product.ColorAlias) ? product.ColorAlias : colorAlias; sizeAlias = !string.IsNullOrWhiteSpace(product.SizeAlias) ? product.SizeAlias : sizeAlias; versionAlias = !string.IsNullOrWhiteSpace(product.VersionAlias) ? product.VersionAlias : versionAlias; } model.ColorAlias = colorAlias; model.SizeAlias = sizeAlias; model.VersionAlias = versionAlias; var skus = ProductManagerApplication.GetSKUs(product.Id); if (skus.Count > 0) { long colorId = 0, sizeId = 0, versionId = 0; foreach (var sku in skus) { var specs = sku.Id.Split('_'); if (specs.Count() > 0 && !string.IsNullOrEmpty(sku.Color)) { if (long.TryParse(specs[1], out colorId)) { } if (colorId != 0) { if (!model.Color.Any(v => v.Value.Equals(sku.Color))) { var c = skus.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock); model.Color.Add(new ProductSKU { //Name = "选择颜色", Name = "选择" + colorAlias, EnabledClass = c != 0 ? "enabled" : "disabled", //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "", SelectedClass = "", SkuId = colorId, Value = sku.Color, Img = Core.MallIO.GetImagePath(sku.ShowPic) }); } } } if (specs.Count() > 1 && !string.IsNullOrEmpty(sku.Size)) { if (long.TryParse(specs[2], out sizeId)) { } if (sizeId != 0) { if (!model.Size.Any(v => v.Value.Equals(sku.Size))) { var ss = skus.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock); model.Size.Add(new ProductSKU { //Name = "选择尺码", Name = "选择" + sizeAlias, EnabledClass = ss != 0 ? "enabled" : "disabled", //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "", SelectedClass = "", SkuId = sizeId, Value = sku.Size }); } } } if (specs.Count() > 2 && !string.IsNullOrEmpty(sku.Version)) { if (long.TryParse(specs[3], out versionId)) { } if (versionId != 0) { if (!model.Version.Any(v => v.Value.Equals(sku.Version))) { var v = skus.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock); model.Version.Add(new ProductSKU { //Name = "选择版本", Name = "选择" + versionAlias, EnabledClass = v != 0 ? "enabled" : "disabled", //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "", SelectedClass = "", SkuId = versionId, Value = sku.Version }); } } } } //var min = skus.Where(s => s.Stock >= 0).Min(s => s.SalePrice); //var max = skus.Where(s => s.Stock >= 0).Max(s => s.SalePrice); //if (min == 0 && max == 0) //{ // price = product.MinSalePrice.ToString("f2"); //} //else if (max > min) //{ // price = string.Format("{0}-{1}", min.ToString("f2"), max.ToString("f2")); //} //else //{ // price = string.Format("{0}", min.ToString("f2")); //} price = ProductWebApplication.GetProductPriceStr2(product, skus);//最小价或区间价文本 } detailModel.Price = string.IsNullOrWhiteSpace(price) ? product.MinSalePrice.ToString("f2") : price; #endregion #region 商品属性 List <TypeAttributesModel> ProductAttrs = new List <TypeAttributesModel>(); var prodAttrs = ProductManagerApplication.GetProductAttributes(product.Id); foreach (var attr in prodAttrs) { if (!ProductAttrs.Any(p => p.AttrId == attr.AttributeId)) { var attribute = _iTypeService.GetAttribute(attr.AttributeId); var values = _iTypeService.GetAttributeValues(attr.AttributeId); TypeAttributesModel attrModel = new TypeAttributesModel() { AttrId = attr.AttributeId, AttrValues = new List <TypeAttrValue>(), Name = attribute.Name }; foreach (var attrV in values) { if (prodAttrs.Any(p => p.ValueId == attrV.Id)) { attrModel.AttrValues.Add(new TypeAttrValue { Id = attrV.Id.ToString(), Name = attrV.Value }); } } ProductAttrs.Add(attrModel); } else { var attrTemp = ProductAttrs.FirstOrDefault(p => p.AttrId == attr.AttributeId); var values = _iTypeService.GetAttributeValues(attr.AttributeId); if (!attrTemp.AttrValues.Any(p => p.Id == attr.ValueId.ToString())) { attrTemp.AttrValues.Add(new TypeAttrValue { Id = attr.ValueId.ToString(), Name = values.FirstOrDefault(a => a.Id == attr.ValueId).Value }); } } } detailModel.ProductAttrs = ProductAttrs; #endregion #region 获取评论、咨询数量 var comments = CommentApplication.GetCommentsByProduct(product.Id); detailModel.CommentCount = comments.Count; var consultations = ServiceApplication.Create <IConsultationService>().GetConsultations(gid); var total = comments.Count; var niceTotal = comments.Count(item => item.ReviewMark >= 4); detailModel.NicePercent = (int)((niceTotal / (double)total) * 100); detailModel.Consultations = consultations.Count(); if (_iVShopService.GetVShopByShopId(shop.Id) == null) { detailModel.VShopId = -1; } else { detailModel.VShopId = _iVShopService.GetVShopByShopId(shop.Id).Id; } #endregion #region 累加浏览次数、 加入历史记录 //if (CurrentUser != null) //{ // BrowseHistrory.AddBrowsingProduct(product.Id, CurrentUser.Id); //} //else //{ // BrowseHistrory.AddBrowsingProduct(product.Id); //} //_iProductService.LogProductVisti(gid); #endregion #region 获取店铺的评价统计 var shopStatisticOrderComments = _iShopService.GetShopStatisticOrderComments(product.ShopId); var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault(); var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault(); var sellerDeliverySpeed = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault(); var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault(); var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault(); var sellerDeliverySpeedPeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault(); var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault(); var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault(); var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault(); var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault(); var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault(); var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault(); decimal defaultValue = 5; //宝贝与描述 if (productAndDescription != null && productAndDescriptionPeer != null && !shop.IsSelf) { detailModel.ProductAndDescription = productAndDescription.CommentValue; detailModel.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue; detailModel.ProductAndDescriptionMin = productAndDescriptionMin.CommentValue; detailModel.ProductAndDescriptionMax = productAndDescriptionMax.CommentValue; } else { detailModel.ProductAndDescription = defaultValue; detailModel.ProductAndDescriptionPeer = defaultValue; detailModel.ProductAndDescriptionMin = defaultValue; detailModel.ProductAndDescriptionMax = defaultValue; } //卖家服务态度 if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null && !shop.IsSelf) { detailModel.SellerServiceAttitude = sellerServiceAttitude.CommentValue; detailModel.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue; detailModel.SellerServiceAttitudeMax = sellerServiceAttitudeMax.CommentValue; detailModel.SellerServiceAttitudeMin = sellerServiceAttitudeMin.CommentValue; } else { detailModel.SellerServiceAttitude = defaultValue; detailModel.SellerServiceAttitudePeer = defaultValue; detailModel.SellerServiceAttitudeMax = defaultValue; detailModel.SellerServiceAttitudeMin = defaultValue; } //卖家发货速度 if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null && !shop.IsSelf) { detailModel.SellerDeliverySpeed = sellerDeliverySpeed.CommentValue; detailModel.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue; detailModel.SellerDeliverySpeedMax = sellerDeliverySpeedMax != null ? sellerDeliverySpeedMax.CommentValue : 0; detailModel.sellerDeliverySpeedMin = sellerDeliverySpeedMin != null ? sellerDeliverySpeedMin.CommentValue : 0; } else { detailModel.SellerDeliverySpeed = defaultValue; detailModel.SellerDeliverySpeedPeer = defaultValue; detailModel.SellerDeliverySpeedMax = defaultValue; detailModel.sellerDeliverySpeedMin = defaultValue; } #endregion #region 是否收藏此商品 if (CurrentUser != null && CurrentUser.Id > 0) { model.IsFavorite = _iProductService.IsFavorite(product.Id, CurrentUser.Id); } else { model.IsFavorite = false; } #endregion long vShopId; var vshopinfo = _iVShopService.GetVShopByShopId(shop.Id); if (vshopinfo == null) { vShopId = -1; } else { vShopId = vshopinfo.Id; } detailModel.VShopId = vShopId; model.Shop.VShopId = vShopId; model.VShopLog = _iVShopService.GetVShopLog(model.Shop.VShopId); if (string.IsNullOrWhiteSpace(model.VShopLog)) { //throw new Mall.Core.MallException("店铺未开通微店功能"); model.VShopLog = SiteSettings.WXLogo; } detailModel.Logined = (null != CurrentUser) ? 1 : 0; model.EnabledBuy = product.AuditStatus == Entities.ProductInfo.ProductAuditStatus.Audited && DateTime.Parse(market.BeginDate) <= DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now && product.SaleStatus == Entities.ProductInfo.ProductSaleStatus.OnSale; int saleCounts = 0; saleCounts = market.SaleCount; if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) < DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now) { TimeSpan end = new TimeSpan(DateTime.Parse(market.EndDate).Ticks); TimeSpan start = new TimeSpan(DateTime.Now.Ticks); TimeSpan ts = end.Subtract(start); detailModel.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds; } else if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) > DateTime.Now) { TimeSpan end = new TimeSpan(DateTime.Parse(market.BeginDate).Ticks); TimeSpan start = new TimeSpan(DateTime.Now.Ticks); TimeSpan ts = end.Subtract(start); detailModel.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds; saleCounts = Mall.Core.Helper.TypeHelper.ObjectToInt(product.SaleCounts) + Mall.Core.Helper.TypeHelper.ObjectToInt(product.VirtualSaleCounts); } ViewBag.DetailModel = detailModel; var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(market.ShopId); ViewBag.CustomerServices = customerServices; //统计商品浏览量、店铺浏览人数 StatisticApplication.StatisticVisitCount(product.Id, product.ShopId); model.IsSaleCountOnOff = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1; //是否显示销量 model.SaleCount = saleCounts; //销量 model.FreightTemplate = FreightTemplateApplication.GetFreightTemplate(product.FreightTemplateId); model.Freight = FreightTemplateApplication.GetFreightStr(market.ProductId, model.FreightTemplate, CurrentUser, product); //运费或免运费 model.StockAll = market.Quantity; return(View(model)); }
public object GetVShopSearchProducts(long vshopId, string keywords = "", /* 搜索关键字 */ string exp_keywords = "", /* 渐进搜索关键字 */ long cid = 0, /* 分类ID */ long b_id = 0, /* 品牌ID */ string a_id = "", /* 属性ID, 表现形式:attrId_attrValueId */ int orderKey = 1, /* 排序项(1:默认,2:销量,3:价格,4:评论数,5:上架时间) */ int orderType = 1, /* 排序方式(1:升序,2:降序) */ int pageNo = 1, /*页码*/ int pageSize = 10 /*每页显示数据量*/ ) { long total; long shopId = -1; var vshop = ServiceProvider.Instance <IVShopService> .Create.GetVShop(vshopId); if (vshop != null) { shopId = vshop.ShopId; } if (!string.IsNullOrWhiteSpace(keywords)) { keywords = keywords.Trim(); } ProductSearch model = new ProductSearch() { shopId = shopId, BrandId = b_id, Ex_Keyword = exp_keywords, Keyword = keywords, OrderKey = orderKey, OrderType = orderType == 1, AttrIds = new System.Collections.Generic.List <string>(), PageNumber = pageNo, PageSize = pageSize, ShopCategoryId = cid }; var productsResult = ServiceProvider.Instance <IProductService> .Create.SearchProduct(model); total = productsResult.Total; var products = productsResult.Models.ToArray(); var productsModel = products.Select(item => new ProductItem() { Id = item.Id, ImageUrl = Core.MallIO.GetRomoteProductSizeImage(item.RelativePath, 1, (int)CommonModel.ImageSize.Size_350), SalePrice = item.MinSalePrice, Name = item.ProductName, //TODO:FG 循环内调用 CommentsCount = CommentApplication.GetProductCommentCount(item.Id), } ); var bizCategories = ServiceProvider.Instance <IShopCategoryService> .Create.GetShopCategory(shopId); var shopCategories = GetSubCategories(bizCategories, 0, 0); //统计店铺访问人数 StatisticApplication.StatisticShopVisitUserCount(vshop.ShopId); dynamic result = new ExpandoObject(); result.ShopCategory = shopCategories; result.Products = productsModel; result.VShopId = vshopId; result.Keywords = keywords; result.total = total; return(Json(new { result })); }
public object GetOrders(int?status, int pageIndex, int pageSize = 8) { CheckUserLogin(); var orderService = ServiceProvider.Instance <IOrderService> .Create; if (status.HasValue && status == 0) { status = null; } var queryModel = new OrderQuery() { Status = (OrderInfo.OrderOperateStatus?)status, UserId = CurrentUser.Id, PageSize = pageSize, PageNo = pageIndex, IsFront = true }; if (queryModel.Status.HasValue && queryModel.Status.Value == Entities.OrderInfo.OrderOperateStatus.WaitReceiving) { if (queryModel.MoreStatus == null) { queryModel.MoreStatus = new List <Entities.OrderInfo.OrderOperateStatus>() { }; } queryModel.MoreStatus.Add(Entities.OrderInfo.OrderOperateStatus.WaitSelfPickUp); } if (status.GetValueOrDefault() == (int)OrderInfo.OrderOperateStatus.Finish) { queryModel.Commented = false;//只查询未评价的订单 } var orders = orderService.GetOrders <OrderInfo>(queryModel); var productService = ServiceProvider.Instance <IProductService> .Create; var vshopService = ServiceProvider.Instance <IVShopService> .Create; var orderRefundService = ServiceProvider.Instance <IRefundService> .Create; var orderItems = OrderApplication.GetOrderItemsByOrderId(orders.Models.Select(p => p.Id)); var orderRefunds = OrderApplication.GetOrderRefunds(orderItems.Select(p => p.Id)); var shopBranchs = ShopBranchApplication.GetShopBranchByIds(orders.Models.Where(a => a.ShopBranchId > 0).Select(p => p.ShopBranchId).ToList()); var result = orders.Models.Select(item => { var orderitems = orderItems.Where(p => p.OrderId == item.Id); var shopBranchInfo = shopBranchs.FirstOrDefault(a => a.Id == item.ShopBranchId);//当前订单所属门店信息 if (item.OrderStatus >= Entities.OrderInfo.OrderOperateStatus.WaitDelivery) { orderService.CalculateOrderItemRefund(item.Id); } var vshop = vshopService.GetVShopByShopId(item.ShopId); var _ordrefobj = orderRefundService.GetOrderRefundByOrderId(item.Id) ?? new Entities.OrderRefundInfo { Id = 0 }; if (item.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitDelivery && item.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitSelfPickUp) { _ordrefobj = new Entities.OrderRefundInfo { Id = 0 }; } int?ordrefstate = (_ordrefobj == null ? null : (int?)_ordrefobj.SellerAuditStatus); ordrefstate = (ordrefstate > 4 ? (int?)_ordrefobj.ManagerConfirmStatus : ordrefstate); //参照PC端会员中心的状态描述信息 string statusText = item.OrderStatus.ToDescription(); if (item.OrderStatus == Entities.OrderInfo.OrderOperateStatus.WaitDelivery || item.OrderStatus == Entities.OrderInfo.OrderOperateStatus.WaitSelfPickUp) { if (ordrefstate.HasValue && ordrefstate != 0 && ordrefstate != 4) { statusText = "退款中"; } } //是否可售后 bool IsShowReturn = OrderApplication.CanRefund(item, ordrefstate, null); var hasAppendComment = ServiceProvider.Instance <ICommentService> .Create.HasAppendComment(orderitems.FirstOrDefault().Id); return(new { OrderId = item.Id, StatusText = statusText, Status = item.OrderStatus, orderType = item.OrderType, orderTypeName = item.OrderType.ToDescription(), shopname = item.ShopName, vshopId = vshop == null ? 0 : vshop.Id, Amount = item.OrderTotalAmount.ToString("F2"), Quantity = OrderApplication.GetOrderTotalProductCount(item.Id), commentCount = OrderApplication.GetOrderCommentCount(item.Id), pickupCode = item.PickupCode, EnabledRefundAmount = item.OrderEnabledRefundAmount, LineItems = orderitems.Select(a => { var prodata = productService.GetProduct(a.ProductId); Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetType(prodata.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; var itemStatusText = ""; var itemrefund = orderRefunds.Where(or => or.OrderItemId == a.Id).FirstOrDefault(d => d.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund); int?itemrefstate = (itemrefund == null ? 0 : (int?)itemrefund.SellerAuditStatus); itemrefstate = (itemrefstate > 4 ? (int?)itemrefund.ManagerConfirmStatus : itemrefstate); if (itemrefund != null) { //默认为商家处理进度 if (itemrefstate == 4) { //商家拒绝 itemStatusText = ""; } else { itemStatusText = "售后处理中"; } } if (itemrefstate > 4) {//如果商家已经处理完,则显示平台处理进度 if (itemrefstate == 7) { itemStatusText = "退款成功"; } } return new { Status = itemrefstate, StatusText = itemStatusText, Id = a.SkuId, productId = a.ProductId, Name = a.ProductName, Image = Core.MallIO.GetRomoteProductSizeImage(a.ThumbnailsUrl, 1, (int)Mall.CommonModel.ImageSize.Size_350), Amount = a.Quantity, Price = a.SalePrice, Unit = prodata == null ? "" : prodata.MeasureUnit, SkuText = colorAlias + ":" + a.Color + " " + sizeAlias + ":" + a.Size + " " + versionAlias + ":" + a.Version, color = a.Color, size = a.Size, version = a.Version, ColorAlias = (prodata != null && !string.IsNullOrWhiteSpace(prodata.ColorAlias)) ? prodata.ColorAlias : colorAlias,//如果商品有自定义规格名称则用 SizeAlias = (prodata != null && !string.IsNullOrWhiteSpace(prodata.SizeAlias)) ? prodata.SizeAlias : sizeAlias, VersionAlias = (prodata != null && !string.IsNullOrWhiteSpace(prodata.VersionAlias)) ? prodata.VersionAlias : versionAlias, RefundStats = itemrefstate, OrderRefundId = (itemrefund == null ? 0 : itemrefund.Id), EnabledRefundAmount = a.EnabledRefundAmount, IsShowRefund = IsShowReturn, IsShowAfterSale = IsShowReturn }; }), RefundStats = ordrefstate, OrderRefundId = _ordrefobj.Id, IsShowLogistics = !string.IsNullOrWhiteSpace(item.ShipOrderNumber) || item.DeliveryType == DeliveryType.ShopStore, ShipOrderNumber = item.ShipOrderNumber, IsShowCreview = (item.OrderStatus == Entities.OrderInfo.OrderOperateStatus.Finish && !hasAppendComment), IsShowPreview = false, //Invoice = item.InvoiceType.ToDescription(), //InvoiceValue = (int)item.InvoiceType, //InvoiceContext = item.InvoiceContext, //InvoiceTitle = item.InvoiceTitle, PaymentType = item.PaymentType.ToDescription(), PaymentTypeValue = (int)item.PaymentType, IsShowClose = (item.OrderStatus == Entities.OrderInfo.OrderOperateStatus.WaitPay), IsShowFinishOrder = (item.OrderStatus == Entities.OrderInfo.OrderOperateStatus.WaitReceiving), IsShowRefund = IsShowReturn, IsShowReturn = IsShowReturn, IsShowTakeCodeQRCode = (!string.IsNullOrWhiteSpace(item.PickupCode) && item.OrderStatus != Entities.OrderInfo.OrderOperateStatus.Finish && item.OrderStatus != Entities.OrderInfo.OrderOperateStatus.Close), OrderDate = item.OrderDate, SupplierId = 0, ShipperName = string.Empty, StoreName = shopBranchInfo != null ? shopBranchInfo.ShopBranchName : string.Empty, IsShowCertification = false, HasAppendComment = hasAppendComment, CreviewText = OrderApplication.GetOrderCommentCount(item.Id) > 0 ? "追加评论" : "评价订单", ProductCommentPoint = 0, DeliveryType = (int)item.DeliveryType }); }); var statistic = StatisticApplication.GetMemberOrderStatistic(CurrentUser.Id); return(Json( new { AllOrderCounts = statistic.OrderCount, WaitingForComments = statistic.WaitingForComments, WaitingForRecieve = statistic.WaitingForRecieve, WaitingForPay = statistic.WaitingForPay, Data = result })); }
public ActionResult Detail(string id) { if (string.IsNullOrEmpty(id)) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); } string price = ""; #region 定义Model和变量 LimitTimeProductDetailModel model = new LimitTimeProductDetailModel { MainId = long.Parse(id), HotAttentionProducts = new List <HotProductInfo>(), HotSaleProducts = new List <HotProductInfo>(), Product = new Entities.ProductInfo(), Shop = new ShopInfoModel(), ShopCategory = new List <CategoryJsonModel>(), Color = new CollectionSKU(), Size = new CollectionSKU(), Version = new CollectionSKU() }; FlashSaleModel market = null; Entities.ShopInfo shop = null; long gid = 0, mid = 0; #endregion #region 商品Id不合法 if (long.TryParse(id, out mid)) { } if (mid == 0) { //跳转到出错页面 return(RedirectToAction("Error404", "Error", new { area = "Web" })); } #endregion #region 初始化商品和店铺 market = _iLimitTimeBuyService.Get(mid); switch (market.Status) { case Entities.FlashSaleInfo.FlashSaleStatus.Ended: return(RedirectToAction("Detail", "Product", new { id = market.ProductId })); case Entities.FlashSaleInfo.FlashSaleStatus.Cancelled: return(RedirectToAction("Detail", "Product", new { id = market.ProductId })); } if (market.Status != Entities.FlashSaleInfo.FlashSaleStatus.Ongoing) { return(RedirectToAction("Home")); } model.FlashSale = market; if (market == null || market.Id == 0 || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing) { //可能参数是商品ID market = market == null?_iLimitTimeBuyService.GetFlaseSaleByProductId(mid) : market; if (market == null) { //跳转到404页面 return(RedirectToAction("Error404", "Error", new { area = "Mobile" })); } if (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing) { return(RedirectToAction("Detail", "Product", new { id = market.ProductId })); } } model.MaxSaleCount = market.LimitCountOfThePeople; model.Title = market.Title; shop = _iShopService.GetShop(market.ShopId); model.Shop.Name = shop.ShopName; #endregion #region 商品描述 var product = _iProductService.GetProduct(market.ProductId); gid = market.ProductId; var brandModel = ServiceApplication.Create <IBrandService>().GetBrand(product.BrandId); product.BrandName = brandModel == null ? "" : brandModel.Name; if (CurrentUser != null && CurrentUser.Id > 0) { product.IsFavorite = ProductManagerApplication.IsFavorite(product.Id, CurrentUser.Id); } model.Product = product; model.Skus = ProductManagerApplication.GetSKUsByProduct(new List <long> { product.Id }); var description = ProductManagerApplication.GetProductDescription(product.Id); model.ProductDescription = description.Description; if (description.DescriptionPrefixId != 0) { var desc = _iProductDescriptionTemplateService .GetTemplate(description.DescriptionPrefixId, product.ShopId); model.DescriptionPrefix = desc == null ? "" : desc.Content; } if (description.DescriptiondSuffixId != 0) { var desc = _iProductDescriptionTemplateService .GetTemplate(description.DescriptiondSuffixId, product.ShopId); model.DescriptiondSuffix = desc == null ? "" : desc.Content; } #endregion #region 店铺 var categories = _iShopCategoryService.GetShopCategory(product.ShopId); List <Entities.ShopCategoryInfo> allcate = categories.ToList(); foreach (var main in allcate.Where(s => s.ParentCategoryId == 0)) { var topC = new CategoryJsonModel() { Name = main.Name, Id = main.Id.ToString(), SubCategory = new List <SecondLevelCategory>() }; foreach (var secondItem in allcate.Where(s => s.ParentCategoryId == main.Id)) { var secondC = new SecondLevelCategory() { Name = secondItem.Name, Id = secondItem.Id.ToString(), }; topC.SubCategory.Add(secondC); } model.ShopCategory.Add(topC); } model.CashDeposits = _iCashDepositsService.GetCashDepositsObligation(product.Id); #endregion #region 热门销售 //会员折扣 decimal discount = 1M; long SelfShopId = 0; if (CurrentUser != null) { discount = CurrentUser.MemberDiscount; var shopInfo = ShopApplication.GetSelfShop(); SelfShopId = shopInfo.Id; } var sale = _iProductService.GetHotSaleProduct(shop.Id, 5); if (sale != null) { foreach (var item in sale.ToArray()) { var salePrice = item.MinSalePrice; if (item.ShopId == SelfShopId) { salePrice = item.MinSalePrice * discount; } var limitBuy = LimitTimeApplication.GetLimitTimeMarketItemByProductId(item.Id); if (limitBuy != null) { salePrice = limitBuy.MinPrice; } model.HotSaleProducts.Add(new HotProductInfo { ImgPath = item.ImagePath, Name = item.ProductName, Price = Math.Round(salePrice, 2), Id = item.Id, SaleCount = (int)item.SaleCounts + Mall.Core.Helper.TypeHelper.ObjectToInt(item.VirtualSaleCounts) }); } } #endregion #region 热门关注 var hot = _iProductService.GetHotConcernedProduct(shop.Id, 5); if (hot != null) { foreach (var item in hot.ToArray()) { model.HotAttentionProducts.Add(new HotProductInfo { ImgPath = item.ImagePath, Name = item.ProductName, Price = item.MinSalePrice, Id = item.Id, SaleCount = (int)item.ConcernedCount }); } } #endregion #region 商品规格 Entities.TypeInfo typeInfo = _iTypeService.GetType(product.TypeId); string colorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; string sizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; if (product != null) { colorAlias = !string.IsNullOrWhiteSpace(product.ColorAlias) ? product.ColorAlias : colorAlias; sizeAlias = !string.IsNullOrWhiteSpace(product.SizeAlias) ? product.SizeAlias : sizeAlias; versionAlias = !string.IsNullOrWhiteSpace(product.VersionAlias) ? product.VersionAlias : versionAlias; } model.ColorAlias = colorAlias; model.SizeAlias = sizeAlias; model.VersionAlias = versionAlias; var skus = _iProductService.GetSKUs(product.Id); if (skus.Count > 0) { long colorId = 0, sizeId = 0, versionId = 0; foreach (var sku in skus) { var specs = sku.Id.Split('_'); if (specs.Count() > 0 && !string.IsNullOrEmpty(sku.Color)) { if (long.TryParse(specs[1], out colorId)) { } if (colorId != 0) { if (!model.Color.Any(v => v.Value.Equals(sku.Color))) { var c = skus.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock); model.Color.Add(new ProductSKU { //Name = "选择颜色", Name = "选择" + colorAlias, EnabledClass = c != 0 ? "enabled" : "disabled", //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "", SelectedClass = "", SkuId = colorId, Value = sku.Color, Img = Mall.Core.MallIO.GetImagePath(sku.ShowPic) }); } } } if (specs.Count() > 1 && !string.IsNullOrEmpty(sku.Size)) { if (long.TryParse(specs[2], out sizeId)) { } if (sizeId != 0) { if (!model.Size.Any(v => v.Value.Equals(sku.Size))) { var ss = skus.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock); model.Size.Add(new ProductSKU { //Name = "选择尺码", Name = "选择" + sizeAlias, EnabledClass = ss != 0 ? "enabled" : "disabled", //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "", SelectedClass = "", SkuId = sizeId, Value = sku.Size }); } } } if (specs.Count() > 2 && !string.IsNullOrEmpty(sku.Version)) { if (long.TryParse(specs[3], out versionId)) { } if (versionId != 0) { if (!model.Version.Any(v => v.Value.Equals(sku.Version))) { var v = skus.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock); model.Version.Add(new ProductSKU { //Name = "选择版本", Name = "选择" + versionAlias, EnabledClass = v != 0 ? "enabled" : "disabled", //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "", SelectedClass = "", SkuId = versionId, Value = sku.Version }); } } } } price = ProductWebApplication.GetProductPriceStr(product, skus, discount);//最小价或区间价文本 } model.Price = string.IsNullOrWhiteSpace(price) ? product.MinSalePrice.ToString("f2") : price; #endregion #region 商品属性 List <TypeAttributesModel> ProductAttrs = new List <TypeAttributesModel>(); var prodAttrs = ProductManagerApplication.GetProductAttributes(product.Id); foreach (var attr in prodAttrs) { if (!ProductAttrs.Any(p => p.AttrId == attr.AttributeId)) { var attribute = _iTypeService.GetAttribute(attr.AttributeId); var values = _iTypeService.GetAttributeValues(attr.AttributeId); var attrModel = new TypeAttributesModel() { AttrId = attr.AttributeId, AttrValues = new List <TypeAttrValue>(), Name = attribute.Name }; foreach (var attrV in values) { if (prodAttrs.Any(p => p.ValueId == attrV.Id)) { attrModel.AttrValues.Add(new TypeAttrValue { Id = attrV.Id.ToString(), Name = attrV.Value }); } } ProductAttrs.Add(attrModel); } else { var attrTemp = ProductAttrs.FirstOrDefault(p => p.AttrId == attr.AttributeId); var values = _iTypeService.GetAttributeValues(attr.AttributeId); if (!attrTemp.AttrValues.Any(p => p.Id == attr.ValueId.ToString())) { attrTemp.AttrValues.Add(new TypeAttrValue { Id = attr.ValueId.ToString(), Name = values.FirstOrDefault(a => a.Id == attr.ValueId).Value }); } } } model.ProductAttrs = ProductAttrs; #endregion #region 获取评论、咨询数量 model.CommentCount = CommentApplication.GetCommentCountByProduct(product.Id); var consultations = _iConsultationService.GetConsultations(gid); model.Consultations = consultations.Count(); #endregion #region 累加浏览次数、 加入历史记录 if (CurrentUser != null) { BrowseHistrory.AddBrowsingProduct(product.Id, CurrentUser.Id); } else { BrowseHistrory.AddBrowsingProduct(product.Id); } //_iProductService.LogProductVisti(gid); //统计商品浏览量、店铺浏览人数 StatisticApplication.StatisticVisitCount(product.Id, product.ShopId); #endregion #region 红包 var bonus = ServiceApplication.Create <IShopBonusService>().GetByShopId(product.ShopId); if (bonus != null) { model.GrantPrice = bonus.GrantPrice; } else { model.GrantPrice = 0; } #endregion #region 获取店铺的评价统计 var shopStatisticOrderComments = _iShopService.GetShopStatisticOrderComments(shop.Id); var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault(); var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault(); var sellerDeliverySpeed = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault(); var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault(); var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault(); var sellerDeliverySpeedPeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault(); var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault(); var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault(); var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault(); var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault(); var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault(); var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault(); decimal defaultValue = 5; //宝贝与描述 if (productAndDescription != null && productAndDescriptionPeer != null) { ViewBag.ProductAndDescription = productAndDescription.CommentValue; ViewBag.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue; ViewBag.ProductAndDescriptionMin = productAndDescriptionMin.CommentValue; ViewBag.ProductAndDescriptionMax = productAndDescriptionMax.CommentValue; } else { ViewBag.ProductAndDescription = defaultValue; ViewBag.ProductAndDescriptionPeer = defaultValue; ViewBag.ProductAndDescriptionMin = defaultValue; ViewBag.ProductAndDescriptionMax = defaultValue; } //卖家服务态度 if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null) { ViewBag.SellerServiceAttitude = sellerServiceAttitude.CommentValue; ViewBag.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue; ViewBag.SellerServiceAttitudeMax = sellerServiceAttitudeMax.CommentValue; ViewBag.SellerServiceAttitudeMin = sellerServiceAttitudeMin.CommentValue; } else { ViewBag.SellerServiceAttitude = defaultValue; ViewBag.SellerServiceAttitudePeer = defaultValue; ViewBag.SellerServiceAttitudeMax = defaultValue; ViewBag.SellerServiceAttitudeMin = defaultValue; } //卖家发货速度 if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null) { ViewBag.SellerDeliverySpeed = sellerDeliverySpeed.CommentValue; ViewBag.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue; ViewBag.SellerDeliverySpeedMax = sellerDeliverySpeedMax.CommentValue; ViewBag.sellerDeliverySpeedMin = sellerDeliverySpeedMin.CommentValue; } else { ViewBag.SellerDeliverySpeed = defaultValue; ViewBag.SellerDeliverySpeedPeer = defaultValue; ViewBag.SellerDeliverySpeedMax = defaultValue; ViewBag.sellerDeliverySpeedMin = defaultValue; } #endregion #region 客服 model.Service = ServiceApplication.Create <ICustomerService>().GetCustomerService(shop.Id).Where(c => c.Type == Entities.CustomerServiceInfo.ServiceType.PreSale && c.TerminalType == Entities.CustomerServiceInfo.ServiceTerminalType.PC).OrderBy(m => m.Tool); #endregion #region 开团提醒场景二维码 var siteSetting = SiteSettingApplication.SiteSettings; if (DateTime.Parse(model.FlashSale.BeginDate) > DateTime.Now && WXIsConfig(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret)) { try { var token = AccessTokenContainer.TryGetAccessToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret); SceneHelper helper = new SceneHelper(); SceneModel scene = new SceneModel(QR_SCENE_Type.FlashSaleRemind, model.FlashSale.Id); int sceneId = helper.SetModel(scene); var ticket = QrCodeApi.Create(token, 86400, sceneId, Senparc.Weixin.MP.QrCode_ActionName.QR_LIMIT_SCENE, null).ticket; ViewBag.ticket = ticket; } catch { } } #endregion model.Logined = (null != CurrentUser) ? 1 : 0; model.EnabledBuy = product.AuditStatus == Entities.ProductInfo.ProductAuditStatus.Audited && DateTime.Parse(market.BeginDate) <= DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now && product.SaleStatus == Entities.ProductInfo.ProductSaleStatus.OnSale; if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) < DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now) { TimeSpan end = new TimeSpan(DateTime.Parse(market.EndDate).Ticks); TimeSpan start = new TimeSpan(DateTime.Now.Ticks); TimeSpan ts = end.Subtract(start); model.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds; } else if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) > DateTime.Now) { TimeSpan end = new TimeSpan(DateTime.Parse(market.BeginDate).Ticks); TimeSpan start = new TimeSpan(DateTime.Now.Ticks); TimeSpan ts = end.Subtract(start); model.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds; } //补充当前店铺红包功能 ViewBag.isShopPage = true; ViewBag.CurShopId = product.ShopId; TempData["isShopPage"] = true; TempData["CurShopId"] = product.ShopId; ViewBag.Keyword = SiteSettings.Keyword; ViewBag.Quantity = market.Quantity;//总活动库存 model.VirtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(product.Id); model.FreightTemplate = FreightTemplateApplication.GetFreightTemplate(product.FreightTemplateId); return(View(model)); }
/// <summary> /// 拼团活动商品详情 /// </summary> /// <param name="id">拼团活动ID</param> /// /// <param name="grouId">团活动ID</param> /// <returns></returns> public JsonResult <Result <dynamic> > GetActiveDetail(long id, long grouId = 0, bool isFirst = true, string ids = "") { var userList = new List <FightGroupOrderInfo>(); var data = FightGroupApplication.GetActive(id, true, true); FightGroupActiveModel result = data; //先初始化拼团商品主图 result.InitProductImages(); var imgpath = data.ProductImgPath; if (result != null) { result.IsEnd = true; if (data.EndTime.Date >= DateTime.Now.Date) { result.IsEnd = false; } //商品图片地址修正 result.ProductDefaultImage = HimallIO.GetRomoteProductSizeImage(imgpath, 1, (int)ImageSize.Size_350); result.ProductImgPath = HimallIO.GetRomoteProductSizeImage(imgpath, 1); } if (result.ProductImages != null) {//将主图相对路径处理为绝对路径 result.ProductImages = result.ProductImages.Select(e => HimallIO.GetRomoteImagePath(e)).ToList(); } if (!string.IsNullOrWhiteSpace(result.IconUrl)) { result.IconUrl = Himall.Core.HimallIO.GetRomoteImagePath(result.IconUrl); } bool IsUserEnter = false; long currentUser = 0; if (CurrentUser != null) { currentUser = CurrentUser.Id; } if (grouId > 0)//获取已参团的用户 { userList = ServiceProvider.Instance <IFightGroupService> .Create.GetActiveUsers(id, grouId); foreach (var item in userList) { item.Photo = !string.IsNullOrWhiteSpace(item.Photo) ? Core.HimallIO.GetRomoteImagePath(item.Photo) : ""; item.HeadUserIcon = !string.IsNullOrWhiteSpace(item.HeadUserIcon) ? Core.HimallIO.GetRomoteImagePath(item.HeadUserIcon) : ""; if (currentUser.Equals(item.OrderUserId)) { IsUserEnter = true; } } } #region 商品规格 var product = ProductManagerApplication.GetProduct((long)result.ProductId); ProductShowSkuInfoModel model = new ProductShowSkuInfoModel(); model.MinSalePrice = data.MiniSalePrice; model.ProductImagePath = string.IsNullOrWhiteSpace(imgpath) ? "" : HimallIO.GetRomoteProductSizeImage(imgpath, 1, (int)Himall.CommonModel.ImageSize.Size_350); List <SKUDataModel> skudata = data.ActiveItems.Where(d => d.ActiveStock > 0).Select(d => new SKUDataModel { SkuId = d.SkuId, Color = d.Color, Size = d.Size, Version = d.Version, Stock = (int)d.ActiveStock, CostPrice = d.ProductCostPrice, SalePrice = d.ProductPrice, Price = d.ActivePrice, }).ToList(); Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetType(product.TypeId); string colorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; string sizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; if (product != null) { colorAlias = !string.IsNullOrWhiteSpace(product.ColorAlias) ? product.ColorAlias : colorAlias; sizeAlias = !string.IsNullOrWhiteSpace(product.SizeAlias) ? product.SizeAlias : sizeAlias; versionAlias = !string.IsNullOrWhiteSpace(product.VersionAlias) ? product.VersionAlias : versionAlias; } model.ColorAlias = colorAlias; model.SizeAlias = sizeAlias; model.VersionAlias = versionAlias; if (result.ActiveItems != null && result.ActiveItems.Count() > 0) { long colorId = 0, sizeId = 0, versionId = 0; var skus = ProductManagerApplication.GetSKUs((long)result.ProductId); foreach (var sku in result.ActiveItems) { var specs = sku.SkuId.Split('_'); if (specs.Count() > 0 && !string.IsNullOrEmpty(sku.Color)) { if (long.TryParse(specs[1], out colorId)) { } if (colorId != 0) { if (!model.Color.Any(v => v.Value.Equals(sku.Color))) { var c = result.ActiveItems.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.ActiveStock); model.Color.Add(new ProductSKU { //Name = "选择颜色", Name = "选择" + colorAlias, EnabledClass = c != 0 ? " " : "disabled", //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "", SelectedClass = "", SkuId = colorId, Value = sku.Color, Img = string.IsNullOrWhiteSpace(sku.ShowPic) ? "" : Core.HimallIO.GetRomoteImagePath(sku.ShowPic) }); } } } if (specs.Count() > 1 && !string.IsNullOrEmpty(sku.Size)) { if (long.TryParse(specs[2], out sizeId)) { } if (sizeId != 0) { if (!model.Size.Any(v => v.Value.Equals(sku.Size))) { var ss = result.ActiveItems.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.ActiveStock); model.Size.Add(new ProductSKU { //Name = "选择尺码", Name = "选择" + sizeAlias, EnabledClass = ss != 0 ? "enabled" : "disabled", SelectedClass = "", SkuId = sizeId, Value = sku.Size }); } } } if (specs.Count() > 2 && !string.IsNullOrEmpty(sku.Version)) { if (long.TryParse(specs[3], out versionId)) { } if (versionId != 0) { if (!model.Version.Any(v => v.Value.Equals(sku.Version))) { var v = result.ActiveItems.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.ActiveStock); model.Version.Add(new ProductSKU { //Name = "选择规格", Name = "选择" + versionAlias, EnabledClass = v != 0 ? "enabled" : "disabled", SelectedClass = "", SkuId = versionId, Value = sku.Version }); } } } } } #endregion var cashDepositModel = CashDepositsApplication.GetCashDepositsObligation((long)result.ProductId);//提供服务(消费者保障、七天无理由、及时发货) var GroupsData = new List <FightGroupsListModel>(); List <FightGroupBuildStatus> stlist = new List <FightGroupBuildStatus>(); stlist.Add(FightGroupBuildStatus.Ongoing); GroupsData = FightGroupApplication.GetGroups(id, stlist, null, null, 1, 10).Models.ToList(); foreach (var item in GroupsData) { TimeSpan mid = item.AddGroupTime.AddHours((double)item.LimitedHour) - DateTime.Now; item.Seconds = (int)mid.TotalSeconds; item.EndHourOrMinute = item.ShowHourOrMinute(item.GetEndHour); item.HeadUserIcon = !string.IsNullOrWhiteSpace(item.HeadUserIcon) ? Core.HimallIO.GetRomoteImagePath(item.HeadUserIcon) : ""; } #region 商品评论 ProductCommentShowModel modelSay = new ProductCommentShowModel(); modelSay.ProductId = (long)result.ProductId; var productSay = ProductManagerApplication.GetProduct((long)result.ProductId); modelSay.CommentList = new List <ProductDetailCommentModel>(); modelSay.IsShowColumnTitle = true; modelSay.IsShowCommentList = true; if (productSay == null) { //跳转到404页面 throw new Core.HimallException("商品不存在"); } var comments = CommentApplication.GetCommentsByProduct(product.Id); modelSay.CommentCount = comments.Count; if (comments.Count > 0) { var comment = comments.OrderByDescending(a => a.ReviewDate).FirstOrDefault(); var orderItem = OrderApplication.GetOrderItem(comment.SubOrderId); var order = OrderApplication.GetOrder(orderItem.OrderId); modelSay.CommentList = comments.OrderByDescending(a => a.ReviewDate) .Take(1) .Select(c => { var images = CommentApplication.GetProductCommentImagesByCommentIds(new List <long> { c.Id }); return(new ProductDetailCommentModel { Sku = ServiceProvider.Instance <IProductService> .Create.GetSkuString(orderItem.SkuId), UserName = c.UserName, ReviewContent = c.ReviewContent, AppendContent = c.AppendContent, AppendDate = c.AppendDate, ReplyAppendContent = c.ReplyAppendContent, ReplyAppendDate = c.ReplyAppendDate, FinshDate = order.FinishDate, Images = images.Where(a => a.CommentType == 0).Select(a => a.CommentImage).ToList(), AppendImages = images.Where(a => a.CommentType == 1).Select(a => a.CommentImage).ToList(), ReviewDate = c.ReviewDate, ReplyContent = string.IsNullOrWhiteSpace(c.ReplyContent) ? "暂无回复" : c.ReplyContent, ReplyDate = c.ReplyDate, ReviewMark = c.ReviewMark, BuyDate = order.OrderDate }); }).ToList(); foreach (var citem in modelSay.CommentList) { if (citem.Images.Count > 0) { for (var _imgn = 0; _imgn < citem.Images.Count; _imgn++) { citem.Images[_imgn] = Himall.Core.HimallIO.GetRomoteImagePath(citem.Images[_imgn]); } } if (citem.AppendImages.Count > 0) { for (var _imgn = 0; _imgn < citem.AppendImages.Count; _imgn++) { citem.AppendImages[_imgn] = Himall.Core.HimallIO.GetRomoteImagePath(citem.AppendImages[_imgn]); } } } } #endregion #region 店铺信息 VShopShowShopScoreModel modelShopScore = new VShopShowShopScoreModel(); modelShopScore.ShopId = result.ShopId; var shop = ServiceProvider.Instance <IShopService> .Create.GetShop(result.ShopId); if (shop == null) { throw new HimallException("错误的店铺信息"); } modelShopScore.ShopName = shop.ShopName; #region 获取店铺的评价统计 var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(result.ShopId); var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault(); var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault(); var sellerDeliverySpeed = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault(); var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault(); var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault(); var sellerDeliverySpeedPeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault(); var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault(); var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault(); var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault(); var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault(); var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault(); var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault(); decimal defaultValue = 5; modelShopScore.SellerServiceAttitude = defaultValue; modelShopScore.SellerServiceAttitudePeer = defaultValue; modelShopScore.SellerServiceAttitudeMax = defaultValue; modelShopScore.SellerServiceAttitudeMin = defaultValue; //宝贝与描述 if (productAndDescription != null && productAndDescriptionPeer != null && !shop.IsSelf) { modelShopScore.ProductAndDescription = productAndDescription.CommentValue; modelShopScore.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue; modelShopScore.ProductAndDescriptionMin = productAndDescriptionMin.CommentValue; modelShopScore.ProductAndDescriptionMax = productAndDescriptionMax.CommentValue; } else { modelShopScore.ProductAndDescription = defaultValue; modelShopScore.ProductAndDescriptionPeer = defaultValue; modelShopScore.ProductAndDescriptionMin = defaultValue; modelShopScore.ProductAndDescriptionMax = defaultValue; } //卖家服务态度 if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null && !shop.IsSelf) { modelShopScore.SellerServiceAttitude = sellerServiceAttitude.CommentValue; modelShopScore.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue; modelShopScore.SellerServiceAttitudeMax = sellerServiceAttitudeMax.CommentValue; modelShopScore.SellerServiceAttitudeMin = sellerServiceAttitudeMin.CommentValue; } else { modelShopScore.SellerServiceAttitude = defaultValue; modelShopScore.SellerServiceAttitudePeer = defaultValue; modelShopScore.SellerServiceAttitudeMax = defaultValue; modelShopScore.SellerServiceAttitudeMin = defaultValue; } //卖家发货速度 if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null && !shop.IsSelf) { modelShopScore.SellerDeliverySpeed = sellerDeliverySpeed.CommentValue; modelShopScore.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue; modelShopScore.SellerDeliverySpeedMax = sellerDeliverySpeedMax != null ? sellerDeliverySpeedMax.CommentValue : 0; modelShopScore.sellerDeliverySpeedMin = sellerDeliverySpeedMin != null ? sellerDeliverySpeedMin.CommentValue : 0; } else { modelShopScore.SellerDeliverySpeed = defaultValue; modelShopScore.SellerDeliverySpeedPeer = defaultValue; modelShopScore.SellerDeliverySpeedMax = defaultValue; modelShopScore.sellerDeliverySpeedMin = defaultValue; } #endregion modelShopScore.ProductNum = ServiceProvider.Instance <IProductService> .Create.GetShopOnsaleProducts(result.ShopId); modelShopScore.IsFavoriteShop = false; modelShopScore.FavoriteShopCount = ServiceProvider.Instance <IShopService> .Create.GetShopFavoritesCount(result.ShopId); if (CurrentUser != null) { modelShopScore.IsFavoriteShop = ServiceProvider.Instance <IShopService> .Create.GetFavoriteShopInfos(CurrentUser.Id).Any(d => d.ShopId == result.ShopId); } long vShopId; var vshopinfo = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id); if (vshopinfo == null) { vShopId = -1; } else { vShopId = vshopinfo.Id; } modelShopScore.VShopId = vShopId; modelShopScore.VShopLog = ServiceProvider.Instance <IVShopService> .Create.GetVShopLog(vShopId); if (!string.IsNullOrWhiteSpace(modelShopScore.VShopLog)) { modelShopScore.VShopLog = Himall.Core.HimallIO.GetRomoteImagePath(modelShopScore.VShopLog); } // 客服 var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(shop.Id); #endregion #region 根据运费模板获取发货地址 var freightTemplateService = ServiceApplication.Create <IFreightTemplateService>(); var template = freightTemplateService.GetFreightTemplate(product.FreightTemplateId); string productAddress = string.Empty; if (template != null) { var fullName = ServiceApplication.Create <IRegionService>().GetFullName(template.SourceAddress); if (fullName != null) { var ass = fullName.Split(' '); if (ass.Length >= 2) { productAddress = ass[0] + " " + ass[1]; } else { productAddress = ass[0]; } } } var ProductAddress = productAddress; var FreightTemplate = template; #endregion #region 获取店铺优惠信息 VShopShowPromotionModel modelVshop = new VShopShowPromotionModel(); modelVshop.ShopId = result.ShopId; var shopInfo = ServiceProvider.Instance <IShopService> .Create.GetShop(result.ShopId); if (shopInfo == null) { throw new HimallException("错误的店铺编号"); } modelVshop.FreeFreight = shop.FreeFreight; var bonus = ServiceApplication.Create <IShopBonusService>().GetByShopId(result.ShopId); if (bonus != null) { modelVshop.BonusCount = bonus.Count; modelVshop.BonusGrantPrice = bonus.GrantPrice; modelVshop.BonusRandomAmountStart = bonus.RandomAmountStart; modelVshop.BonusRandomAmountEnd = bonus.RandomAmountEnd; } FullDiscountActive fullDiscount = null; //var fullDiscount = FullDiscountApplication.GetOngoingActiveByProductId(id, shop.Id); #endregion //商品描述 var description = ProductManagerApplication.GetProductDescription(result.ProductId); if (description == null) { throw new HimallException("错误的商品编号"); } string DescriptionPrefix = "", DescriptiondSuffix = ""; var iprodestempser = ServiceApplication.Create <IProductDescriptionTemplateService>(); if (description.DescriptionPrefixId != 0) { var desc = iprodestempser.GetTemplate(description.DescriptionPrefixId, product.ShopId); DescriptionPrefix = desc == null ? "" : desc.MobileContent; } if (description.DescriptiondSuffixId != 0) { var desc = iprodestempser.GetTemplate(description.DescriptiondSuffixId, product.ShopId); DescriptiondSuffix = desc == null ? "" : desc.MobileContent; } var productDescription = DescriptionPrefix + description.ShowMobileDescription + DescriptiondSuffix; //统计商品浏览量、店铺浏览人数 StatisticApplication.StatisticVisitCount(product.Id, product.ShopId); AutoMapper.Mapper.CreateMap <FightGroupActiveModel, FightGroupActiveResult>(); var fightGroupData = AutoMapper.Mapper.Map <FightGroupActiveResult>(result); decimal discount = 1M; if (CurrentUser != null) { discount = CurrentUser.MemberDiscount; } var shopItem = ShopApplication.GetShop(result.ShopId); fightGroupData.MiniSalePrice = shopItem.IsSelf ? fightGroupData.MiniSalePrice * discount : fightGroupData.MiniSalePrice; string loadShowPrice = string.Empty;//app拼团详细页加载时显示的区间价 loadShowPrice = fightGroupData.MiniSalePrice.ToString("f2"); if (fightGroupData != null && fightGroupData.ActiveItems.Count() > 0) { decimal min = fightGroupData.ActiveItems.Min(s => s.ActivePrice); decimal max = fightGroupData.ActiveItems.Max(s => s.ActivePrice); loadShowPrice = (min < max) ? (min.ToString("f2") + " - " + max.ToString("f2")) : min.ToString("f2"); } var _result = new { success = true, FightGroupData = fightGroupData, ShowSkuInfo = new { ColorAlias = model.ColorAlias, SizeAlias = model.SizeAlias, VersionAlias = model.VersionAlias, MinSalePrice = model.MinSalePrice, ProductImagePath = model.ProductImagePath, Color = model.Color.OrderByDescending(p => p.SkuId), Size = model.Size.OrderByDescending(p => p.SkuId), Version = model.Version.OrderByDescending(p => p.SkuId) }, ShowPromotion = modelVshop, fullDiscount = fullDiscount, ShowNewCanJoinGroup = GroupsData, ProductCommentShow = modelSay, ProductDescription = productDescription.Replace("src=\"/Storage/", "src=\"" + Core.HimallIO.GetRomoteImagePath("/Storage") + "/"), ShopScore = modelShopScore, CashDepositsServer = cashDepositModel, ProductAddress = ProductAddress, //Free = FreightTemplate.IsFree == FreightTemplateType.Free ? "免运费" : "", userList = userList, IsUserEnter = IsUserEnter, SkuData = skudata, CustomerServices = customerServices, IsOpenLadder = product.IsOpenLadder, VideoPath = string.IsNullOrWhiteSpace(product.VideoPath) ? string.Empty : Himall.Core.HimallIO.GetRomoteImagePath(product.VideoPath), LoadShowPrice = loadShowPrice, //商品时区间价 ProductSaleCountOnOff = (SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1), //是否显示销量 SaleCounts = data.ActiveItems.Sum(d => d.BuyCount), //销量 FreightStr = FreightTemplateApplication.GetFreightStr(product.Id, FreightTemplate, CurrentUser, product), //运费多少或免运费 SendTime = (FreightTemplate != null && !string.IsNullOrEmpty(FreightTemplate.SendTime) ? (FreightTemplate.SendTime + "h内发货") : ""), //运费模板发货时间 }; return(JsonResult <dynamic>(_result)); }
public JsonResult GetPlatTradeStatistic(DateTime startDate, DateTime endDate) { var platTradeStatistic = StatisticApplication.GetPlatTradeStatistic(startDate, endDate); return(Json(new { success = true, model = platTradeStatistic })); }
public JsonResult GetProductSaleCategoryStatistic(DateTime startDate, DateTime endDate) { var productCateSales = StatisticApplication.GetProductCategorySales(CurrentSellerManager.ShopId, startDate, endDate); return(Json(new { success = true, model = productCateSales }, JsonRequestBehavior.AllowGet)); }
public ActionResult Center() { var userId = CurrentUser.Id; MemberCenterModel model = new MemberCenterModel(); var statistic = StatisticApplication.GetMemberOrderStatistic(userId, true); var member = _iMemberService.GetMember(userId); model.Member = member; model.AllOrders = statistic.OrderCount; model.WaitingForRecieve = statistic.WaitingForRecieve + OrderApplication.GetWaitConsumptionOrderNumByUserId(UserId); model.WaitingForPay = statistic.WaitingForPay; model.WaitingForDelivery = statistic.WaitingForDelivery; model.WaitingForComments = statistic.WaitingForComments; model.RefundOrders = statistic.RefundCount; model.FavoriteProductCount = FavoriteApplication.GetFavoriteCountByUser(userId); //拼团 model.CanFightGroup = FightGroupApplication.IsOpenMarketService(); model.BulidFightGroupNumber = FightGroupApplication.CountJoiningOrder(userId); model.Capital = MemberCapitalApplication.GetBalanceByUserId(userId); model.CouponsCount = MemberApplication.GetAvailableCouponCount(userId); var integral = MemberIntegralApplication.GetMemberIntegral(userId); model.GradeName = MemberGradeApplication.GetMemberGradeByUserIntegral(integral.HistoryIntegrals).GradeName; model.MemberAvailableIntegrals = MemberIntegralApplication.GetAvailableIntegral(userId); model.CollectionShop = ShopApplication.GetUserConcernShopsCount(userId); model.CanSignIn = _iMemberSignInService.CanSignInByToday(userId); model.SignInIsEnable = _iMemberSignInService.GetConfig().IsEnable; model.userMemberInfo = CurrentUser; model.IsOpenRechargePresent = SiteSettings.IsOpenRechargePresent; model.DistributionOpenMyShopShow = SiteSettings.DistributorRenameOpenMyShop; model.DistributionMyShopShow = SiteSettings.DistributorRenameMyShop; if (PlatformType == PlatformType.WeiXin) { //分销 model.IsShowDistributionOpenMyShop = SiteSettings.DistributionIsEnable; var duser = DistributionApplication.GetDistributor(CurrentUser.Id); if (duser != null && duser.DistributionStatus != (int)DistributorStatus.UnApply) { model.IsShowDistributionOpenMyShop = false; //拒绝的分销员显示“我要开店” if (duser.DistributionStatus == (int)DistributorStatus.Refused || duser.DistributionStatus == (int)DistributorStatus.UnAudit) { model.IsShowDistributionOpenMyShop = true && SiteSettings.DistributionIsEnable; } model.IsShowDistributionMyShop = true && SiteSettings.DistributionIsEnable; if (duser.DistributionStatus == (int)DistributorStatus.NotAvailable || duser.DistributionStatus == (int)DistributorStatus.Refused || duser.DistributionStatus == (int)DistributorStatus.UnAudit) { model.IsShowDistributionMyShop = false; } } } _iMemberService.AddIntegel(member); //给用户加积分//执行登录后初始化相关操作 return(View(model)); }
public JsonResult GetProductSaleCategoryStatistic(DateTime startDate, DateTime endDate) { var productCateSales = StatisticApplication.GetProductCategorySales(0, startDate, endDate); return(Json(new { success = true, model = productCateSales })); }
public object GetProductDetail(long id) { ProductDetailModelForMobie model = new ProductDetailModelForMobie() { Product = new ProductInfoModel(), Shop = new ShopInfoModel(), Color = new CollectionSKU(), Size = new CollectionSKU(), Version = new CollectionSKU() }; ProductInfo product = null; ShopInfo shop = null; product = ServiceProvider.Instance <IProductService> .Create.GetProduct(id); var cashDepositModel = ServiceProvider.Instance <ICashDepositsService> .Create.GetCashDepositsObligation(product.Id);//提供服务(消费者保障、七天无理由、及时发货) model.CashDepositsServer = cashDepositModel; #region 根据运费模板获取发货地址 var freightTemplateService = ServiceHelper.Create <IFreightTemplateService>(); FreightTemplateInfo template = freightTemplateService.GetFreightTemplate(product.FreightTemplateId); string productAddress = string.Empty; if (template != null && template.SourceAddress.HasValue) { var fullName = ServiceHelper.Create <IRegionService>().GetFullName(template.SourceAddress.Value); if (fullName != null) { var ass = fullName.Split(' '); if (ass.Length >= 2) { productAddress = ass[0] + " " + ass[1]; } else { productAddress = ass[0]; } } } model.ProductAddress = productAddress; model.FreightTemplate = template; #endregion #region 店铺Logo long vShopId; shop = ServiceProvider.Instance <IShopService> .Create.GetShop(product.ShopId); var vshopinfo = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id); if (vshopinfo == null) { vShopId = -1; } else { vShopId = vshopinfo.Id; } model.Shop.VShopId = vShopId; model.VShopLog = ServiceProvider.Instance <IVShopService> .Create.GetVShopLog(model.Shop.VShopId); #endregion model.Shop.FavoriteShopCount = ServiceProvider.Instance <IShopService> .Create.GetShopFavoritesCount(product.ShopId);//关注人数 var com = product.Himall_ProductComments.Where(item => !item.IsHidden.HasValue || item.IsHidden.Value == false); var limitBuy = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetLimitTimeMarketItemByProductId(id); #region 商品SKU ProductTypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetType(product.TypeId); string colorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; string sizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; if (limitBuy != null) { var limitSku = ServiceProvider.Instance <ILimitTimeBuyService> .Create.Get(limitBuy.Id); var limitSkuItem = limitSku.Details.OrderBy(d => d.Price).FirstOrDefault(); if (limitSkuItem != null) { product.MinSalePrice = limitSkuItem.Price; } } if (product.SKUInfo != null && product.SKUInfo.Count() > 0) { long colorId = 0, sizeId = 0, versionId = 0; foreach (var sku in product.SKUInfo) { var specs = sku.Id.Split('_'); if (specs.Count() > 0) { if (long.TryParse(specs[1], out colorId)) { } if (colorId != 0) { if (!model.Color.Any(v => v.Value.Equals(sku.Color))) { var c = product.SKUInfo.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock); model.Color.Add(new ProductSKU { //Name = "选择颜色", Name = "选择" + colorAlias, EnabledClass = c != 0 ? "enabled" : "disabled", //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "", SelectedClass = "", SkuId = colorId, Value = sku.Color, Img = Himall.Core.HimallIO.GetRomoteImagePath(sku.ShowPic) }); } } } if (specs.Count() > 1) { if (long.TryParse(specs[2], out sizeId)) { } if (sizeId != 0) { if (!model.Size.Any(v => v.Value.Equals(sku.Size))) { var ss = product.SKUInfo.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock); model.Size.Add(new ProductSKU { //Name = "选择尺码", Name = "选择" + sizeAlias, EnabledClass = ss != 0 ? "enabled" : "disabled", //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "", SelectedClass = "", SkuId = sizeId, Value = sku.Size }); } } } if (specs.Count() > 2) { if (long.TryParse(specs[3], out versionId)) { } if (versionId != 0) { if (!model.Version.Any(v => v.Value.Equals(sku.Version))) { var v = product.SKUInfo.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock); model.Version.Add(new ProductSKU { //Name = "选择版本", Name = "选择" + versionAlias, EnabledClass = v != 0 ? "enabled" : "disabled", //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "", SelectedClass = "", SkuId = versionId, Value = sku.Version }); } } } } } #endregion #region 店铺 shop = ServiceProvider.Instance <IShopService> .Create.GetShop(product.ShopId); var mark = ShopServiceMark.GetShopComprehensiveMark(shop.Id); model.Shop.PackMark = mark.PackMark; model.Shop.ServiceMark = mark.ServiceMark; model.Shop.ComprehensiveMark = mark.ComprehensiveMark; var comm = ServiceProvider.Instance <ICommentService> .Create.GetCommentsByProductId(id); model.Shop.Name = shop.ShopName; model.Shop.ProductMark = (comm == null || comm.Count() == 0) ? 0 : comm.Average(p => (decimal)p.ReviewMark); model.Shop.Id = product.ShopId; model.Shop.FreeFreight = shop.FreeFreight; model.Shop.ProductNum = ServiceProvider.Instance <IProductService> .Create.GetShopOnsaleProducts(product.ShopId); var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(product.ShopId); var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault(); var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault(); var sellerDeliverySpeed = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault(); var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault(); var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault(); var sellerDeliverySpeedPeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault(); var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault(); var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault(); var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault(); var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault(); var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault(); var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault(); decimal defaultValue = 5; //宝贝与描述 if (productAndDescription != null && productAndDescriptionPeer != null) { model.Shop.ProductAndDescription = productAndDescription.CommentValue; } else { model.Shop.ProductAndDescription = defaultValue; } //卖家服务态度 if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null) { model.Shop.SellerServiceAttitude = sellerServiceAttitude.CommentValue; } else { model.Shop.SellerServiceAttitude = defaultValue; } //卖家发货速度 if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null) { model.Shop.SellerDeliverySpeed = sellerDeliverySpeed.CommentValue; } else { model.Shop.SellerDeliverySpeed = defaultValue; } if (ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id) == null) { model.Shop.VShopId = -1; } else { model.Shop.VShopId = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id).Id; } //优惠券 var couponCount = GetCouponList(shop.Id);//取设置的优惠券 if (couponCount > 0) { model.Shop.CouponCount = couponCount; } // 客服 var customerServices = CustomerServiceApplication.GetMobileCustomerService(shop.Id); var meiqia = CustomerServiceApplication.GetPreSaleByShopId(shop.Id).FirstOrDefault(p => p.Tool == CustomerServiceInfo.ServiceTool.MeiQia); if (meiqia != null) { customerServices.Insert(0, meiqia); } #endregion #region 商品 var consultations = ServiceProvider.Instance <IConsultationService> .Create.GetConsultations(id); double total = product.Himall_ProductComments.Count(); double niceTotal = product.Himall_ProductComments.Count(item => item.ReviewMark >= 4); bool isFavorite = false; bool IsFavoriteShop = false; decimal discount = 1M; if (CurrentUser == null) { isFavorite = false; IsFavoriteShop = false; } else { isFavorite = ServiceProvider.Instance <IProductService> .Create.IsFavorite(product.Id, CurrentUser.Id); var favoriteShopIds = ServiceProvider.Instance <IShopService> .Create.GetFavoriteShopInfos(CurrentUser.Id).Select(item => item.ShopId).ToArray();//获取已关注店铺 IsFavoriteShop = favoriteShopIds.Contains(product.ShopId); discount = CurrentUser.MemberDiscount; } var productImage = new List <string>(); for (int i = 1; i < 6; i++) { if (Core.HimallIO.ExistFile(product.RelativePath + string.Format("/{0}.png", i))) { var path = Core.HimallIO.GetRomoteProductSizeImage(product.RelativePath, i, (int)Himall.CommonModel.ImageSize.Size_350); productImage.Add(path); } } //File.Exists(HttpContext.Current.Server.MapPath(product.ImagePath + string.Format("/{0}.png", 1))); decimal minSalePrice = shop.IsSelf ? product.MinSalePrice * discount : product.MinSalePrice; var isValidLimitBuy = "false"; if (limitBuy != null) { isValidLimitBuy = "true"; minSalePrice = limitBuy.MinPrice; //限时购不打折 } bool isFightGroupActive = false; var activeInfo = ServiceProvider.Instance <IFightGroupService> .Create.GetActiveByProId(product.Id); if (activeInfo != null && activeInfo.ActiveStatus > FightGroupActiveStatus.Ending) { isFightGroupActive = true; } model.Product = new ProductInfoModel() { ProductId = product.Id, CommentCount = com.Count(),//product.Himall_ProductComments.Count(), Consultations = consultations.Count(), ImagePath = productImage, IsFavorite = isFavorite, MarketPrice = product.MarketPrice, MinSalePrice = minSalePrice, NicePercent = model.Shop.ProductMark == 0 ? 100 : (int)((niceTotal / total) * 100), ProductName = product.ProductName, ProductSaleStatus = product.SaleStatus, AuditStatus = product.AuditStatus, ShortDescription = product.ShortDescription, ProductDescription = GetProductDescription(product.ProductDescriptionInfo), IsOnLimitBuy = limitBuy != null }; #endregion #region 佣金 var probroker = DistributionApplication.GetDistributionProductInfo(id); var IsDistribution = false; decimal Brokerage = 0; if (probroker != null) { IsDistribution = true; Brokerage = probroker.Commission; } #endregion #region 代金红包 var bonus = ServiceProvider.Instance <IShopBonusService> .Create.GetByShopId(shop.Id); int BonusCount = 0; decimal BonusGrantPrice = 0; decimal BonusRandomAmountStart = 0; decimal BonusRandomAmountEnd = 0; if (bonus != null) { BonusCount = bonus.Count; BonusGrantPrice = bonus.GrantPrice; BonusRandomAmountStart = bonus.RandomAmountStart; BonusRandomAmountEnd = bonus.RandomAmountEnd; } var fullDiscount = FullDiscountApplication.GetOngoingActiveByProductId(id, shop.Id); #endregion LogProduct(id); //统计商品浏览量、店铺浏览人数 StatisticApplication.StatisticVisitCount(product.Id, product.ShopId); var IsPromoter = false; if (CurrentUser != null && CurrentUser.Id > 0) { var prom = DistributionApplication.GetPromoterByUserId(CurrentUser.Id); if (prom != null && prom.Status == PromoterInfo.PromoterStatus.Audited) { IsPromoter = true; } } return(Json(new { Success = "true", IsOnLimitBuy = isValidLimitBuy, IsFightGroupActive = isFightGroupActive, ActiveId = isFightGroupActive ? activeInfo.Id : 0, ActiveStatus = activeInfo != null ? activeInfo.ActiveStatus.GetHashCode() : 0, MaxSaleCount = limitBuy == null ? 0 : limitBuy.LimitCountOfThePeople, Title = limitBuy == null ? string.Empty : limitBuy.Title, Second = limitBuy == null ? 0 : (limitBuy.EndDate - DateTime.Now).TotalSeconds, Product = model.Product, CashDepositsServer = model.CashDepositsServer, //提供服务(消费者保障、七天无理由、及时发货) ProductAddress = model.ProductAddress, //发货地址 Free = model.FreightTemplate.IsFree == FreightTemplateType.Free ? "免运费" : "", //是否免运费 VShopLog = Himall.Core.HimallIO.GetRomoteImagePath(model.VShopLog), Shop = model.Shop, IsFavoriteShop = IsFavoriteShop, Color = model.Color, Size = model.Size, Version = model.Version, BonusCount = BonusCount, BonusGrantPrice = BonusGrantPrice, BonusRandomAmountStart = BonusRandomAmountStart, BonusRandomAmountEnd = BonusRandomAmountEnd, fullDiscount = fullDiscount, ColorAlias = colorAlias, SizeAlias = sizeAlias, VersionAlias = versionAlias, IsDistribution = IsDistribution, Brokerage = Brokerage.ToString("f2"), IsPromoter = IsPromoter, userId = CurrentUser == null ? 0 : CurrentUser.Id, IsOpenStore = SiteSettingApplication.GetSiteSettings() != null && SiteSettingApplication.GetSiteSettings().IsOpenStore, CustomerServices = customerServices })); }
public ActionResult SearchAd(string sid, long cid = 0, string keywords = "", int pageNo = 1, decimal startPrice = 0, decimal endPrice = decimal.MaxValue) { int pageSize = 40; long shopId = 0; ShopInfo shopObj = null; endPrice = endPrice <= 0 || endPrice < startPrice ? decimal.MaxValue : endPrice; startPrice = startPrice < 0 ? 0 : startPrice; //shopId 不是数字 if (!long.TryParse(sid, out shopId)) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); //404 页面 } //店铺Id不存在 shopObj = _iShopService.GetShop(shopId); if (null == shopObj) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); //404 页面 } #region 初始化Model ShopHomeModel model = new ShopHomeModel { HotAttentionProducts = new List <HotProductInfo>(), HotSaleProducts = new List <HotProductInfo>(), Floors = new List <ShopHomeFloor>(), Navignations = new List <BannerInfo>(), Shop = new ShopInfoModel(), ShopCategory = new List <CategoryJsonModel>(), Slides = new List <SlideAdInfo>(), Logo = "" }; #endregion #region 导航和3个推荐商品 //导航 model.Navignations = _iNavigationService.GetSellerNavigations(shopObj.Id).ToList(); //banner和3个推荐商品 model.ImageAds = _iSlideAdsService.GetImageAds(shopObj.Id).OrderBy(item => item.Id).ToList(); model.Slides = _iSlideAdsService.GetSlidAds(shopObj.Id, SlideAdInfo.SlideAdType.ShopHome).ToList(); #endregion #region 店铺分类 var categories = _iShopCategoryService.GetShopCategory(shopObj.Id).ToArray(); foreach (var main in categories.Where(s => s.ParentCategoryId == 0)) { var topC = new CategoryJsonModel() { Name = main.Name, Id = main.Id.ToString(), SubCategory = new List <SecondLevelCategory>() }; foreach (var secondItem in categories.Where(s => s.ParentCategoryId == main.Id)) { var secondC = new SecondLevelCategory() { Name = secondItem.Name, Id = secondItem.Id.ToString(), }; topC.SubCategory.Add(secondC); } model.ShopCategory.Add(topC); } #endregion #region 店铺信息 var mark = ShopServiceMark.GetShopComprehensiveMark(shopObj.Id); model.Shop.Name = shopObj.ShopName; model.Shop.CompanyName = shopObj.CompanyName; model.Shop.Id = shopObj.Id; model.Shop.PackMark = mark.PackMark; model.Shop.ServiceMark = mark.ServiceMark; model.Shop.ComprehensiveMark = mark.ComprehensiveMark; model.Shop.Phone = shopObj.CompanyPhone; model.Shop.Address = _iRegionService.GetFullName(shopObj.CompanyRegionId); model.Logo = shopObj.Logo; #endregion SearchProductQuery query = new SearchProductQuery() { ShopId = long.Parse(sid), ShopCategoryId = cid, Keyword = keywords, StartPrice = startPrice, EndPrice = endPrice, PageNumber = pageNo, PageSize = pageSize }; SearchProductResult result = _iSearchProductService.SearchProduct(query); model.Products = result.Data; //#endregion #region 热门销售 var sale = _iProductService.GetHotSaleProduct(shopObj.Id, 5); if (sale != null) { foreach (var item in sale) { model.HotSaleProducts.Add(new HotProductInfo { ImgPath = item.ImagePath, Name = item.ProductName, Price = item.MinSalePrice, Id = item.Id, SaleCount = (int)item.SaleCounts }); } } #endregion #region 热门关注 var hot = _iProductService.GetHotConcernedProduct(shopObj.Id, 5).ToList(); if (hot != null) { foreach (var item in hot) { model.HotAttentionProducts.Add(new HotProductInfo { ImgPath = item.ImagePath, Name = item.ProductName, Price = item.MinSalePrice, Id = item.Id, SaleCount = (int)item.ConcernedCount }); } } #endregion #region 获取店铺的评价统计 var shopStatisticOrderComments = _iShopService.GetShopStatisticOrderComments(shopId); var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault(); var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault(); var sellerDeliverySpeed = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault(); var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault(); var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault(); var sellerDeliverySpeedPeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault(); var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault(); var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault(); var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault(); var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault(); var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault(); var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault(); decimal defaultValue = 5; //宝贝与描述 if (productAndDescription != null && productAndDescriptionPeer != null) { ViewBag.ProductAndDescription = productAndDescription.CommentValue; ViewBag.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue; ViewBag.ProductAndDescriptionMin = productAndDescriptionMin.CommentValue; ViewBag.ProductAndDescriptionMax = productAndDescriptionMax.CommentValue; } else { ViewBag.ProductAndDescription = defaultValue; ViewBag.ProductAndDescriptionPeer = defaultValue; ViewBag.ProductAndDescriptionMin = defaultValue; ViewBag.ProductAndDescriptionMax = defaultValue; } //卖家服务态度 if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null) { ViewBag.SellerServiceAttitude = sellerServiceAttitude.CommentValue; ViewBag.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue; ViewBag.SellerServiceAttitudeMax = sellerServiceAttitudeMax.CommentValue; ViewBag.SellerServiceAttitudeMin = sellerServiceAttitudeMin.CommentValue; } else { ViewBag.SellerServiceAttitude = defaultValue; ViewBag.SellerServiceAttitudePeer = defaultValue; ViewBag.SellerServiceAttitudeMax = defaultValue; ViewBag.SellerServiceAttitudeMin = defaultValue; } //卖家发货速度 if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null) { ViewBag.SellerDeliverySpeed = sellerDeliverySpeed.CommentValue; ViewBag.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue; ViewBag.SellerDeliverySpeedMax = sellerDeliverySpeedMax.CommentValue; ViewBag.sellerDeliverySpeedMin = sellerDeliverySpeedMin.CommentValue; } else { ViewBag.SellerDeliverySpeed = defaultValue; ViewBag.SellerDeliverySpeedPeer = defaultValue; ViewBag.SellerDeliverySpeedMax = defaultValue; ViewBag.sellerDeliverySpeedMin = defaultValue; } #endregion #region 分页控制 PagingInfo info = new PagingInfo { CurrentPage = pageNo, ItemsPerPage = pageSize, TotalItems = result.Total }; ViewBag.pageInfo = info; #endregion var categoryName = string.Empty; if (keywords == string.Empty) { if (cid != 0) { var category = _iShopCategoryService.GetCategory(cid) ?? new ShopCategoryInfo() { }; categoryName = category.Name; } } ViewBag.CategoryName = categoryName; ViewBag.Keyword = keywords; ViewBag.cid = cid; ViewBag.BrowsedHistory = BrowseHistrory.GetBrowsingProducts(13, CurrentUser == null ? 0 : CurrentUser.Id); //补充当前店铺红包功能 ViewBag.isShopPage = true; ViewBag.CurShopId = shopId; TempData["isShopPage"] = true; TempData["CurShopId"] = shopId; //统计店铺访问人数 StatisticApplication.StatisticShopVisitUserCount(shopId); return(View(model)); }
public JsonResult GetPlatTradeStatistic(DateTime startDate, DateTime endDate, int type, long?shopbranchId) { var platTradeStatistic = StatisticApplication.GetShopTradeStatistic(CurrentSellerManager.ShopId, shopbranchId, startDate, endDate, type); return(Json(new { success = true, model = platTradeStatistic }, JsonRequestBehavior.AllowGet)); }
public object GetShopBranchHome() { try { CheckUserLogin(); var now = DateTime.Now; var orderQuery = new OrderCountStatisticsQuery() { ShopBranchId = CurrentShopBranch.Id, Fields = new List <OrderCountStatisticsFields> { OrderCountStatisticsFields.ActualPayAmount } }; //三月内 orderQuery.OrderDateBegin = new DateTime(now.Year, now.Month, 1).AddMonths(-2); var threeMonthAmount = StatisticApplication.GetOrderCount(orderQuery).TotalActualPayAmount; //本周 orderQuery.OrderDateBegin = now.Date.AddDays(-(int)now.DayOfWeek); var weekAmount = StatisticApplication.GetOrderCount(orderQuery).TotalActualPayAmount; //今天 orderQuery.OrderDateBegin = now.Date; var todayAmount = StatisticApplication.GetOrderCount(orderQuery).TotalActualPayAmount; //待自提订单数 orderQuery = new OrderCountStatisticsQuery() { ShopBranchId = CurrentShopBranch.Id, OrderOperateStatus = Entities.OrderInfo.OrderOperateStatus.WaitSelfPickUp, Fields = new List <OrderCountStatisticsFields> { OrderCountStatisticsFields.OrderCount } }; var pickUpOrderCount = StatisticApplication.GetOrderCount(orderQuery).OrderCount; //近三天发布商品数 var productCount = ProductManagerApplication.GetProductCount(new ProductQuery { ShopBranchId = CurrentShopBranch.Id, AuditStatus = new[] { Entities.ProductInfo.ProductAuditStatus.Audited }, StartDate = now.Date.AddDays(-2) }); var vshop = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(CurrentShopBranch.ShopId); var logo = "/Images/branchapp.jpg"; if (vshop != null && vshop.State == Entities.VShopInfo.VShopStates.Normal && !string.IsNullOrEmpty(vshop.WXLogo)) { logo = vshop.WXLogo; } var shopBranch = ShopBranchApplication.GetShopBranchById(CurrentShopBranch.Id); var isShelvesProduct = false; if (shopBranch != null && shopBranch.Status == ShopBranchStatus.Normal) { isShelvesProduct = shopBranch.IsShelvesProduct; } return(new { success = true, data = new { shopName = CurrentShopBranch.ShopBranchName, todayAmount = todayAmount, weekAmount = weekAmount, threeMonthAmounht = threeMonthAmount, createProductCount = productCount, pickUpOrderCount = pickUpOrderCount, logo = logo, shopBranchId = CurrentShopBranch.Id, IsShelvesProduct = isShelvesProduct } }); } catch (Exception ex) { Log.Error(ex.ToString()); return(new { success = false, data = new { } }); } }
public object GetLimitBuyProduct(long id) { ProductDetailModelForMobie model = new ProductDetailModelForMobie() { Product = new ProductInfoModel(), Shop = new ShopInfoModel(), Color = new CollectionSKU(), Size = new CollectionSKU(), Version = new CollectionSKU() }; ProductInfo product = null; ShopInfo shop = null; FlashSaleModel market = null; market = ServiceProvider.Instance <ILimitTimeBuyService> .Create.Get(id); if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing) { //可能参数是诊疗项目ID market = market == null ? ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetFlaseSaleByProductId(id) : market; if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing) { //跳转到404页面 return(Json(new { Success = "false", ErrorMsg = "你所请求的限时购或者诊疗项目不存在!" })); } } if (market != null && (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing || DateTime.Parse(market.EndDate) < DateTime.Now)) { return(Json(new { Success = "true", IsValidLimitBuy = "false" })); } model.MaxSaleCount = market.LimitCountOfThePeople; model.Title = market.Title; product = ServiceProvider.Instance <IProductService> .Create.GetProduct(market.ProductId); bool hasSku = false; #region 诊疗项目SKU ProductTypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetType(product.TypeId); string colorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; string sizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; if (product.SKUInfo != null && product.SKUInfo.Count() > 0) { hasSku = true; long colorId = 0, sizeId = 0, versionId = 0; foreach (var sku in product.SKUInfo) { var specs = sku.Id.Split('_'); if (specs.Count() > 0) { if (long.TryParse(specs[1], out colorId)) { } if (colorId != 0) { if (!model.Color.Any(v => v.Value.Equals(sku.Color))) { var c = product.SKUInfo.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock); model.Color.Add(new ProductSKU { //Name = "选择颜色" , Name = "选择" + colorAlias, EnabledClass = c != 0 ? "enabled" : "disabled", //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "", SelectedClass = "", SkuId = colorId, Value = sku.Color, Img = sku.ShowPic }); } } } if (specs.Count() > 1) { if (long.TryParse(specs[2], out sizeId)) { } if (sizeId != 0) { if (!model.Size.Any(v => v.Value.Equals(sku.Size))) { var ss = product.SKUInfo.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock); model.Size.Add(new ProductSKU { //Name = "选择尺码" , Name = "选择" + sizeAlias, EnabledClass = ss != 0 ? "enabled" : "disabled", //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "", SelectedClass = "", SkuId = sizeId, Value = sku.Size }); } } } if (specs.Count() > 2) { if (long.TryParse(specs[3], out versionId)) { } if (versionId != 0) { if (!model.Version.Any(v => v.Value.Equals(sku.Version))) { var v = product.SKUInfo.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock); model.Version.Add(new ProductSKU { //Name = "选择版本" , Name = "选择" + versionAlias, EnabledClass = v != 0 ? "enabled" : "disabled", //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "", SelectedClass = "", SkuId = versionId, Value = sku.Version }); } } } } } #endregion #region 诊所 shop = ServiceProvider.Instance <IShopService> .Create.GetShop(product.ShopId); var mark = ShopServiceMark.GetShopComprehensiveMark(shop.Id); model.Shop.PackMark = mark.PackMark; model.Shop.ServiceMark = mark.ServiceMark; model.Shop.ComprehensiveMark = mark.ComprehensiveMark; var comm = ServiceProvider.Instance <ICommentService> .Create.GetCommentsByProductId(product.Id); model.Shop.Name = shop.ShopName; model.Shop.ProductMark = (comm == null || comm.Count() == 0) ? 0 : comm.Average(p => ( decimal )p.ReviewMark); model.Shop.Id = product.ShopId; model.Shop.FreeFreight = shop.FreeFreight; model.Shop.ProductNum = ServiceProvider.Instance <IProductService> .Create.GetShopOnsaleProducts(product.ShopId); var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(product.ShopId); var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault(); var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault(); var sellerDeliverySpeed = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault(); var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault(); var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault(); var sellerDeliverySpeedPeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault(); var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault(); var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault(); var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault(); var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault(); var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault(); var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault(); decimal defaultValue = 5; //宝贝与描述 if (productAndDescription != null && productAndDescriptionPeer != null) { model.Shop.ProductAndDescription = productAndDescription.CommentValue; } else { model.Shop.ProductAndDescription = defaultValue; } //诊所服务态度 if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null) { model.Shop.SellerServiceAttitude = sellerServiceAttitude.CommentValue; } else { model.Shop.SellerServiceAttitude = defaultValue; } //诊所发货速度 if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null) { model.Shop.SellerDeliverySpeed = sellerDeliverySpeed.CommentValue; } else { model.Shop.SellerDeliverySpeed = defaultValue; } if (ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id) == null) { model.Shop.VShopId = -1; } else { model.Shop.VShopId = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id).Id; } //优惠券 var result = GetCouponList(shop.Id); //取设置的优惠券 if (result != null) { var couponCount = result.Count(); model.Shop.CouponCount = couponCount; } #endregion #region 诊疗项目 var consultations = ServiceProvider.Instance <IConsultationService> .Create.GetConsultations(product.Id); double total = product.Himall_ProductComments.Count(); double niceTotal = product.Himall_ProductComments.Count(item => item.ReviewMark >= 4); bool isFavorite = false; if (CurrentUser == null) { isFavorite = false; } else { isFavorite = ServiceProvider.Instance <IProductService> .Create.IsFavorite(product.Id, CurrentUser.Id); } var limitBuy = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetLimitTimeMarketItemByProductId(product.Id); var productImage = new List <string>(); for (int i = 1; i < 6; i++) { if (File.Exists(HttpContext.Current.Server.MapPath(product.RelativePath + string.Format("/{0}.png", i)))) { productImage.Add(Core.HimallIO.GetRomoteImagePath(product.RelativePath + string.Format("/{0}.png", i))); } } model.Product = new ProductInfoModel() { ProductId = product.Id, CommentCount = product.Himall_ProductComments.Count(), Consultations = consultations.Count(), ImagePath = productImage, IsFavorite = isFavorite, MarketPrice = market.MinPrice, MinSalePrice = product.MinSalePrice, NicePercent = model.Shop.ProductMark == 0 ? 100 : ( int )((niceTotal / total) * 100), ProductName = product.ProductName, ProductSaleStatus = product.SaleStatus, AuditStatus = product.AuditStatus, ShortDescription = product.ShortDescription, ProductDescription = product.ProductDescriptionInfo.ShowMobileDescription, IsOnLimitBuy = limitBuy != null }; #endregion LogProduct(market.ProductId); //统计诊疗项目浏览量、诊所浏览人数 StatisticApplication.StatisticVisitCount(product.Id, product.ShopId); TimeSpan end = new TimeSpan(DateTime.Parse(market.EndDate).Ticks); TimeSpan start = new TimeSpan(DateTime.Now.Ticks); TimeSpan ts = end.Subtract(start); var second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds; return(Json(new { Success = "true", IsOnLimitBuy = "true", HasSku = hasSku, MaxSaleCount = market.LimitCountOfThePeople, Title = market.Title, Second = second, Product = model.Product, Shop = model.Shop, Color = model.Color, Size = model.Size, Version = model.Version, ColorAlias = colorAlias, SizeAlias = sizeAlias, VersionAlias = versionAlias })); }