コード例 #1
0
        /// <summary>
        /// 确认并修改订单
        /// </summary>
        /// <param name="orderDetail">
        /// 订单详情对象
        /// </param>
        /// <param name="products">
        /// 订单商品列表
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult ConfirmAndEditOrderDetail(OrderDetailModel orderDetail, List<OrderProductModel> products)
        {
            try
            {
                if (orderDetail.OrderInfo.IsRequireInvoice
                    && (orderDetail.InvoiceInfo == null
                        || string.IsNullOrWhiteSpace(orderDetail.InvoiceInfo.InvoiceTitle)
                        || orderDetail.InvoiceInfo.InvoiceCost <= 0
                        || orderDetail.InvoiceInfo.InvoiceTypeID < 1))
                {
                    return this.Json(new AjaxResponse() { State = -1, Message = "要求开发票,但发票信息不全!!" });
                }

                if (products == null || products.Count < 0)
                {
                    return this.Json(new AjaxResponse { State = -1, Message = "订单商品不能为空!!" });
                }

                var orderService = new OrderService(this.SystemUserSession.EmployeeID);
                List<Order_Product> productList;
                Order order = ResetOrderInfo(orderDetail, products,out productList);

                orderService.ManualConfirmOrder(
                    order,
                    productList,
                    DataTransfer.Transfer<Order_Invoice>(orderDetail.InvoiceInfo, typeof(OrderInvoiceModel)),
                    DataTransfer.Transfer<User_RecieveAddress>(orderDetail.ReceiverInfo, typeof(UserReceiveAddressModel)));

                return this.Json(new AjaxResponse { State = 1, Message = "操作成功" });
            }
            catch (Exception ex)
            {
                return this.Json(new AjaxResponse { State = -1, Message = ex.Message });
            }
        }
