コード例 #1
0
        public ActionResult Satisfied(int pageSize = 15, int pageNo = 1)
        {
            var query = new OrderQuery();

            query.PageNo   = pageNo;
            query.PageSize = pageSize;
            query.Status   = Entities.OrderInfo.OrderOperateStatus.Finish;
            query.UserId   = CurrentUser.Id;
            query.Sort     = "CommentCount";
            query.IsAsc    = true;

            var model = OrderApplication.GetOrders(query);

            ViewBag.Comments = CommentApplication.GetOrderCommentByOrder(model.Models.Select(p => p.Id));

            #region 分页控制
            PagingInfo info = new PagingInfo
            {
                CurrentPage  = pageNo,
                ItemsPerPage = pageSize,
                TotalItems   = model.Total
            };
            ViewBag.pageInfo = info;
            #endregion
            ViewBag.Keyword  = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword;
            ViewBag.Keywords = SiteSettings.HotKeyWords;
            return(View(model.Models));
        }
コード例 #2
0
        // GET: Web/OrderEvaluation
        public ActionResult Index(long id)
        {
            var model           = CommentApplication.GetProductEvaluationByOrderId(id, CurrentUser.Id);
            var orderEvaluation = TradeCommentApplication.GetOrderComment(id, CurrentUser.Id);

            if (orderEvaluation != null)
            {
                ViewBag.Mark = Math.Round((orderEvaluation.PackMark + orderEvaluation.ServiceMark + orderEvaluation.DeliveryMark) / 3D);
            }
            else
            {
                ViewBag.Mark = 0;
            }
            ViewBag.OrderId = id;
            //检查当前产品是否产自官方自营店
            ViewBag.IsSellerAdminProdcut = OrderApplication.GetOrder(id).ShopId.Equals(1L);
            ViewBag.Keyword  = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword;
            ViewBag.Keywords = SiteSettings.HotKeyWords;
            var orderInfo = OrderApplication.GetOrder(id);

            if (orderInfo != null)
            {
                ViewBag.IsVirtual = orderInfo.OrderType == Himall.Entities.OrderInfo.OrderTypes.Virtual ? 1 : 0;
            }
            return(View(model));
        }
コード例 #3
0
        /// <summary>
        /// 用户收藏的商品
        /// </summary>
        /// <param name="pageNo"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public object GetUserCollectionProduct(int pageNo = 1, int pageSize = 16)
        {
            CheckUserLogin();
            if (CurrentUser != null)
            {
                var model = ServiceProvider.Instance <IProductService> .Create.GetUserConcernProducts(CurrentUser.Id, pageNo, pageSize);

                var result = model.Models.ToArray().Select(item =>
                {
                    var pro = ProductManagerApplication.GetProduct(item.ProductId);
                    return(new
                    {
                        Id = item.ProductId,
                        Image = HimallIO.GetRomoteProductSizeImage(pro.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_220),
                        ProductName = pro.ProductName,
                        SalePrice = pro.MinSalePrice.ToString("F2"),
                        Evaluation = CommentApplication.GetCommentCountByProduct(pro.Id),
                        Status = ProductManagerApplication.GetProductShowStatus(pro)
                    });
                });
                return(new { success = true, data = result, total = model.Total });
            }
            else
            {
                return(new Result {
                    success = false, msg = "未登录"
                });
            }
        }
コード例 #4
0
        public JsonResult AddOrderEvaluationAndComment(int packMark, int deliveryMark, int serviceMark, long orderId, string productCommentsJSON)
        {
            if (packMark != 0 || deliveryMark != 0 || serviceMark == 0)
            {
                var info = new DTO.OrderComment();
                info.UserId       = CurrentUser.Id;
                info.PackMark     = packMark;
                info.DeliveryMark = deliveryMark;
                info.ServiceMark  = serviceMark;
                info.OrderId      = orderId;
                TradeCommentApplication.Add(info);
            }

            var productComments = JsonConvert.DeserializeObject <List <ProductCommentsModel> >(productCommentsJSON);
            var list            = new List <DTO.ProductComment>();

            foreach (var productComment in productComments)
            {
                var model = new ProductComment();
                model.ReviewDate    = DateTime.Now;
                model.ReviewContent = productComment.content;
                model.UserId        = CurrentUser.Id;
                model.UserName      = CurrentUser.UserName;
                model.Email         = CurrentUser.Email;
                model.SubOrderId    = productComment.subOrderId;
                model.ReviewMark    = productComment.star;
                if (productComment.proimages != null && productComment.proimages.Length > 0)
                {
                    model.Images = new List <ProductCommentImage>();
                    foreach (var img in productComment.proimages)
                    {
                        var p = new ProductCommentImage();
                        p.CommentType  = 0;                       //0代表默认的表示评论的图片
                        p.CommentImage = MoveImages(img, CurrentUser.Id);
                        model.Images.Add(p);
                    }
                }

                list.Add(model);
            }
            var comments = CommentApplication.GetProductEvaluationByOrderIdNew(orderId, CurrentUser.Id);

            foreach (var item in comments)
            {
                var addComment = productComments.FirstOrDefault(e => e.subOrderId == item.Id);
                if (addComment != null)
                {
                    return(Json(new Result()
                    {
                        success = false, msg = "您已进行过评价!", status = -1
                    }));
                }
            }
            CommentApplication.Add(list);

            return(Json(new Result()
            {
                success = true, msg = "评价成功"
            }));
        }
コード例 #5
0
        /// <summary>
        /// 追加评论
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public ActionResult AppendComment(long orderId)
        {
            var model = CommentApplication.GetProductEvaluationByOrderIdNew(orderId, CurrentUser.Id);

            ViewBag.Keyword  = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword;
            ViewBag.Keywords = SiteSettings.HotKeyWords;
            return(View(model));
        }
コード例 #6
0
        /// <summary>
        /// 获取评价
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetComments([FromUri] ProductCommentQuery query)
        {
            if (query.PageNo == 0)
            {
                query.PageNo = 1;
            }
            if (query.PageSize == 0)
            {
                query.PageSize = 5;
            }
            var data = CommentApplication.GetProductComments(query);

            AutoMapper.Mapper.CreateMap <ProductComment, HomeGetCommentListModel>();
            var datalist = Mapper.Map <List <ProductComment>, List <HomeGetCommentListModel> >(data.Models);
            var users    = MemberApplication.GetMembers(datalist.Select(d => d.UserId).ToList());
            var products = ProductManagerApplication.GetAllProductByIds(datalist.Select(d => d.ProductId).ToList());

            //补充数据信息
            foreach (var item in datalist)
            {
                var u       = users.FirstOrDefault(d => d.Id == item.UserId);
                var product = products.FirstOrDefault(d => d.Id == item.ProductId);
                if (u != null)
                {
                    item.UserPhoto = Himall.Core.HimallIO.GetRomoteImagePath(u.Photo);
                }
                if (product != null)
                {
                    item.ProductName = product.ProductName;
                }
                //规格
                var sku = ProductManagerApplication.GetSKU(item.SkuId);
                if (sku != null)
                {
                    List <string> skucs = new List <string>();
                    if (!string.IsNullOrWhiteSpace(sku.Color))
                    {
                        skucs.Add(sku.Color);
                    }
                    if (!string.IsNullOrWhiteSpace(sku.Size))
                    {
                        skucs.Add(sku.Size);
                    }
                    if (!string.IsNullOrWhiteSpace(sku.Version))
                    {
                        skucs.Add(sku.Version);
                    }
                    item.SKU = string.Join("+", skucs);
                }
                foreach (var pitem in item.Images)
                {
                    pitem.CommentImage = HimallIO.GetRomoteImagePath(pitem.CommentImage);
                }
            }
            return(JsonResult <dynamic>(new { total = data.Total, rows = datalist }));
        }
コード例 #7
0
        /// <summary>
        /// 追加评论
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public ActionResult AppendComment(long orderId)
        {
            var model = CommentApplication.GetProductEvaluationByOrderIdNew(orderId, CurrentUser.Id);

            if (model.FirstOrDefault().AppendTime.HasValue)
            {
                return(RedirectToAction("orders", "member"));
            }

            return(View(model));
        }
