/// <summary>
        /// 获取发货记录的Html
        /// </summary>
        /// <param name="order">订单</param>
        /// <returns></returns>
        public virtual HtmlString GetDeliveryRecordsHtml(SellerOrder order)
        {
            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");
            var deliveries = order.OrderDeliveries.OrderByDescending(d => d.CreateTime);

            foreach (var delivery in deliveries)
            {
                table.Rows.Add(new {
                    Serial           = delivery.Serial,
                    OrderLogistics   = delivery.Logistics?.Name,
                    LogisticsSerial  = delivery.LogisticsSerial,
                    DeliveryOperator = delivery.Operator?.Username,
                    DeliveryTime     = delivery.CreateTime.ToClientTimeString(),
                    Action           = ""           // TODO: 添加查看发货记录详情的代码
                });
            }
            return((HtmlString)table.ToLiquid());
        }
        /// <summary>
        /// 转换搜索回应到静态表格构建器
        /// 请手动添加列到返回结果,添加后可以直接描画到模板
        /// </summary>
        /// <param name="response">搜索回应</param>
        /// <returns></returns>
        public static StaticTableBuilder ToTableBuilder(this StaticTableSearchResponse response)
        {
            var builder = new StaticTableBuilder();

            builder.Rows.AddRange(response.Rows);
            return(builder);
        }
示例#3
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());
        }
        /// <summary>
        /// 获取相关交易的Html
        /// </summary>
        /// <param name="orderId">订单Id</param>
        /// <returns></returns>
        public virtual HtmlString GetReleatedTransactionsHtml(Guid orderId)
        {
            var currencyManager = Application.Ioc.Resolve <CurrencyManager>();
            var table           = new StaticTableBuilder();

            table.Columns.Add("Serial");
            table.Columns.Add("PaymentApi", "150");
            table.Columns.Add("ExternalSerial", "150");
            table.Columns.Add("Amount", "150");
            table.Columns.Add("State", "150");
            var transactions = GetReleatedTransactions(orderId);

            foreach (var transaction in transactions)
            {
                var currency = currencyManager.GetCurrency(transaction.CurrencyType);
                table.Rows.Add(new {
                    Serial         = transaction.Serial,
                    PaymentApi     = transaction.Api?.Name,
                    ExternalSerial = transaction.ExternalSerial,
                    Amount         = currency.Format(transaction.Amount),
                    State          = new T(transaction.State.GetDescription())
                });
            }
            return((HtmlString)table.ToLiquid());
        }
        /// <summary>
        /// 绑定表单
        /// </summary>
        protected override void OnBind()
        {
            // 获取订单
            var id           = Request.Get <Guid>("id");
            var orderManager = Application.Ioc.Resolve <SellerOrderManager>();
            var order        = orderManager.Get(id);

            if (order == null)
            {
                throw new BadRequestException("Order not exist");
            }
            // 包含实际商品时,提示收货地址和物流名称,否则提示是虚拟发货并隐藏物流控件
            var templateManager     = Application.Ioc.Resolve <TemplateManager>();
            var containsRealProduct = order.ContainsRealProduct();

            if (containsRealProduct)
            {
                var logisticsManager = Application.Ioc.Resolve <LogisticsManager>();
                var shippingAddress  = order.OrderParameters.GetShippingAddress();
                var logisticsId      = order.OrderParameters.GetSellerToLogistics()
                                       .GetOrDefault(order.Owner?.Id ?? Guid.Empty);
                var logistics = logisticsManager.GetWithCache(logisticsId);
                AlertHtml = new T(
                    "The shipping address is \"{0}\", and buyer want to use logistics \"{1}\"",
                    shippingAddress?.GenerateSummary(), logistics?.Name);
                Logistics = logistics?.Id ?? Guid.Empty;
            }
            else
            {
                AlertHtml = new T(
                    "Order only contains virtual products, " +
                    "if you have something to buyer please use comment");
                Form.Fields.RemoveAll(a =>
                                      a.Attribute.Name == "Logistics" ||
                                      a.Attribute.Name == "LogisticsSerial");
            }
            // 构建发货商品的表格
            var tableBuilder = new StaticTableBuilder();

            tableBuilder.Columns.Add("Product");
            tableBuilder.Columns.Add("ShippedQuantity", "130");
            tableBuilder.Columns.Add("ThisDeliveryQuantity", "130");
            foreach (var product in order.OrderProducts)
            {
                var info = product.ToDisplayInfo();
                tableBuilder.Rows.Add(new {
                    Product              = info.GetSummaryHtml(),
                    ShippedQuantity      = info.GetShippedCountHtml(),
                    ThisDeliveryQuantity = info.GetDeliveryCountEditor()
                });
            }
            DeliveryCountsJson   = new Dictionary <Guid, long>();
            DeliveryProductTable = (HtmlString)tableBuilder.ToLiquid();
        }