コード例 #2
0
        /// <summary>
        /// 查询订单详情
        /// </summary>
        /// <param name="orderID">
        /// 订单编码
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult QueryOrderDetails(int orderID)
        {
            var orderDetailModel = new OrderDetailModel();

            if (orderID > 0)
            {
                var order = new OrderService().QueryById(orderID);
                orderDetailModel.OrderInfo = DataTransfer.Transfer<OrderModel>(order, typeof(Order));
                var orderStatusTrackings = new OrderStatusTrackingService().QueryByOrderID(orderID);

                #region 订单状态信息

                var orderState = new OrderState { PaymentMethod = order.PaymentMethodID };
                switch (order.Status)
                {
                    case 0:
                    case 1:
                        orderState.Status = order.PaymentMethodID == 0 ? 1 : 0;
                        break;
                    case 2:
                        orderState.Status = 2;
                        break;
                    case 3:
                        orderState.Status = 4;
                        break;
                    case 100:
                        if (order.PaymentMethodID == 0)
                        {
                            orderState.Status = 0;
                        }

                        break;
                }

                if (orderStatusTrackings != null)
                {
                    orderState.ProcessDatetimes = new List<string>();
                    foreach (var orderStatusTracking in orderStatusTrackings)
                    {
                        if (orderState.Status == 0 && orderStatusTracking.Status == 0)
                        {
                            orderState.ProcessDatetimes.Add(
                                orderStatusTracking.CreateTime.ToString("yyyy-MM-dd hh:mm:ss"));
                        }

                        if (order.PaymentMethodID == 0 && orderState.Status == 1
                            && (orderStatusTracking.Status == 0 || orderStatusTracking.Status == 1))
                        {
                            orderState.ProcessDatetimes.Add(
                                orderStatusTracking.CreateTime.ToString("yyyy-MM-dd hh:mm:ss"));
                        }

                        if (orderState.Status == 2
                            && (orderStatusTracking.Status == 0 || orderStatusTracking.Status == 1
                                || orderStatusTracking.Status == 2))
                        {
                            orderState.ProcessDatetimes.Add(
                                orderStatusTracking.CreateTime.ToString("yyyy-MM-dd hh:mm:ss"));
                        }

                        if (orderState.Status == 4
                            && (orderStatusTracking.Status == 0 || orderStatusTracking.Status == 1
                                || orderStatusTracking.Status == 2 || orderStatusTracking.Status == 3))
                        {
                            orderState.ProcessDatetimes.Add(
                                orderStatusTracking.CreateTime.ToString("yyyy-MM-dd hh:mm:ss"));
                        }
                    }
                }

                orderDetailModel.CurrentOrderState = orderState;

                #endregion

                #region 订单发票信息

                if (order.IsRequireInvoice)
                {
                    orderDetailModel.InvoiceInfo =
                        DataTransfer.Transfer<OrderInvoiceModel>(
                            new OrderInvoiceService().SelectByOrderID(orderID),
                            typeof(Order_Invoice));
                }

                #endregion

                #region 订单变化追踪记录

                orderDetailModel.OrderTrackDetails = new List<OrderTrackDetailModel>();

                if (orderStatusTrackings != null)
                {
                    foreach (var orderStatusTracking in orderStatusTrackings)
                    {
                        System_Employee systemUser = null;

                        if (orderStatusTracking.EmployeeID > 0) systemUser = new SystemEmployeeService().QueryByID(orderStatusTracking.EmployeeID);

                        orderDetailModel.OrderTrackDetails.Add(
                            new OrderTrackDetailModel()
                            {
                                Operator =
                                    orderStatusTracking.EmployeeID > 0
                                        ? systemUser==null?"客服":"客服:"+systemUser.Name
                                        : (orderStatusTracking.UserID > 0) ? "客户" : "系统",
                                OperateSummary = orderStatusTracking.Remark,
                                OperateTime = orderStatusTracking.CreateTime
                            });

                        if (orderStatusTracking.Status == 2)
                        {
                            // 若产品已发货,则获取快递跟踪信息
                            var orderDeliverTrackDetail =
                                new OrderDeliveryTrackDetailService().QueryOrderDeliveryTrackDetailsByOrderID(orderID);
                            if (orderDeliverTrackDetail != null && !string.IsNullOrWhiteSpace(orderDeliverTrackDetail.Steps))
                            {
                                var details = orderDeliverTrackDetail.Steps.Split(';');

                                foreach (var orderDeliveryTrackingDetail in details)
                                {
                                    if (!string.IsNullOrWhiteSpace(orderDeliveryTrackingDetail))
                                    {
                                        var di = orderDeliveryTrackingDetail.Split('|');
                                        if (di.Length >= 2)
                                        {
                                            var tracking = new OrderTrackDetailModel { OperateSummary = di[1], Operator = "快递公司" };

                                            DateTime dt;
                                            if (DateTime.TryParse(di[0], out dt))
                                            {
                                                tracking.OperateTime = dt;
                                            }
                                            orderDetailModel.OrderTrackDetails.Add(tracking);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                #region 老的方法

                /*
                string summary = string.Empty;
                if (order.PaymentMethodID == 0)
                {
                    summary = order.PaymentStatus == 0 ? "您提交了订单,等待付款。" : "您提交了订单,商品准备出库。";
                }
                else if (order.PaymentMethodID == 1)
                {
                    summary = "您提交了订单,请等待确认。";
                }

                orderDetailModel.OrderDeliveryTrackDetails.Add(
                       new OrderDeliveryTrackDetailModel
                       {
                           OperateSummary = summary,
                           Operator = "客户",
                           OperateTime = order.CreateTime
                       });

                if (order.Status == 6)
                {
                    orderDetailModel.OrderDeliveryTrackDetails.Add(
                       new OrderDeliveryTrackDetailModel
                       {
                           OperateSummary = "订单已取消",
                           Operator = "客户",
                           OperateTime = order.CreateTime
                       });
                }
                else if (order.Status == 4 || order.Status == 8)
                {
                    orderDetailModel.OrderDeliveryTrackDetails.Add(
                        new OrderDeliveryTrackDetailModel
                            {
                                OperateSummary = "订单已作废",
                                Operator = "系统",
                                OperateTime = order.CreateTime
                            });
                }
                else
                {
                    if (orderStatusLogs != null)
                    {
                        foreach (var orderStatusLog in orderStatusLogs)
                        {
                            if (orderStatusLog.Status == 1)
                            {
                                summary = "您的订单已确认,准备出库";
                            }

                            if (orderStatusLog.Status == 2)
                            {
                                summary = "您的订单已出库"; // todo: 添加快递单号,快递公司名称
                            }

                            orderDetailModel.OrderDeliveryTrackDetails.Add(
                            new OrderDeliveryTrackDetailModel
                            {
                                OperateSummary = summary,
                                Operator = new SystemEmployeeService().QueryByID(orderStatusLog.EmployeeID).Name,  // todo: 添加操作员工名称
                                OperateTime = order.CreateTime
                            });
                        }
                    }
                }

                // 若订单已发货或已签收,则有物流流转信息
                if (order.Status == 3 || order.Status == 2)
                {
                    var orderDeliverTrackDetails =
                        new OrderDeliveryTrackDetailService().QueryOrderDeliveryTrackDetailsByOrderID(orderID);
                    foreach (var orderDeliveryTrackingDetail in orderDeliverTrackDetails)
                    {
                        orderDetailModel.OrderDeliveryTrackDetails.Add(
                            DataTransfer.Transfer<OrderDeliveryTrackDetailModel>(
                                orderDeliveryTrackingDetail,
                                typeof(Order_Delivery_Tracking_Details)));
                    }
                }
                */

                #endregion

                #endregion

                #region 订单收货信息

                orderDetailModel.ReceiverInfo =
                    DataTransfer.Transfer<UserReceiveAddressModel>(
                        new UserReceiveAddressService().QueryByID(order.RecieveAddressID),
                        typeof(User_RecieveAddress));

                #endregion

                #region 订单商品信息

                orderDetailModel.OrderProducts = new List<OrderProductModel>();

                var orderProducts = new OrderProductService().QueryByOrderId(orderID);
                if (orderProducts != null)
                {
                    foreach (var orderProduct in orderProducts)
                    {
                        orderDetailModel.OrderProducts.Add(
                            DataTransfer.Transfer<OrderProductModel>(orderProduct, typeof(Order_Product)));
                    }
                }

                #endregion

                #region 订单支付信息

                orderDetailModel.PaymentInfo = new PaymentInfoModel
                                                   {
                                                       OrderID = orderID,
                                                       PaymentMethodID = order.PaymentMethodID,
                                                       TotalMoney = order.TotalMoney,
                                                       DeliveryCost = order.DeliveryCost,
                                                       ActualPaid =
                                                           order.PaymentStatus == 1
                                                               ? order.TotalMoney + order.DeliveryCost
                                                               : 0,
                                                       ActualMoney =
                                                           order.TotalMoney + order.DeliveryCost
                                                   };

                #endregion
            }

            return this.View("Order/OrderDetail", orderDetailModel);
        }
コード例 #3
0
        /// <summary>
        /// 重置订单信息
        /// </summary>
        /// <param name="orderDetail"></param>
        /// <param name="products"></param>
        /// <param name="productList"></param>
        /// <returns></returns>
        private Order ResetOrderInfo(OrderDetailModel orderDetail, List<OrderProductModel> products, out List<Order_Product> productList)
        {
            productList = new List<Order_Product>();
            var orginalOrderProducts = new OrderProductService().QueryByOrderId(orderDetail.OrderInfo.ID);

            foreach (var product in products)
            {
                var originalOrderProduct = orginalOrderProducts.FirstOrDefault(p => p.ID == product.ID);
                Order_Product orderProduct = null;
                if (originalOrderProduct != null)
                {
                    originalOrderProduct.TransactPrice = product.TransactPrice;
                    originalOrderProduct.Quantity = product.Quantity;
                    orderProduct = originalOrderProduct;
                }
                else
                {
                    //新增的商品
                    orderProduct = DataTransfer.Transfer<Order_Product>(product, typeof(OrderProductModel));
                }

                productList.Add(orderProduct);
            }

            var order = new Order
                        {
                            CpsID = orderDetail.OrderInfo.CpsID,
                            DeliveryCost = orderDetail.OrderInfo.DeliveryCost,
                            Description = orderDetail.OrderInfo.Description,
                            ID = orderDetail.OrderInfo.ID,
                            IsRequireInvoice = orderDetail.OrderInfo.IsRequireInvoice
                        };
            return order;
        }