コード例 #8
0
        // GET: Web/ProductComment
        public ActionResult Index(long id)
        {
            var productMark = CommentApplication.GetProductAverageMark(id);

            ViewBag.CommentCount = CommentApplication.GetCommentCountByProduct(id);
            ViewBag.productMark  = productMark;
            var productinfo = _iProductService.GetProduct(id);

            ViewBag.Keyword = SiteSettings.Keyword;
            return(View(productinfo));
        }
コード例 #9
0
        public ActionResult Details(long orderId)
        {
            var orderComment = TradeCommentApplication.GetOrderComment(orderId, CurrentUser.Id);

            ViewBag.PackMark     = orderComment != null ? orderComment.PackMark - 1 : -1;
            ViewBag.DeliveryMark = orderComment != null ? orderComment.DeliveryMark - 1 : -1;
            ViewBag.ServiceMark  = orderComment != null ? orderComment.ServiceMark - 1 : -1;
            var model = CommentApplication.GetProductEvaluationByOrderIdNew(orderId, CurrentUser.Id);

            ViewBag.IsSellerAdminProdcut = OrderApplication.GetOrder(orderId).ShopId.Equals(1L);
            return(View(model));
        }
コード例 #10
0
        /// <summary>
        /// 追加评价
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public JsonResult <Result <int> > PostAppendComment(CommentAppendCommentModel value)
        {
            CheckUserLogin();
            string productCommentsJSON = value.productCommentsJSON;
            //var commentService = ServiceProvider.Instance<ICommentService>.Create;
            var productComments = JsonConvert.DeserializeObject <List <AppendCommentModel> >(productCommentsJSON);

            foreach (var m in productComments)
            {
                m.UserId = CurrentUser.Id;
            }
            CommentApplication.Append(productComments);
            return(JsonResult <int>());
        }
コード例 #11
0
        public ActionResult AppendProductComment(string productCommentsJSON)
        {
            var productComments = JsonConvert.DeserializeObject <List <AppendCommentModel> >(productCommentsJSON);

            foreach (var m in productComments)
            {
                m.UserId = CurrentUser.Id;
            }
            CommentApplication.Append(productComments);
            return(Json(new Result()
            {
                success = true, msg = "追加成功"
            }));
        }
コード例 #12
0
        // GET: Web/OrderEvaluation
        public ActionResult Index(long id)
        {
            var model           = CommentApplication.GetProductEvaluationByOrderId(id, CurrentUser.Id);
            var orderEvaluation = TradeCommentApplication.GetOrderComment(id, CurrentUser.Id);

            if (orderEvaluation != null)
            {
                ViewBag.Mark = Math.Round((orderEvaluation.PackMark + orderEvaluation.ServiceMark + orderEvaluation.DeliveryMark) / 3D);
            }
            else
            {
                ViewBag.Mark = 0;
            }
            ViewBag.OrderId = id;
            //检查当前产品是否产自官方自营店
            ViewBag.IsSellerAdminProdcut = OrderApplication.GetOrder(id).ShopId.Equals(1L);
            return(View(model));
        }
コード例 #13
0
        // GET: Web/ProductConsultation
        public ActionResult Index(long id = 0)
        {
            var productMark = CommentApplication.GetProductAverageMark(id);

            ViewBag.CommentCount = CommentApplication.GetCommentCountByProduct(id);
            ViewBag.productMark  = productMark;
            var productinfo = _iProductService.GetProduct(id);
            List <FlashSalePrice> falseSalePrice = _iLimitTimeBuyService.GetPriceByProducrIds(new List <long> {
                id
            });

            if (falseSalePrice != null && falseSalePrice.Count == 1)
            {
                productinfo.MinSalePrice = falseSalePrice[0].MinPrice;
            }
            ViewBag.Keyword = SiteSettings.Keyword;
            return(View(productinfo));
        }
コード例 #14
0
        void AddProductsComment(long orderId, IEnumerable <ProductCommentModel> productComments)
        {
            var list = new List <ProductComment>();

            foreach (var productComment in productComments)
            {
                var model = new ProductComment();
                model.ReviewDate    = DateTime.Now;
                model.ReviewContent = productComment.Content;
                model.UserId        = CurrentUser.Id;
                model.UserName      = CurrentUser.UserName;
                model.Email         = CurrentUser.Email;
                model.SubOrderId    = productComment.OrderItemId;
                model.ReviewMark    = productComment.Mark;
                model.ProductId     = productComment.ProductId;
                if (productComment.Images != null && productComment.Images.Length > 0)
                {
                    model.Images = new List <ProductCommentImage>();
                    foreach (var img in productComment.Images)
                    {
                        var p = new ProductCommentImage();
                        p.CommentType  = 0;//0代表默认的表示评论的图片
                        p.CommentImage = MoveImages(img, CurrentUser.Id);
                        model.Images.Add(p);
                    }
                }
                else if (productComment.WXmediaId != null && productComment.WXmediaId.Length > 0)
                {
                    model.Images = new List <ProductCommentImage>();
                    foreach (var img in productComment.WXmediaId)
                    {
                        var p = new ProductCommentImage();
                        p.CommentType  = 0;//0代表默认的表示评论的图片
                        p.CommentImage = DownloadWxImage(img);
                        if (!string.IsNullOrEmpty(p.CommentImage))
                        {
                            model.Images.Add(p);
                        }
                    }
                }
                list.Add(model);
            }
            CommentApplication.Add(list);
        }
コード例 #15
0
        /// <summary>
        /// 获取追加评论
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetAppendComment(long orderId)
        {
            CheckUserLogin();
            var model = CommentApplication.GetProductEvaluationByOrderIdNew(orderId, CurrentUser.Id);

            if (model.Count() > 0 && model.FirstOrDefault().AppendTime.HasValue)
            {
                return(Json(ErrorResult <dynamic>("追加评论时,获取数据异常", new int[0])));
            }
            else
            {
                var listResult = model.Select(item => new
                {
                    Id          = item.Id,
                    CommentId   = item.CommentId,
                    ProductId   = item.ProductId,
                    ProductName = item.ProductName,
                    //ThumbnailsUrl = item.ThumbnailsUrl,
                    ThumbnailsUrl      = Core.HimallIO.GetRomoteProductSizeImage(item.ThumbnailsUrl, 1, (int)Himall.CommonModel.ImageSize.Size_220), //商城App追加评论时获取商品图片
                    BuyTime            = item.BuyTime,
                    EvaluationStatus   = item.EvaluationStatus,
                    EvaluationContent  = item.EvaluationContent,
                    AppendContent      = item.AppendContent,
                    AppendTime         = item.AppendTime,
                    EvaluationTime     = item.EvaluationTime,
                    ReplyTime          = item.ReplyTime,
                    ReplyContent       = item.ReplyContent,
                    ReplyAppendTime    = item.ReplyAppendTime,
                    ReplyAppendContent = item.ReplyAppendContent,
                    EvaluationRank     = item.EvaluationRank,
                    OrderId            = item.OrderId,
                    CommentImages      = item.CommentImages.Select(r => new
                    {
                        CommentImage = r.CommentImage,
                        CommentId    = r.CommentId,
                        CommentType  = r.CommentType
                    }).ToList(),
                    Color   = item.Color,
                    Size    = item.Size,
                    Version = item.Version
                }).ToList();
                return(JsonResult <dynamic>(listResult));
            }
        }
コード例 #16
0
        public ActionResult Details(long orderId)
        {
            var orderComment = TradeCommentApplication.GetOrderComment(orderId, CurrentUser.Id);

            ViewBag.PackMark     = orderComment != null ? orderComment.PackMark - 1 : -1;
            ViewBag.DeliveryMark = orderComment != null ? orderComment.DeliveryMark - 1 : -1;
            ViewBag.ServiceMark  = orderComment != null ? orderComment.ServiceMark - 1 : -1;
            var  model     = CommentApplication.GetProductEvaluationByOrderIdNew(orderId, CurrentUser.Id);
            var  orderInfo = OrderApplication.GetOrder(orderId);
            bool isVirtual = false;

            if (orderInfo != null)
            {
                ViewBag.IsSellerAdminProdcut = orderInfo.ShopId.Equals(1L);
                isVirtual = orderInfo.OrderType == Entities.OrderInfo.OrderTypes.Virtual;
            }
            ViewBag.IsVirtual = isVirtual;
            ViewBag.Keyword   = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword;
            ViewBag.Keywords  = SiteSettings.HotKeyWords;
            return(View(model));
        }
