예제 #1
0
        public ActionResult GetOrderFull(string orderId)
        {
            Guid orderGuid = Guid.Parse(orderId);

            try
            {
                string  accountName = Helpers.DecodeCookie(Request.Cookies["user"]["user_accountname"]);
                Account account     = _memberCenterService.GetAccount(accountName);

                OrderFullModel orderFull = _memberCenterService.GetOrderFull(orderGuid);

                string response = JsonConvert.SerializeObject(orderFull);
                return(Content(response, "application/json"));
            }
            catch (Exception)
            {
                throw;
            }
        }
        public OrderFullModel GetOrderFull(Guid orderId)
        {
            try
            {
                Order       o  = _repository.GetAll <Order>().First(x => x.OrderId == orderId);
                OrderDetail od = _repository.GetAll <OrderDetail>().First(x => x.OrderId == orderId);

                OrderFullModel orderFull = new OrderFullModel
                {
                    DateService     = o.DateService.ToString("yyyy-MM-dd,HH:mm"),
                    Address         = o.Address,
                    OrderState      = o.OrderState,
                    FinalPrice      = od.FinalPrice,
                    FullName        = o.FullName,
                    Phone           = o.Phone,
                    Email           = o.Email,
                    CreateTime      = o.CreateTime.ToString("yyyy-MM-dd,HH:mm"),
                    InvoiceType     = o.InvoiceType,
                    InvoiceDonateTo = o.InvoiceDonateTo,
                    ProductName     = od.ProductName,
                    Rate            = o.Rate,
                };

                var couponDetail = _repository.GetAll <CouponDetail>()
                                   .FirstOrDefault(x => x.CouponDetailId == o.CouponDetailId);
                if (couponDetail == null)
                {
                    orderFull.DiscountAmount = 0;
                }
                else
                {
                    orderFull.DiscountAmount = _repository.GetAll <Coupon>()
                                               .First(x => x.CouponId == couponDetail.CouponId)
                                               .DiscountAmount;
                }

                switch (o.PaymentType)
                {
                case "Credit_CreditCard":
                    orderFull.PaymentType = "信用卡";
                    break;

                case "":
                    orderFull.PaymentType = "未付款";
                    break;

                default:
                    orderFull.PaymentType = "其他";
                    break;
                }

                OrderPackage package = _repository.GetAll <OrderPackage>().FirstOrDefault(x => x.OrderId == orderId);

                if (package != null)
                {
                    orderFull.PackageModel = new PackageModel
                    {
                        RoomTypes    = package.RoomTypes.Split(',').Select(x => int.Parse(x)).ToArray(),
                        SquareFeets  = package.SquareFeets.Split(',').Select(x => int.Parse(x)).ToArray(),
                        ServiceItems = package.ServiceItems.Replace("+", " + "),
                        Hour         = package.Hour,
                        Price        = package.Price,
                    };
                }
                else
                {
                    var userDefined = _repository.GetAll <OrderUserDefined>().Where(x => x.OrderId == orderId);

                    orderFull.UserDefinedList = new List <UserDefinedModel>();
                    foreach (var item in userDefined)
                    {
                        orderFull.UserDefinedList.Add(new UserDefinedModel
                        {
                            RoomType     = item.RoomType,
                            SquareFeet   = item.SquareFeet,
                            ServiceItems = item.ServiceItems.Replace(",", " + "),
                            Hour         = item.Hour,
                            Price        = item.Price
                        });
                    }
                }
                return(orderFull);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }