1
0
forked from BRT/arc
arc/android/ozon/GetLastTransactionsScript.h

60 lines
2.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include "CommonScript.h"
#include <QDateTime>
#include <QJsonObject>
#include <QList>
#include <QPair>
#include "db/DeviceInfo.h"
#include "db/BankProfileInfo.h"
namespace Ozon {
class GetLastTransactionsScript final : public CommonScript {
Q_OBJECT
signals:
// Испускается на КАЖДУЮ найденную транзакцию из списка целей.
void transactionParsed(const QJsonObject &tx);
public:
explicit GetLastTransactionsScript(
QString deviceId,
QString appCode,
int maxCount = 0,
QList<QPair<double, QDateTime>> targets = {},
QString materialId = {},
QObject *parent = nullptr
);
~GetLastTransactionsScript() override;
protected:
void doStart() override;
private:
// Навигация до экрана "Операции", возвращает true если успешно
bool navigateToTransactionList(const DeviceInfo &device, const BankProfileInfo &app);
// Сканирование последних транзакций (для UI: 24ч или maxCount)
void scanRecentTransactions(const DeviceInfo &device, int accountId);
// Поиск одной конкретной транзакции по сумме и времени (FETCH_TRANSACTIONS).
// Возвращает true и эмитит transactionParsed, если нашли; false — если нет.
bool searchOne(const DeviceInfo &device, int accountId,
double searchAmount, const QDateTime &searchTime);
// Быстрый возврат к началу списка операций (между поисками целей)
void scrollListToTop(const DeviceInfo &device);
QString m_deviceId;
const QString m_appCode;
const int m_maxCount; // 0 = фильтр по 24ч, >0 = N последних
// Список целей поиска: пары (сумма в рублях со знаком, примерное время UTC).
// Пустой список → режим сканирования последних (scanRecentTransactions).
const QList<QPair<double, QDateTime>> m_targets;
const QString m_materialId; // UUID задачи (для сохранения дампов)
QString m_error;
};
} // namespace Ozon