private void AutoOrderComment(List <OrderInfo> orders)
 {
     foreach (var order in orders)
     {
         OrderCommentInfo info = new OrderCommentInfo();
         info.UserId       = order.UserId;
         info.PackMark     = 5;
         info.DeliveryMark = 5;
         info.ServiceMark  = 5;
         info.OrderId      = order.Id;
         info.ShopId       = order.ShopId;
         info.ShopName     = order.ShopName;
         info.UserName     = order.UserName;
         info.CommentDate  = DateTime.Now;
         Context.OrderCommentInfo.Add(info);
         Context.SaveChanges();
         //MemberIntegralRecord record = new MemberIntegralRecord();
         //record.UserName = info.UserName;
         //record.ReMark = "预约单号:" + info.OrderId;
         //record.MemberId = info.UserId;
         //record.RecordDate = DateTime.Now;
         //record.TypeId = MemberIntegral.IntegralType.Comment;
         //MemberIntegralRecordAction action = new MemberIntegralRecordAction();
         //action.VirtualItemTypeId = MemberIntegral.VirtualItemType.Comment;
         //action.VirtualItemId = info.OrderId;
         //record.Himall_MemberIntegralRecordAction.Add(action);
         //var memberIntegral = ServiceProvider.Instance<IMemberIntegralConversionFactoryService>.Create.Create(MemberIntegral.IntegralType.Comment);
         //ServiceProvider.Instance<IMemberIntegralService>.Create.AddMemberIntegral(record, memberIntegral);
     }
 }
        public ActionResult Index(long id)
        {
            IList <ProductEvaluation> productEvaluationByOrderId = ServiceHelper.Create <ICommentService>().GetProductEvaluationByOrderId(id, base.CurrentUser.Id);
            OrderCommentInfo          orderCommentInfo           = ServiceHelper.Create <ITradeCommentService>().GetOrderCommentInfo(id, base.CurrentUser.Id);

            if (orderCommentInfo == null)
            {
                ViewBag.Mark = 0;
            }
            else
            {
                ViewBag.Mark = Math.Round((double)(orderCommentInfo.PackMark + orderCommentInfo.ServiceMark + orderCommentInfo.DeliveryMark) / 3);
            }
            ViewBag.OrderId = id;
            dynamic viewBag = base.ViewBag;
            long    shopId  = ServiceHelper.Create <IOrderService>().GetOrder(id).ShopId;

            viewBag.IsSellerAdminProdcut = shopId.Equals(1);

            foreach (var item in productEvaluationByOrderId)
            {
                item.ThumbnailsUrl = ServiceHelper.Create <IProductService>().GetProduct(item.ProductId) == null ? "" : (ServiceHelper.Create <IProductService>().GetProduct(item.ProductId).ImagePath == null ? "" : ServiceHelper.Create <IProductService>().GetProduct(item.ProductId).ImagePath);
            }
            return(View(productEvaluationByOrderId));
        }
