Commit f87b375a authored by xianyang's avatar xianyang

优化用户账户 userid查询

parent 1dd3771c
......@@ -275,10 +275,14 @@ class AccountStatistics(object):
self.gift_type = gift_type
self.unique = unique
self.guild_uuid = []
self.user_list = []
def business_query(self, date, condition):
"""业务数据查询"""
if self.unique in ["user_account", "guild_account", "knapsack_account"]:
if self.user_list:
user_uuid = self.user_list[0]
condition.append(f" uuid='{user_uuid.get('uuid')}'")
u_sql = f"select uuid,type,reference_type,SUM(cast(amount as decimal(20,6)))/1000 as amount,create_time,amount_type from {date} WHERE {' and '.join(condition)} GROUP BY uuid,type,reference_type,amount_type ORDER BY create_time DESC"
else:
if self.uuid:
......@@ -340,6 +344,10 @@ class AccountStatistics(object):
total_list = []
yw_condition = self.public_query()
month, last_month, before_last_month = get_last_month()
if self.unique == "user_account":
if self.user_id:
user_sql = f"select uuid from v2_user where user_id={self.user_id}"
self.user_list = LinkMysql(env.DB_3YV2).query_mysql(user_sql)
with ThreadPoolExecutor(max_workers=3) as pool:
future1 = pool.submit(self.business_query, 'assets_log_' + month, yw_condition)
future2 = pool.submit(self.business_query, 'assets_log_' + last_month, yw_condition)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment