Exemplo n.º 1
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());
        }
Exemplo n.º 2
0
        /// <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());
        }
Exemplo n.º 3
0
        /// <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());
        }
Exemplo n.º 4
0
        /// <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();
        }
Exemplo n.º 5
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());
        }
Exemplo n.º 6
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());
        }
Exemplo n.º 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());
        }
 /// <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());
     }
 }
Exemplo n.º 9
0
        /// <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());
        }
Exemplo n.º 10
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());
        }
Exemplo n.º 11
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());
        }
Exemplo n.º 12
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();
        }
Exemplo n.º 13
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());
        }
Exemplo n.º 14
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());
        }