private static IOrderNOSQLStrategy _ordernosql = BMAData.OrderNOSQL;//订单非关系型数据库 #region 辅助方法 /// <summary> /// 从IDataReader创建ProductReviewInfo /// </summary> public static ProductReviewInfo BuildProductReviewFromReader(IDataReader reader) { ProductReviewInfo productReviewInfo = new ProductReviewInfo(); productReviewInfo.ReviewId = TypeHelper.ObjectToInt(reader["reviewid"]); productReviewInfo.Pid = TypeHelper.ObjectToInt(reader["pid"]); productReviewInfo.Uid = TypeHelper.ObjectToInt(reader["uid"]); productReviewInfo.OPRId = TypeHelper.ObjectToInt(reader["oprid"]); productReviewInfo.Oid = TypeHelper.ObjectToInt(reader["oid"]); productReviewInfo.ParentId = TypeHelper.ObjectToInt(reader["parentid"]); productReviewInfo.State = TypeHelper.ObjectToInt(reader["state"]); productReviewInfo.StoreId = TypeHelper.ObjectToInt(reader["storeid"]); productReviewInfo.Star = TypeHelper.ObjectToInt(reader["star"]); productReviewInfo.Quality = TypeHelper.ObjectToInt(reader["quality"]); productReviewInfo.Message = reader["message"].ToString(); productReviewInfo.ReviewTime = TypeHelper.ObjectToDateTime(reader["reviewtime"]); productReviewInfo.PayCredits = TypeHelper.ObjectToInt(reader["paycredits"]); productReviewInfo.PName = reader["pname"].ToString(); productReviewInfo.PShowImg = reader["pshowimg"].ToString(); productReviewInfo.BuyTime = TypeHelper.ObjectToDateTime(reader["buytime"]); productReviewInfo.IP = reader["ip"].ToString(); return productReviewInfo; }
/// <summary> /// 评价商品 /// </summary> public void ReviewProduct(ProductReviewInfo productReviewInfo) { DbParameter[] parms = { GenerateInParam("@pid", SqlDbType.Int, 4, productReviewInfo.Pid), GenerateInParam("@uid", SqlDbType.Int, 4, productReviewInfo.Uid), GenerateInParam("@oprid", SqlDbType.Int, 4, productReviewInfo.OPRId), GenerateInParam("@oid", SqlDbType.Int, 4, productReviewInfo.Oid), GenerateInParam("@parentid", SqlDbType.Int, 4, productReviewInfo.ParentId), GenerateInParam("@state", SqlDbType.TinyInt, 1, productReviewInfo.State), GenerateInParam("@storeid", SqlDbType.Int, 4, productReviewInfo.StoreId), GenerateInParam("@star", SqlDbType.TinyInt, 1, productReviewInfo.Star), GenerateInParam("@quality", SqlDbType.SmallInt, 4, productReviewInfo.Quality), GenerateInParam("@message", SqlDbType.NVarChar, 200, productReviewInfo.Message), GenerateInParam("@reviewtime", SqlDbType.DateTime, 8, productReviewInfo.ReviewTime), GenerateInParam("@paycredits", SqlDbType.Int, 4, productReviewInfo.PayCredits), GenerateInParam("@pname", SqlDbType.NVarChar, 200, productReviewInfo.PName), GenerateInParam("@pshowimg", SqlDbType.NVarChar, 100, productReviewInfo.PShowImg), GenerateInParam("@buytime", SqlDbType.DateTime, 8, productReviewInfo.BuyTime), GenerateInParam("@ip", SqlDbType.VarChar, 15, productReviewInfo.IP) }; RDBSHelper.ExecuteNonQuery(CommandType.StoredProcedure, string.Format("{0}reviewproduct", RDBSHelper.RDBSTablePre), parms); }
/// <summary> /// 评价商品 /// </summary> public ActionResult ReviewProduct() { int oid = WebHelper.GetQueryInt("oid");//订单id int recordId = WebHelper.GetQueryInt("recordId");//订单商品记录id int star = WebHelper.GetFormInt("star");//星星 string message = WebHelper.GetFormString("message");//评价内容 if (star > 5 || star < 0) return AjaxResult("wrongstar", "请选择正确的星星"); if (message.Length == 0) return AjaxResult("emptymessage", "请填写评价内容"); if (message.Length > 100) return AjaxResult("muchmessage", "评价内容最多输入100个字"); //禁止词 string bannedWord = FilterWords.GetWord(message); if (bannedWord != "") return AjaxResult("bannedWord", "评价内容中不能包含违禁词"); OrderInfo orderInfo = Orders.GetOrderByOid(oid); if (orderInfo == null || orderInfo.Uid != WorkContext.Uid) return AjaxResult("noexistorder", "订单不存在"); if (orderInfo.OrderState != (int)OrderState.Completed) return AjaxResult("nocomplete", "订单还未完成,不能评价"); OrderProductInfo orderProductInfo = null; List<OrderProductInfo> orderProductList = Orders.GetOrderProductList(oid); foreach (OrderProductInfo item in orderProductList) { if (item.RecordId == recordId) { orderProductInfo = item; break; } } if (orderProductInfo == null) return AjaxResult("noproduct", "商品不存在"); //商品已评价 if (orderProductInfo.IsReview == 1) return AjaxResult("reviewed", "商品已经评价"); int payCredits = Credits.SendReviewProductCredits(ref WorkContext.PartUserInfo, orderProductInfo, DateTime.Now); ProductReviewInfo productReviewInfo = new ProductReviewInfo() { Pid = orderProductInfo.Pid, Uid = orderProductInfo.Uid, OPRId = orderProductInfo.RecordId, Oid = orderProductInfo.Oid, ParentId = 0, State = 0, StoreId = orderProductInfo.StoreId, Star = star, Quality = 0, Message = WebHelper.HtmlEncode(FilterWords.HideWords(message)), ReviewTime = DateTime.Now, PayCredits = payCredits, PName = orderProductInfo.Name, PShowImg = orderProductInfo.ShowImg, BuyTime = orderProductInfo.AddTime, IP = WorkContext.IP }; ProductReviews.ReviewProduct(productReviewInfo); orderProductInfo.IsReview = 1; if (Orders.IsReviewAllOrderProduct(orderProductList) && Stores.GetStoreReviewByOid(oid) != null) Orders.UpdateOrderIsReview(oid, 1); return AjaxResult("success", recordId.ToString()); }
/// <summary> /// 评价商品 /// </summary> public static void ReviewProduct(ProductReviewInfo productReviewInfo) { BrnMall.Data.ProductReviews.ReviewProduct(productReviewInfo); }
/// <summary> /// 评价商品 /// </summary> public static void ReviewProduct(ProductReviewInfo productReviewInfo) { BrnMall.Core.BMAData.RDBS.ReviewProduct(productReviewInfo); if (_ordernosql != null) _ordernosql.ReviewProduct(productReviewInfo.Oid, productReviewInfo.ReviewId); }