Пример #1
0
        /// <summary>
        /// 获取订单基本信息的Html
        /// </summary>
        /// <param name="info">订单显示信息</param>
        /// <returns></returns>
        public static HtmlString GetBaseInformationHtml(this OrderDisplayInfo info)
        {
            var templateManager = Application.Ioc.Resolve <TemplateManager>();

            return(new HtmlString(templateManager.RenderTemplate(
                                      "shopping.order/tmpl.order_view.tab_base_information.html", new { info })));
        }
Пример #2
0
        /// <summary>
        /// 获取订单列表页的表格头部
        /// </summary>
        /// <param name="info">订单显示信息</param>
        /// <returns></returns>
        public static HtmlString GetTableHeadingHtml(this OrderDisplayInfo info)
        {
            var templateManager = Application.Ioc.Resolve <TemplateManager>();

            return(new HtmlString(templateManager.RenderTemplate(
                                      "shopping.order/tmpl.order_list.table_heading.html", new { info })));
        }
Пример #3
0
        /// <summary>
        /// 获取订单总价和价格组成部分的Html
        /// 会同时显示订单总价和价格组成部分
        /// 但组成部分中的商品总价会忽略显示
        /// </summary>
        /// <param name="info">订单显示信息</param>
        /// <returns></returns>
        public static HtmlString GetTotalCostWithPartsHtml(this OrderDisplayInfo info)
        {
            var templateManager = Application.Ioc.Resolve <TemplateManager>();

            return(new HtmlString(templateManager.RenderTemplate(
                                      "shopping.order/tmpl.order_list.total_cost_with_parts.html", new { info })));
        }
Пример #4
0
        /// <summary>
        /// 获取发货记录的Html
        /// </summary>
        /// <param name="info">订单显示信息</param>
        /// <param name="deliveries">发货记录</param>
        /// <returns></returns>
        public static HtmlString GetDeliveryRecordsHtml(
            this OrderDisplayInfo info, IEnumerable <OrderDelivery> deliveries)
        {
            var table = new StaticTableBuilder();

            table.Columns.Add("Serial");
            table.Columns.Add("OrderLogistics", "150");
            table.Columns.Add("LogisticsSerial", "150");
            table.Columns.Add("DeliveryOperator", "150");
            table.Columns.Add("DeliveryTime", "150");
            table.Columns.Add("Actions", "150", cssClass: "actions");
            deliveries = deliveries.OrderByDescending(d => d.CreateTime);
            var templateManager = Application.Ioc.Resolve <TemplateManager>();

            foreach (var delivery in deliveries)
            {
                var viewUrl = string.Format(info.ViewDeliveryUrlFormat, delivery.Id);
                var action  = string.IsNullOrEmpty(viewUrl) ? new HtmlString("") :
                              DefaultOrderDisplayInfoProvider.GetModalAction(templateManager,
                                                                             new T("View"), viewUrl, "fa fa-edit",
                                                                             new T("View Delivery"), "btn btn-xs btn-info");
                table.Rows.Add(new {
                    Serial           = delivery.Serial,
                    OrderLogistics   = delivery.Logistics?.Name,
                    LogisticsSerial  = delivery.LogisticsSerial,
                    DeliveryOperator = delivery.Operator?.Username,
                    DeliveryTime     = delivery.CreateTime.ToClientTimeString(),
                    Actions          = action
                });
            }
            return((HtmlString)table.ToLiquid());
        }
Пример #5
0
        /// <summary>
        /// 获取订单操作在表格单元格(订单列表页)中的Html
        /// </summary>
        /// <param name="info">订单显示信息</param>
        /// <returns></returns>
        public static HtmlString GetOrderActionsTableCellHtml(this OrderDisplayInfo info)
        {
            var result = new StringBuilder();

            foreach (var action in info.ActionHtmls)
            {
                var actionHtml = action.ToString();
                if (actionHtml.Contains("btn-danger") || actionHtml.Contains("action-disabled"))
                {
                    continue;
                }
                result.AppendLine(actionHtml);
            }
            return(new HtmlString(result.ToString()));
        }
Пример #6
0
        /// <summary>
        /// 获取订单各项价格编辑表格的Html
        /// </summary>
        public static HtmlString GetOrderCostEditHtml(this OrderDisplayInfo info)
        {
            var table = new StaticTableBuilder();

            table.TableClass += " order-cost-edit-table";
            table.Columns.Add("OrderPricePart");
            table.Columns.Add("Cost", "110");
            foreach (var part in info.TotalCostCalcResult.Parts)
            {
                table.Rows.Add(new {
                    OrderPricePartType = part.Type,
                    OrderPricePart     = new T(part.Type),
                    Cost = part.GetDeltaEditor()
                });
            }
            return((HtmlString)table.ToLiquid());
        }
Пример #7
0
        /// <summary>
        /// 获取订单商品编辑表格的Html
        /// </summary>
        public static HtmlString GetOrderProductPriceEditHtml(this OrderDisplayInfo info)
        {
            var table = new StaticTableBuilder();

            table.TableClass += " order-product-price-edit-table";
            table.Columns.Add("Product");
            table.Columns.Add("ProductUnitPrice", "110");
            table.Columns.Add("Quantity", "110");
            foreach (var product in info.OrderProducts)
            {
                table.Rows.Add(new {
                    Product          = product.GetSummaryHtml(),
                    ProductUnitPrice = product.GetPriceEditor(),
                    Quantity         = product.GetCountEditor()
                });
            }
            return((HtmlString)table.ToLiquid());
        }
Пример #8
0
        /// <summary>
        /// 获取订单交易金额编辑表格的Html
        /// </summary>
        public static HtmlString GetOrderTransactionEditHtml(this OrderDisplayInfo info)
        {
            var table = new StaticTableBuilder();

            table.TableClass += " transaction-amount-edit-table";
            table.Columns.Add("PaymentTransaction");
            table.Columns.Add("Amount", "110");
            var orderManager = Application.Ioc.Resolve <SellerOrderManager>();
            var transactions = orderManager.GetReleatedTransactions(info.Id);

            foreach (var transaction in transactions)
            {
                table.Rows.Add(new {
                    PaymentTransactionId = transaction.Id,
                    PaymentTransaction   = transaction.Serial,
                    Amount = transaction.GetAmountEditor()
                });
            }
            return((HtmlString)table.ToLiquid());
        }
Пример #9
0
        /// <summary>
        /// 获取订单详细记录的html
        /// </summary>
        /// <param name="info">订单显示信息</param>
        /// <returns></returns>
        public static HtmlString GetOrderRecordsHtml(this OrderDisplayInfo info)
        {
            var orderManager = Application.Ioc.Resolve <SellerOrderManager>();
            var table        = new StaticTableBuilder();

            table.Columns.Add("CreateTime", "150");
            table.Columns.Add("Creator", "150");
            table.Columns.Add("Contents");
            var records = orderManager.GetDetailRecords(info.Id);

            foreach (var record in records)
            {
                table.Rows.Add(new {
                    CreateTime = record.CreateTime.ToClientTimeString(),
                    Creator    = record.Creator?.Username,
                    Contents   = record.Content
                });
            }
            return((HtmlString)table.ToLiquid());
        }
Пример #10
0
        /// <summary>
        /// 转换订单到显示信息
        /// </summary>
        /// <param name="order">订单</param>
        /// <param name="operatorType">操作人类型</param>
        /// <returns></returns>
        public static OrderDisplayInfo ToDisplayInfo(this SellerOrder order, OrderOperatorType operatorType)
        {
            var currencyManager      = Application.Ioc.Resolve <CurrencyManager>();
            var currency             = currencyManager.GetCurrency(order.Currency);
            var displayInfoProviders = Application.Ioc.ResolveMany <IOrderDisplayInfoProvider>();
            var info = new OrderDisplayInfo();

            info.Serial           = order.Serial;
            info.BuyerId          = order.Buyer?.Id;
            info.Buyer            = order.Buyer?.Username;
            info.SellerId         = order.Owner?.Id;
            info.Seller           = order.Owner?.Username;
            info.State            = order.State.ToString();
            info.StateDescription = new T(order.State.GetDescription());
            info.StateTimes       = order.StateTimes.ToDictionary(
                e => e.Key.ToString(), e => e.Value.ToClientTimeString());
            info.OrderParameters              = order.OrderParameters;
            info.TotalCost                    = order.TotalCost;
            info.TotalCostString              = currency.Format(info.TotalCost);
            info.TotalCostDescription         = order.TotalCostCalcResult.Parts.GetDescription();
            info.TotalCostCalcResult          = order.TotalCostCalcResult;
            info.OriginalTotalCost            = order.OriginalTotalCostCalcResult.Parts.Sum();
            info.OriginalTotalCostString      = currency.Format(info.OriginalTotalCost);
            info.OriginalTotalCostDescription = order.OriginalTotalCostCalcResult.Parts.GetDescription();
            info.OriginalTotalCostResult      = order.OriginalTotalCostCalcResult;
            info.Currency    = currencyManager.GetCurrency(order.Currency);
            info.RemarkFlags = order.RemarkFlags;
            info.CreateTime  = order.CreateTime.ToClientTimeString();
            foreach (var provider in displayInfoProviders)
            {
                provider.AddWarnings(order, info.WarningHtmls, operatorType);
                provider.AddToolButtons(order, info.ToolButtonHtmls, operatorType);
                provider.AddSubjects(order, info.SubjectHtmls, operatorType);
                provider.AddActions(order, info.ActionHtmls, operatorType);
            }
            info.OrderProducts = order.OrderProducts.Select(p => p.ToDisplayInfo()).ToList();
            return(info);
        }
Пример #11
0
        /// <summary>
        /// 获取订单留言的Html
        /// </summary>
        /// <param name="info">订单显示信息</param>
        /// <param name="comments">留言列表</param>
        /// <returns></returns>
        public static HtmlString GetOrderCommentsHtml(
            this OrderDisplayInfo info,
            IEnumerable <OrderComment> comments)
        {
            var templateManager = Application.Ioc.Resolve <TemplateManager>();
            var table           = new StaticTableBuilder();

            table.Columns.Add("Type", "150");
            table.Columns.Add("Creator", "150");
            table.Columns.Add("Contents");
            table.Columns.Add("CreateTime", "150");
            comments = comments.OrderByDescending(d => d.CreateTime);
            foreach (var comment in comments)
            {
                table.Rows.Add(new {
                    Type       = new T(comment.Side.GetDescription()),
                    Creator    = comment.Owner?.Username,
                    Contents   = comment.Contents,
                    CreateTime = comment.CreateTime.ToClientTimeString()
                });
            }
            return((HtmlString)table.ToLiquid());
        }
Пример #12
0
        /// <summary>
        /// 获取相关交易的Html
        /// </summary>
        /// <param name="info">订单显示信息</param>
        /// <returns></returns>
        public static HtmlString GetReleatedTransactionsHtml(this OrderDisplayInfo info)
        {
            var currencyManager = Application.Ioc.Resolve <CurrencyManager>();
            var orderManager    = Application.Ioc.Resolve <SellerOrderManager>();
            var table           = new StaticTableBuilder();

            table.Columns.Add("CreateTime", "150");
            table.Columns.Add("Serial");
            table.Columns.Add("PaymentApi", "150");
            table.Columns.Add("ExternalSerial", "150");
            table.Columns.Add("Amount", "150");
            table.Columns.Add("State", "150");
            table.Columns.Add("Actions", cssClass: "actions");
            var transactions    = orderManager.GetReleatedTransactions(info.Id);
            var templateManager = Application.Ioc.Resolve <TemplateManager>();

            foreach (var transaction in transactions)
            {
                var currency = currencyManager.GetCurrency(transaction.CurrencyType);
                var viewUrl  = string.Format(info.ViewTransactionUrlFormat, transaction.Id);
                var action   = string.IsNullOrEmpty(viewUrl) ? new HtmlString("") :
                               DefaultOrderDisplayInfoProvider.GetModalAction(templateManager,
                                                                              new T("View"), viewUrl, "fa fa-edit",
                                                                              new T("View Transaction"), "btn btn-xs btn-info");
                table.Rows.Add(new {
                    CreateTime     = transaction.CreateTime.ToClientTimeString(),
                    Serial         = transaction.Serial,
                    PaymentApi     = transaction.Api?.Name,
                    ExternalSerial = transaction.ExternalSerial,
                    Amount         = currency.Format(transaction.Amount),
                    State          = new T(transaction.State.GetDescription()),
                    Actions        = action
                });
            }
            return((HtmlString)table.ToLiquid());
        }