示例#6
0
 /// <summary>
 /// 导出到数据流
 /// </summary>
 public void Export(StaticTableBuilder table, Stream stream)
 {
     using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true)) {
         // 写入第一行的列名
         writer.WriteLine(string.Join(",",
                                      table.Columns.Select(c => CsvCell(c.Caption))));
         // 写入数据行
         foreach (var row in table.GetHashRows())
         {
             writer.WriteLine(string.Join(",",
                                          table.Columns.Select(c => CsvCell(row[c.Member]))));
         }
     }
 }
示例#7
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());
        }
示例#8
0
        /// <summary>
        /// 获取商品评价的html
        /// </summary>
        /// <param name="order">卖家订单</param>
        /// <returns></returns>
        public virtual HtmlString GetProductRatingsHtml(SellerOrder order)
        {
            var table = new StaticTableBuilder();

            table.Columns.Add("Product");
            table.Columns.Add("Rate", "150");
            table.Columns.Add("ProductRating", "300");
            foreach (var product in order.OrderProducts)
            {
                var rating = Get(r => r.OrderProduct.Id == product.Id);
                table.Rows.Add(new {
                    Product       = product.ToDisplayInfo().GetSummaryHtml(),
                    Rate          = new T(rating?.Rank.GetDescription() ?? "No Rating"),
                    ProductRating = rating?.Comment
                });
            }
            return((HtmlString)table.ToLiquid());
        }
示例#9
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());
        }
 /// <summary>
 /// 获取交易详细记录的html
 /// </summary>
 public virtual HtmlString GetDetailRecordsHtml(Guid transactionId)
 {
     using (UnitOfWork.Scope()) {
         var table = new StaticTableBuilder();
         table.Columns.Add("CreateTime", "150");
         table.Columns.Add("Creator", "150");
         table.Columns.Add("Contents");
         var records = GetDetailRecords(transactionId);
         foreach (var record in records)
         {
             table.Rows.Add(new {
                 CreateTime = record.CreateTime.ToClientTime(),
                 Creator    = record.Creator == null ? null : record.Creator.Username,
                 Contents   = record.Content
             });
         }
         return((HtmlString)table.ToLiquid());
     }
 }
        /// <summary>
        /// 获取订单详细记录的html
        /// </summary>
        /// <param name="orderId">订单Id</param>
        /// <returns></returns>
        public virtual HtmlString GetOrderRecordsHtml(Guid orderId)
        {
            var table = new StaticTableBuilder();

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

            foreach (var record in records)
            {
                table.Rows.Add(new {
                    Time     = record.CreateTime.ToClientTimeString(),
                    Creator  = record.Creator?.Username,
                    Contents = record.Content
                });
            }
            return((HtmlString)table.ToLiquid());
        }
