优化导包顺序,修复颜色显示不正常的问题

This commit is contained in:
zayac 2024-01-21 17:39:48 +08:00
parent c1a143aa8e
commit 78996e841c
8 changed files with 39 additions and 29 deletions

View File

@ -1,15 +1,15 @@
import threading
import time
import schedule import schedule
import telebot import telebot
import time
import threading
from loguru import logger from loguru import logger
from telebot import types from telebot import types
from src.entity.finance import get_net_win_by_telegram_id from src.entity.finance import get_net_win_by_telegram_id
from src.entity.visual_list import text_count_by_telegram_id
from src.entity.pay_record import get_pay_failed_by_telegram_id from src.entity.pay_record import get_pay_failed_by_telegram_id
from src.entity.user import get_all_users from src.entity.user import get_all_users
from src.entity.visual_list import text_count_by_telegram_id
TOKEN = '6013830443:AAGzq1Tgtr_ZejU7bv0mab14xOwi0_64d0w' TOKEN = '6013830443:AAGzq1Tgtr_ZejU7bv0mab14xOwi0_64d0w'
bot = telebot.TeleBot(TOKEN) bot = telebot.TeleBot(TOKEN)

View File

@ -3,12 +3,11 @@ import time
import schedule import schedule
from loguru import logger from loguru import logger
from src.core.constant import BOT_TOKEN, COUNT_GROUP_ID
from src.core.message_client import send_message
from src.core.util import get_curr_day from src.core.util import get_curr_day
from src.entity.finance import get_net_win_by_user from src.entity.finance import get_net_win_by_user
from src.entity.pay_record import get_pay_failed_by_user from src.entity.pay_record import get_pay_failed_by_user
from src.core.constant import BOT_TOKEN, COUNT_GROUP_ID
from src.core.message_client import send_message
from src.entity.user import get_user_by_username_and_password from src.entity.user import get_user_by_username_and_password
from src.entity.visual_list import text_count_by_user from src.entity.visual_list import text_count_by_user

View File

@ -1,14 +1,15 @@
import time
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from dataclasses import dataclass from dataclasses import dataclass
from typing import List from typing import List
from loguru import logger
from src.core.api_request import account_post from src.core.api_request import account_post
from src.core.constant import BANNER_URL, BOT_TOKEN, GROUP_ID from src.core.constant import BANNER_URL, BOT_TOKEN, GROUP_ID
from src.core.message_client import send_message from src.core.message_client import send_message
from src.core.util import get_curr_day from src.core.util import get_curr_day
from src.entity.account import Account from src.entity.account import Account
import time
from src.entity.member import get_today_new_member_list from src.entity.member import get_today_new_member_list
from src.entity.pay_record import get_latest_deposit_user from src.entity.pay_record import get_latest_deposit_user
from src.entity.user import User from src.entity.user import User
@ -47,7 +48,6 @@ def query_banner_info(account: Account):
try: try:
date = get_curr_day() date = get_curr_day()
banner_info = get_banner_info(account) banner_info = get_banner_info(account)
from loguru import logger
logger.debug(f'{account.name}请求成功:{banner_info}') logger.debug(f'{account.name}请求成功:{banner_info}')
logger.info( logger.info(
f'{time.strftime("%Y-%m-%d %H:%M:%S")} {account.name}:注册:{banner_info.registerMembers},首存:{banner_info.firstDepositNum},负盈利:{banner_info.netWinLose},有效:{banner_info.effectiveNew},活跃:{banner_info.activeMembers}') f'{time.strftime("%Y-%m-%d %H:%M:%S")} {account.name}:注册:{banner_info.registerMembers},首存:{banner_info.firstDepositNum},负盈利:{banner_info.netWinLose},有效:{banner_info.effectiveNew},活跃:{banner_info.activeMembers}')
@ -87,4 +87,4 @@ def query_banner_info(account: Account):
def get_banner_info_by_user(user: User) -> List[BannerInfo]: def get_banner_info_by_user(user: User) -> List[BannerInfo]:
with ThreadPoolExecutor(max_workers=len(user.accounts)) as executor: with ThreadPoolExecutor(max_workers=len(user.accounts)) as executor:
futures = [executor.submit(get_banner_info, account) for account in user.accounts] futures = [executor.submit(get_banner_info, account) for account in user.accounts]
return [future.result() for future in futures] return [future.result() for future in futures]

View File

@ -6,11 +6,11 @@ from typing import Dict, List, Optional
from src import logger from src import logger
from src.core import api_request, util from src.core import api_request, util
from src.core.constant import PAY_RECORD_URL, PAY_RECORD_LIST_URL from src.core.constant import PAY_RECORD_LIST_URL, PAY_RECORD_URL
from src.core.util import get_curr_day, get_first_day_month from src.core.util import get_curr_day, get_first_day_month
from src.entity.account import Account from src.entity.account import Account
from src.entity.member import (async_get_member_detail_by_name, from src.entity.member import (MemberList, async_get_member_detail_by_name,
get_member_by_name, get_member_list, MemberList) get_member_by_name, get_member_list)
from src.entity.user import User, get_user_by_telegram_id from src.entity.user import User, get_user_by_telegram_id

View File

@ -1,7 +1,7 @@
from dataclasses import dataclass from dataclasses import dataclass
from typing import List from typing import List
from cachetools import cached, TTLCache
from cachetools import TTLCache, cached
from sqlalchemy import String, func from sqlalchemy import String, func
from sqlalchemy.dialects.mssql import TINYINT from sqlalchemy.dialects.mssql import TINYINT
from sqlalchemy.orm import Mapped, mapped_column, relationship from sqlalchemy.orm import Mapped, mapped_column, relationship

