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.
56 lines
1.7 KiB
C++
56 lines
1.7 KiB
C++
#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() << "Не смогли дойти до домашней страницы....";
|
||
}
|
||
}
|