コード例 #17
0
        // GET: Mobile/Comment
        public ActionResult Index(long orderId)
        {
            var order         = OrderApplication.GetOrder(orderId);
            var orderComments = OrderApplication.GetOrderCommentCount(new[] { orderId });

            bool valid = false;

            if (order != null && (!orderComments.ContainsKey(orderId) || orderComments[orderId] == 0))
            {
                // 订单还未被评价过,有效
                valid = true;
                var model           = CommentApplication.GetProductEvaluationByOrderId(orderId, CurrentUser.Id);
                var orderEvaluation = TradeCommentApplication.GetOrderComment(orderId, CurrentUser.Id);

                ViewBag.Products = model;
                var orderItems = OrderApplication.GetOrderItemsByOrderId(orderId);
                ViewBag.OrderItemIds = orderItems.Select(item => item.Id);
            }
            ViewBag.Valid = valid;

            return(View());
        }
コード例 #18
0
        public ActionResult Index(int pageSize = 10, int pageNo = 1)
        {
            var        model = _iProductService.GetUserConcernProducts(CurrentUser.Id, pageNo, pageSize);
            PagingInfo info  = new PagingInfo
            {
                CurrentPage  = pageNo,
                ItemsPerPage = pageSize,
                TotalItems   = model.Total
            };

            ViewBag.pageInfo = info;
            ViewBag.Keyword  = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword;
            ViewBag.Keywords = SiteSettings.HotKeyWords;
            if (model.Models.Count == 0 && pageNo > 1)
            {//如果当前页没有数据,跳转到前一页
                return(Redirect("/ProductConcern/Index?pageNo=" + (pageNo - 1)));
            }
            ViewBag.Products = ProductManagerApplication.GetProducts(model.Models.Select(p => p.ProductId));
            ViewBag.SKUs     = ProductManagerApplication.GetSKUsByProduct(model.Models.Select(p => p.ProductId));
            //TODO:FG 此实现待优化
            ViewBag.Comments = CommentApplication.GetCommentsByProduct(model.Models.Select(p => p.ProductId));
            return(View(model.Models));
        }
コード例 #19
0
        /// <summary>
        /// 根据订单ID获取评价
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetComment(long orderId)
        {
            CheckUserLogin();
            var order   = OrderApplication.GetOrderInfo(orderId);
            var comment = OrderApplication.GetOrderCommentCount(order.Id);

            if (order != null && comment == 0)
            {
                var model = CommentApplication.GetProductEvaluationByOrderId(orderId, CurrentUser.Id).Select(item => new
                {
                    ProductId   = item.ProductId,
                    ProductName = item.ProductName,
                    Image       = Core.HimallIO.GetRomoteProductSizeImage(item.ThumbnailsUrl, 1, (int)Himall.CommonModel.ImageSize.Size_220) //商城App评论时获取商品图片
                });
                var orderitems      = OrderApplication.GetOrderItems(order.Id);
                var orderEvaluation = TradeCommentApplication.GetOrderCommentInfo(orderId, CurrentUser.Id);
                var isVirtual       = order.OrderType == Himall.Entities.OrderInfo.OrderTypes.Virtual ? 1 : 0;
                return(JsonResult <dynamic>(new { Product = model, orderItemIds = orderitems.Select(item => item.Id), isVirtual = isVirtual }));
            }
            else
            {
                return(Json(ErrorResult <dynamic>("该订单不存在或者已评论过")));
            }
        }
コード例 #20
0
 void AddProductsComment(long orderId, IEnumerable <ProductCommentModel> productComments)
 {
     foreach (var productComment in productComments)
     {
         Entities.ProductCommentInfo model = new Entities.ProductCommentInfo();
         model.ReviewDate    = DateTime.Now;
         model.ReviewContent = productComment.Content;
         model.UserId        = CurrentUser.Id;
         model.UserName      = CurrentUser.UserName;
         model.Email         = CurrentUser.Email;
         model.SubOrderId    = productComment.OrderItemId;
         model.ReviewMark    = productComment.Mark;
         model.ProductId     = productComment.ProductId;
         if (productComment.Images != null && productComment.Images.Length > 0)
         {
             model.ProductCommentImageInfo = productComment.Images.Select(item => new Entities.ProductCommentImageInfo
             {
                 CommentType  = 0,//0代表默认的表示评论的图片
                 CommentImage = MoveImages(item, CurrentUser.Id)
             }).ToList();
         }
         CommentApplication.AddComment(model);
     }
 }
コード例 #21
0
        public ActionResult AppendProductComment(string productCommentsJSON)
        {
            var productComments = JsonConvert.DeserializeObject <List <AppendCommentModel> >(productCommentsJSON);
            var comments        = CommentApplication.GetCommentss(productComments.Select(e => e.Id));

            foreach (var m in productComments)
            {
                var comment = comments.FirstOrDefault(e => e.Id == m.Id && !string.IsNullOrWhiteSpace(e.AppendContent));
                if (comment != null)
                {
                    return(Json(new Result()
                    {
                        success = false, msg = "您已追加过评价,不需要再重复操作!", status = -1
                    }));
                }
                m.UserId = CurrentUser.Id;
            }

            CommentApplication.Append(productComments);
            return(Json(new Result()
            {
                success = true, msg = "追加成功"
            }));
        }
コード例 #22
0
        /// <summary>
        /// 评价聚合
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult <Result <ProductCommentCountAggregateModel> > GetCommentCountAggregate(long id)
        {
            var data = CommentApplication.GetProductCommentStatistic(shopBranchId: id);

            return(JsonResult(data));
        }
コード例 #23
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
            }));
        }
コード例 #24
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));
        }
