Esempio n. 1
0
        /// <summary>
        /// 确认订单
        /// </summary>
        /// <param name="order">
        /// 订单对象
        /// </param>
        /// <param name="orderProducts">
        /// 订单商品列表
        /// </param>
        /// <param name="orderInvoice">
        /// 订单发票
        /// </param>
        /// <param name="userRecieveAddress">
        /// 用户收货地址信息
        /// </param>
        public void ManualConfirmOrder(
            Order order, 
            List<Order_Product> orderProducts, 
            Order_Invoice orderInvoice, 
            User_RecieveAddress userRecieveAddress)
        {
            //todo: 订单数据需要从数据库取一次
            /************
             * 一、修改订单
             * 1. 修改收货人信息。
             * 2. 修改订单商品信息
             * 3. 修改订单发票信息
             * 4. 修改订单信息
             * 二、确认订单
             * 1.推送到ERP系统
             * 2.修改订单为确认状态
             * ***********/
            SqlTransaction transaction = null;
            var orderProductService = new OrderProductService();
            Order orignalOrder = this.EditOrderInfo(order, orderProducts, orderInvoice, userRecieveAddress);

            switch (orignalOrder.Status)
            {
                case 100:
                    throw new Exception("此订单处于等待支付状态,不允许确认。");
                case 1:
                    throw new Exception("此订单已确认,请不要重复操作!");
                case 2:
                    throw new Exception("此订单已发货");
                case 3:
                    throw new Exception("此订单已签收");
                case 4:
                case 6:
                case 8:
                    throw new Exception("此订单已取消");
                case 5:
                    throw new Exception("此订单已损失");
                case 0:
                    //确认订单
                    try
                    {
                        Order_Payment payment = null;
                        if (order.PaymentStatus == 1)
                        {
                            payment = new OrderPaymentService().QueryByOrderID(order.ID);
                        }

                        orderProducts = orderProductService.QueryByOrderId(order.ID);
                        this.orderDA.SqlServer.BeginTransaction();
                        transaction = this.orderDA.SqlServer.Transaction;
                        this.ConfirmByUpdateOrder(orignalOrder, transaction, payment, orderProducts);

                        new OrderStatusTrackingService().Add(
                            new Order_Status_Tracking
                            {
                                OrderID = order.ID,
                                EmployeeID = isBackage ? this.userID : 0,
                                Remark = "订单已经确认,等待出库",
                                Status = 1,  // 已确认的订单状态为码 1
                                UserID = order.UserID
                            },
                            transaction);

                        transaction.Commit();
                    }
                    catch (Exception exception)
                    {
                        if (transaction != null)
                        {
                            transaction.Rollback();
                        }

                        LogUtils.Log(
                            string.Format(
                                "确认订单出错,订单编码{0},操作人ID:{1},错误信息:{2},内部错误:{3},堆栈信息:{4}",
                                order.ID,
                                this.userID,
                                exception.Message,
                                exception.InnerException,
                                exception.StackTrace),
                            "确认订单--服务层",
                            Category.Fatal);
                        throw;
                    }

                    // 写订单修改日志
                    try
                    {
                        var orderStatusLogService = new OrderStatusLogService();
                        orderStatusLogService.Insert(
                            new Order_Status_Log
                            {
                                EmployeeID = this.userID,
                                OrderID = order.ID,
                                Remark = order.Description,
                                Status = 1
                            },
                            null);
                    }
                    catch (Exception exception)
                    {
                        TextLogger.Instance.Log(
                            string.Format("后台订单确认--订单状态日志写入错误.(订单编码:{0},操作员编码:{1})", order.ID, this.userID),
                            Category.Error,
                            exception);
                    }
                    break;
                default:
                    throw new Exception("订单状态异常。");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 添加订单
        /// </summary>
        /// <param name="order">
        /// 订单兑现
        /// </param>
        /// <param name="orderProducts">
        /// 订单商品列表
        /// </param>
        /// <param name="invoice">
        /// 发票信息
        /// </param>
        /// <param name="Coupons">赠送的优惠券信息</param>
        /// <param name="promotes">订单促销信息</param>
        /// <returns>
        /// 已添加订单的编码
        /// </returns>
        public int Add(Order order, List<Order_Product> orderProducts, Order_Invoice invoice, List<Gift_Coupon> Coupons = null, List<Order_Product_Promote> promotes = null)
        {
            // 1.添加订单
            // 2.添加订单商品
            // 3.添加发票(若有)
            var orderProductService = new OrderProductService();
            SqlTransaction transaction = null;
            int orderId;
            try
            {
                if (order.TotalMoney == 0) //如果0,则认为是前端的订单,需要从新计算金额,不能享受到优惠和促销
                {
                    double totalMoney = 0;
                    foreach (var orderProduct in orderProducts)
                    {
                        totalMoney += orderProduct.TransactPrice * orderProduct.Quantity;
                    }

                    order.TotalMoney = totalMoney;
                    order.DeliveryCost = totalMoney >= 100 ? 0 : 10; // todo: 读取数据库配置,设置运费。
                }

                order.TotalIntegral = (int)order.TotalMoney / 1;

                orderId = this.orderDA.Insert(order, out transaction);
                order.ID = orderId;

                orderProductService.BatchAddOrderProduct(orderProducts, order.CpsID, orderId, transaction);

                if (invoice != null)
                {
                    invoice.OrderID = orderId;
                    invoice.InvoiceCost = order.TotalMoney;
                    new OrderInvoiceService().Add(invoice, transaction);
                }

                //赠送优惠券
                if (Coupons != null && Coupons.Count > 0)
                {
                    foreach (var giftCoupon in Coupons)
                    {
                        switch (giftCoupon.CouponType)
                        {
                            case 0:
                                //默认新方法的券状态为2,未激活
                                new CouponCashBindingService().Add(orderId, giftCoupon.CouponID, this.userID, "购物赠券", 2, transaction);
                                break;
                            case 1:
                                //默认新方法的券状态为2,未激活
                                new CouponDecreaseBindingService().Add(orderId, giftCoupon.CouponID, this.userID, "购物赠券", 2, transaction);
                                break;
                        }
                    }
                }

                if (promotes != null && promotes.Count > 0)
                {
                    foreach (var promote in promotes)
                    {
                        promote.OrderID = orderId;
                    }

                    var rowCount = new OrderProductPromoteService().BatchAdd(promotes, transaction);
                    if (rowCount < 1)
                    {
                        LogUtils.Log("添加订单(订单号:" + order.OrderCode + ")时添加的订单商品促销信息数为:" + rowCount, "添加订单服务层", Category.Info);
                    }
                }

                string remark;

                if (order.PaymentMethodID == 1||order.PaymentMethodID == 2)
                {
                    remark = "添加订单成功,等待确认";
                }
                else
                {
                    remark = order.PaymentStatus == 0 ? "添加订单成功,等待付款" : "添加订单成功,等待确认";
                }

                new OrderStatusTrackingService().Add(
                    new Order_Status_Tracking
                        {
                            OrderID = orderId,
                            EmployeeID = isBackage? this.userID:0,
                            Remark = remark,
                            Status = 0,
                            UserID = order.UserID
                        },
                    transaction);
                transaction.Commit();
            }
            catch (Exception)
            {
                if (transaction != null)
                {
                    transaction.Rollback();
                }

                throw;
            }

            // 写订单修改日志
            try
            {
                var orderStatusLogService = new OrderStatusLogService();
                orderStatusLogService.Insert(
                    new Order_Status_Log
                    {
                        EmployeeID = isBackage? this.userID:0, // 若是后台,则填写操作员工编码
                        OrderID = orderId,
                        Remark = order.Description,
                        Status = 0
                    },
                    null);
            }
            catch (Exception exception)
            {
                TextLogger.Instance.Log(
                    string.Format("后台添加订单--订单状态日志写入错误.(订单编码:{0},操作员编码:{1})", order.ID, this.userID),
                    Category.Error,
                    exception);
            }

            return orderId;
        }
Esempio n. 3
0
        private bool PushOrderToHwErp(Order order, List<Order_Product> orderProducts, SqlTransaction transaction, out string errorMsg, Order_Payment payment = null)
        {
            #region 订单推送ERP

            #region 订单基本信息

            errorMsg = string.Empty;

            var hi = new HwRest.HwOrderInfo();

            hi.orderNumber = order.OrderCode;
            hi.orderDate = order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss");
            if (order.PaymentStatus == 1)
            {
                //var orderPayment = new OrderPaymentService().QueryByOrderID(order.ID);
                //if (orderPayment != null) hi.payTime = Convert.ToDateTime(orderPayment.CreateTime).ToString();

                //todo:若订单已在线支付,则认为是当前时间支付,因为在线支付订单是有系统在支付时自动确认的。当时不够准确。
                hi.payTime = payment == null ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : payment.CreateTime.ToString("yyyy-MM-dd HH:mm:ss");
            }

            if (string.IsNullOrWhiteSpace(hi.payTime))
            {
                hi.payTime = "";
            }

            var orderReceiveAddress = new UserReceiveAddressService().QueryByID(order.RecieveAddressID);

            hi.buyerNick = string.IsNullOrWhiteSpace(order.UserName) ? orderReceiveAddress.Consignee : order.UserName;
            hi.totalAmount = Math.Round(order.TotalMoney + order.DeliveryCost, 2).ToString();
            hi.payment = payment == null
                             ? (order.TotalMoney + order.DeliveryCost).ToString()
                             : Math.Round(payment.PaymentMoney, 2).ToString();
            hi.postAmount = order.DeliveryCost.ToString();
            hi.discount = order.Discount.ToString();
            hi.points = "";
            hi.pointsAmount = "";
            hi.couponsAmount = "";
            hi.virtualAmount = "";
            hi.fullMinus = "";
            var orderInvoice = new OrderInvoiceService().SelectByOrderID(order.ID);
            hi.invoiceTitle = orderInvoice != null ? orderInvoice.InvoiceTitle : "";
            hi.invoiceContent = orderInvoice != null ? orderInvoice.InvoiceContent : "";
            hi.invoiceAmount = orderInvoice != null ? orderInvoice.InvoiceCost.ToString() : "";
            hi.tradeFrom = "官网订单";

            if (order.PaymentMethodID == 0)
            {
                if (payment != null)
                {
                    hi.paymentType = payment.PaymentOrgName;
                }
                else
                {
                    hi.paymentType = "网上支付";
                }
                hi.sellerMemo = "";
            }
            else
            {
                hi.paymentType = "货到付款";
                hi.sellerMemo = "";
            }

            hi.consignee = orderReceiveAddress != null ? orderReceiveAddress.Consignee : order.UserName;
            if (orderReceiveAddress != null)
            {
                if (!string.IsNullOrWhiteSpace(orderReceiveAddress.CountyName(",")))
                {
                    var strs = orderReceiveAddress.CountyName(",").Split(',');
                    if (strs.Length == 3)
                    {
                        hi.province = strs[0];
                        hi.city = strs[1];
                        hi.cityarea = strs[2];
                    }
                    else
                    {
                        hi.cityarea = orderReceiveAddress.CountyName(",");
                        hi.province = "";
                        hi.city = "";
                    }
                }
            }
            else
            {
                hi.cityarea = "";
                hi.province = "";
                hi.city = "";
            }

            hi.address = orderReceiveAddress != null ? orderReceiveAddress.Address : "";
            hi.mobilePhone = orderReceiveAddress != null ? orderReceiveAddress.Mobile : "";
            hi.telephone = orderReceiveAddress != null ? orderReceiveAddress.Tel : "";
            hi.zip = orderReceiveAddress != null ? orderReceiveAddress.ZipCode : "";
            hi.buyerMessage ="客户备注:"+ order.Remark + ";客服备注:" + order.Description;

            #endregion

            #region 商品列表

            List<HwRest.HwProductList> hplist = new List<HwRest.HwProductList>();
            if (orderProducts == null || orderProducts.Count < 1)
            {
                orderProducts = new OrderProductService().QueryByOrderId(order.ID);
            }

            foreach (var orderProduct in orderProducts)
            {
                var hwProduct =
                    hplist.FirstOrDefault(p => p.productNumber == orderProduct.Barcode && orderProduct.TransactPrice <= 0);

                //赠品与正常商品合并
                if (hwProduct != null)
                {
                    hwProduct.orderCount = (int.Parse(hwProduct.orderCount) + orderProduct.Quantity).ToString();
                    hwProduct.giftCount = (int.Parse(hwProduct.giftCount) + orderProduct.Quantity).ToString();
                    //将商品价格当做优惠金额进行处理
                    hwProduct.discountFee = (int.Parse(hwProduct.discountFee) + int.Parse(hwProduct.price) * orderProduct.Quantity).ToString();
                }
                else
                {
                    HwRest.HwProductList hpl = new HwRest.HwProductList();
                    hpl.productNumber = orderProduct.Barcode; //新系统中没有商品编号,此处设为商品条形码
                    hpl.productName = orderProduct.ProductName;
                    hpl.skuNumber = orderProduct.Barcode;
                    hpl.skuName = "";
                    hpl.price = orderProduct.TransactPrice.ToString();
                    hpl.orderCount = orderProduct.Quantity.ToString();
                    hpl.giftCount = (orderProduct.TransactPrice > 0 ? 0 : orderProduct.Quantity).ToString();
                    hpl.amount = (orderProduct.TransactPrice * orderProduct.Quantity).ToString();
                    hpl.memo = orderProduct.TransactPrice > 0 ? "" : "【赠品】";
                    hpl.discountFee = "0";
                    hpl.barcode = orderProduct.Barcode;
                    hplist.Add(hpl);
                }
            }

            #endregion

            HwRest.OWebOrderItems OWebOrderItems = new HwRest.OWebOrderItems();
            OWebOrderItems.OWebOrderItem = hplist.ToArray();

            HwRest.HwOrderAdd_Info hai = new HwRest.HwOrderAdd_Info();
            hi.OWebOrderItems = OWebOrderItems;
            hai.OWebOrder = hi;

            HwRest.HwClient HwClient = new HwRest.HwClient();
            HwClient.XmlValues = hai.ToXmlParameter();
            HwClient.OrderNumber = hi.orderNumber;
            string HwBackXml = HwClient.Execute();

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(HwBackXml);
            XmlNode root = doc.SelectSingleNode("//Response");

            var log = new Order_Erp_Log
                          {
                              ERP = "HW_ERP",
                              OrderID = order.ID,
                              OperateType = 1,
                              ReqContent = HwClient.XmlValues,
                              ResContent = HwBackXml,
                              UserID = order.UserID,
                              Operator = isBackage ? this.userID : 0,
                              CreateTime = DateTime.Now
                          };

            if (payment != null)
            {
                log.ExtField = "在线支付订单,支付时间:" + payment.CreateTime;
            }

            var result = false;

            if (HwBackXml.Contains("推单异常") || root.FirstChild.InnerText.ToLower() != "true")
            {
                log.IsSuccess = false;

                //获取退单错误信息
                var errorNode = root.SelectSingleNode("//value");

                if (errorNode != null)
                {
                    errorMsg = errorNode.InnerText;
                }

                result = false;

                LogUtils.Log("订单推送失败,订单编码:" + order.ID + ",错误消息:" + HwBackXml, "订单推送ERP", Category.Error);
            }
            else
            {
                log.IsSuccess = true;
                result = true;
                LogUtils.Log("订单推送成功,订单编码:" + order.ID, "订单推送ERP");
            }

            try
            {
                var orderErpLogService = new OrderERPLogService();
                orderErpLogService.Add(log, null); //添加日志,无需事务,防止回滚
            }
            catch(Exception exception)
            {
                LogUtils.Log(
                    string.Format(
                        "[Order_ERP]订单推送成功,但是写入日志信息发生错误。订单编号:{0},错误信息:{1}/{2}",
                        order.OrderCode,
                        exception.Message,
                        exception.InnerException),
                    "[Order_ERP]订单推送",
                    Category.Error);
            }

            return result;

            #endregion
        }
Esempio n. 4
0
        /// <summary>
        /// 根据订单编码查询成交产品信息
        /// </summary>
        /// <param name="request">
        /// 请求对象
        /// </param>
        /// <param name="orderId">
        /// 订单编码
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult QueryOrderProductByOrderId([DataSourceRequest] DataSourceRequest request, int orderId)
        {
            var orderProductService = new OrderProductService();
            var list = orderProductService.QueryByOrderId(orderId);

            if (list == null || list.Count < 1)
            {
                return Json(null, JsonRequestBehavior.AllowGet);
            }

            var modelList = new List<OrderProductModel>();
            foreach (var item in list)
            {
                var order = DataTransfer.Transfer<OrderProductModel>(item, typeof(Order_Product));
                modelList.Add(order);
            }

            var dataSource = new DataSource { Data = modelList };

            return Json(dataSource, JsonRequestBehavior.AllowGet);
        }
Esempio n. 5
0
        public ActionResult QueryOrderProducts(
            [DataSourceRequest] DataSourceRequest request,
            string OrderCode,
            string Status,
            string PaymentMethodID,
            string UserName,
            string Consignee,
            string CpsID,
            string StartDateTime,
            string EndDateTime,
            string MinTotalMoney,
            string MaxTotalMoney)
        {
            int pageCount, rowCount;
            string condition = this.BuildOrderSearchCondition(
                OrderCode,
                Status,
                PaymentMethodID,
                UserName,
                Consignee,
                CpsID,
                StartDateTime,
                EndDateTime,
                MinTotalMoney,
                MaxTotalMoney);
            var paging = new Paging(null, null, "ID", condition, request.Page, request.PageSize, "CreateTime", 1);
            var list = new OrderProductService().Paging(paging, out pageCount, out rowCount);
            var modelList = new List<OrderProductModel>();
            foreach (var orderProduct in list)
            {
                modelList.Add(DataTransfer.Transfer<OrderProductModel>(orderProduct, typeof(Order_Product)));
            }

            return this.Json(modelList.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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;
        }
Esempio n. 8
0
 public ActionResult RemoveOrderProduct(int id)
 {
     var orderProductService = new OrderProductService();
     orderProductService.RemoveOrderProduct(id);
     return null;
 }
Esempio n. 9
0
 public PartialViewResult OrderProducts(int orderID)
 {
     var orderProducts = new OrderProductService().QueryByOrderId(orderID);
     return this.PartialView("Partial/OrderProduct", orderProducts);
 }
Esempio n. 10
0
        public JsonResult AddComment(int score, int productID, string content)
        {
            try
            {
                var userID = this.GetUserID();
                if (userID <= 0)
                {
                    return this.Json(new AjaxResponse(2, "未登录!"));
                }

                // 商品ID、会员ID 查询订单
                var orderCount = new OrderProductService().QueryByProductIDAndUserID(productID, userID);
                if (orderCount <= 0)
                {
                    return this.Json(new AjaxResponse(3, "未购买过!"));
                }

                var commentReply = new Product_Comment
                {
                    UserID = userID,
                    ProductID = productID,
                    Content = content,
                    Status = 1,
                    Score = score
                };
                commentReply.ID = new ProductCommentService().Add(commentReply);
                return this.Json(new AjaxResponse(1, "评论成功!"));
            }
            catch (Exception exception)
            {
                return this.Json(new AjaxResponse(0, "评论失败!:" + exception.Message));
            }
        }