Exemple #3
0
        public JsonResult AddOrderEvaluationAndComment(int PackMark, int DeliveryMark, int ServiceMark, long OrderId, string productCommentsJSON)
        {
            using (TransactionScope transactionScope = new TransactionScope())
            {
                if (PackMark != 0 || DeliveryMark != 0 || ServiceMark != 0)
                {
                    OrderCommentInfo orderCommentInfo = new OrderCommentInfo()
                    {
                        UserId       = base.CurrentUser.Id,
                        PackMark     = PackMark,
                        DeliveryMark = DeliveryMark,
                        ServiceMark  = ServiceMark,
                        OrderId      = OrderId
                    };
                    List <ProductCommentsModel> productCommentsModels = JsonConvert.DeserializeObject <List <ProductCommentsModel> >(productCommentsJSON);
                    ServiceHelper.Create <ITradeCommentService>().AddOrderComment(orderCommentInfo);
                    foreach (ProductCommentsModel productCommentsModel in productCommentsModels)
                    {
                        ProductCommentInfo productCommentInfo = new ProductCommentInfo()
                        {
                            ReviewDate    = DateTime.Now,
                            ReviewContent = productCommentsModel.content,
                            UserId        = base.CurrentUser.Id,
                            UserName      = base.CurrentUser.UserName,
                            Email         = base.CurrentUser.Email,
                            SubOrderId    = new long?(productCommentsModel.subOrderId),
                            ReviewMark    = productCommentsModel.star
                        };
                        ServiceHelper.Create <ICommentService>().AddComment(productCommentInfo);
                    }
                }
                else
                {
                    foreach (ProductCommentsModel productCommentsModel1 in JsonConvert.DeserializeObject <List <ProductCommentsModel> >(productCommentsJSON))
                    {
                        ProductCommentInfo productCommentInfo1 = new ProductCommentInfo()
                        {
                            ReviewDate    = DateTime.Now,
                            ReviewContent = productCommentsModel1.content,
                            UserId        = base.CurrentUser.Id,
                            UserName      = base.CurrentUser.UserName,
                            Email         = base.CurrentUser.Email,
                            SubOrderId    = new long?(productCommentsModel1.subOrderId),
                            ReviewMark    = productCommentsModel1.star
                        };
                        ServiceHelper.Create <ICommentService>().AddComment(productCommentInfo1);
                    }
                }
                transactionScope.Complete();
            }
            Result result = new Result()
            {
                success = true,
                msg     = "Evaluated Success"
            };

            return(Json(result));
        }
Exemple #4
0
        public JsonResult AddOrderEvaluation(OrderCommentInfo info)
        {
            info.UserId = base.CurrentUser.Id;
            ServiceHelper.Create <ITradeCommentService>().AddOrderComment(info);
            Result result = new Result()
            {
                success = true,
                msg     = "Evaluated Success"
            };

            return(Json(result));
        }
Exemple #5
0
        public ActionResult Details(long orderId)
        {
            OrderCommentInfo orderCommentInfo = ServiceHelper.Create <ITradeCommentService>().GetOrderCommentInfo(orderId, base.CurrentUser.Id);

            base.ViewBag.PackMark     = (orderCommentInfo != null ? orderCommentInfo.PackMark - 1 : -1);
            base.ViewBag.DeliveryMark = (orderCommentInfo != null ? orderCommentInfo.DeliveryMark - 1 : -1);
            base.ViewBag.ServiceMark  = (orderCommentInfo != null ? orderCommentInfo.ServiceMark - 1 : -1);
            IList <ProductEvaluation> productEvaluationByOrderIdNew = ServiceHelper.Create <ICommentService>().GetProductEvaluationByOrderIdNew(orderId, base.CurrentUser.Id);
            dynamic viewBag = base.ViewBag;
            long    shopId  = ServiceHelper.Create <IOrderService>().GetOrder(orderId).ShopId;

            viewBag.IsSellerAdminProdcut = shopId.Equals(1);
            return(View(productEvaluationByOrderIdNew));
        }
Exemple #6
0
        private void AddOrderComment(OrderCommentModel comment)
        {
            ITradeCommentService tradeCommentService = ServiceHelper.Create <ITradeCommentService>();
            OrderCommentInfo     orderCommentInfo    = new OrderCommentInfo()
            {
                OrderId      = comment.OrderId,
                DeliveryMark = comment.DeliveryMark,
                ServiceMark  = comment.ServiceMark,
                PackMark     = comment.PackMark,
                UserId       = base.CurrentUser.Id
            };

            tradeCommentService.AddOrderComment(orderCommentInfo);
        }
Exemple #7
0
        public void DeleteOrderComment(long Id)
        {
            OrderCommentInfo orderCommentInfo = context.OrderCommentInfo.FindById <OrderCommentInfo>(Id);

            if (orderCommentInfo != null)
            {
                List <long?> list = (
                    from d in context.OrderItemInfo.FindBy((OrderItemInfo d) => d.OrderId == orderCommentInfo.OrderId)
                    select(long?) d.Id).ToList <long?>();
                List <ProductCommentInfo> productCommentInfos = context.ProductCommentInfo.FindBy((ProductCommentInfo d) => list.Contains(d.SubOrderId)).ToList();
                context.ProductCommentInfo.RemoveRange(productCommentInfos);
                context.OrderCommentInfo.Remove(orderCommentInfo);
                context.SaveChanges();
            }
        }
