/// <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}", Request.Url.Authority, "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.HasValue)
            {
                //统计商品浏览量、店铺浏览人数
                StatisticApplication.StatisticVisitCount(model.ProductId.Value, model.ShopId);
            }

            var customerServices = CustomerServiceApplication.GetMobileCustomerService(model.ShopId);
            var meiqia           = CustomerServiceApplication.GetPreSaleByShopId(model.ShopId).FirstOrDefault(p => p.Tool == CustomerServiceInfo.ServiceTool.MeiQia);

            if (meiqia != null)
            {
                customerServices.Insert(0, meiqia);
            }
            ViewBag.CustomerServices = customerServices;

            return(View(model));
        }
Beispiel #2
0
        public ActionResult Detail(long id)
        {
            FightGroupActiveModel source = FightGroupApplication.GetActive(id, false, true);

            if (source == null)
            {
                throw new HimallException("错误的活动信息");
            }
            source.InitProductImages();
            Mapper.CreateMap <FightGroupActiveModel, FightGroupActiveDetailModel>();
            FightGroupActiveDetailModel model = Mapper.Map <FightGroupActiveDetailModel>(source);
            decimal memberDiscount            = 1;

            if (base.CurrentUser != null)
            {
                memberDiscount = base.CurrentUser.MemberDiscount;
            }
            ((dynamic)base.ViewBag).Discount = memberDiscount;
            Shop shop = ShopApplication.GetShop(model.ShopId, false);

            ((dynamic)base.ViewBag).IsSelf = shop.IsSelf;
            model.ShareUrl   = string.Format("{0}/m-{1}/FightGroup/Detail/{2}", CurrentUrlHelper.CurrentUrlNoPort(), "WeiXin", source.Id);
            model.ShareTitle = (source.ActiveStatus == FightGroupActiveStatus.WillStart) ? "限时限量火拼 即将开始" : "限时限量火拼 正在进行";
            model.ShareImage = source.ProductDefaultImage;
            if (!string.IsNullOrWhiteSpace(model.ShareImage) && (model.ShareImage.Substring(0, 4) != "http"))
            {
                model.ShareImage = HimallIO.GetRomoteImagePath(model.ShareImage, null);
            }
            model.ShareDesc = source.ProductName;
            if (!string.IsNullOrWhiteSpace(source.ProductShortDescription))
            {
                model.ShareDesc = model.ShareDesc + ",(" + source.ProductShortDescription + ")";
            }
            if (model.ProductId.HasValue)
            {
                StatisticApplication.StatisticVisitCount(model.ProductId.Value, model.ShopId);
            }
            List <CustomerService> mobileCustomerService = CustomerServiceApplication.GetMobileCustomerService(model.ShopId);
            CustomerService        item = CustomerServiceApplication.GetPreSaleByShopId(model.ShopId).FirstOrDefault <CustomerService>(p => p.Tool == CustomerServiceInfo.ServiceTool.MeiQia);

            if (item != null)
            {
                mobileCustomerService.Insert(0, item);
            }
            ((dynamic)base.ViewBag).CustomerServices = mobileCustomerService;
            return(base.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));
        }
Beispiel #4
0
        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 }));
            }
        }