コード例 #25
0
        public object GetLimitBuyProduct(long id)
        {
            ProductDetailModelForMobie model = new ProductDetailModelForMobie()
            {
                Product = new ProductInfoModel(),
                Shop    = new ShopInfoModel(),
                Color   = new CollectionSKU(),
                Size    = new CollectionSKU(),
                Version = new CollectionSKU()
            };

            Entities.ProductInfo product = null;
            Entities.ShopInfo    shop    = null;
            FlashSaleModel       market  = null;

            market = ServiceProvider.Instance <ILimitTimeBuyService> .Create.Get(id);

            if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
            {
                //可能参数是商品ID
                market = market == null ? ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetFlaseSaleByProductId(id) : market;

                if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
                {
                    //跳转到404页面
                    throw new MallApiException("你所请求的限时购或者商品不存在!");
                }
            }

            if (market != null && (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing || DateTime.Parse(market.EndDate) < DateTime.Now))
            {
                return(new { success = true, IsValidLimitBuy = false });
            }

            model.MaxSaleCount = market.LimitCountOfThePeople;
            model.Title        = market.Title;

            product = ServiceProvider.Instance <IProductService> .Create.GetProduct(market.ProductId);

            bool hasSku = false;

            #region 商品SKU
            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;
            }
            var skus = ProductManagerApplication.GetSKUs(product.Id);
            if (skus.Count > 0)
            {
                hasSku = true;
                long colorId = 0, sizeId = 0, versionId = 0;
                foreach (var sku in skus)
                {
                    var specs = sku.Id.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 == sku.Color))
                            {
                                var c = skus.Where(s => s.Color == sku.Color).Sum(s => s.Stock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色" ,
                                    Name          = "选择" + colorAlias,
                                    EnabledClass  = c != 0 ? "enabled" : "disabled",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = 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 = skus.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码" ,
                                    Name         = "选择" + sizeAlias,
                                    EnabledClass = ss != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "",
                                    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 = skus.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择版本" ,
                                    Name         = "选择" + versionAlias,
                                    EnabledClass = v != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
            }
            #endregion

            #region 店铺
            shop = ServiceProvider.Instance <IShopService> .Create.GetShop(product.ShopId);

            var mark = Web.Framework.ShopServiceMark.GetShopComprehensiveMark(shop.Id);
            model.Shop.PackMark          = mark.PackMark;
            model.Shop.ServiceMark       = mark.ServiceMark;
            model.Shop.ComprehensiveMark = mark.ComprehensiveMark;
            model.Shop.Name        = shop.ShopName;
            model.Shop.ProductMark = CommentApplication.GetProductAverageMark(product.Id);
            model.Shop.Id          = product.ShopId;
            model.Shop.FreeFreight = shop.FreeFreight;
            model.Shop.ProductNum  = ServiceProvider.Instance <IProductService> .Create.GetShopOnsaleProducts(product.ShopId);


            var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(product.ShopId);

            var productAndDescription = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescription);
            var sellerServiceAttitude = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitude);
            var sellerDeliverySpeed   = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeed);

            var productAndDescriptionPeer = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionPeer);
            var sellerServiceAttitudePeer = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudePeer);
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.FirstOrDefault(c => c.CommentKey == StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedPeer);



            decimal defaultValue = 5;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null)
            {
                model.Shop.ProductAndDescription = productAndDescription.CommentValue;
            }
            else
            {
                model.Shop.ProductAndDescription = defaultValue;
            }
            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null)
            {
                model.Shop.SellerServiceAttitude = sellerServiceAttitude.CommentValue;
            }
            else
            {
                model.Shop.SellerServiceAttitude = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null)
            {
                model.Shop.SellerDeliverySpeed = sellerDeliverySpeed.CommentValue;
            }
            else
            {
                model.Shop.SellerDeliverySpeed = defaultValue;
            }
            if (ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id) == null)
            {
                model.Shop.VShopId = -1;
            }
            else
            {
                model.Shop.VShopId = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id).Id;
            }

            //优惠券
            var result = GetCouponList(shop.Id);//取设置的优惠券
            if (result != null)
            {
                var couponCount = result.Count();
                model.Shop.CouponCount = couponCount;
            }
            #endregion

            #region 商品
            var consultations = ServiceProvider.Instance <IConsultationService> .Create.GetConsultations(product.Id);

            var  comments   = CommentApplication.GetCommentsByProduct(product.Id);
            var  total      = comments.Count;
            var  niceTotal  = comments.Count(item => item.ReviewMark >= 4);
            bool isFavorite = false;
            if (CurrentUser == null)
            {
                isFavorite = false;
            }
            else
            {
                isFavorite = ServiceProvider.Instance <IProductService> .Create.IsFavorite(product.Id, CurrentUser.Id);
            }
            var limitBuy = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetLimitTimeMarketItemByProductId(product.Id);

            var productImage = new List <string>();

            var env = EngineContext.Current.Resolve <IWebHostEnvironment>();

            for (int i = 1; i < 6; i++)
            {
                if (System.IO.File.Exists(env.ContentRootPath + product.RelativePath + string.Format("/{0}.png", i)))
                {
                    productImage.Add(Core.MallIO.GetRomoteImagePath(product.RelativePath + string.Format("/{0}.png", i)));
                }
            }
            var desc = ProductManagerApplication.GetProductDescription(product.Id);
            model.Product = new ProductInfoModel()
            {
                ProductId          = product.Id,
                CommentCount       = CommentApplication.GetCommentCountByProduct(product.Id),
                Consultations      = consultations.Count(),
                ImagePath          = productImage,
                IsFavorite         = isFavorite,
                MarketPrice        = market.MinPrice,
                MinSalePrice       = product.MinSalePrice,
                NicePercent        = model.Shop.ProductMark == 0 ? 100 : (int)((niceTotal / total) * 100),
                ProductName        = product.ProductName,
                ProductSaleStatus  = product.SaleStatus,
                AuditStatus        = product.AuditStatus,
                ShortDescription   = product.ShortDescription,
                ProductDescription = desc.ShowMobileDescription,
                MeasureUnit        = product.MeasureUnit,
                IsOnLimitBuy       = limitBuy != null,
                VideoPath          = string.IsNullOrWhiteSpace(product.VideoPath) ? string.Empty : Mall.Core.MallIO.GetRomoteImagePath(product.VideoPath),
            };
            #endregion

            LogProduct(market.ProductId);
            //统计商品浏览量、店铺浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);

            TimeSpan end    = new TimeSpan(DateTime.Parse(market.EndDate).Ticks);
            TimeSpan start  = new TimeSpan(DateTime.Now.Ticks);
            TimeSpan ts     = end.Subtract(start);
            var      second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;

            return(new
            {
                success = true,
                IsOnLimitBuy = true,
                HasSku = hasSku,
                MaxSaleCount = market.LimitCountOfThePeople,
                Title = market.Title,
                Second = second,
                Product = model.Product,
                Shop = model.Shop,
                Color = model.Color.OrderBy(p => p.SkuId),
                Size = model.Size.OrderBy(p => p.SkuId),
                Version = model.Version.OrderBy(p => p.SkuId),
                ColorAlias = colorAlias,
                SizeAlias = sizeAlias,
                VersionAlias = versionAlias
            });
        }
