/// <summary>
        /// Показать платеж по id счета
        /// </summary>
        /// <param name="InvoiceId"></param>
        /// <param name="MessageId"></param>
        /// <returns></returns>
        private async Task <IActionResult> SendViewPayment(int PaymentId, int MessageId = 0)
        {
            try
            {
                var Payment = PaymentsFunction.GetPayment(PaymentId);

                if (Payment != null)
                {
                    BotMessage = new PaymentViewMessage(Payment);
                    await SendMessage(BotMessage.BuildMsg(), MessageId);
                }

                else
                {
                    await AnswerCallback("Данные по оплате отсутствуют", true);
                }

                return(OkResult);
            }

            catch
            {
                return(OkResult);
            }
        }
        public async Task <IActionResult> Run()
        {
            try
            {
                BotInfo = Bot.GeneralFunction.GetBotInfo();

                PaymentsFunction = new PaymentsFunction();

                var InvoiceList = PaymentsFunction.FindNoPaidInvoice(); //Находим все не оплаченые чеки

                TelegramBotClient = new TelegramBotClient(BotInfo.Token);

                foreach (var invoice in InvoiceList)
                {
                    var result = await PaymentsFunction.CheckPaidInvoice(invoice);

                    if (result != null && result.Paid && result.Payment.Count > 0) // владельцу бота
                    {
                        await TelegramBotClient.SendTextMessageAsync(BotInfo.OwnerChatId, "Поступил новый платеж /payment" + result.Payment.LastOrDefault().Id.ToString());
                    }

                    if (result != null && result.Paid && result.Payment.Count > 0) // в чат
                    {
                        await TelegramBotClient.SendTextMessageAsync(BotInfo.Configuration.PrivateGroupChatId, "Поступил новый платеж /payment" + result.Payment.LastOrDefault().Id.ToString());
                    }
                }

                return(Ok());
            }

            catch
            {
                return(NotFound());
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Платежи
        /// </summary>
        private void CreatePaymentWorksheet()
        {
            PaymentList = PaymentsFunction.GetPaymentsList();

            // шапка
            PaymentkWorksheet.Cells[1, 1].Value = "Номер заказа";
            PaymentkWorksheet.Cells[1, 2].Value = "Дата";
            PaymentkWorksheet.Cells[1, 3].Value = "Id платежа";
            PaymentkWorksheet.Cells[1, 4].Value = "Номер транзакции";
            PaymentkWorksheet.Cells[1, 5].Value = "Комменатрий";
            PaymentkWorksheet.Cells[1, 6].Value = "Адрес счета получателя";
            PaymentkWorksheet.Cells[1, 7].Value = "Сумма";
            PaymentkWorksheet.Cells[1, 8].Value = "Платежная система";

            int row = 2;

            foreach (var payment in PaymentList)
            {
                //Номер заказа
                PaymentkWorksheet.Cells[row, 1].Value = payment.Invoice.Orders.FirstOrDefault().Number;

                //Дата
                PaymentkWorksheet.Cells[row, 2].Value = payment.TimestampDataAdd.ToString();

                //Id платежа
                PaymentkWorksheet.Cells[row, 3].Value = payment.Id;

                //Номер транзакции
                PaymentkWorksheet.Cells[row, 4].Value = payment.TxId;

                //Комменатрий
                PaymentkWorksheet.Cells[row, 5].Value = payment.Comment;

                //Адрес счета получателя
                PaymentkWorksheet.Cells[row, 6].Value = payment.Invoice.AccountNumber;

                //Сумма
                PaymentkWorksheet.Cells[row, 7].Value = payment.Summ;

                //Платежная система
                PaymentkWorksheet.Cells[row, 8].Value = payment.Invoice.PaymentType.Name;
            }
        }
        /// <summary>
        /// Показать детали платежа /payment[id]
        /// </summary>
        /// <returns></returns>
        private async Task <IActionResult> SendViewPayment()
        {
            try
            {
                int Id = Convert.ToInt32(base.CommandName.Substring(PaymentCmd.Length));

                var Payment = PaymentsFunction.GetPayment(Id);

                BotMessage = new PaymentViewMessage(Payment);
                await SendMessage(BotMessage.BuildMsg());

                return(OkResult);
            }

            catch
            {
                return(OkResult);
            }
        }
        public override InlineQueryResult[] GetResult()
        {
            var list = PaymentsFunction.GetPaymentsList().Take(MaxResult).ToList();


            InputTextMessageContent[]  textcontent = new InputTextMessageContent[list.Count];
            InlineQueryResultArticle[] article     = new InlineQueryResultArticle[list.Count];
            InlineQueryResult[]        result      = new InlineQueryResult[list.Count];

            int i = 0;

            foreach (var payment in list)
            {
                //PaymentViewMsg = new Messages.Admin.PaymentViewMessage(payment);
                //BotMessage mess = PaymentViewMsg.BuildMsg();

                textcontent[i]                       = new InputTextMessageContent();
                textcontent[i].ParseMode             = Telegram.Bot.Types.Enums.ParseMode.Html;
                textcontent[i].DisableWebPagePreview = true;
                textcontent[i].MessageText           = "/payment" + payment.Id.ToString();

                article[i]             = new InlineQueryResultArticle();
                article[i].HideUrl     = false;
                article[i].Id          = payment.Id.ToString();
                article[i].Title       = "Платеж №" + payment.Id.ToString();
                article[i].Description = payment.TimestampDataAdd.ToString();

                article[i].ThumbUrl = "https://cdn2.iconfinder.com/data/icons/shop-payment-vol-6/128/shop-01-256.png";
                //article[i].ReplyMarkup = mess.MessageReplyMarkup;
                article[i].InputMessageContent = textcontent[i];


                result[i] = new InlineQueryResult();
                result[i] = article[i];

                i++;
            }

            return(result);
        }
Exemplo n.º 6
0
        public override BotMessage BuildMsg()
        {
            if (Payment == null)
            {
                Payment = PaymentsFunction.GetPayment(PaymentId);
            }

            if (Payment != null && Payment.Invoice != null && Payment.Invoice.Orders.Count > 0)
            {
                ViewOrderBtn = BuildInlineBtn("Детали заказа", BuildCallData(OrderProccesingBot.CmdGetOrderAdmin, OrderProccesingBot.ModuleName, Payment.Invoice.Orders.FirstOrDefault().Id), base.PackageEmodji);

                ViewInvoiceBtn = BuildInlineBtn("Счет", BuildCallData(OrderProccesingBot.ViewInvoiceCmd, OrderProccesingBot.ModuleName, Payment.Invoice.Orders.FirstOrDefault().Id), base.PaperEmodji);

                SearchPaymentBtn = InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Платежи" + base.CreditCardEmodji, InlineFind.Payment + "|");

                base.TextMessage = "Платеж №" + Payment.Id.ToString() + " для Заказа №" + Payment.Invoice.Orders.FirstOrDefault().Number.ToString()
                                   + NewLine() + Bold("Дата добавления платежа:") + Payment.TimestampDataAdd.ToString() + NewLine() +
                                   Bold("Сумма:") + Payment.Summ.ToString() + NewLine() +
                                   Bold("ID Транзакции:") + Payment.TxId.ToString();

                base.MessageReplyMarkup = new InlineKeyboardMarkup(new[]
                {
                    new[]
                    {
                        ViewInvoiceBtn
                    },
                    new[]
                    {
                        ViewOrderBtn
                    },
                    new[]
                    {
                        SearchPaymentBtn
                    }
                });
            }
            return(this);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Кнопка  я оплатил. ПРоверка платежа
        /// </summary>
        /// <returns></returns>
        private async Task <IActionResult> CheckPay()
        {
            PaymentsFunction paymentsFunction = new PaymentsFunction();
            var invoice = await paymentsFunction.CheckPaidInvoice(OrderId);

            paymentsFunction.Dispose();

            if (invoice != null && invoice.Payment.Count > 0 && invoice.Paid) // платеж найден и счет имеет статут Оплачен
            {
                BotMessage = new InvoiceViewMessage(invoice, OrderId);
                await EditMessage(BotMessage.BuildMsg());

                //уведомляем сотрудников о поступлении платежа
                PaymentViewMessage paymentViewMessage = new PaymentViewMessage(invoice.Payment.LastOrDefault().Id);
                await SendMessageAllBotEmployeess(paymentViewMessage.BuildMsg());
            }

            else
            {
                await AnswerCallback("Платеж не найден", true);
            }

            return(OkResult);
        }