View File

@ -1,5 +1,6 @@
from PyQt6.QtCore import QObject, pyqtSignal from PyQt6.QtCore import QObject, pyqtSignal
class GlobalSignals(QObject): class GlobalSignals(QObject):
user_data_updated = pyqtSignal() user_data_updated = pyqtSignal()

View File

@ -1,13 +1,15 @@
import configparser import configparser
import os import os
import time
from loguru import logger from loguru import logger
from PyQt6.QtCore import QDate, QDateTime, Qt, QThreadPool, QTime, QTimer from PyQt6.QtCore import QDate, QDateTime, Qt, QThreadPool, QTime, QTimer
from PyQt6.QtGui import QColor, QIcon, QAction from PyQt6.QtGui import QAction, QColor, QIcon
from PyQt6.QtWidgets import (QApplication, QCheckBox, QDateEdit, QHBoxLayout, from PyQt6.QtWidgets import (QApplication, QCheckBox, QDateEdit, QHBoxLayout,
QHeaderView, QMainWindow, QPushButton, QHeaderView, QMainWindow, QMenu, QMessageBox,
QSizePolicy, QTableWidget, QTableWidgetItem, QPushButton, QSizePolicy, QSystemTrayIcon,
QTabWidget, QTextEdit, QVBoxLayout, QWidget, QMessageBox, QSystemTrayIcon, QMenu) QTableWidget, QTableWidgetItem, QTabWidget,
QTextEdit, QVBoxLayout, QWidget)
from src.core.message_client import send_message from src.core.message_client import send_message
from src.core.util import convert_data, resource_path from src.core.util import convert_data, resource_path
@ -116,14 +118,15 @@ class Application(QMainWindow):
def init_table_data(self): def init_table_data(self):
# 初始化表格数据 # 初始化表格数据
# 例如,加载账户数据并更新表格 data = self.query_initial_data(self.user)
for account in self.user.accounts: for row in data:
data = self.query_initial_data(account) time_str = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
self.update_table(account.username, data) self.update_table(row.agentCode, [time_str, row.registerMembers, row.firstDepositNum, row.netWinLose,
row.effectiveNew, row.activeMembers])
def query_initial_data(self, account): def query_initial_data(self, account):
# 实际实现应该根据您的业务逻辑来定义 # 实际实现应该根据您的业务逻辑来定义
return ReportTask.query_data_for_account(account) return ReportTask.query_data_for_user(account)
def setup_report_timer(self): def setup_report_timer(self):
self.report_timer = QTimer(self) self.report_timer = QTimer(self)
@ -201,9 +204,10 @@ class Application(QMainWindow):
def update_date_edit(self): def update_date_edit(self):
# 更新日期选择器的日期为当前日期 # 更新日期选择器的日期为当前日期
self.dateEdit.setDate(QDate.currentDate()) self.dateEdit.setDate(QDate.currentDate())
# 强制刷新控件
self.dateEdit.update()
# 更新日期范围 # 更新日期范围
self.update_date_range() self.update_date_range()
print(self.dateEdit.date())
# 设置定时器每24小时触发一次 # 设置定时器每24小时触发一次
self.date_update_timer.start(86400000) self.date_update_timer.start(86400000)
@ -330,7 +334,7 @@ class Application(QMainWindow):
for col, cell_data in enumerate(data): for col, cell_data in enumerate(data):
cell = self.create_table_cell(cell_data, table, col) cell = self.create_table_cell(cell_data, table, col)
# 注意这里我们使用 row_count 而不是 0 # 使用 row_count 而不是 0
table.setItem(row_count, col, cell) table.setItem(row_count, col, cell)
self.handle_data_change(table, cell_data, col, account_username, notifications) self.handle_data_change(table, cell_data, col, account_username, notifications)
@ -354,7 +358,7 @@ class Application(QMainWindow):
def update_cell_color(self, table, col, count_change): def update_cell_color(self, table, col, count_change):
# 更新单元格颜色 # 更新单元格颜色
cell = table.item(0, col) cell = table.item(table.rowCount() - 1, col)
if count_change > 0: if count_change > 0:
cell.setForeground(QColor(Qt.GlobalColor.green)) cell.setForeground(QColor(Qt.GlobalColor.green))
elif count_change < 0: elif count_change < 0:

View File

@ -1,8 +1,9 @@
import time import time
from PyQt6.QtCore import QObject, QRunnable, pyqtSignal from PyQt6.QtCore import QObject, QRunnable, pyqtSignal
from src.entity.banner_info import get_banner_info
from src.entity.finance import get_net_win_by_user, get_adjusted_salary from src.entity.banner_info import get_banner_info, get_banner_info_by_user
from src.entity.finance import get_adjusted_salary, get_net_win_by_user
from src.entity.pay_record import get_pay_failed_by_user from src.entity.pay_record import get_pay_failed_by_user
from src.entity.visual_list import text_count_by_user from src.entity.visual_list import text_count_by_user
@ -30,6 +31,11 @@ class ReportTask(QRunnable):
return [time_str, banner_info.registerMembers, banner_info.firstDepositNum, banner_info.netWinLose, return [time_str, banner_info.registerMembers, banner_info.firstDepositNum, banner_info.netWinLose,
banner_info.effectiveNew, banner_info.activeMembers] banner_info.effectiveNew, banner_info.activeMembers]
@staticmethod
def query_data_for_user(user):
banner_info_res = get_banner_info_by_user(user)
return banner_info_res
class ButtonTask(QRunnable): class ButtonTask(QRunnable):
def __init__(self, query_type, selected_date_str, user): def __init__(self, query_type, selected_date_str, user):