Ejemplo n.º 1
0
        /// <summary>
        /// 获取拼团订单详情
        /// </summary>
        /// <param name="Id">订单Id</param>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetFightGroupOrderDetail(long id)
        {
            var userList = new List <FightGroupOrderInfo>();

            var orderDetail = FightGroupApplication.GetFightGroupOrderStatusByOrderId(id);

            //团组活动信息
            orderDetail.UserInfo = new List <UserInfo>();
            var data = FightGroupApplication.GetActive((long)orderDetail.ActiveId, false, true);

            Mapper.CreateMap <FightGroupActiveInfo, FightGroupActiveModel>();
            //规格映射
            Mapper.CreateMap <FightGroupActiveItemInfo, FightGroupActiveItemModel>();

            FightGroupsModel groupsdata = FightGroupApplication.GetGroup(orderDetail.ActiveId, orderDetail.GroupId);

            if (groupsdata == null)
            {
                throw new HimallException("错误的拼团信息");
            }
            if (data != null)
            {
                //商品图片地址修正
                data.ProductDefaultImage = HimallIO.GetRomoteProductSizeImage(data.ProductImgPath, 1, (int)ImageSize.Size_350);
            }
            orderDetail.AddGroupTime = groupsdata.AddGroupTime;
            orderDetail.GroupStatus  = groupsdata.BuildStatus;
            orderDetail.ProductId    = data.ProductId;
            orderDetail.ProductName  = data.ProductName;
            orderDetail.IconUrl      = HimallIO.GetRomoteProductSizeImage(data.ProductImgPath, 1, (int)ImageSize.Size_350);//result.IconUrl;
            orderDetail.thumbs       = HimallIO.GetRomoteProductSizeImage(data.ProductImgPath, 1, (int)ImageSize.Size_100);
            //在使用之后,再修正为绝对路径
            data.ProductImgPath = HimallIO.GetRomoteImagePath(data.ProductImgPath);

            orderDetail.MiniGroupPrice = data.MiniGroupPrice;
            TimeSpan mids = DateTime.Now - (DateTime)orderDetail.AddGroupTime;

            orderDetail.Seconds       = (int)(data.LimitedHour * 3600) - (int)mids.TotalSeconds;
            orderDetail.LimitedHour   = data.LimitedHour.GetValueOrDefault();
            orderDetail.LimitedNumber = data.LimitedNumber.GetValueOrDefault();
            orderDetail.JoinedNumber  = groupsdata.JoinedNumber;
            orderDetail.OverTime      = groupsdata.OverTime.HasValue ? groupsdata.OverTime : orderDetail.AddGroupTime.AddHours((double)orderDetail.LimitedHour);
            if (orderDetail.OverTime.HasValue)
            {
                orderDetail.OverTime = DateTime.Parse(orderDetail.OverTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            //拼装已参团成功的用户
            userList = ServiceProvider.Instance <IFightGroupService> .Create.GetActiveUsers((long)orderDetail.ActiveId, (long)orderDetail.GroupId);

            foreach (var userItem in userList)
            {
                var userInfo = new UserInfo();
                userInfo.Photo    = !string.IsNullOrWhiteSpace(userItem.Photo) ? Core.HimallIO.GetRomoteImagePath(userItem.Photo) : "";
                userInfo.UserName = userItem.UserName;
                userInfo.JoinTime = userItem.JoinTime;
                orderDetail.UserInfo.Add(userInfo);
            }
            //获取团长信息
            var GroupsData = ServiceProvider.Instance <IFightGroupService> .Create.GetGroup(orderDetail.ActiveId, orderDetail.GroupId);

            if (GroupsData != null)
            {
                orderDetail.HeadUserName     = GroupsData.HeadUserName;
                orderDetail.HeadUserIcon     = !string.IsNullOrWhiteSpace(GroupsData.HeadUserIcon) ? Core.HimallIO.GetRomoteImagePath(GroupsData.HeadUserIcon) : "";
                orderDetail.ShowHeadUserIcon = !string.IsNullOrWhiteSpace(GroupsData.ShowHeadUserIcon) ? Core.HimallIO.GetRomoteImagePath(GroupsData.ShowHeadUserIcon) : "";
            }
            //商品评论数
            var product = ServiceProvider.Instance <IProductService> .Create.GetProduct(orderDetail.ProductId);

            var comCount = CommentApplication.GetCommentCountByProduct(product.Id);
            //商品描述

            var ProductDescription = ServiceApplication.Create <IProductService>().GetProductDescription(orderDetail.ProductId);

            if (ProductDescription == null)
            {
                throw new Himall.Core.HimallException("错误的商品编号");
            }

            string description = ProductDescription.ShowMobileDescription.Replace("src=\"/Storage/", "src=\"" + Core.HimallIO.GetRomoteImagePath("/Storage/") + "/");//商品描述

            return(JsonResult <dynamic>(new
            {
                OrderDetail = orderDetail,
                ComCount = comCount,
                ProductDescription = description
            }));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取拼团订单详情
        /// </summary>
        /// <param name="Id">订单Id</param>
        /// <returns></returns>
        public object GetFightGroupOrderDetail(long Id)
        {
            var userList = new List <FightGroupOrderInfo>();

            var orderDetail = FightGroupApplication.GetFightGroupOrderStatusByOrderId(Id);

            //团组活动信息
            orderDetail.UserInfo = new List <UserInfo>();
            var data = FightGroupApplication.GetActive((long)orderDetail.ActiveId, false, true);

            Mapper.CreateMap <FightGroupActiveInfo, FightGroupActiveModel>();
            //规格映射
            Mapper.CreateMap <FightGroupActiveItemInfo, FightGroupActiveItemModel>();
            if (data != null)
            {
                //商品图片地址修正
                data.ProductDefaultImage = HimallIO.GetProductSizeImage(data.ProductImgPath, 1, (int)ImageSize.Size_350);
                data.ProductImgPath      = HimallIO.GetRomoteImagePath(data.ProductImgPath);
            }
            FightGroupsModel groupsdata = FightGroupApplication.GetGroup(orderDetail.ActiveId.Value, orderDetail.GroupId.Value);

            if (groupsdata == null)
            {
                throw new HimallException("错误的拼团信息");
            }
            orderDetail.AddGroupTime = groupsdata.AddGroupTime;
            //if (!string.IsNullOrWhiteSpace(result.IconUrl))
            //{
            //    result.IconUrl = Himall.Core.HimallIO.GetImagePath(result.IconUrl);
            //}
            orderDetail.ProductId      = data.ProductId;
            orderDetail.ProductName    = data.ProductName;
            orderDetail.IconUrl        = HimallIO.GetRomoteProductSizeImage(data.ProductImgPath, 1, (int)ImageSize.Size_350);//result.IconUrl;
            orderDetail.MiniGroupPrice = data.MiniGroupPrice;
            TimeSpan mids = DateTime.Now - (DateTime)orderDetail.AddGroupTime;

            orderDetail.Seconds       = (int)(data.LimitedHour * 3600) - (int)mids.TotalSeconds;
            orderDetail.LimitedHour   = data.LimitedHour.GetValueOrDefault();
            orderDetail.LimitedNumber = data.LimitedNumber.GetValueOrDefault();
            orderDetail.JoinedNumber  = groupsdata.JoinedNumber;
            orderDetail.OverTime      = groupsdata.OverTime.HasValue? groupsdata.OverTime:orderDetail.AddGroupTime.AddHours((double)orderDetail.LimitedHour);
            //拼装已参团成功的用户
            userList = ServiceProvider.Instance <IFightGroupService> .Create.GetActiveUsers((long)orderDetail.ActiveId, (long)orderDetail.GroupId);

            foreach (var userItem in userList)
            {
                var userInfo = new UserInfo();
                userInfo.Photo    = !string.IsNullOrWhiteSpace(userItem.Photo) ? Core.HimallIO.GetRomoteImagePath(userItem.Photo) : "";
                userInfo.UserName = userItem.UserName;
                userInfo.JoinTime = userItem.JoinTime;
                orderDetail.UserInfo.Add(userInfo);
            }
            //获取团长信息
            var GroupsData = ServiceProvider.Instance <IFightGroupService> .Create.GetGroup((long)orderDetail.ActiveId, (long)orderDetail.GroupId);

            if (GroupsData != null)
            {
                orderDetail.HeadUserName     = GroupsData.HeadUserName;
                orderDetail.HeadUserIcon     = !string.IsNullOrWhiteSpace(GroupsData.HeadUserIcon) ? Core.HimallIO.GetRomoteImagePath(GroupsData.HeadUserIcon) : "";
                orderDetail.ShowHeadUserIcon = !string.IsNullOrWhiteSpace(GroupsData.ShowHeadUserIcon) ? Core.HimallIO.GetRomoteImagePath(GroupsData.ShowHeadUserIcon) : "";
            }
            //商品评论数
            var product = ServiceProvider.Instance <IProductService> .Create.GetProduct((long)orderDetail.ProductId);

            var com      = product.Himall_ProductComments.Where(item => !item.IsHidden.HasValue || item.IsHidden.Value == false);
            var comCount = com.Count();
            //商品描述

            var ProductDescription = ServiceHelper.Create <IProductService>().GetProductDescription((long)orderDetail.ProductId);

            if (ProductDescription == null)
            {
                throw new Himall.Core.HimallException("错误的商品编号");
            }

            string description = ProductDescription.ShowMobileDescription.Replace("src=\"/Storage/", "src=\"" + Core.HimallIO.GetRomoteImagePath("/Storage/"));//商品描述

            return(Json(new
            {
                OrderDetail = orderDetail,
                ComCount = comCount,
                ProductDescription = description
            }));
        }