1
0
forked from BRT/arc
arc/android/rshb/PayByPhoneScript.cpp
slava 59cef50ad3 Add enhanced account and transaction handling features
Refactored code to improve account and transaction data parsing and management, introducing support for additional fields like card numbers and account statuses. Added new utilities for database connections, device-specific screenshot handling, and XML parsing for enriched account and transaction details.
2025-05-07 14:15:08 +07:00

56 lines
1.7 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.

#include "PayByPhoneScript.h"
#include <utility>
#include "DatabaseManager.h"
#include "dao/AccountDAO.h"
#include "dao/ApplicationDAO.h"
#include "dao/DeviceDAO.h"
#include "dao/TransactionDAO.h"
#include "db/ApplicationInfo.h"
#include "db/DeviceInfo.h"
PayByPhoneScript::PayByPhoneScript(
AccountInfo account,
QString phone,
QString bankName,
const double amount,
QObject *parent
) : CommonScript(parent),
m_account(std::move(account)), m_phone(std::move(phone)),
m_bankName(std::move(bankName)), m_amount(amount) {
}
PayByPhoneScript::~PayByPhoneScript() = default;
void PayByPhoneScript::doStart() {
const DeviceInfo device = DeviceDAO::getDeviceById(m_account.deviceId);
const ApplicationInfo app = ApplicationDAO::getApplicationsByDeviceId(m_account.deviceId, m_account.appName);
if (device.id.isEmpty() || app.id.isEmpty()) {
qDebug() << "Device or app not found....";
return;
}
m_width = device.screenWidth;
m_height = device.screenHeight;
m_pinCode = app.pinCode;
m_packageName = app.package;
if (runAppAndGoToHomeScreen()) {
if (goToAllProducts()) {
QList<AccountInfo> accounts = xmlScreenParser.parseAccountsInfo();
for (AccountInfo &account: accounts) {
account.deviceId = m_account.deviceId;
account.appName = m_account.appName;
if (!AccountDAO::upsertAccount(account)) {
qDebug() << "Not updated: " << account.lastNumbers;
}
}
} else {
qDebug() << "Не смогли открыть 'Все продукты'";
}
} else {
qDebug() << "Не смогли дойти до домашней страницы....";
}
}