예제 #1
0
        /// <summary>
        /// 创建评论
        /// </summary>
        /// <returns></returns>
        public JsonResult CreateReview()
        {
            Product_ReviewDetail info = new Product_ReviewDetail();

            info.ProductSysNo = int.Parse(Request["ProductSysNo"].ToString());
            info.Title        = Request["Title"].ToString();
            info.Prons        = Request["Prons"].ToString();
            //info.Cons = Request["Cons"].ToString();
            //info.Service = Request["Service"].ToString();
            info.Image = Request["Image"].ToString();
            int tempso = int.Parse(Request["SoSysNo"].ToString());

            if (tempso != 0 && tempso > 0)
            {
                info.SOSysno = tempso;
            }
            decimal s1 = Convert.ToDecimal(string.IsNullOrEmpty(Request["Score1"].ToString()) == true ? "5" : Request["Score1"].ToString());
            decimal s2 = Convert.ToDecimal(string.IsNullOrEmpty(Request["Score2"].ToString()) == true ? "5" : Request["Score2"].ToString());
            decimal s3 = Convert.ToDecimal(string.IsNullOrEmpty(Request["Score3"].ToString()) == true ? "5" : Request["Score3"].ToString());
            decimal s4 = Convert.ToDecimal(string.IsNullOrEmpty(Request["Score4"].ToString()) == true ? "5" : Request["Score4"].ToString());

            info.Score1 = Convert.ToInt32(s1);
            info.Score2 = Convert.ToInt32(s2);
            info.Score3 = Convert.ToInt32(s3);
            info.Score4 = Convert.ToInt32(s4);

            info.CustomerInfo.SysNo = this.CurrUser.UserSysNo;
            info.ReviewType         = ReviewType.Common;
            bool IsSuccess = ReviewFacade.CreateProductReview(info);

            if (IsSuccess)
            {
                return(new JsonResult()
                {
                    Data = 1
                });
            }
            else
            {
                return(new JsonResult()
                {
                    Data = 0
                });
            }
        }
예제 #2
0
        /// <summary>
        /// 发表评论检查
        /// </summary>
        public static void CreateReviewPreCheck(Product_ReviewDetail reviewInfo)
        {
            if (reviewInfo.ProductSysNo <= 0)
            {
                throw new BusinessException("商品信息错误");
            }

            if (String.IsNullOrEmpty(reviewInfo.Title))
            {
                throw new BusinessException("评论标题不能为空!");
            }
            else if (reviewInfo.Title.Length > 40)
            {
                throw new BusinessException("标题长度不能大于40!");
            }

            if (String.IsNullOrEmpty(reviewInfo.Prons))
            {
                throw new BusinessException("评论优点不能为空!");
            }
            else if (reviewInfo.Prons.Length > 300)
            {
                throw new BusinessException("评论有点长度不能大于300!");
            }

            if (!String.IsNullOrEmpty(reviewInfo.Cons) && reviewInfo.Cons.Length > 300)
            {
                throw new BusinessException("评论缺点长度不能大于300!");
            }

            if (!String.IsNullOrEmpty(reviewInfo.Service) && reviewInfo.Service.Length > 300)
            {
                throw new BusinessException("评论服务长度不能大于300!");
            }

            //if (!String.IsNullOrEmpty(reviewInfo.Image))
            //{
            //    if (reviewInfo.Image.Split('|').Length > Int32.Parse(ResourceHelper.GetParam("WebUpload_ImageCountlimit_Rview")))
            //    {
            //        throw new BusinessException("FeedBackE0019");
            //    }
            //}
        }
예제 #3
0
        /// <summary>
        /// 获取评论详情
        /// </summary>
        /// <param name="queryInfo"></param>
        /// <returns></returns>
        public static Product_ReviewDetail GetProductReviewInfo(Product_ReviewQueryInfo queryInfo)
        {
            Product_ReviewDetail productReviewDetail = ReviewDA.GetProductReviewInfo(queryInfo);

            if (productReviewDetail != null)
            {
                productReviewDetail.Cons    = CommonFacade.SetCannotOnlineWordsMask(productReviewDetail.Cons);
                productReviewDetail.Prons   = CommonFacade.SetCannotOnlineWordsMask(productReviewDetail.Prons);
                productReviewDetail.Service = CommonFacade.SetCannotOnlineWordsMask(productReviewDetail.Service);
                if (productReviewDetail.ReplieList != null)
                {
                    foreach (var reply in productReviewDetail.ReplieList)
                    {
                        reply.Content = CommonFacade.SetCannotOnlineWordsMask(reply.Content);
                    }
                }
            }
            return(productReviewDetail);
        }
