Ejemplo n.º 1
0
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SaveReview(Jinher.AMP.BTP.Deploy.CustomDTO.ReviewSDTO reviewSDTO, System.Guid appId)
        {
            //定义返回值
            Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO result;

            try
            {
                //调用代理方法
                result = base.Channel.SaveReview(reviewSDTO, appId);
            }
            catch
            {
                //抛异常
                throw;
            }
            finally
            {
                //关链接
                ChannelClose();
            }            //返回结果
            return(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 添加评价
 /// <para>Service Url: http://devbtp.sv.iuoooo.com/Jinher.AMP.BTP.SV.ReviewSV.svc/SaveReview
 /// </para>
 /// </summary>
 /// <param name="reviewSDTO">评价实体</param>
 /// <param name="appId">appId</param>
 /// <returns></returns>
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SaveReview(Jinher.AMP.BTP.Deploy.CustomDTO.ReviewSDTO reviewSDTO, System.Guid appId)
 {
     base.Do();
     return(this.Command.SaveReview(reviewSDTO, appId));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加评价
        /// </summary>
        /// <param name="reviewSDTO">评价实体</param>
        /// <param name="appId">appId</param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SaveReviewExt
            (Jinher.AMP.BTP.Deploy.CustomDTO.ReviewSDTO reviewSDTO, System.Guid appId)
        {
            try
            {
                if (reviewSDTO == null || reviewSDTO.UserId == Guid.Empty || reviewSDTO.OrderItemId == Guid.Empty)
                {
                    return new ResultDTO {
                               ResultCode = 1, Message = "参数错误!"
                    }
                }
                ;

                if (string.IsNullOrWhiteSpace(reviewSDTO.Details))
                {
                    return(new ResultDTO {
                        ResultCode = 1, Message = "参数错误,评价内容不能为空!"
                    });
                }
                if (Review.ObjectSet().Any(c => c.UserId == reviewSDTO.UserId && c.OrderItemId == reviewSDTO.OrderItemId))
                {
                    return(new ResultDTO {
                        ResultCode = 1, Message = "已评价!"
                    });
                }

                var orderitem = OrderItem.ObjectSet().FirstOrDefault(n => n.Id == reviewSDTO.OrderItemId);
                if (orderitem != null)
                {
                    ContextSession contextSession = ContextFactory.CurrentThreadContext;

                    Review review = new Review();
                    review.Id                  = Guid.NewGuid();
                    review.EntityState         = System.Data.EntityState.Added;
                    review.Name                = "评价";
                    review.UserId              = reviewSDTO.UserId;
                    review.UserName            = reviewSDTO.Name ?? string.Empty;
                    review.UserHeader          = reviewSDTO.UserHead;
                    review.Content             = reviewSDTO.Details;
                    review.CommodityId         = orderitem.CommodityId;
                    review.AppId               = appId;
                    review.OrderItemId         = orderitem.Id;
                    review.CommodityName       = orderitem.Name;
                    review.CommodityPicture    = orderitem.PicturesPath;
                    review.CommodityAttributes = orderitem.CommodityAttributes;
                    contextSession.SaveObject(review);

                    orderitem.AlreadyReview = true;
                    contextSession.SaveObject(orderitem);

                    //增加商品评价数
                    Commodity com = Commodity.ObjectSet().FirstOrDefault(n => n.Id == orderitem.CommodityId);
                    if (com != null)
                    {
                        com.TotalReview += 1;
                        contextSession.SaveObject(com);
                    }

                    contextSession.SaveChanges();

                    if (com != null)
                    {
                        com.RefreshCache(EntityState.Modified);
                    }
                    var esAppId = CommodityOrder.ObjectSet().Where(t => t.Id == orderitem.CommodityOrderId).Select(t => t.EsAppId).FirstOrDefault();
                    if (esAppId.HasValue)
                    {
                        bool giveResult = SignSV.Instance.GiveScoreBtpComment(review.UserId, esAppId.Value, reviewSDTO.SourceUrl, orderitem.CommodityOrderId, orderitem.Code, review.Id);
                        if (!giveResult)
                        {
                            return(new ResultDTO {
                                ResultCode = 1, Message = "评价加积分错误"
                            });
                        }
                    }
                }
                else
                {
                    return(new ResultDTO {
                        ResultCode = 1, Message = "Error"
                    });
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("添加评价服务异常。reviewSDTO:{0},appId:{1}", JsonHelper.JsonSerializer(reviewSDTO), appId), ex);
                return(new ResultDTO {
                    ResultCode = 1, Message = "Error"
                });
            }
            return(new ResultDTO {
                ResultCode = 0, Message = "Success"
            });
        }