//public ActionResult Detials(long id) //{ // long templateId = id; // var templateExtend = new Himall.Web.Areas.SellerAdmin.Models.FreightTemplateInfoExtend() // { // ShopID = CurrentSellerManager.ShopId // }; // var template = _iFreightTemplateService.GetFreightTemplate(templateId); // if (template.ShopID != CurrentSellerManager.ShopId) // { // throw new Core.HimallException("该运费模板不存在" + id); // } // var regionService = _iRegionService; // if (template.SourceAddress.HasValue) // { // templateExtend.SourceAddressStr = regionService.GetRegionPath(template.SourceAddress.Value); // } // templateExtend.Id = template.Id; // templateExtend.IsFree = template.IsFree; // templateExtend.Name = template.Name; // templateExtend.ShopID = template.ShopID; // templateExtend.SendTime = template.SendTime; // templateExtend.SourceAddress = template.SourceAddress; // templateExtend.ValuationMethod = template.ValuationMethod; // templateExtend.FreightAreaContent = template.Himall_FreightAreaContent.Select(e => new Himall.Web.Areas.SellerAdmin.Models.FreightAreaContentInfoExtend() // { // AreaContent = e.AreaContent, // AreaContentCN = regionService.GetRegionByName(e.AreaContent).Name, // AccumulationUnit = e.AccumulationUnit, // AccumulationUnitMoney = e.AccumulationUnitMoney, // FirstUnit = e.FirstUnit, // FirstUnitMonry = e.FirstUnitMonry, // IsDefault = e.IsDefault, // FreightTemplateId = e.FreightTemplateId, // Id = e.Id // }); // ViewBag.IsUsed = 0; // return View(templateExtend); //} public JsonResult GetFreightTemplateInfo(long templateid) { var templateInfo = FreightTemplateApplication.GetFreightTemplate(templateid, CurrentSellerManager.ShopId); return(Json(new { model = templateInfo, success = true })); }
/// <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)); }
/// <summary> /// 参与拼团 /// <para>拼团查看</para> /// </summary> /// <param name="id">团编号</param> /// <param name="aid">活动编号</param> /// <returns></returns> public ActionResult GroupDetail(long id, long aid) { FightGroupActiveModel activedata = FightGroupApplication.GetActive(aid, false); if (activedata == null) { throw new HimallException("错误的活动信息"); } activedata.InitProductImages(); FightGroupsModel groupsdata = FightGroupApplication.GetGroup(aid, id); if (groupsdata == null) { throw new HimallException("错误的拼团信息"); } if (groupsdata.BuildStatus == FightGroupBuildStatus.Opening) { return(Redirect(string.Format("/m-{0}/Member/Center/", PlatformType.ToString()))); } FightGroupGroupDetailModel model = new FightGroupGroupDetailModel(); model.ActiveData = activedata; model.GroupsData = groupsdata; model.HasJoin = false; if (CurrentUser != null) { model.HasJoin = !FightGroupApplication.CanJoinGroup(aid, id, CurrentUser.Id); } model.ShareUrl = string.Format("{0}/m-{1}/FightGroup/GroupDetail/{2}?aid={3}", CurrentUrlHelper.CurrentUrlNoPort(), "WeiXin", groupsdata.Id, groupsdata.ActiveId); model.ShareTitle = "我参加了(" + activedata.ProductName + ")的拼团"; model.ShareImage = activedata.ProductDefaultImage; if (!string.IsNullOrWhiteSpace(model.ShareImage)) { if (model.ShareImage.Substring(0, 4) != "http") { model.ShareImage = HimallIO.GetRomoteImagePath(model.ShareImage); } } int neednum = groupsdata.LimitedNumber - groupsdata.JoinedNumber; neednum = neednum < 0 ? 0 : neednum; if (neednum > 0) { model.ShareDesc = "还差" + neednum + "人即可成团"; } if (!string.IsNullOrWhiteSpace(activedata.ProductShortDescription)) { if (!string.IsNullOrWhiteSpace(model.ShareDesc)) { model.ShareDesc += ",(" + activedata.ProductShortDescription + ")"; } else { model.ShareDesc += activedata.ProductShortDescription; } } model.ActiveData.IsSaleCountOnOff = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1; //是否显示销量 model.ActiveData.SaleVolume = activedata.ActiveItems.Sum(d => d.BuyCount); //销量 model.ActiveData.FreightTemplate = FreightTemplateApplication.GetFreightTemplate(activedata.FreightTemplateId); //运费模板 model.ActiveData.FreightStr = FreightTemplateApplication.GetFreightStr(activedata.ProductId, activedata.FreightTemplate, CurrentUser); //运费或免运费 return(View(model)); }
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 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="data"></param> /// <returns></returns> private product_item_model ProductInfoMapChange(Entities.ProductInfo data) { var prodata = data; if (prodata == null) { throw new MallApiException(OpenApiErrorCode.Product_Not_Exists, "num_iid"); } product_item_model result = new product_item_model(); #region 装配信息 result.num_iid = (int)prodata.Id; result.outer_id = prodata.ProductCode; result.brand_id = (int)prodata.BrandId; result.brand_name = prodata.BrandName; result.cid = (int)prodata.CategoryId; result.type_id = (int)prodata.TypeId; var category = CategoryApplication.GetCategory(prodata.CategoryId); var desc = ProductManagerApplication.GetProductDescription(prodata.Id); if (category != null) { result.cat_name = category.Name; var type = TypeApplication.GetType(category.TypeId); if (type != null) { result.type_name = type.Name; } } result.title = prodata.ProductName.Trim(); result.list_time = prodata.AddedDate; result.modified = prodata.AddedDate; result.display_sequence = (int)prodata.DisplaySequence; result.sold_quantity = (int)prodata.SaleCounts; result.desc = desc.Description; result.wap_desc = desc.MobileDescription; result.pic_url.Add(System.IO.Path.Combine(OpenAPIHelper.HostUrl, prodata.GetImage(ImageSize.Size_350, 1))); ProductStatus ps = GetProductStatus(prodata); result.approve_status = ps.ToString(); #region 商品属性填充 var prodAttrs = ProductManagerApplication.GetProductAttributes(prodata.Id); var prodAttrids = prodAttrs.Select(d => d.AttributeId).ToList(); var prodAttrValues = _iTypeService.GetAttributeValues(prodAttrids); result.props_name = ""; if (prodAttrids.Count > 0) { List <string> propslst = new List <string>(); List <string> propsvallst = new List <string>(); foreach (var curattid in prodAttrids) { var item = prodAttrs.FirstOrDefault(d => d.AttributeId == curattid); propsvallst.Clear(); var attribute = _iTypeService.GetAttribute(item.AttributeId); var values = prodAttrValues.Where(p => p.AttributeId == curattid); foreach (var attrV in values) { if (prodAttrs.Any(p => p.ValueId == attrV.Id)) { propsvallst.Add(attrV.Value); } } propslst.Add(attribute.Name + "#cln#[" + string.Join(",", propsvallst.ToArray()) + "]"); } result.props_name = string.Join("#scln#", propslst.ToArray()); } #endregion #region 发货地区 var prolocid = FreightTemplateApplication.GetFreightTemplate(prodata.FreightTemplateId).SourceAddress; result.location = ""; var locpath = _iRegionService.GetFullName(prolocid, ","); result.location = "{'city':'#c#', 'state':'#p#'}"; if (!string.IsNullOrWhiteSpace(locpath)) { var _tmparr = locpath.Split(','); result.location = result.location.Replace("#p#", _tmparr[0]); if (_tmparr.Length > 1) { result.location = result.location.Replace("#c#", _tmparr[1]); } else { result.location = result.location.Replace("#c#", ""); } } #endregion #region SKUS Entities.TypeInfo typeInfo = _iTypeService.GetType(data.TypeId); string colorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; string sizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; if (prodata != null) { colorAlias = !string.IsNullOrWhiteSpace(prodata.ColorAlias) ? prodata.ColorAlias : colorAlias; sizeAlias = !string.IsNullOrWhiteSpace(prodata.SizeAlias) ? prodata.SizeAlias : sizeAlias; versionAlias = !string.IsNullOrWhiteSpace(prodata.VersionAlias) ? prodata.VersionAlias : versionAlias; } result.skus = new List <product_sku_model>(); var skus = ProductManagerApplication.GetSKUs(prodata.Id); foreach (var item in skus) { product_sku_model skudata = new product_sku_model(); skudata.sku_id = item.Id; skudata.outer_sku_id = item.Sku; skudata.price = item.SalePrice; skudata.quantity = (int)item.Stock; //skudata.sku_properties_name = "颜色:" + item.Color + "尺寸:" + item.Size + "版本:" + item.Version; skudata.sku_properties_name = colorAlias + ":" + item.Color + " " + sizeAlias + ":" + item.Size + " " + versionAlias + ":" + item.Version; string sku_properties_name = item.Color + " " + item.Size + " " + item.Version; if (string.IsNullOrWhiteSpace(sku_properties_name)) { skudata.sku_properties_name = ""; } if (!string.IsNullOrWhiteSpace(skudata.sku_properties_name)) { result.skus.Add(skudata); } } #endregion #endregion return(result); }