Пример #13
0
        /// <summary>
        /// 转换订单到显示信息
        /// </summary>
        /// <param name="order">卖家订单</param>
        /// <param name="operatorType">操作人类型</param>
        /// <returns></returns>
        public static OrderDisplayInfo ToDisplayInfo(this SellerOrder order, OrderOperatorType operatorType)
        {
            var currencyManager      = Application.Ioc.Resolve <CurrencyManager>();
            var currency             = currencyManager.GetCurrency(order.Currency);
            var displayInfoProviders = Application.Ioc.ResolveMany <IOrderDisplayInfoProvider>();
            var info = new OrderDisplayInfo();

            info.Id               = order.Id;
            info.Serial           = order.Serial;
            info.BuyerId          = order.Buyer?.Id;
            info.Buyer            = order.Buyer?.Username;
            info.SellerId         = order.Owner?.Id;
            info.Seller           = order.Owner?.Username;
            info.State            = order.State.ToString();
            info.StateDescription = new T(order.State.GetDescription());
            info.StateTimes       = order.StateTimes.ToDictionary(
                e => e.Key.ToString(), e => e.Value.ToClientTimeString());
            info.OrderParameters              = order.OrderParameters;
            info.TotalCost                    = order.TotalCost;
            info.TotalCostString              = currency.Format(info.TotalCost);
            info.TotalCostDescription         = order.TotalCostCalcResult.Parts.GetDescription();
            info.TotalCostCalcResult          = order.TotalCostCalcResult;
            info.OriginalTotalCost            = order.OriginalTotalCostCalcResult.Parts.Sum();
            info.OriginalTotalCostString      = currency.Format(info.OriginalTotalCost);
            info.OriginalTotalCostDescription = order.OriginalTotalCostCalcResult.Parts.GetDescription();
            info.OriginalTotalCostResult      = order.OriginalTotalCostCalcResult;
            info.Currency    = currencyManager.GetCurrency(order.Currency);
            info.RemarkFlags = order.RemarkFlags.ToString();
            info.CreateTime  = order.CreateTime.ToClientTimeString();
            info.LastComment = order.OrderComments
                               .OrderByDescending(c => c.CreateTime).FirstOrDefault()?.Contents;
            if (operatorType == OrderOperatorType.Admin)
            {
                info.ViewTransactionUrlFormat = "/admin/payment_transactions/edit?id={0}";
            }
            else
            {
                info.ViewTransactionUrlFormat = "";
            }
            if (operatorType == OrderOperatorType.Admin)
            {
                info.ViewDeliveryUrlFormat = "/admin/orders/delivery_view?id={0}";
            }
            else if (operatorType == OrderOperatorType.Buyer)
            {
                info.ViewDeliveryUrlFormat = "/user/orders/delivery_view?id={0}";
            }
            else if (operatorType == OrderOperatorType.Seller)
            {
                info.ViewDeliveryUrlFormat = "/seller/orders/delivery_view?id={0}";
            }
            else
            {
                info.ViewDeliveryUrlFormat = "";
            }
            foreach (var provider in displayInfoProviders)
            {
                provider.AddWarnings(order, info.WarningHtmls, operatorType);
                provider.AddToolButtons(order, info.ToolButtonHtmls, operatorType);
                provider.AddSubjects(order, info.SubjectHtmls, operatorType);
                provider.AddActions(order, info.ActionHtmls, operatorType);
            }
            info.OrderProducts = order.OrderProducts.Select(p => p.ToDisplayInfo()).ToList();
            return(info);
        }