当前位置: 首页>>代码示例>>C#>>正文


C# MerchantTribeApplication.CalculateOrder方法代码示例

本文整理汇总了C#中MerchantTribeApplication.CalculateOrder方法的典型用法代码示例。如果您正苦于以下问题:C# MerchantTribeApplication.CalculateOrder方法的具体用法?C# MerchantTribeApplication.CalculateOrder怎么用?C# MerchantTribeApplication.CalculateOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MerchantTribeApplication的用法示例。


在下文中一共展示了MerchantTribeApplication.CalculateOrder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateInvoiceForStore

        // working with local dates and times
        public static void GenerateInvoiceForStore(Store s, DateTime invoiceDateLocal, MerchantTribeApplication app)
        {
            // Create an Order
            Orders.Order o = new Orders.Order();
            o.StoreId = WebAppSettings.BillingStoreId;
            app.OrderServices.Orders.Create(o);

            o.Notes.Add(new Orders.OrderNote() { IsPublic = false, Note = "Auto Generated By Invoicing System" });

            // Base Rate
            Orders.LineItem li = new Orders.LineItem();
            li.BasePricePerItem = s.CurrentPlanRate;
            li.ProductName = "BV Commerce Hosted: " + s.PlanName;
            li.ProductSku = "BVH" + s.PlanId;
            li.Quantity = 1;
            li.QuantityShipped = 1;
            li.ShippingSchedule = -1;
            o.Items.Add(li);

            // need to add Percent of sales
            decimal lastMonthSales = 0;
            // End date should be immediately before bill not, not on the bill date
            DateTime localEnd = Dates.MaxOutTime(invoiceDateLocal);
            localEnd = localEnd.AddDays(-1);
            DateTime localStart = Dates.ZeroOutTime(invoiceDateLocal).AddMonths(-1);
            lastMonthSales = app.OrderServices.Transactions.FindBillableTransactionTotal(localStart.ToUniversalTime(),
                                                                        localEnd.ToUniversalTime(),
                                                                        s.Id);
            Orders.LineItem li2 = new Orders.LineItem();
            Decimal multiplier = s.CurrentPlanPercent / 100;
            Decimal transFees = Math.Round(multiplier * lastMonthSales, 2, MidpointRounding.AwayFromZero);
            li2.BasePricePerItem = transFees;
            li2.ProductName = "Transaction Fees:";
            li2.ProductShortDescription = s.CurrentPlanPercent + "% of " + lastMonthSales.ToString("c");
            li2.ProductShortDescription += " " + localStart.ToShortDateString() + " to " + localEnd.ToShortDateString();
            li2.ProductSku = "BVHTF";
            li2.Quantity = 1;
            li2.QuantityShipped = 1;
            li2.ShippingSchedule = -1;
            o.Items.Add(li2);

            List<UserAccount> users = app.AccountServices.FindAdminUsersByStoreId(s.Id);
            if (users != null)
            {
                if (users.Count > 0)
                {
                    UserAccount u = users[0];
                    o.UserEmail = u.Email;

                    Service svc = new Service(WebAppSettings.ApplicationConnectionString);
                    BillingAccount act = svc.Accounts.FindOrCreate(u.Email);
                    if (act != null)
                    {
                        o.BillingAddress.RegionData.Abbreviation = string.Empty;
                        o.BillingAddress.RegionName = string.Empty;
                        o.BillingAddress.PostalCode = act.BillingZipCode;
                        o.BillingAddress.FirstName = act.CreditCard.CardHolderName;
                        o.BillingAddress.Company = s.StoreName;

                        app.CalculateOrder(o);

                        Orders.OrderPaymentManager payManager = new Orders.OrderPaymentManager(o, app);
                        payManager.CreditCardAddInfo(act.CreditCard, o.TotalGrand);

                        o.OrderNumber = app.OrderServices.GenerateNewOrderNumber(WebAppSettings.BillingStoreId).ToString();
                        o.StatusCode = Orders.OrderStatusCode.Received;
                        o.IsPlaced = true;
                        o.TimeOfOrderUtc = DateTime.UtcNow;
                        o.EvaluateCurrentShippingStatus();

                        app.OrderServices.Orders.Update(o);
                    }
                }
            }
        }
开发者ID:NightOwl888,项目名称:MerchantTribe,代码行数:76,代码来源:BillingManager.cs


注:本文中的MerchantTribeApplication.CalculateOrder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。