Ejemplo n.º 1
0
        /// <summary>
        /// 获取拼团活动
        /// </summary>
        /// <param name="id"></param>
        /// <param name="needGetProductCommentNumber">是否需要同步获取商品的评价数量</param>
        /// <param name="isLoadItems">是否加载节点信息</param>
        /// <returns></returns>
        public static FightGroupActiveModel XcxGetActive(long id, bool needGetProductCommentNumber = false, bool isLoadItems = true)
        {
            var data = _iFightGroupService.GetActive(id, needGetProductCommentNumber, isLoadItems);

            Mapper.CreateMap <FightGroupActiveInfo, FightGroupActiveModel>();
            //规格映射
            Mapper.CreateMap <FightGroupActiveItemInfo, FightGroupActiveItemModel>();
            Mapper.CreateMap <Model.ComboDetail, DTO.ComboDetail>();
            FightGroupActiveModel result = Mapper.Map <FightGroupActiveInfo, FightGroupActiveModel>(data);

            result.MiniSalePrice = data.MiniSalePrice;
            if (result != null)
            {
                //商品图片地址修正
                result.ProductDefaultImage = HimallIO.GetProductSizeImage(data.ProductImgPath, 1, (int)ImageSize.Size_350);
                if (!string.IsNullOrWhiteSpace(result.IconUrl))
                {
                    result.IconUrl = Himall.Core.HimallIO.GetImagePath(result.IconUrl);
                }
                if (result.ActiveItems != null)
                {
                    foreach (var item in result.ActiveItems)
                    {
                        if (!string.IsNullOrWhiteSpace(item.ShowPic))
                        {
                            item.ShowPic = HimallIO.GetImagePath(item.ShowPic);
                        }
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        public ActionResult ShowDetail(FightGroupActiveModel data, int hst = 1, DateTime?etime = new DateTime?())
        {
            FightGroupShowDetailModel model = new FightGroupShowDetailModel();

            if (data == null)
            {
                throw new HimallException("错误的活动信息");
            }
            model.ActiveData          = data;
            model.LimitedHourShowType = hst;
            if (etime.HasValue)
            {
                model.EndBuildGroupTime = etime.Value;
            }
            model.ProductMiniPriceByUser = model.ActiveData.MiniSalePrice;
            if (ShopApplication.GetShop(data.ShopId, false).IsSelf)
            {
                decimal memberDiscount = 1M;
                if (base.CurrentUser != null)
                {
                    memberDiscount = base.CurrentUser.MemberDiscount;
                }
                model.ProductMiniPriceByUser *= memberDiscount;
            }
            return(base.View(model));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取拼团活动
        /// </summary>
        /// <param name="id"></param>
        /// <param name="needGetProductCommentNumber">是否需要同步获取商品的评价数量</param>
        /// <param name="isLoadItems">是否加载节点信息</param>
        /// <returns></returns>
        public static FightGroupActiveModel GetActive(long id, bool needGetProductCommentNumber = false, bool isLoadItems = true)
        {
            var data = Service.GetActive(id, needGetProductCommentNumber, isLoadItems);

            Mapper.CreateMap <FightGroupActiveInfo, FightGroupActiveModel>();
            //规格映射
            Mapper.CreateMap <FightGroupActiveItemInfo, FightGroupActiveItemModel>();
            FightGroupActiveModel result = Mapper.Map <Entities.FightGroupActiveInfo, FightGroupActiveModel>(data);

            if (result != null)
            {
                //商品图片地址修正
                result.ProductDefaultImage = HimallIO.GetProductSizeImage(data.ProductImgPath, 1, (int)ImageSize.Size_350);
                if (!string.IsNullOrWhiteSpace(result.IconUrl))
                {
                    result.IconUrl = Himall.Core.HimallIO.GetImagePath(result.IconUrl);
                }
                if (result.ActiveItems != null)
                {
                    foreach (var item in result.ActiveItems)
                    {
                        if (!string.IsNullOrWhiteSpace(item.ShowPic))
                        {
                            item.ShowPic = HimallIO.GetImagePath(item.ShowPic);
                        }
                    }
                }
                //商品主图视频地址修正
                if (!string.IsNullOrWhiteSpace(data.VideoPath))
                {
                    result.VideoPath = Himall.Core.HimallIO.GetRomoteImagePath(data.VideoPath);
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        public ActionResult ShowDetail(FightGroupActiveModel data, int hst = 1, DateTime?etime = null)
        {
            FightGroupShowDetailModel model = new FightGroupShowDetailModel();

            if (data == null)
            {
                throw new HimallException("错误的活动信息");
            }
            //data.InitProductImages();
            model.ActiveData          = data;
            model.LimitedHourShowType = hst;
            if (etime.HasValue)
            {
                model.EndBuildGroupTime = etime.Value;
            }
            model.ProductMiniPriceByUser = model.ActiveData.MiniSalePrice;
            var shopInfo = ShopApplication.GetShop(data.ShopId);

            if (shopInfo.IsSelf)
            {
                decimal discount = 1M;
                if (CurrentUser != null)
                {
                    discount = CurrentUser.MemberDiscount;
                }
                model.ProductMiniPriceByUser = model.ProductMiniPriceByUser * discount;
            }
            return(View(model));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取拼团活动
        /// </summary>
        /// <param name="id"></param>
        /// <param name="needGetProductCommentNumber">是否需要同步获取商品的评价数量</param>
        /// <param name="isLoadItems">是否加载节点信息</param>
        /// <returns></returns>
        public static FightGroupActiveModel GetActive(long id, bool needGetProductCommentNumber = false, bool isLoadItems = true)
        {
            FightGroupActiveInfo source = _iFightGroupService.GetActive(id, needGetProductCommentNumber, isLoadItems, true);

            Mapper.CreateMap <FightGroupActiveInfo, FightGroupActiveModel>();
            Mapper.CreateMap <FightGroupActiveItemInfo, FightGroupActiveItemModel>();
            FightGroupActiveModel model = Mapper.Map <FightGroupActiveInfo, FightGroupActiveModel>(source);

            if (model != null)
            {
                model.ProductDefaultImage = HimallIO.GetProductSizeImage(source.ProductImgPath, 1, 350);
                if (!string.IsNullOrWhiteSpace(model.IconUrl))
                {
                    model.IconUrl = HimallIO.GetImagePath(model.IconUrl, null);
                }
                if (model.ActiveItems == null)
                {
                    return(model);
                }
                foreach (FightGroupActiveItemModel model2 in model.ActiveItems)
                {
                    if (!string.IsNullOrWhiteSpace(model2.ShowPic))
                    {
                        model2.ShowPic = HimallIO.GetImagePath(model2.ShowPic, null);
                    }
                }
            }
            return(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}", 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));
        }
Ejemplo n.º 7
0
        public JsonResult EditActive(FightGroupActiveModel model)
        {
            var result = new Result {
                success = false, msg = "未知错误", status = -1
            };
            FightGroupActiveModel data = FightGroupApplication.GetActive(model.Id);

            if (data == null)
            {
                throw new MallException("错误的活动编号");
            }
            if (model.EndTime < DateTime.Now)
            {
                throw new MallException("错误的结束时间");
            }
            if (model.EndTime < model.StartTime)
            {
                throw new MallException("错误的结束时间");
            }
            var market = MarketApplication.GetMarketService(CurrentSellerManager.ShopId, MarketType.FightGroup);

            if (market != null)
            {
                var endtime = MarketApplication.GetServiceEndTime(market.Id);
                var newEnd  = DateTime.Parse(endtime.ToString("yyyy-MM-dd") + " 23:59:59");
                if (newEnd < model.EndTime.Date)
                {
                    throw new MallException(string.Format("活动结束时间不得超过服务到期时间,<br/>您的服务到期时间为{0}", newEnd.ToString("yyyy-MM-dd HH:mm:ss")));
                }
            }
            else
            {
                throw new MallException("您没有订购此服务");
            }
            if (ModelState.IsValid)
            {
                TryUpdateModelAsync(data);

                model = data;
                //数据有效性验证
                model.CheckValidation();

                data.IconUrl = SaveActiveIcon(data.IconUrl);


                FightGroupApplication.UpdateActive(data);
                ProductManagerApplication.SaveCaculateMinPrice(model.ProductId, CurrentShop.Id);
                result = new Result {
                    success = true, msg = "操作成功", status = 1
                };
            }
            else
            {
                result = new Result {
                    success = false, msg = "数据异常,请检查数据有效性", status = -1
                };
            }
            return(Json(result));
        }
Ejemplo n.º 8
0
        public object EditActive(FightGroupActiveModel model)
        {
            var result = new Result {
                success = false, msg = "未知错误", status = -1
            };
            FightGroupActiveModel data = FightGroupApplication.GetActive(model.Id);

            if (data == null)
            {
                throw new HimallException("错误的活动编号");
            }
            if (model.EndTime < DateTime.Now)
            {
                throw new HimallException("错误的结束时间");
            }
            if (model.EndTime < model.StartTime)
            {
                throw new HimallException("错误的结束时间");
            }
            try
            {
                //数据有效性验证
                //model.CheckValidation();
                data.ProductName             = model.ProductName;
                data.ProductShortDescription = model.ProductShortDescription;
                data.ProductDefaultImage     = model.ProductDefaultImage;
                data.ProductImages           = model.ProductImages;
                data.ShowMobileDescription   = model.ShowMobileDescription;
                data.ActiveItems             = model.ActiveItems;
                data.OpenGroupReward         = model.OpenGroupReward;
                data.InvitationReward        = model.InvitationReward;
                data.LimitQuantity           = model.LimitQuantity;
                data.LimitedNumber           = model.LimitedNumber;
                data.MiniSalePrice           = model.MiniSalePrice;
                data.StartTime   = model.StartTime;
                data.EndTime     = model.EndTime;
                data.IsCombo     = model.IsCombo;
                data.Seconds     = model.Seconds;
                data.LimitedHour = model.LimitedHour;
                data.GroupNotice = model.GroupNotice;
                data.IconUrl     = model.ProductDefaultImage;
                //订单有效日期,使用时间是什么鬼
                data.OrderDate   = model.OrderDate;
                data.UseDate     = model.UseDate;
                data.PayCode     = model.PayCode;
                data.ReturnMoney = model.ReturnMoney;
                FightGroupApplication.UpdateActive(data);
                result = new Result {
                    success = true, msg = "操作成功", status = 1
                };
            }
            catch (Exception ex)
            {
                result = new Result {
                    success = false, msg = ex.Message, status = -1
                };
            }
            return(Json(result));
        }
        /// <summary>
        /// 新增拼团活动
        /// </summary>
        /// <param name="data"></param>
        public static void AddActive(FightGroupActiveModel data)
        {
            Mapper.CreateMap <FightGroupActiveModel, FightGroupActiveInfo>();
            Mapper.CreateMap <FightGroupActiveItemModel, FightGroupActiveItemInfo>();
            var model = Mapper.Map <FightGroupActiveModel, FightGroupActiveInfo>(data);

            _iFightGroupService.AddActive(model);
        }
Ejemplo n.º 10
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));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 新增拼团活动
        /// </summary>
        /// <param name="data"></param>
        public static void AddActive(FightGroupActiveModel data)
        {
            Mapper.CreateMap <FightGroupActiveModel, FightGroupActiveInfo>();
            Mapper.CreateMap <FightGroupActiveItemModel, FightGroupActiveItemInfo>();
            var model = Mapper.Map <FightGroupActiveModel, FightGroupActiveInfo>(data);

            Service.AddActive(model);
            Cache.Remove(CacheKeyCollection.CACHE_FIGHTGROUP);
        }
 /// <summary>
 /// 修改拼团活动
 /// </summary>
 /// <param name="data"></param>
 public static void UpdateActive(FightGroupActiveModel data)
 {
     #region 更新活动
     Mapper.CreateMap <FightGroupActiveModel, FightGroupActiveInfo>();
     Mapper.CreateMap <FightGroupActiveItemModel, FightGroupActiveItemInfo>();
     var model = Mapper.Map <FightGroupActiveModel, FightGroupActiveInfo>(data);
     _iFightGroupService.UpdateActive(model);
     #endregion
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 新增团购活动
        /// </summary>
        /// <returns></returns>
        public object AddActive(FightGroupActiveModel model)
        {
            var result = new Result {
                success = false, msg = "未知错误", status = -1
            };
            FightGroupActiveModel data = new FightGroupActiveModel();

            if (model.EndTime.Date < DateTime.Now.Date)
            {
                throw new HimallException("错误的结束时间");
            }
            if (model.EndTime.Date < model.StartTime.Date)
            {
                throw new HimallException("错误的结束时间");
            }
            //数据有效性验证
            //model.CheckValidation();

            /*var skudata = FightGroupApplication.GetNewActiveItems(model.ProductId.Value).skulist;
             * foreach (var item in model.ActiveItems)
             * {
             *  var cursku = skudata.FirstOrDefault(d => d.SkuId == item.SkuId);
             *  if (cursku != null)
             *  {
             *      if (item.ActiveStock > cursku.ProductStock)
             *      {
             *          throw new HimallException(item.SkuId + "错误的活动库存");
             *      }
             *  }
             *  else
             *  {
             *      model.ActiveItems.Remove(item);
             *  }
             * }*/

            try
            {
                //model.ShopId = CurrentUserId;
                //model.ShopId = 1;
                model.LimitQuantity = 1;
                model.Seconds       = 86400;
                model.AddTime       = DateTime.Now;
                model.IconUrl       = model.ProductDefaultImage;
                FightGroupApplication.AddActive(model);
                result = new Result {
                    success = true, msg = "操作成功", status = 1
                };
            }
            catch (Exception ex)
            {
                result = new Result {
                    success = false, msg = ex.Message, status = -1
                };
            }
            return(Json(result));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 查看活动
        /// </summary>
        /// <param name="id">活动编号</param>
        /// <returns></returns>
        public ActionResult ViewActive(long id)
        {
            FightGroupActiveModel model = FightGroupApplication.GetActive(id);

            if (model == null)
            {
                throw new HimallException("错误的活动编号");
            }
            return(View(model));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 添加拼团活动
        /// </summary>
        /// <returns></returns>
        public ActionResult AddActive()
        {
            FightGroupActiveModel model = new FightGroupActiveModel();

            model.ShopId    = CurShopId;
            model.StartTime = DateTime.Now;
            model.EndTime   = DateTime.Now.AddMonths(1);

            return(View(model));
        }
        /// <summary>
        /// 我的拼团详情
        /// </summary>
        /// <param name="id"></param>
        /// <param name="aid"></param>
        /// <returns></returns>
        public ActionResult GroupDetail(long id, long aid)
        {
            FightGroupActiveModel gpact = FightGroupApplication.GetActive(aid, false);

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

            if (groupsdata == null)
            {
                throw new HimallException("错误的拼团信息");
            }
            if (groupsdata.BuildStatus == FightGroupBuildStatus.Opening)
            {
                //throw new HimallException("开团未成功,等待团长付款中");
                return(Redirect(string.Format("/m-{0}/Member/Center/", PlatformType.ToString())));
            }
            MyFightGroupDetailModel model = new MyFightGroupDetailModel();

            model.ActiveData = gpact;
            model.GroupsData = groupsdata;

            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 = "我参加了(" + groupsdata.ProductName + ")的拼团";
            model.ShareImage = gpact.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(gpact.ProductShortDescription))
            {
                if (!string.IsNullOrWhiteSpace(model.ShareDesc))
                {
                    model.ShareDesc += ",(" + gpact.ProductShortDescription + ")";
                }
                else
                {
                    model.ShareDesc += gpact.ProductShortDescription;
                }
            }
            return(View(model));
        }
Ejemplo n.º 17
0
 /// <summary>
 /// 修改拼团活动
 /// </summary>
 /// <param name="data"></param>
 public static void UpdateActive(FightGroupActiveModel data)
 {
     #region 更新活动
     Mapper.CreateMap <FightGroupActiveModel, FightGroupActiveInfo>();
     Mapper.CreateMap <FightGroupActiveItemModel, FightGroupActiveItemInfo>();
     Mapper.CreateMap <DTO.ComboDetail, Model.ComboDetail>();
     var model = Mapper.Map <FightGroupActiveModel, FightGroupActiveInfo>(data);
     _iFightGroupService.UpdateActive(model);
     Cache.Remove(CacheKeyCollection.CACHE_FIGHTGROUP);
     #endregion
 }
Ejemplo n.º 18
0
        /// <summary>
        /// 使用商品编号获取正在进行的拼团活动
        /// </summary>
        /// <param name="productId"></param>
        /// <returns></returns>
        public static FightGroupActiveModel GetActiveAndItemsByProductId(long productId)
        {
            long actid = Service.GetActiveIdByProductId(productId);
            FightGroupActiveModel result = null;

            if (actid > 0)
            {
                result = GetActive(actid, false, true);
            }
            return(result);
        }
Ejemplo n.º 19
0
        public ActionResult GroupOrderOk(long orderid)
        {
            FightGroupOrderOkModel model = new FightGroupOrderOkModel();
            FightGroupOrderModel   order = FightGroupApplication.GetOrder(orderid);

            if (order == null)
            {
                throw new HimallException("错误的拼团预约单信息");
            }
            FightGroupsModel group = FightGroupApplication.GetGroup(order.ActiveId, order.GroupId);

            if (group == null)
            {
                throw new HimallException("错误的拼团信息");
            }
            if (group.BuildStatus == FightGroupBuildStatus.Opening)
            {
                return(this.Redirect(string.Format("/m-{0}/Member/Center/", base.PlatformType.ToString())));
            }
            if (group.BuildStatus == FightGroupBuildStatus.Failed)
            {
            }
            FightGroupActiveModel model4 = FightGroupApplication.GetActive(group.ActiveId, false, true);

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

            num = (num < 0) ? 0 : num;
            if (num > 0)
            {
                model.ShareDesc = "还差" + num + "人即可成团";
            }
            if (!string.IsNullOrWhiteSpace(model4.ProductShortDescription))
            {
                if (!string.IsNullOrWhiteSpace(model.ShareDesc))
                {
                    model.ShareDesc = model.ShareDesc + ",(" + model4.ProductShortDescription + ")";
                }
                else
                {
                    model.ShareDesc = model.ShareDesc + model4.ProductShortDescription;
                }
            }
            return(base.View(model));
        }
Ejemplo n.º 20
0
        public ActionResult ShowActionHead(FightGroupActiveModel data)
        {
            FightGroupShowDetailModel model = new FightGroupShowDetailModel();

            if (data == null)
            {
                throw new HimallException("错误的活动信息");
            }
            data.InitProductImages();
            model.ActiveData = data;
            return(View(model));
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 修改拼团活动
        /// </summary>
        /// <param name="data"></param>
        public static void UpdateActive(FightGroupActiveModel data)
        {
            #region 更新活动
            //   Mapper.CreateMap<FightGroupActiveModel, FightGroupActiveInfo>();
            //  Mapper.CreateMap<FightGroupActiveItemModel, FightGroupActiveItemInfo>();
            // var model = Mapper.Map<FightGroupActiveModel, FightGroupActiveInfo>(data);
            var model = data.Map <FightGroupActiveInfo>();

            Service.UpdateActive(model);
            Cache.Remove(CacheKeyCollection.CACHE_FIGHTGROUP);
            #endregion
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 修改拼团活动
        /// </summary>
        /// <returns></returns>
        public ActionResult EditActive(long id)
        {
            FightGroupActiveModel model = FightGroupApplication.GetActive(id);

            if (model == null)
            {
                throw new MallException("错误的活动编号");
            }
            if (model.EndTime < DateTime.Now)
            {
                throw new MallException("已结束的活动不可以编辑");
            }
            return(View(model));
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 查看活动
        /// </summary>
        /// <param name="id">活动编号</param>
        /// <returns></returns>
        public ActionResult ViewActive(long id)
        {
            FightGroupActiveModel model = FightGroupApplication.GetActive(id);

            if (model == null)
            {
                throw new MallException("错误的活动编号");
            }
            if (model.ShopId != CurShopId)
            {
                throw new MallException("错误的活动编号");
            }
            model.ProductDefaultImage = MallIO.GetProductSizeImage(model.ProductImgPath, 1, ImageSize.Size_150.GetHashCode());
            return(View(model));
        }
Ejemplo n.º 24
0
        public JsonResult GetSkus(long id)
        {
            FightGroupActiveModel model = FightGroupApplication.GetActive(id, false, true);

            if (model == null)
            {
                throw new HimallException("错误的活动信息");
            }
            List <SKUDataModel> data = (from d in model.ActiveItems
                                        where d.ActiveStock > 0L
                                        select new SKUDataModel {
                SkuId = d.SkuId, Color = d.Color, Size = d.Size, Version = d.Version, Stock = (int)d.ActiveStock.Value, CostPrice = d.ProductCostPrice, SalePrice = d.ProductPrice, Price = d.ActivePrice
            }).ToList <SKUDataModel>();

            return(base.Json(data));
        }
Ejemplo n.º 25
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>
        /// 分享参数二次加载
        /// <para>ios分享错误临时解决方案</para>
        /// </summary>
        /// <param name="id"></param>
        /// <param name="aid"></param>
        /// <returns></returns>
        public JsonResult GetGroupDetailWXShare(long id, long aid)
        {
            FightGroupActiveModel gpact = FightGroupApplication.GetActive(aid, false);

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

            if (groupsdata == null)
            {
                throw new HimallException("错误的拼团信息");
            }
            if (groupsdata.BuildStatus == FightGroupBuildStatus.Opening)
            {
                throw new HimallException("开团未成功,等待团长付款中");
            }
            MyFightGroupDetailModel model = new MyFightGroupDetailModel();

            model.ShareUrl   = string.Format("{0}/m-{1}/FightGroup/GroupDetail/{2}?aid={3}", Request.Url.Authority, "WeiXin", groupsdata.Id, groupsdata.ActiveId);
            model.ShareTitle = "我参加了(" + groupsdata.ProductName + ")的拼团";
            model.ShareImage = gpact.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;

            model.ShareDesc = "还差" + neednum + "人即可成团";
            if (!string.IsNullOrWhiteSpace(gpact.ProductShortDescription))
            {
                model.ShareDesc += ",(" + gpact.ProductShortDescription + ")";
            }

            //model.WeiXinShareArgs = Application.WXApiApplication.GetWeiXinShareArgs(this.HttpContext.Request.UrlReferrer.AbsoluteUri);

            return(Json(model));
        }
Ejemplo n.º 27
0
        public JsonResult EditActive(FightGroupActiveModel model)
        {
            var result = new Result {
                success = false, msg = "未知错误", status = -1
            };
            FightGroupActiveModel data = FightGroupApplication.GetActive(model.Id);

            if (data == null)
            {
                throw new HimallException("错误的活动编号");
            }
            if (model.EndTime < DateTime.Now)
            {
                throw new HimallException("错误的结束时间");
            }
            if (model.EndTime < model.StartTime)
            {
                throw new HimallException("错误的结束时间");
            }

            if (ModelState.IsValid)
            {
                UpdateModel(data);

                model = data;
                //数据有效性验证
                model.CheckValidation();

                data.IconUrl = SaveActiveIcon(data.IconUrl);


                FightGroupApplication.UpdateActive(data);
                result = new Result {
                    success = true, msg = "操作成功", status = 1
                };
            }
            else
            {
                result = new Result {
                    success = false, msg = "数据异常,请检查数据有效性", status = -1
                };
            }
            return(Json(result));
        }
Ejemplo n.º 28
0
        public JsonResult GetSkus(long id)
        {
            FightGroupActiveModel model = FightGroupApplication.GetActive(id, false);

            if (model == null)
            {
                throw new HimallException("错误的活动信息");
            }
            List <SKUDataModel> skudata = model.ActiveItems.Where(d => d.ActiveStock > 0).Select(d => new SKUDataModel
            {
                SkuId     = d.SkuId,
                Color     = d.Color,
                Size      = d.Size,
                Version   = d.Version,
                Stock     = (int)d.ActiveStock,
                CostPrice = d.ProductCostPrice,
                SalePrice = d.ProductPrice,
                Price     = d.ActivePrice,
            }).ToList();

            return(Json(skudata));
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 拼团活动商品详情
        /// </summary>
        /// <param name="id">拼团活动ID</param>
        /// /// <param name="grouId">团活动ID</param>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetActiveDetail(long id, long grouId = 0, bool isFirst = true, string ids = "")
        {
            var userList = new List <FightGroupOrderInfo>();
            var data     = FightGroupApplication.GetActive(id, true, true);
            FightGroupActiveModel result = data;

            //先初始化拼团商品主图
            result.InitProductImages();
            var imgpath = data.ProductImgPath;

            if (result != null)
            {
                result.IsEnd = true;
                if (data.EndTime.Date >= DateTime.Now.Date)
                {
                    result.IsEnd = false;
                }
                //商品图片地址修正
                result.ProductDefaultImage = HimallIO.GetRomoteProductSizeImage(imgpath, 1, (int)ImageSize.Size_350);
                result.ProductImgPath      = HimallIO.GetRomoteProductSizeImage(imgpath, 1);
            }
            if (result.ProductImages != null)
            {//将主图相对路径处理为绝对路径
                result.ProductImages = result.ProductImages.Select(e => HimallIO.GetRomoteImagePath(e)).ToList();
            }

            if (!string.IsNullOrWhiteSpace(result.IconUrl))
            {
                result.IconUrl = Himall.Core.HimallIO.GetRomoteImagePath(result.IconUrl);
            }
            bool IsUserEnter = false;
            long currentUser = 0;

            if (CurrentUser != null)
            {
                currentUser = CurrentUser.Id;
            }
            if (grouId > 0)//获取已参团的用户
            {
                userList = ServiceProvider.Instance <IFightGroupService> .Create.GetActiveUsers(id, grouId);

                foreach (var item in userList)
                {
                    item.Photo        = !string.IsNullOrWhiteSpace(item.Photo) ? Core.HimallIO.GetRomoteImagePath(item.Photo) : "";
                    item.HeadUserIcon = !string.IsNullOrWhiteSpace(item.HeadUserIcon) ? Core.HimallIO.GetRomoteImagePath(item.HeadUserIcon) : "";
                    if (currentUser.Equals(item.OrderUserId))
                    {
                        IsUserEnter = true;
                    }
                }
            }
            #region 商品规格
            var product = ProductManagerApplication.GetProduct((long)result.ProductId);

            ProductShowSkuInfoModel model = new ProductShowSkuInfoModel();
            model.MinSalePrice     = data.MiniSalePrice;
            model.ProductImagePath = string.IsNullOrWhiteSpace(imgpath) ? "" : HimallIO.GetRomoteProductSizeImage(imgpath, 1, (int)Himall.CommonModel.ImageSize.Size_350);

            List <SKUDataModel> skudata = data.ActiveItems.Where(d => d.ActiveStock > 0).Select(d => new SKUDataModel
            {
                SkuId     = d.SkuId,
                Color     = d.Color,
                Size      = d.Size,
                Version   = d.Version,
                Stock     = (int)d.ActiveStock,
                CostPrice = d.ProductCostPrice,
                SalePrice = d.ProductPrice,
                Price     = d.ActivePrice,
            }).ToList();

            Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.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;

            if (result.ActiveItems != null && result.ActiveItems.Count() > 0)
            {
                long colorId = 0, sizeId = 0, versionId = 0;
                var  skus = ProductManagerApplication.GetSKUs((long)result.ProductId);
                foreach (var sku in result.ActiveItems)
                {
                    var specs = sku.SkuId.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 = result.ActiveItems.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.ActiveStock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色",
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? " " : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = string.IsNullOrWhiteSpace(sku.ShowPic) ? "" : Core.HimallIO.GetRomoteImagePath(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 = result.ActiveItems.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.ActiveStock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码",
                                    Name          = "选择" + sizeAlias,
                                    EnabledClass  = ss != 0 ? "enabled" : "disabled",
                                    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 = result.ActiveItems.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.ActiveStock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择规格",
                                    Name          = "选择" + versionAlias,
                                    EnabledClass  = v != 0 ? "enabled" : "disabled",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
            }
            #endregion

            var cashDepositModel = CashDepositsApplication.GetCashDepositsObligation((long)result.ProductId);//提供服务(消费者保障、七天无理由、及时发货)

            var GroupsData = new List <FightGroupsListModel>();
            List <FightGroupBuildStatus> stlist = new List <FightGroupBuildStatus>();
            stlist.Add(FightGroupBuildStatus.Ongoing);
            GroupsData = FightGroupApplication.GetGroups(id, stlist, null, null, 1, 10).Models.ToList();
            foreach (var item in GroupsData)
            {
                TimeSpan mid = item.AddGroupTime.AddHours((double)item.LimitedHour) - DateTime.Now;
                item.Seconds         = (int)mid.TotalSeconds;
                item.EndHourOrMinute = item.ShowHourOrMinute(item.GetEndHour);
                item.HeadUserIcon    = !string.IsNullOrWhiteSpace(item.HeadUserIcon) ? Core.HimallIO.GetRomoteImagePath(item.HeadUserIcon) : "";
            }

            #region 商品评论
            ProductCommentShowModel modelSay = new ProductCommentShowModel();
            modelSay.ProductId = (long)result.ProductId;
            var productSay = ProductManagerApplication.GetProduct((long)result.ProductId);
            modelSay.CommentList       = new List <ProductDetailCommentModel>();
            modelSay.IsShowColumnTitle = true;
            modelSay.IsShowCommentList = true;

            if (productSay == null)
            {
                //跳转到404页面
                throw new Core.HimallException("商品不存在");
            }
            var comments = CommentApplication.GetCommentsByProduct(product.Id);
            modelSay.CommentCount = comments.Count;
            if (comments.Count > 0)
            {
                var comment   = comments.OrderByDescending(a => a.ReviewDate).FirstOrDefault();
                var orderItem = OrderApplication.GetOrderItem(comment.SubOrderId);
                var order     = OrderApplication.GetOrder(orderItem.OrderId);
                modelSay.CommentList = comments.OrderByDescending(a => a.ReviewDate)
                                       .Take(1)
                                       .Select(c => {
                    var images = CommentApplication.GetProductCommentImagesByCommentIds(new List <long> {
                        c.Id
                    });
                    return(new ProductDetailCommentModel
                    {
                        Sku = ServiceProvider.Instance <IProductService> .Create.GetSkuString(orderItem.SkuId),
                        UserName = c.UserName,
                        ReviewContent = c.ReviewContent,
                        AppendContent = c.AppendContent,
                        AppendDate = c.AppendDate,
                        ReplyAppendContent = c.ReplyAppendContent,
                        ReplyAppendDate = c.ReplyAppendDate,
                        FinshDate = order.FinishDate,
                        Images = images.Where(a => a.CommentType == 0).Select(a => a.CommentImage).ToList(),
                        AppendImages = images.Where(a => a.CommentType == 1).Select(a => a.CommentImage).ToList(),
                        ReviewDate = c.ReviewDate,
                        ReplyContent = string.IsNullOrWhiteSpace(c.ReplyContent) ? "暂无回复" : c.ReplyContent,
                        ReplyDate = c.ReplyDate,
                        ReviewMark = c.ReviewMark,
                        BuyDate = order.OrderDate
                    });
                }).ToList();
                foreach (var citem in modelSay.CommentList)
                {
                    if (citem.Images.Count > 0)
                    {
                        for (var _imgn = 0; _imgn < citem.Images.Count; _imgn++)
                        {
                            citem.Images[_imgn] = Himall.Core.HimallIO.GetRomoteImagePath(citem.Images[_imgn]);
                        }
                    }
                    if (citem.AppendImages.Count > 0)
                    {
                        for (var _imgn = 0; _imgn < citem.AppendImages.Count; _imgn++)
                        {
                            citem.AppendImages[_imgn] = Himall.Core.HimallIO.GetRomoteImagePath(citem.AppendImages[_imgn]);
                        }
                    }
                }
            }
            #endregion

            #region 店铺信息
            VShopShowShopScoreModel modelShopScore = new VShopShowShopScoreModel();
            modelShopScore.ShopId = result.ShopId;
            var shop = ServiceProvider.Instance <IShopService> .Create.GetShop(result.ShopId);

            if (shop == null)
            {
                throw new HimallException("错误的店铺信息");
            }

            modelShopScore.ShopName = shop.ShopName;

            #region 获取店铺的评价统计
            var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(result.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;

            modelShopScore.SellerServiceAttitude     = defaultValue;
            modelShopScore.SellerServiceAttitudePeer = defaultValue;
            modelShopScore.SellerServiceAttitudeMax  = defaultValue;
            modelShopScore.SellerServiceAttitudeMin  = defaultValue;

            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null && !shop.IsSelf)
            {
                modelShopScore.ProductAndDescription     = productAndDescription.CommentValue;
                modelShopScore.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                modelShopScore.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                modelShopScore.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                modelShopScore.ProductAndDescription     = defaultValue;
                modelShopScore.ProductAndDescriptionPeer = defaultValue;
                modelShopScore.ProductAndDescriptionMin  = defaultValue;
                modelShopScore.ProductAndDescriptionMax  = defaultValue;
            }

            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null && !shop.IsSelf)
            {
                modelShopScore.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                modelShopScore.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                modelShopScore.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                modelShopScore.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                modelShopScore.SellerServiceAttitude     = defaultValue;
                modelShopScore.SellerServiceAttitudePeer = defaultValue;
                modelShopScore.SellerServiceAttitudeMax  = defaultValue;
                modelShopScore.SellerServiceAttitudeMin  = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null && !shop.IsSelf)
            {
                modelShopScore.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                modelShopScore.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                modelShopScore.SellerDeliverySpeedMax  = sellerDeliverySpeedMax != null ? sellerDeliverySpeedMax.CommentValue : 0;
                modelShopScore.sellerDeliverySpeedMin  = sellerDeliverySpeedMin != null ? sellerDeliverySpeedMin.CommentValue : 0;
            }
            else
            {
                modelShopScore.SellerDeliverySpeed     = defaultValue;
                modelShopScore.SellerDeliverySpeedPeer = defaultValue;
                modelShopScore.SellerDeliverySpeedMax  = defaultValue;
                modelShopScore.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion

            modelShopScore.ProductNum = ServiceProvider.Instance <IProductService> .Create.GetShopOnsaleProducts(result.ShopId);

            modelShopScore.IsFavoriteShop    = false;
            modelShopScore.FavoriteShopCount = ServiceProvider.Instance <IShopService> .Create.GetShopFavoritesCount(result.ShopId);

            if (CurrentUser != null)
            {
                modelShopScore.IsFavoriteShop = ServiceProvider.Instance <IShopService> .Create.GetFavoriteShopInfos(CurrentUser.Id).Any(d => d.ShopId == result.ShopId);
            }

            long vShopId;
            var  vshopinfo = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id);

            if (vshopinfo == null)
            {
                vShopId = -1;
            }
            else
            {
                vShopId = vshopinfo.Id;
            }
            modelShopScore.VShopId  = vShopId;
            modelShopScore.VShopLog = ServiceProvider.Instance <IVShopService> .Create.GetVShopLog(vShopId);

            if (!string.IsNullOrWhiteSpace(modelShopScore.VShopLog))
            {
                modelShopScore.VShopLog = Himall.Core.HimallIO.GetRomoteImagePath(modelShopScore.VShopLog);
            }

            // 客服
            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(shop.Id);
            #endregion
            #region 根据运费模板获取发货地址
            var    freightTemplateService = ServiceApplication.Create <IFreightTemplateService>();
            var    template       = freightTemplateService.GetFreightTemplate(product.FreightTemplateId);
            string productAddress = string.Empty;
            if (template != null)
            {
                var fullName = ServiceApplication.Create <IRegionService>().GetFullName(template.SourceAddress);
                if (fullName != null)
                {
                    var ass = fullName.Split(' ');
                    if (ass.Length >= 2)
                    {
                        productAddress = ass[0] + " " + ass[1];
                    }
                    else
                    {
                        productAddress = ass[0];
                    }
                }
            }

            var ProductAddress  = productAddress;
            var FreightTemplate = template;
            #endregion

            #region 获取店铺优惠信息
            VShopShowPromotionModel modelVshop = new VShopShowPromotionModel();
            modelVshop.ShopId = result.ShopId;
            var shopInfo = ServiceProvider.Instance <IShopService> .Create.GetShop(result.ShopId);

            if (shopInfo == null)
            {
                throw new HimallException("错误的店铺编号");
            }

            modelVshop.FreeFreight = shop.FreeFreight;


            var bonus = ServiceApplication.Create <IShopBonusService>().GetByShopId(result.ShopId);
            if (bonus != null)
            {
                modelVshop.BonusCount             = bonus.Count;
                modelVshop.BonusGrantPrice        = bonus.GrantPrice;
                modelVshop.BonusRandomAmountStart = bonus.RandomAmountStart;
                modelVshop.BonusRandomAmountEnd   = bonus.RandomAmountEnd;
            }
            FullDiscountActive fullDiscount = null;
            //var fullDiscount = FullDiscountApplication.GetOngoingActiveByProductId(id, shop.Id);
            #endregion
            //商品描述

            var description = ProductManagerApplication.GetProductDescription(result.ProductId);
            if (description == null)
            {
                throw new HimallException("错误的商品编号");
            }

            string DescriptionPrefix = "", DescriptiondSuffix = "";
            var    iprodestempser = ServiceApplication.Create <IProductDescriptionTemplateService>();
            if (description.DescriptionPrefixId != 0)
            {
                var desc = iprodestempser.GetTemplate(description.DescriptionPrefixId, product.ShopId);
                DescriptionPrefix = desc == null ? "" : desc.MobileContent;
            }

            if (description.DescriptiondSuffixId != 0)
            {
                var desc = iprodestempser.GetTemplate(description.DescriptiondSuffixId, product.ShopId);
                DescriptiondSuffix = desc == null ? "" : desc.MobileContent;
            }
            var productDescription = DescriptionPrefix + description.ShowMobileDescription + DescriptiondSuffix;
            //统计商品浏览量、店铺浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);

            AutoMapper.Mapper.CreateMap <FightGroupActiveModel, FightGroupActiveResult>();
            var     fightGroupData = AutoMapper.Mapper.Map <FightGroupActiveResult>(result);
            decimal discount       = 1M;
            if (CurrentUser != null)
            {
                discount = CurrentUser.MemberDiscount;
            }
            var shopItem = ShopApplication.GetShop(result.ShopId);
            fightGroupData.MiniSalePrice = shopItem.IsSelf ? fightGroupData.MiniSalePrice * discount : fightGroupData.MiniSalePrice;

            string loadShowPrice = string.Empty;//app拼团详细页加载时显示的区间价
            loadShowPrice = fightGroupData.MiniSalePrice.ToString("f2");

            if (fightGroupData != null && fightGroupData.ActiveItems.Count() > 0)
            {
                decimal min = fightGroupData.ActiveItems.Min(s => s.ActivePrice);
                decimal max = fightGroupData.ActiveItems.Max(s => s.ActivePrice);
                loadShowPrice = (min < max) ? (min.ToString("f2") + " - " + max.ToString("f2")) : min.ToString("f2");
            }

            var _result = new
            {
                success        = true,
                FightGroupData = fightGroupData,
                ShowSkuInfo    = new
                {
                    ColorAlias       = model.ColorAlias,
                    SizeAlias        = model.SizeAlias,
                    VersionAlias     = model.VersionAlias,
                    MinSalePrice     = model.MinSalePrice,
                    ProductImagePath = model.ProductImagePath,
                    Color            = model.Color.OrderByDescending(p => p.SkuId),
                    Size             = model.Size.OrderByDescending(p => p.SkuId),
                    Version          = model.Version.OrderByDescending(p => p.SkuId)
                },
                ShowPromotion       = modelVshop,
                fullDiscount        = fullDiscount,
                ShowNewCanJoinGroup = GroupsData,
                ProductCommentShow  = modelSay,
                ProductDescription  = productDescription.Replace("src=\"/Storage/", "src=\"" + Core.HimallIO.GetRomoteImagePath("/Storage") + "/"),
                ShopScore           = modelShopScore,
                CashDepositsServer  = cashDepositModel,
                ProductAddress      = ProductAddress,
                //Free = FreightTemplate.IsFree == FreightTemplateType.Free ? "免运费" : "",
                userList              = userList,
                IsUserEnter           = IsUserEnter,
                SkuData               = skudata,
                CustomerServices      = customerServices,
                IsOpenLadder          = product.IsOpenLadder,
                VideoPath             = string.IsNullOrWhiteSpace(product.VideoPath) ? string.Empty : Himall.Core.HimallIO.GetRomoteImagePath(product.VideoPath),
                LoadShowPrice         = loadShowPrice,                                                                                                           //商品时区间价
                ProductSaleCountOnOff = (SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1),                                                        //是否显示销量
                SaleCounts            = data.ActiveItems.Sum(d => d.BuyCount),                                                                                   //销量
                FreightStr            = FreightTemplateApplication.GetFreightStr(product.Id, FreightTemplate, CurrentUser, product),                             //运费多少或免运费
                SendTime              = (FreightTemplate != null && !string.IsNullOrEmpty(FreightTemplate.SendTime) ? (FreightTemplate.SendTime + "h内发货") : ""), //运费模板发货时间
            };
            return(JsonResult <dynamic>(_result));
        }
Ejemplo n.º 30
0
        /// <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));
        }