예제 #4
0
파일: ReviewDA.cs 프로젝트: sanlonezhang/ql
        /// <summary>
        /// 发表评论
        /// </summary>
        /// <param name="reviewInfo"></param>
        /// <returns></returns>
        public static bool CreateProductReview(Product_ReviewDetail reviewInfo)
        {
            bool        result      = false;
            DataCommand dataCommand = DataCommandManager.GetDataCommand("CreateProductReview");

            dataCommand.SetParameterValue("@ProductSysNo", reviewInfo.ProductSysNo);
            dataCommand.SetParameterValue("@CustomerSysNo", reviewInfo.CustomerInfo.SysNo);
            dataCommand.SetParameterValue("@Title", reviewInfo.Title);
            dataCommand.SetParameterValue("@Prons", reviewInfo.Prons);
            dataCommand.SetParameterValue("@Cons", reviewInfo.Cons);
            dataCommand.SetParameterValue("@Service", reviewInfo.Service);
            dataCommand.SetParameterValue("@Score", reviewInfo.Score);
            dataCommand.SetParameterValue("@Image", reviewInfo.Image);
            dataCommand.SetParameterValue("@Score1", reviewInfo.Score1);
            dataCommand.SetParameterValue("@Score2", reviewInfo.Score2);
            dataCommand.SetParameterValue("@Score3", reviewInfo.Score3);
            dataCommand.SetParameterValue("@Score4", reviewInfo.Score4);
            dataCommand.SetParameterValue("@ReviewType", reviewInfo.ReviewType);
            dataCommand.SetParameterValue("@SOSysNo", reviewInfo.SOSysno);
            SetCommandDefaultParameters(dataCommand);
            result = dataCommand.ExecuteNonQuery() > 0;

            return(result);
        }
예제 #5
0
        /// <summary>
        /// 发表评论 评分计算
        /// </summary>
        public static Product_ReviewDetail ReviewScoreCalculator(Product_ReviewDetail reviewInfo)
        {
            reviewInfo.Score = Convert.ToDecimal((((decimal)reviewInfo.Score1 + (decimal)reviewInfo.Score2 + (decimal)reviewInfo.Score3 + (decimal)reviewInfo.Score4) / 4).ToString("f1"));

            return(reviewInfo);
        }
예제 #6
0
        /// <summary>
        /// 发表评论
        /// </summary>
        /// <param name="reviewInfo"></param>
        /// <returns></returns>
        public static bool CreateProductReview(Product_ReviewDetail reviewInfo)
        {
            string   cacheKey     = CommonFacade.GenerateKey("CreateProductReview", reviewInfo.CustomerInfo.SysNo.ToString(), reviewInfo.ProductSysNo.ToString());
            DateTime now          = DateTime.Now;
            int      nowTimePoint = now.Hour * 3600 + now.Minute * 60 + now.Second;

            if (HttpRuntime.Cache[cacheKey] != null)
            {
                int preTimePoint = (int)HttpRuntime.Cache[cacheKey];
                if (nowTimePoint - preTimePoint < 60)
                {
                    throw new BusinessException("很抱歉,您发表评论的频率过快,请稍后再试。");
                }
            }
            else
            {
                HttpRuntime.Cache.Insert(cacheKey, 0, null, DateTime.Now.AddSeconds(CacheTime.Shortest), Cache.NoSlidingExpiration);
            }

            bool result = false;

            #region 二期修改不用此方法
            ////根据用户customer以及商品编号获取订单编号以及商品code
            //List<Product_TempSOinfo> tempsoinfo = ReviewDA.GetSoSysNoAndProductCode(reviewInfo.CustomerInfo.SysNo, reviewInfo.ProductSysNo);
            //if (tempsoinfo != null && tempsoinfo.Count > 0)
            //{
            //    CreateReviewPreCheck(reviewInfo);
            //    ReviewScoreCalculator(reviewInfo);
            //    //取消15天的检查
            //    //CheckCreateReviewByDays(reviewInfo.ProductSysNo, reviewInfo.CustomerInfo.SysNo);

            //    //检查当前订单号是否已评论
            //    if (reviewInfo.SOSysno != null && reviewInfo.SOSysno > 0)
            //    {
            //        Product_TempSOinfo temp = tempsoinfo.SingleOrDefault(p => p.SOSysNo == reviewInfo.SOSysno);
            //        if (temp != null)
            //        {
            //            bool isReview = ReviewDA.CheckReviewBySoSysNo(reviewInfo.SOSysno);
            //            if (isReview)
            //            {
            //                throw new BusinessException("当前订单已经参与过评论!");
            //            }
            //        }
            //        else
            //        {
            //            throw new BusinessException("须购买过此商品且订单已完成才能发表评论!");
            //        }
            //    }
            //    else
            //    {
            //        reviewInfo.SOSysno = tempsoinfo[0].SOSysNo;
            //    }
            //    //reviewInfo.SOSysno = tempsoinfo.SOSysNo;
            //    result = ReviewDA.CreateProductReview(reviewInfo);
            //}
            //else
            //{
            //    throw new BusinessException("须购买过此商品且订单已完成才能发表评论!");
            //}
            #endregion

            //根据用户customer以及商品编号获取-----该用户所有订单编号以及商品code
            List <Product_TempSOinfo> tempsoinfo = ReviewDA.GetCustomerSoSysNoAndProductCode(reviewInfo.CustomerInfo.SysNo, reviewInfo.ProductSysNo);
            if (tempsoinfo != null && tempsoinfo.Count > 0)
            {
                CreateReviewPreCheck(reviewInfo);
                ReviewScoreCalculator(reviewInfo);
                Product_TempSOinfo temp = tempsoinfo.SingleOrDefault(p => p.SOSysNo == reviewInfo.SOSysno);
                if (temp != null)
                {
                    //检查当前订单号是否已经完成两次评论
                    int num = ReviewDA.CheckReviewedBySoSysNo(temp.SOSysNo, reviewInfo.ProductSysNo);
                    if (num > 1)
                    {
                        throw new BusinessException("当前订单已经参与过两次评论!");
                    }
                    else
                    {
                        result = ReviewDA.CreateProductReview(reviewInfo);
                    }
                }
                else
                {
                    throw new BusinessException("须购买过此商品且订单已完成才能发表评论!");
                }
            }
            else
            {
                throw new BusinessException("须购买过此商品且订单已完成才能发表评论!");
            }
            if (result)
            {
                now          = DateTime.Now;
                nowTimePoint = now.Hour * 3600 + now.Minute * 60 + now.Second;
                HttpRuntime.Cache[cacheKey] = nowTimePoint;
            }

            return(result);
        }