コード例 #26
0
        public ActionResult Detail(string id)
        {
            LimitTimeBuyDetailModel detailModel = new LimitTimeBuyDetailModel();
            string price = "";

            #region 定义Model和变量

            LimitTimeProductDetailModel model = new LimitTimeProductDetailModel
            {
                MainId = long.Parse(id),
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Product      = new Entities.ProductInfo(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Color        = new CollectionSKU(),
                Size         = new CollectionSKU(),
                Version      = new CollectionSKU()
            };

            FlashSaleModel    market = null;
            Entities.ShopInfo shop   = null;

            long gid = 0, mid = 0;

            #endregion

            #region 商品Id不合法
            if (long.TryParse(id, out mid))
            {
            }
            if (mid == 0)
            {
                //跳转到出错页面
                return(RedirectToAction("Error404", "Error", new { area = "Mobile" }));
            }
            #endregion

            #region 初始化商品和店铺
            //参数是限时购活动ID
            try
            {
                market = _iLimitTimeBuyService.Get(mid);
            }
            catch
            {
                market = null;
            }
            if (market != null)
            {
                switch (market.Status)
                {
                case FlashSaleInfo.FlashSaleStatus.Ended:
                    return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));

                case FlashSaleInfo.FlashSaleStatus.Cancelled:
                    return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
                }

                model.FlashSale = market;
            }
            if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
            {
                //可能参数是商品ID
                market = market == null?_iLimitTimeBuyService.GetFlaseSaleByProductId(mid) : market;

                if (market == null)
                {
                    //跳转到404页面
                    return(RedirectToAction("Error404", "Error", new { area = "Mobile" }));
                }
                if (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
                {
                    return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
                }
                market = _iLimitTimeBuyService.Get(market.Id);
            }
            model.FlashSale = market;

            if (market != null && (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing || DateTime.Parse(market.EndDate) < DateTime.Now))
            {
                return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
            }

            model.MaxSaleCount = market.LimitCountOfThePeople;
            model.Title        = market.Title;

            shop = _iShopService.GetShop(market.ShopId);

            #endregion

            #region  存在的商品
            if (null == market || market.Id == 0)
            {
                //跳转到出错页面
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            #endregion

            #region 商品描述
            var product = _iProductService.GetProduct(market.ProductId);
            gid = market.ProductId;

            model.Product = product;
            var description = ProductManagerApplication.GetProductDescription(product.Id);
            model.ProductDescription = description.ShowMobileDescription;
            if (description.DescriptionPrefixId != 0)
            {
                var desc = _iProductDescriptionTemplateService
                           .GetTemplate(description.DescriptionPrefixId, product.ShopId);
                model.DescriptionPrefix = desc == null ? "" : desc.Content;
            }

            if (description.DescriptiondSuffixId != 0)
            {
                var desc = _iProductDescriptionTemplateService
                           .GetTemplate(description.DescriptiondSuffixId, product.ShopId);
                model.DescriptiondSuffix = desc == null ? "" : desc.Content;
            }

            var mark = ShopServiceMark.GetShopComprehensiveMark(shop.Id);
            model.Shop.PackMark          = mark.PackMark;
            model.Shop.ServiceMark       = mark.ServiceMark;
            model.Shop.ComprehensiveMark = mark.ComprehensiveMark;
            model.Shop.Name               = shop.ShopName;
            model.Shop.ProductMark        = CommentApplication.GetProductAverageMark(gid);
            model.Shop.Id                 = product.ShopId;
            model.Shop.FreeFreight        = shop.FreeFreight;
            detailModel.ProductNum        = _iProductService.GetShopOnsaleProducts(product.ShopId);
            detailModel.FavoriteShopCount = _iShopService.GetShopFavoritesCount(product.ShopId);
            if (CurrentUser == null)
            {
                detailModel.IsFavorite     = false;
                detailModel.IsFavoriteShop = false;
            }
            else
            {
                detailModel.IsFavorite = _iProductService.IsFavorite(product.Id, CurrentUser.Id);
                var favoriteShopIds = _iShopService.GetFavoriteShopInfos(CurrentUser.Id).Select(item => item.ShopId).ToArray();//获取已关注店铺
                detailModel.IsFavoriteShop = favoriteShopIds.Contains(product.ShopId);
            }
            #endregion

            #region 店铺分类

            var categories = _iShopCategoryService.GetShopCategory(product.ShopId);
            List <Entities.ShopCategoryInfo> allcate = categories.ToList();
            foreach (var main in allcate.Where(s => s.ParentCategoryId == 0))
            {
                var topC = new CategoryJsonModel()
                {
                    Name        = main.Name,
                    Id          = main.Id.ToString(),
                    SubCategory = new List <SecondLevelCategory>()
                };
                foreach (var secondItem in allcate.Where(s => s.ParentCategoryId == main.Id))
                {
                    var secondC = new SecondLevelCategory()
                    {
                        Name = secondItem.Name,
                        Id   = secondItem.Id.ToString(),
                    };

                    topC.SubCategory.Add(secondC);
                }
                model.ShopCategory.Add(topC);
            }

            #endregion

            #region 热门销售

            var sale = _iProductService.GetHotSaleProduct(shop.Id, 5);
            if (sale != null)
            {
                foreach (var item in sale.ToArray())
                {
                    model.HotSaleProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.SaleCounts + Mall.Core.Helper.TypeHelper.ObjectToInt(item.VirtualSaleCounts)
                    });
                }
            }

            #endregion

            #region 热门关注

            var hot = _iProductService.GetHotConcernedProduct(shop.Id, 5);
            if (hot != null)
            {
                foreach (var item in hot.ToArray())
                {
                    model.HotAttentionProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.ConcernedCount
                    });
                }
            }
            #endregion

            #region 商品规格

            Entities.TypeInfo typeInfo     = _iTypeService.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;
            var skus = ProductManagerApplication.GetSKUs(product.Id);
            if (skus.Count > 0)
            {
                long colorId = 0, sizeId = 0, versionId = 0;
                foreach (var sku in skus)
                {
                    var specs = sku.Id.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 = skus.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色",
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = Core.MallIO.GetImagePath(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 = skus.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码",
                                    Name         = "选择" + sizeAlias,
                                    EnabledClass = ss != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "",
                                    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 = skus.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择版本",
                                    Name         = "选择" + versionAlias,
                                    EnabledClass = v != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
                //var min = skus.Where(s => s.Stock >= 0).Min(s => s.SalePrice);
                //var max = skus.Where(s => s.Stock >= 0).Max(s => s.SalePrice);
                //if (min == 0 && max == 0)
                //{
                //    price = product.MinSalePrice.ToString("f2");
                //}
                //else if (max > min)
                //{
                //    price = string.Format("{0}-{1}", min.ToString("f2"), max.ToString("f2"));
                //}
                //else
                //{
                //    price = string.Format("{0}", min.ToString("f2"));
                //}
                price = ProductWebApplication.GetProductPriceStr2(product, skus);//最小价或区间价文本
            }
            detailModel.Price = string.IsNullOrWhiteSpace(price) ? product.MinSalePrice.ToString("f2") : price;
            #endregion

            #region 商品属性
            List <TypeAttributesModel> ProductAttrs = new List <TypeAttributesModel>();
            var prodAttrs = ProductManagerApplication.GetProductAttributes(product.Id);
            foreach (var attr in prodAttrs)
            {
                if (!ProductAttrs.Any(p => p.AttrId == attr.AttributeId))
                {
                    var attribute = _iTypeService.GetAttribute(attr.AttributeId);
                    var values    = _iTypeService.GetAttributeValues(attr.AttributeId);
                    TypeAttributesModel attrModel = new TypeAttributesModel()
                    {
                        AttrId     = attr.AttributeId,
                        AttrValues = new List <TypeAttrValue>(),
                        Name       = attribute.Name
                    };
                    foreach (var attrV in values)
                    {
                        if (prodAttrs.Any(p => p.ValueId == attrV.Id))
                        {
                            attrModel.AttrValues.Add(new TypeAttrValue
                            {
                                Id   = attrV.Id.ToString(),
                                Name = attrV.Value
                            });
                        }
                    }
                    ProductAttrs.Add(attrModel);
                }
                else
                {
                    var attrTemp = ProductAttrs.FirstOrDefault(p => p.AttrId == attr.AttributeId);
                    var values   = _iTypeService.GetAttributeValues(attr.AttributeId);
                    if (!attrTemp.AttrValues.Any(p => p.Id == attr.ValueId.ToString()))
                    {
                        attrTemp.AttrValues.Add(new TypeAttrValue
                        {
                            Id   = attr.ValueId.ToString(),
                            Name = values.FirstOrDefault(a => a.Id == attr.ValueId).Value
                        });
                    }
                }
            }
            detailModel.ProductAttrs = ProductAttrs;
            #endregion

            #region 获取评论、咨询数量

            var comments = CommentApplication.GetCommentsByProduct(product.Id);
            detailModel.CommentCount = comments.Count;

            var consultations = ServiceApplication.Create <IConsultationService>().GetConsultations(gid);

            var total     = comments.Count;
            var niceTotal = comments.Count(item => item.ReviewMark >= 4);
            detailModel.NicePercent   = (int)((niceTotal / (double)total) * 100);
            detailModel.Consultations = consultations.Count();

            if (_iVShopService.GetVShopByShopId(shop.Id) == null)
            {
                detailModel.VShopId = -1;
            }
            else
            {
                detailModel.VShopId = _iVShopService.GetVShopByShopId(shop.Id).Id;
            }
            #endregion

            #region 累加浏览次数、 加入历史记录
            //if (CurrentUser != null)
            //{
            //    BrowseHistrory.AddBrowsingProduct(product.Id, CurrentUser.Id);
            //}
            //else
            //{
            //    BrowseHistrory.AddBrowsingProduct(product.Id);
            //}
            //_iProductService.LogProductVisti(gid);
            #endregion

            #region 获取店铺的评价统计
            var shopStatisticOrderComments = _iShopService.GetShopStatisticOrderComments(product.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;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null && !shop.IsSelf)
            {
                detailModel.ProductAndDescription     = productAndDescription.CommentValue;
                detailModel.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                detailModel.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                detailModel.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                detailModel.ProductAndDescription     = defaultValue;
                detailModel.ProductAndDescriptionPeer = defaultValue;
                detailModel.ProductAndDescriptionMin  = defaultValue;
                detailModel.ProductAndDescriptionMax  = defaultValue;
            }
            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null && !shop.IsSelf)
            {
                detailModel.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                detailModel.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                detailModel.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                detailModel.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                detailModel.SellerServiceAttitude     = defaultValue;
                detailModel.SellerServiceAttitudePeer = defaultValue;
                detailModel.SellerServiceAttitudeMax  = defaultValue;
                detailModel.SellerServiceAttitudeMin  = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null && !shop.IsSelf)
            {
                detailModel.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                detailModel.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                detailModel.SellerDeliverySpeedMax  = sellerDeliverySpeedMax != null ? sellerDeliverySpeedMax.CommentValue : 0;
                detailModel.sellerDeliverySpeedMin  = sellerDeliverySpeedMin != null ? sellerDeliverySpeedMin.CommentValue : 0;
            }
            else
            {
                detailModel.SellerDeliverySpeed     = defaultValue;
                detailModel.SellerDeliverySpeedPeer = defaultValue;
                detailModel.SellerDeliverySpeedMax  = defaultValue;
                detailModel.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion

            #region 是否收藏此商品
            if (CurrentUser != null && CurrentUser.Id > 0)
            {
                model.IsFavorite = _iProductService.IsFavorite(product.Id, CurrentUser.Id);
            }
            else
            {
                model.IsFavorite = false;
            }
            #endregion

            long vShopId;
            var  vshopinfo = _iVShopService.GetVShopByShopId(shop.Id);
            if (vshopinfo == null)
            {
                vShopId = -1;
            }
            else
            {
                vShopId = vshopinfo.Id;
            }
            detailModel.VShopId = vShopId;
            model.Shop.VShopId  = vShopId;

            model.VShopLog = _iVShopService.GetVShopLog(model.Shop.VShopId);
            if (string.IsNullOrWhiteSpace(model.VShopLog))
            {
                //throw new Mall.Core.MallException("店铺未开通微店功能");
                model.VShopLog = SiteSettings.WXLogo;
            }
            detailModel.Logined = (null != CurrentUser) ? 1 : 0;
            model.EnabledBuy    = product.AuditStatus == Entities.ProductInfo.ProductAuditStatus.Audited && DateTime.Parse(market.BeginDate) <= DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now && product.SaleStatus == Entities.ProductInfo.ProductSaleStatus.OnSale;
            int saleCounts = 0;
            saleCounts = market.SaleCount;
            if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) < DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now)
            {
                TimeSpan end   = new TimeSpan(DateTime.Parse(market.EndDate).Ticks);
                TimeSpan start = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts    = end.Subtract(start);
                detailModel.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;
            }
            else if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) > DateTime.Now)
            {
                TimeSpan end   = new TimeSpan(DateTime.Parse(market.BeginDate).Ticks);
                TimeSpan start = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts    = end.Subtract(start);
                detailModel.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;
                saleCounts         = Mall.Core.Helper.TypeHelper.ObjectToInt(product.SaleCounts) + Mall.Core.Helper.TypeHelper.ObjectToInt(product.VirtualSaleCounts);
            }
            ViewBag.DetailModel = detailModel;

            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(market.ShopId);
            ViewBag.CustomerServices = customerServices;

            //统计商品浏览量、店铺浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);

            model.IsSaleCountOnOff = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1;                                          //是否显示销量
            model.SaleCount        = saleCounts;                                                                                              //销量
            model.FreightTemplate  = FreightTemplateApplication.GetFreightTemplate(product.FreightTemplateId);
            model.Freight          = FreightTemplateApplication.GetFreightStr(market.ProductId, model.FreightTemplate, CurrentUser, product); //运费或免运费
            model.StockAll         = market.Quantity;

            return(View(model));
        }