Exemple #8
0
        public void DeleteOrderComment(long Id)
        {
            OrderCommentInfo ociobj = Context.OrderCommentInfo.FindById(Id);

            if (ociobj != null)
            {
                //删除相关信息
                List <long?> orditemid = Context.OrderItemInfo.FindBy(d => d.OrderId == ociobj.OrderId).Select(d => (long?)d.Id).ToList();
                var          procoms   = Context.ProductCommentInfo.FindBy(d => orditemid.Contains(d.SubOrderId)).ToList();
                Context.ProductCommentInfo.RemoveRange(procoms);
                //删除订单评价
                Context.OrderCommentInfo.Remove(ociobj);
                Context.SaveChanges();
            }
        }
Exemple #9
0
        public void AddOrderComment(OrderCommentInfo info)
        {
            OrderInfo orderInfo = (
                from a in context.OrderInfo
                where a.Id == info.OrderId && a.UserId == info.UserId
                select a).FirstOrDefault();

            if (orderInfo == null)
            {
                throw new HimallException("该订单不存在,或者不属于该用户!");
            }
            if ((
                    from a in context.OrderCommentInfo
                    where a.OrderId == info.OrderId && a.UserId == info.UserId
                    select a).Count() > 0)
            {
                throw new HimallException("您已经评论过该订单!");
            }
            info.ShopId      = orderInfo.ShopId;
            info.ShopName    = orderInfo.ShopName;
            info.UserName    = orderInfo.UserName;
            info.CommentDate = DateTime.Now;
            context.OrderCommentInfo.Add(info);
            context.SaveChanges();
            MemberIntegralRecord memberIntegralRecord = new MemberIntegralRecord()
            {
                UserName   = info.UserName,
                ReMark     = string.Concat("订单号:", info.OrderId),
                MemberId   = info.UserId,
                RecordDate = new DateTime?(DateTime.Now),
                TypeId     = MemberIntegral.IntegralType.Comment
            };
            MemberIntegralRecordAction memberIntegralRecordAction = new MemberIntegralRecordAction()
            {
                VirtualItemTypeId = new MemberIntegral.VirtualItemType?(MemberIntegral.VirtualItemType.Comment),
                VirtualItemId     = info.OrderId
            };

            memberIntegralRecord.ChemCloud_MemberIntegralRecordAction.Add(memberIntegralRecordAction);
            IConversionMemberIntegralBase conversionMemberIntegralBase = Instance <IMemberIntegralConversionFactoryService> .Create.Create(MemberIntegral.IntegralType.Comment, 0);

            Instance <IMemberIntegralService> .Create.AddMemberIntegral(memberIntegralRecord, conversionMemberIntegralBase);
        }
        public void DeleteOrderComment(long Id)
        {
            OrderCommentInfo ociobj = DbFactory.Default.Get <OrderCommentInfo>().Where(p => p.Id == Id).FirstOrDefault();

            if (ociobj != null)
            {
                //删除相关信息
                List <long> orditemid = DbFactory.Default
                                        .Get <OrderItemInfo>()
                                        .Where(d => d.OrderId == ociobj.OrderId)
                                        .Select(d => d.Id)
                                        .ToList <long>();
                DbFactory.Default.InTransaction(() =>
                {
                    DbFactory.Default.Del <ProductCommentInfo>(d => d.SubOrderId.ExIn(orditemid));
                    //删除订单评价
                    DbFactory.Default.Del(ociobj);
                });
            }
        }
        public void AddOrderComment(OrderCommentInfo info, int productNum)
        {
            var order = DbFactory.Default.Get <OrderInfo>().Where(a => a.Id == info.OrderId && a.UserId == info.UserId).FirstOrDefault();

            if (order == null)
            {
                throw new MallException("该订单不存在,或者不属于该用户!");
            }
            var orderComment = DbFactory.Default.Get <OrderCommentInfo>().Where(a => a.OrderId == info.OrderId && a.UserId == info.UserId);

            if (orderComment.Count() > 0)
            {
                throw new MallException("您已经评论过该订单!");
            }
            info.ShopId      = order.ShopId;
            info.ShopName    = order.ShopName;
            info.UserName    = order.UserName;
            info.CommentDate = DateTime.Now;
            info.OrderId     = order.Id;
            DbFactory.Default.Add(info);

            Mall.Entities.MemberIntegralRecordInfo record = new Mall.Entities.MemberIntegralRecordInfo();
            record.UserName   = info.UserName;
            record.ReMark     = "订单号:" + info.OrderId;
            record.MemberId   = info.UserId;
            record.RecordDate = DateTime.Now;
            record.TypeId     = Mall.Entities.MemberIntegralInfo.IntegralType.Comment;
            Mall.Entities.MemberIntegralRecordActionInfo action = new Mall.Entities.MemberIntegralRecordActionInfo();
            action.VirtualItemTypeId = Mall.Entities.MemberIntegralInfo.VirtualItemType.Comment;
            action.VirtualItemId     = info.OrderId;
            record.MemberIntegralRecordActionInfo.Add(action);
            var memberIntegral = ServiceProvider.Instance <IMemberIntegralConversionFactoryService> .Create.Create(Mall.Entities.MemberIntegralInfo.IntegralType.Comment);

            if (memberIntegral != null)
            {
                record.Integral = productNum * memberIntegral.ConversionIntegral();
            }
            ServiceProvider.Instance <IMemberIntegralService> .Create.AddMemberIntegral(record, null);
        }
        public ActionResult Details(long orderId)
        {
            OrderCommentInfo orderCommentInfo = ServiceHelper.Create <ITradeCommentService>().GetOrderCommentInfo(orderId, base.CurrentUser.Id);

            base.ViewBag.PackMark     = (orderCommentInfo != null ? orderCommentInfo.PackMark - 1 : -1);
            base.ViewBag.DeliveryMark = (orderCommentInfo != null ? orderCommentInfo.DeliveryMark - 1 : -1);
            base.ViewBag.ServiceMark  = (orderCommentInfo != null ? orderCommentInfo.ServiceMark - 1 : -1);
            base.ViewBag.QualityMark  = (orderCommentInfo != null ? orderCommentInfo.QualityMark - 1 : -1);


            IList <ProductEvaluation> productEvaluationByOrderIdNew = ServiceHelper.Create <ICommentService>().GetProductEvaluationByOrderIdNew(orderId, base.CurrentUser.Id);

            dynamic viewBag = base.ViewBag;
            long    shopId  = ServiceHelper.Create <IOrderService>().GetOrder(orderId).ShopId;

            viewBag.IsSellerAdminProdcut = shopId.Equals(1);

            foreach (var item in productEvaluationByOrderIdNew)
            {
                item.ThumbnailsUrl = ServiceHelper.Create <IProductService>().GetProduct(item.ProductId) == null ? "" : (ServiceHelper.Create <IProductService>().GetProduct(item.ProductId).ImagePath == null ? "" : ServiceHelper.Create <IProductService>().GetProduct(item.ProductId).ImagePath);
            }
            return(View(productEvaluationByOrderIdNew));
        }
