public static async Task <IDisposableEntity <Order> > CreateOrderAsync( this TestServiceScope scope, Registration registration, Product[] products = null, ProductVariant[] variants = null, int[] quantities = null, Order.OrderStatus status = Order.OrderStatus.Verified) { var order = new Order { Registration = registration, Status = status, OrderLines = products?.Select((p, i) => new OrderLine { Product = p, ProductVariant = variants != null && variants.Length > i ? variants[i] : null, Quantity = quantities != null && quantities.Length > i ? quantities[i] : p.MinimumQuantity, VatPercent = p.VatPercent, Price = p.Price, ProductName = p.Name }).ToList() }; await scope.Db.Orders.AddAsync(order); await scope.Db.SaveChangesAsync(); return(new DisposableEntity <Order>(order, scope.Db)); }
/// <summary> /// Updates all the orders. Adds and subtracts money spent buying and selling. /// </summary> /// <param name="currentDate">Current date of the simulation</param> private void UpdateOrders(DateTime currentDate) { // Update all the open orders. for (int i = 0; i < _activeOrders.Count; i++) { Order order = _activeOrders[i]; // Save the previous status befure the update so we can see if it got filled this update. Order.OrderStatus previousStatus = order.Status; int barNum = order.Ticker.GetBar(currentDate); if (barNum != -1) { order.Update(barNum); } // If the order was open before the update, then there are two possible outcomes: // 1. It filled and did NOT close this update. // 2. It filled and did close this update. if (previousStatus == Order.OrderStatus.Open) { // If it filled but didn't close, then subtract it from our cash. if (order.Status == Order.OrderStatus.Filled) { Broker.AccountCash -= order.NumberOfShares * order.BuyPrice; } // If it closed the same bar then it opened, we haven't had a simulated bar to subtract // the cost from our cash, so just add the gain back to the cash. else if (order.IsFinished()) { Broker.AccountCash += order.Gain; } } // If the order just finished then add the value back because we deducted the cash from // when the order was filled on a previous update. else if (previousStatus == Order.OrderStatus.Filled && order.IsFinished()) { Broker.AccountCash += order.Value; } } // Remove the orders that are finished. This will just remove them from // this array but they order will still be saved in the order history. _activeOrders.RemoveAll(order => order.IsFinished() || order.Status == Order.OrderStatus.Cancelled); double accountValue = 0; for (int i = 0; i < _activeOrders.Count; i++) { Order order = _activeOrders[i]; accountValue += order.Value; } // Save the current value at the end of the frame. accountValue += Broker.AccountCash; Broker.CurrentAccountValue = accountValue; Broker.AddValueToList(currentDate, accountValue); }
void UpdateStatus(Order.OrderStatus status) { bool result = Order.UpdateStatus(lblOrderID.Text, status); lblStatus.Text = result ? "Update successful" : "Update failed"; if (result) { ddlStatus.SelectedValue = ((int)status).ToString(); } }
public IActionResult GetAllOrders(int CustomerId, Order.OrderStatus orderstatus) { if (CustomerId == 0) { return(new ObjectResult(_repository.GetAll())); } else { return(new ObjectResult(_repository.GetByCustomer(CustomerId))); } }
public static async Task <IDisposableEntity <Order> > CreateOrderAsync( this TestServiceScope scope, Registration registration, Product[] products = null, ProductVariant[] variants = null, int[] quantities = null, ApplicationUser user = null, string userId = null, Order.OrderStatus status = Order.OrderStatus.Verified, PaymentMethod.PaymentProvider paymentProvider = PaymentMethod.PaymentProvider.EmailInvoice, Instant?time = null) { var order = new Order { OrderTime = time ?? SystemClock.Instance.Now(), UserId = user?.Id ?? userId ?? registration.UserId, Registration = registration, PaymentMethod = paymentProvider, OrderLines = products?.Select((p, i) => new OrderLine { Product = p, ProductVariant = variants?.Length > i ? variants[i] : null, Quantity = quantities?.Length > i ? quantities[i] : p.MinimumQuantity, ProductDescription = products[i].Description, ProductVariantDescription = variants?.Length > i ? variants[i]?.Description : null, VatPercent = p.VatPercent, Price = variants?.Length > i ? variants[i]?.Price ?? p.Price : p.Price, ProductName = p.Name, ProductVariantName = variants?.Length > i ? variants[i]?.Name : null, }).ToList() }; if (status == Order.OrderStatus.Invoiced || status == Order.OrderStatus.Refunded) { order.Status = Order.OrderStatus.Verified; } if (status == Order.OrderStatus.Refunded) { order.Status = Order.OrderStatus.Invoiced; } if (status != Order.OrderStatus.Draft) { order.Status = status; } await scope.Db.Orders.AddAsync(order); await scope.Db.SaveChangesAsync(); return(new DisposableEntity <Order>(order, scope.Db)); }
public static bool UpdateStatus(string orderId, Order.OrderStatus status) { try { int result = DataProvider.Instance.ExecuteNonQuery("Order_UpdateStatus", Convert.ToInt32(orderId), (int)status); return(result > 0); } catch (Exception) { return(false); } }
public Collection <Order> FindByStatus(Order.OrderStatus orderVal) { Collection <Order> matches = new Collection <Order>(); foreach (Order order in orders) { if (order.OrderValue == orderVal) { matches.Add(order); } } return(matches); }
public static async Task <IDisposableEntity <Order> > CreateOrderAsync( this ApplicationDbContext context, Registration registration, Product product, ProductVariant variant = null, int quantity = 1, Order.OrderStatus status = Order.OrderStatus.Verified) { return(await context.CreateOrderAsync(registration, new[] { product }, variant != null?new[] { variant } : null, new[] { quantity }, status)); }
public static async Task <IDisposableEntity <Order> > CreateOrderAsync( this TestServiceScope scope, Registration registration, Product product, ProductVariant variant = null, int quantity = 1, Order.OrderStatus status = Order.OrderStatus.Verified) { return(await scope.CreateOrderAsync(registration, new[] { product }, variant != null?new[] { variant } : null, new[] { quantity }, status)); }
private string _skuCode; // Added by KK on 2016/06/05. //private string _subjectId; // index for subject in subject list. //public OrderItemDetails(string orderId, string item, float price, int amount, string prop, Order.OrderStatus status) public OrderItemDetails(string orderId, string subject, float price, int amount, string code, Order.OrderStatus status, string skuCode) { _orderId = orderId; _price = price; _amount = amount; _code = code; //_prop = prop; _status = status; _subject = subject; // Removed by KK on 2016/06/05. //_subjectId = SubjectInfo.GetSubjectId(_subject); _skuCode = skuCode; }
public static string PresenetStatus(Order.OrderStatus status) { switch (status) { case Order.OrderStatus.Received: return("Recibida"); case Order.OrderStatus.Started: return("Empezada"); case Order.OrderStatus.Finished: return("Terminda"); default: throw new ArgumentOutOfRangeException(nameof(status), status, null); } }
//public virtual IQueryable<Customer> UspGetAllCustomers() => // FromExpression(() => UspGetAllCustomers()); public virtual void UspSetOrderStatus(Order.OrderStatus oldOrderStatus, Order.OrderStatus newOrderStatus) { var oldOrderStatusParam = new Microsoft.Data.SqlClient.SqlParameter() { ParameterName = "@oldOrderStatus", SqlDbType = System.Data.SqlDbType.Int, SqlValue = (int)oldOrderStatus }; var newOrderStatusParam = new Microsoft.Data.SqlClient.SqlParameter() { ParameterName = "@newOrderStatus", SqlDbType = System.Data.SqlDbType.Int, SqlValue = (int)newOrderStatus }; Database.ExecuteSqlRaw("EXEC uspSetOrderStatus @oldOrderStatus, @newOrderStatus", oldOrderStatusParam, newOrderStatusParam); }
public static async Task <IDisposableEntity <Order> > CreateOrderAsync( this TestServiceScope scope, Registration registration, Product product, ProductVariant variant = null, int quantity = 1, Order.OrderStatus status = Order.OrderStatus.Verified, ApplicationUser user = null, string userId = null, PaymentMethod.PaymentProvider paymentProvider = PaymentMethod.PaymentProvider.EmailInvoice) { return(await scope.CreateOrderAsync(registration, new[] { product }, variant != null?new[] { variant } : null, new[] { quantity }, user, userId, status, paymentProvider)); }
private static string GetStautsDesc(Order.OrderStatus status) { switch (status) { case OrderParser.Order.OrderStatus.Deal: return("未付款"); case OrderParser.Order.OrderStatus.Paid: return("已付款"); case OrderParser.Order.OrderStatus.Sent: return("已发货"); case OrderParser.Order.OrderStatus.Succeeded: return("交易成功"); case OrderParser.Order.OrderStatus.Closed: return("已取消"); } return(string.Empty); }
private static string GetStatusDescColor(Order.OrderStatus status) { switch (status) { case OrderParser.Order.OrderStatus.Deal: return("#808080"); case OrderParser.Order.OrderStatus.Paid: return("#ff4000"); case OrderParser.Order.OrderStatus.Sent: return("#800080"); case OrderParser.Order.OrderStatus.Succeeded: return("#008000"); case OrderParser.Order.OrderStatus.Closed: return("#d0d0d0"); } return("#404040"); }
//private bool ContainsBondedProducts(List<Order> orders) //{ // if (null == orders || orders.Count <= 0) // return false; // foreach (Order o in orders) // { // if (o.Items.Contains("保税区")) // return true; // } // return false; //} // 从多个订单中提取产品信息, 相同产品合并计数. private List <SoldProductInfo> GetProducts(List <Order> orders, out int cMustSendFromDe, out int cBonded) { cMustSendFromDe = 0; cBonded = 0; SortedList <string, SoldProductInfo> sortedProducts = new SortedList <string, SoldProductInfo>(); foreach (Order o in orders) { string allItems = o.Items; string[] items = allItems.Split('★'); for (int i = 0; i < items.Length; i++) { string item = items[i]; string[] infos = item.Split('☆'); if (infos.Length < 3) { continue; } if (string.IsNullOrEmpty(infos[0])) { Trace.WriteLine("null product found!!!"); } string productTitle = infos[0]; int count = int.Parse(infos[2]); ProductInfo pi = ProductInfo.Match(productTitle, o.Remark); if (null == pi) { continue; } for (int c = 16; c > 0; c--) { if (productTitle.Contains(string.Format("{0}盒装", c)) || productTitle.Contains(string.Format("{0}罐装", c))) { count *= c; break; } } //// 双11链接, 1+12盒链接, 1+4盒链接, 2+12盒链接, 2+4盒链接, 3段4罐链接 //if (productTitle.Contains("12盒包邮包税") || productTitle.Contains("直邮12盒")) // count *= 12; //if (productTitle.Contains("直邮9罐")) // count *= 9; //if (productTitle.Contains("现货4盒")) // count *= 4; //if (productTitle.Contains("现货4罐")) // count *= 4; //if (productTitle.Contains("3罐")) // count *= 3; //if (pi.Id.Equals("001-0005") && productTitle.Contains("12盒包邮包税")) // count *= 12; //if (pi.Id.Equals("001-0005") && productTitle.Contains("4盒")) // count *= 4; //if (pi.Id.Equals("001-0006") && productTitle.Contains("12盒包邮包税")) // count *= 12; //if (pi.Id.Equals("001-0006") && productTitle.Contains("4盒")) // count *= 4; //if (pi.Id.Equals("001-0004") && productTitle.Contains("4罐")) // count *= 4; Order.OrderStatus status = (Order.OrderStatus)Enum.Parse(typeof(Order.OrderStatus), infos[3]); bool succeeded = false; bool cancelled = false; bool sent = false; if (infos.Length >= 4) { succeeded = (status == Order.OrderStatus.Succeeded); cancelled = (status == Order.OrderStatus.Closed); sent = (status == Order.OrderStatus.Sent); } if (succeeded || cancelled || sent) { continue; } string code = string.Empty; if (infos.Length >= 5) { code = infos[4]; } if (code.ToLower().StartsWith("d-")) { cMustSendFromDe++; continue; } // Removed by KK on 2015/09/18. // 保税区不再设单独链接, 可以/可能跟其他链接共用. // 同时, cBonded不再准确. //if (!code.ToLower().StartsWith("b-") && !productTitle.Contains("保税区")) // continue; cBonded++; bool bingo = false; foreach (SoldProductInfo spi in sortedProducts.Values) { if (spi.Id.Equals(pi.Id)) { bingo = true; spi.AddCount(count); break; } } if (!bingo) { sortedProducts.Add(pi.Id, new SoldProductInfo(pi.Id, pi.BrandId, pi.SkuCode, pi.NingboId, pi.DangdangCode, pi.Name, pi.Price, pi.Specification, pi.ShortName, pi.Keywords, pi.Conflict, count, status, code)); } //products.Add(new SoldProductInfo(pi.Id, pi.BrandId, pi.Name, pi.Price, pi.Specification, pi.ShortName, pi.Keywords, count, status)); } } List <SoldProductInfo> products = new List <SoldProductInfo>(); foreach (SoldProductInfo p in sortedProducts.Values) { products.Add(p); } return(products); }
public SoldProductInfo(string id, string brandId, string skuCode, string ningboId, string dangdangCode, string name, float price, string specification, string shortName, string keywords, bool conflict, int count, Order.OrderStatus status, string taobaoCode) : base(id, brandId, skuCode, ningboId, dangdangCode, name, price, specification, shortName, keywords, conflict) { _count = count; _status = status; _taobaoCode = taobaoCode; }
public void AddProduct(string title, float price, int amount, Order.OrderStatus orderStatus) { Label lblTitle = new Label(); lblTitle.Text = title; lblTitle.AutoSize = true; lblTitle.Margin = new Padding(0, 0, 0, 0); lblTitle.Padding = new Padding(0, 0, 0, 0); lblTitle.ForeColor = Color.RoyalBlue; lblTitle.Font = this.Font; Label lblStatus = new Label(); lblStatus.AutoSize = true; lblStatus.Margin = new Padding(0, 0, 0, 0); lblStatus.Padding = new Padding(0, 0, 0, 0); lblStatus.Font = this.Font; Panel pnlTitle = new Panel(); pnlTitle.AutoSize = true; pnlTitle.AutoSizeMode = AutoSizeMode.GrowAndShrink; pnlTitle.Margin = new Padding(0, 0, 16, 0); pnlTitle.BackColor = Color.Transparent; pnlTitle.Controls.AddRange(new Control[] { lblTitle, lblStatus }); //lblStatus.BringToFront(); lblTitle.Location = new Point(0, 0); lblStatus.Location = new Point(lblTitle.Right - 6, 0); Label lblPrice = new Label(); lblPrice.Text = price.ToString("0.00"); lblPrice.AutoSize = true; lblPrice.Margin = new Padding(0, 0, 16, 0); lblPrice.ForeColor = Color.OrangeRed; lblPrice.Font = this.Font; Label lblAmount = new Label(); lblAmount.Text = amount.ToString(); lblAmount.AutoSize = true; lblAmount.Margin = new Padding(0, 0, 6, 0); lblAmount.ForeColor = Color.FromArgb(0x60, 0x60, 0x60); lblAmount.Font = new Font(this.Font, FontStyle.Bold); tblMain.Controls.AddRange(new Control[] { pnlTitle, lblPrice, lblAmount }); switch (orderStatus) { case Order.OrderStatus.Deal: lblStatus.Text += " (未付款)"; lblStatus.ForeColor = Color.Gray; break; case Order.OrderStatus.Paid: lblStatus.Text += " (已付款)"; lblStatus.ForeColor = Color.OrangeRed; break; case Order.OrderStatus.Sent: lblStatus.Text += " (已发货)"; lblStatus.ForeColor = Color.Purple; break; case Order.OrderStatus.Succeeded: lblStatus.Text += " (交易成功)"; lblStatus.ForeColor = Color.DarkGreen; break; case Order.OrderStatus.Closed: lblTitle.ForeColor = Color.Gray; lblStatus.ForeColor = Color.Gray; lblPrice.ForeColor = Color.Gray; lblAmount.ForeColor = Color.Gray; lblStatus.Text += " (已取消)"; break; } }
public void SetOrderStatus(Order order, Order.OrderStatus status) { order.Status = status; }