Ensure BankSetupWizard triggers only when bankProfileId is empty and pinCodeChecked is false in DeviceSettingsWindow and DeviceWidget.
This commit is contained in:
parent
c5e8fc4ed5
commit
baa60d008b
@ -16,6 +16,7 @@
|
|||||||
#include "black/LoginAndCheckAccountsScript.h"
|
#include "black/LoginAndCheckAccountsScript.h"
|
||||||
#include "black/GetProfileInfoScript.h"
|
#include "black/GetProfileInfoScript.h"
|
||||||
#include "black/GetCardInfoScript.h"
|
#include "black/GetCardInfoScript.h"
|
||||||
|
#include "dushanbe/LoginAndCheckAccountsScript.h"
|
||||||
#include "dushanbe/GetProfileInfoScript.h"
|
#include "dushanbe/GetProfileInfoScript.h"
|
||||||
#include "dushanbe/GetCardInfoScript.h"
|
#include "dushanbe/GetCardInfoScript.h"
|
||||||
#include "dao/BankProfileDAO.h"
|
#include "dao/BankProfileDAO.h"
|
||||||
@ -223,6 +224,26 @@ void AccountSettingsWindow::toggleProfileStatus() {
|
|||||||
m_app.status = newStatus;
|
m_app.status = newStatus;
|
||||||
showOverlay(isActive ? "Выключение профиля..." : "Включение профиля...");
|
showOverlay(isActive ? "Выключение профиля..." : "Включение профиля...");
|
||||||
sendAppStatus(newStatus);
|
sendAppStatus(newStatus);
|
||||||
|
|
||||||
|
// При включении профиля — включаем на сервере все локально активные материалы
|
||||||
|
if (!isActive) {
|
||||||
|
const QList<MaterialInfo> materials = MaterialDAO::getAccounts(m_deviceId, m_app.code);
|
||||||
|
for (const auto &mat : materials) {
|
||||||
|
if (mat.status == MaterialStatus::Active && !mat.materialId.isEmpty()) {
|
||||||
|
auto *thread = new QThread;
|
||||||
|
auto *net = new NetworkService;
|
||||||
|
net->moveToThread(thread);
|
||||||
|
net->addExtra("material_id", mat.materialId);
|
||||||
|
net->addExtra("enable", true);
|
||||||
|
connect(thread, &QThread::started, net, &NetworkService::toggleMaterial);
|
||||||
|
connect(net, &NetworkService::finished, thread, &QThread::quit);
|
||||||
|
connect(net, &NetworkService::finished, net, &QObject::deleteLater);
|
||||||
|
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
||||||
|
thread->start();
|
||||||
|
qDebug() << "[AccountSettings] Enabling material on server:" << mat.materialId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Edit PIN ───────────────────────────────────────────────────────────────
|
// ── Edit PIN ───────────────────────────────────────────────────────────────
|
||||||
@ -250,17 +271,26 @@ void AccountSettingsWindow::startCheckPinCode() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showOverlay("Проверка пин-кода...");
|
||||||
|
pauseActiveProfiles();
|
||||||
|
|
||||||
auto *thread = new QThread(nullptr);
|
auto *thread = new QThread(nullptr);
|
||||||
const QString deviceId = m_deviceId;
|
const QString deviceId = m_deviceId;
|
||||||
const QString appCode = m_app.code;
|
const QString appCode = m_app.code;
|
||||||
const int appId = m_app.id;
|
const int appId = m_app.id;
|
||||||
|
|
||||||
auto onResult = [this, appId](const QString &result) {
|
auto onResult = [this, appId](const QString &result) {
|
||||||
if (result.isEmpty()) {
|
QMetaObject::invokeMethod(this, [this, appId, result]() {
|
||||||
BankProfileDAO::updatePinCodeStatus(appId, "yes", "");
|
resumePausedProfiles();
|
||||||
m_app.pinCodeChecked = true;
|
if (result.isEmpty()) {
|
||||||
QMetaObject::invokeMethod(this, [this]() { updateStatusUI(); }, Qt::QueuedConnection);
|
BankProfileDAO::updatePinCodeStatus(appId, "yes", "");
|
||||||
}
|
m_app.pinCodeChecked = true;
|
||||||
|
updateStatusUI();
|
||||||
|
hideOverlay(true, "Пин-код проверен");
|
||||||
|
} else {
|
||||||
|
hideOverlay(false, "Ошибка: " + result);
|
||||||
|
}
|
||||||
|
}, Qt::QueuedConnection);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (appCode == "ozon") {
|
if (appCode == "ozon") {
|
||||||
@ -279,7 +309,17 @@ void AccountSettingsWindow::startCheckPinCode() {
|
|||||||
connect(worker, &Black::LoginAndCheckAccountsScript::finished, thread, &QThread::quit);
|
connect(worker, &Black::LoginAndCheckAccountsScript::finished, thread, &QThread::quit);
|
||||||
connect(worker, &Black::LoginAndCheckAccountsScript::finished, worker, &QObject::deleteLater);
|
connect(worker, &Black::LoginAndCheckAccountsScript::finished, worker, &QObject::deleteLater);
|
||||||
connect(thread, &QThread::finished, thread, &QObject::deleteLater);
|
connect(thread, &QThread::finished, thread, &QObject::deleteLater);
|
||||||
|
} else if (appCode == "dushanbe_city_bank") {
|
||||||
|
auto *worker = new Dushanbe::LoginAndCheckAccountsScript(deviceId, appCode, nullptr, true);
|
||||||
|
worker->moveToThread(thread);
|
||||||
|
connect(thread, &QThread::started, worker, &Dushanbe::LoginAndCheckAccountsScript::start);
|
||||||
|
connect(worker, &Dushanbe::LoginAndCheckAccountsScript::finishedWithResult, this, onResult, Qt::QueuedConnection);
|
||||||
|
connect(worker, &Dushanbe::LoginAndCheckAccountsScript::finished, thread, &QThread::quit);
|
||||||
|
connect(worker, &Dushanbe::LoginAndCheckAccountsScript::finished, worker, &QObject::deleteLater);
|
||||||
|
connect(thread, &QThread::finished, thread, &QObject::deleteLater);
|
||||||
} else {
|
} else {
|
||||||
|
resumePausedProfiles();
|
||||||
|
hideOverlay(false, "Банк не поддерживается");
|
||||||
thread->deleteLater();
|
thread->deleteLater();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -192,6 +192,24 @@ void DeviceWidget::buildBankRow(const BankProfileInfo &app, QWidget *rowWidget,
|
|||||||
qDebug() << "Cant update bank data";
|
qDebug() << "Cant update bank data";
|
||||||
} else {
|
} else {
|
||||||
sendBankStatus(app.deviceId, app.code, newStatus);
|
sendBankStatus(app.deviceId, app.code, newStatus);
|
||||||
|
// При включении — включаем на сервере все локально активные материалы
|
||||||
|
if (newStatus == "active") {
|
||||||
|
const QList<MaterialInfo> materials = MaterialDAO::getAccounts(app.deviceId, app.code);
|
||||||
|
for (const auto &mat : materials) {
|
||||||
|
if (mat.status == MaterialStatus::Active && !mat.materialId.isEmpty()) {
|
||||||
|
auto *thr = new QThread;
|
||||||
|
auto *ns = new NetworkService;
|
||||||
|
ns->moveToThread(thr);
|
||||||
|
ns->addExtra("material_id", mat.materialId);
|
||||||
|
ns->addExtra("enable", true);
|
||||||
|
QObject::connect(thr, &QThread::started, ns, &NetworkService::toggleMaterial);
|
||||||
|
QObject::connect(ns, &NetworkService::finished, thr, &QThread::quit);
|
||||||
|
QObject::connect(ns, &NetworkService::finished, ns, &QObject::deleteLater);
|
||||||
|
QObject::connect(thr, &QThread::finished, thr, &QThread::deleteLater);
|
||||||
|
thr->start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user