private async Task <IActionResult> BackToOrder() { BotMessage = new OrderViewMessage(this.Order); await EditMessage(BotMessage.BuildMsg()); return(OkResult); }
/// <summary> /// Заносим информацию о полученом платеже в бд и уведовляем об этом операторов /// </summary> /// <returns></returns> private async Task <IActionResult> SuccessfulPaymentCreditCard() { var id = Convert.ToInt32(this.Update.Message.SuccessfulPayment.InvoicePayload); this.OrderId = Convert.ToInt32(id); OrderFunction = new BusinessLayer.OrderFunction(); var Payment = OrderFunction.AddCreditCardPayment(this.OrderId, (this.Update.Message.SuccessfulPayment.TotalAmount / 100), this.Update.Message.SuccessfulPayment.ProviderPaymentChargeId, "идентификатор платежа в Telegram:" + this.Update.Message.SuccessfulPayment.TelegramPaymentChargeId); if (Payment != null) { BotMessage = new OrderViewMessage(this.OrderId); // отправляем пользователю сообщение с деталями его заказа await SendMessage(BotMessage.BuildMsg()); BotMessage = new PaymentViewMessage(Payment.Id);// отрпавляем уведомление о новом платеже всем операторам await SendMessageAllBotEmployeess(BotMessage.BuildMsg()); OrderFunction.Dispose(); } return(OkResult); }
protected override void Constructor() { if (Update.Message != null && Update.Message.ReplyToMessage != null) { CommandName = Update.Message.ReplyToMessage.Text; } try { PaymentsMethodsListMsg = new PaymentsMethodsListMessage(); if (base.Argumetns.Count > 0) { OrderId = Argumetns[0]; OrderViewMsg = new OrderViewMessage(this.OrderId); MyOrdersMsg = new MyOrdersMessage(base.FollowerId, BotInfo.Id); using (MarketBotDbContext db = new MarketBotDbContext()) Order = db.Orders.Where(o => o.Id == this.OrderId).Include(o => o.OrderConfirm). Include(o => o.OrderDone).Include(o => o.OrderDeleted). Include(o => o.OrderProduct).Include(o => o.Follower).Include(o => o.FeedBack).Include(o => o.Invoice).FirstOrDefault(); CheckPayMsg = new CheckPayMessage(Order); } RequestPhoneNumberMsg = new RequestPhoneNumberMessage(base.FollowerId); ViewShipAddressMsg = new AddressListMessage(base.FollowerId); OrderPreviewMsg = new OrderTempMessage(base.FollowerId, BotInfo.Id); } catch { } finally { } }
/// <summary> /// Показать заказ пользователя. Команда /myorder /// </summary> /// <returns></returns> private async Task <IActionResult> SendMyOrder() { try { int number = Convert.ToInt32(base.CommandName.Substring(MyOrder.Length)); using (MarketBotDbContext db = new MarketBotDbContext()) { Orders order = new Orders(); // Пользователь будет видеть заказы оформелнные через других ботов order = db.Orders.Where(o => o.Number == number && o.FollowerId == FollowerId).Include(o => o.OrderConfirm) .Include(o => o.OrderDeleted).Include(o => o.OrderDone).Include(o => o.FeedBack). Include(o => o.OrderProduct).Include(o => o.OrderAddress).Include(o => o.BotInfo).Include(o => o.Invoice).FirstOrDefault(); if (order != null) { OrderViewMsg = new OrderViewMessage(order); await SendMessage(OrderViewMsg.BuildMessage()); return(base.OkResult); } else { return(base.OkResult); } } } catch { return(base.NotFoundResult); } }
/// <summary> /// Сохрнанить /// </summary> /// <returns></returns> private async Task <IActionResult> OrderSave() { Bot.Order.InsertNewOrder insertNewOrder = new Bot.Order.InsertNewOrder(FollowerId, BotInfo); var new_order = insertNewOrder.AddOrder(); if (new_order != null && new_order.Invoice != null) { InvoiceViewMsg = new InvoiceViewMessage(new_order.Invoice, new_order.Id, "BackToMyOrder"); await EditMessage(InvoiceViewMsg.BuildMessage()); } // Если тип платежа "при получении", то отправляем уведомление о новом заказке Админам if (new_order != null && new_order.Invoice == null) { OrderViewMsg = new OrderViewMessage(new_order); await EditMessage(OrderViewMsg.BuildMessage()); await OrderRedirectToAdmins(new_order.Id); } return(OkResult); }
/// <summary> /// Показать заказ пользователя. Команда /myorder /// </summary> /// <returns></returns> private async Task <IActionResult> SendMyOrder() { try { int number = Convert.ToInt32(base.CommandName.Substring(MyOrder.Length)); OrderFunction = new OrderFunction(); this.Order = OrderFunction.GetFollowerOrder(number, FollowerId); if (this.Order != null) { BotMessage = new OrderViewMessage(this.Order); await SendMessage(BotMessage.BuildMsg()); } return(base.OkResult); } catch { return(base.OkResult); } }
/// <summary> /// Сохрнанить заказ. Перенести все данные из корзины. /// </summary> /// <returns></returns> private async Task <IActionResult> OrderSave() { Orders new_order = null; bool blocked = false; OrderFunction = new OrderFunction(); ConfigurationBot = base.GetConfigurationBot(BotInfo.Id); blocked = FollowerFunction.IsBlocked(FollowerId); if (blocked) { await AnswerCallback("Вы заблокированы администратором системы!", true); } // если в настройках бота указано время работы магазина, то проверяем подходит ли текщее время //под это правило. Если подходит то офрмляем заказ if (!blocked && ConfigurationBot.StartTime != null && ConfigurationBot.EndTime != null && ConfigurationBot.StartTime.Value.Hours <= DateTime.Now.Hour && ConfigurationBot.StartTime.Value <= DateTime.Now.TimeOfDay && ConfigurationBot.EndTime.Value > DateTime.Now.TimeOfDay) { new_order = OrderFunction.CreateOrder(FollowerId, BotInfo); } //Время работы магазина не указано. else if (!blocked && ConfigurationBot.EndTime == null && ConfigurationBot.StartTime == null) { new_order = OrderFunction.CreateOrder(FollowerId, BotInfo); } else { await AnswerCallback("Мы обрабатываем заказы только в период с " + ConfigurationBot.StartTime.ToString() + " и по " + ConfigurationBot.EndTime.ToString(), true); } if (new_order != null && new_order.Invoice != null) { BotMessage = new InvoiceViewMessage(new_order.Invoice, new_order.Id); await EditMessage(BotMessage.BuildMsg()); } if (new_order != null && new_order.Invoice == null) { BotMessage = new OrderViewMessage(new_order); await EditMessage(BotMessage.BuildMsg()); } //то отправляем уведомление о новом заказке Админам if (new_order != null) { BotMessage = new AdminOrderMessage(new_order); var message = BotMessage.BuildMsg(); await SendMessageAllBotEmployeess(message); } OrderFunction.Dispose(); return(OkResult); }