Ejemplo n.º 1
0
        /// <summary>
        /// 添加评论
        /// </summary>
        /// <param name="result"></param>
        public void AddProductComment(ref string result)
        {
            int    productID      = RequestHelper.GetQueryString <int>("ProductID");
            int    orderID        = RequestHelper.GetQueryString <int>("OrderID");
            string commentCookies = CookiesHelper.ReadCookieValue("CommentCookies" + productID.ToString());

            if (ShopConfig.ReadConfigInfo().CommentRestrictTime > 0 && commentCookies != string.Empty)
            {
                result = "请不要频繁提交";
            }
            else
            {
                ProductCommentInfo productComment = new ProductCommentInfo();
                productComment.ProductId         = productID;
                productComment.Title             = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Title"));
                productComment.Content           = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Content"));
                productComment.UserIP            = ClientHelper.IP;
                productComment.PostDate          = RequestHelper.DateNow;
                productComment.Support           = 0;
                productComment.Against           = 0;
                productComment.Status            = ShopConfig.ReadConfigInfo().CommentDefaultStatus;
                productComment.Rank              = RequestHelper.GetQueryString <int>("Rank");
                productComment.ReplyCount        = 0;
                productComment.AdminReplyContent = string.Empty;
                productComment.AdminReplyDate    = RequestHelper.DateNow;
                productComment.UserId            = base.UserId;
                productComment.UserName          = base.UserName;
                productComment.OrderId           = orderID;
                ProductCommentBLL.Add(productComment);
                if (ShopConfig.ReadConfigInfo().CommentRestrictTime > 0)
                {
                    CookiesHelper.AddCookie("CommentCookies" + productID.ToString(), "CommentCookies" + productID.ToString(), ShopConfig.ReadConfigInfo().CommentRestrictTime, TimeType.Second);
                }
            }
        }
Ejemplo n.º 2
0
        public ActionResult AddProductComment(int productID, int orderID)
        {
            string commentCookies = CookiesHelper.ReadCookieValue("CommentCookies" + productID.ToString());

            if (ShopConfig.ReadConfigInfo().CommentRestrictTime > 0 && commentCookies != string.Empty)
            {
                return(Content("请不要频繁提交"));
            }
            else
            {
                var procomList = ProductCommentBLL.SearchProductCommentList(new ProductCommentSearchInfo()
                {
                    OrderID = orderID, ProductId = productID, UserId = uid
                });
                if (procomList.Count > 0)
                {
                    return(Content("已经提交过相关评论"));
                }
                ProductCommentInfo productComment = new ProductCommentInfo();
                productComment.ProductId         = productID;
                productComment.Title             = StringHelper.AddSafe(RequestHelper.GetForm <string>("Title"));
                productComment.Content           = StringHelper.AddSafe(RequestHelper.GetForm <string>("Content"));
                productComment.UserIP            = ClientHelper.IP;
                productComment.PostDate          = RequestHelper.DateNow;
                productComment.Support           = 0;
                productComment.Against           = 0;
                productComment.Status            = ShopConfig.ReadConfigInfo().CommentDefaultStatus;
                productComment.Rank              = RequestHelper.GetForm <int>("Rank");
                productComment.ReplyCount        = 0;
                productComment.AdminReplyContent = string.Empty;
                productComment.AdminReplyDate    = RequestHelper.DateNow;
                productComment.UserId            = uid;
                productComment.UserName          = user.UserName;
                productComment.OrderId           = orderID;
                int pcid = ProductCommentBLL.Add(productComment);
                if (ShopConfig.ReadConfigInfo().CommentRestrictTime > 0)
                {
                    CookiesHelper.AddCookie("CommentCookies" + productID.ToString(), "CommentCookies" + productID.ToString(), ShopConfig.ReadConfigInfo().CommentRestrictTime, TimeType.Second);
                }

                return(Content("ok|" + pcid));
            }
        }
