Example #1
0
async def menu_info_order(orderID, message):
    mes = config.adminMessage["order_missing"]
    keyboard = None
    order = ordersProcessingModel.get_order_provisional(orderID)
    if order:
        mes = config.adminMessage["order_pr_detailed_info"].format(
            orderID=order.id,
            userID=order.userID,
            text=order.text,
            discount=str(order.discount) + ("%" if order.percent else " р."),
            payment="по частям" if order.separate_payment else " целиком",
            date=time.strftime('%Y-%m-%d %H:%M:%S',
                               time.localtime(order.date)))
        mes += "" if order.active else "<b>Заказ выполнен</b>"
        keyboard = await buttons.getActionKeyboard(
            order.id,
            OrderProcessingSend="Отправить форму оплаты",
            OrderProcMessageSend="Написать",
            OrderProcessingCloser="Отказать") if order.active else None
        if len(order.document) == 1:
            await message.answer_document(caption=mes,
                                          document=order.document[0],
                                          reply_markup=keyboard)
            return
        elif len(order.document) > 1:
            for document in order.document:
                await message.answer_document(document=document)
    await message.answer(text=mes, reply_markup=keyboard)
Example #2
0
async def menu_close_order(orderID, message, state):
    mes = config.adminMessage["order_missing"]
    keyboard = None
    order = ordersProcessingModel.get_order_provisional(orderID)
    if order and not order.active:
        mes = config.adminMessage["order_completed"]
    elif order:
        await state.update_data(orderID=order.id)
        await AdminCloseOrderPr.message.set()
        mes = config.adminMessage["order_close_text"]
        keyboard = await buttons.getCustomKeyboard(cancel="Отмена")
    await message.answer(text=mes, reply_markup=keyboard)
Example #3
0
async def message_send_yes(call: types.CallbackQuery, state: FSMContext):
    await call.answer()
    mes = config.adminMessage["order_missing"]
    data = await state.get_data()
    order = ordersProcessingModel.get_order_provisional(data.get("orderID"))
    if order:
        text = config.adminMessage["order_send_mes"].format(orderID=order.id)
        text += data.get("text")
        await bot.send_message(chat_id=order.userID, text=text)
        await menu_info_order(order.id, call.message)
        mes = config.adminMessage["message_yes_send"]
    await state.finish()
    await call.message.edit_text(mes)
Example #4
0
async def message_send_yes(call: types.CallbackQuery, state: FSMContext):
    await call.answer(cache_time=2)
    mes = "Все пропало ((("
    data = await state.get_data()
    order = ordersProcessingModel.get_order_provisional(data.get("orderID"))
    if order and not order.active:
        mes = config.adminMessage["order_completed"]
    elif order:
        amount = int(data.get("price")) - (
            int(data.get("price")) / 100 * order.discount
            if order.percent and order.discount != 0 else order.discount)
        amount = int(amount)
        amount = amount if order.separate_payment else int(
            amount - (amount / 100 * config.discount_full_payment))
        if amount < 100:
            await state.finish()
            await call.message.edit_text(
                "Вышла сумма меньше 100р.\nОтправка отменена")
            return
        PRICE = types.LabeledPrice(
            label="Работа на заказ",
            amount=(int(amount / 2) if order.separate_payment else amount) *
            100)
        secret_key = hashlib.md5("{nameProduct}{time}".format(
            nameProduct="Работа на заказ", time=time.time()).encode())
        await bot.send_invoice(chat_id=order.userID,
                               title=config.payMessage["title"],
                               description=config.payMessage["description"],
                               provider_token=config.PAYMENT_TOKEN,
                               currency=config.currency,
                               is_flexible=False,
                               prices=[PRICE],
                               start_parameter='time-machine-example',
                               payload=secret_key.hexdigest())
        paymentModel.create_payment(call.from_user.id, order.text,
                                    order.document, order.separate_payment,
                                    amount, secret_key.hexdigest(), False)
        order.updateActive_order()
        mes = config.adminMessage["message_yes_send"]
    await state.finish()
    await call.message.edit_text(mes)