/// <summary> /// 商品 /// </summary> public ActionResult Product() { //商品id int pid = GetRouteInt("pid"); if (pid == 0) { pid = WebHelper.GetQueryInt("pid"); } //判断商品是否存在 ProductInfo productInfo = Products.GetProductById(pid); if (productInfo == null) { return(PromptView("/", "你访问的商品不存在")); } //店铺信息 StoreInfo storeInfo = Stores.GetStoreById(productInfo.StoreId); if (storeInfo.State != (int)StoreState.Open) { return(PromptView("/", "你访问的商品不存在")); } //商品存在时 ProductModel model = new ProductModel(); //商品id model.Pid = pid; //商品信息 model.ProductInfo = productInfo; //商品分类 model.CategoryInfo = Categories.GetCategoryById(productInfo.CateId); //商品品牌 model.BrandInfo = Brands.GetBrandById(productInfo.BrandId); //店铺信息 model.StoreInfo = storeInfo; //店长信息 model.StoreKeeperInfo = Stores.GetStoreKeeperById(storeInfo.StoreId); //店铺区域 model.StoreRegion = Regions.GetRegionById(storeInfo.RegionId); //店铺等级信息 model.StoreRankInfo = StoreRanks.GetStoreRankById(storeInfo.StoreRid); //商品图片列表 model.ProductImageList = Products.GetProductImageList(pid); //扩展商品属性列表 model.ExtProductAttributeList = Products.GetExtProductAttributeList(pid); //商品SKU列表 model.ProductSKUList = Products.GetProductSKUListBySKUGid(productInfo.SKUGid); //商品库存数量 model.StockNumber = Products.GetProductStockNumberByPid(pid); //单品促销 model.SinglePromotionInfo = Promotions.GetSinglePromotionByPidAndTime(pid, DateTime.Now); //买送促销活动列表 model.BuySendPromotionList = Promotions.GetBuySendPromotionList(productInfo.StoreId, pid, DateTime.Now); //赠品促销活动 model.GiftPromotionInfo = Promotions.GetGiftPromotionByPidAndTime(pid, DateTime.Now); //赠品列表 if (model.GiftPromotionInfo != null) { model.ExtGiftList = Promotions.GetExtGiftList(model.GiftPromotionInfo.PmId); } //套装商品列表 model.SuitProductList = Promotions.GetProductAllSuitPromotion(pid, DateTime.Now); //满赠促销活动 model.FullSendPromotionInfo = Promotions.GetFullSendPromotionByStoreIdAndPidAndTime(productInfo.StoreId, pid, DateTime.Now); //满减促销活动 model.FullCutPromotionInfo = Promotions.GetFullCutPromotionByStoreIdAndPidAndTime(productInfo.StoreId, pid, DateTime.Now); //广告语 model.Slogan = model.SinglePromotionInfo == null ? "" : model.SinglePromotionInfo.Slogan; //商品促销信息 model.PromotionMsg = Promotions.GeneratePromotionMsg(model.SinglePromotionInfo, model.BuySendPromotionList, model.FullSendPromotionInfo, model.FullCutPromotionInfo); //商品折扣价格 model.DiscountPrice = Promotions.ComputeDiscountPrice(model.ProductInfo.ShopPrice, model.SinglePromotionInfo); //关联商品列表 model.RelateProductList = Products.GetRelateProductList(pid); //用户浏览历史 model.UserBrowseHistory = BrowseHistories.GetUserBrowseHistory(WorkContext.Uid, pid); //商品咨询类型列表 model.ProductConsultTypeList = ProductConsults.GetProductConsultTypeList(); //更新浏览历史 if (WorkContext.Uid > 0) { Asyn.UpdateBrowseHistory(WorkContext.Uid, pid); } //更新商品统计 Asyn.UpdateProductStat(pid, WorkContext.RegionId); return(View(model)); }
/// <summary> /// 商品 /// </summary> public ActionResult Product() { //商品id int pid = GetRouteInt("pid"); if (pid == 0) { pid = WebHelper.GetQueryInt("pid"); } //判断商品是否存在 PartProductInfo productInfo = Products.GetPartProductById(pid); if (productInfo == null) { return(PromptView(Url.Action("index", "home"), "你访问的商品不存在")); } //商品存在时 ProductModel model = new ProductModel(); //商品id model.Pid = pid; //商品信息 model.ProductInfo = productInfo; //商品分类 model.CategoryInfo = Categories.GetCategoryById(productInfo.CateId); //商品品牌 model.BrandInfo = Brands.GetBrandById(productInfo.BrandId); //商品图片列表 model.ProductImageList = Products.GetProductImageList(pid); //商品SKU列表 model.ProductSKUList = Products.GetProductSKUListBySKUGid(productInfo.SKUGid); //商品库存数量 model.StockNumber = Products.GetProductStockNumberByPid(pid); //单品促销 model.SinglePromotionInfo = Promotions.GetSinglePromotionByPidAndTime(pid, DateTime.Now); //买送促销活动列表 model.BuySendPromotionList = Promotions.GetBuySendPromotionList(pid, DateTime.Now); //赠品促销活动 model.GiftPromotionInfo = Promotions.GetGiftPromotionByPidAndTime(pid, DateTime.Now); //赠品列表 if (model.GiftPromotionInfo != null) { model.ExtGiftList = Promotions.GetExtGiftList(model.GiftPromotionInfo.PmId); } //套装商品列表 model.SuitProductList = Promotions.GetProductAllSuitPromotion(pid, DateTime.Now); //满赠促销活动 model.FullSendPromotionInfo = Promotions.GetFullSendPromotionByPidAndTime(pid, DateTime.Now); //满减促销活动 model.FullCutPromotionInfo = Promotions.GetFullCutPromotionByPidAndTime(pid, DateTime.Now); //广告语 model.Slogan = model.SinglePromotionInfo == null ? "" : model.SinglePromotionInfo.Slogan; //商品促销信息 model.PromotionMsg = Promotions.GeneratePromotionMsg(model.SinglePromotionInfo, model.BuySendPromotionList, model.FullSendPromotionInfo, model.FullCutPromotionInfo); //商品折扣价格 model.DiscountPrice = Promotions.ComputeDiscountPrice(model.ProductInfo.ShopPrice, model.SinglePromotionInfo); //关联商品列表 model.RelateProductList = Products.GetRelateProductList(pid); //更新浏览历史 if (WorkContext.Uid > 0) { Asyn.UpdateBrowseHistory(WorkContext.Uid, pid); } //更新商品统计 Asyn.UpdateProductStat(pid, WorkContext.RegionId); return(View(model)); }