/// <summary> /// 获取拼团项用于新增活动 /// </summary> /// <param name="productId">商品编号</param> /// <returns></returns> public static FightGroupGetSkuListModel GetNewActiveItems(long productId) { FightGroupGetSkuListModel result = new FightGroupGetSkuListModel(); var pro = GetService <IProductService>().GetProduct(productId); result.ProductImg = MallIO.GetProductSizeImage(pro.RelativePath, 1, (int)Mall.CommonModel.ImageSize.Size_150); result.skulist = new List <FightGroupActiveItemModel>(); var price = 0m; if (pro.IsOpenLadder) { var ladder = ProductManagerApplication.GetLadderPriceByProductIds(productId); if (ladder.Any()) { price = ladder.OrderBy(m => m.MinBath).FirstOrDefault().Price; } } var skus = ProductManagerApplication.GetSKUs(pro.Id); foreach (var item in skus) { FightGroupActiveItemModel data = new FightGroupActiveItemModel(); data.ProductId = productId; data.SkuId = item.Id; data.SkuName = item.Color + " " + item.Size + " " + item.Version; data.ProductPrice = price > 0 ? price : item.SalePrice; data.ProductStock = item.Stock; data.ActivePrice = data.ProductPrice; data.ActiveStock = 0; //活动库存置空 result.skulist.Add(data); } return(result); }
/// <summary> /// 获取拼团项用于新增活动 /// </summary> /// <param name="productId">商品编号</param> /// <returns></returns> public static FightGroupGetSkuListModel GetNewActiveItems(long productId) { FightGroupGetSkuListModel result = new FightGroupGetSkuListModel(); var pro = _iProductService.GetProduct(productId); result.ProductImg = HimallIO.GetProductSizeImage(pro.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_150); result.skulist = new List <FightGroupActiveItemModel>(); foreach (var item in pro.SKUInfo) { FightGroupActiveItemModel _data = new FightGroupActiveItemModel(); _data.ProductId = productId; _data.SkuId = item.Id; _data.SkuName = item.Color + " " + item.Size + " " + item.Version; _data.ProductPrice = item.SalePrice; _data.ProductStock = item.Stock; _data.ActivePrice = _data.ProductPrice; _data.ActiveStock = 0; //活动库存置空 result.skulist.Add(_data); } return(result); }
public object GetActiveById(int id) { try { //CheckUserLogin(); FightGroupActiveModel data = FightGroupApplication.XcxGetActive(id, false); if (data == null) { throw new HimallException("错误的活动信息"); } //data.InitProductImages(); FightGroupActiveImgInfo imgInfo = FightGroupApplication.XcxGetActiveImg(id); AutoMapper.Mapper.CreateMap <FightGroupActiveModel, FightGroupActiveDetailModel>(); FightGroupActiveDetailModel model = AutoMapper.Mapper.Map <FightGroupActiveDetailModel>(data); model.ShareTitle = data.ActiveStatus == FightGroupActiveStatus.WillStart ? "限时限量火拼 即将开始" : "限时限量火拼 正在进行"; if (imgInfo != null) { model.ProductDefaultImage = imgInfo.ProductDefaultImage; model.ProductImages = imgInfo.ProductImages.Split(',').ToList(); model.ShowMobileDescription = imgInfo.ShowMobileDescription; model.ShareImage = imgInfo.ProductDefaultImage; model.IconUrl = imgInfo.ProductDefaultImage; } model.GroupNotice = data.GroupNotice; model.ShareDesc = data.ProductName; model.ReturnMoney = data.ReturnMoney; /*if (!string.IsNullOrWhiteSpace(model.ShareImage)) * { * if (model.ShareImage.Substring(0, 4) != "http") * { * model.ShareImage = HimallIO.GetRomoteImagePath(model.ShareImage); * } * }*/ /*if (model.IconUrl.Substring(0, 4) != "http") * { * model.IconUrl = HimallIO.GetRomoteImagePath(model.IconUrl); * } * if (model.ProductImgPath.Substring(0, 4) != "http") * { * model.ProductImgPath = HimallIO.GetRomoteImagePath(model.ProductImgPath); * } * if (model.ProductDefaultImage.Substring(0, 4) != "http") * { * model.ProductDefaultImage = HimallIO.GetRomoteImagePath(model.ProductDefaultImage); * } * for (int i = 0; i < model.ProductImages.Count; i++) * { * model.ProductImages[i] = HimallIO.GetRomoteImagePath(model.ProductImages[i]); * }*/ /*if (!string.IsNullOrWhiteSpace(data.ProductShortDescription)) * { * model.ShareDesc += ",(" + data.ProductShortDescription + ")"; * } * var ProductDescription = ServiceHelper.Create<IProductService>().GetProductDescription(model.ProductId.Value); * if (ProductDescription == null) * { * throw new Himall.Core.HimallException("错误的商品编号"); * } * model.ShowMobileDescription = ProductDescription.ShowMobileDescription.Replace("src=\"/Storage/", * "src=\"" + Core.HimallIO.GetRomoteImagePath("/Storage/")); * model.GroupNotice = "1、活动结束后将从拼单成功的所有订单中,随机选取1名使用者赠送。\n2、一等奖为iPhoneX,二等奖为88元优惠券。";//TODO 功能待实现data.GroupNotice;*/ /*if (model.ProductId.HasValue) * { * //统计商品浏览量、店铺浏览人数 * StatisticApplication.StatisticVisitCount(model.ProductId.Value, model.ShopId); * } * IProductService _iProductService = ServiceProvider.Instance<IProductService>.Create; * bool isSub = _iProductService.IsFavorite((long)model.ProductId, CurrentUserId); * model.IsSubscribe = isSub ? 1 : 0;*/ //model.IsVirtualProduct = 1; List <FightGroupActiveItemInfo> sourceList = FightGroupApplication.GetActiveItemsInfos(model.Id); List <FightGroupActiveItemModel> targetList = new List <FightGroupActiveItemModel>(); foreach (var itemInfo in sourceList) { FightGroupActiveItemModel m = new FightGroupActiveItemModel(); m.Id = itemInfo.Id; m.ActiveId = itemInfo.ActiveId.Value; m.ActivePrice = itemInfo.ActivePrice; m.ActiveStock = itemInfo.ActiveStock; m.BuyCount = itemInfo.BuyCount; m.Color = itemInfo.Color; m.ProductCostPrice = itemInfo.ProductCostPrice; m.ProductId = itemInfo.ProductId.Value; m.ProductPrice = itemInfo.ProductPrice; m.ProductStock = itemInfo.ProductStock; m.ShowPic = itemInfo.ShowPic; m.Size = itemInfo.Size; m.SkuName = itemInfo.SkuName; m.SkuId = itemInfo.SkuId; m.Version = itemInfo.Version; targetList.Add(m); } model.ActiveItems = targetList; return(Json(new { Status = "OK", FightGroupDetail = model })); } catch (Exception ex) { return(Json(new { Status = "Error", Msg = ex.Message })); } }
public ActionResult ShowSkuInfo(FightGroupActiveModel data) { if (data == null) { throw new HimallException("错误的活动信息"); } ProductShowSkuInfoModel model = new ProductShowSkuInfoModel { MinSalePrice = data.MiniGroupPrice, ProductImagePath = data.ProductImgPath }; ProductTypeInfo typeByProductId = this._iTypeService.GetTypeByProductId(data.ProductId.Value); string str = ((typeByProductId == null) || string.IsNullOrEmpty(typeByProductId.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeByProductId.ColorAlias; string str2 = ((typeByProductId == null) || string.IsNullOrEmpty(typeByProductId.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeByProductId.SizeAlias; string str3 = ((typeByProductId == null) || string.IsNullOrEmpty(typeByProductId.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeByProductId.VersionAlias; model.ColorAlias = str; model.SizeAlias = str2; model.VersionAlias = str3; if ((data.ActiveItems != null) && (data.ActiveItems.Count <FightGroupActiveItemModel>() > 0)) { long result = 0L; long num2 = 0L; long num3 = 0L; using (List <FightGroupActiveItemModel> .Enumerator enumerator = data.ActiveItems.GetEnumerator()) { while (enumerator.MoveNext()) { Func <ProductSKU, bool> predicate = null; Func <FightGroupActiveItemModel, bool> func2 = null; Func <ProductSKU, bool> func3 = null; Func <FightGroupActiveItemModel, bool> func4 = null; Func <ProductSKU, bool> func5 = null; Func <FightGroupActiveItemModel, bool> func6 = null; FightGroupActiveItemModel sku = enumerator.Current; string[] source = sku.SkuId.Split(new char[] { '_' }); if (source.Count <string>() > 0) { if (long.TryParse(source[1], out result)) { } if (result != 0L) { if (predicate == null) { predicate = v => v.Value.Equals(sku.Color); } if (!model.Color.Any <ProductSKU>(predicate)) { if (func2 == null) { func2 = s => s.Color.Equals(sku.Color); } long? nullable = data.ActiveItems.Where <FightGroupActiveItemModel>(func2).Sum <FightGroupActiveItemModel>((Func <FightGroupActiveItemModel, long?>)(s => s.ActiveStock)); ProductSKU item = new ProductSKU { Name = "选择" + str, EnabledClass = (nullable != 0L) ? "enabled" : "disabled", SelectedClass = "", SkuId = result, Value = sku.Color, Img = sku.ShowPic }; model.Color.Add(item); } } } if (source.Count <string>() > 1) { if (long.TryParse(source[2], out num2)) { } if (num2 != 0L) { if (func3 == null) { func3 = v => v.Value.Equals(sku.Size); } if (!model.Size.Any <ProductSKU>(func3)) { if (func4 == null) { func4 = s => s.Size.Equals(sku.Size); } long? nullable2 = data.ActiveItems.Where <FightGroupActiveItemModel>(func4).Sum <FightGroupActiveItemModel>((Func <FightGroupActiveItemModel, long?>)(s1 => s1.ActiveStock)); ProductSKU tsku2 = new ProductSKU { Name = "选择" + str2, EnabledClass = (nullable2 != 0L) ? "enabled" : "disabled", SelectedClass = "", SkuId = num2, Value = sku.Size }; model.Size.Add(tsku2); } } } if (source.Count <string>() > 2) { if (long.TryParse(source[3], out num3)) { } if (num3 != 0L) { if (func5 == null) { func5 = v => v.Value.Equals(sku.Version); } if (!model.Version.Any <ProductSKU>(func5)) { if (func6 == null) { func6 = s => s.Version.Equals(sku.Version); } long? nullable3 = data.ActiveItems.Where <FightGroupActiveItemModel>(func6).Sum <FightGroupActiveItemModel>((Func <FightGroupActiveItemModel, long?>)(s => s.ActiveStock)); ProductSKU tsku3 = new ProductSKU { Name = "选择" + str3, EnabledClass = (nullable3 != 0L) ? "enabled" : "disabled", SelectedClass = "", SkuId = num3, Value = sku.Version }; model.Version.Add(tsku3); } } } } } } return(base.View(model)); }