public void ProcessRequest(HttpContext context) { RequestModel requestModel = bllReview.ConvertRequestToModel <RequestModel>(new RequestModel()); if (string.IsNullOrWhiteSpace(requestModel.for_id)) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "评论对象Id为空"; bllReview.ContextResponse(context, apiResp); return; } BLLJIMP.Model.ReviewInfo review = new BLLJIMP.Model.ReviewInfo(); review.AuditStatus = 0; review.ForeignkeyId = requestModel.for_id; review.Expand1 = requestModel.ex_id; review.UserId = CurrentUserInfo.UserID; review.UserName = bllUser.GetUserDispalyName(CurrentUserInfo); review.ReviewScore = requestModel.score; review.ReviewContent = requestModel.content; review.InsertDate = DateTime.Now; review.ReviewType = requestModel.type; review.ReviewTitle = requestModel.title; review.WebsiteOwner = bllReview.WebsiteOwner; review.IsHideUserName = 0; review.ReviewMainId = int.Parse(bllReview.GetGUID(TransacType.CommAdd)); review.CommentImg = requestModel.comment_img; review.Ex2 = requestModel.order_detail_id; if (bllReview.Add(review)) { if (review.ReviewType == "OrderComment" && !string.IsNullOrWhiteSpace(review.Expand1)) //更新 平均分 评分人数 { var total = 0; List <BLLJIMP.Model.ReviewInfo> sourceData = bllReview.GetActReviewList(out total, 1, 0, "", "", "", "OrderComment", review.Expand1, "0", "AutoId"); double reviewAvgScore = bllReview.GetReviewAvgScore(bllReview.WebsiteOwner, "", "OrderComment", review.Expand1, "0"); bllReview.Update(new BLLJIMP.Model.WXMallProductInfo(), string.Format("ReviewCount='{0}',ReviewScore='{1}'", total, reviewAvgScore), string.Format("PID='{0}' And WebsiteOwner='{1}' ", review.Expand1, bllReview.WebsiteOwner)); bllReview.Update(new BLLJIMP.Model.WXMallOrderInfo(), string.Format("ReviewScore='{0}'", review.ReviewScore), string.Format("OrderID='{0}' And WebsiteOwner='{1}' ", review.ForeignkeyId, bllReview.WebsiteOwner)); } apiResp.status = true; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsSuccess; apiResp.msg = "评论完成"; BLLRedis.ClearReviewList(bllReview.WebsiteOwner); } else { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "评论失败"; } bllReview.ContextResponse(context, apiResp); }
/// <summary> /// 保存回复 /// </summary> /// <param name="context"></param> /// <returns></returns> private string ReplyReviewInfo(HttpContext context) { string reviewId = context.Request["ReviewID"]; string replyContent = context.Request["ReplyContent"]; string parentId = context.Request["AutoId"]; if (string.IsNullOrEmpty(replyContent)) { resp.Status = -1; resp.Msg = "回复内容不能为空"; } bool isSuccess = bllJuactivity.Add(new BLLJIMP.Model.ReplyReviewInfo() { ReviewID = Convert.ToInt32(reviewId), ReplyContent = replyContent, PraentId = Convert.ToInt32(parentId), UserId = currentUserInfo.UserID, UserName = currentUserInfo.TrueName, InsertDate = DateTime.Now, }); BLLJIMP.Model.ReviewInfo review = bllJuactivity.Get <BLLJIMP.Model.ReviewInfo>(" AutoId=" + reviewId); if (isSuccess) { if (review != null) { review.NumCount++; bllJuactivity.Update(review); } resp.Status = 0; resp.Msg = "添加成功"; } else { resp.Status = 0; resp.Msg = "添加失败"; } return(Common.JSONHelper.ObjectToJson(resp)); }
/// <summary> /// 发表话题 /// </summary> /// <param name="context"></param> /// <returns></returns> private string Add(HttpContext context) { string title = context.Request["title"]; string content = context.Request["content"]; if (string.IsNullOrEmpty(title)) { resp.Msg = "标题不能为空"; return(Common.JSONHelper.ObjectToJson(resp)); } if (string.IsNullOrEmpty(content)) { resp.Msg = "内容不能为空"; return(Common.JSONHelper.ObjectToJson(resp)); } BLLJIMP.Model.ReviewInfo model = new BLLJIMP.Model.ReviewInfo { ForeignkeyId = bll.WebsiteOwner, ForeignkeyName = bll.WebsiteOwner, UserId = this.currentUserInfo.UserID, UserName = this.currentUserInfo.TrueName, ReviewPower = 0, InsertDate = DateTime.Now, ReviewTitle = title, ReviewContent = content, WebsiteOwner = bll.WebsiteOwner, PraiseNum = 0, StepNum = 0, AuditStatus = 1, ReviewType = "话题", CategoryType = "", ReplyDateTiem = DateTime.Now }; if (bll.Add(model)) { resp.Status = 1; resp.Msg = "发布成功"; } return(Common.JSONHelper.ObjectToJson(resp)); }