示例#12
0
        public IActionResult AboutWebsite()
        {
            var privilegeManager = Application.Ioc.Resolve <PrivilegeManager>();

            privilegeManager.Check(typeof(ICanUseAdminPanel));
            var configManager   = Application.Ioc.Resolve <GenericConfigManager>();
            var pluginManager   = Application.Ioc.Resolve <PluginManager>();
            var websiteSettings = configManager.GetData <WebsiteSettings>();
            var localeSettings  = configManager.GetData <LocaleSettings>();

#if NETCORE
            var serverUsername = "";
#else
            var serverUsername = Environment.UserName;
#endif
            var zkwebVersion     = Application.Version;
            var zkwebFullVersion = Application.FullVersion;
            var memoryUsage      = SystemUtils.GetUsedMemoryBytes() / 1024 / 1024;
            var pluginInfoTable  = new StaticTableBuilder();
            pluginInfoTable.Columns.Add("DirectoryName");
            pluginInfoTable.Columns.Add("Name");
            pluginInfoTable.Columns.Add("Version");
            pluginInfoTable.Columns.Add("FullVersion");
            pluginInfoTable.Columns.Add("Description");
            pluginInfoTable.Rows.AddRange(pluginManager.Plugins.Select(p => new {
                DirectoryName = p.DirectoryName(),
                Name          = new T(p.Name),
                Version       = p.VersionObject(),
                FullVersion   = p.Version,
                Description   = new T(p.Description)
            }));
            return(new TemplateResult("common.admin/about_website.html", new {
                websiteName = websiteSettings.WebsiteName,
                defaultLanguage = localeSettings.DefaultLanguage,
                defaultTimeZone = localeSettings.DefaultTimezone,
                serverUsername = serverUsername,
                zkwebVersion = zkwebVersion.ToString(),
                zkwebFullVersion = zkwebFullVersion,
                memoryUsage = memoryUsage,
                pluginInfoTable = pluginInfoTable
            }));
        }
示例#13
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());
        }
示例#14
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());
        }
示例#15
0
        /// <summary>
        /// 绑定表单
        /// </summary>
        protected override void OnBind(OrderDelivery bindFrom)
        {
            DeliverySerial   = bindFrom.Serial;
            OrderLogistics   = new T(bindFrom.Logistics?.Name);
            LogisticsSerial  = bindFrom.LogisticsSerial;
            DeliveryOperator = new T(bindFrom.Operator?.Username);
            CreateTime       = bindFrom.CreateTime.ToClientTimeString();
            var tableBuilder = new StaticTableBuilder();

            tableBuilder.Columns.Add("Product");
            tableBuilder.Columns.Add("ThisDeliveryQuantity", "130");
            foreach (var product in bindFrom.OrderProducts)
            {
                var info = product.OrderProduct.ToDisplayInfo();
                tableBuilder.Rows.Add(new {
                    Product = info.GetSummaryHtml(),
                    ThisDeliveryQuantity = product.Count
                });
            }
            DeliveryProductTable = (HtmlString)tableBuilder.ToLiquid();
        }
示例#16
0
        /// <summary>
        /// 把Ajax表格数据的搜索回应转换为静态表格构建器
        /// </summary>
        /// <param name="response">搜索回应</param>
        /// <returns></returns>
        public static StaticTableBuilder ToTableBuilder(this AjaxTableSearchResponse response)
        {
            var builder = new StaticTableBuilder();

            // 添加列
            // 不显示Id列,序号列,操作列
            foreach (var column in response.Columns)
            {
                if (column is AjaxTableIdColumn ||
                    column.Key == "No" ||
                    column is AjaxTableActionColumn)
                {
                    continue;
                }
                builder.Columns.Add(column.Key);
            }
            // 添加行
            foreach (var row in response.Rows)
            {
                builder.Rows.Add(row);
            }
            return(builder);
        }
示例#17
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());
        }
示例#18
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());
        }
示例#19
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="table">静态表格</param>
 /// <param name="filenameWithoutExtensions">不带后缀的文件名</param>
 public StaticTableExportResult(StaticTableBuilder table, string filenameWithoutExtensions)
 {
     Table = table;
     FilenameWithoutExtensions = filenameWithoutExtensions;
 }