예제 #1
0
        /// <summary>
        /// 获得已完成的订单
        /// </summary>
        /// <returns></returns>

        public ActionResult Completed()
        {
            List <OrderModel>   orderModelList = new List <OrderModel>();
            IEnumerable <Order> orderList      = _orderBLL.GetCompletedOrders();

            foreach (var item in orderList)
            {
                OrderModel om     = new OrderModel(item);
                Member     member = _memberBLL.GetMemberById(item.MemberId);
                om.MemberName = member.NickeName;

                Address address = _addressBLL.GetAddressById(om.AddressId);
                om.Phone     = address.Phone;
                om.Address   = address.Province + "," + address.City + "," + address.County + "," + address.Detail;
                om.Consignee = address.Consignee;

                // 添加配送状态
                om.LogisticalStatus = _orderStatusBLL.GetOrderStatusByOrderId(om.Id).Status;

                orderModelList.Add(om);
            }
            ViewData["CompletedOrderList"] = orderModelList;

            return(View());
        }
예제 #2
0
        //[HttpPost]
        //public ActionResult Create()
        //{
        //    return View();
        //}
        public ActionResult Detail(string orderNo)
        {
            // 先获得订单对象
            Order order = _orderBLL.GetOrderByOrderNo(orderNo);

            ViewBag.OrderNo     = order.OrderNo;
            ViewBag.OrderStatus = order.Status;
            ViewBag.Status      = order.Status == 0 ? "未完成" : (order.Status == 1 ? "已完成" : "已取消");
            ViewBag.TotalPrice  = order.TotalPrice;
            ViewBag.CreateTime  = order.CreatedTime;
            ViewBag.Payway      = order.PayWay == 0 ? "微信支付" : "余额支付";

            // 获取订单配送状态
            OrderStatus os = _orderStausBLL.GetOrderStatusByOrderId(order.Id);

            ViewBag.Logistical = os.Status;

            // 获取地址
            Address address = _addressBLL.GetAddressById(order.AddressId);

            // 构造 AddressModel
            AddressModel ad = new AddressModel();

            ad.City      = address.City;
            ad.Consignee = address.Consignee;
            ad.County    = address.County;
            ad.Detail    = address.Detail;
            ad.Phone     = address.Phone;
            ad.Province  = address.Province;

            ViewData["address"] = ad;

            List <OrderDetail> odList = new List <OrderDetail>();

            odList = _orderDetailBLL.GetOrderDetailByOrderNo(orderNo).ToList();

            List <OrderDetailModel> odmList = new List <OrderDetailModel>();

            foreach (var item in odList)
            {
                OrderDetailModel odm = new OrderDetailModel(item);
                odm.GoodsName   = _goodsBLL.GetGoodsById(item.GoodsId).Name;
                odm.PicturePath = _goodsImagesBLL.GetPictureByGoodsId(item.GoodsId).ImagePath;

                odmList.Add(odm);
            }
            ViewData["OrderDetailModelList"] = odmList;
            ViewBag.TotalPrice = order.TotalPrice;
            return(View());
        }