예제 #7
0
파일: ReviewDA.cs 프로젝트: sanlonezhang/ql
        /// <summary>
        /// 获取品论详情
        /// </summary>
        /// <param name="queryInfo"></param>
        /// <returns></returns>
        public static Product_ReviewDetail GetProductReviewInfo(Product_ReviewQueryInfo queryInfo)
        {
            DataCommand dataCommand = DataCommandManager.GetDataCommand("ProductReview_GetProductReviewInfoBySysNo");

            dataCommand.SetParameterValue("@SysNo", queryInfo.ReviewSysNo);
            dataCommand.SetParameterValue("@PageSize", queryInfo.PagingInfo.PageSize);
            dataCommand.SetParameterValue("@PageIndex", queryInfo.PagingInfo.PageIndex);
            SetCommandDefaultParameters(dataCommand);
            DataSet              result      = dataCommand.ExecuteDataSet();
            DataTable            masterTable = result.Tables[0];
            Product_ReviewDetail reviewInfo  = new Product_ReviewDetail();

            if (masterTable.Rows != null && masterTable.Rows.Count > 0)
            {
                reviewInfo = DataMapper.GetEntity <Product_ReviewDetail>(masterTable.Rows[0]);
                Product_ReviewMaster masterscore = GetProductReviewMaster(reviewInfo.ProductSysNo);
                if (masterscore != null && reviewInfo != null)
                {
                    reviewInfo.AvgScore = masterscore.AvgScore;

                    reviewInfo.ReviewCount = masterscore.ReviewCount;
                }
                DataTable itemTable = result.Tables[1];
                if (itemTable.Rows != null && itemTable.Rows.Count > 0)
                {
                    DataRow[] itemRows = itemTable.Select("ReviewSysNo=" + reviewInfo.SysNo);
                    DataTable newdt    = new DataTable();
                    newdt = itemTable.Clone();
                    foreach (DataRow row in itemRows)
                    {
                        newdt.ImportRow(row);
                    }
                    if (newdt != null && newdt.Rows.Count > 0)
                    {
                        List <Product_ReplyDetail> replyList = DataMapper.GetEntityList <Product_ReplyDetail, List <Product_ReplyDetail> >(newdt.Rows);
                        int totalCount    = Convert.ToInt32(dataCommand.GetParameterValue("@TotalCount"));
                        int webTotalCount = Convert.ToInt32(dataCommand.GetParameterValue("@WebTotalCount"));
                        int pageIndex     = queryInfo.PagingInfo.PageIndex;
                        if ((pageIndex * queryInfo.PagingInfo.PageSize) > totalCount)
                        {
                            if (totalCount != 0 && (totalCount % queryInfo.PagingInfo.PageSize) == 0)
                            {
                                pageIndex = (int)(totalCount / queryInfo.PagingInfo.PageSize);
                            }
                            else
                            {
                                pageIndex = (int)(totalCount / queryInfo.PagingInfo.PageSize) + 1;
                            }
                        }
                        //网友回复
                        reviewInfo.Replies = new PagedResult <Product_ReplyDetail>(webTotalCount, queryInfo.PagingInfo.PageSize, pageIndex, replyList.FindAll(f => f.ReplyType == FeedbackReplyType.Web));

                        //厂商和买家回复
                        reviewInfo.ReplieList =
                            replyList.FindAll(f => f.ReplyType == FeedbackReplyType.Manufacturer || f.ReplyType == FeedbackReplyType.Newegg);
                        //reviewInfo.ReplieList.Sort((a, b) => b.ReplyType.CompareTo(a.ReplyType));
                    }
                }

                if (result.Tables.Count > 2)
                {
                    DataTable scoreNameTable = result.Tables[2];
                    if (scoreNameTable.Rows != null && scoreNameTable.Rows.Count > 0 && reviewInfo != null)
                    {
                        reviewInfo.ScoreNameList = new List <string>();
                        foreach (DataRow row in scoreNameTable.Rows)
                        {
                            reviewInfo.ScoreNameList.Add(row["Name"].ToString());
                        }
                    }
                }
            }
            return(reviewInfo);
        }