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 = "评价成功"
            }));
        }
        /// <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));
        }
        /// <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));
        }
        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));
        }
Example #5
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));
            }
        }
        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));
        }
        /// <summary>
        /// 追加评论
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public ActionResult AppendComment(long orderId)
        {
            var model = CommentApplication.GetProductEvaluationByOrderIdNew(orderId, CurrentUser.Id);

            return(View(model));
        }