예제 #1
0
        public ActionResult AddEmployee([DataSourceRequest] DataSourceRequest request, EmployeeModel employeeModel)
        {
            try
            {
                if (employeeModel != null)
                {
                    this.systemEmployeeService = new SystemEmployeeService();

                    var backstageEmployee = DataTransfer.Transfer<System_Employee>(
                        employeeModel,
                        typeof(EmployeeModel));

                    employeeModel.ID = this.systemEmployeeService.AddEmployee(backstageEmployee);

                    if (employeeModel.ID > 0)
                    {
                        return this.Json(new[] { employeeModel }.ToDataSourceResult(request, this.ModelState));
                    }
                }
            }
            catch (Exception exception)
            {
                throw new Exception("添加员工时发生错误", exception);
            }

            return this.View();
        }
예제 #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
        public ActionResult RemoveEmployee(int id, FormCollection collection)
        {
            try
            {
                this.systemEmployeeService = new SystemEmployeeService();

                this.systemEmployeeService.RemoveEmployeeByID(id);

                return this.RedirectToAction("Index");
            }
            catch
            {
                return this.View();
            }
        }
예제 #4
0
        /// <summary>
        /// The query select list items.
        /// </summary>
        /// <returns>
        /// The <see cref="JsonResult"/>.
        /// </returns>
        public JsonResult QueryEmployeeSelectListItems()
        {
            this.systemEmployeeService = new SystemEmployeeService();

            var list = this.systemEmployeeService.QueryAll();
            if (list != null)
            {
                return this.Json(list, JsonRequestBehavior.AllowGet);
            }

            return this.Json(null);
        }
예제 #5
0
        /// <summary>
        /// The editing inline_ read.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <param name="departmentID">
        /// The department ID.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult QueryEmployeeByDepartmentID([DataSourceRequest] DataSourceRequest request, int departmentID)
        {
            this.systemEmployeeService = new SystemEmployeeService();

            if (request.Page <= 0)
            {
                request.Page = 1;
            }

            int pageCount;
            int totalCount;

            var paging = new Paging("[System_Employee]", null, "ID", string.Format("DepartmentID = {0}", departmentID), request.Page, request.PageSize);

            var list = this.systemEmployeeService.Query(paging, out pageCount, out totalCount);
            if (list == null)
            {
                return this.View();
            }

            var modelList = new List<EmployeeModel>();
            foreach (var backstageEmployee in list)
            {
                modelList.Add(DataTransfer.Transfer<EmployeeModel>(backstageEmployee, typeof(System_Employee)));
            }

            var result = new DataSourceResult { Data = modelList, Total = totalCount };

            return this.Json(result);
        }
예제 #6
0
        public ActionResult ModifyEmployee([DataSourceRequest] DataSourceRequest request, EmployeeModel employeeModel)
        {
            if (employeeModel != null && this.ModelState.IsValid)
            {
                this.systemEmployeeService = new SystemEmployeeService();

                var backstageEmployee = DataTransfer.Transfer<System_Employee>(
                    employeeModel,
                    typeof(EmployeeModel));

                this.systemEmployeeService.ModifyEmployee(backstageEmployee);
            }

            return this.Json(new[] { employeeModel }.ToDataSourceResult(request, this.ModelState));
        }