コード例 #27
0
        public object GetVShopSearchProducts(long vshopId,
                                             string keywords     = "", /* 搜索关键字 */
                                             string exp_keywords = "", /* 渐进搜索关键字 */
                                             long cid            = 0,  /* 分类ID */
                                             long b_id           = 0,  /* 品牌ID */
                                             string a_id         = "", /* 属性ID, 表现形式:attrId_attrValueId */
                                             int orderKey        = 1,  /* 排序项(1:默认,2:销量,3:价格,4:评论数,5:上架时间) */
                                             int orderType       = 1,  /* 排序方式(1:升序,2:降序) */
                                             int pageNo          = 1,  /*页码*/
                                             int pageSize        = 10  /*每页显示数据量*/
                                             )
        {
            long total;
            long shopId = -1;
            var  vshop  = ServiceProvider.Instance <IVShopService> .Create.GetVShop(vshopId);

            if (vshop != null)
            {
                shopId = vshop.ShopId;
            }

            if (!string.IsNullOrWhiteSpace(keywords))
            {
                keywords = keywords.Trim();
            }

            ProductSearch model = new ProductSearch()
            {
                shopId         = shopId,
                BrandId        = b_id,
                Ex_Keyword     = exp_keywords,
                Keyword        = keywords,
                OrderKey       = orderKey,
                OrderType      = orderType == 1,
                AttrIds        = new System.Collections.Generic.List <string>(),
                PageNumber     = pageNo,
                PageSize       = pageSize,
                ShopCategoryId = cid
            };

            var productsResult = ServiceProvider.Instance <IProductService> .Create.SearchProduct(model);

            total = productsResult.Total;
            var products = productsResult.Models.ToArray();

            var productsModel = products.Select(item =>
                                                new ProductItem()
            {
                Id        = item.Id,
                ImageUrl  = Core.MallIO.GetRomoteProductSizeImage(item.RelativePath, 1, (int)CommonModel.ImageSize.Size_350),
                SalePrice = item.MinSalePrice,
                Name      = item.ProductName,
                //TODO:FG 循环内调用
                CommentsCount = CommentApplication.GetProductCommentCount(item.Id),
            }
                                                );
            var bizCategories = ServiceProvider.Instance <IShopCategoryService> .Create.GetShopCategory(shopId);

            var shopCategories = GetSubCategories(bizCategories, 0, 0);

            //统计店铺访问人数
            StatisticApplication.StatisticShopVisitUserCount(vshop.ShopId);
            dynamic result = new ExpandoObject();

            result.ShopCategory = shopCategories;
            result.Products     = productsModel;
            result.VShopId      = vshopId;
            result.Keywords     = keywords;
            result.total        = total;
            return(Json(new { result }));
        }
コード例 #28
0
        /// <summary>
        /// 追加评论
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public ActionResult AppendComment(long orderId)
        {
            var model = CommentApplication.GetProductEvaluationByOrderIdNew(orderId, CurrentUser.Id);

            return(View(model));
        }
