示例#1
0
        public ActionResult GroupDetail(long id, long aid)
        {
            FightGroupActiveModel model = FightGroupApplication.GetActive(aid, false, true);

            if (model == null)
            {
                throw new HimallException("错误的活动信息");
            }
            model.InitProductImages();
            FightGroupsModel group = FightGroupApplication.GetGroup(aid, id);

            if (group == null)
            {
                throw new HimallException("错误的拼团信息");
            }
            if (group.BuildStatus == FightGroupBuildStatus.Opening)
            {
                return(this.Redirect(string.Format("/m-{0}/Member/Center/", base.PlatformType.ToString())));
            }
            FightGroupGroupDetailModel model3 = new FightGroupGroupDetailModel
            {
                ActiveData = model,
                GroupsData = group,
                HasJoin    = false
            };

            if (base.CurrentUser != null)
            {
                model3.HasJoin = !FightGroupApplication.CanJoinGroup(aid, id, base.CurrentUser.Id);
            }
            model3.ShareUrl   = string.Format("{0}/m-{1}/FightGroup/GroupDetail/{2}?aid={3}", new object[] { CurrentUrlHelper.CurrentUrlNoPort(), "WeiXin", group.Id, group.ActiveId });
            model3.ShareTitle = "我参加了(" + model.ProductName + ")的拼团";
            model3.ShareImage = model.ProductDefaultImage;
            if (!string.IsNullOrWhiteSpace(model3.ShareImage) && (model3.ShareImage.Substring(0, 4) != "http"))
            {
                model3.ShareImage = HimallIO.GetRomoteImagePath(model3.ShareImage, null);
            }
            int num = group.LimitedNumber - group.JoinedNumber;

            num = (num < 0) ? 0 : num;
            if (num > 0)
            {
                model3.ShareDesc = "还差" + num + "人即可成团";
            }
            if (!string.IsNullOrWhiteSpace(model.ProductShortDescription))
            {
                if (!string.IsNullOrWhiteSpace(model3.ShareDesc))
                {
                    model3.ShareDesc = model3.ShareDesc + ",(" + model.ProductShortDescription + ")";
                }
                else
                {
                    model3.ShareDesc = model3.ShareDesc + model.ProductShortDescription;
                }
            }
            return(base.View(model3));
        }
        /// <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));
        }
        /// <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}", Request.Url.Scheme + "://" + Request.Url.Authority, "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;
                }
            }

            return(View(model));
        }