Exemple #13
0
        public void AddOrderComment(OrderCommentInfo info)
        {
            var order = Context.OrderInfo.Where(a => a.Id == info.OrderId && a.UserId == info.UserId).FirstOrDefault();

            if (order == null)
            {
                throw new HimallException("该订单不存在,或者不属于该用户!");
            }
            var orderComment = Context.OrderCommentInfo.Where(a => a.OrderId == info.OrderId && a.UserId == info.UserId);

            if (orderComment.Count() > 0)
            {
                throw new HimallException("您已经评论过该订单!");
            }
            info.ShopId      = order.ShopId;
            info.ShopName    = order.ShopName;
            info.UserName    = order.UserName;
            info.CommentDate = DateTime.Now;
            Context.OrderCommentInfo.Add(info);
            Context.SaveChanges();
            MemberIntegralRecord record = new MemberIntegralRecord();

            record.UserName   = info.UserName;
            record.ReMark     = "订单号:" + info.OrderId;
            record.MemberId   = info.UserId;
            record.RecordDate = DateTime.Now;
            record.TypeId     = MemberIntegral.IntegralType.Comment;
            MemberIntegralRecordAction action = new MemberIntegralRecordAction();

            action.VirtualItemTypeId = MemberIntegral.VirtualItemType.Comment;
            action.VirtualItemId     = info.OrderId;
            record.Himall_MemberIntegralRecordAction.Add(action);
            var memberIntegral = ServiceProvider.Instance <IMemberIntegralConversionFactoryService> .Create.Create(MemberIntegral.IntegralType.Comment);

            ServiceProvider.Instance <IMemberIntegralService> .Create.AddMemberIntegral(record, memberIntegral);
        }
        public JsonResult AddOrderEvaluationAndComment(int PackMark, int DeliveryMark, int ServiceMark, int QualityMark, long OrderId, string productCommentsJSON)
        {
            using (TransactionScope transactionScope = new TransactionScope())
            {
                if (PackMark != 0 || DeliveryMark != 0 || ServiceMark != 0 || QualityMark != 0)
                {
                    OrderCommentInfo orderCommentInfo = new OrderCommentInfo()
                    {
                        UserId       = base.CurrentUser.Id,
                        PackMark     = PackMark,
                        DeliveryMark = DeliveryMark,
                        ServiceMark  = ServiceMark,
                        OrderId      = OrderId,
                        QualityMark  = QualityMark
                    };
                    List <ProductCommentsModel> productCommentsModels = JsonConvert.DeserializeObject <List <ProductCommentsModel> >(productCommentsJSON);
                    ServiceHelper.Create <ITradeCommentService>().AddOrderComment(orderCommentInfo);
                    foreach (ProductCommentsModel productCommentsModel in productCommentsModels)
                    {
                        ProductCommentInfo productCommentInfo = new ProductCommentInfo()
                        {
                            ReviewDate    = DateTime.Now,
                            ReviewContent = productCommentsModel.content,
                            UserId        = base.CurrentUser.Id,
                            UserName      = base.CurrentUser.UserName,
                            Email         = base.CurrentUser.Email,
                            SubOrderId    = new long?(productCommentsModel.subOrderId),
                            ReviewMark    = productCommentsModel.star
                        };
                        ServiceHelper.Create <ICommentService>().AddComment(productCommentInfo);
                    }
                }
                else
                {
                    foreach (ProductCommentsModel productCommentsModel1 in JsonConvert.DeserializeObject <List <ProductCommentsModel> >(productCommentsJSON))
                    {
                        ProductCommentInfo productCommentInfo1 = new ProductCommentInfo()
                        {
                            Id            = 0,
                            ProductId     = 0,
                            ShopId        = 0,
                            ShopName      = string.Empty,
                            UserId        = base.CurrentUser.Id,
                            UserName      = base.CurrentUser.UserName,
                            Email         = base.CurrentUser.Email,
                            ReviewContent = productCommentsModel1.content,
                            ReviewDate    = DateTime.Now,
                            ReplyContent  = string.Empty,
                            ReplyDate     = DateTime.Now,
                            ReviewMark    = productCommentsModel1.star,
                            SubOrderId    = new long?(productCommentsModel1.subOrderId)
                        };

                        ServiceHelper.Create <ICommentService>().AddComment(productCommentInfo1);
                    }
                }

                /*评价完成后,更改订单状态为已完结*/
                //评价不更改订单的状态信息,防止订单完成的时间根据评价时间随意更改
                ServiceHelper.Create <IOrderService>().UpdateOrderStatuOnly(OrderId, 5);

                transactionScope.Complete();
            }
            Result result = new Result()
            {
                success = true,
                msg     = "评价成功"
            };

            return(Json(result));
        }