コード例 #29
0
        public ActionResult Detail(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            string price = "";

            #region 定义Model和变量

            LimitTimeProductDetailModel model = new LimitTimeProductDetailModel
            {
                MainId = long.Parse(id),
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Product      = new Entities.ProductInfo(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Color        = new CollectionSKU(),
                Size         = new CollectionSKU(),
                Version      = new CollectionSKU()
            };

            FlashSaleModel    market = null;
            Entities.ShopInfo shop   = null;

            long gid = 0, mid = 0;

            #endregion


            #region 商品Id不合法
            if (long.TryParse(id, out mid))
            {
            }
            if (mid == 0)
            {
                //跳转到出错页面
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            #endregion


            #region 初始化商品和店铺

            market = _iLimitTimeBuyService.Get(mid);

            switch (market.Status)
            {
            case Entities.FlashSaleInfo.FlashSaleStatus.Ended:
                return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));

            case Entities.FlashSaleInfo.FlashSaleStatus.Cancelled:
                return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
            }
            if (market.Status != Entities.FlashSaleInfo.FlashSaleStatus.Ongoing)
            {
                return(RedirectToAction("Home"));
            }
            model.FlashSale = market;
            if (market == null || market.Id == 0 || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
            {
                //可能参数是商品ID
                market = market == null?_iLimitTimeBuyService.GetFlaseSaleByProductId(mid) : market;

                if (market == null)
                {
                    //跳转到404页面
                    return(RedirectToAction("Error404", "Error", new { area = "Mobile" }));
                }
                if (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
                {
                    return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
                }
            }

            model.MaxSaleCount = market.LimitCountOfThePeople;
            model.Title        = market.Title;

            shop            = _iShopService.GetShop(market.ShopId);
            model.Shop.Name = shop.ShopName;
            #endregion

            #region 商品描述
            var product = _iProductService.GetProduct(market.ProductId);
            gid = market.ProductId;


            var brandModel = ServiceApplication.Create <IBrandService>().GetBrand(product.BrandId);
            product.BrandName = brandModel == null ? "" : brandModel.Name;
            if (CurrentUser != null && CurrentUser.Id > 0)
            {
                product.IsFavorite = ProductManagerApplication.IsFavorite(product.Id, CurrentUser.Id);
            }
            model.Product = product;
            model.Skus    = ProductManagerApplication.GetSKUsByProduct(new List <long> {
                product.Id
            });
            var description = ProductManagerApplication.GetProductDescription(product.Id);
            model.ProductDescription = description.Description;
            if (description.DescriptionPrefixId != 0)
            {
                var desc = _iProductDescriptionTemplateService
                           .GetTemplate(description.DescriptionPrefixId, product.ShopId);
                model.DescriptionPrefix = desc == null ? "" : desc.Content;
            }

            if (description.DescriptiondSuffixId != 0)
            {
                var desc = _iProductDescriptionTemplateService
                           .GetTemplate(description.DescriptiondSuffixId, product.ShopId);
                model.DescriptiondSuffix = desc == null ? "" : desc.Content;
            }

            #endregion

            #region 店铺

            var categories = _iShopCategoryService.GetShopCategory(product.ShopId);
            List <Entities.ShopCategoryInfo> allcate = categories.ToList();
            foreach (var main in allcate.Where(s => s.ParentCategoryId == 0))
            {
                var topC = new CategoryJsonModel()
                {
                    Name        = main.Name,
                    Id          = main.Id.ToString(),
                    SubCategory = new List <SecondLevelCategory>()
                };
                foreach (var secondItem in allcate.Where(s => s.ParentCategoryId == main.Id))
                {
                    var secondC = new SecondLevelCategory()
                    {
                        Name = secondItem.Name,
                        Id   = secondItem.Id.ToString(),
                    };

                    topC.SubCategory.Add(secondC);
                }
                model.ShopCategory.Add(topC);
            }
            model.CashDeposits = _iCashDepositsService.GetCashDepositsObligation(product.Id);

            #endregion

            #region 热门销售

            //会员折扣
            decimal discount   = 1M;
            long    SelfShopId = 0;
            if (CurrentUser != null)
            {
                discount = CurrentUser.MemberDiscount;
                var shopInfo = ShopApplication.GetSelfShop();
                SelfShopId = shopInfo.Id;
            }
            var sale = _iProductService.GetHotSaleProduct(shop.Id, 5);
            if (sale != null)
            {
                foreach (var item in sale.ToArray())
                {
                    var salePrice = item.MinSalePrice;
                    if (item.ShopId == SelfShopId)
                    {
                        salePrice = item.MinSalePrice * discount;
                    }
                    var limitBuy = LimitTimeApplication.GetLimitTimeMarketItemByProductId(item.Id);
                    if (limitBuy != null)
                    {
                        salePrice = limitBuy.MinPrice;
                    }
                    model.HotSaleProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = Math.Round(salePrice, 2),
                        Id        = item.Id,
                        SaleCount = (int)item.SaleCounts + Mall.Core.Helper.TypeHelper.ObjectToInt(item.VirtualSaleCounts)
                    });
                }
            }

            #endregion

            #region 热门关注

            var hot = _iProductService.GetHotConcernedProduct(shop.Id, 5);
            if (hot != null)
            {
                foreach (var item in hot.ToArray())
                {
                    model.HotAttentionProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.ConcernedCount
                    });
                }
            }
            #endregion

            #region 商品规格

            Entities.TypeInfo typeInfo     = _iTypeService.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;
            var skus = _iProductService.GetSKUs(product.Id);
            if (skus.Count > 0)
            {
                long colorId = 0, sizeId = 0, versionId = 0;
                foreach (var sku in skus)
                {
                    var specs = sku.Id.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 = skus.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色",
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = Mall.Core.MallIO.GetImagePath(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 = skus.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码",
                                    Name         = "选择" + sizeAlias,
                                    EnabledClass = ss != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "",
                                    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 = skus.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择版本",
                                    Name         = "选择" + versionAlias,
                                    EnabledClass = v != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }

                price = ProductWebApplication.GetProductPriceStr(product, skus, discount);//最小价或区间价文本
            }
            model.Price = string.IsNullOrWhiteSpace(price) ? product.MinSalePrice.ToString("f2") : price;
            #endregion

            #region 商品属性
            List <TypeAttributesModel> ProductAttrs = new List <TypeAttributesModel>();
            var prodAttrs = ProductManagerApplication.GetProductAttributes(product.Id);
            foreach (var attr in prodAttrs)
            {
                if (!ProductAttrs.Any(p => p.AttrId == attr.AttributeId))
                {
                    var attribute = _iTypeService.GetAttribute(attr.AttributeId);
                    var values    = _iTypeService.GetAttributeValues(attr.AttributeId);
                    var attrModel = new TypeAttributesModel()
                    {
                        AttrId     = attr.AttributeId,
                        AttrValues = new List <TypeAttrValue>(),
                        Name       = attribute.Name
                    };
                    foreach (var attrV in values)
                    {
                        if (prodAttrs.Any(p => p.ValueId == attrV.Id))
                        {
                            attrModel.AttrValues.Add(new TypeAttrValue
                            {
                                Id   = attrV.Id.ToString(),
                                Name = attrV.Value
                            });
                        }
                    }
                    ProductAttrs.Add(attrModel);
                }
                else
                {
                    var attrTemp = ProductAttrs.FirstOrDefault(p => p.AttrId == attr.AttributeId);
                    var values   = _iTypeService.GetAttributeValues(attr.AttributeId);
                    if (!attrTemp.AttrValues.Any(p => p.Id == attr.ValueId.ToString()))
                    {
                        attrTemp.AttrValues.Add(new TypeAttrValue
                        {
                            Id   = attr.ValueId.ToString(),
                            Name = values.FirstOrDefault(a => a.Id == attr.ValueId).Value
                        });
                    }
                }
            }
            model.ProductAttrs = ProductAttrs;
            #endregion

            #region 获取评论、咨询数量

            model.CommentCount = CommentApplication.GetCommentCountByProduct(product.Id);

            var consultations = _iConsultationService.GetConsultations(gid);
            model.Consultations = consultations.Count();

            #endregion

            #region 累加浏览次数、 加入历史记录
            if (CurrentUser != null)
            {
                BrowseHistrory.AddBrowsingProduct(product.Id, CurrentUser.Id);
            }
            else
            {
                BrowseHistrory.AddBrowsingProduct(product.Id);
            }

            //_iProductService.LogProductVisti(gid);
            //统计商品浏览量、店铺浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);
            #endregion

            #region 红包
            var bonus = ServiceApplication.Create <IShopBonusService>().GetByShopId(product.ShopId);
            if (bonus != null)
            {
                model.GrantPrice = bonus.GrantPrice;
            }
            else
            {
                model.GrantPrice = 0;
            }
            #endregion

            #region 获取店铺的评价统计

            var shopStatisticOrderComments = _iShopService.GetShopStatisticOrderComments(shop.Id);

            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;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null)
            {
                ViewBag.ProductAndDescription     = productAndDescription.CommentValue;
                ViewBag.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                ViewBag.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                ViewBag.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                ViewBag.ProductAndDescription     = defaultValue;
                ViewBag.ProductAndDescriptionPeer = defaultValue;
                ViewBag.ProductAndDescriptionMin  = defaultValue;
                ViewBag.ProductAndDescriptionMax  = defaultValue;
            }
            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null)
            {
                ViewBag.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                ViewBag.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                ViewBag.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                ViewBag.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                ViewBag.SellerServiceAttitude     = defaultValue;
                ViewBag.SellerServiceAttitudePeer = defaultValue;
                ViewBag.SellerServiceAttitudeMax  = defaultValue;
                ViewBag.SellerServiceAttitudeMin  = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null)
            {
                ViewBag.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                ViewBag.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                ViewBag.SellerDeliverySpeedMax  = sellerDeliverySpeedMax.CommentValue;
                ViewBag.sellerDeliverySpeedMin  = sellerDeliverySpeedMin.CommentValue;
            }
            else
            {
                ViewBag.SellerDeliverySpeed     = defaultValue;
                ViewBag.SellerDeliverySpeedPeer = defaultValue;
                ViewBag.SellerDeliverySpeedMax  = defaultValue;
                ViewBag.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion

            #region 客服
            model.Service = ServiceApplication.Create <ICustomerService>().GetCustomerService(shop.Id).Where(c => c.Type == Entities.CustomerServiceInfo.ServiceType.PreSale && c.TerminalType == Entities.CustomerServiceInfo.ServiceTerminalType.PC).OrderBy(m => m.Tool);
            #endregion

            #region 开团提醒场景二维码
            var siteSetting = SiteSettingApplication.SiteSettings;
            if (DateTime.Parse(model.FlashSale.BeginDate) > DateTime.Now && WXIsConfig(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret))
            {
                try
                {
                    var         token   = AccessTokenContainer.TryGetAccessToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret);
                    SceneHelper helper  = new SceneHelper();
                    SceneModel  scene   = new SceneModel(QR_SCENE_Type.FlashSaleRemind, model.FlashSale.Id);
                    int         sceneId = helper.SetModel(scene);
                    var         ticket  = QrCodeApi.Create(token, 86400, sceneId, Senparc.Weixin.MP.QrCode_ActionName.QR_LIMIT_SCENE, null).ticket;
                    ViewBag.ticket = ticket;
                }
                catch { }
            }
            #endregion

            model.Logined    = (null != CurrentUser) ? 1 : 0;
            model.EnabledBuy = product.AuditStatus == Entities.ProductInfo.ProductAuditStatus.Audited && DateTime.Parse(market.BeginDate) <= DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now && product.SaleStatus == Entities.ProductInfo.ProductSaleStatus.OnSale;
            if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) < DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now)
            {
                TimeSpan end   = new TimeSpan(DateTime.Parse(market.EndDate).Ticks);
                TimeSpan start = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts    = end.Subtract(start);
                model.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;
            }
            else if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) > DateTime.Now)
            {
                TimeSpan end   = new TimeSpan(DateTime.Parse(market.BeginDate).Ticks);
                TimeSpan start = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts    = end.Subtract(start);
                model.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;
            }

            //补充当前店铺红包功能
            ViewBag.isShopPage     = true;
            ViewBag.CurShopId      = product.ShopId;
            TempData["isShopPage"] = true;
            TempData["CurShopId"]  = product.ShopId;

            ViewBag.Keyword          = SiteSettings.Keyword;
            ViewBag.Quantity         = market.Quantity;//总活动库存
            model.VirtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(product.Id);
            model.FreightTemplate    = FreightTemplateApplication.GetFreightTemplate(product.FreightTemplateId);
            return(View(model));
        }