Ejemplo n.º 3
0
        private void Submit()
        {
            string urlPrefix = string.IsNullOrEmpty(isMobile) ? "/user" : "/mobile";

            if (base.UserId < 1)
            {
                ResponseHelper.Write("error|登录状态已过期,请重新登录|" + urlPrefix + "/login.html");
                ResponseHelper.End();
            }

            int orderId = RequestHelper.GetForm <int>("orderId");

            if (ProductCommentBLL.HasCommented(orderId, base.UserId))
            {
                ResponseHelper.Write("error|订单已评价|" + urlPrefix + "/userproductcomment.html");
                ResponseHelper.End();
            }

            order = OrderBLL.Read(orderId, base.UserId);
            if (order.Id < 1)
            {
                ResponseHelper.Write("error|订单不存在|" + urlPrefix + "/order.html");
                ResponseHelper.End();
            }

            orderDetailList = OrderDetailBLL.ReadList(orderId);

            List <ProductCommentInfo> productCommentList = new List <ProductCommentInfo>();

            foreach (OrderDetailInfo orderDetail in orderDetailList)
            {
                int    rank    = RequestHelper.GetForm <int>("rank_" + orderDetail.ProductId);
                string content = StringHelper.AddSafe(RequestHelper.GetForm <string>("content_" + orderDetail.ProductId));

                if (rank >= 1 && rank <= 5 && !string.IsNullOrEmpty(content))
                {
                    ProductCommentInfo productComment = new ProductCommentInfo();
                    productComment.ProductId         = orderDetail.ProductId;
                    productComment.Title             = "";
                    productComment.Content           = content;
                    productComment.UserIP            = ClientHelper.IP;
                    productComment.PostDate          = RequestHelper.DateNow;
                    productComment.Support           = 0;
                    productComment.Against           = 0;
                    productComment.Status            = ShopConfig.ReadConfigInfo().CommentDefaultStatus;
                    productComment.Rank              = rank;
                    productComment.ReplyCount        = 0;
                    productComment.AdminReplyContent = string.Empty;
                    productComment.AdminReplyDate    = RequestHelper.DateNow;
                    productComment.UserId            = base.UserId;
                    productComment.UserName          = base.UserName;
                    productComment.OrderId           = order.Id;
                    productComment.BuyDate           = order.AddDate;

                    productCommentList.Add(productComment);
                }
                else
                {
                    ResponseHelper.Write("error|评价失败|" + urlPrefix + "/userproductcommentAdd.html?orderid=" + order.Id);
                    ResponseHelper.End();
                }
            }

            foreach (ProductCommentInfo comment in productCommentList)
            {
                ProductCommentBLL.Add(comment);
            }

            ResponseHelper.Write("ok|评价成功|" + urlPrefix + "/userproductcomment.html");
            ResponseHelper.End();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 提交数据
        /// </summary>
        protected override void PostBack()
        {
            string url = "";

            if (Request.RawUrl.ToLower().IndexOf("/mobile/") >= 0)
            {
                url = "/mobile/";
            }
            else
            {
                url = "/User/";
            }
            if (base.UserId > 0)
            {
                int orderID = RequestHelper.GetForm <int>("OrderID");

                order           = OrderBLL.Read(orderID, base.UserId);
                orderDetailList = OrderDetailBLL.ReadList(orderID);

                if (order.Id > 0)
                {
                    if (ProductCommentBLL.SearchProductCommentList(new ProductCommentSearchInfo {
                        OrderID = order.Id
                    }).Count <= 0)
                    {
                        List <ProductCommentInfo> productCommentList = new List <ProductCommentInfo>();
                        foreach (OrderDetailInfo orderDetail in orderDetailList)
                        {
                            if (RequestHelper.GetForm <int>("pid_" + orderDetail.ProductId) > 0)
                            {
                                proID = RequestHelper.GetForm <int>("pid_" + orderDetail.ProductId);
                            }
                        }
                        //foreach (OrderDetailInfo orderDetail in orderDetailList)
                        //{
                        int    rank    = RequestHelper.GetForm <int>("rank_" + proID);
                        string title   = StringHelper.AddSafe(RequestHelper.GetForm <string>("title_" + proID));
                        string content = StringHelper.AddSafe(RequestHelper.GetForm <string>("content_" + proID));

                        //   ProductInfo product = ProductBLL.ReadProduct(orderDetail.ProductID);
                        ProductInfo product = ProductBLL.Read(proID);
                        if (rank >= 1 && rank <= 5 && content != string.Empty)
                        {
                            ProductCommentInfo productComment = new ProductCommentInfo();
                            //   productComment.ProductID = orderDetail.ProductID;
                            productComment.ProductId         = proID;
                            productComment.Title             = title;
                            productComment.Content           = content;
                            productComment.UserIP            = ClientHelper.IP;
                            productComment.PostDate          = RequestHelper.DateNow;
                            productComment.Support           = 0;
                            productComment.Against           = 0;
                            productComment.Status            = ShopConfig.ReadConfigInfo().CommentDefaultStatus;
                            productComment.Rank              = rank;
                            productComment.ReplyCount        = 0;
                            productComment.AdminReplyContent = string.Empty;
                            productComment.AdminReplyDate    = RequestHelper.DateNow;
                            productComment.UserId            = base.UserId;
                            productComment.UserName          = base.UserName;
                            productComment.OrderId           = order.Id;
                            productComment.BuyDate           = order.AddDate;
                            productCommentList.Add(productComment);
                        }
                        else
                        {
                            ResponseHelper.Redirect(url + "CommentOrderProduct-O" + order.Id + ".html");
                        }
                        //}

                        foreach (ProductCommentInfo comment in productCommentList)
                        {
                            ProductCommentBLL.Add(comment);
                        }

                        ResponseHelper.Redirect(url + "UserProductComment.html");
                    }
                    else
                    {
                        ResponseHelper.Redirect(url + "UserProductComment.html");
                    }
                }
                else
                {
                    ResponseHelper.Redirect(url + "Order.html");
                }
            }
            else
            {
                ResponseHelper.Redirect(url + "Login.html");
            }
        }