2026-10-10 19:15:31 +08:00
|
|
|
#include "CrownClient.h"
|
|
|
|
|
#include "Connect.h"
|
|
|
|
|
#include "User.h"
|
|
|
|
|
#include "Global.h"
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include "WebEnginePage.h"
|
|
|
|
|
#include <QXmlStreamReader>
|
|
|
|
|
#include <QDomDocument>
|
|
|
|
|
#include "Utils.h"
|
|
|
|
|
#include <QSound>
|
|
|
|
|
#include <QToolTip>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include "AppInstanceManager.h"
|
|
|
|
|
#include "PushMsg.h"
|
|
|
|
|
#include <QNetworkProxyFactory>
|
|
|
|
|
#include <QWebEngineSettings>
|
|
|
|
|
#include <QWebEngineProfile>
|
|
|
|
|
CrownClient::CrownClient(QWidget *parent)
|
|
|
|
|
: QMainWindow(parent)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//// ... 在创建 QWebEngineView 之前添加这行代码
|
|
|
|
|
//QNetworkProxyFactory::setUseSystemConfiguration(false);
|
|
|
|
|
|
|
|
|
|
// 安装 UI
|
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
// 设置窗口图标
|
|
|
|
|
this->setWindowIcon(QIcon(":/images/Images/client.ico"));
|
|
|
|
|
// 设置窗口标题
|
|
|
|
|
this->setWindowTitle(QString("金运来皇冠跟单软件(客户端) ") + QString(VERSION));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
///////////////////////////////////////////////////
|
|
|
|
|
// 调试窗口
|
|
|
|
|
///////////////////////////////////////////////////
|
|
|
|
|
QWidget* debug_window = new QWidget(nullptr);
|
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout(debug_window);
|
|
|
|
|
|
|
|
|
|
QWebEngineView* debug = new QWebEngineView();
|
|
|
|
|
layout->addWidget(debug);
|
|
|
|
|
debug_window->setLayout(layout);
|
|
|
|
|
debug->load(QUrl("http://localhost:7777/")); \
|
|
|
|
|
debug_window->show();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 防止多开
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
connect(AppInstanceManager::instance(), &AppInstanceManager::raiseRequested,
|
|
|
|
|
this, [this]() {
|
|
|
|
|
showNormal(); // 双击托盘图标恢复窗口
|
|
|
|
|
//show();
|
|
|
|
|
raise();
|
|
|
|
|
activateWindow();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 托盘图标
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// 创建托盘图标
|
|
|
|
|
trayIcon = new QSystemTrayIcon(this);
|
|
|
|
|
trayIcon->setIcon(QIcon(":/images/Images/client.ico"));
|
|
|
|
|
trayIcon->setToolTip("金运来皇冠跟单软件(客户端)");
|
|
|
|
|
// 创建托盘菜单
|
|
|
|
|
QMenu *trayMenu = new QMenu(this);
|
|
|
|
|
trayMenu->addAction("恢复", this, &CrownClient::showNormal);
|
|
|
|
|
trayMenu->addAction("退出", this, &CrownClient::close);
|
|
|
|
|
|
|
|
|
|
trayIcon->setContextMenu(trayMenu);
|
|
|
|
|
trayIcon->show();
|
|
|
|
|
|
|
|
|
|
// 连接托盘图标点击事件
|
|
|
|
|
connect(trayIcon, &QSystemTrayIcon::activated, this, &CrownClient::onTrayIconActivated);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////
|
|
|
|
|
// 心跳定时器
|
|
|
|
|
//////////////////////////////////////////////////////////
|
|
|
|
|
m_heartbeatTimer = new QTimer(this);
|
|
|
|
|
connect(m_heartbeatTimer, &QTimer::timeout, this, &CrownClient::heartbeat);
|
|
|
|
|
m_heartbeatTimer->start(15000); // 15秒一次
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 变量初始化
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// 初始化状态
|
|
|
|
|
m_state = wait;
|
|
|
|
|
// 清空变量
|
|
|
|
|
m_readOrderTimes = 0;
|
|
|
|
|
m_readOrderCount = 0;
|
|
|
|
|
m_successOrderCount = 0;
|
|
|
|
|
m_screenOrderCount = 0;
|
|
|
|
|
|
|
|
|
|
m_bet_thread = nullptr;
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 连接窗口
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
Connect* window_connect = new Connect();
|
|
|
|
|
// 载入窗口
|
|
|
|
|
connect(ui.connectButton, &QPushButton::clicked, window_connect, &QWidget::show);
|
|
|
|
|
// 开始读取注单
|
|
|
|
|
connect(this, &CrownClient::signalStart, window_connect, &Connect::slotStart);
|
|
|
|
|
// 停止读取注单
|
|
|
|
|
connect(this, &CrownClient::signalStop, window_connect, &Connect::slotStop);
|
|
|
|
|
// 改变状态
|
|
|
|
|
connect(window_connect, &Connect::signalStateChange, this, &CrownClient::slotChangeState);
|
|
|
|
|
|
|
|
|
|
// 接收注单
|
|
|
|
|
connect(window_connect, &Connect::signalUpdateOrders, this, &CrownClient::slotAcceptOrders);
|
|
|
|
|
|
|
|
|
|
connect(window_connect, &Connect::signalReadOrdersTimes, this, &CrownClient::slotUpdateReadOrdersTimes);
|
|
|
|
|
connect(window_connect, &Connect::signalReadOrdersCount, this, &CrownClient::slotUpdateReadOrdersCount);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 账户管理
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
User* user = new User();
|
|
|
|
|
// 窗口显示
|
|
|
|
|
connect(ui.userManagerButton, &QPushButton::clicked, user, &QWidget::show);
|
|
|
|
|
// 连接添加用户信息信号
|
|
|
|
|
connect(this, &CrownClient::signalAddUser, user, &User::slotAddUser);
|
|
|
|
|
// 连接设置用户信息信号
|
|
|
|
|
connect(user, &User::signalSetUser, this, &CrownClient::slotSetUser);
|
|
|
|
|
// 开始按钮
|
|
|
|
|
connect(ui.startButton, &QPushButton::clicked, this, [=]() {
|
|
|
|
|
QString username = ui.usernameEdit->text();
|
|
|
|
|
QString password = ui.passwordEdit->text();
|
|
|
|
|
emit signalAddUser(username, password);
|
|
|
|
|
});
|
|
|
|
|
// 登录按钮
|
|
|
|
|
connect(ui.loginButton, &QPushButton::clicked, this, [=]() {
|
|
|
|
|
QString username = ui.usernameEdit->text();
|
|
|
|
|
QString password = ui.passwordEdit->text();
|
|
|
|
|
emit signalAddUser(username, password);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 通知窗口
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
m_window_notice = new Notice();
|
|
|
|
|
// 载入窗口
|
|
|
|
|
connect(ui.button_notice, &QPushButton::clicked, m_window_notice, &QWidget::show);
|
|
|
|
|
//// 开始读取注单
|
|
|
|
|
//connect(this, &CrownClient::signalStart, window_connect, &Connect::slotStart);
|
|
|
|
|
//// 停止读取注单
|
|
|
|
|
//connect(this, &CrownClient::signalStop, window_connect, &Connect::slotStop);
|
|
|
|
|
//// 改变状态
|
|
|
|
|
//connect(window_connect, &Connect::signalStateChange, this, &CrownClient::slotChangeState);
|
|
|
|
|
|
|
|
|
|
//// 接收注单
|
|
|
|
|
//connect(window_connect, &Connect::signalUpdateOrders, this, &CrownClient::slotAcceptOrders);
|
|
|
|
|
|
|
|
|
|
//connect(window_connect, &Connect::signalReadOrdersTimes, this, &CrownClient::slotUpdateReadOrdersTimes);
|
|
|
|
|
//connect(window_connect, &Connect::signalReadOrdersCount, this, &CrownClient::slotUpdateReadOrdersCount);
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 跟单设置
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
m_window_setting = new Setting();
|
|
|
|
|
connect(ui.settingButton, &QPushButton::clicked, m_window_setting, &Setting::show);
|
|
|
|
|
connect(ui.settingButton, &QPushButton::clicked, window_connect, &Connect::slotFlushAccount);
|
|
|
|
|
// 更新联盟和队伍
|
|
|
|
|
connect(this, &CrownClient::signalUpdateLeagueAndTeam, m_window_setting, &Setting::slotUpdateLeagueAndTeam);
|
|
|
|
|
// 更新用户列表
|
|
|
|
|
connect(window_connect, &Connect::signalUpdateUsers, m_window_setting, [this](QList<QMap<QString, QString>> list) {
|
|
|
|
|
m_window_setting->slotUpdateUsers(list);
|
|
|
|
|
if (m_bet_thread)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// 皇冠时间按钮
|
|
|
|
|
ui.crownTimeButton->setIconSize(QSize(48, 48));
|
|
|
|
|
//ui.crownTimeButton->setFlat(true);
|
|
|
|
|
ui.crownTimeButton->setCursor(QCursor(Qt::PointingHandCursor));
|
|
|
|
|
|
|
|
|
|
connect(ui.crownTimeButton, &QPushButton::clicked, this, [&]() {
|
|
|
|
|
// 直接调用统一时间调整函数
|
|
|
|
|
view_change_time(!g_config->crownTime());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 显示账号和到期时间
|
2026-10-17 16:31:54 +08:00
|
|
|
// 到期文案由 Verify 统一拼:永久授权 / 剩余点数 / 到期日期,三种计费各显示各的
|
|
|
|
|
ui.endtimeLabel->setText("<html><head/><body><p><span style=\"color:#008000;\">软件登录账号: " + g_verify->Username() + QString(" 软件到期时间: ") + g_verify->DueTimeText() + "</span></p></body></html>");
|
2026-10-10 19:15:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 重写Page屏蔽SSL证书错误
|
|
|
|
|
WebEnginePage* page = new WebEnginePage();
|
|
|
|
|
page->profile()->setHttpAcceptLanguage("zh-CN,zh;q=0.9");
|
|
|
|
|
ui.webEngineView->setPage(page);
|
|
|
|
|
|
|
|
|
|
QWebEngineSettings *settings = page->settings();
|
|
|
|
|
|
|
|
|
|
// 禁用favicon自动加载
|
|
|
|
|
settings->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, false);
|
|
|
|
|
// 禁用右键菜单
|
|
|
|
|
ui.webEngineView->setContextMenuPolicy(Qt::NoContextMenu);
|
|
|
|
|
// 设置访问地址
|
|
|
|
|
if (!ui.urlCombo->currentText().isEmpty())
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "主程序 -> 浏览默认网址:" << ui.urlCombo->currentText();
|
|
|
|
|
ui.webEngineView->load(QUrl(ui.urlCombo->currentText()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 读取配置
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// ui.screenDateTimeCheckBox->setChecked(false);
|
|
|
|
|
ui.dateTimeEdit->setDateTime(g_config->formatDateTime(QDateTime::currentDateTime()));
|
|
|
|
|
ui.screenDateTimeCheckBox->setChecked(g_config->screenDateTimeEnable());
|
|
|
|
|
if (g_config->crownTime())
|
|
|
|
|
{
|
|
|
|
|
ui.crownTimeButton->setIcon(QIcon(":/images/Images/crownTime.png"));
|
|
|
|
|
ui.crownTimeButton->setText("皇冠时间");
|
|
|
|
|
|
|
|
|
|
QPalette palette;
|
|
|
|
|
palette.setColor(QPalette::ButtonText, QColor(Qt::red));
|
|
|
|
|
ui.crownTimeButton->setPalette(palette);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ui.crownTimeButton->setIcon(QIcon(":/images/Images/localTime.png"));
|
|
|
|
|
ui.crownTimeButton->setText("本地时间");
|
|
|
|
|
QPalette palette;
|
|
|
|
|
palette.setColor(QPalette::ButtonText, QColor(QRgb(0x008000)));
|
|
|
|
|
ui.crownTimeButton->setPalette(palette);
|
|
|
|
|
}
|
|
|
|
|
// qDebug() << "URL List:" << g_config->client_url_list();
|
|
|
|
|
// qDebug() << "Current URL:" << g_config->client_url();
|
|
|
|
|
// qDebug() << g_config->client_url_list();
|
|
|
|
|
ui.urlCombo->addItems(g_config->client_url_list());
|
|
|
|
|
ui.urlCombo->setCurrentText(g_config->client_url());
|
|
|
|
|
ui.usernameEdit->setText(g_config->username());
|
|
|
|
|
ui.passwordEdit->setText(g_config->password());
|
|
|
|
|
|
|
|
|
|
//ui.dateTimeEdit->setDateTime(QDateTime::fromString(g_config->screenDateTime()));
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 接收注单表格 - 改为QTreeView实现
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
{
|
|
|
|
|
// 创建模型
|
|
|
|
|
QStandardItemModel *orderModel = new QStandardItemModel(0, 11, this);
|
|
|
|
|
orderModel->setHorizontalHeaderLabels({ "单号/场次","下注时间","接收时间","会员/代理","项目","类型","联赛/队伍","下注","盘口","赔率","金额" });
|
|
|
|
|
|
|
|
|
|
// 设置TreeView
|
|
|
|
|
ui.order_tree_view->setModel(orderModel);
|
|
|
|
|
ui.order_tree_view->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
|
ui.order_tree_view->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
|
|
|
|
|
// 设置列宽策略
|
|
|
|
|
ui.order_tree_view->header()->setSectionsMovable(true); // 允许列移动
|
|
|
|
|
ui.order_tree_view->header()->setSectionResizeMode(QHeaderView::Interactive); // 允许手动调整列宽
|
|
|
|
|
ui.order_tree_view->header()->setMinimumSectionSize(50); // 设置最小宽度
|
|
|
|
|
ui.order_tree_view->setWordWrap(true); // 设置文本自动换行和工具提示
|
|
|
|
|
ui.order_tree_view->setSortingEnabled(true); // 启用排序
|
|
|
|
|
|
|
|
|
|
// 设置初始列宽(根据你的测试数据合理分配)
|
|
|
|
|
ui.order_tree_view->header()->resizeSection(0, 200); // 单号/场次
|
|
|
|
|
ui.order_tree_view->header()->resizeSection(1, 150); // 下注时间
|
|
|
|
|
ui.order_tree_view->header()->resizeSection(2, 150); // 接收时间
|
|
|
|
|
ui.order_tree_view->header()->resizeSection(3, 120); // 会员/代理
|
|
|
|
|
ui.order_tree_view->header()->resizeSection(4, 150); // 项目(足球滚球全场等可能较长)
|
|
|
|
|
ui.order_tree_view->header()->resizeSection(5, 100); // 类型
|
|
|
|
|
ui.order_tree_view->header()->resizeSection(6, 250); // 联赛/队伍(需要较宽空间)
|
|
|
|
|
ui.order_tree_view->header()->resizeSection(7, 100); // 下注
|
|
|
|
|
ui.order_tree_view->header()->resizeSection(8, 80); // 盘口
|
|
|
|
|
ui.order_tree_view->header()->resizeSection(9, 150); // 赔率
|
|
|
|
|
ui.order_tree_view->header()->resizeSection(10, 80); // 金额
|
|
|
|
|
|
|
|
|
|
// 创建右键菜单
|
|
|
|
|
QMenu* orderMenu = new QMenu(ui.order_tree_view);
|
|
|
|
|
QMenu* orderGroupMenu = new QMenu("分组方式", orderMenu);
|
|
|
|
|
QAction* orderGroupByIdAction = new QAction("按订单号分组", orderMenu);
|
|
|
|
|
QAction* orderGroupByTimeAction = new QAction("按时间分组", orderMenu);
|
|
|
|
|
QAction* orderNoGroupAction = new QAction("无分组", orderMenu);
|
|
|
|
|
QAction* orderDeleteAction = new QAction("删除选中项", orderMenu);
|
|
|
|
|
QAction* orderClearAction = new QAction("清空所有", orderMenu);
|
|
|
|
|
|
|
|
|
|
orderGroupMenu->addAction(orderGroupByIdAction);
|
|
|
|
|
orderGroupMenu->addAction(orderGroupByTimeAction);
|
|
|
|
|
orderGroupMenu->addAction(orderNoGroupAction);
|
|
|
|
|
orderMenu->addMenu(orderGroupMenu);
|
|
|
|
|
orderMenu->addSeparator();
|
|
|
|
|
orderMenu->addAction(orderDeleteAction);
|
|
|
|
|
orderMenu->addAction(orderClearAction);
|
|
|
|
|
|
|
|
|
|
// 连接信号槽
|
|
|
|
|
connect(ui.order_tree_view, &QTreeView::customContextMenuRequested, this, [=](const QPoint &pos) {
|
|
|
|
|
orderMenu->popup(ui.order_tree_view->viewport()->mapToGlobal(pos));
|
|
|
|
|
});
|
|
|
|
|
connect(orderGroupByIdAction, &QAction::triggered, this, [=]() { groupTreeView(ui.order_tree_view, BY_ORDER_ID); });
|
|
|
|
|
connect(orderGroupByTimeAction, &QAction::triggered, this, [=]() { groupTreeView(ui.order_tree_view, BY_TIME); });
|
|
|
|
|
connect(orderNoGroupAction, &QAction::triggered, this, [=]() { groupTreeView(ui.order_tree_view, NO_GROUP); });
|
|
|
|
|
connect(orderDeleteAction, &QAction::triggered, this, [=]() { deleteSelectedItems(ui.order_tree_view); });
|
|
|
|
|
connect(orderClearAction, &QAction::triggered, this, [=]() { clearTreeView(ui.order_tree_view); });
|
|
|
|
|
|
|
|
|
|
// 启用排序
|
|
|
|
|
ui.order_tree_view->setSortingEnabled(true);
|
|
|
|
|
|
|
|
|
|
// 读取接收注单缓存
|
|
|
|
|
QList<QMap<QString, QString>> accept_orders = g_config->get_accept_orders();
|
|
|
|
|
for (QMap<QString, QString> accept_order : accept_orders)
|
|
|
|
|
{
|
|
|
|
|
view_add_accept_order(accept_order);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 筛选注单表格 - 改为QTreeView
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
{
|
|
|
|
|
QStandardItemModel *screen_model = new QStandardItemModel(0, 11, this);
|
|
|
|
|
screen_model->setHorizontalHeaderLabels({ "单号/场次","下注时间","会员/代理","项目","类型","联赛/队伍","下注","盘口","赔率","金额","原因" });
|
|
|
|
|
|
|
|
|
|
ui.screen_tree_view->setModel(screen_model);
|
|
|
|
|
ui.screen_tree_view->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
|
ui.screen_tree_view->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
|
|
|
|
|
// 设置列宽策略
|
|
|
|
|
ui.screen_tree_view->header()->setSectionsMovable(true); // 允许列移动
|
|
|
|
|
ui.screen_tree_view->header()->setSectionResizeMode(QHeaderView::Interactive); // 允许手动调整列宽
|
|
|
|
|
ui.screen_tree_view->header()->setMinimumSectionSize(50); // 设置最小宽度
|
|
|
|
|
ui.screen_tree_view->setWordWrap(true); // 设置文本自动换行和工具提示
|
|
|
|
|
ui.screen_tree_view->setSortingEnabled(true); // 启用排序
|
|
|
|
|
|
|
|
|
|
// 设置初始列宽
|
|
|
|
|
ui.screen_tree_view->header()->resizeSection(0, 200); // 单号/场次
|
|
|
|
|
ui.screen_tree_view->header()->resizeSection(1, 150); // 下注时间
|
|
|
|
|
ui.screen_tree_view->header()->resizeSection(2, 120); // 会员/代理
|
|
|
|
|
ui.screen_tree_view->header()->resizeSection(3, 150); // 项目
|
|
|
|
|
ui.screen_tree_view->header()->resizeSection(4, 100); // 类型
|
|
|
|
|
ui.screen_tree_view->header()->resizeSection(5, 250); // 联赛/队伍
|
|
|
|
|
ui.screen_tree_view->header()->resizeSection(6, 100); // 下注
|
|
|
|
|
ui.screen_tree_view->header()->resizeSection(7, 80); // 盘口
|
|
|
|
|
ui.screen_tree_view->header()->resizeSection(8, 150); // 赔率
|
|
|
|
|
ui.screen_tree_view->header()->resizeSection(9, 80); // 金额
|
|
|
|
|
ui.screen_tree_view->header()->resizeSection(10, 150); // 原因
|
|
|
|
|
|
|
|
|
|
// 创建右键菜单
|
|
|
|
|
QMenu* screenMenu = new QMenu(ui.screen_tree_view);
|
|
|
|
|
QMenu* screenGroupMenu = new QMenu("分组方式", screenMenu);
|
|
|
|
|
QAction* screenGroupByIdAction = new QAction("按订单号分组", screenMenu);
|
|
|
|
|
QAction* screenGroupByTimeAction = new QAction("按时间分组", screenMenu);
|
|
|
|
|
QAction* screenNoGroupAction = new QAction("无分组", screenMenu);
|
|
|
|
|
QAction* screenDeleteAction = new QAction("删除选中项", screenMenu);
|
|
|
|
|
QAction* screenClearAction = new QAction("清空所有", screenMenu);
|
|
|
|
|
|
|
|
|
|
screenGroupMenu->addAction(screenGroupByIdAction);
|
|
|
|
|
screenGroupMenu->addAction(screenGroupByTimeAction);
|
|
|
|
|
screenGroupMenu->addAction(screenNoGroupAction);
|
|
|
|
|
screenMenu->addMenu(screenGroupMenu);
|
|
|
|
|
screenMenu->addSeparator();
|
|
|
|
|
screenMenu->addAction(screenDeleteAction);
|
|
|
|
|
screenMenu->addAction(screenClearAction);
|
|
|
|
|
|
|
|
|
|
// 连接信号槽
|
|
|
|
|
connect(ui.screen_tree_view, &QTreeView::customContextMenuRequested, this, [=](const QPoint &pos) {
|
|
|
|
|
screenMenu->popup(ui.screen_tree_view->viewport()->mapToGlobal(pos));
|
|
|
|
|
});
|
|
|
|
|
connect(screenGroupByIdAction, &QAction::triggered, this, [=]() { groupTreeView(ui.screen_tree_view, BY_ORDER_ID); });
|
|
|
|
|
connect(screenGroupByTimeAction, &QAction::triggered, this, [=]() { groupTreeView(ui.screen_tree_view, BY_TIME); });
|
|
|
|
|
connect(screenNoGroupAction, &QAction::triggered, this, [=]() { groupTreeView(ui.screen_tree_view, NO_GROUP); });
|
|
|
|
|
connect(screenDeleteAction, &QAction::triggered, this, [=]() { deleteSelectedItems(ui.screen_tree_view); });
|
|
|
|
|
connect(screenClearAction, &QAction::triggered, this, [=]() { clearTreeView(ui.screen_tree_view); });
|
|
|
|
|
|
|
|
|
|
// 启用排序
|
|
|
|
|
ui.screen_tree_view->setSortingEnabled(true);
|
|
|
|
|
|
|
|
|
|
// 读取筛选注单缓存
|
|
|
|
|
QList<QMap<QString, QString>> screen_orders = g_config->get_screen_orders();
|
|
|
|
|
for (QMap<QString, QString> screen_order : screen_orders) {
|
|
|
|
|
view_add_screen_order(screen_order);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 跟单成功表格 - 改为QTreeView
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
{
|
|
|
|
|
QStandardItemModel* success_model = new QStandardItemModel(0, 10, this);
|
|
|
|
|
success_model->setHorizontalHeaderLabels({ "单号/场次","跟单时间","会员/代理","项目","类型","联赛/队伍","下注","盘口","赔率","金额" });
|
|
|
|
|
|
|
|
|
|
ui.success_tree_view->setModel(success_model);
|
|
|
|
|
ui.success_tree_view->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
|
ui.success_tree_view->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
|
|
|
|
|
// 设置列宽策略
|
|
|
|
|
ui.success_tree_view->header()->setSectionsMovable(true); // 允许列移动
|
|
|
|
|
ui.success_tree_view->header()->setSectionResizeMode(QHeaderView::Interactive); // 允许手动调整列宽
|
|
|
|
|
ui.success_tree_view->header()->setMinimumSectionSize(50); // 设置最小宽度
|
|
|
|
|
ui.success_tree_view->setWordWrap(true); // 设置文本自动换行和工具提示
|
|
|
|
|
ui.success_tree_view->setSortingEnabled(true); // 启用排序
|
|
|
|
|
|
|
|
|
|
// 设置初始列宽
|
|
|
|
|
ui.success_tree_view->header()->resizeSection(0, 200); // 单号/场次
|
|
|
|
|
ui.success_tree_view->header()->resizeSection(1, 150); // 跟单时间
|
|
|
|
|
ui.success_tree_view->header()->resizeSection(2, 120); // 会员/代理
|
|
|
|
|
ui.success_tree_view->header()->resizeSection(3, 150); // 项目
|
|
|
|
|
ui.success_tree_view->header()->resizeSection(4, 100); // 类型
|
|
|
|
|
ui.success_tree_view->header()->resizeSection(5, 250); // 联赛/队伍
|
|
|
|
|
ui.success_tree_view->header()->resizeSection(6, 100); // 下注
|
|
|
|
|
ui.success_tree_view->header()->resizeSection(7, 80); // 盘口
|
|
|
|
|
ui.success_tree_view->header()->resizeSection(8, 150); // 赔率
|
|
|
|
|
ui.success_tree_view->header()->resizeSection(9, 80); // 金额
|
|
|
|
|
|
|
|
|
|
// 创建右键菜单
|
|
|
|
|
QMenu* successMenu = new QMenu(ui.success_tree_view);
|
|
|
|
|
QMenu* successGroupMenu = new QMenu("分组方式", successMenu);
|
|
|
|
|
QAction* successGroupByIdAction = new QAction("按订单号分组", successMenu);
|
|
|
|
|
QAction* successGroupByTimeAction = new QAction("按时间分组", successMenu);
|
|
|
|
|
QAction* successNoGroupAction = new QAction("无分组", successMenu);
|
|
|
|
|
QAction* successDeleteAction = new QAction("删除选中项", successMenu);
|
|
|
|
|
QAction* successClearAction = new QAction("清空所有", successMenu);
|
|
|
|
|
|
|
|
|
|
successGroupMenu->addAction(successGroupByIdAction);
|
|
|
|
|
successGroupMenu->addAction(successGroupByTimeAction);
|
|
|
|
|
successGroupMenu->addAction(successNoGroupAction);
|
|
|
|
|
successMenu->addMenu(successGroupMenu);
|
|
|
|
|
successMenu->addSeparator();
|
|
|
|
|
successMenu->addAction(successDeleteAction);
|
|
|
|
|
successMenu->addAction(successClearAction);
|
|
|
|
|
|
|
|
|
|
// 连接信号槽
|
|
|
|
|
connect(ui.success_tree_view, &QTreeView::customContextMenuRequested, this, [=](const QPoint &pos) {
|
|
|
|
|
successMenu->popup(ui.success_tree_view->viewport()->mapToGlobal(pos));
|
|
|
|
|
});
|
|
|
|
|
connect(successGroupByIdAction, &QAction::triggered, this, [=]() { groupTreeView(ui.success_tree_view, BY_ORDER_ID); });
|
|
|
|
|
connect(successGroupByTimeAction, &QAction::triggered, this, [=]() { groupTreeView(ui.success_tree_view, BY_TIME); });
|
|
|
|
|
connect(successNoGroupAction, &QAction::triggered, this, [=]() { groupTreeView(ui.success_tree_view, NO_GROUP); });
|
|
|
|
|
connect(successDeleteAction, &QAction::triggered, this, [=]() { deleteSelectedItems(ui.success_tree_view); });
|
|
|
|
|
connect(successClearAction, &QAction::triggered, this, [=]() { clearTreeView(ui.success_tree_view); });
|
|
|
|
|
|
|
|
|
|
// 启用排序
|
|
|
|
|
ui.success_tree_view->setSortingEnabled(true);
|
|
|
|
|
|
|
|
|
|
// 读取成功注单缓存
|
|
|
|
|
QList<QMap<QString, QString>> success_orders = g_config->get_success_orders();
|
|
|
|
|
for (QMap<QString, QString> success_order : success_orders) {
|
|
|
|
|
view_add_success_order(success_order);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 跟单失败表格 - 改为QTreeView
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
{
|
|
|
|
|
QStandardItemModel * failed_model = new QStandardItemModel(0, 11, this);
|
|
|
|
|
failed_model->setHorizontalHeaderLabels({ "单号/场次","跟单时间","会员/代理","项目","类型","联赛/队伍","下注","盘口","赔率","金额","原因" });
|
|
|
|
|
|
|
|
|
|
ui.failed_tree_view->setModel(failed_model);
|
|
|
|
|
ui.failed_tree_view->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
|
ui.failed_tree_view->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
|
|
|
|
|
// 设置列宽策略
|
|
|
|
|
ui.failed_tree_view->header()->setSectionsMovable(true); // 允许列移动
|
|
|
|
|
ui.failed_tree_view->header()->setSectionResizeMode(QHeaderView::Interactive); // 允许手动调整列宽
|
|
|
|
|
ui.failed_tree_view->header()->setMinimumSectionSize(50); // 设置最小宽度
|
|
|
|
|
ui.failed_tree_view->setWordWrap(true); // 设置文本自动换行和工具提示
|
|
|
|
|
ui.failed_tree_view->setSortingEnabled(true); // 启用排序
|
|
|
|
|
|
|
|
|
|
// 设置初始列宽
|
|
|
|
|
ui.failed_tree_view->header()->resizeSection(0, 200); // 单号/场次
|
|
|
|
|
ui.failed_tree_view->header()->resizeSection(1, 150); // 跟单时间
|
|
|
|
|
ui.failed_tree_view->header()->resizeSection(2, 120); // 会员/代理
|
|
|
|
|
ui.failed_tree_view->header()->resizeSection(3, 150); // 项目
|
|
|
|
|
ui.failed_tree_view->header()->resizeSection(4, 100); // 类型
|
|
|
|
|
ui.failed_tree_view->header()->resizeSection(5, 250); // 联赛/队伍
|
|
|
|
|
ui.failed_tree_view->header()->resizeSection(6, 100); // 下注
|
|
|
|
|
ui.failed_tree_view->header()->resizeSection(7, 80); // 盘口
|
|
|
|
|
ui.failed_tree_view->header()->resizeSection(8, 150); // 赔率
|
|
|
|
|
ui.failed_tree_view->header()->resizeSection(9, 80); // 金额
|
|
|
|
|
ui.failed_tree_view->header()->resizeSection(10, 150); // 原因
|
|
|
|
|
|
|
|
|
|
// 创建右键菜单
|
|
|
|
|
QMenu* failedMenu = new QMenu(ui.failed_tree_view);
|
|
|
|
|
QMenu* failedGroupMenu = new QMenu("分组方式", failedMenu);
|
|
|
|
|
QAction* failedGroupByIdAction = new QAction("按订单号分组", failedMenu);
|
|
|
|
|
QAction* failedGroupByTimeAction = new QAction("按时间分组", failedMenu);
|
|
|
|
|
QAction* failedNoGroupAction = new QAction("无分组", failedMenu);
|
|
|
|
|
QAction* failedDeleteAction = new QAction("删除选中项", failedMenu);
|
|
|
|
|
QAction* failedClearAction = new QAction("清空所有", failedMenu);
|
|
|
|
|
|
|
|
|
|
failedGroupMenu->addAction(failedGroupByIdAction);
|
|
|
|
|
failedGroupMenu->addAction(failedGroupByTimeAction);
|
|
|
|
|
failedGroupMenu->addAction(failedNoGroupAction);
|
|
|
|
|
failedMenu->addMenu(failedGroupMenu);
|
|
|
|
|
failedMenu->addSeparator();
|
|
|
|
|
failedMenu->addAction(failedDeleteAction);
|
|
|
|
|
failedMenu->addAction(failedClearAction);
|
|
|
|
|
|
|
|
|
|
// 连接信号槽
|
|
|
|
|
connect(ui.failed_tree_view, &QTreeView::customContextMenuRequested, this, [=](const QPoint &pos) {
|
|
|
|
|
failedMenu->popup(ui.failed_tree_view->viewport()->mapToGlobal(pos));
|
|
|
|
|
});
|
|
|
|
|
connect(failedGroupByIdAction, &QAction::triggered, this, [=]() { groupTreeView(ui.failed_tree_view, BY_ORDER_ID); });
|
|
|
|
|
connect(failedGroupByTimeAction, &QAction::triggered, this, [=]() { groupTreeView(ui.failed_tree_view, BY_TIME); });
|
|
|
|
|
connect(failedNoGroupAction, &QAction::triggered, this, [=]() { groupTreeView(ui.failed_tree_view, NO_GROUP); });
|
|
|
|
|
connect(failedDeleteAction, &QAction::triggered, this, [=]() { deleteSelectedItems(ui.failed_tree_view); });
|
|
|
|
|
connect(failedClearAction, &QAction::triggered, this, [=]() { clearTreeView(ui.failed_tree_view); });
|
|
|
|
|
|
|
|
|
|
// 启用排序
|
|
|
|
|
ui.failed_tree_view->setSortingEnabled(true);
|
|
|
|
|
|
|
|
|
|
// 读取失败注单缓存
|
|
|
|
|
QList<QMap<QString, QString>> failedOrders = g_config->get_failed_orders();
|
|
|
|
|
for (QMap<QString, QString> failedOrder : failedOrders) {
|
|
|
|
|
view_add_failed_order(failedOrder);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 补单表格 - 改为QTreeView
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
{
|
|
|
|
|
QStandardItemModel* rebet_model = new QStandardItemModel(0, 11, this);
|
|
|
|
|
rebet_model->setHorizontalHeaderLabels({ "单号/场次","跟单时间","会员/代理","项目","类型","联赛/队伍","下注","盘口","赔率","金额","原因" });
|
|
|
|
|
|
|
|
|
|
ui.rebet_tree_view->setModel(rebet_model);
|
|
|
|
|
ui.rebet_tree_view->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
|
ui.rebet_tree_view->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
|
|
|
|
|
// 设置列宽策略
|
|
|
|
|
ui.rebet_tree_view->header()->setSectionsMovable(true); // 允许列移动
|
|
|
|
|
ui.rebet_tree_view->header()->setSectionResizeMode(QHeaderView::Interactive); // 允许手动调整列宽
|
|
|
|
|
ui.rebet_tree_view->header()->setMinimumSectionSize(50); // 设置最小宽度
|
|
|
|
|
ui.rebet_tree_view->setWordWrap(true); // 设置文本自动换行和工具提示
|
|
|
|
|
ui.rebet_tree_view->setSortingEnabled(true); // 启用排序
|
|
|
|
|
|
|
|
|
|
// 设置初始列宽
|
|
|
|
|
ui.rebet_tree_view->header()->resizeSection(0, 200); // 单号/场次
|
|
|
|
|
ui.rebet_tree_view->header()->resizeSection(1, 150); // 跟单时间
|
|
|
|
|
ui.rebet_tree_view->header()->resizeSection(2, 120); // 会员/代理
|
|
|
|
|
ui.rebet_tree_view->header()->resizeSection(3, 150); // 项目
|
|
|
|
|
ui.rebet_tree_view->header()->resizeSection(4, 100); // 类型
|
|
|
|
|
ui.rebet_tree_view->header()->resizeSection(5, 250); // 联赛/队伍
|
|
|
|
|
ui.rebet_tree_view->header()->resizeSection(6, 100); // 下注
|
|
|
|
|
ui.rebet_tree_view->header()->resizeSection(7, 80); // 盘口
|
|
|
|
|
ui.rebet_tree_view->header()->resizeSection(8, 150); // 赔率
|
|
|
|
|
ui.rebet_tree_view->header()->resizeSection(9, 80); // 金额
|
|
|
|
|
ui.rebet_tree_view->header()->resizeSection(10, 150); // 原因
|
|
|
|
|
|
|
|
|
|
// 创建右键菜单
|
|
|
|
|
QMenu* rebetMenu = new QMenu(ui.rebet_tree_view);
|
|
|
|
|
QMenu* rebetGroupMenu = new QMenu("分组方式", rebetMenu);
|
|
|
|
|
QAction* rebetGroupByIdAction = new QAction("按订单号分组", rebetMenu);
|
|
|
|
|
QAction* rebetGroupByTimeAction = new QAction("按时间分组", rebetMenu);
|
|
|
|
|
QAction* rebetNoGroupAction = new QAction("无分组", rebetMenu);
|
|
|
|
|
QAction* rebetDeleteAction = new QAction("删除选中项", rebetMenu);
|
|
|
|
|
QAction* rebetClearAction = new QAction("清空所有", rebetMenu);
|
|
|
|
|
|
|
|
|
|
rebetGroupMenu->addAction(rebetGroupByIdAction);
|
|
|
|
|
rebetGroupMenu->addAction(rebetGroupByTimeAction);
|
|
|
|
|
rebetGroupMenu->addAction(rebetNoGroupAction);
|
|
|
|
|
rebetMenu->addMenu(rebetGroupMenu);
|
|
|
|
|
rebetMenu->addSeparator();
|
|
|
|
|
rebetMenu->addAction(rebetDeleteAction);
|
|
|
|
|
rebetMenu->addAction(rebetClearAction);
|
|
|
|
|
|
|
|
|
|
// 连接信号槽
|
|
|
|
|
connect(ui.rebet_tree_view, &QTreeView::customContextMenuRequested, this, [=](const QPoint &pos) {
|
|
|
|
|
rebetMenu->popup(ui.rebet_tree_view->viewport()->mapToGlobal(pos));
|
|
|
|
|
});
|
|
|
|
|
connect(rebetGroupByIdAction, &QAction::triggered, this, [=]() { groupTreeView(ui.rebet_tree_view, BY_ORDER_ID); });
|
|
|
|
|
connect(rebetGroupByTimeAction, &QAction::triggered, this, [=]() { groupTreeView(ui.rebet_tree_view, BY_TIME); });
|
|
|
|
|
connect(rebetNoGroupAction, &QAction::triggered, this, [=]() { groupTreeView(ui.rebet_tree_view, NO_GROUP); });
|
|
|
|
|
connect(rebetDeleteAction, &QAction::triggered, this, [=]() { deleteSelectedItems(ui.rebet_tree_view); });
|
|
|
|
|
connect(rebetClearAction, &QAction::triggered, this, [=]() { clearTreeView(ui.rebet_tree_view); });
|
|
|
|
|
|
|
|
|
|
// 启用排序
|
|
|
|
|
ui.rebet_tree_view->setSortingEnabled(true);
|
|
|
|
|
|
|
|
|
|
// 读取补单记录缓存
|
|
|
|
|
QList<QMap<QString, QString>> rebet_orders = g_config->get_rebet_orders();
|
|
|
|
|
for (QMap<QString, QString> rebet_order : rebet_orders) {
|
|
|
|
|
view_add_rebet_order(rebet_order);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 日志树
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
{
|
|
|
|
|
// 建立数据模型对象空间并指定父对象
|
|
|
|
|
m_logModel = new QStandardItemModel(ui.log_tree_view);
|
|
|
|
|
// 绑定数据模型到树形视图上
|
|
|
|
|
ui.log_tree_view->setModel(m_logModel);
|
|
|
|
|
// 设置水平表头列宽度根据内容变化
|
|
|
|
|
ui.log_tree_view->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
|
|
|
|
// 设置可排序
|
|
|
|
|
ui.log_tree_view->setSortingEnabled(true);
|
|
|
|
|
// 添加列标题
|
|
|
|
|
m_logModel->setHorizontalHeaderLabels({ "时间","类型","日志" });
|
|
|
|
|
|
|
|
|
|
// 创建一个QSortFilterProxyModel作为代理模型
|
|
|
|
|
m_logProxyModel = new QSortFilterProxyModel();
|
|
|
|
|
// 设置代理模型的源模型为我们创建的数据模型
|
|
|
|
|
m_logProxyModel->setSourceModel(m_logModel);
|
|
|
|
|
// 将QTreeView的模型设置为代理模型
|
|
|
|
|
ui.log_tree_view->setModel(m_logProxyModel);
|
|
|
|
|
|
|
|
|
|
// 启用代理模型的排序功能
|
|
|
|
|
m_logProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
|
m_logProxyModel->setDynamicSortFilter(true);
|
|
|
|
|
|
|
|
|
|
ui.log_tree_view->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
|
connect(this, &CrownClient::log, this, &CrownClient::on_log);
|
|
|
|
|
|
|
|
|
|
// 创建日志右键菜单
|
|
|
|
|
QMenu* logMenu = new QMenu(ui.log_tree_view);
|
|
|
|
|
QMenu* logGroupMenu = new QMenu("分组方式", logMenu);
|
|
|
|
|
QAction* logGroupByTimeAction = new QAction("按时间分组", logMenu);
|
|
|
|
|
QAction* logGroupByTypeAction = new QAction("按类型分组", logMenu);
|
|
|
|
|
QAction* logNoGroupAction = new QAction("无分组", logMenu);
|
|
|
|
|
QAction* logDeleteAction = new QAction("删除选中项", logMenu);
|
|
|
|
|
QAction* logClearAction = new QAction("清空所有", logMenu);
|
|
|
|
|
|
|
|
|
|
logGroupMenu->addAction(logGroupByTimeAction);
|
|
|
|
|
logGroupMenu->addAction(logGroupByTypeAction);
|
|
|
|
|
logGroupMenu->addAction(logNoGroupAction);
|
|
|
|
|
logMenu->addMenu(logGroupMenu);
|
|
|
|
|
logMenu->addSeparator();
|
|
|
|
|
logMenu->addAction(logDeleteAction);
|
|
|
|
|
logMenu->addAction(logClearAction);
|
|
|
|
|
|
|
|
|
|
// 连接信号槽
|
|
|
|
|
connect(ui.log_tree_view, &QTreeView::customContextMenuRequested, this, [=](const QPoint &pos) {
|
|
|
|
|
logMenu->popup(ui.log_tree_view->viewport()->mapToGlobal(pos));
|
|
|
|
|
});
|
|
|
|
|
connect(logGroupByTimeAction, &QAction::triggered, this, [=]() { groupLogTreeView(BY_TIME); });
|
|
|
|
|
connect(logGroupByTypeAction, &QAction::triggered, this, [=]() { groupLogTreeView(BY_LOG_TYPE); });
|
|
|
|
|
connect(logNoGroupAction, &QAction::triggered, this, [=]() { groupLogTreeView(NO_GROUP); });
|
|
|
|
|
connect(logDeleteAction, &QAction::triggered, this, [=]() { deleteSelectedItems(ui.log_tree_view); });
|
|
|
|
|
connect(logClearAction, &QAction::triggered, this, [=]() { clearTreeView(ui.log_tree_view); });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 开始按钮
|
|
|
|
|
connect(ui.startButton, &QPushButton::clicked, this, &CrownClient::slotStart);
|
|
|
|
|
// 停止按钮
|
|
|
|
|
connect(ui.stopButton, &QPushButton::clicked, this, &CrownClient::slotStop);
|
|
|
|
|
// 登录按钮
|
|
|
|
|
connect(ui.loginButton, &QPushButton::clicked, this, &CrownClient::slotLogin);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//connect(this,&CrownClient::signalBetSuccess, m_conn);
|
|
|
|
|
|
|
|
|
|
// 创建定时器获取必要参数
|
|
|
|
|
m_paramerTimer = new QTimer(this);
|
|
|
|
|
connect(m_paramerTimer, &QTimer::timeout, this, &CrownClient::slotUpdateParamer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//// 开启心跳线程
|
|
|
|
|
//m_heartbeat_thread = new HeartbeatThread();
|
|
|
|
|
//connect(m_heartbeat_thread, &HeartbeatThread::signal_due, this, [&]() {
|
|
|
|
|
// VMProtectBegin("HeartBeat");
|
|
|
|
|
// QMessageBox::critical(nullptr, "错误", "授权已到期!");
|
|
|
|
|
// QApplication::quit();
|
|
|
|
|
// VMProtectEnd();
|
|
|
|
|
//});
|
|
|
|
|
//m_heartbeat_thread->start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建下注线程
|
|
|
|
|
m_bet_thread = new BetThread();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(m_bet_thread, &BetThread::signal_view_add_failed_order, this, &CrownClient::view_add_failed_order);
|
|
|
|
|
|
|
|
|
|
connect(m_bet_thread, &BetThread::signal_view_add_rebet_order, this, &CrownClient::view_add_rebet_order);
|
|
|
|
|
connect(m_bet_thread, &BetThread::signal_view_add_screen_order, this, &CrownClient::view_add_screen_order);
|
|
|
|
|
connect(m_bet_thread, &BetThread::signal_view_add_success_order, this, &CrownClient::view_add_success_order);
|
|
|
|
|
connect(m_bet_thread, &BetThread::signal_view_alert_failed_order, this, &CrownClient::view_alert_failed_order);
|
|
|
|
|
connect(m_bet_thread, &BetThread::signal_view_remove_failed_order, this, &CrownClient::view_remove_failed_order);
|
|
|
|
|
|
|
|
|
|
connect(m_bet_thread, &BetThread::account_disconnect, this, &CrownClient::on_disconnected);
|
|
|
|
|
|
|
|
|
|
// 发送跟单信息给服务端(防止重复跟单)
|
|
|
|
|
// connect(this, &CrownClient::signalBetSuccess, window_connect, &Connect::slotFollowBet);
|
|
|
|
|
connect(m_bet_thread,&BetThread::signal_bet_oder,window_connect, &Connect::slotFollowBet);
|
|
|
|
|
connect(m_bet_thread, &BetThread::log, this, &CrownClient::log);
|
|
|
|
|
|
|
|
|
|
emit log("日志","程序启动成功");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CrownClient::~CrownClient()
|
|
|
|
|
{
|
|
|
|
|
if (m_paramerTimer->isActive())
|
|
|
|
|
{
|
|
|
|
|
m_paramerTimer->stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CrownClient::closeEvent(QCloseEvent * event)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// 检查是否是自发事件(用户点击关闭按钮)
|
|
|
|
|
if (event->spontaneous()) {
|
|
|
|
|
// 用户点击窗口关闭按钮,最小化到托盘
|
|
|
|
|
if (trayIcon->isVisible()) {
|
|
|
|
|
hide(); // 隐藏窗口
|
|
|
|
|
event->ignore(); // 忽略关闭事件
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 在关闭窗口前确保所有网络请求被取消
|
|
|
|
|
QWebEnginePage* page = ui.webEngineView->page();
|
|
|
|
|
page->load(QUrl(""));
|
|
|
|
|
// 安全删除QWebEngineView和QWebEnginePage
|
|
|
|
|
//ui.webEngineView->deleteLater();
|
|
|
|
|
page->deleteLater();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 保存配置 -> 过滤注单时间开关
|
|
|
|
|
g_config->setScreenDateTimeEnable(ui.screenDateTimeCheckBox->isChecked());
|
|
|
|
|
// 保存配置 -> 过滤注单时间
|
|
|
|
|
g_config->setScreenDateTime(ui.dateTimeEdit->dateTime().toString());
|
|
|
|
|
|
|
|
|
|
g_config->set_client_url_list(ui.urlCombo->items());
|
|
|
|
|
g_config->set_client_url(ui.urlCombo->currentText());
|
|
|
|
|
g_config->setUsername(ui.usernameEdit->text());
|
|
|
|
|
g_config->setPassword(ui.passwordEdit->text());
|
|
|
|
|
if (m_heartbeatTimer->isActive())
|
|
|
|
|
{
|
|
|
|
|
m_heartbeatTimer->stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 平台账户掉线重连
|
|
|
|
|
/// </summary>
|
|
|
|
|
void CrownClient::on_disconnected()
|
|
|
|
|
{
|
|
|
|
|
// 判断当前正在工作状态
|
|
|
|
|
if (m_state == work)
|
|
|
|
|
{
|
|
|
|
|
// 立即更新为重新登录状态
|
|
|
|
|
m_state = relogin;
|
|
|
|
|
// 推送掉线消息
|
|
|
|
|
push_disconnected();
|
|
|
|
|
// 退出线程
|
|
|
|
|
m_bet_thread->exit();
|
|
|
|
|
// 清空参数
|
|
|
|
|
m_paramers.clear();
|
|
|
|
|
|
|
|
|
|
m_start_time = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
|
|
|
|
emit log("掉线重连", "平台账户掉线重连");
|
|
|
|
|
QTimer::singleShot(10 * 1000, [&]() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 访问网址
|
|
|
|
|
ui.webEngineView->page()->load(QUrl(""));
|
|
|
|
|
ui.webEngineView->page()->load(ui.urlCombo->currentText());
|
|
|
|
|
if (!m_paramerTimer->isActive())
|
|
|
|
|
{
|
|
|
|
|
m_paramerTimer->start(3000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 开始工作
|
|
|
|
|
/// </summary>
|
|
|
|
|
void CrownClient::slotStart()
|
|
|
|
|
{
|
|
|
|
|
// 保存配置 -> 过滤注单时间开关
|
|
|
|
|
g_config->setScreenDateTimeEnable(ui.screenDateTimeCheckBox->isChecked());
|
|
|
|
|
// 保存配置 -> 过滤注单时间
|
|
|
|
|
g_config->setScreenDateTime(ui.dateTimeEdit->dateTime().toString());
|
|
|
|
|
|
|
|
|
|
// 更新网址
|
|
|
|
|
m_paramers["url"] = ui.urlCombo->currentText();
|
|
|
|
|
// qDebug() << "网址:" << m_paramers["url"];
|
|
|
|
|
// 禁用连接按钮
|
|
|
|
|
ui.connectButton->setDisabled(true);
|
|
|
|
|
// 禁用设置按钮
|
|
|
|
|
ui.settingButton->setDisabled(true);
|
|
|
|
|
// 禁用开始按钮
|
|
|
|
|
ui.startButton->setDisabled(true);
|
|
|
|
|
// 启用停止按钮
|
|
|
|
|
ui.stopButton->setDisabled(false);
|
|
|
|
|
ui.screenDateTimeCheckBox->setDisabled(true);
|
|
|
|
|
ui.urlCombo->setDisabled(true);
|
|
|
|
|
ui.usernameEdit->setDisabled(true);
|
|
|
|
|
ui.passwordEdit->setDisabled(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_start_time = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
|
|
|
|
|
|
|
|
|
// 连接网页加载完成事件
|
|
|
|
|
connect(ui.webEngineView->page(), &QWebEnginePage::loadFinished, this, &CrownClient::slotLoadFinished);
|
|
|
|
|
// 访问网址
|
|
|
|
|
ui.webEngineView->page()->load(ui.urlCombo->currentText());
|
|
|
|
|
if (!m_paramerTimer->isActive())
|
|
|
|
|
{
|
|
|
|
|
m_paramerTimer->start(3000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (!m_work_timer->isActive())
|
|
|
|
|
//{
|
|
|
|
|
// m_work_timer->start(1000);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
emit signalStart();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CrownClient::slotStop()
|
|
|
|
|
{
|
|
|
|
|
ui.webEngineView->page()->load(QUrl(""));
|
|
|
|
|
// 启用连接按钮
|
|
|
|
|
ui.connectButton->setDisabled(false);
|
|
|
|
|
// 启用设置按钮
|
|
|
|
|
ui.settingButton->setDisabled(false);
|
|
|
|
|
// 禁用开始按钮
|
|
|
|
|
ui.startButton->setDisabled(false);
|
|
|
|
|
// 启用停止按钮
|
|
|
|
|
ui.stopButton->setDisabled(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui.screenDateTimeCheckBox->setDisabled(false);
|
|
|
|
|
ui.urlCombo->setDisabled(false);
|
|
|
|
|
ui.usernameEdit->setDisabled(false);
|
|
|
|
|
ui.passwordEdit->setDisabled(false);
|
|
|
|
|
// 取消连接网页加载完成事件
|
|
|
|
|
disconnect(ui.webEngineView->page(), &QWebEnginePage::loadFinished, this, &CrownClient::slotLoadFinished);
|
|
|
|
|
if (m_paramerTimer->isActive())
|
|
|
|
|
{
|
|
|
|
|
m_paramerTimer->stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_bet_thread->exit();
|
|
|
|
|
//if (m_work_timer->isActive())
|
|
|
|
|
//{
|
|
|
|
|
// m_work_timer->stop();
|
|
|
|
|
//}
|
|
|
|
|
m_state = wait;
|
|
|
|
|
m_paramers.clear();
|
|
|
|
|
// 等到登录成功再切换
|
|
|
|
|
ui.stateButton->setIcon(QIcon(":/images/Images/stop.png"));
|
|
|
|
|
emit signalStop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 网页加载完成事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="isok">是否加载完成</param>
|
|
|
|
|
void CrownClient::slotLoadFinished(bool isok)
|
|
|
|
|
{
|
|
|
|
|
if (isok)
|
|
|
|
|
{
|
|
|
|
|
// this->slotLogin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 槽函数 -> 登录
|
|
|
|
|
/// </summary>
|
|
|
|
|
void CrownClient::slotLogin()
|
|
|
|
|
{
|
|
|
|
|
// 延迟 500 毫秒防止未加载完成
|
|
|
|
|
QTimer::singleShot(1500, [&]() {
|
|
|
|
|
|
|
|
|
|
QString username = ui.usernameEdit->text().trimmed();
|
|
|
|
|
QString password = ui.passwordEdit->text().trimmed();
|
|
|
|
|
|
|
|
|
|
QString jsCode = QString(R"(
|
|
|
|
|
(function() {
|
|
|
|
|
try {
|
|
|
|
|
function fireKeyEvent(element, evtType, keyChar) {
|
|
|
|
|
if (!element) return;
|
|
|
|
|
element.focus();
|
|
|
|
|
var KeyboardEventInit = {key:keyChar, code:'', location:0, repeat:false, isComposing:false};
|
|
|
|
|
var evtObj = new KeyboardEvent(evtType, KeyboardEventInit);
|
|
|
|
|
element.dispatchEvent(evtObj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function virtualText(el, str) {
|
|
|
|
|
if (!el) return;
|
|
|
|
|
for(var i = 0; i < str.length; i++){
|
|
|
|
|
var cCode = str.charCodeAt(i);
|
|
|
|
|
fireKeyEvent(el,'keydown',cCode);
|
|
|
|
|
fireKeyEvent(el,'keypress',cCode);
|
|
|
|
|
fireKeyEvent(el,'keyup',cCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查元素是否存在
|
|
|
|
|
var userObj = document.getElementById('usr');
|
|
|
|
|
var pwdObj = document.getElementById('pwd');
|
|
|
|
|
var loginBtn = document.getElementById('btn_login');
|
|
|
|
|
|
|
|
|
|
if (!userObj || !pwdObj || !loginBtn) {
|
|
|
|
|
console.log('登录元素未找到,等待重试');
|
|
|
|
|
// 如果元素不存在,延迟200ms重试
|
|
|
|
|
setTimeout(arguments.callee, 200);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
userObj.click();
|
|
|
|
|
var input_user = '%1';
|
|
|
|
|
var input_user_event = new InputEvent('input', {bubbles: false, cancelable: false});
|
|
|
|
|
userObj.value = input_user;
|
|
|
|
|
userObj.dispatchEvent(input_user_event);
|
|
|
|
|
virtualText(userObj, input_user);
|
|
|
|
|
|
|
|
|
|
var input_pwd = '%2';
|
|
|
|
|
var input_pwd_event = new InputEvent('input', {bubbles: false, cancelable: false});
|
|
|
|
|
pwdObj.value = input_pwd;
|
|
|
|
|
pwdObj.dispatchEvent(input_pwd_event);
|
|
|
|
|
virtualText(pwdObj, input_pwd);
|
|
|
|
|
|
|
|
|
|
// 添加一点延迟再点击登录按钮
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
loginBtn.click();
|
|
|
|
|
console.log('登录按钮已点击');
|
|
|
|
|
}, 200);
|
|
|
|
|
|
|
|
|
|
} catch(e) {
|
|
|
|
|
console.log('登录过程出错:', e.message);
|
|
|
|
|
}
|
|
|
|
|
})();
|
|
|
|
|
)").arg(username).arg(password);
|
|
|
|
|
|
|
|
|
|
ui.webEngineView->page()->runJavaScript(jsCode);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 槽函数 -> 登录
|
|
|
|
|
///// </summary>
|
|
|
|
|
//void CrownClient::slotLogin()
|
|
|
|
|
//{
|
|
|
|
|
// // 延迟 500 毫秒防止未加载完成
|
|
|
|
|
// QTimer::singleShot(1500, [=]() {
|
|
|
|
|
//
|
|
|
|
|
// QString username = ui.usernameEdit->text().trimmed();
|
|
|
|
|
// QString password = ui.passwordEdit->text().trimmed();
|
|
|
|
|
//
|
|
|
|
|
// QString jsCode = QString(R"(
|
|
|
|
|
// function fireKeyEvent(element, evtType, keyChar) {
|
|
|
|
|
// element.focus();
|
|
|
|
|
// var KeyboardEventInit = {key:keyChar, code:'', location:0, repeat:false, isComposing:false};
|
|
|
|
|
// var evtObj = new KeyboardEvent(evtType, KeyboardEventInit);
|
|
|
|
|
// element.dispatchEvent(evtObj);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// function virtualText(el,str){
|
|
|
|
|
// for(var i = 0; i<str.length; i++){
|
|
|
|
|
// var cCode = str.charCodeAt(i);
|
|
|
|
|
// fireKeyEvent(el,'keydown',cCode);
|
|
|
|
|
// fireKeyEvent(el,'keypress',cCode);
|
|
|
|
|
// fireKeyEvent(el,'keyup',cCode);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// document.getElementById('usr').click();
|
|
|
|
|
// var userObj = document.getElementById('usr');
|
|
|
|
|
// var input_user = '%1';
|
|
|
|
|
// var input_user_event = new InputEvent('input', {bubbles: false, cancelable: false});
|
|
|
|
|
// userObj.value = input_user;
|
|
|
|
|
// userObj.dispatchEvent(input_user_event);
|
|
|
|
|
// virtualText(userObj,input_user);
|
|
|
|
|
//
|
|
|
|
|
// var pwdObj = document.getElementById('pwd');
|
|
|
|
|
// var input_pwd = '%2';
|
|
|
|
|
// var input_pwd_event = new InputEvent('input', {bubbles: false, cancelable: false});
|
|
|
|
|
// pwdObj.value = input_pwd;
|
|
|
|
|
// pwdObj.dispatchEvent(input_pwd_event);
|
|
|
|
|
// virtualText(pwdObj,input_pwd);
|
|
|
|
|
//
|
|
|
|
|
// document.getElementById('btn_login').click();
|
|
|
|
|
// )").arg(username).arg(password);
|
|
|
|
|
//
|
|
|
|
|
// ui.webEngineView->page()->runJavaScript(jsCode);
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
void CrownClient::slotUpdateParamer()
|
|
|
|
|
{
|
|
|
|
|
qint64 current_time = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
|
|
|
|
if (current_time - m_start_time > 30 * 1000)
|
|
|
|
|
{
|
|
|
|
|
// 清空参数
|
|
|
|
|
m_state = wait;
|
|
|
|
|
m_paramers.clear();
|
|
|
|
|
m_start_time = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
|
|
|
|
// 重新载入页面
|
|
|
|
|
ui.webEngineView->page()->load(ui.urlCombo->currentText());
|
|
|
|
|
|
|
|
|
|
qDebug() << "登录超时重载";
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// qDebug() << QString("定时器检测参数(%1)(%2):").arg(QDateTime::currentDateTime().toString()).arg(m_state) << m_paramers;
|
|
|
|
|
ui.webEngineView->page()->runJavaScript("if (document.getElementById('btn_login') && document.getElementById('usr') && document.getElementById('pwd')) 'ok';", [&](const QVariant& v) {
|
|
|
|
|
if (m_state == wait || m_state == relogin)
|
|
|
|
|
{
|
|
|
|
|
// 确保刚加载 设置为准备就绪状态
|
|
|
|
|
if (m_paramers["btn_login"].isEmpty())
|
|
|
|
|
{
|
|
|
|
|
m_paramers["btn_login"] = v.toString();
|
|
|
|
|
if (!v.toString().isEmpty())
|
|
|
|
|
{
|
|
|
|
|
m_state = readyLogin;
|
|
|
|
|
slotLogin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ui.webEngineView->page()->runJavaScript("if (document.getElementById('text_error')) document.getElementById('text_error').textContent;", [&](const QVariant& v) {
|
|
|
|
|
// qDebug() << "获取参数[text_error]: " << v.toString();
|
|
|
|
|
m_paramers["text_error"] = v.toString();
|
|
|
|
|
if (!v.toString().isEmpty() && m_state == readyLogin)
|
|
|
|
|
{
|
|
|
|
|
// qDebug() << "登录失败";
|
|
|
|
|
m_paramers.clear();
|
|
|
|
|
m_state = relogin;
|
|
|
|
|
// 重新执行登录
|
|
|
|
|
slotLogin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ui.webEngineView->page()->runJavaScript("if (langx) langx;", [&](const QVariant& v) {
|
|
|
|
|
// qDebug() << "获取参数[langx]: " << v.toString();
|
|
|
|
|
m_paramers["langx"] = v.toString();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ui.webEngineView->page()->runJavaScript("if (ver) ver;", [&](const QVariant& v) {
|
|
|
|
|
// qDebug() << "获取参数[ver]: " << v.toString();
|
|
|
|
|
m_paramers["ver"] = v.toString();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ui.webEngineView->page()->runJavaScript("if(document.URL) document.URL;", [=](const QVariant& v) {
|
|
|
|
|
// qDebug() << "获取参数[url]: " << v.toString();
|
|
|
|
|
m_paramers["url"] = v.toString();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 更新cookie
|
|
|
|
|
ui.webEngineView->page()->runJavaScript("function GetCookie(){return document.cookie} GetCookie();", [=](const QVariant& v) {
|
|
|
|
|
m_paramers["cookies"] = v.toString();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui.webEngineView->page()->runJavaScript("if (top.param) top.param;", [this](const QVariant& v) {
|
|
|
|
|
// qDebug() << "获取参数[param]: " << v.toString();
|
|
|
|
|
if (!v.toString().isEmpty() && this->m_paramers["text_error"].isEmpty() && !this->m_paramers["ver"].isEmpty() && m_state != work)
|
|
|
|
|
{
|
|
|
|
|
push_reconnected();
|
|
|
|
|
//if (m_state == relogin)
|
|
|
|
|
//{
|
|
|
|
|
// push_reconnected();
|
|
|
|
|
//}
|
|
|
|
|
m_state = work;
|
|
|
|
|
// 设置绿色信号灯
|
|
|
|
|
slotChangeState(2);
|
|
|
|
|
|
|
|
|
|
// 等到登录成功再切换
|
|
|
|
|
ui.stateButton->setIcon(QIcon(":/images/Images/start.png"));
|
|
|
|
|
// qDebug() << "登录成功";
|
|
|
|
|
if (this->m_paramers["url"] == "")
|
|
|
|
|
{
|
|
|
|
|
this->m_paramers["url"] = ui.urlCombo->currentText();
|
|
|
|
|
}
|
|
|
|
|
//this->m_paramers["url"] = ui.urlCombo->currentText();
|
|
|
|
|
this->m_paramers["param"] = v.toString();
|
|
|
|
|
m_bet_thread->setParam(m_paramers["url"], m_paramers["ver"], m_paramers["param"], m_paramers["cookies"]);
|
|
|
|
|
m_bet_thread->start();
|
|
|
|
|
|
|
|
|
|
m_paramerTimer->stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// alert_kick 踢人画面
|
|
|
|
|
|
|
|
|
|
//ui.webEngineView->findText("重新登入", QWebEnginePage::FindCaseSensitively, [&](bool result) {
|
|
|
|
|
// if (result)
|
|
|
|
|
// {
|
|
|
|
|
// qDebug() << "掉线";
|
|
|
|
|
// }
|
|
|
|
|
//});
|
|
|
|
|
|
|
|
|
|
//ui.webEngineView->page()->runJavaScript("if (document.getElementById('#popup_title')) 'ok';", [&](const QVariant& v) {
|
|
|
|
|
// qDebug() << "获取参数[掉线]: " << v.toString();
|
|
|
|
|
// if (!v.toString().isEmpty() && m_state == work)
|
|
|
|
|
// {
|
|
|
|
|
// qDebug() << "登录失败";
|
|
|
|
|
// m_paramers.clear();
|
|
|
|
|
// m_state = relogin;
|
|
|
|
|
// // 重新执行登录
|
|
|
|
|
// slotLogin();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//});
|
|
|
|
|
// popup_content
|
|
|
|
|
if (m_state == work)
|
|
|
|
|
{
|
|
|
|
|
m_paramerTimer->stop();
|
|
|
|
|
slotUpdateLeague();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CrownClient::slotUpdateLeague()
|
|
|
|
|
{
|
|
|
|
|
QNetworkAccessManager networkManager;
|
|
|
|
|
// 网络请求
|
|
|
|
|
QNetworkRequest request;
|
|
|
|
|
request.setUrl(QUrl(QString(m_paramers["url"] + "transform.php?ver=" + m_paramers["ver"])));
|
|
|
|
|
request.setRawHeader("Accept", "*/*");
|
|
|
|
|
request.setRawHeader("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6");
|
|
|
|
|
request.setRawHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.50");
|
|
|
|
|
request.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
|
|
|
request.setRawHeader("Origin", m_paramers["url"].toUtf8());
|
|
|
|
|
request.setRawHeader("Referer", m_paramers["url"].toUtf8());
|
|
|
|
|
|
|
|
|
|
// 获取当前时间戳
|
|
|
|
|
QString timeStamp = QString::number(QDateTime::currentDateTime().addSecs(-43200).toTime_t());
|
|
|
|
|
QString data = "p=get_list_tv&" + m_paramers["param"] + ">ype=ALL&date=ALL&device=phone&ts=" + timeStamp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QNetworkReply* reply = networkManager.post(request, data.toUtf8());
|
|
|
|
|
// 忽略SSL证书错误
|
|
|
|
|
reply->ignoreSslErrors();
|
|
|
|
|
// 事件循环
|
|
|
|
|
QEventLoop eventLoop;
|
|
|
|
|
// 连接信号和槽
|
|
|
|
|
connect(&networkManager, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
|
|
|
|
|
// 开始循环
|
|
|
|
|
eventLoop.exec();
|
|
|
|
|
|
|
|
|
|
// 错误处理
|
|
|
|
|
if (reply->error() != QNetworkReply::NoError)
|
|
|
|
|
{
|
|
|
|
|
QVariant statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
|
|
|
|
|
qDebug("服务器响应错误代码: %d Qt错误代码:%d\n", statusCode.toInt(), (int)reply->error());
|
|
|
|
|
qDebug(qPrintable(reply->errorString()));
|
|
|
|
|
reply->deleteLater();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QByteArray result = reply->readAll();
|
|
|
|
|
reply->deleteLater();
|
|
|
|
|
QXmlStreamReader reader(result);
|
|
|
|
|
QList<QMap<QString, QString>> list;
|
|
|
|
|
QMap<QString, QString> game;
|
|
|
|
|
bool start = false;
|
|
|
|
|
while (!reader.atEnd())
|
|
|
|
|
{
|
|
|
|
|
reader.readNext();
|
|
|
|
|
|
|
|
|
|
if (reader.name() == "game" && reader.isStartElement())
|
|
|
|
|
{
|
|
|
|
|
start = true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (start && reader.name() != "game")
|
|
|
|
|
{
|
|
|
|
|
QString name = reader.name().toString();
|
|
|
|
|
game[name] = reader.readElementText();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (reader.name() == "game" && reader.isEndElement())
|
|
|
|
|
{
|
|
|
|
|
start = false;
|
|
|
|
|
list.append(game);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
emit signalUpdateLeagueAndTeam(list);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CrownClient::slotChangeState(int state)
|
|
|
|
|
{
|
|
|
|
|
if (state == 0)
|
|
|
|
|
{
|
|
|
|
|
ui.stateButton_connect->setIcon(QIcon(":/images/Images/red.png"));
|
|
|
|
|
ui.stateButton_connect->setText("连接断开");
|
|
|
|
|
QPalette palette;
|
|
|
|
|
palette.setColor(QPalette::ButtonText, QColor(Qt::red));
|
|
|
|
|
ui.stateButton_connect->setPalette(palette);
|
|
|
|
|
}
|
|
|
|
|
else if (state == 1)
|
|
|
|
|
{
|
|
|
|
|
ui.stateButton_connect->setIcon(QIcon(":/images/Images/yellow.png"));
|
|
|
|
|
ui.stateButton_connect->setText("等待连接");
|
|
|
|
|
QPalette palette;
|
|
|
|
|
palette.setColor(QPalette::ButtonText, QColor(0xFF8C00));
|
|
|
|
|
ui.stateButton_connect->setPalette(palette);
|
|
|
|
|
}
|
|
|
|
|
else if (state == 2)
|
|
|
|
|
{
|
|
|
|
|
ui.stateButton_connect->setIcon(QIcon(":/images/Images/green.png"));
|
|
|
|
|
ui.stateButton_connect->setText("连接成功");
|
|
|
|
|
QPalette palette;
|
|
|
|
|
palette.setColor(QPalette::ButtonText, QColor(0x008000));
|
|
|
|
|
ui.stateButton_connect->setPalette(palette);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
接收注单
|
|
|
|
|
list:注单信息
|
|
|
|
|
*/
|
|
|
|
|
void CrownClient::slotAcceptOrders(QList<QMap<QString, QString>> list)
|
|
|
|
|
{
|
|
|
|
|
// 播放接收注单声音
|
|
|
|
|
if (g_config->acceptOrderSoundEnable())
|
|
|
|
|
{
|
|
|
|
|
if (!g_config->acceptOrderSoundPath().isEmpty())
|
|
|
|
|
{
|
|
|
|
|
QSound::play(g_config->acceptOrderSoundPath());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QSound::play(":/sound/sound/accept.wav");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emit log("程序运行",QString("接收到 %1 条注单").arg(list.count()));
|
|
|
|
|
for (int i = 0; i < list.count(); i++)
|
|
|
|
|
{
|
|
|
|
|
QMap<QString, QString> order = list[i];
|
|
|
|
|
|
|
|
|
|
// 提前处理数据格式
|
|
|
|
|
// 接收时间(按当前配置取)
|
|
|
|
|
// 存储皇冠时间
|
|
|
|
|
order["ACCEPT_DATETIME"] = QDateTime::currentDateTime().addSecs(-43200).toString("yyyy-MM-dd hh:mm:ss");
|
|
|
|
|
// 接收注单入库
|
|
|
|
|
g_config->add_accept_order(order);
|
|
|
|
|
// 添加接收注单视图
|
|
|
|
|
|
|
|
|
|
view_add_accept_order(order);
|
|
|
|
|
push_accept(order);
|
|
|
|
|
// 开始筛选注单
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 滚动到最后一行
|
|
|
|
|
//ui.orderTableWidget->scrollToBottom();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
设置账户信息
|
|
|
|
|
*/
|
|
|
|
|
void CrownClient::slotSetUser(QString username, QString password)
|
|
|
|
|
{
|
|
|
|
|
if (ui.startButton->isEnabled())
|
|
|
|
|
{
|
|
|
|
|
ui.usernameEdit->setText(username);
|
|
|
|
|
ui.passwordEdit->setText(password);
|
|
|
|
|
//ui.levelCombo->setCurrentText(level);
|
|
|
|
|
//ui.safeCodeEdit->setText(safeCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
更新读取次数
|
|
|
|
|
*/
|
|
|
|
|
void CrownClient::slotUpdateReadOrdersTimes()
|
|
|
|
|
{
|
|
|
|
|
m_readOrderTimes++;
|
|
|
|
|
ui.readOrderTimes->setText("<html><head/><body><p>读取次数:<span style=\"color:#0000FF;\"> " + QString::number(m_readOrderTimes) + "</span> 接收注单:<span style=\"color:#008000;\"> " + QString::number(m_readOrderCount) + "</span> 跟单成功:<span style=\"color:#00FF00;\"> " + QString::number(m_successOrderCount) + "</span> 过滤注单:<span style=\"color:#FF0000;\"> " + QString::number(m_screenOrderCount)+ "</span></p></body></html>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
更新读取数量
|
|
|
|
|
*/
|
|
|
|
|
void CrownClient::slotUpdateReadOrdersCount(int count)
|
|
|
|
|
{
|
|
|
|
|
m_readOrderCount += count;
|
|
|
|
|
ui.readOrderTimes->setText("<html><head/><body><p>读取次数:<span style=\"color:#0000FF;\"> " + QString::number(m_readOrderTimes) + "</span> 接收注单:<span style=\"color:#008000;\"> " + QString::number(m_readOrderCount) + "</span> 跟单成功:<span style=\"color:#00FF00;\"> " + QString::number(m_successOrderCount) + "</span> 过滤注单:<span style=\"color:#FF0000;\"> " + QString::number(m_screenOrderCount) + "</span></p></body></html>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CrownClient::on_log(QString type, QString log)
|
|
|
|
|
{
|
|
|
|
|
// 1. 获取并调整当前时间(根据crownTime配置)
|
|
|
|
|
const bool useCrownTime = g_config->crownTime();
|
|
|
|
|
const QDateTime currentTime = QDateTime::currentDateTime();
|
|
|
|
|
const QDateTime displayTime = useCrownTime ? currentTime.addSecs(-43200) : currentTime;
|
|
|
|
|
|
|
|
|
|
// 2. 格式化日期时间字符串
|
|
|
|
|
const QString datetimeStr = displayTime.toString("yyyy-MM-dd hh:mm:ss");
|
|
|
|
|
const QString dateStr = displayTime.toString("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
// 3. 创建日志条目项
|
|
|
|
|
QList<QStandardItem*> logItems = {
|
|
|
|
|
new QStandardItem(datetimeStr),
|
|
|
|
|
new QStandardItem(type),
|
|
|
|
|
new QStandardItem(log)
|
|
|
|
|
};
|
|
|
|
|
logItems.first()->setData(-1, Qt::UserRole + 1); // 标记为子节点
|
|
|
|
|
|
|
|
|
|
// 4. 根据当前分组模式处理
|
|
|
|
|
if (m_logGroupType == NO_GROUP) {
|
|
|
|
|
// 无分组模式,直接添加
|
|
|
|
|
m_logModel->appendRow(logItems);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 查找或创建分组节点
|
|
|
|
|
QString groupKey;
|
|
|
|
|
if (m_logGroupType == BY_TIME) {
|
|
|
|
|
groupKey = dateStr;
|
|
|
|
|
}
|
|
|
|
|
else if (m_logGroupType == BY_LOG_TYPE) {
|
|
|
|
|
groupKey = type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStandardItem* groupItem = nullptr;
|
|
|
|
|
for (int i = 0; i < m_logModel->rowCount(); ++i) {
|
|
|
|
|
if (m_logModel->item(i)->text() == groupKey) {
|
|
|
|
|
groupItem = m_logModel->item(i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (groupItem) {
|
|
|
|
|
groupItem->appendRow(logItems);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
groupItem = new QStandardItem(groupKey);
|
|
|
|
|
groupItem->setData(1, Qt::UserRole + 1); // 标记为分组节点
|
|
|
|
|
groupItem->setIcon(QIcon(":/icons/date.png"));
|
|
|
|
|
groupItem->appendRow(logItems);
|
|
|
|
|
m_logModel->appendRow(groupItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 自动滚动到底部
|
|
|
|
|
ui.log_tree_view->scrollToBottom();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CrownClient::view_add_accept_order(QMap<QString, QString> order)
|
|
|
|
|
{
|
|
|
|
|
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(ui.order_tree_view->model());
|
|
|
|
|
if (!model) return;
|
|
|
|
|
|
|
|
|
|
// 处理下注时间(皇冠时间提前12小时)
|
|
|
|
|
QString bet_dateTime = order["DATETIME"];
|
|
|
|
|
if (!g_config->crownTime()) {
|
|
|
|
|
QDateTime finalDate1 = QDateTime::fromString(bet_dateTime, "yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
bet_dateTime = finalDate1.addSecs(43200).toString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 提取日期用于分组
|
|
|
|
|
QString dateStr = QDateTime::fromString(bet_dateTime, "yyyy-MM-dd HH:mm:ss")
|
|
|
|
|
.toString("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
// 创建行数据项
|
|
|
|
|
QList<QStandardItem*> rowItems;
|
|
|
|
|
|
|
|
|
|
// Column 0: 单号/场次
|
|
|
|
|
QStandardItem* item_tid = new QStandardItem(order["TID"]);
|
|
|
|
|
item_tid->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
item_tid->setData(-1, Qt::UserRole + 1); // 标记为子节点
|
|
|
|
|
rowItems.append(item_tid);
|
|
|
|
|
|
|
|
|
|
// Column 1: 下注时间
|
|
|
|
|
QStandardItem* item_betDateTime = new QStandardItem(bet_dateTime);
|
|
|
|
|
item_betDateTime->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_betDateTime);
|
|
|
|
|
|
|
|
|
|
// Column 2: 接收时间
|
|
|
|
|
QString accept_dateTime = order["ACCEPT_DATETIME"];
|
|
|
|
|
if (!g_config->crownTime()) {
|
|
|
|
|
QDateTime finalDate1 = QDateTime::fromString(accept_dateTime, "yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
accept_dateTime = finalDate1.addSecs(43200).toString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
}
|
|
|
|
|
QStandardItem* item_acceptTime = new QStandardItem(accept_dateTime);
|
|
|
|
|
item_acceptTime->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_acceptTime);
|
|
|
|
|
|
|
|
|
|
// Column 3: 会员/代理
|
|
|
|
|
QStandardItem* item_username = new QStandardItem(order["NAME0"]);
|
|
|
|
|
item_username->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_username);
|
|
|
|
|
|
|
|
|
|
// Column 4: 项目
|
|
|
|
|
QStandardItem* item_projectName = new QStandardItem(order["GT"] + order["SESSION"] + order["STAGE"]);
|
|
|
|
|
item_projectName->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_projectName);
|
|
|
|
|
|
|
|
|
|
// Column 5: 类型
|
|
|
|
|
|
|
|
|
|
QStandardItem* item_type = new QStandardItem(Utils::get_market(order["WAGERS_TYPE"]) + Utils::format_wagers_type(order));
|
|
|
|
|
item_type->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_type);
|
|
|
|
|
|
|
|
|
|
// Column 6: 联赛/队伍
|
|
|
|
|
QString league;
|
|
|
|
|
if (order["SCORE"] != "")
|
|
|
|
|
{
|
|
|
|
|
league = order["LEAGUE"] + "\n" + order["TEAM_H"] + " " + order["SCORE"] + " " + order["TEAM_C"];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
league = order["LEAGUE"] + "\n" + order["TEAM_H"] + " vs " + order["TEAM_C"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStandardItem* item_league = new QStandardItem(league);
|
|
|
|
|
item_league->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_league);
|
|
|
|
|
|
|
|
|
|
// Column 7: 下注
|
|
|
|
|
QStandardItem* item_team_bet = new QStandardItem(order["ORDER_TYPE"]);
|
|
|
|
|
item_team_bet->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_team_bet);
|
|
|
|
|
|
|
|
|
|
// Column 8: 盘口
|
|
|
|
|
QStandardItem* item_handicap = new QStandardItem(order["ORDER_CON"]);
|
|
|
|
|
item_handicap->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_handicap);
|
|
|
|
|
|
|
|
|
|
// Column 9: 赔率
|
|
|
|
|
QStandardItem* item_odds = new QStandardItem(order["IORATIO"]);
|
|
|
|
|
item_odds->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_odds);
|
|
|
|
|
|
|
|
|
|
// Column 10: 金额
|
|
|
|
|
QStandardItem* item_gold = new QStandardItem(Utils::instance().formatGold(order["GOLD"]));
|
|
|
|
|
item_gold->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_gold);
|
|
|
|
|
|
|
|
|
|
// 根据当前分组模式处理
|
|
|
|
|
if (m_orderGroupType == NO_GROUP) {
|
|
|
|
|
// 无分组模式,直接添加
|
|
|
|
|
model->appendRow(rowItems);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 获取干净的分组键(移除可能存在的计数)
|
|
|
|
|
QString rawGroupKey;
|
|
|
|
|
if (m_orderGroupType == BY_TIME) {
|
|
|
|
|
rawGroupKey = dateStr;
|
|
|
|
|
}
|
|
|
|
|
else if (m_orderGroupType == BY_ORDER_ID) {
|
|
|
|
|
rawGroupKey = order["TID"]; // 取订单号前8位作为分组
|
|
|
|
|
}
|
|
|
|
|
QString cleanGroupKey = rawGroupKey.split(" (").first().trimmed();
|
|
|
|
|
|
|
|
|
|
// 查找或创建分组节点(比较时也清理计数)
|
|
|
|
|
QStandardItem* groupItem = nullptr;
|
|
|
|
|
for (int i = 0; i < model->rowCount(); ++i) {
|
|
|
|
|
QString itemText = model->item(i)->text();
|
|
|
|
|
if (itemText.split(" (").first().trimmed() == cleanGroupKey) {
|
|
|
|
|
groupItem = model->item(i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (groupItem) {
|
|
|
|
|
// 添加到现有分组
|
|
|
|
|
groupItem->appendRow(rowItems);
|
|
|
|
|
// 统一更新分组标题格式为"键 (计数)"
|
|
|
|
|
groupItem->setText(QString("%1 (%2)").arg(cleanGroupKey).arg(groupItem->rowCount()));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 创建新分组(直接使用带计数的格式)
|
|
|
|
|
groupItem = new QStandardItem(QString("%1 (1)").arg(cleanGroupKey));
|
|
|
|
|
groupItem->setData(1, Qt::UserRole + 1); // 标记为分组节点
|
|
|
|
|
groupItem->setSelectable(false);
|
|
|
|
|
groupItem->setEditable(false);
|
|
|
|
|
groupItem->setIcon(QIcon(":/icons/date.png"));
|
|
|
|
|
groupItem->appendRow(rowItems);
|
|
|
|
|
model->appendRow(groupItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 自动滚动到底部
|
|
|
|
|
ui.order_tree_view->scrollToBottom();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 其他 view_add_* 函数也按照类似的模式修改,这里以 view_add_screen_order 为例
|
|
|
|
|
void CrownClient::view_add_screen_order(QMap<QString, QString> order)
|
|
|
|
|
{
|
|
|
|
|
m_screenOrderCount++;
|
|
|
|
|
view_flush_counter();
|
|
|
|
|
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(ui.screen_tree_view->model());
|
|
|
|
|
if (!model) return;
|
|
|
|
|
|
|
|
|
|
// 处理下注时间
|
|
|
|
|
QString betTime = order["DATETIME"];
|
|
|
|
|
if (!g_config->crownTime()) {
|
|
|
|
|
QDateTime finalDate = QDateTime::fromString(betTime, "yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
betTime = finalDate.addSecs(43200).toString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString dateStr = QDateTime::fromString(betTime, "yyyy-MM-dd HH:mm:ss")
|
|
|
|
|
.toString("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
// 创建行数据项
|
|
|
|
|
QList<QStandardItem*> rowItems;
|
|
|
|
|
|
|
|
|
|
// Column 0: 单号/场次
|
|
|
|
|
QStandardItem* item_tid = new QStandardItem(order["TID"]);
|
|
|
|
|
item_tid->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
item_tid->setData(-1, Qt::UserRole + 1);
|
|
|
|
|
rowItems.append(item_tid);
|
|
|
|
|
|
|
|
|
|
// Column 1: 下注时间
|
|
|
|
|
QStandardItem* item_betTime = new QStandardItem(betTime);
|
|
|
|
|
item_betTime->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_betTime);
|
|
|
|
|
|
|
|
|
|
// Column 2: 会员/代理
|
|
|
|
|
QStandardItem* item_username = new QStandardItem(order["NAME0"]);
|
|
|
|
|
item_username->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_username);
|
|
|
|
|
|
|
|
|
|
// Column 3: 项目
|
|
|
|
|
QStandardItem* item_project = new QStandardItem(order["GT"] + order["SESSION"] + order["STAGE"]);
|
|
|
|
|
item_project->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_project);
|
|
|
|
|
|
|
|
|
|
// Column 4: 类型
|
|
|
|
|
QStandardItem* item_type = new QStandardItem(Utils::get_market(order["WAGERS_TYPE"]) + Utils::format_wagers_type(order));
|
|
|
|
|
item_type->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_type);
|
|
|
|
|
|
|
|
|
|
// Column 5: 联赛/队伍
|
|
|
|
|
QString league;
|
|
|
|
|
if (order["SCORE"] != "")
|
|
|
|
|
{
|
|
|
|
|
league = order["LEAGUE"] + "\n" + order["TEAM_H"] + " " + order["SCORE"] + " " + order["TEAM_C"];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
league = order["LEAGUE"] + "\n" + order["TEAM_H"] + " vs " + order["TEAM_C"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStandardItem* item_league = new QStandardItem(league);
|
|
|
|
|
|
|
|
|
|
//QStandardItem* item_league = new QStandardItem(
|
|
|
|
|
// order["LEAGUE"] + "\n" + order["TEAM_H"] + " vs " + order["TEAM_C"]);
|
|
|
|
|
item_league->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_league);
|
|
|
|
|
|
|
|
|
|
// Column 6: 下注
|
|
|
|
|
QStandardItem* item_teamBet = new QStandardItem(order["ORDER_TYPE"]);
|
|
|
|
|
item_teamBet->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_teamBet);
|
|
|
|
|
|
|
|
|
|
// Column 7: 盘口
|
|
|
|
|
QString handicap;
|
|
|
|
|
if (order["ORDER_CON_NEW"].isEmpty())
|
|
|
|
|
{
|
|
|
|
|
if (order["ORDER_CON"] != "")
|
|
|
|
|
{
|
|
|
|
|
handicap = "(原)" + order["ORDER_CON"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
handicap = "(原)" + order["ORDER_CON"] + "\n" + "(现)" + order["ORDER_CON_NEW"];
|
|
|
|
|
}
|
|
|
|
|
QStandardItem* item_handicap = new QStandardItem(handicap);
|
|
|
|
|
item_handicap->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_handicap);
|
|
|
|
|
|
|
|
|
|
// Column 8: 赔率
|
|
|
|
|
// 筛选显示原始赔率/最新赔率
|
|
|
|
|
// 补单显示原始赔率/最新赔率
|
|
|
|
|
QString odds;
|
|
|
|
|
if (order["IORATIO_NEW"].isEmpty())
|
|
|
|
|
{
|
|
|
|
|
odds = "(原)" + order["IORATIO"];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
odds = "(原)" + order["IORATIO"] + "\n" + "(现)" + order["IORATIO_NEW"];
|
|
|
|
|
}
|
|
|
|
|
QStandardItem* item_odds = new QStandardItem(odds);
|
|
|
|
|
item_odds->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_odds);
|
|
|
|
|
|
|
|
|
|
// Column 9: 金额
|
|
|
|
|
QStandardItem* item_gold = new QStandardItem(order["GOLD"]);
|
|
|
|
|
item_gold->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_gold);
|
|
|
|
|
|
|
|
|
|
// Column 10: 原因
|
|
|
|
|
QStandardItem* item_reason = new QStandardItem(order["REASON"]);
|
|
|
|
|
item_reason->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_reason);
|
|
|
|
|
|
|
|
|
|
// 根据当前分组模式处理
|
|
|
|
|
if (m_screenGroupType == NO_GROUP) {
|
|
|
|
|
// 无分组模式,直接添加
|
|
|
|
|
model->appendRow(rowItems);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 获取干净的分组键(移除可能存在的计数)
|
|
|
|
|
QString rawGroupKey;
|
|
|
|
|
if (m_screenGroupType == BY_TIME) {
|
|
|
|
|
rawGroupKey = dateStr;
|
|
|
|
|
}
|
|
|
|
|
else if (m_screenGroupType == BY_ORDER_ID) {
|
|
|
|
|
rawGroupKey = order["TID"]; // 使用完整订单号作为分组键
|
|
|
|
|
}
|
|
|
|
|
QString cleanGroupKey = rawGroupKey.split(" (").first().trimmed();
|
|
|
|
|
|
|
|
|
|
// 查找或创建分组节点(比较时也清理计数)
|
|
|
|
|
QStandardItem* groupItem = nullptr;
|
|
|
|
|
for (int i = 0; i < model->rowCount(); ++i) {
|
|
|
|
|
QString itemText = model->item(i)->text();
|
|
|
|
|
if (itemText.split(" (").first().trimmed() == cleanGroupKey) {
|
|
|
|
|
groupItem = model->item(i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (groupItem) {
|
|
|
|
|
// 添加到现有分组
|
|
|
|
|
groupItem->appendRow(rowItems);
|
|
|
|
|
// 统一更新分组标题格式为"键 (计数)"
|
|
|
|
|
groupItem->setText(QString("%1 (%2)").arg(cleanGroupKey).arg(groupItem->rowCount()));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 创建新分组(直接使用带计数的格式)
|
|
|
|
|
groupItem = new QStandardItem(QString("%1 (1)").arg(cleanGroupKey));
|
|
|
|
|
groupItem->setData(1, Qt::UserRole + 1); // 标记为分组节点
|
|
|
|
|
groupItem->setSelectable(false);
|
|
|
|
|
groupItem->setEditable(false);
|
|
|
|
|
groupItem->setIcon(QIcon(":/icons/date.png"));
|
|
|
|
|
groupItem->appendRow(rowItems);
|
|
|
|
|
model->appendRow(groupItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 自动滚动到底部
|
|
|
|
|
ui.screen_tree_view->scrollToBottom();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CrownClient::view_add_success_order(QMap<QString, QString> order)
|
|
|
|
|
{
|
|
|
|
|
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(ui.success_tree_view->model());
|
|
|
|
|
if (!model) return;
|
|
|
|
|
|
|
|
|
|
// 跟单时间(本地当前时间,用于列表显示与分组)
|
|
|
|
|
//QString followTime = g_config->formatDateTime(QDateTime::currentDateTime())
|
|
|
|
|
// .toString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
QString followTime = order["DATETIME"];
|
|
|
|
|
if (!g_config->crownTime()) {
|
|
|
|
|
QDateTime finalDate = QDateTime::fromString(followTime, "yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
followTime = finalDate.addSecs(43200).toString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
}
|
|
|
|
|
QString dateStr = QDateTime::fromString(followTime, "yyyy-MM-dd HH:mm:ss")
|
|
|
|
|
.toString("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
// 清洗队名
|
|
|
|
|
auto cleanTeam = [](QString s)->QString {
|
|
|
|
|
s.replace(QRegularExpression("<br\\s*/?>", QRegularExpression::CaseInsensitiveOption), "");
|
|
|
|
|
s.remove(' ');
|
|
|
|
|
return s.trimmed();
|
|
|
|
|
};
|
|
|
|
|
QString teamH = cleanTeam(order["TEAM_H"]);
|
|
|
|
|
QString teamC = cleanTeam(order["TEAM_C"]);
|
|
|
|
|
|
|
|
|
|
// 盘口:原/新
|
|
|
|
|
QString handicap;
|
|
|
|
|
if (order["ORDER_CON_NEW"].isEmpty())
|
|
|
|
|
{
|
|
|
|
|
if (order["ORDER_CON"] != "")
|
|
|
|
|
{
|
|
|
|
|
handicap = "(原)" + order["ORDER_CON"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
handicap = "(原)" + order["ORDER_CON"] + "\n" + "(现)" + order["ORDER_CON_NEW"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 赔率:原/新
|
|
|
|
|
QString odds;
|
|
|
|
|
if (order["IORATIO_NEW"].isEmpty())
|
|
|
|
|
{
|
|
|
|
|
odds = "(原)" + order["IORATIO"];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
odds = "(原)" + order["IORATIO"] + "\n" + "(现)" + order["IORATIO_NEW"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建行
|
|
|
|
|
QList<QStandardItem*> rowItems;
|
|
|
|
|
|
|
|
|
|
// 0: 单号
|
|
|
|
|
QStandardItem* item_tid = new QStandardItem(order["TID"]);
|
|
|
|
|
item_tid->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
item_tid->setData(-1, Qt::UserRole + 1);
|
|
|
|
|
rowItems.append(item_tid);
|
|
|
|
|
|
|
|
|
|
// 1: 跟单时间
|
|
|
|
|
QStandardItem* item_followTime = new QStandardItem(followTime);
|
|
|
|
|
item_followTime->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_followTime);
|
|
|
|
|
|
|
|
|
|
// 2: 会员/代理
|
|
|
|
|
QStandardItem* item_username = new QStandardItem(order["NAME0"]);
|
|
|
|
|
item_username->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_username);
|
|
|
|
|
|
|
|
|
|
// 3: 项目(球种+会话+场次)
|
|
|
|
|
QStandardItem* item_project = new QStandardItem(order["GT"] + order["SESSION"] + order["STAGE"]);
|
|
|
|
|
item_project->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_project);
|
|
|
|
|
|
|
|
|
|
// 4: 类型(统一用文案格式化)
|
|
|
|
|
QStandardItem* item_type = new QStandardItem(Utils::get_market(order["WAGERS_TYPE"]) + Utils::format_wagers_type(order));
|
|
|
|
|
item_type->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_type);
|
|
|
|
|
|
|
|
|
|
// 5: 联赛/队伍
|
|
|
|
|
QString score;
|
|
|
|
|
if (order["SCORE_NEW"] != "")
|
|
|
|
|
{
|
|
|
|
|
score = order["LEAGUE"] + "\n" + teamH + " "+order["SCORE_NEW"]+" " + teamC ;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
score = order["LEAGUE"] + "\n" + teamH + " vs " + teamC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStandardItem* item_league = new QStandardItem(score);
|
|
|
|
|
item_league->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_league);
|
|
|
|
|
|
|
|
|
|
// 6: 下注
|
|
|
|
|
QStandardItem* item_teamBet = new QStandardItem(order["ORDER_TYPE"]);
|
|
|
|
|
item_teamBet->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_teamBet);
|
|
|
|
|
|
|
|
|
|
// 7: 盘口
|
|
|
|
|
QStandardItem* item_handicap = new QStandardItem(handicap);
|
|
|
|
|
item_handicap->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_handicap);
|
|
|
|
|
|
|
|
|
|
// 8: 赔率
|
|
|
|
|
QStandardItem* item_odds = new QStandardItem(odds);
|
|
|
|
|
item_odds->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_odds);
|
|
|
|
|
|
|
|
|
|
// 9: 金额
|
|
|
|
|
QStandardItem* item_gold = new QStandardItem(Utils::instance().formatGold(order["GOLD"]));
|
|
|
|
|
item_gold->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_gold);
|
|
|
|
|
|
|
|
|
|
// 分组
|
|
|
|
|
if (m_successGroupType == NO_GROUP) {
|
|
|
|
|
model->appendRow(rowItems);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
QString rawGroupKey;
|
|
|
|
|
if (m_successGroupType == BY_TIME) {
|
|
|
|
|
rawGroupKey = dateStr;
|
|
|
|
|
}
|
|
|
|
|
else if (m_successGroupType == BY_ORDER_ID) {
|
|
|
|
|
rawGroupKey = order["TID"].left(8);
|
|
|
|
|
}
|
|
|
|
|
QString cleanGroupKey = rawGroupKey.split(" (").first().trimmed();
|
|
|
|
|
|
|
|
|
|
QStandardItem* groupItem = nullptr;
|
|
|
|
|
for (int i = 0; i < model->rowCount(); ++i) {
|
|
|
|
|
QString txt = model->item(i)->text();
|
|
|
|
|
if (txt.split(" (").first().trimmed() == cleanGroupKey) {
|
|
|
|
|
groupItem = model->item(i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (groupItem) {
|
|
|
|
|
groupItem->appendRow(rowItems);
|
|
|
|
|
groupItem->setText(QString("%1 (%2)").arg(cleanGroupKey).arg(groupItem->rowCount()));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
groupItem = new QStandardItem(QString("%1 (1)").arg(cleanGroupKey));
|
|
|
|
|
groupItem->setData(1, Qt::UserRole + 1);
|
|
|
|
|
groupItem->setSelectable(false);
|
|
|
|
|
groupItem->setEditable(false);
|
|
|
|
|
groupItem->setIcon(QIcon(":/icons/success.png"));
|
|
|
|
|
groupItem->appendRow(rowItems);
|
|
|
|
|
model->appendRow(groupItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 计数与滚动
|
|
|
|
|
m_successOrderCount++;
|
|
|
|
|
view_flush_counter();
|
|
|
|
|
ui.success_tree_view->scrollToBottom();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CrownClient::view_add_failed_order(QMap<QString, QString> order)
|
|
|
|
|
{
|
|
|
|
|
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(ui.failed_tree_view->model());
|
|
|
|
|
if (!model) return;
|
|
|
|
|
|
|
|
|
|
// 跟单时间
|
|
|
|
|
QString followTime = order["DATETIME"];
|
|
|
|
|
if (!g_config->crownTime()) {
|
|
|
|
|
QDateTime finalDate = QDateTime::fromString(followTime, "yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
followTime = finalDate.addSecs(43200).toString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
}
|
|
|
|
|
QString dateStr = QDateTime::fromString(followTime, "yyyy-MM-dd HH:mm:ss")
|
|
|
|
|
.toString("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
// 创建行数据项
|
|
|
|
|
QList<QStandardItem*> rowItems;
|
|
|
|
|
|
|
|
|
|
// Column 0: 单号/场次
|
|
|
|
|
QStandardItem* item_tid = new QStandardItem(order["TID"]);
|
|
|
|
|
item_tid->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
item_tid->setData(-1, Qt::UserRole + 1); // 标记为子节点
|
|
|
|
|
rowItems.append(item_tid);
|
|
|
|
|
|
|
|
|
|
// Column 1: 跟单时间
|
|
|
|
|
QStandardItem* item_followTime = new QStandardItem(followTime);
|
|
|
|
|
item_followTime->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_followTime);
|
|
|
|
|
|
|
|
|
|
// Column 2: 会员/代理
|
|
|
|
|
QStandardItem* item_username = new QStandardItem(order["NAME0"]);
|
|
|
|
|
item_username->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_username);
|
|
|
|
|
|
|
|
|
|
// Column 3: 项目
|
|
|
|
|
QStandardItem* item_project = new QStandardItem(order["GT"] + order["SESSION"] + order["STAGE"]);
|
|
|
|
|
item_project->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_project);
|
|
|
|
|
|
|
|
|
|
// Column 4: 类型
|
|
|
|
|
QStandardItem* item_type = new QStandardItem(Utils::get_market(order["WAGERS_TYPE"]) + Utils::format_wagers_type(order));
|
|
|
|
|
item_type->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_type);
|
|
|
|
|
|
|
|
|
|
// Column 5: 联赛/队伍
|
|
|
|
|
QString league;
|
|
|
|
|
if (order["SCORE"] != "")
|
|
|
|
|
{
|
|
|
|
|
league = order["LEAGUE"] + "\n" + order["TEAM_H"] + " " + order["SCORE"] + " " + order["TEAM_C"];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
league = order["LEAGUE"] + "\n" + order["TEAM_H"] + " vs " + order["TEAM_C"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStandardItem* item_league = new QStandardItem(league);
|
|
|
|
|
item_league->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_league);
|
|
|
|
|
|
|
|
|
|
// Column 6: 下注
|
|
|
|
|
QStandardItem* item_teamBet = new QStandardItem(order["ORDER_TYPE"]);
|
|
|
|
|
item_teamBet->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_teamBet);
|
|
|
|
|
|
|
|
|
|
// Column 7: 盘口
|
|
|
|
|
QString handicap;
|
|
|
|
|
if (order["ORDER_CON_NEW"].isEmpty())
|
|
|
|
|
{
|
|
|
|
|
if (order["ORDER_CON"] != "")
|
|
|
|
|
{
|
|
|
|
|
handicap = "(原)" + order["ORDER_CON"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
handicap = "(原)" + order["ORDER_CON"] + "\n" + "(现)" + order["ORDER_CON_NEW"];
|
|
|
|
|
}
|
|
|
|
|
QStandardItem* item_handicap = new QStandardItem(handicap);
|
|
|
|
|
item_handicap->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_handicap);
|
|
|
|
|
|
|
|
|
|
// Column 8: 赔率
|
|
|
|
|
// 失败显示原始赔率/最新赔率
|
|
|
|
|
// 补单显示原始赔率/最新赔率
|
|
|
|
|
QString odds;
|
|
|
|
|
if (order["IORATIO_NEW"].isEmpty())
|
|
|
|
|
{
|
|
|
|
|
odds = "(原)" + order["IORATIO"];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
odds = "(原)" + order["IORATIO"] + "\n" + "(现)" + order["IORATIO_NEW"];
|
|
|
|
|
}
|
|
|
|
|
QStandardItem* item_odds = new QStandardItem(odds);
|
|
|
|
|
item_odds->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_odds);
|
|
|
|
|
|
|
|
|
|
// Column 9: 金额
|
|
|
|
|
QStandardItem* item_gold = new QStandardItem(Utils::instance().formatGold(order["GOLD"]));
|
|
|
|
|
item_gold->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_gold);
|
|
|
|
|
|
|
|
|
|
// Column 10: 原因
|
|
|
|
|
QStandardItem* item_reason = new QStandardItem(order["REASON"]);
|
|
|
|
|
item_reason->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_reason);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据当前分组模式处理
|
|
|
|
|
if (m_failedGroupType == NO_GROUP) {
|
|
|
|
|
// 无分组模式,直接添加
|
|
|
|
|
model->appendRow(rowItems);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 获取干净的分组键(移除可能存在的计数)
|
|
|
|
|
QString rawGroupKey;
|
|
|
|
|
if (m_failedGroupType == BY_TIME) {
|
|
|
|
|
rawGroupKey = dateStr;
|
|
|
|
|
}
|
|
|
|
|
else if (m_failedGroupType == BY_ORDER_ID) {
|
|
|
|
|
rawGroupKey = order["TID"]; // 使用完整订单号作为分组键
|
|
|
|
|
}
|
|
|
|
|
QString cleanGroupKey = rawGroupKey.split(" (").first().trimmed();
|
|
|
|
|
|
|
|
|
|
// 查找或创建分组节点(比较时也清理计数)
|
|
|
|
|
QStandardItem* groupItem = nullptr;
|
|
|
|
|
for (int i = 0; i < model->rowCount(); ++i) {
|
|
|
|
|
QString itemText = model->item(i)->text();
|
|
|
|
|
if (itemText.split(" (").first().trimmed() == cleanGroupKey) {
|
|
|
|
|
groupItem = model->item(i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (groupItem) {
|
|
|
|
|
// 添加到现有分组
|
|
|
|
|
groupItem->appendRow(rowItems);
|
|
|
|
|
// 统一更新分组标题格式为"键 (计数)"
|
|
|
|
|
groupItem->setText(QString("%1 (%2)").arg(cleanGroupKey).arg(groupItem->rowCount()));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 创建新分组(直接使用带计数的格式)
|
|
|
|
|
groupItem = new QStandardItem(QString("%1 (1)").arg(cleanGroupKey));
|
|
|
|
|
groupItem->setData(1, Qt::UserRole + 1); // 标记为分组节点
|
|
|
|
|
groupItem->setSelectable(false);
|
|
|
|
|
groupItem->setEditable(false);
|
|
|
|
|
groupItem->setIcon(QIcon(":/icons/failed.png"));
|
|
|
|
|
groupItem->appendRow(rowItems);
|
|
|
|
|
model->appendRow(groupItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 自动滚动到底部
|
|
|
|
|
ui.failed_tree_view->scrollToBottom();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CrownClient::view_alert_failed_order(QMap<QString, QString> order)
|
|
|
|
|
{
|
|
|
|
|
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(ui.failed_tree_view->model());
|
|
|
|
|
if (!model) return;
|
|
|
|
|
|
|
|
|
|
QString tid = order["TID"];
|
|
|
|
|
|
|
|
|
|
// 查找匹配的订单项(递归搜索所有层级)
|
|
|
|
|
QModelIndexList matches = model->match(
|
|
|
|
|
model->index(0, 0),
|
|
|
|
|
Qt::DisplayRole,
|
|
|
|
|
tid,
|
|
|
|
|
-1,
|
|
|
|
|
Qt::MatchExactly | Qt::MatchRecursive
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (matches.isEmpty()) {
|
|
|
|
|
// qDebug() << "未找到需要更新的失败订单:" << tid;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取找到的第一行
|
|
|
|
|
QModelIndex rowIndex = matches.first();
|
|
|
|
|
QStandardItem* item = model->itemFromIndex(rowIndex);
|
|
|
|
|
if (!item) return;
|
|
|
|
|
|
|
|
|
|
// 获取所在行和父项
|
|
|
|
|
int row = rowIndex.row();
|
|
|
|
|
QStandardItem* parentItem = item->parent();
|
|
|
|
|
|
|
|
|
|
// 更新原因列(第10列)
|
|
|
|
|
QStandardItem* reasonItem = nullptr;
|
|
|
|
|
if (parentItem) {
|
|
|
|
|
// 分组模式下的子项
|
|
|
|
|
reasonItem = parentItem->child(row, 10);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 无分组模式
|
|
|
|
|
reasonItem = model->item(row, 10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (reasonItem) {
|
|
|
|
|
reasonItem->setText(order["REASON"]);
|
|
|
|
|
reasonItem->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
// qDebug() << "已更新失败订单原因:" << tid << order["REASON"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CrownClient::view_remove_failed_order(QMap<QString, QString> order)
|
|
|
|
|
{
|
|
|
|
|
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(ui.failed_tree_view->model());
|
|
|
|
|
if (!model) return;
|
|
|
|
|
|
|
|
|
|
QString tid = order["TID"];
|
|
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
|
|
// 遍历所有项(包括分组)
|
|
|
|
|
for (int i = 0; i < model->rowCount(); ++i) {
|
|
|
|
|
QStandardItem* item = model->item(i);
|
|
|
|
|
|
|
|
|
|
// 检查是否是分组项
|
|
|
|
|
if (item->data(Qt::UserRole + 1).toInt() == 1) {
|
|
|
|
|
// 分组项,检查其子项
|
|
|
|
|
for (int j = 0; j < item->rowCount(); ++j) {
|
|
|
|
|
QStandardItem* childItem = item->child(j, 0);
|
|
|
|
|
if (childItem && childItem->text() == tid) {
|
|
|
|
|
// 移除子项
|
|
|
|
|
item->removeRow(j);
|
|
|
|
|
|
|
|
|
|
// 更新分组标题计数
|
|
|
|
|
QString cleanText = item->text().split(" (").first().trimmed();
|
|
|
|
|
item->setText(QString("%1 (%2)").arg(cleanText).arg(item->rowCount()));
|
|
|
|
|
|
|
|
|
|
// 如果分组为空则移除
|
|
|
|
|
if (item->rowCount() == 0) {
|
|
|
|
|
model->removeRow(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
found = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 非分组项直接比较
|
|
|
|
|
else if (item && item->text() == tid) {
|
|
|
|
|
model->removeRow(i);
|
|
|
|
|
found = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found) break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
|
// qDebug() << "未找到要移除的订单:" << tid;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// qDebug() << "已移除失败订单:" << tid;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CrownClient::view_add_rebet_order(QMap<QString, QString> order)
|
|
|
|
|
{
|
|
|
|
|
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(ui.rebet_tree_view->model());
|
|
|
|
|
if (!model) return;
|
|
|
|
|
|
|
|
|
|
// 跟单时间
|
|
|
|
|
QString followTime = order["DATETIME"];
|
|
|
|
|
if (!g_config->crownTime()) {
|
|
|
|
|
QDateTime finalDate = QDateTime::fromString(followTime, "yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
followTime = finalDate.addSecs(43200).toString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
}
|
|
|
|
|
QString dateStr = QDateTime::fromString(followTime, "yyyy-MM-dd HH:mm:ss")
|
|
|
|
|
.toString("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
// 创建行数据项
|
|
|
|
|
QList<QStandardItem*> rowItems;
|
|
|
|
|
|
|
|
|
|
// 提取纯净的订单号(移除可能存在的补单次数)
|
|
|
|
|
QString rawTid = order["TID"].split(" (").first().trimmed();
|
|
|
|
|
|
|
|
|
|
// Column 0: 单号/场次
|
|
|
|
|
QStandardItem* item_tid = new QStandardItem(order["TID"]);
|
|
|
|
|
item_tid->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
item_tid->setData(-1, Qt::UserRole + 1); // 标记为子节点
|
|
|
|
|
rowItems.append(item_tid);
|
|
|
|
|
|
|
|
|
|
// Column 1: 跟单时间
|
|
|
|
|
QStandardItem* item_followTime = new QStandardItem(followTime);
|
|
|
|
|
item_followTime->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_followTime);
|
|
|
|
|
|
|
|
|
|
// Column 2: 会员/代理
|
|
|
|
|
QStandardItem* item_username = new QStandardItem(order["NAME0"]);
|
|
|
|
|
item_username->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_username);
|
|
|
|
|
|
|
|
|
|
// Column 3: 项目
|
|
|
|
|
QStandardItem* item_project = new QStandardItem(order["GT"] + order["SESSION"] + order["STAGE"]);
|
|
|
|
|
item_project->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_project);
|
|
|
|
|
|
|
|
|
|
// Column 4: 类型
|
|
|
|
|
QStandardItem* item_type = new QStandardItem(Utils::get_market(order["WAGERS_TYPE"]) + Utils::format_wagers_type(order));
|
|
|
|
|
item_type->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_type);
|
|
|
|
|
|
|
|
|
|
// Column 5: 联赛/队伍
|
|
|
|
|
QString league;
|
|
|
|
|
if (order["SCORE"] != "")
|
|
|
|
|
{
|
|
|
|
|
league = order["LEAGUE"] + "\n" + order["TEAM_H"] + " " + order["SCORE"] + " " + order["TEAM_C"];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
league = order["LEAGUE"] + "\n" + order["TEAM_H"] + " vs " + order["TEAM_C"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStandardItem* item_league = new QStandardItem(league);
|
|
|
|
|
item_league->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_league);
|
|
|
|
|
|
|
|
|
|
// Column 6: 下注
|
|
|
|
|
QStandardItem* item_teamBet = new QStandardItem(order["ORDER_TYPE"]);
|
|
|
|
|
item_teamBet->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_teamBet);
|
|
|
|
|
|
|
|
|
|
// Column 7: 盘口
|
|
|
|
|
QString handicap;
|
|
|
|
|
if (order["ORDER_CON_NEW"].isEmpty())
|
|
|
|
|
{
|
|
|
|
|
if (order["ORDER_CON"] != "")
|
|
|
|
|
{
|
|
|
|
|
handicap = "(原)" + order["ORDER_CON"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
handicap = "(原)" + order["ORDER_CON"] + "\n" + "(现)" + order["ORDER_CON_NEW"];
|
|
|
|
|
}
|
|
|
|
|
QStandardItem* item_handicap = new QStandardItem(handicap);
|
|
|
|
|
item_handicap->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_handicap);
|
|
|
|
|
|
|
|
|
|
// Column 8: 赔率
|
|
|
|
|
// 补单显示原始赔率/最新赔率
|
|
|
|
|
QString odds;
|
|
|
|
|
if (order["IORATIO_NEW"].isEmpty())
|
|
|
|
|
{
|
|
|
|
|
odds = "(原)" + order["IORATIO"];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
odds = "(原)" + order["IORATIO"] + "\n" + "(现)" + order["IORATIO_NEW"];
|
|
|
|
|
}
|
|
|
|
|
QStandardItem* item_odds = new QStandardItem(odds);
|
|
|
|
|
item_odds->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_odds);
|
|
|
|
|
|
|
|
|
|
// Column 9: 金额
|
|
|
|
|
QStandardItem* item_gold = new QStandardItem(Utils::instance().formatGold(order["GOLD"]));
|
|
|
|
|
item_gold->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_gold);
|
|
|
|
|
|
|
|
|
|
// Column 10: 原因
|
|
|
|
|
QStandardItem* item_reason = new QStandardItem(order["REASON"]);
|
|
|
|
|
item_reason->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item_reason);
|
|
|
|
|
|
|
|
|
|
// 根据当前分组模式处理
|
|
|
|
|
if (m_rebetGroupType == NO_GROUP) {
|
|
|
|
|
// 无分组模式,直接添加
|
|
|
|
|
model->appendRow(rowItems);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 获取干净的分组键(移除可能存在的计数)
|
|
|
|
|
QString rawGroupKey;
|
|
|
|
|
if (m_rebetGroupType == BY_TIME) {
|
|
|
|
|
rawGroupKey = dateStr;
|
|
|
|
|
}
|
|
|
|
|
else if (m_rebetGroupType == BY_ORDER_ID) {
|
|
|
|
|
rawGroupKey = rawTid; // 使用纯净的订单号作为分组键
|
|
|
|
|
}
|
|
|
|
|
QString cleanGroupKey = rawGroupKey.split(" (").first().trimmed();
|
|
|
|
|
|
|
|
|
|
// 查找或创建分组节点(比较时也清理计数)
|
|
|
|
|
QStandardItem* groupItem = nullptr;
|
|
|
|
|
for (int i = 0; i < model->rowCount(); ++i) {
|
|
|
|
|
QString itemText = model->item(i)->text();
|
|
|
|
|
if (itemText.split(" (").first().trimmed() == cleanGroupKey) {
|
|
|
|
|
groupItem = model->item(i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (groupItem) {
|
|
|
|
|
// 添加到现有分组
|
|
|
|
|
groupItem->appendRow(rowItems);
|
|
|
|
|
// 统一更新分组标题格式为"键 (计数)"
|
|
|
|
|
groupItem->setText(QString("%1 (%2)").arg(cleanGroupKey).arg(groupItem->rowCount()));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 创建新分组(直接使用带计数的格式)
|
|
|
|
|
groupItem = new QStandardItem(QString("%1 (1)").arg(cleanGroupKey));
|
|
|
|
|
groupItem->setData(1, Qt::UserRole + 1); // 标记为分组节点
|
|
|
|
|
groupItem->setSelectable(false);
|
|
|
|
|
groupItem->setEditable(false);
|
|
|
|
|
groupItem->setIcon(QIcon(":/icons/rebet.png"));
|
|
|
|
|
groupItem->appendRow(rowItems);
|
|
|
|
|
model->appendRow(groupItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 自动滚动到底部
|
|
|
|
|
ui.rebet_tree_view->scrollToBottom();
|
|
|
|
|
}
|
|
|
|
|
void CrownClient::view_change_time(bool isCrownTime)
|
|
|
|
|
{
|
|
|
|
|
// 1. 更新时间模式配置
|
|
|
|
|
g_config->setCrownTime(isCrownTime);
|
|
|
|
|
|
|
|
|
|
// 2. 计算时间偏移量(12小时 = 43200秒)
|
|
|
|
|
const int timeOffset = isCrownTime ? -43200 : 43200;
|
|
|
|
|
|
|
|
|
|
// 3. 更新界面时间显示
|
|
|
|
|
ui.dateTimeEdit->setDateTime(ui.dateTimeEdit->dateTime().addSecs(timeOffset));
|
|
|
|
|
g_config->setScreenDateTime(ui.dateTimeEdit->dateTime().toString());
|
|
|
|
|
|
|
|
|
|
// 4. 更新按钮状态
|
|
|
|
|
ui.crownTimeButton->setIcon(QIcon(isCrownTime
|
|
|
|
|
? ":/images/Images/crownTime.png"
|
|
|
|
|
: ":/images/Images/localTime.png"));
|
|
|
|
|
ui.crownTimeButton->setText(isCrownTime ? "皇冠时间" : "本地时间");
|
|
|
|
|
|
|
|
|
|
QToolTip::showText(ui.crownTimeButton->mapToGlobal(ui.crownTimeButton->rect().bottomLeft()),
|
|
|
|
|
isCrownTime ? "当前设置为皇冠时间" : "当前设置为本地时间");
|
|
|
|
|
|
|
|
|
|
QPalette palette;
|
|
|
|
|
palette.setColor(QPalette::ButtonText, isCrownTime ? QColor(Qt::red) : QColor(QRgb(0x008000)));
|
|
|
|
|
ui.crownTimeButton->setPalette(palette);
|
|
|
|
|
|
|
|
|
|
// 5. 处理所有视图
|
|
|
|
|
const QVector<QTreeView*> allViews = {
|
|
|
|
|
ui.order_tree_view,
|
|
|
|
|
ui.screen_tree_view,
|
|
|
|
|
ui.success_tree_view,
|
|
|
|
|
ui.failed_tree_view,
|
|
|
|
|
ui.rebet_tree_view,
|
|
|
|
|
ui.log_tree_view
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (QTreeView* treeView : allViews) {
|
|
|
|
|
// 获取模型
|
|
|
|
|
QAbstractItemModel* model = treeView->model();
|
|
|
|
|
QStandardItemModel* standardModel = qobject_cast<QStandardItemModel*>(
|
|
|
|
|
(treeView == ui.log_tree_view) ?
|
|
|
|
|
qobject_cast<QSortFilterProxyModel*>(model)->sourceModel() :
|
|
|
|
|
model
|
|
|
|
|
);
|
|
|
|
|
if (!standardModel) continue;
|
|
|
|
|
|
|
|
|
|
// 禁用视图刷新
|
|
|
|
|
treeView->setUpdatesEnabled(false);
|
|
|
|
|
|
|
|
|
|
// 确定需要调整的时间列索引集合
|
|
|
|
|
QVector<int> timeColumns;
|
|
|
|
|
if (treeView == ui.order_tree_view) {
|
|
|
|
|
// 下注时间(1列) + 接收时间(2列)
|
|
|
|
|
timeColumns = { 1, 2 };
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.log_tree_view) {
|
|
|
|
|
// 日志视图时间在第0列
|
|
|
|
|
timeColumns = { 0 };
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 其余视图时间统一在第1列
|
|
|
|
|
timeColumns = { 1 };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 处理所有行(包括分组行)
|
|
|
|
|
for (int row = 0; row < standardModel->rowCount(); ++row) {
|
|
|
|
|
QStandardItem* item = standardModel->item(row, 0);
|
|
|
|
|
if (!item) continue;
|
|
|
|
|
|
|
|
|
|
// 处理分组标题时间(如"2025-06-16 (2)")
|
|
|
|
|
if (item->data(Qt::UserRole + 1).toInt() == 1 && item->text().contains(" (")) {
|
|
|
|
|
QStringList parts = item->text().split(" (");
|
|
|
|
|
if (parts.size() >= 2) {
|
|
|
|
|
QString dateStr = parts[0].trimmed();
|
|
|
|
|
QString countStr = parts[1].replace(")", "").trimmed();
|
|
|
|
|
|
|
|
|
|
QDate date = QDate::fromString(dateStr, "yyyy-MM-dd");
|
|
|
|
|
if (date.isValid()) {
|
|
|
|
|
// 切换到皇冠时间 -> 日期减1天;切换到本地时间 -> 日期加1天
|
|
|
|
|
date = isCrownTime ? date.addDays(-1) : date.addDays(1);
|
|
|
|
|
item->setText(QString("%1 (%2)")
|
|
|
|
|
.arg(date.toString("yyyy-MM-dd"))
|
|
|
|
|
.arg(countStr));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 处理当前行的各时间列
|
|
|
|
|
for (int timeColumn : timeColumns) {
|
|
|
|
|
QStandardItem* timeItem = standardModel->item(row, timeColumn);
|
|
|
|
|
if (timeItem && !timeItem->text().isEmpty()) {
|
|
|
|
|
QDateTime originalTime = QDateTime::fromString(timeItem->text(), "yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
if (originalTime.isValid()) {
|
|
|
|
|
timeItem->setText(originalTime.addSecs(timeOffset).toString("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 处理分组下的子项
|
|
|
|
|
if (item->rowCount() > 0) {
|
|
|
|
|
for (int childRow = 0; childRow < item->rowCount(); ++childRow) {
|
|
|
|
|
for (int timeColumn : timeColumns) {
|
|
|
|
|
QStandardItem* childTimeItem = item->child(childRow, timeColumn);
|
|
|
|
|
if (childTimeItem && !childTimeItem->text().isEmpty()) {
|
|
|
|
|
QDateTime originalTime = QDateTime::fromString(childTimeItem->text(), "yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
if (originalTime.isValid()) {
|
|
|
|
|
childTimeItem->setText(originalTime.addSecs(timeOffset).toString("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 恢复视图刷新
|
|
|
|
|
treeView->setUpdatesEnabled(true);
|
|
|
|
|
treeView->viewport()->update();
|
|
|
|
|
|
|
|
|
|
// 重新应用当前分组(确保分组标题更新)
|
|
|
|
|
if (treeView == ui.log_tree_view) {
|
|
|
|
|
groupLogTreeView(m_logGroupType);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 添加更新计数器的函数
|
|
|
|
|
void CrownClient::view_flush_counter()
|
|
|
|
|
{
|
|
|
|
|
ui.readOrderTimes->setText(QString("<html><head/><body><p>读取次数:<span style=\"color:#0000FF;\"> %1</span>"
|
|
|
|
|
" 接收注单:<span style=\"color:#008000;\"> %2</span>"
|
|
|
|
|
" 跟单成功:<span style=\"color:#00FF00;\"> %3</span>"
|
|
|
|
|
" 过滤注单:<span style=\"color:#FF0000;\"> %4</span></p></body></html>")
|
|
|
|
|
.arg(m_readOrderTimes)
|
|
|
|
|
.arg(m_readOrderCount)
|
|
|
|
|
.arg(m_successOrderCount)
|
|
|
|
|
.arg(m_screenOrderCount));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CrownClient::groupTreeView(QTreeView* treeView, GroupType groupType)
|
|
|
|
|
{
|
|
|
|
|
if (treeView == ui.order_tree_view) {
|
|
|
|
|
m_orderGroupType = groupType;
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.screen_tree_view) {
|
|
|
|
|
m_screenGroupType = groupType;
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.success_tree_view) {
|
|
|
|
|
m_successGroupType = groupType;
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.failed_tree_view) {
|
|
|
|
|
m_failedGroupType = groupType;
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.rebet_tree_view) {
|
|
|
|
|
m_rebetGroupType = groupType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(treeView->model());
|
|
|
|
|
if (!model) return;
|
|
|
|
|
|
|
|
|
|
// 1. 保存当前列宽
|
|
|
|
|
QVector<int> columnWidths;
|
|
|
|
|
for (int i = 0; i < model->columnCount(); ++i) {
|
|
|
|
|
columnWidths.append(treeView->columnWidth(i));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2. 保存当前数据
|
|
|
|
|
QList<QMap<int, QString>> allData;
|
|
|
|
|
for (int row = 0; row < model->rowCount(); ++row) {
|
|
|
|
|
QStandardItem* item = model->item(row);
|
|
|
|
|
if (item->data(Qt::UserRole + 1).toInt() == 1) {
|
|
|
|
|
// 分组节点,遍历其子节点
|
|
|
|
|
for (int childRow = 0; childRow < item->rowCount(); ++childRow) {
|
|
|
|
|
QMap<int, QString> rowData;
|
|
|
|
|
for (int col = 0; col < model->columnCount(); ++col) {
|
|
|
|
|
QStandardItem* childItem = item->child(childRow, col);
|
|
|
|
|
if (childItem) {
|
|
|
|
|
rowData[col] = childItem->text();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
allData.append(rowData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 普通节点
|
|
|
|
|
QMap<int, QString> rowData;
|
|
|
|
|
for (int col = 0; col < model->columnCount(); ++col) {
|
|
|
|
|
QStandardItem* childItem = model->item(row, col);
|
|
|
|
|
if (childItem) {
|
|
|
|
|
rowData[col] = childItem->text();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
allData.append(rowData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3. 清空模型并重新设置表头
|
|
|
|
|
model->clear();
|
|
|
|
|
if (treeView == ui.order_tree_view) {
|
|
|
|
|
model->setHorizontalHeaderLabels({ "单号/场次","下注时间","接收时间","会员/代理","项目","类型","联赛/队伍","下注","盘口","赔率","金额" });
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.screen_tree_view) {
|
|
|
|
|
model->setHorizontalHeaderLabels({ "单号/场次","下注时间","会员/代理","项目","类型","联赛/队伍","下注","盘口","赔率","金额","原因" });
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.success_tree_view) {
|
|
|
|
|
model->setHorizontalHeaderLabels({ "单号/场次","跟单时间","会员/代理","项目","类型","联赛/队伍","下注","盘口","赔率","金额" });
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.failed_tree_view) {
|
|
|
|
|
model->setHorizontalHeaderLabels({ "单号/场次","跟单时间","会员/代理","项目","类型","联赛/队伍","下注","盘口","赔率","金额","原因" });
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.rebet_tree_view) {
|
|
|
|
|
model->setHorizontalHeaderLabels({ "单号/场次","跟单时间","会员/代理","项目","类型","联赛/队伍","下注","盘口","赔率","金额","原因" });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 4. 重新添加数据,按照新的分组方式
|
|
|
|
|
if (groupType == NO_GROUP) {
|
|
|
|
|
// 无分组,直接添加所有行
|
|
|
|
|
for (const auto& rowData : allData) {
|
|
|
|
|
QList<QStandardItem*> rowItems;
|
|
|
|
|
for (int col = 0; col < model->columnCount(); ++col) {
|
|
|
|
|
QStandardItem* item = new QStandardItem(rowData[col]);
|
|
|
|
|
item->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item);
|
|
|
|
|
}
|
|
|
|
|
model->appendRow(rowItems);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 有分组,按分组键组织数据
|
|
|
|
|
QMap<QString, QList<QMap<int, QString>>> groupedData;
|
|
|
|
|
|
|
|
|
|
for (const auto& rowData : allData) {
|
|
|
|
|
QString groupKey;
|
|
|
|
|
if (groupType == BY_TIME) {
|
|
|
|
|
QString timeStr = rowData[1]; // 假设第1列是时间
|
|
|
|
|
groupKey = timeStr.left(10); // 取日期部分
|
|
|
|
|
}
|
|
|
|
|
else if (groupType == BY_ORDER_ID) {
|
|
|
|
|
groupKey = rowData[0].left(8); // 假设第0列是订单号,取前8位
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 清除可能存在的已有计数
|
|
|
|
|
groupKey = groupKey.split(" (").first().trimmed();
|
|
|
|
|
groupedData[groupKey].append(rowData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加分组和子项
|
|
|
|
|
for (auto it = groupedData.begin(); it != groupedData.end(); ++it) {
|
|
|
|
|
QString groupTitle = QString("%1 (%2)").arg(it.key()).arg(it.value().size());
|
|
|
|
|
|
|
|
|
|
QStandardItem* groupItem = new QStandardItem(groupTitle);
|
|
|
|
|
groupItem->setData(1, Qt::UserRole + 1); // 标记为分组节点
|
|
|
|
|
groupItem->setSelectable(false);
|
|
|
|
|
groupItem->setEditable(false);
|
|
|
|
|
groupItem->setIcon(QIcon(":/icons/date.png"));
|
|
|
|
|
|
|
|
|
|
for (const auto& rowData : it.value()) {
|
|
|
|
|
QList<QStandardItem*> rowItems;
|
|
|
|
|
for (int col = 0; col < model->columnCount(); ++col) {
|
|
|
|
|
QStandardItem* item = new QStandardItem(rowData[col]);
|
|
|
|
|
item->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item);
|
|
|
|
|
}
|
|
|
|
|
groupItem->appendRow(rowItems);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model->appendRow(groupItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 5. 恢复列宽
|
|
|
|
|
for (int i = 0; i < columnWidths.size() && i < model->columnCount(); ++i) {
|
|
|
|
|
treeView->setColumnWidth(i, columnWidths[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 6. 展开所有分组
|
|
|
|
|
treeView->expandAll();
|
|
|
|
|
}
|
|
|
|
|
void CrownClient::groupLogTreeView(GroupType groupType)
|
|
|
|
|
{
|
|
|
|
|
m_logGroupType = groupType;
|
|
|
|
|
|
|
|
|
|
if (!m_logModel) return;
|
|
|
|
|
|
|
|
|
|
// 保存当前数据
|
|
|
|
|
QList<QMap<int, QString>> allData;
|
|
|
|
|
for (int row = 0; row < m_logModel->rowCount(); ++row) {
|
|
|
|
|
QStandardItem* item = m_logModel->item(row);
|
|
|
|
|
if (item->data(Qt::UserRole + 1).toInt() == 1) {
|
|
|
|
|
// 分组节点,遍历其子节点
|
|
|
|
|
for (int childRow = 0; childRow < item->rowCount(); ++childRow) {
|
|
|
|
|
QMap<int, QString> rowData;
|
|
|
|
|
for (int col = 0; col < m_logModel->columnCount(); ++col) {
|
|
|
|
|
QStandardItem* childItem = item->child(childRow, col);
|
|
|
|
|
if (childItem) {
|
|
|
|
|
rowData[col] = childItem->text();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
allData.append(rowData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 普通节点
|
|
|
|
|
QMap<int, QString> rowData;
|
|
|
|
|
for (int col = 0; col < m_logModel->columnCount(); ++col) {
|
|
|
|
|
QStandardItem* childItem = m_logModel->item(row, col);
|
|
|
|
|
if (childItem) {
|
|
|
|
|
rowData[col] = childItem->text();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
allData.append(rowData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 清空模型并重新设置表头
|
|
|
|
|
m_logModel->clear();
|
|
|
|
|
m_logModel->setHorizontalHeaderLabels({ "时间","类型","日志" });
|
|
|
|
|
|
|
|
|
|
// 重新添加数据,按照新的分组方式
|
|
|
|
|
if (groupType == NO_GROUP) {
|
|
|
|
|
// 无分组,直接添加所有行
|
|
|
|
|
for (const auto& rowData : allData) {
|
|
|
|
|
QList<QStandardItem*> rowItems;
|
|
|
|
|
for (int col = 0; col < m_logModel->columnCount(); ++col) {
|
|
|
|
|
QStandardItem* item = new QStandardItem(rowData[col]);
|
|
|
|
|
item->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item);
|
|
|
|
|
}
|
|
|
|
|
m_logModel->appendRow(rowItems);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 有分组,按分组键组织数据
|
|
|
|
|
QMap<QString, QList<QMap<int, QString>>> groupedData;
|
|
|
|
|
|
|
|
|
|
for (const auto& rowData : allData) {
|
|
|
|
|
QString groupKey;
|
|
|
|
|
if (groupType == BY_TIME) {
|
|
|
|
|
QString timeStr = rowData[0]; // 第0列是时间
|
|
|
|
|
groupKey = timeStr.left(10); // 取日期部分
|
|
|
|
|
}
|
|
|
|
|
else if (groupType == BY_LOG_TYPE) {
|
|
|
|
|
groupKey = rowData[1]; // 第1列是日志类型
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 清除可能存在的已有计数
|
|
|
|
|
groupKey = groupKey.split(" (").first().trimmed();
|
|
|
|
|
groupedData[groupKey].append(rowData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加分组和子项
|
|
|
|
|
for (auto it = groupedData.begin(); it != groupedData.end(); ++it) {
|
|
|
|
|
QString groupTitle = QString("%1 (%2)").arg(it.key()).arg(it.value().size());
|
|
|
|
|
|
|
|
|
|
QStandardItem* groupItem = new QStandardItem(groupTitle);
|
|
|
|
|
groupItem->setData(1, Qt::UserRole + 1); // 标记为分组节点
|
|
|
|
|
groupItem->setSelectable(false);
|
|
|
|
|
groupItem->setEditable(false);
|
|
|
|
|
groupItem->setIcon(QIcon(":/icons/date.png"));
|
|
|
|
|
|
|
|
|
|
for (const auto& rowData : it.value()) {
|
|
|
|
|
QList<QStandardItem*> rowItems;
|
|
|
|
|
for (int col = 0; col < m_logModel->columnCount(); ++col) {
|
|
|
|
|
QStandardItem* item = new QStandardItem(rowData[col]);
|
|
|
|
|
item->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
rowItems.append(item);
|
|
|
|
|
}
|
|
|
|
|
groupItem->appendRow(rowItems);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_logModel->appendRow(groupItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 展开所有分组
|
|
|
|
|
ui.log_tree_view->expandAll();
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
void CrownClient::deleteSelectedItems(QTreeView* treeView)
|
|
|
|
|
{
|
|
|
|
|
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(treeView->model());
|
|
|
|
|
if (!model || !treeView->selectionModel()) {
|
|
|
|
|
// qDebug() << "模型或选择模型无效";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取所有选中的行(使用selectedRows确保获取整行)
|
|
|
|
|
QModelIndexList selected = treeView->selectionModel()->selectedRows(0); // 只需要第一列索引
|
|
|
|
|
if (selected.isEmpty()) {
|
|
|
|
|
// qDebug() << "没有选中的行";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 收集要删除的订单号和对应模型索引
|
|
|
|
|
QMap<QString, QModelIndex> itemsToDelete;
|
|
|
|
|
for (const QModelIndex &index : selected) {
|
|
|
|
|
QStandardItem* item = model->itemFromIndex(index);
|
|
|
|
|
if (item) {
|
|
|
|
|
QString tid = item->data(Qt::UserRole + 2).toString();
|
|
|
|
|
if (tid.isEmpty()) {
|
|
|
|
|
tid = item->text().split(" (").first().trimmed();
|
|
|
|
|
}
|
|
|
|
|
itemsToDelete.insert(tid, index);
|
|
|
|
|
// qDebug() << "准备删除订单:" << tid << "行号:" << index.row();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 根据视图类型调用对应的数据库删除函数
|
|
|
|
|
bool dbSuccess = false;
|
|
|
|
|
QList<QString> tidList = itemsToDelete.keys();
|
|
|
|
|
|
|
|
|
|
if (treeView == ui.order_tree_view) {
|
|
|
|
|
dbSuccess = g_config->remove_accept_orders(tidList);
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.screen_tree_view) {
|
|
|
|
|
dbSuccess = g_config->remove_screen_orders(tidList);
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.success_tree_view) {
|
|
|
|
|
dbSuccess = g_config->remove_success_orders(tidList);
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.failed_tree_view) {
|
|
|
|
|
dbSuccess = g_config->remove_failed_orders(tidList);
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.rebet_tree_view) {
|
|
|
|
|
dbSuccess = g_config->remove_rebet_orders(tidList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!dbSuccess) {
|
|
|
|
|
QMessageBox::warning(this, "警告", "删除数据库记录失败!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 从后往前删除模型项
|
|
|
|
|
QList<QModelIndex> sortedIndexes = itemsToDelete.values();
|
|
|
|
|
std::sort(sortedIndexes.begin(), sortedIndexes.end(),
|
|
|
|
|
[](const QModelIndex &a, const QModelIndex &b) {
|
|
|
|
|
return a.row() > b.row();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 禁用视图刷新以提高性能
|
|
|
|
|
treeView->setUpdatesEnabled(false);
|
|
|
|
|
|
|
|
|
|
for (const QModelIndex &index : sortedIndexes) {
|
|
|
|
|
QModelIndex parent = index.parent();
|
|
|
|
|
if (parent.isValid()) {
|
|
|
|
|
// 分组模式
|
|
|
|
|
QStandardItem* parentItem = model->itemFromIndex(parent);
|
|
|
|
|
if (parentItem) {
|
|
|
|
|
// qDebug() << "删除分组子项:" << index.row() << "父项:" << parent.row();
|
|
|
|
|
parentItem->removeRow(index.row());
|
|
|
|
|
|
|
|
|
|
// 更新分组标题
|
|
|
|
|
QString groupText = parentItem->text().split(" (").first().trimmed();
|
|
|
|
|
parentItem->setText(QString("%1 (%2)").arg(groupText).arg(parentItem->rowCount()));
|
|
|
|
|
|
|
|
|
|
// 空分组处理
|
|
|
|
|
if (parentItem->rowCount() == 0) {
|
|
|
|
|
model->removeRow(parent.row());
|
|
|
|
|
// qDebug() << "移除空分组:" << parent.row();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 非分组模式
|
|
|
|
|
// qDebug() << "删除独立行:" << index.row();
|
|
|
|
|
model->removeRow(index.row());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 重新启用视图刷新
|
|
|
|
|
treeView->setUpdatesEnabled(true);
|
|
|
|
|
|
|
|
|
|
// 只更新变化的部分,而不是重置整个视图
|
|
|
|
|
treeView->viewport()->update();
|
|
|
|
|
// qDebug() << "删除完成,当前模型行数:" << model->rowCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CrownClient::clearTreeView(QTreeView* treeView)
|
|
|
|
|
{
|
|
|
|
|
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(treeView->model());
|
|
|
|
|
if (!model) return;
|
|
|
|
|
|
|
|
|
|
// 根据视图类型清空对应数据库表
|
|
|
|
|
bool dbSuccess = false;
|
|
|
|
|
if (treeView == ui.order_tree_view) {
|
|
|
|
|
dbSuccess = g_config->clear_accept_orders();
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.screen_tree_view) {
|
|
|
|
|
dbSuccess = g_config->clear_screen_orders();
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.success_tree_view) {
|
|
|
|
|
dbSuccess = g_config->clear_success_orders();
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.failed_tree_view) {
|
|
|
|
|
dbSuccess = g_config->clear_failed_orders();
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.rebet_tree_view) {
|
|
|
|
|
dbSuccess = g_config->clear_rebet_orders();
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.log_tree_view) {
|
|
|
|
|
model->clear();
|
|
|
|
|
model->setHorizontalHeaderLabels({ "时间","类型","日志" });
|
|
|
|
|
treeView->reset();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbSuccess) {
|
|
|
|
|
model->clear();
|
|
|
|
|
|
|
|
|
|
// 重新设置表头
|
|
|
|
|
if (treeView == ui.order_tree_view) {
|
|
|
|
|
model->setHorizontalHeaderLabels({ "单号/场次","下注时间","接收时间","会员/代理","项目","类型","联赛/队伍","下注","盘口","赔率","金额" });
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.screen_tree_view) {
|
|
|
|
|
model->setHorizontalHeaderLabels({ "单号/场次","下注时间","会员/代理","项目","类型","联赛/队伍","下注","盘口","赔率","金额","原因" });
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.success_tree_view) {
|
|
|
|
|
model->setHorizontalHeaderLabels({ "单号/场次","跟单时间","会员/代理","项目","类型","联赛/队伍","下注","盘口","赔率","金额" });
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.failed_tree_view) {
|
|
|
|
|
model->setHorizontalHeaderLabels({ "单号/场次","跟单时间","会员/代理","项目","类型","联赛/队伍","下注","盘口","赔率","金额","原因" });
|
|
|
|
|
}
|
|
|
|
|
else if (treeView == ui.rebet_tree_view) {
|
|
|
|
|
model->setHorizontalHeaderLabels({ "单号/场次","跟单时间","会员/代理","项目","类型","联赛/队伍","下注","盘口","赔率","金额","原因" });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
treeView->reset();
|
|
|
|
|
// qDebug() << "清空完成:" << treeView->objectName();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
QMessageBox::warning(this, "警告", "清空数据库表失败!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CrownClient::onTrayIconActivated(QSystemTrayIcon::ActivationReason reason)
|
|
|
|
|
{
|
|
|
|
|
if (reason == QSystemTrayIcon::DoubleClick) {
|
|
|
|
|
showNormal(); // 双击托盘图标恢复窗口
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 心跳检查槽函数
|
|
|
|
|
void CrownClient::heartbeat()
|
|
|
|
|
{
|
|
|
|
|
VMProtectBegin("Heartbeat_Check");
|
|
|
|
|
|
|
|
|
|
QString result;
|
|
|
|
|
bool heartbeatResult = g_verify->Heartbeat(result);
|
|
|
|
|
|
|
|
|
|
if (!heartbeatResult) {
|
|
|
|
|
// 心跳失败,可以记录日志但不立即退出
|
|
|
|
|
qDebug() << "心跳失败:" << result;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-17 16:31:54 +08:00
|
|
|
// 检查授权到期时间;永久授权和点数计费没有到期日,GetDueTime 是占位日期,不会走到这里
|
|
|
|
|
QDateTime dueTime = g_verify->GetDueTime();
|
|
|
|
|
if (dueTime.isValid() && dueTime.msecsTo(QDateTime::currentDateTime()) >= 0) {
|
2026-10-10 19:15:31 +08:00
|
|
|
QMessageBox::critical(nullptr, "错误", "授权已到期!");
|
|
|
|
|
QApplication::quit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VMProtectEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CrownClient::push_disconnected()
|
|
|
|
|
{
|
|
|
|
|
PushMsg *worker = new PushMsg();
|
|
|
|
|
QThread *workerThread = new QThread();
|
|
|
|
|
|
|
|
|
|
worker->moveToThread(workerThread);
|
|
|
|
|
|
|
|
|
|
// 连接信号槽
|
|
|
|
|
connect(workerThread, &QThread::started, [worker]() {
|
|
|
|
|
//"-4826387471"
|
|
|
|
|
//worker->push("account_dissconnected", "-4826387471", QMap<QString, QString>());
|
|
|
|
|
worker->push("account_dissconnected", g_config->notice_account(), QMap<QString, QString>());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(worker, &PushMsg::resultReady, [](const QString &result) {
|
|
|
|
|
// qDebug() << "Result:" << result;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(worker, &PushMsg::resultReady, workerThread, &QThread::quit);
|
|
|
|
|
connect(workerThread, &QThread::finished, worker, &PushMsg::deleteLater);
|
|
|
|
|
connect(workerThread, &QThread::finished, workerThread, &QThread::deleteLater);
|
|
|
|
|
|
|
|
|
|
workerThread->start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CrownClient::push_reconnected()
|
|
|
|
|
{
|
|
|
|
|
PushMsg *worker = new PushMsg();
|
|
|
|
|
QThread *workerThread = new QThread();
|
|
|
|
|
|
|
|
|
|
worker->moveToThread(workerThread);
|
|
|
|
|
|
|
|
|
|
// 连接信号槽
|
|
|
|
|
connect(workerThread, &QThread::started, [worker]() {
|
|
|
|
|
worker->push("account_reconnected", g_config->notice_account(), QMap<QString, QString>());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(worker, &PushMsg::resultReady, [](const QString &result) {
|
|
|
|
|
// qDebug() << "Result:" << result;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(worker, &PushMsg::resultReady, workerThread, &QThread::quit);
|
|
|
|
|
connect(workerThread, &QThread::finished, worker, &PushMsg::deleteLater);
|
|
|
|
|
connect(workerThread, &QThread::finished, workerThread, &QThread::deleteLater);
|
|
|
|
|
|
|
|
|
|
workerThread->start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CrownClient::push_accept(QMap<QString, QString> order)
|
|
|
|
|
{
|
|
|
|
|
PushMsg *worker = new PushMsg();
|
|
|
|
|
QThread *workerThread = new QThread();
|
|
|
|
|
|
|
|
|
|
worker->moveToThread(workerThread);
|
|
|
|
|
|
|
|
|
|
// 连接信号槽
|
|
|
|
|
connect(workerThread, &QThread::started, [worker, order]() {
|
|
|
|
|
worker->push("accept_order", g_config->notice_account(), order);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(worker, &PushMsg::resultReady, [](const QString &result) {
|
|
|
|
|
// qDebug() << "Result:" << result;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(worker, &PushMsg::resultReady, workerThread, &QThread::quit);
|
|
|
|
|
connect(workerThread, &QThread::finished, worker, &PushMsg::deleteLater);
|
|
|
|
|
connect(workerThread, &QThread::finished, workerThread, &QThread::deleteLater);
|
|
|
|
|
|
|
|
|
|
workerThread->start();
|
|
|
|
|
}
|