コード例 #30
0
        /// <summary>
        /// 门店列表
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetStoreList(string fromLatLng, string keyWords = "", long?tagsId = null, long?shopId = null, int pageNo = 1, int pageSize = 10)
        {
            //TODO:FG 异常查询 MysqlExecuted:226,耗时:1567.4137毫秒
            CheckOpenStore();
            ShopBranchQuery query = new ShopBranchQuery();

            query.PageNo                  = pageNo;
            query.PageSize                = pageSize;
            query.Status                  = ShopBranchStatus.Normal;
            query.ShopBranchName          = keyWords.Trim();
            query.ShopBranchTagId         = tagsId;
            query.CityId                  = -1;
            query.FromLatLng              = fromLatLng;
            query.OrderKey                = 2;
            query.OrderType               = true;
            query.ShopBranchProductStatus = ShopBranchSkuStatus.Normal;
            if (query.FromLatLng.Split(',').Length != 2)
            {
                throw new HimallException("无法获取您的当前位置,请确认是否开启定位服务!");
            }
            if (shopId.HasValue)
            {
                //var shop = ShopApplication.GetShopInfo(shopId.Value);
                var isFreeze = ShopApplication.IsFreezeShop(shopId.Value);
                if (isFreeze)
                {
                    return(Json(ErrorResult <dynamic>(msg: "此店铺已冻结")));
                }
                else
                {
                    var isExpired = ShopApplication.IsExpiredShop(shopId.Value);
                    if (isExpired)
                    {
                        return(Json(ErrorResult <dynamic>(msg: "此店铺已过期")));
                    }
                }
            }
            string address = "", province = "", city = "", district = "", street = "";
            string currentPosition = string.Empty;//当前详情地址,优先顺序:建筑、社区、街道
            Region cityInfo        = new Region();

            if (shopId.HasValue)//如果传入了商家ID,则只取商家下门店
            {
                query.ShopId = shopId.Value;
                if (query.ShopId <= 0)
                {
                    throw new HimallException("无法定位到商家!");
                }
            }
            else//否则取用户同城门店
            {
                var addressObj = ShopbranchHelper.GetAddressByLatLng(query.FromLatLng, ref address, ref province, ref city, ref district, ref street);
                if (string.IsNullOrWhiteSpace(city))
                {
                    city = province;
                }
                if (string.IsNullOrWhiteSpace(city))
                {
                    throw new HimallException("无法定位到城市!");
                }
                cityInfo = RegionApplication.GetRegionByName(city, Region.RegionLevel.City);
                if (cityInfo == null)
                {
                    throw new HimallException("无法定位到城市!");
                }
                if (cityInfo != null)
                {
                    query.CityId = cityInfo.Id;
                }
                //处理当前地址
                currentPosition = street;
            }
            var shopBranchs = ShopBranchApplication.SearchNearShopBranchs(query);
            //组装首页数据
            //补充门店活动数据
            var homepageBranchs = ProcessBranchHomePageData(shopBranchs.Models);

            AutoMapper.Mapper.CreateMap <HomePageShopBranch, HomeGetStoreListModel>();
            var  homeStores = AutoMapper.Mapper.Map <List <HomePageShopBranch>, List <HomeGetStoreListModel> >(homepageBranchs);
            long userId     = 0;

            if (CurrentUser != null)
            {//如果已登陆取购物车数据
                //memberCartInfo = CartApplication.GetShopBranchCart(CurrentUser.Id);
                userId = CurrentUser.Id;
            }
            //统一处理门店购物车数量
            var cartItemCount = ShopBranchApplication.GetShopBranchCartItemCount(userId, homeStores.Select(e => e.ShopBranch.Id).ToList());

            foreach (var item in homeStores)
            {
                //商品
                ShopBranchProductQuery proquery = new ShopBranchProductQuery();
                proquery.PageSize = 4;
                proquery.PageNo   = 1;
                proquery.OrderKey = 3;
                if (!string.IsNullOrWhiteSpace(keyWords))
                {
                    proquery.KeyWords = keyWords;
                }
                proquery.ShopBranchId            = item.ShopBranch.Id;
                proquery.ShopBranchProductStatus = ShopBranchSkuStatus.Normal;
                //proquery.FilterVirtualProduct = true;
                var pageModel = ShopBranchApplication.GetShopBranchProducts(proquery);
                var dtNow     = DateTime.Now;
                //var saleCountByMonth = OrderApplication.GetSaleCount(dtNow.AddDays(-30).Date, dtNow, shopBranchId: proquery.ShopBranchId.Value);
                item.SaleCount        = OrderApplication.GetSaleCount(shopBranchId: proquery.ShopBranchId.Value);
                item.SaleCountByMonth = ShopBranchApplication.GetShopBranchSaleCount(item.ShopBranch.Id, dtNow.AddDays(-30).Date, dtNow);
                item.ShowProducts     = pageModel.Models.Select(p =>
                {
                    var comcount = CommentApplication.GetProductHighCommentCount(productId: p.Id, shopBranchId: proquery.ShopBranchId.Value);
                    return(new HomeGetStoreListProductModel
                    {
                        Id = p.Id,
                        DefaultImage = HimallIO.GetRomoteProductSizeImage(p.ImagePath, 1, ImageSize.Size_150.GetHashCode()),
                        MinSalePrice = p.MinSalePrice,
                        ProductName = p.ProductName,
                        HasSKU = p.HasSKU,
                        MarketPrice = p.MarketPrice,
                        SaleCount = Himall.Core.Helper.TypeHelper.ObjectToInt(p.VirtualSaleCounts) + OrderApplication.GetSaleCount(dtNow.AddDays(-30).Date, dtNow, shopBranchId: proquery.ShopBranchId.Value, productId: p.Id),
                        HighCommentCount = comcount,
                    });
                }).ToList();
                item.ProductCount = pageModel.Total;
                if (cartItemCount != null)
                {
                    item.CartQuantity = cartItemCount.ContainsKey(item.ShopBranch.Id) ? cartItemCount[item.ShopBranch.Id] : 0;
                }
                //评分
                item.CommentScore = ShopBranchApplication.GetServiceMark(item.ShopBranch.Id).ComprehensiveMark;
            }
            return(JsonResult <dynamic>(new
            {
                Total = shopBranchs.Total,
                CityInfo = new { Id = cityInfo.Id, Name = cityInfo.Name },
                CurrentAddress = currentPosition,
                Stores = homeStores,
                ProductSaleCountOnOff = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1
            }));
        }