Emit parsed transaction data as a signal to streamline GetLastTransactionsScript integration with EventHandler.
This commit is contained in:
parent
33c8420910
commit
d235508c70
@ -1,5 +1,7 @@
|
|||||||
#include "GetLastTransactionsScript.h"
|
#include "GetLastTransactionsScript.h"
|
||||||
|
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
@ -466,6 +468,32 @@ void GetLastTransactionsScript::searchTransaction(const DeviceInfo &device, int
|
|||||||
TransactionDAO::insertTransactionIfNotExists(tx);
|
TransactionDAO::insertTransactionIfNotExists(tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Отдаём результат в EventHandler через сигнал (как Dushanbe)
|
||||||
|
{
|
||||||
|
const QString finalExternalId = externalId.isEmpty()
|
||||||
|
? QString("ozon_") + QString(dtStr).remove(',').trimmed().replace(' ', '_')
|
||||||
|
: externalId;
|
||||||
|
|
||||||
|
QJsonObject txJson;
|
||||||
|
txJson["bank_transaction_id"] = finalExternalId;
|
||||||
|
txJson["amount"] = static_cast<int>(parsed.amount * 100);
|
||||||
|
txJson["currency"] = 643; // RUB
|
||||||
|
txJson["transaction_type"] = "bank";
|
||||||
|
QString participator = detail.phone;
|
||||||
|
if (participator.isEmpty()) participator = detail.name;
|
||||||
|
txJson["bank_participator_id"] = participator;
|
||||||
|
txJson["status"] = "completed";
|
||||||
|
QJsonObject extraObj;
|
||||||
|
extraObj["fee"] = 0;
|
||||||
|
txJson["extra"] = extraObj;
|
||||||
|
txJson["created_at"] = txTime.isValid()
|
||||||
|
? txTime.toUTC().toString(Qt::ISODate) : QJsonValue(QJsonValue::Null);
|
||||||
|
|
||||||
|
qDebug() << "[FetchTransactions] Emitting parsed tx:"
|
||||||
|
<< QJsonDocument(txJson).toJson(QJsonDocument::Compact);
|
||||||
|
emit transactionParsed(txJson);
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_resultScreenshot.isEmpty())
|
if (!m_resultScreenshot.isEmpty())
|
||||||
emit screenshotReady(m_resultScreenshot);
|
emit screenshotReady(m_resultScreenshot);
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "CommonScript.h"
|
#include "CommonScript.h"
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QJsonObject>
|
||||||
#include "db/DeviceInfo.h"
|
#include "db/DeviceInfo.h"
|
||||||
#include "db/BankProfileInfo.h"
|
#include "db/BankProfileInfo.h"
|
||||||
|
|
||||||
@ -9,6 +10,9 @@ namespace Ozon {
|
|||||||
class GetLastTransactionsScript final : public CommonScript {
|
class GetLastTransactionsScript final : public CommonScript {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void transactionParsed(const QJsonObject &tx);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GetLastTransactionsScript(
|
explicit GetLastTransactionsScript(
|
||||||
QString deviceId,
|
QString deviceId,
|
||||||
|
|||||||
@ -454,6 +454,9 @@ void EventHandler::startThreadForTask(const MaterialInfo &account, const EventIn
|
|||||||
if (appCode == "ozon") {
|
if (appCode == "ozon") {
|
||||||
auto *w = new Ozon::GetLastTransactionsScript(adbSerial, appCode, 0, searchAmount, searchTime);
|
auto *w = new Ozon::GetLastTransactionsScript(adbSerial, appCode, 0, searchAmount, searchTime);
|
||||||
setup(w); connectScreenshot(w);
|
setup(w); connectScreenshot(w);
|
||||||
|
connect(w, &Ozon::GetLastTransactionsScript::transactionParsed, this,
|
||||||
|
[this, key](const QJsonObject &tx) { m_parsedTxs[key] = tx; },
|
||||||
|
Qt::DirectConnection);
|
||||||
}
|
}
|
||||||
else if (appCode == "black")
|
else if (appCode == "black")
|
||||||
setup(new Black::GetLastTransactionsScript(adbSerial, appCode));
|
setup(new Black::GetLastTransactionsScript(adbSerial, appCode));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user